Fix toolbar code to hide / add items

This commit is contained in:
Tim Bentley 2009-08-28 18:40:07 +01:00
commit 0c9fcd0571
3 changed files with 48 additions and 14 deletions

View File

@ -71,14 +71,29 @@ class OpenLPToolbar(QtGui.QToolBar):
ButtonIcon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)),
QtGui.QIcon.Normal, QtGui.QIcon.Off)
if ButtonIcon is not None:
ToolbarButton = self.addAction(ButtonIcon, title)
if slot is not None:
ToolbarButton = self.addAction(ButtonIcon, title, slot)
else:
ToolbarButton = self.addAction(ButtonIcon, title)
if tooltip is not None:
ToolbarButton.setToolTip(tooltip)
if slot is not None:
QtCore.QObject.connect(ToolbarButton, QtCore.SIGNAL(u'triggered()'), slot)
self.icons[title] = ButtonIcon
self.actions[title] = ToolbarButton
def addToolbarSeparator(self, handle):
"""
Add a Separator bar to the toolbar and store it's Handle
"""
action = self.addSeparator()
self.actions[handle] = action
def addToolbarWidget(self, handle, widget):
"""
Add a Widget to the toolbar and store it's Handle
"""
action = self.addWidget(widget)
self.actions[handle] = action
def getIconFromTitle(self, title):
"""
Search through the list of icons for an icon with a particular title,
@ -92,3 +107,11 @@ class OpenLPToolbar(QtGui.QToolBar):
else:
self.log.error(u'getIconFromTitle - no icon for %s' % title)
return QtGui.QIcon()
def makeWidgetsInvisible(self, widgets):
for widget in widgets:
self.actions[widget].setVisible(False)
def makeWidgetsVisible(self, widgets):
for widget in widgets:
self.actions[widget].setVisible(True)

View File

@ -66,6 +66,7 @@ class SlideController(QtGui.QWidget):
QtGui.QWidget.__init__(self, parent)
self.isLive = isLive
self.parent = parent
self.image_list = [u'Start Loop', u'Stop Loop', u'Loop Spearator', u'Image SpinBox']
self.Panel = QtGui.QWidget(parent.ControlSplitter)
self.Splitter = QtGui.QSplitter(self.Panel)
self.Splitter.setOrientation(QtCore.Qt.Vertical)
@ -120,13 +121,13 @@ class SlideController(QtGui.QWidget):
translate(u'SlideController', u'Move to last'),
self.onSlideSelectedLast)
if self.isLive:
self.Toolbar.addSeparator()
self.Toolbar.addToolbarSeparator(u'Close Separator')
self.Toolbar.addToolbarButton(u'Close Screen',
u':/slides/slide_close.png',
translate(u'SlideController', u'Close Screen'),
self.onBlankScreen)
if isLive:
self.Toolbar.addSeparator()
self.Toolbar.addToolbarSeparator(u'Loop Spearator')
self.Toolbar.addToolbarButton(u'Start Loop',
u':/media/media_time.png',
translate(u'SlideController', u'Start continuous loop'),
@ -135,11 +136,11 @@ class SlideController(QtGui.QWidget):
u':/media/media_stop.png',
translate(u'SlideController', u'Stop continuous loop'),
self.onStopLoop)
self.Toolbar.addSeparator()
self.DelaySpinBox = QtGui.QSpinBox(self.Toolbar)
self.SpinWidget = QtGui.QWidgetAction(self.Toolbar)
self.SpinWidget.setDefaultWidget(self.DelaySpinBox)
self.Toolbar.addAction(self.SpinWidget)
self.DelaySpinBox = QtGui.QSpinBox()
# self.SpinWidget = QtGui.QWidgetAction(self.Toolbar)
# self.SpinWidget.setDefaultWidget(self.DelaySpinBox)
# self.Toolbar.addAction(self.SpinWidget)
self.Toolbar.addToolbarWidget(u'Image SpinBox', self.DelaySpinBox)
#self.DelaySpinBox.setValue(self.parent.parent.ImageTab.loop_delay)
self.DelaySpinBox.setSuffix(translate(u'SlideController', u's'))
@ -195,8 +196,9 @@ class SlideController(QtGui.QWidget):
Allows the live toolbar to be customised
"""
if item.service_item_type == ServiceType.Text:
a = c
pass
self.Toolbar.makeWidgetsInvisible(self.image_list)
elif item.service_item_type == ServiceType.Image:
self.Toolbar.makeWidgetsVisible(self.image_list)
def enablePreviewToolBar(self, item):
"""

View File

@ -1,4 +1,13 @@
from setuptools import setup APP = ['openlp.pyw'] OPTIONS = {'argv_emulation': True, 'includes': ['sip', 'PyQt4']} setup(
from setuptools import setup
APP = ['openlp.pyw']
OPTIONS = {'argv_emulation': True, 'includes': ['sip', 'PyQt4']}
setup(
name='openlp.org',
version='1.9.0',
url='http://www.openlp.org/', app=APP, options={'py2app': OPTIONS}, setup_requires=['py2app'], )
url='http://www.openlp.org/',
app=APP,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)