forked from openlp/openlp
Added ImageToolBar to show what I am thinking
Cleanup mainwindow from mark 1 attempt. Fix bug in Thememanager so themes are not deleted
This commit is contained in:
parent
7927080838
commit
560584d8f6
@ -253,7 +253,7 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
def onDeleteClick(self):
|
||||
raise NotImplementedError(u'MediaManagerItem.onDeleteClick needs to be defined by the plugin')
|
||||
|
||||
def generateSlideData(self):
|
||||
def generateSlideData(self, item):
|
||||
raise NotImplementedError(u'MediaManagerItem.generateSlideData needs to be defined by the plugin')
|
||||
|
||||
def onPreviewClick(self):
|
||||
|
@ -28,7 +28,7 @@ class OpenLPToolbar(QtGui.QToolBar):
|
||||
Lots of toolbars around the place, so it makes sense to have a common way to manage them
|
||||
"""
|
||||
def __init__(self, parent):
|
||||
QtGui.QToolBar.__init__(self, parent)
|
||||
QtGui.QToolBar.__init__(self, None)
|
||||
# useful to be able to reuse button icons...
|
||||
self.icons = {}
|
||||
self.log = logging.getLogger(u'OpenLPToolbar')
|
||||
|
@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License along with
|
||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
"""
|
||||
from slidecontroller import BaseToolbar
|
||||
from slidecontrollermanager import SlideControllerManager
|
||||
from maindisplay import MainDisplay
|
||||
from amendthemeform import AmendThemeForm
|
||||
@ -32,5 +33,5 @@ from servicemanager import ServiceManager
|
||||
from thememanager import ThemeManager
|
||||
from mainwindow import MainWindow
|
||||
|
||||
__all__ = ['SplashScreen', 'AboutForm', 'SettingsForm',
|
||||
__all__ = ['SplashScreen', 'AboutForm', 'SettingsForm', 'BaseToolbar'
|
||||
'MainWindow', 'MainDisplay', 'SlideController', 'ServiceManager', 'ThemeManager', 'AmendThemeForm']
|
||||
|
@ -169,11 +169,8 @@ class MainWindow(object):
|
||||
self.ControlSplitter.setObjectName(u'ControlSplitter')
|
||||
self.MainContentLayout.addWidget(self.ControlSplitter)
|
||||
# Create slide controllers
|
||||
PreviewController = SlideController(self)
|
||||
LiveController = SlideController(self, True)
|
||||
self.slideControllerManager.add_controllers(u'base', PreviewController, LiveController)
|
||||
self.PreviewController = PreviewController
|
||||
self.LiveController = LiveController
|
||||
self.PreviewController = SlideController(self)
|
||||
self.LiveController = SlideController(self, True)
|
||||
# Create menu
|
||||
self.MenuBar = QtGui.QMenuBar(self.mainWindow)
|
||||
self.MenuBar.setGeometry(QtCore.QRect(0, 0, 1087, 27))
|
||||
|
@ -166,7 +166,17 @@ class SlideController(QtGui.QWidget):
|
||||
self.PreviewListView.setSpacing(0)
|
||||
self.PreviewListView.setObjectName(u'PreviewListView')
|
||||
self.ControllerLayout.addWidget(self.PreviewListView)
|
||||
self.defineToolbar()
|
||||
# Plugin the Base Toolbar class
|
||||
self.BaseToolbar = BaseToolbar(self.isLive)
|
||||
self.Toolbar = self.BaseToolbar.getToolbar()
|
||||
self.ControllerLayout.addWidget(self.Toolbar)
|
||||
sizeToolbarPolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Fixed)
|
||||
sizeToolbarPolicy.setHorizontalStretch(0)
|
||||
sizeToolbarPolicy.setVerticalStretch(0)
|
||||
sizeToolbarPolicy.setHeightForWidth(
|
||||
self.Toolbar.sizePolicy().hasHeightForWidth())
|
||||
self.Toolbar.setSizePolicy(sizeToolbarPolicy)
|
||||
# Screen preview area
|
||||
self.PreviewFrame = QtGui.QFrame(self.Splitter)
|
||||
self.PreviewFrame.setGeometry(QtCore.QRect(0, 0, 250, 190))
|
||||
@ -194,21 +204,46 @@ class SlideController(QtGui.QWidget):
|
||||
self.SlidePreview.setScaledContents(True)
|
||||
self.SlidePreview.setObjectName(u'SlidePreview')
|
||||
self.grid.addWidget(self.SlidePreview, 0, 0, 1, 1)
|
||||
# Some events
|
||||
QtCore.QObject.connect(self.PreviewListView,
|
||||
QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected)
|
||||
QtCore.SIGNAL(u'clicked(QModelIndex)'), self.BaseToolbar.onSlideSelected)
|
||||
QtCore.QObject.connect(self.PreviewListView,
|
||||
QtCore.SIGNAL(u'activated(QModelIndex)'), self.onSlideSelected)
|
||||
QtCore.SIGNAL(u'activated(QModelIndex)'), self.BaseToolbar.onSlideSelected)
|
||||
# Add Late Arrivals
|
||||
self.BaseToolbar.PreviewListView = self.PreviewListView
|
||||
self.BaseToolbar.PreviewListData = self.PreviewListData
|
||||
self.BaseToolbar.SlidePreview = self.SlidePreview
|
||||
self.BaseToolbar.mainDisplay = self.parent.mainDisplay
|
||||
|
||||
def addServiceItem(self, item):
|
||||
self.BaseToolbar.addServiceItem(item)
|
||||
|
||||
def addServiceManagerItem(self, item, slideno):
|
||||
self.BaseToolbar.addServiceManagerItem(item, slideno)
|
||||
|
||||
class BaseToolbar(object):
|
||||
|
||||
def __init__(self, isLive):
|
||||
self.Toolbar = None
|
||||
self.PreviewListView = QtGui.QListWidget()
|
||||
self.PreviewListData = None
|
||||
self.isLive = isLive
|
||||
self.defineToolbar()
|
||||
|
||||
def getToolbar(self):
|
||||
return self.Toolbar
|
||||
|
||||
def defineToolbar(self):
|
||||
# Controller toolbar
|
||||
self.Toolbar = OpenLPToolbar(self.Controller)
|
||||
#self.Toolbar = OpenLPToolbar(self.Controller)
|
||||
self.Toolbar = OpenLPToolbar(self)
|
||||
sizeToolbarPolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Fixed)
|
||||
sizeToolbarPolicy.setHorizontalStretch(0)
|
||||
sizeToolbarPolicy.setVerticalStretch(0)
|
||||
sizeToolbarPolicy.setHeightForWidth(
|
||||
self.Toolbar.sizePolicy().hasHeightForWidth())
|
||||
self.Toolbar.setSizePolicy(sizeToolbarPolicy)
|
||||
|
||||
if self.isLive:
|
||||
self.Toolbar.addToolbarButton(u'First Slide',
|
||||
u':/slides/slide_first.png',
|
||||
@ -232,8 +267,6 @@ class SlideController(QtGui.QWidget):
|
||||
u':/slides/slide_close.png',
|
||||
translate(u'SlideController', u'Close Screen'),
|
||||
self.onBlankScreen)
|
||||
self.Toolbar.setSizePolicy(sizeToolbarPolicy)
|
||||
self.ControllerLayout.addWidget(self.Toolbar)
|
||||
|
||||
def onSlideSelectedFirst(self):
|
||||
"""
|
||||
@ -311,7 +344,7 @@ class SlideController(QtGui.QWidget):
|
||||
if self.isLive:
|
||||
no = frame[1]
|
||||
LiveFrame = self.serviceitem.frames[no][u'image']
|
||||
self.parent.mainDisplay.frameView(LiveFrame)
|
||||
self.mainDisplay.frameView(LiveFrame)
|
||||
|
||||
def addServiceItem(self, serviceitem):
|
||||
"""
|
||||
|
@ -175,30 +175,33 @@ class ThemeManager(QtGui.QWidget):
|
||||
|
||||
def onEditTheme(self):
|
||||
items = self.ThemeListView.selectedIndexes()
|
||||
for item in items:
|
||||
data = self.themeData.getValue(item)
|
||||
self.amendThemeForm.loadTheme(data[3])
|
||||
self.amendThemeForm.exec_()
|
||||
if len(items) > 0:
|
||||
for item in items:
|
||||
print item
|
||||
data = self.themeData.getValue(item)
|
||||
self.amendThemeForm.loadTheme(data[3])
|
||||
self.amendThemeForm.exec_()
|
||||
|
||||
def onDeleteTheme(self):
|
||||
items = self.ThemeListView.selectedIndexes()
|
||||
theme = u''
|
||||
for item in items:
|
||||
data = self.themeData.getValue(item)
|
||||
theme = data[3]
|
||||
th = theme + u'.png'
|
||||
try:
|
||||
os.remove(os.path.join(self.path, th))
|
||||
except:
|
||||
#if not present do not worry
|
||||
pass
|
||||
try:
|
||||
shutil.rmtree(os.path.join(self.path, theme))
|
||||
except:
|
||||
#if not present do not worry
|
||||
pass
|
||||
self.themeData.clearItems()
|
||||
self.loadThemes()
|
||||
if len(items) > 0:
|
||||
theme = u''
|
||||
for item in items:
|
||||
data = self.themeData.getValue(item)
|
||||
theme = data[3]
|
||||
th = theme + u'.png'
|
||||
try:
|
||||
os.remove(os.path.join(self.path, th))
|
||||
except:
|
||||
#if not present do not worry
|
||||
pass
|
||||
try:
|
||||
shutil.rmtree(os.path.join(self.path, theme))
|
||||
except:
|
||||
#if not present do not worry
|
||||
pass
|
||||
self.themeData.clearItems()
|
||||
self.loadThemes()
|
||||
|
||||
def onExportTheme(self):
|
||||
pass
|
||||
|
@ -57,8 +57,6 @@ class BibleMediaItem(MediaManagerItem):
|
||||
self.TranslationContext = u'BiblePlugin'
|
||||
self.PluginTextShort = u'Bible'
|
||||
self.ConfigSection = u'bibles'
|
||||
# self.OnNewPrompt = u'Select Image(s)'
|
||||
# self.OnNewFileMasks = u'Images (*.jpg *jpeg *.gif *.png *.bmp)'
|
||||
MediaManagerItem.__init__(self, parent, icon, title)
|
||||
self.search_results = {} # place to store the search results
|
||||
QtCore.QObject.connect(Receiver().get_receiver(),
|
||||
|
@ -18,4 +18,4 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
"""
|
||||
from mediaitem import ImageMediaItem
|
||||
from imageslidecontroller import ImageSlideController
|
||||
from imageslidecontroller import ImageToolbar
|
||||
|
@ -22,13 +22,23 @@ import os
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from openlp.core.lib import OpenLPToolbar, translate
|
||||
from openlp.core.ui import SlideController
|
||||
from openlp.core.ui.slidecontroller import BaseToolbar
|
||||
|
||||
class ImageSlideController(SlideController):
|
||||
class ImageToolbar(BaseToolbar):
|
||||
|
||||
def __init__(self, isLive):
|
||||
self.Toolbar = None
|
||||
self.PreviewListView = QtGui.QListWidget()
|
||||
self.PreviewListData = None
|
||||
self.isLive = isLive
|
||||
self.defineToolbar()
|
||||
|
||||
def getToolbar(self):
|
||||
return self.Toolbar
|
||||
|
||||
def defineToolbar(self):
|
||||
# Controller toolbar
|
||||
self.Toolbar = OpenLPToolbar(self.Controller)
|
||||
#self.Toolbar = OpenLPToolbar(self.Controller)
|
||||
sizeToolbarPolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Fixed)
|
||||
sizeToolbarPolicy.setHorizontalStretch(0)
|
||||
@ -62,10 +72,32 @@ class ImageSlideController(SlideController):
|
||||
self.Toolbar.addToolbarButton(u'Start Loop',
|
||||
u':/slides/slide_last.png',
|
||||
translate(u'SlideController', u'Start continuous loop'),
|
||||
self.onSlideSelectedLast)
|
||||
self.onStartLoop)
|
||||
self.Toolbar.addToolbarButton(u'Stop Loop',
|
||||
u':/slides/slide_last.png',
|
||||
translate(u'SlideController', u'Start continuous loop'),
|
||||
self.onSlideSelectedLast)
|
||||
self.onStopLoop)
|
||||
self.Toolbar.setSizePolicy(sizeToolbarPolicy)
|
||||
self.ControllerLayout.addWidget(self.Toolbar)
|
||||
|
||||
def onStartLoop(self):
|
||||
"""
|
||||
Go to the last slide.
|
||||
"""
|
||||
row = self.PreviewListData.createIndex(
|
||||
self.PreviewListData.rowCount() - 1, 0)
|
||||
if row.isValid():
|
||||
self.PreviewListView.selectionModel().setCurrentIndex(row,
|
||||
QtGui.QItemSelectionModel.SelectCurrent)
|
||||
self.onSlideSelected(row)
|
||||
|
||||
def onStopLoop(self):
|
||||
"""
|
||||
Go to the last slide.
|
||||
"""
|
||||
row = self.PreviewListData.createIndex(
|
||||
self.PreviewListData.rowCount() - 1, 0)
|
||||
if row.isValid():
|
||||
self.PreviewListView.selectionModel().setCurrentIndex(row,
|
||||
QtGui.QItemSelectionModel.SelectCurrent)
|
||||
self.onSlideSelected(row)
|
||||
|
@ -22,7 +22,7 @@ import os
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from openlp.core.lib import MediaManagerItem, ServiceItem, translate, BaseListWithDnD
|
||||
from openlp.plugins.images.lib.imageslidecontroller import ImageSlideController
|
||||
from openlp.plugins.images.lib.imageslidecontroller import ImageToolbar
|
||||
|
||||
# We have to explicitly create separate classes for each plugin
|
||||
# in order for DnD to the Service manager to work correctly.
|
||||
@ -56,9 +56,9 @@ class ImageMediaItem(MediaManagerItem):
|
||||
MediaManagerItem.__init__(self, parent, icon, title)
|
||||
#create and install our own slide controllers
|
||||
#a=c
|
||||
live_controller = ImageSlideController(self.parent.slideManager.parent, True)
|
||||
preview_controller = ImageSlideController(self.parent.slideManager.parent)
|
||||
self.parent.slideManager.add_controllers(u'image', preview_controller, live_controller)
|
||||
# live_controller = ImageSlideController(self.parent.slideManager.parent, True)
|
||||
# preview_controller = ImageSlideController(self.parent.slideManager.parent)
|
||||
# self.parent.slideManager.add_controllers(u'image', preview_controller, live_controller)
|
||||
|
||||
def initialise(self):
|
||||
self.ListView.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
|
||||
|
Loading…
Reference in New Issue
Block a user