From 98614f629c1c4c96eed68271d76a30161502eaf4 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 26 May 2011 10:15:56 +0200 Subject: [PATCH 2/5] make themes in menu checkable --- openlp/core/ui/servicemanager.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 6834c8df8..82a49cc54 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -37,7 +37,8 @@ from openlp.core.lib import OpenLPToolbar, ServiceItem, Receiver, build_icon, \ ItemCapabilities, SettingsManager, translate from openlp.core.lib.theme import ThemeLevel 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.printserviceform import PrintServiceForm from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \ @@ -676,8 +677,19 @@ class ServiceManager(QtGui.QWidget): .is_capable(ItemCapabilities.AllowsVariableStartTime): self.timeAction.setVisible(True) 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) + 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)) def onServiceItemNoteForm(self): @@ -1276,10 +1288,16 @@ class ServiceManager(QtGui.QWidget): self.themeComboBox.clear() self.themeMenu.clear() self.themeComboBox.addItem(u'') + themeGroup = QtGui.QActionGroup(self.themeMenu) + themeGroup.setExclusive(True) + themeGroup.setObjectName(u'themeGroup') for theme in theme_list: self.themeComboBox.addItem(theme) - context_menu_action(self.themeMenu, None, theme, + themeAction = context_menu_action(self.themeMenu, None, theme, self.onThemeChangeAction) + themeAction.setObjectName(theme) + themeAction.setCheckable(True) + themeGroup.addAction(themeAction) find_and_set_in_combo_box(self.themeComboBox, self.service_theme) self.mainwindow.renderer.set_service_theme(self.service_theme) self.regenerateServiceItems() From b890b52a8d5d88a35e33eb02de26e5e348888998 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 27 May 2011 08:29:14 +0200 Subject: [PATCH 3/5] finished the theme menu --- openlp/core/ui/servicemanager.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index ed0de1fa8..1cf76951c 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -677,19 +677,18 @@ class ServiceManager(QtGui.QWidget): .is_capable(ItemCapabilities.AllowsVariableStartTime): self.timeAction.setVisible(True) self.themeMenu.menuAction().setVisible(False) + # Set up the theme menu. if serviceItem[u'service_item'].is_text() and \ len(self.themeMenu.actions()) > 1: self.themeMenu.menuAction().setVisible(True) + # The service item does not have a theme, check the "Default". if serviceItem[u'service_item'].theme is None: - themeAction = self.themeMenu.findChild(QtGui.QAction, u'Sunrise') + themeAction = self.themeMenu.defaultAction() else: - themeAction = self.themeMenu.findChild(QtGui.QAction, u'Sunrise') + themeAction = self.themeMenu.findChild( + QtGui.QAction, serviceItem[u'service_item'].theme) 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)) def onServiceItemNoteForm(self): @@ -1295,6 +1294,14 @@ class ServiceManager(QtGui.QWidget): themeGroup = QtGui.QActionGroup(self.themeMenu) themeGroup.setExclusive(True) themeGroup.setObjectName(u'themeGroup') + # Create a "Default" theme, which allows the user to reset the item's + # theme to the service theme or global theme. + defaultTheme = context_menu_action(self.themeMenu, None, + UiStrings().Default, self.onThemeChangeAction) + defaultTheme.setCheckable(True) + self.themeMenu.setDefaultAction(defaultTheme) + themeGroup.addAction(defaultTheme) + context_menu_separator(self.themeMenu) for theme in theme_list: self.themeComboBox.addItem(theme) themeAction = context_menu_action(self.themeMenu, None, theme, @@ -1307,7 +1314,10 @@ class ServiceManager(QtGui.QWidget): self.regenerateServiceItems() def onThemeChangeAction(self): - theme = unicode(self.sender().text()) + theme = unicode(self.sender().objectName()) + # No object name means that the "Default" theme is supposed to be used. + if not theme: + theme = None item = self.findServiceItem()[0] self.serviceItems[item][u'service_item'].theme = theme self.regenerateServiceItems() From 8a38c0b76624427896cab097e254e534f78600b8 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 27 May 2011 08:45:42 +0200 Subject: [PATCH 4/5] do not hide the menu --- openlp/core/ui/servicemanager.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 1cf76951c..30bb66115 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -678,8 +678,7 @@ class ServiceManager(QtGui.QWidget): self.timeAction.setVisible(True) self.themeMenu.menuAction().setVisible(False) # Set up the theme menu. - if serviceItem[u'service_item'].is_text() and \ - len(self.themeMenu.actions()) > 1: + if serviceItem[u'service_item'].is_text(): self.themeMenu.menuAction().setVisible(True) # The service item does not have a theme, check the "Default". if serviceItem[u'service_item'].theme is None: From 18e3cb023264367520798455e53e69050bf40607 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 27 May 2011 09:02:02 +0200 Subject: [PATCH 5/5] removed not needed import --- openlp/core/ui/servicemanager.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 30bb66115..c32567075 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -37,8 +37,7 @@ from openlp.core.lib import OpenLPToolbar, ServiceItem, Receiver, build_icon, \ ItemCapabilities, SettingsManager, translate from openlp.core.lib.theme import ThemeLevel from openlp.core.lib.ui import UiStrings, critical_error_message_box, \ - context_menu_action, context_menu_separator, find_and_set_in_combo_box, \ - checkable_action + context_menu_action, context_menu_separator, find_and_set_in_combo_box from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm from openlp.core.ui.printserviceform import PrintServiceForm from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \