forked from openlp/openlp
- Themes in service item theme menu are checkable.
- Allow the user to reset the theme to the (global/service) default theme. bzr-revno: 1582
This commit is contained in:
commit
62fe00cc13
@ -676,8 +676,17 @@ 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)
|
||||||
|
# Set up the theme menu.
|
||||||
if serviceItem[u'service_item'].is_text():
|
if serviceItem[u'service_item'].is_text():
|
||||||
self.themeMenu.menuAction().setVisible(True)
|
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))
|
action = self.menu.exec_(self.serviceManagerList.mapToGlobal(point))
|
||||||
|
|
||||||
def onServiceItemNoteForm(self):
|
def onServiceItemNoteForm(self):
|
||||||
@ -1280,16 +1289,33 @@ 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')
|
||||||
|
# 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:
|
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()
|
||||||
|
|
||||||
def onThemeChangeAction(self):
|
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]
|
item = self.findServiceItem()[0]
|
||||||
self.serviceItems[item][u'service_item'].theme = theme
|
self.serviceItems[item][u'service_item'].theme = theme
|
||||||
self.regenerateServiceItems()
|
self.regenerateServiceItems()
|
||||||
|
Loading…
Reference in New Issue
Block a user