From 625ef9fc00bcb464103ea0d6a4b165fd61758218 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 1 Jan 2011 22:41:28 +0100 Subject: [PATCH 1/7] fixed adding more images at once, tweaked adding images when one image is not present --- openlp/plugins/images/lib/mediaitem.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 7281bb091..3309f06aa 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -43,6 +43,7 @@ class ImageListView(BaseListWithDnD): self.PluginName = u'Images' BaseListWithDnD.__init__(self, parent) + class ImageMediaItem(MediaManagerItem): """ This is the custom media manager item for images. @@ -51,8 +52,8 @@ class ImageMediaItem(MediaManagerItem): def __init__(self, parent, plugin, icon): self.IconPath = u'images/image' - # this next is a class, not an instance of a class - it will - # be instanced by the base MediaManagerItem + # This next is a class, not an instance of a class - it will + # be instanced by the base MediaManagerItem. self.ListViewWithDnD_class = ImageListView MediaManagerItem.__init__(self, parent, self, icon) @@ -113,7 +114,7 @@ class ImageMediaItem(MediaManagerItem): u':/system/system_close.png', translate('ImagePlugin.MediaItem', 'Reset Live Background'), self.onResetClick, False) - # Add the song widget to the page layout + # Add the song widget to the page layout. self.pageLayout.addWidget(self.ImageWidget) self.resetButton.setVisible(False) @@ -171,15 +172,24 @@ class ImageMediaItem(MediaManagerItem): if os.path.exists(filename): (path, name) = os.path.split(filename) service_item.add_from_image(filename, name) - return True - else: - # File is no longer present + # We have only one image, which is no longer present. + elif len(items) == 1: QtGui.QMessageBox.critical( self, translate('ImagePlugin.MediaItem', 'Missing Image'), unicode(translate('ImagePlugin.MediaItem', - 'The Image %s no longer exists.')) % filename) + 'The image %s no longer exists.')) % filename) return False + # We have more than one item, but a file is missing. + elif QtGui.QMessageBox.question(self, + translate('ImagePlugin.MediaItem', 'Missing Image'), + unicode(translate('ImagePlugin.MediaItem', 'The image ' + '%s no longer exists. Do you want to add the other ' + 'images anyway?')) % filename, + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | + QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No: + return False + return True else: return False From 2693e3dbd94f5ff1ba1e8141a86d26d1cc6ccd84 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 1 Jan 2011 22:46:00 +0100 Subject: [PATCH 2/7] removed a not needed import --- openlp/plugins/images/lib/mediaitem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 3309f06aa..b0b411798 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -31,7 +31,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \ context_menu_action, ItemCapabilities, SettingsManager, translate, \ - check_item_selected, Receiver + check_item_selected from openlp.core.utils import AppLocation, get_images_filter log = logging.getLogger(__name__) From def66c204a2b94de5aa9f88a677cbe323615f5a6 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 1 Jan 2011 22:55:22 +0100 Subject: [PATCH 3/7] fixed wrong indent --- openlp/plugins/images/lib/mediaitem.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index b0b411798..c3b265e61 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -182,13 +182,13 @@ class ImageMediaItem(MediaManagerItem): return False # We have more than one item, but a file is missing. elif QtGui.QMessageBox.question(self, - translate('ImagePlugin.MediaItem', 'Missing Image'), - unicode(translate('ImagePlugin.MediaItem', 'The image ' - '%s no longer exists. Do you want to add the other ' - 'images anyway?')) % filename, - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | - QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No: - return False + translate('ImagePlugin.MediaItem', 'Missing Image'), + unicode(translate('ImagePlugin.MediaItem', 'The image %s ' + 'no longer exists. Do you want to add the other images ' + 'anyway?')) % filename, + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | + QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No: + return False return True else: return False From 8a0eeb54bb66e9d3cc9cf4a354e969e75ccae721 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 2 Jan 2011 08:57:05 +0100 Subject: [PATCH 4/7] --- openlp/plugins/images/__init__.py | 2 +- openlp/plugins/images/imageplugin.py | 2 +- openlp/plugins/images/lib/__init__.py | 2 +- openlp/plugins/images/lib/mediaitem.py | 48 +++++++++++++++++++------- 4 files changed, 38 insertions(+), 16 deletions(-) diff --git a/openlp/plugins/images/__init__.py b/openlp/plugins/images/__init__.py index 6ea473c72..9939bd87e 100644 --- a/openlp/plugins/images/__init__.py +++ b/openlp/plugins/images/__init__.py @@ -26,4 +26,4 @@ """ The :mod:`images` module provides the Images plugin. The Images plugin provides the facility to display images from OpenLP. -""" \ No newline at end of file +""" diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index 79b08eb8c..ea118d3ec 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -41,7 +41,7 @@ class ImagePlugin(Plugin): self.icon = build_icon(self.icon_path) def getMediaManagerItem(self): - # Create the MediaManagerItem object + # Create the MediaManagerItem object. return ImageMediaItem(self, self, self.icon) def about(self): diff --git a/openlp/plugins/images/lib/__init__.py b/openlp/plugins/images/lib/__init__.py index 6ff2a295b..6a16ecc88 100644 --- a/openlp/plugins/images/lib/__init__.py +++ b/openlp/plugins/images/lib/__init__.py @@ -24,4 +24,4 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from mediaitem import ImageMediaItem \ No newline at end of file +from mediaitem import ImageMediaItem diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index c3b265e61..f81a744d4 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -166,29 +166,51 @@ class ImageMediaItem(MediaManagerItem): service_item.add_capability(ItemCapabilities.AllowsAdditions) # force a nonexistent theme service_item.theme = -1 + existing_images = [] + missing_images = [] + text = u'' for item in items: bitem = self.listView.item(item.row()) filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) if os.path.exists(filename): - (path, name) = os.path.split(filename) - service_item.add_from_image(filename, name) - # We have only one image, which is no longer present. - elif len(items) == 1: - QtGui.QMessageBox.critical( - self, translate('ImagePlugin.MediaItem', - 'Missing Image'), + existing_images.append(filename) + else: + missing_images.append(filename) + text += u'\n' + filename + # We cannot continue, as all images are missing. + if len(missing_images) == len(items): + if len(missing_images) == 1: + QtGui.QMessageBox.critical(self, + translate('ImagePlugin.MediaItem', 'Missing Image'), unicode(translate('ImagePlugin.MediaItem', - 'The image %s no longer exists.')) % filename) - return False - # We have more than one item, but a file is missing. - elif QtGui.QMessageBox.question(self, - translate('ImagePlugin.MediaItem', 'Missing Image'), + 'The image %s no longer exists.')) % text) + else: + QtGui.QMessageBox.critical(self, + translate('ImagePlugin.MediaItem', 'Missing Images'), + unicode(translate('ImagePlugin.MediaItem', + 'The following images no longer exist: %s')) % text) + return False + # We still have present images. Ask what to do. + elif missing_images: + if len(missing_images) == 1 and QtGui.QMessageBox.question( + self, translate('ImagePlugin.MediaItem', 'Missing Image'), unicode(translate('ImagePlugin.MediaItem', 'The image %s ' 'no longer exists. Do you want to add the other images ' - 'anyway?')) % filename, + 'anyway?')) % text, QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No: return False + elif len(missing_images) > 1 and QtGui.QMessageBox.question( + self, translate('ImagePlugin.MediaItem', 'Missing Images'), + unicode(translate('ImagePlugin.MediaItem', 'The following ' + 'images no longer exist: %s\nDo you want to add the other ' + 'images anyway?')) % text, + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | + QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No: + return False + for filename in existing_images: + (path, name) = os.path.split(filename) + service_item.add_from_image(filename, name) return True else: return False From 48a96769d7b99d5b8421a2825c0185e429375040 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 2 Jan 2011 16:42:30 +0000 Subject: [PATCH 5/7] Add YAS for closure --- openlp/core/ui/advancedtab.py | 25 ++++++++++++++++++------- openlp/core/ui/mainwindow.py | 27 ++++++++++++++++----------- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 0a8547837..e2cfa72bf 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -90,6 +90,10 @@ class AdvancedTab(SettingsTab): self.expandServiceItemCheckBox.setObjectName( u'expandServiceItemCheckBox') self.uiLayout.addWidget(self.expandServiceItemCheckBox) + self.enableAutoCloseCheckBox = QtGui.QCheckBox(self.uiGroupBox) + self.enableAutoCloseCheckBox.setObjectName( + u'enableAutoCloseCheckBox') + self.uiLayout.addWidget(self.enableAutoCloseCheckBox) # self.sharedDirGroupBox = QtGui.QGroupBox(self.leftWidget) # self.sharedDirGroupBox.setObjectName(u'sharedDirGroupBox') # self.sharedDirGroupBox.setGeometry(QtCore.QRect(0, 65, 500, 85)) @@ -150,6 +154,8 @@ class AdvancedTab(SettingsTab): 'Double-click to send items straight to live')) self.expandServiceItemCheckBox.setText(translate('OpenLP.AdvancedTab', 'Expand new service items on creation')) + self.enableAutoCloseCheckBox.setText(translate('OpenLP.AdvancedTab', + 'Enable confirm on closure')) # self.sharedDirGroupBox.setTitle( # translate('AdvancedTab', 'Central Data Store')) # self.sharedCheckBox.setText( @@ -180,6 +186,9 @@ class AdvancedTab(SettingsTab): self.expandServiceItemCheckBox.setChecked( settings.value(u'expand service item', QtCore.QVariant(False)).toBool()) + self.enableAutoCloseCheckBox.setChecked( + settings.value(u'enable auto close', + QtCore.QVariant(True)).toBool()) settings.endGroup() def save(self): @@ -196,12 +205,14 @@ class AdvancedTab(SettingsTab): QtCore.QVariant(self.doubleClickLiveCheckBox.isChecked())) settings.setValue(u'expand service item', QtCore.QVariant(self.expandServiceItemCheckBox.isChecked())) + settings.setValue(u'enable auto close', + QtCore.QVariant(self.enableAutoCloseCheckBox.isChecked())) settings.endGroup() - def onSharedCheckBoxChanged(self, checked): - """ - Enables the widgets to allow a shared data location - """ - self.sharedLabel.setEnabled(checked) - self.sharedTextEdit.setEnabled(checked) - self.sharedPushButton.setEnabled(checked) \ No newline at end of file +# def onSharedCheckBoxChanged(self, checked): +# """ +# Enables the widgets to allow a shared data location +# """ +# self.sharedLabel.setEnabled(checked) +# self.sharedTextEdit.setEnabled(checked) +# self.sharedPushButton.setEnabled(checked) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 8c6117955..5c30fdc71 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -842,7 +842,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtGui.QMessageBox.Save), QtGui.QMessageBox.Save) if ret == QtGui.QMessageBox.Save: - #self.ServiceManagerContents.onSaveService(True) if self.ServiceManagerContents.saveFile(): self.cleanUp() event.accept() @@ -854,18 +853,24 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): else: event.ignore() else: - ret = QtGui.QMessageBox.question(self, - translate('OpenLP.MainWindow', 'Close OpenLP'), - translate('OpenLP.MainWindow', 'Are you sure you want to close OpenLP?'), - QtGui.QMessageBox.StandardButtons( - QtGui.QMessageBox.Yes | - QtGui.QMessageBox.No), - QtGui.QMessageBox.Yes) - if ret == QtGui.QMessageBox.Yes: + if QtCore.QSettings().value(u'advanced/enable auto close', + QtCore.QVariant(True)).toBool(): + ret = QtGui.QMessageBox.question(self, + translate('OpenLP.MainWindow', 'Close OpenLP'), + translate('OpenLP.MainWindow', 'Are you sure you want to close OpenLP?'), + QtGui.QMessageBox.StandardButtons( + QtGui.QMessageBox.Yes | + QtGui.QMessageBox.No), + QtGui.QMessageBox.Yes) + if ret == QtGui.QMessageBox.Yes: + self.cleanUp() + event.accept() + else: + event.ignore() + else: self.cleanUp() event.accept() - else: - event.ignore() + def cleanUp(self): """ From d8ef3c5947a253ddec1c304384b5ce6ac67adbfe Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 2 Jan 2011 22:34:33 +0100 Subject: [PATCH 6/7] added a check to prevent replacing the live background with an non existing image, prevent replacing with more images --- openlp/plugins/images/lib/mediaitem.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index bf702ae44..ccc432931 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -208,16 +208,21 @@ class ImageMediaItem(MediaManagerItem): self.parent.liveController.display.resetImage() def onReplaceClick(self): - # TODO: Check if image exists. if check_item_selected(self.listView, translate('ImagePlugin.MediaItem', 'You must select an image to replace the background with.')): - items = self.listView.selectedIndexes() - for item in items: - bitem = self.listView.item(item.row()) - filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) + item = self.listView.selectedIndexes()[0] + bitem = self.listView.item(item.row()) + filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) + if os.path.exists(filename): (path, name) = os.path.split(filename) self.parent.liveController.display.directImage(name, filename) + else: + QtGui.QMessageBox.critical(self, + translate('ImagePlugin.MediaItem', 'Live Background Could ' + 'Not Be Replaced'), + unicode(translate('ImagePlugin.MediaItem', + 'The image %s no longer exists.')) % filename) self.resetButton.setVisible(True) def onPreviewClick(self): From c11454b02dfc80e32768438f8e7132de4aa89540 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 3 Jan 2011 08:56:17 +0000 Subject: [PATCH 7/7] Fix review comments --- openlp/core/ui/advancedtab.py | 8 ++++---- openlp/core/ui/maindisplay.py | 3 +-- openlp/core/ui/mainwindow.py | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index e2cfa72bf..dd196d68d 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -155,7 +155,7 @@ class AdvancedTab(SettingsTab): self.expandServiceItemCheckBox.setText(translate('OpenLP.AdvancedTab', 'Expand new service items on creation')) self.enableAutoCloseCheckBox.setText(translate('OpenLP.AdvancedTab', - 'Enable confirm on closure')) + 'Enable application exit confirmation')) # self.sharedDirGroupBox.setTitle( # translate('AdvancedTab', 'Central Data Store')) # self.sharedCheckBox.setText( @@ -187,7 +187,7 @@ class AdvancedTab(SettingsTab): settings.value(u'expand service item', QtCore.QVariant(False)).toBool()) self.enableAutoCloseCheckBox.setChecked( - settings.value(u'enable auto close', + settings.value(u'enable exit confirmation', QtCore.QVariant(True)).toBool()) settings.endGroup() @@ -205,7 +205,7 @@ class AdvancedTab(SettingsTab): QtCore.QVariant(self.doubleClickLiveCheckBox.isChecked())) settings.setValue(u'expand service item', QtCore.QVariant(self.expandServiceItemCheckBox.isChecked())) - settings.setValue(u'enable auto close', + settings.setValue(u'enable exit confirmation', QtCore.QVariant(self.enableAutoCloseCheckBox.isChecked())) settings.endGroup() @@ -215,4 +215,4 @@ class AdvancedTab(SettingsTab): # """ # self.sharedLabel.setEnabled(checked) # self.sharedTextEdit.setEnabled(checked) -# self.sharedPushButton.setEnabled(checked) +# self.sharedPushButton.setEnabled(checked) \ No newline at end of file diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index dd24f172d..d243733dc 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -94,7 +94,6 @@ class MainDisplay(DisplayWidget): """ This is the display screen. """ - def __init__(self, parent, screens, live): DisplayWidget.__init__(self, live, parent=None) self.parent = parent @@ -116,7 +115,7 @@ class MainDisplay(DisplayWidget): """ Set up and build the output screen """ - log.debug(u'Setup live = %s for %s ' % (self.isLive, + log.debug(u'Setup live = %s for monitor %s ' % (self.isLive, self.screens.monitor_number)) self.usePhonon = QtCore.QSettings().value( u'media/use phonon', QtCore.QVariant(True)).toBool() diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 5c30fdc71..867fb3c51 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -853,7 +853,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): else: event.ignore() else: - if QtCore.QSettings().value(u'advanced/enable auto close', + if QtCore.QSettings().value(u'advanced/enable exit confirmation', QtCore.QVariant(True)).toBool(): ret = QtGui.QMessageBox.question(self, translate('OpenLP.MainWindow', 'Close OpenLP'), @@ -1059,4 +1059,4 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.recentFiles.insert(0, QtCore.QString(filename)) while self.recentFiles.count() > maxRecentFiles: # Don't care what API says takeLast works, removeLast doesn't! - self.recentFiles.takeLast() + self.recentFiles.takeLast() \ No newline at end of file