diff --git a/openlp.pyw b/openlp.pyw index fd8bfb41e..81ae3e47f 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -27,9 +27,8 @@ import os import sys import logging - -from logging import FileHandler from optparse import OptionParser + from PyQt4 import QtCore, QtGui log = logging.getLogger() @@ -167,7 +166,7 @@ def main(): if not os.path.exists(log_path): os.makedirs(log_path) filename = os.path.join(log_path, u'openlp.log') - logfile = FileHandler(filename, u'w') + logfile = logging.FileHandler(filename, u'w') logfile.setFormatter(logging.Formatter( u'%(asctime)s %(name)-55s %(levelname)-8s %(message)s')) log.addHandler(logfile) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 4718e289e..f62778820 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -174,6 +174,8 @@ def resize_image(image, width, height): """ preview = QtGui.QImage(image) if not preview.isNull(): + if preview.width() == width and preview.height == height: + return preview preview = preview.scaled(width, height, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) realw = preview.width() diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 8ebfe88ae..cad0b35cb 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -66,7 +66,7 @@ class MediaManagerItem(QtGui.QWidget): The shortened (usually singular) name for the plugin e.g. *'Song'* for the Songs plugin. - ``self.PluginNameVisible`` + ``self.pluginNameVisible`` The user visible name for a plugin which should use a suitable translation function. @@ -108,21 +108,17 @@ class MediaManagerItem(QtGui.QWidget): self.icon = None if title: self.title = title - self.Toolbar = None + self.toolbar = None self.remoteTriggered = None - self.ServiceItemIconName = None + self.serviceItemIconName = None self.singleServiceItem = True - self.PageLayout = QtGui.QVBoxLayout(self) - self.PageLayout.setSpacing(0) - self.PageLayout.setContentsMargins(4, 0, 4, 0) + self.pageLayout = QtGui.QVBoxLayout(self) + self.pageLayout.setSpacing(0) + self.pageLayout.setContentsMargins(4, 0, 4, 0) self.requiredIcons() - self.initPluginNameVisible() self.setupUi() self.retranslateUi() - def initPluginNameVisible(self): - pass - def requiredIcons(self): """ This method is called to define the icons for the plugin. @@ -149,9 +145,9 @@ class MediaManagerItem(QtGui.QWidget): A method to help developers easily add a toolbar to the media manager item. """ - if self.Toolbar is None: - self.Toolbar = OpenLPToolbar(self) - self.PageLayout.addWidget(self.Toolbar) + if self.toolbar is None: + self.toolbar = OpenLPToolbar(self) + self.pageLayout.addWidget(self.toolbar) def addToolbarButton( self, title, tooltip, icon, slot=None, checkable=False): @@ -180,13 +176,13 @@ class MediaManagerItem(QtGui.QWidget): # break compatability), but it makes sense for the icon to # come before the tooltip (as you have to have an icon, but # not neccesarily a tooltip) - self.Toolbar.addToolbarButton(title, icon, tooltip, slot, checkable) + self.toolbar.addToolbarButton(title, icon, tooltip, slot, checkable) def addToolbarSeparator(self): """ A very simple method to add a separator to the toolbar. """ - self.Toolbar.addSeparator() + self.toolbar.addSeparator() def setupUi(self): """ @@ -215,7 +211,7 @@ class MediaManagerItem(QtGui.QWidget): unicode(translate('MediaManagerItem', 'Import %s')) % self.PluginNameShort, unicode(translate('MediaManagerItem', 'Import a %s')) % - self.PluginNameVisible, + self.pluginNameVisible, u':/general/general_import.png', self.onImportClick) ## File Button ## if self.hasFileIcon: @@ -223,7 +219,7 @@ class MediaManagerItem(QtGui.QWidget): unicode(translate('MediaManagerItem', 'Load %s')) % self.PluginNameShort, unicode(translate('MediaManagerItem', 'Load a new %s')) % - self.PluginNameVisible, + self.pluginNameVisible, u':/general/general_open.png', self.onFileClick) ## New Button ## if self.hasNewIcon: @@ -231,7 +227,7 @@ class MediaManagerItem(QtGui.QWidget): unicode(translate('MediaManagerItem', 'New %s')) % self.PluginNameShort, unicode(translate('MediaManagerItem', 'Add a new %s')) % - self.PluginNameVisible, + self.pluginNameVisible, u':/general/general_new.png', self.onNewClick) ## Edit Button ## if self.hasEditIcon: @@ -240,7 +236,7 @@ class MediaManagerItem(QtGui.QWidget): self.PluginNameShort, unicode(translate( 'MediaManagerItem', 'Edit the selected %s')) % - self.PluginNameVisible, + self.pluginNameVisible, u':/general/general_edit.png', self.onEditClick) ## Delete Button ## if self.hasDeleteIcon: @@ -275,61 +271,67 @@ class MediaManagerItem(QtGui.QWidget): Creates the main widget for listing items the media item is tracking """ #Add the List widget - self.ListView = self.ListViewWithDnD_class(self) - self.ListView.uniformItemSizes = True - self.ListView.setGeometry(QtCore.QRect(10, 100, 256, 591)) - self.ListView.setSpacing(1) - self.ListView.setSelectionMode( + self.listView = self.ListViewWithDnD_class(self) + self.listView.uniformItemSizes = True + self.listView.setGeometry(QtCore.QRect(10, 100, 256, 591)) + self.listView.setSpacing(1) + self.listView.setSelectionMode( QtGui.QAbstractItemView.ExtendedSelection) - self.ListView.setAlternatingRowColors(True) - self.ListView.setDragEnabled(True) - self.ListView.setObjectName(u'%sListView' % self.PluginNameShort) - #Add tp PageLayout - self.PageLayout.addWidget(self.ListView) + self.listView.setAlternatingRowColors(True) + self.listView.setDragEnabled(True) + self.listView.setObjectName(u'%sListView' % self.PluginNameShort) + #Add to pageLayout + self.pageLayout.addWidget(self.listView) #define and add the context menu - self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) + self.listView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) if self.hasEditIcon: - self.ListView.addAction( + self.listView.addAction( context_menu_action( - self.ListView, u':/general/general_edit.png', + self.listView, u':/general/general_edit.png', unicode(translate('MediaManagerItem', '&Edit %s')) % - self.PluginNameVisible, + self.pluginNameVisible, self.onEditClick)) - self.ListView.addAction(context_menu_separator(self.ListView)) + self.listView.addAction(context_menu_separator(self.listView)) if self.hasDeleteIcon: - self.ListView.addAction( + self.listView.addAction( context_menu_action( - self.ListView, u':/general/general_delete.png', + self.listView, u':/general/general_delete.png', unicode(translate('MediaManagerItem', '&Delete %s')) % - self.PluginNameVisible, + self.pluginNameVisible, self.onDeleteClick)) - self.ListView.addAction(context_menu_separator(self.ListView)) - self.ListView.addAction( + self.listView.addAction(context_menu_separator(self.listView)) + self.listView.addAction( context_menu_action( - self.ListView, u':/general/general_preview.png', + self.listView, u':/general/general_preview.png', unicode(translate('MediaManagerItem', '&Preview %s')) % - self.PluginNameVisible, + self.pluginNameVisible, self.onPreviewClick)) - self.ListView.addAction( + self.listView.addAction( context_menu_action( - self.ListView, u':/general/general_live.png', + self.listView, u':/general/general_live.png', translate('MediaManagerItem', '&Show Live'), self.onLiveClick)) - self.ListView.addAction( + self.listView.addAction( context_menu_action( - self.ListView, u':/general/general_add.png', + self.listView, u':/general/general_add.png', translate('MediaManagerItem', '&Add to Service'), self.onAddClick)) if self.addToServiceItem: - self.ListView.addAction( + self.listView.addAction( context_menu_action( - self.ListView, u':/general/general_add.png', + self.listView, u':/general/general_add.png', translate('MediaManagerItem', '&Add to selected Service Item'), self.onAddEditClick)) - QtCore.QObject.connect( - self.ListView, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), - self.onPreviewClick) + if QtCore.QSettings().value(u'advanced/double click live', + QtCore.QVariant(False)).toBool(): + QtCore.QObject.connect(self.listView, + QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), + self.onLiveClick) + else: + QtCore.QObject.connect(self.listView, + QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), + self.onPreviewClick) def initialise(self): """ @@ -372,8 +374,8 @@ class MediaManagerItem(QtGui.QWidget): """ count = 0 filelist = [] - while count < self.ListView.count(): - bitem = self.ListView.item(count) + while count < self.listView.count(): + bitem = self.listView.item(count) filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) filelist.append(filename) count += 1 @@ -383,16 +385,19 @@ class MediaManagerItem(QtGui.QWidget): """ Validates to see if the file still exists or thumbnail is up to date """ - if os.path.exists(file): + if not os.path.exists(file): + return False + if os.path.exists(thumb): filedate = os.stat(file).st_mtime thumbdate = os.stat(thumb).st_mtime #if file updated rebuild icon if filedate > thumbdate: - self.IconFromFile(file, thumb) - return True - return False + self.iconFromFile(file, thumb) + else: + self.iconFromFile(file, thumb) + return True - def IconFromFile(self, file, thumb): + def iconFromFile(self, file, thumb): """ Create a thumbnail icon from a given file @@ -433,7 +438,7 @@ class MediaManagerItem(QtGui.QWidget): Preview an item by building a service item then adding that service item to the preview slide controller. """ - if not self.ListView.selectedIndexes() and not self.remoteTriggered: + if not self.listView.selectedIndexes() and not self.remoteTriggered: QtGui.QMessageBox.information(self, translate('MediaManagerItem', 'No Items Selected'), translate('MediaManagerItem', @@ -450,7 +455,7 @@ class MediaManagerItem(QtGui.QWidget): Send an item live by building a service item then adding that service item to the live slide controller. """ - if not self.ListView.selectedIndexes(): + if not self.listView.selectedIndexes(): QtGui.QMessageBox.information(self, translate('MediaManagerItem', 'No Items Selected'), translate('MediaManagerItem', @@ -466,7 +471,7 @@ class MediaManagerItem(QtGui.QWidget): """ Add a selected item to the current service """ - if not self.ListView.selectedIndexes() and not self.remoteTriggered: + if not self.listView.selectedIndexes() and not self.remoteTriggered: QtGui.QMessageBox.information(self, translate('MediaManagerItem', 'No Items Selected'), translate('MediaManagerItem', @@ -482,7 +487,7 @@ class MediaManagerItem(QtGui.QWidget): self.parent.serviceManager.addServiceItem(service_item, replace=self.remoteTriggered) else: - items = self.ListView.selectedIndexes() + items = self.listView.selectedIndexes() for item in items: service_item = self.buildServiceItem(item) if service_item: @@ -493,7 +498,7 @@ class MediaManagerItem(QtGui.QWidget): """ Add a selected item to an existing item in the current service. """ - if not self.ListView.selectedIndexes() and not self.remoteTriggered: + if not self.listView.selectedIndexes() and not self.remoteTriggered: QtGui.QMessageBox.information(self, translate('MediaManagerItem', 'No items selected'), translate('MediaManagerItem', @@ -522,10 +527,10 @@ class MediaManagerItem(QtGui.QWidget): Common method for generating a service item """ service_item = ServiceItem(self.parent) - if self.ServiceItemIconName: - service_item.add_icon(self.ServiceItemIconName) + if self.serviceItemIconName: + service_item.add_icon(self.serviceItemIconName) else: - service_item.add_icon(self.parent.icon) + service_item.add_icon(self.parent.icon_path) if self.generateSlideData(service_item, item): return service_item else: diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 18d4bdc9e..082070575 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -269,8 +269,22 @@ class Plugin(QtCore.QObject): if self.settings_tab: self.settingsForm.insertTab(self.settings_tab, self.weight) - def canDeleteTheme(self, theme): + def usesTheme(self, theme): """ - Called to ask the plugin if a theme can be deleted + Called to find out if a plugin is currently using a theme. + + Returns True if the theme is being used, otherwise returns False. """ - return True \ No newline at end of file + return False + + def renameTheme(self, oldTheme, newTheme): + """ + Renames a theme a plugin is using making the plugin use the new name. + + ``oldTheme`` + The name of the theme the plugin should stop using. + + ``newTheme`` + The new name the plugin should now use. + """ + pass diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index a8988aa84..86694e986 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -117,8 +117,7 @@ class ServiceItem(object): service item in the service manager. ``icon`` - An instance of QIcon or a string to an icon in the resource or on - disk. + A string to an icon in the resources or on disk. """ self.icon = icon self.iconic_representation = build_icon(icon) diff --git a/openlp/core/lib/toolbar.py b/openlp/core/lib/toolbar.py index 6b87f84fe..14b6d66ac 100644 --- a/openlp/core/lib/toolbar.py +++ b/openlp/core/lib/toolbar.py @@ -71,27 +71,27 @@ class OpenLPToolbar(QtGui.QToolBar): ``objectname`` The name of the object, as used in `