added menu entry to update the theme images

This commit is contained in:
Andreas Preikschat 2011-05-20 13:45:39 +02:00
parent 875202deca
commit 304f4ff732
3 changed files with 42 additions and 1 deletions

View File

@ -229,6 +229,8 @@ class Ui_MainWindow(object):
self.ToolsOpenDataFolder = icon_action(mainWindow,
u'ToolsOpenDataFolder', u':/general/general_open.png',
category=UiStrings().Tools)
self.updateThemeImages = base_action(mainWindow,
u'updateThemeImages', category=UiStrings().Tools)
action_list.add_category(UiStrings().Settings, CategoryOrder.standardMenu)
self.settingsPluginListItem = shortcut_action(mainWindow,
u'settingsPluginListItem', [QtGui.QKeySequence(u'Alt+F7')],
@ -292,6 +294,7 @@ class Ui_MainWindow(object):
self.SettingsConfigureItem))
add_actions(self.ToolsMenu, (self.ToolsAddToolItem, None))
add_actions(self.ToolsMenu, (self.ToolsOpenDataFolder, None))
add_actions(self.ToolsMenu, [self.updateThemeImages])
add_actions(self.HelpMenu, (self.HelpDocumentationItem,
self.HelpOnlineHelpItem, None, self.helpWebSiteItem,
self.HelpAboutItem))
@ -433,6 +436,11 @@ class Ui_MainWindow(object):
translate('OpenLP.MainWindow', 'Open &Data Folder...'))
self.ToolsOpenDataFolder.setStatusTip(translate('OpenLP.MainWindow',
'Open the folder where songs, bibles and other data resides.'))
self.updateThemeImages.setText(
translate('OpenLP.MainWindow', 'Update Theme Images'))
self.updateThemeImages.setStatusTip(
translate('OpenLP.MainWindow', 'Update the preview images for all '
'themes.'))
self.ModeDefaultItem.setText(
translate('OpenLP.MainWindow', '&Default'))
self.ModeDefaultItem.setStatusTip(translate('OpenLP.MainWindow',
@ -505,6 +513,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
QtCore.SIGNAL(u'triggered()'), self.onHelpOnLineHelpClicked)
QtCore.QObject.connect(self.ToolsOpenDataFolder,
QtCore.SIGNAL(u'triggered()'), self.onToolsOpenDataFolderClicked)
QtCore.QObject.connect(self.updateThemeImages,
QtCore.SIGNAL(u'triggered()'), self.onUpdateThemeImages)
QtCore.QObject.connect(self.DisplayTagItem,
QtCore.SIGNAL(u'triggered()'), self.onDisplayTagItemClicked)
QtCore.QObject.connect(self.SettingsConfigureItem,
@ -717,6 +727,12 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
path = AppLocation.get_data_path()
QtGui.QDesktopServices.openUrl(QtCore.QUrl("file:///" + path))
def onUpdateThemeImages(self):
"""
Updates the new theme preview images.
"""
self.themeManagerContents.updatePreviewImages()
def onDisplayTagItemClicked(self):
"""
Show the Settings dialog

View File

@ -660,6 +660,31 @@ class ThemeManager(QtGui.QWidget):
pixmap.save(thumb, u'png')
log.debug(u'Theme image written to %s', samplepathname)
def updatePreviewImages(self):
"""
Called to update the themes' preview images.
"""
progressDialog = QtGui.QProgressDialog(self.mainwindow)
progressDialog.setWindowModality(QtCore.Qt.WindowModal)
progressDialog.setLabelText(
translate('OpenLP.ThemeManager', 'Starting update...',
'Shown when you update the theme images.'))
progressDialog.setCancelButton(None)
progressDialog.setRange(0, len(self.themelist))
progressDialog.setMinimumDuration(0)
progressDialog.forceShow()
Receiver.send_message(u'openlp_process_events')
for index, theme in enumerate(self.themelist):
progressDialog.setValue(index)
progressDialog.setLabelText(unicode(translate('OpenLP.ThemeManager',
'Updating %s...',
'Shown when you update the theme images.')) % theme)
Receiver.send_message(u'openlp_process_events')
self.generateAndSaveImage(
self.path, theme, self.getThemeData(theme))
progressDialog.setValue(len(self.themelist))
self.loadThemes()
def generateImage(self, themeData, forcePage=False):
"""
Call the renderer to build a Sample Image

View File

@ -342,7 +342,7 @@ def add_actions(target, actions):
The menu or toolbar to add actions to.
``actions``
The actions to be added. An action consisting of the keyword 'None'
The actions to be added. An action consisting of the keyword ``None``
will result in a separator being inserted into the target.
"""
for action in actions: