← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~googol-hush/openlp/service-theme-menu into lp:openlp

 

Andreas Preikschat has proposed merging lp:~googol-hush/openlp/service-theme-menu into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~googol-hush/openlp/service-theme-menu/+merge/62613

Hello,

- Themes in service item theme menu are checkable.
- Allow the user to reset the theme to the (global/service) default theme.

http://img812.imageshack.us/img812/3108/bildschirmfoto270520110.png
-- 
https://code.launchpad.net/~googol-hush/openlp/service-theme-menu/+merge/62613
Your team OpenLP Core is requested to review the proposed merge of lp:~googol-hush/openlp/service-theme-menu into lp:openlp.
=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py	2011-05-26 17:11:22 +0000
+++ openlp/core/ui/servicemanager.py	2011-05-27 07:04:27 +0000
@@ -676,8 +676,17 @@
             .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():
             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.defaultAction()
+            else:
+                themeAction = self.themeMenu.findChild(
+                    QtGui.QAction, serviceItem[u'service_item'].theme)
+            if themeAction is not None:
+                themeAction.setChecked(True)
         action = self.menu.exec_(self.serviceManagerList.mapToGlobal(point))
 
     def onServiceItemNoteForm(self):
@@ -1280,16 +1289,33 @@
         self.themeComboBox.clear()
         self.themeMenu.clear()
         self.themeComboBox.addItem(u'')
+        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)
-            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()
 
     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()


Follow ups