make themes in menu checkable

This commit is contained in:
Andreas Preikschat 2011-05-26 10:15:56 +02:00
parent 8a32e09211
commit 98614f629c

View File

@ -37,7 +37,8 @@ from openlp.core.lib import OpenLPToolbar, ServiceItem, Receiver, build_icon, \
ItemCapabilities, SettingsManager, translate ItemCapabilities, SettingsManager, translate
from openlp.core.lib.theme import ThemeLevel from openlp.core.lib.theme import ThemeLevel
from openlp.core.lib.ui import UiStrings, critical_error_message_box, \ from openlp.core.lib.ui import UiStrings, critical_error_message_box, \
context_menu_action, context_menu_separator, find_and_set_in_combo_box context_menu_action, context_menu_separator, find_and_set_in_combo_box, \
checkable_action
from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm
from openlp.core.ui.printserviceform import PrintServiceForm from openlp.core.ui.printserviceform import PrintServiceForm
from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \ from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \
@ -676,8 +677,19 @@ class ServiceManager(QtGui.QWidget):
.is_capable(ItemCapabilities.AllowsVariableStartTime): .is_capable(ItemCapabilities.AllowsVariableStartTime):
self.timeAction.setVisible(True) self.timeAction.setVisible(True)
self.themeMenu.menuAction().setVisible(False) self.themeMenu.menuAction().setVisible(False)
if serviceItem[u'service_item'].is_text(): if serviceItem[u'service_item'].is_text() and \
len(self.themeMenu.actions()) > 1:
self.themeMenu.menuAction().setVisible(True) self.themeMenu.menuAction().setVisible(True)
if serviceItem[u'service_item'].theme is None:
themeAction = self.themeMenu.findChild(QtGui.QAction, u'Sunrise')
else:
themeAction = self.themeMenu.findChild(QtGui.QAction, u'Sunrise')
if themeAction is not None:
themeAction.setChecked(True)
print self.mainwindow.renderer.global_theme
for themeAction in self.themeMenu.actions():
themeAction.setChecked(
themeAction.text() == serviceItem[u'service_item'].theme)
action = self.menu.exec_(self.serviceManagerList.mapToGlobal(point)) action = self.menu.exec_(self.serviceManagerList.mapToGlobal(point))
def onServiceItemNoteForm(self): def onServiceItemNoteForm(self):
@ -1276,10 +1288,16 @@ class ServiceManager(QtGui.QWidget):
self.themeComboBox.clear() self.themeComboBox.clear()
self.themeMenu.clear() self.themeMenu.clear()
self.themeComboBox.addItem(u'') self.themeComboBox.addItem(u'')
themeGroup = QtGui.QActionGroup(self.themeMenu)
themeGroup.setExclusive(True)
themeGroup.setObjectName(u'themeGroup')
for theme in theme_list: for theme in theme_list:
self.themeComboBox.addItem(theme) self.themeComboBox.addItem(theme)
context_menu_action(self.themeMenu, None, theme, themeAction = context_menu_action(self.themeMenu, None, theme,
self.onThemeChangeAction) self.onThemeChangeAction)
themeAction.setObjectName(theme)
themeAction.setCheckable(True)
themeGroup.addAction(themeAction)
find_and_set_in_combo_box(self.themeComboBox, self.service_theme) find_and_set_in_combo_box(self.themeComboBox, self.service_theme)
self.mainwindow.renderer.set_service_theme(self.service_theme) self.mainwindow.renderer.set_service_theme(self.service_theme)
self.regenerateServiceItems() self.regenerateServiceItems()