Fix bug #596541 hide theme combo for global themes

This commit is contained in:
Tim Bentley 2010-06-26 08:19:30 +01:00
parent 4820d5d15f
commit b59b2bdafa
3 changed files with 26 additions and 14 deletions

View File

@ -33,7 +33,7 @@ log = logging.getLogger(__name__)
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import OpenLPToolbar, ServiceItem, context_menu_action, \ from openlp.core.lib import OpenLPToolbar, ServiceItem, context_menu_action, \
Receiver, build_icon, ItemCapabilities, SettingsManager, translate Receiver, build_icon, ItemCapabilities, SettingsManager, translate, ThemeLevel
from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm
from openlp.core.utils import AppLocation from openlp.core.utils import AppLocation
@ -134,15 +134,13 @@ class ServiceManager(QtGui.QWidget):
self.ThemeLabel = QtGui.QLabel(translate('ServiceManager', 'Theme:'), self.ThemeLabel = QtGui.QLabel(translate('ServiceManager', 'Theme:'),
self) self)
self.ThemeLabel.setMargin(3) self.ThemeLabel.setMargin(3)
self.Toolbar.addWidget(self.ThemeLabel) self.Toolbar.addToolbarWidget(u'ThemeLabel', self.ThemeLabel)
self.ThemeComboBox = QtGui.QComboBox(self.Toolbar) self.ThemeComboBox = QtGui.QComboBox(self.Toolbar)
self.ThemeComboBox.setToolTip(translate('ServiceManager', self.ThemeComboBox.setToolTip(translate('ServiceManager',
'Select a theme for the service')) 'Select a theme for the service'))
self.ThemeComboBox.setSizeAdjustPolicy( self.ThemeComboBox.setSizeAdjustPolicy(
QtGui.QComboBox.AdjustToContents) QtGui.QComboBox.AdjustToContents)
self.ThemeWidget = QtGui.QWidgetAction(self.Toolbar) self.Toolbar.addToolbarWidget(u'ThemeWidget', self.ThemeComboBox)
self.ThemeWidget.setDefaultWidget(self.ThemeComboBox)
self.Toolbar.addAction(self.ThemeWidget)
self.Layout.addWidget(self.Toolbar) self.Layout.addWidget(self.Toolbar)
# Create the service manager list # Create the service manager list
self.ServiceManagerList = ServiceManagerList(self) self.ServiceManagerList = ServiceManagerList(self)
@ -214,6 +212,8 @@ class ServiceManager(QtGui.QWidget):
QtCore.SIGNAL(u'servicemanager_list_request'), self.listRequest) QtCore.SIGNAL(u'servicemanager_list_request'), self.listRequest)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'config_updated'), self.regenerateServiceItems) QtCore.SIGNAL(u'config_updated'), self.regenerateServiceItems)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'theme_update_global'), self.themeChange)
# Last little bits of setting up # Last little bits of setting up
self.service_theme = unicode(QtCore.QSettings().value( self.service_theme = unicode(QtCore.QSettings().value(
self.parent.serviceSettingsSection + u'/service theme', self.parent.serviceSettingsSection + u'/service theme',
@ -756,6 +756,18 @@ class ServiceManager(QtGui.QWidget):
QtCore.QVariant(self.service_theme)) QtCore.QVariant(self.service_theme))
self.regenerateServiceItems() self.regenerateServiceItems()
def themeChange(self):
"""
The theme may have changed in the settings dialog so make
sure the theme combo box is in the correct state.
"""
if self.parent.RenderManager.theme_level == ThemeLevel.Global:
self.Toolbar.actions[u'ThemeLabel'].setVisible(False)
self.Toolbar.actions[u'ThemeWidget'].setVisible(False)
else:
self.Toolbar.actions[u'ThemeLabel'].setVisible(True)
self.Toolbar.actions[u'ThemeWidget'].setVisible(True)
def regenerateServiceItems(self): def regenerateServiceItems(self):
""" """
Rebuild the service list as things have changed and a Rebuild the service list as things have changed and a

View File

@ -513,21 +513,21 @@ class SlideController(QtGui.QWidget):
""" """
log.debug(u'processManagerItem') log.debug(u'processManagerItem')
self.onStopLoop() self.onStopLoop()
#If old item was a command tell it to stop #If old item was a command tell it to stop
if self.serviceItem: if self.serviceItem:
if self.serviceItem.is_command(): if self.serviceItem.is_command():
Receiver.send_message(u'%s_stop' % Receiver.send_message(u'%s_stop' %
self.serviceItem.name.lower(), [serviceItem, self.isLive]) self.serviceItem.name.lower(), [serviceItem, self.isLive])
if self.serviceItem.is_media(): if self.serviceItem.is_media():
self.onMediaStop() self.onMediaStop()
if serviceItem.is_media(): if serviceItem.is_media():
self.onMediaStart(serviceItem) self.onMediaStart(serviceItem)
if self.isLive: # if self.isLive:
blanked = self.blankButton.isChecked() # blanked = self.blankButton.isChecked()
else: # else:
blanked = False # blanked = False
Receiver.send_message(u'%s_start' % serviceItem.name.lower(), # Receiver.send_message(u'%s_start' % serviceItem.name.lower(),
[serviceItem, self.isLive, blanked, slideno]) # [serviceItem, self.isLive, blanked, slideno])
self.slideList = {} self.slideList = {}
width = self.parent.ControlSplitter.sizes()[self.split] width = self.parent.ControlSplitter.sizes()[self.split]
#Set pointing cursor when we have somthing to point at #Set pointing cursor when we have somthing to point at

View File

@ -150,9 +150,9 @@ class ThemesTab(SettingsTab):
settings.setValue(u'global theme', settings.setValue(u'global theme',
QtCore.QVariant(self.global_theme)) QtCore.QVariant(self.global_theme))
settings.endGroup() settings.endGroup()
Receiver.send_message(u'theme_update_global', self.global_theme)
self.parent.RenderManager.set_global_theme( self.parent.RenderManager.set_global_theme(
self.global_theme, self.theme_level) self.global_theme, self.theme_level)
Receiver.send_message(u'theme_update_global', self.global_theme)
def postSetUp(self): def postSetUp(self):
Receiver.send_message(u'theme_update_global', self.global_theme) Receiver.send_message(u'theme_update_global', self.global_theme)