forked from openlp/openlp
Service Items can now have their theme changes at run time.
This commit is contained in:
parent
5f25ffd267
commit
da4a26ef5f
@ -25,13 +25,7 @@
|
||||
|
||||
import sys
|
||||
import os
|
||||
try:
|
||||
import sqlite
|
||||
except:
|
||||
try:
|
||||
import pysqlite2
|
||||
except:
|
||||
print 'No Sqlite2 package available'
|
||||
import sqlite
|
||||
import sqlite3
|
||||
import re
|
||||
from optparse import OptionParser
|
||||
|
@ -110,12 +110,21 @@ def contextMenuAction(base, icon, text, slot):
|
||||
Utility method to help build context menus for plugins
|
||||
"""
|
||||
action = QtGui.QAction(text, base)
|
||||
action.setIcon(buildIcon(icon))
|
||||
if icon is not None:
|
||||
action.setIcon(buildIcon(icon))
|
||||
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), slot)
|
||||
return action
|
||||
|
||||
def contextMenu(base, icon, text):
|
||||
"""
|
||||
Utility method to help build context menus for plugins
|
||||
"""
|
||||
action = QtGui.QMenu(text, base)
|
||||
action.setIcon(buildIcon(icon))
|
||||
return action
|
||||
|
||||
def contextMenuSeparator(base):
|
||||
action = QtGui.QAction("", base)
|
||||
action = QtGui.QAction(u'', base)
|
||||
action.setSeparator(True)
|
||||
return action
|
||||
|
||||
|
@ -30,7 +30,7 @@ import zipfile
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from openlp.core.lib import PluginConfig, OpenLPToolbar, ServiceItem, \
|
||||
ServiceType, contextMenuAction, contextMenuSeparator, Receiver
|
||||
ServiceType, contextMenuAction, contextMenuSeparator, Receiver, contextMenu
|
||||
|
||||
class ServiceManagerList(QtGui.QTreeWidget):
|
||||
|
||||
@ -168,6 +168,12 @@ class ServiceManager(QtGui.QWidget):
|
||||
self.ServiceManagerList.addAction(contextMenuAction(
|
||||
self.ServiceManagerList, ':/services/service_delete',
|
||||
self.trUtf8(u'&Remove from Service'), self.onDeleteFromService))
|
||||
self.ServiceManagerList.addAction(contextMenuSeparator(
|
||||
self.ServiceManagerList))
|
||||
self.ThemeMenu = contextMenu(
|
||||
self.ServiceManagerList, '',
|
||||
self.trUtf8(u'&Change Item Theme'))
|
||||
self.ServiceManagerList.addAction(self.ThemeMenu.menuAction())
|
||||
self.Layout.addWidget(self.ServiceManagerList)
|
||||
# Add the bottom toolbar
|
||||
self.OrderToolbar = OpenLPToolbar(self)
|
||||
@ -602,9 +608,15 @@ class ServiceManager(QtGui.QWidget):
|
||||
|
||||
"""
|
||||
self.ThemeComboBox.clear()
|
||||
self.ThemeMenu.clear()
|
||||
self.ThemeComboBox.addItem(u'')
|
||||
for theme in theme_list:
|
||||
self.ThemeComboBox.addItem(theme)
|
||||
action = contextMenuAction(
|
||||
self.ServiceManagerList,
|
||||
None,
|
||||
theme , self.onThemeChangeAction)
|
||||
self.ThemeMenu.addAction(action)
|
||||
id = self.ThemeComboBox.findText(self.service_theme,
|
||||
QtCore.Qt.MatchExactly)
|
||||
# Not Found
|
||||
@ -614,3 +626,9 @@ class ServiceManager(QtGui.QWidget):
|
||||
self.ThemeComboBox.setCurrentIndex(id)
|
||||
self.parent.RenderManager.set_service_theme(self.service_theme)
|
||||
self.regenerateServiceItems()
|
||||
|
||||
def onThemeChangeAction(self):
|
||||
theme = unicode(self.sender().text())
|
||||
item, count = self.findServiceItem()
|
||||
self.serviceItems[item][u'data'].theme = theme
|
||||
self.regenerateServiceItems()
|
||||
|
Loading…
Reference in New Issue
Block a user