diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 2d3e55355..75bafc5e8 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -137,13 +137,12 @@ def image_to_byte(image): # convert to base64 encoding so does not get missed! return byte_array.toBase64() -def resize_image(image, width, height, background=QtCore.Qt.black): +def resize_image(image_path, width, height, background=QtCore.Qt.black): """ Resize an image to fit on the current screen. - ``image`` - The image to resize. It has to be either a ``QImage`` instance or the - path to the image. + ``image_path`` + The path to the image to resize. ``width`` The new image width. @@ -155,16 +154,24 @@ def resize_image(image, width, height, background=QtCore.Qt.black): The background colour defaults to black. """ log.debug(u'resize_image - start') - if isinstance(image, QtGui.QImage): - preview = image + reader = QtGui.QImageReader(image_path) + # The image's ratio. + image_ratio = float(reader.size().width()) / float(reader.size().height()) + resize_ratio = float(width) / float(height) + # Figure out the size we want to resize the image to (keep aspect ratio). + if image_ratio == resize_ratio: + size = QtCore.QSize(width, height) + elif image_ratio < resize_ratio: + # Use the image's height as reference for the new size. + size = QtCore.QSize(image_ratio * height, height) else: - preview = QtGui.QImage(image) - if not preview.isNull(): - # Only resize if different size - if preview.width() == width and preview.height == height: - return preview - preview = preview.scaled(width, height, QtCore.Qt.KeepAspectRatio, - QtCore.Qt.SmoothTransformation) + # Use the image's width as reference for the new size. + size = QtCore.QSize(width, 1 / (image_ratio / width)) + reader.setScaledSize(size) + preview = reader.read() + if image_ratio == resize_ratio: + # We neither need to centre the image nor add "bars" to the image. + return preview realw = preview.width() realh = preview.height() # and move it to the centre of the preview space diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 268b383d4..7cabdbf17 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -391,21 +391,26 @@ class MediaManagerItem(QtGui.QWidget): self.iconFromFile(image, thumb) return True - def iconFromFile(self, image, thumb): + def iconFromFile(self, image_path, thumb_path): """ Create a thumbnail icon from a given image. - ``image`` + ``image_path`` The image file to create the icon from. - ``thumb`` - The filename to save the thumbnail to + ``thumb_path`` + The filename to save the thumbnail to. """ - icon = build_icon(unicode(image)) - pixmap = icon.pixmap(QtCore.QSize(88, 50)) - ext = os.path.splitext(thumb)[1].lower() - pixmap.save(thumb, ext[1:]) - return icon + ext = os.path.splitext(thumb_path)[1].lower() + reader = QtGui.QImageReader(image_path) + ratio = float(reader.size().width()) / float(reader.size().height()) + reader.setScaledSize(QtCore.QSize(int(ratio * 88), 88)) + thumb = reader.read() + thumb.save(thumb_path, ext[1:]) + if os.path.exists(thumb_path): + return build_icon(unicode(thumb_path)) + # Fallback for files with animation support. + return build_icon(unicode(image_path)) def loadList(self, list): raise NotImplementedError(u'MediaManagerItem.loadList needs to be ' diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 250991d2a..f9af00f6e 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -86,6 +86,8 @@ class Renderer(object): """ log.debug(u'Update Display') self._calculate_default(self.screens.current[u'size']) + if self.display: + self.display.close() self.display = MainDisplay(None, self.image_manager, False) self.display.setup() self.bg_frame = None diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 5055bb619..13c421708 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -85,7 +85,6 @@ class UiStrings(object): self.LengthTime = unicode(translate('OpenLP.Ui', 'Length %s')) self.Live = translate('OpenLP.Ui', 'Live') self.LiveBGError = translate('OpenLP.Ui', 'Live Background Error') - self.LivePanel = translate('OpenLP.Ui', 'Live Panel') self.LiveToolbar = translate('OpenLP.Ui', 'Live Toolbar') self.Load = translate('OpenLP.Ui', 'Load') self.Minutes = translate('OpenLP.Ui', 'm', @@ -102,14 +101,13 @@ class UiStrings(object): self.OLPV2 = translate('OpenLP.Ui', 'OpenLP 2.0') self.OpenLPStart = translate('OpenLP.Ui', 'OpenLP is already running. ' 'Do you wish to continue?') - self.OpenService = translate('OpenLP.Ui', 'Open Service') + self.OpenService = translate('OpenLP.Ui', 'Open service.') self.Preview = translate('OpenLP.Ui', 'Preview') - self.PreviewPanel = translate('OpenLP.Ui', 'Preview Panel') - self.PrintServiceOrder = translate('OpenLP.Ui', 'Print Service Order') + self.PrintService = translate('OpenLP.Ui', 'Print Service') self.ReplaceBG = translate('OpenLP.Ui', 'Replace Background') - self.ReplaceLiveBG = translate('OpenLP.Ui', 'Replace Live Background') + self.ReplaceLiveBG = translate('OpenLP.Ui', 'Replace live background.') self.ResetBG = translate('OpenLP.Ui', 'Reset Background') - self.ResetLiveBG = translate('OpenLP.Ui', 'Reset Live Background') + self.ResetLiveBG = translate('OpenLP.Ui', 'Reset live background.') self.Seconds = translate('OpenLP.Ui', 's', 'The abbreviated unit for seconds') self.SaveAndPreview = translate('OpenLP.Ui', 'Save && Preview') diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 3b006bf5e..c83a199b1 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -200,15 +200,14 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): """ Prepare the UI for the process. """ - # We start on 2 for plugins status setting plus a "finished" point. - max_progress = 2 + self.max_progress = 0 # Loop through the songs list and increase for each selected item for i in xrange(self.songsListWidget.count()): item = self.songsListWidget.item(i) if item.checkState() == QtCore.Qt.Checked: filename = item.data(QtCore.Qt.UserRole).toString() size = self._getFileSize(u'%s%s' % (self.web, filename)) - max_progress += size + self.max_progress += size # Loop through the Bibles list and increase for each selected item iterator = QtGui.QTreeWidgetItemIterator(self.biblesTreeWidget) while iterator.value(): @@ -216,7 +215,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): if item.parent() and item.checkState(0) == QtCore.Qt.Checked: filename = item.data(0, QtCore.Qt.UserRole).toString() size = self._getFileSize(u'%s%s' % (self.web, filename)) - max_progress += size + self.max_progress += size iterator += 1 # Loop through the themes list and increase for each selected item for i in xrange(self.themesListWidget.count()): @@ -224,23 +223,40 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): if item.checkState() == QtCore.Qt.Checked: filename = item.data(QtCore.Qt.UserRole).toString() size = self._getFileSize(u'%s%s' % (self.web, filename)) - max_progress += size + self.max_progress += size self.finishButton.setVisible(False) - self.progressBar.setValue(0) - self.progressBar.setMinimum(0) - self.progressBar.setMaximum(max_progress) + if self.max_progress: + # Add on 2 for plugins status setting plus a "finished" point. + self.max_progress = self.max_progress + 2 + self.progressBar.setValue(0) + self.progressBar.setMinimum(0) + self.progressBar.setMaximum(self.max_progress) + self.progressPage.setTitle(translate('OpenLP.FirstTimeWizard', + 'Setting Up And Downloading')) + self.progressPage.setSubTitle(translate('OpenLP.FirstTimeWizard', + 'Please wait while OpenLP is set up ' + 'and your data is downloaded.')) + else: + self.progressBar.setVisible(False) + self.progressPage.setTitle(translate('OpenLP.FirstTimeWizard', + 'Setting Up')) + self.progressPage.setSubTitle(u'Setup complete.') def _postWizard(self): """ Clean up the UI after the process has finished. """ - self.progressBar.setValue(self.progressBar.maximum()) + if self.max_progress: + self.progressBar.setValue(self.progressBar.maximum()) + self.progressLabel.setText(translate('OpenLP.FirstTimeWizard', + 'Download complete. Click the finish button to start OpenLP.')) + else: + self.progressLabel.setText(translate('OpenLP.FirstTimeWizard', + 'Click the finish button to start OpenLP.')) self.finishButton.setVisible(True) self.finishButton.setEnabled(True) self.cancelButton.setVisible(False) self.nextButton.setVisible(False) - self.progressLabel.setText(translate('OpenLP.FirstTimeWizard', - 'Download complete. Click the finish button to start OpenLP.')) Receiver.send_message(u'openlp_process_events') def _performWizard(self): diff --git a/openlp/core/ui/firsttimewizard.py b/openlp/core/ui/firsttimewizard.py index 6852d533a..fa7d88ed6 100644 --- a/openlp/core/ui/firsttimewizard.py +++ b/openlp/core/ui/firsttimewizard.py @@ -254,10 +254,6 @@ class Ui_FirstTimeWizard(object): 'Default Settings')) self.defaultsPage.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Set up default settings to be used by OpenLP.')) - self.progressPage.setTitle(translate('OpenLP.FirstTimeWizard', - 'Setting Up And Importing')) - self.progressPage.setSubTitle(translate('OpenLP.FirstTimeWizard', - 'Please wait while OpenLP is set up and your data is imported.')) self.displayLabel.setText(translate('OpenLP.FirstTimeWizard', 'Default output display:')) self.themeLabel.setText(translate('OpenLP.FirstTimeWizard', diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index e2117cc10..0db8bb26f 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -63,6 +63,7 @@ class MainDisplay(QtGui.QGraphicsView): self.setStyleSheet(u'border: 0px; margin: 0px; padding: 0px;') self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool | QtCore.Qt.WindowStaysOnTopHint) + self.setAttribute(QtCore.Qt.WA_DeleteOnClose) if self.isLive: QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'maindisplay_hide'), self.hideDisplay) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index b4a3b3640..091703c13 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -356,9 +356,9 @@ class Ui_MainWindow(object): translate('OpenLP.MainWindow', 'Save Service As')) self.fileSaveAsItem.setStatusTip(translate('OpenLP.MainWindow', 'Save the current service under a new name.')) - self.printServiceOrderItem.setText(UiStrings().PrintServiceOrder) + self.printServiceOrderItem.setText(UiStrings().PrintService) self.printServiceOrderItem.setStatusTip(translate('OpenLP.MainWindow', - 'Print the current Service Order.')) + 'Print the current service.')) self.fileExitItem.setText( translate('OpenLP.MainWindow', 'E&xit')) self.fileExitItem.setStatusTip( diff --git a/openlp/core/ui/printservicedialog.py b/openlp/core/ui/printservicedialog.py index 4afd58b74..805b3a1b5 100644 --- a/openlp/core/ui/printservicedialog.py +++ b/openlp/core/ui/printservicedialog.py @@ -149,7 +149,7 @@ class Ui_PrintServiceDialog(object): QtCore.SIGNAL(u'toggled(bool)'), self.toggleOptions) def retranslateUi(self, printServiceDialog): - printServiceDialog.setWindowTitle(UiStrings().PrintServiceOrder) + printServiceDialog.setWindowTitle(UiStrings().PrintService) self.slideTextCheckBox.setText(translate('OpenLP.PrintServiceForm', 'Include slide text if available')) self.pageBreakAfterText.setText(translate('OpenLP.PrintServiceForm', @@ -159,7 +159,7 @@ class Ui_PrintServiceDialog(object): self.metaDataCheckBox.setText(translate('OpenLP.PrintServiceForm', 'Include play length of media items')) self.titleLineEdit.setText(translate('OpenLP.PrintServiceForm', - 'Service Order Sheet')) + 'Service Sheet')) self.zoomComboBox.addItem(ZoomSize.Sizes[ZoomSize.Page]) self.zoomComboBox.addItem(ZoomSize.Sizes[ZoomSize.Width]) self.zoomComboBox.addItem(ZoomSize.Sizes[ZoomSize.OneHundred]) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 8ecd89bc7..8a018d915 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1035,6 +1035,7 @@ class ServiceManager(QtGui.QWidget): item[u'selected'] = False serviceIterator = QtGui.QTreeWidgetItemIterator( self.serviceManagerList) + selectedItem = None while serviceIterator.value(): if serviceIterator.value().isSelected(): selectedItem = serviceIterator.value() diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 5b6212cf8..d490f3bce 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -59,6 +59,7 @@ class SlideController(QtGui.QWidget): """ QtGui.QWidget.__init__(self, parent) self.isLive = isLive + self.display = None self.screens = ScreenList.get_instance() self.ratio = float(self.screens.current[u'size'].width()) / \ float(self.screens.current[u'size'].height()) @@ -422,6 +423,8 @@ class SlideController(QtGui.QWidget): screen previews. """ # rebuild display as screen size changed + if self.display: + self.display.close() self.display = MainDisplay(self, self.image_manager, self.isLive) self.display.alertTab = self.alertTab self.display.setup() diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 7913aac31..6d86851a0 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -732,6 +732,7 @@ class BibleUpgradeForm(OpenLPWizard): self.newbibles[number].session.commit() if not bible_failed: self.newbibles[number].create_meta(u'Version', name) + oldbible.close_connection() delete_file(os.path.join(self.path, filename[0])) self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 41dc947f9..49488be0e 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -1101,3 +1101,7 @@ class OldBibleDB(QtCore.QObject, Manager): ] else: return None + + def close_connection(self): + self.cursor.close() + self.connection.close() diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 5209461df..f2b9a57d3 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -983,7 +983,7 @@ class BibleMediaItem(MediaManagerItem): Search for some Bible verses (by reference). """ bible = unicode(self.quickVersionComboBox.currentText()) - search_results = self.plugin.manager.get_verses(bible, string, False) + search_results = self.plugin.manager.get_verses(bible, string, False, False) results = [] if search_results: versetext = u' '.join([verse.text for verse in search_results]) diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 4a7585f11..32a2a3146 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -93,6 +93,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.titleEdit.setText(u'') self.creditEdit.setText(u'') self.themeComboBox.setCurrentIndex(0) + self.titleEdit.setFocus(QtCore.Qt.OtherFocusReason) else: self.customSlide = self.manager.get_object(CustomSlide, id) self.titleEdit.setText(self.customSlide.title)