From 96f5a62fbe30102c27265aad6588b9d17768ade2 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 9 Mar 2011 17:54:59 +0000 Subject: [PATCH 01/49] Cleanups --- openlp/core/ui/firsttimelanguageform.py | 1 - openlp/core/ui/maindisplay.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/openlp/core/ui/firsttimelanguageform.py b/openlp/core/ui/firsttimelanguageform.py index 98489fde7..3916e428e 100644 --- a/openlp/core/ui/firsttimelanguageform.py +++ b/openlp/core/ui/firsttimelanguageform.py @@ -28,7 +28,6 @@ from PyQt4 import QtGui from firsttimelanguagedialog import Ui_FirstTimeLanguageDialog -from openlp.core.lib import translate from openlp.core.utils import LanguageManager class FirstTimeLanguageForm(QtGui.QDialog, Ui_FirstTimeLanguageDialog): diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 357eb655a..a3195fc39 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -396,7 +396,7 @@ class MainDisplay(DisplayWidget): if self.hideMode: self.hideDisplay(self.hideMode) else: - self.setVisible(True) + self.setVisible(True) preview = QtGui.QImage(self.screen[u'size'].width(), self.screen[u'size'].height(), QtGui.QImage.Format_ARGB32_Premultiplied) From 292aba71daeb6f2830079602f7b86440909504d0 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 9 Mar 2011 20:50:12 +0000 Subject: [PATCH 02/49] UiStrings.OpenFile --- openlp/core/lib/ui.py | 1 + openlp/core/ui/advancedtab.py | 3 +-- openlp/core/ui/servicemanager.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index eae4f60ca..1306a903f 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -73,6 +73,7 @@ class UiStrings(object): NISp = translate('OpenLP.Ui', 'No Items Selected', 'Plural') OLPV1 = translate('OpenLP.Ui', 'openlp.org 1.x') OLPV2 = translate('OpenLP.Ui', 'OpenLP 2.0') + OpenFile = translate('OpenLP.Ui', 'Open File') OpenService = translate('OpenLP.Ui', 'Open Service') Preview = translate('OpenLP.Ui', 'Preview') PreviewPanel = translate('OpenLP.Ui', 'Preview Panel') diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index a8e8b294e..bb3a252a9 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -215,8 +215,7 @@ class AdvancedTab(SettingsTab): file_filters = u'%s;;%s (*.*) (*)' % (get_images_filter(), UiStrings.AllFiles) filename = QtGui.QFileDialog.getOpenFileName(self, - translate('OpenLP.AdvancedTab', 'Open File'), '', - file_filters) + UiStrings.OpenFile, '', file_filters) if filename: self.defaultFileEdit.setText(filename) self.defaultFileEdit.setFocus() diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 3cdf25c7a..47e1f2de0 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -376,7 +376,7 @@ class ServiceManager(QtGui.QWidget): elif result == QtGui.QMessageBox.Save: self.saveFile() fileName = unicode(QtGui.QFileDialog.getOpenFileName(self.mainwindow, - translate('OpenLP.ServiceManager', 'Open File'), + UiStrings.OpenFile, SettingsManager.get_last_dir( self.mainwindow.serviceSettingsSection), translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz)'))) From 85b5a31813695b37c95cc406af906ec698350f26 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 11 Mar 2011 16:35:32 +0000 Subject: [PATCH 03/49] Unused import --- openlp/plugins/songs/lib/sofimport.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/plugins/songs/lib/sofimport.py b/openlp/plugins/songs/lib/sofimport.py index 49adcd302..37f3136e9 100644 --- a/openlp/plugins/songs/lib/sofimport.py +++ b/openlp/plugins/songs/lib/sofimport.py @@ -33,7 +33,6 @@ import os import re -from songimport import SongImport from oooimport import OooImport if os.name == u'nt': From c663c09932c73d5c133794a8e256815ea88e994a Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 11 Mar 2011 16:51:07 +0000 Subject: [PATCH 04/49] Unused variables --- openlp/core/ui/servicemanager.py | 4 ++-- openlp/plugins/images/lib/mediaitem.py | 17 +++++++++-------- openlp/plugins/media/lib/mediaitem.py | 1 - 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index bb313fa3b..05a5b3d5c 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -417,7 +417,7 @@ class ServiceManager(QtGui.QWidget): return self.saveFileAs() path_file_name = unicode(self.fileName()) (path, file_name) = os.path.split(path_file_name) - (basename, extension) = os.path.splitext(file_name) + basename = os.path.splitext(file_name)[0] service_file_name = basename + '.osd' log.debug(u'ServiceManager.saveFile - %s' % path_file_name) SettingsManager.set_last_dir(self.mainwindow.serviceSettingsSection, @@ -439,7 +439,7 @@ class ServiceManager(QtGui.QWidget): if path_from in write_list: continue file_size = os.path.getsize(path_from) - size_limit = 52428800 # 50MiB + #size_limit = 52428800 # 50MiB #if file_size > size_limit: # # File exeeds size_limit bytes, ask user # message = unicode(translate('OpenLP.ServiceManager', diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index e6fdfe7db..ac4074835 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -162,9 +162,9 @@ class ImageMediaItem(MediaManagerItem): # Continue with the existing images. for item in items: bitem = self.listView.item(item.row()) - filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) - (path, name) = os.path.split(filename) - service_item.add_from_image(filename, name) + filepath = unicode(bitem.data(QtCore.Qt.UserRole).toString()) + filename = os.path.split(filepath)[1] + service_item.add_from_image(filepath, filename) return True else: return False @@ -191,13 +191,14 @@ class ImageMediaItem(MediaManagerItem): 'You must select an image to replace the background with.')): 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) + filepath = unicode(bitem.data(QtCore.Qt.UserRole).toString()) + if os.path.exists(filepath): + filename = os.path.split(filename)[1] + self.parent.liveController.display.directImage(filename, + filepath) self.resetAction.setVisible(True) else: critical_error_message_box(UiStrings.LiveBGError, unicode(translate('ImagePlugin.MediaItem', 'There was a problem replacing your background, ' - 'the image file "%s" no longer exists.')) % filename) + 'the image file "%s" no longer exists.')) % filepath) diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 40ea7abb1..d5d6ad926 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -109,7 +109,6 @@ class MediaMediaItem(MediaManagerItem): item = self.listView.currentItem() filename = unicode(item.data(QtCore.Qt.UserRole).toString()) if os.path.exists(filename): - (path, name) = os.path.split(filename) self.parent.liveController.display.video(filename, 0, True) self.resetAction.setVisible(True) else: From 89cf1f8c8cdfaa44cba570bd62bc66f6bb8a0771 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 15 Mar 2011 12:56:47 +0000 Subject: [PATCH 05/49] Fix typo --- 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 ac4074835..fd7d39c57 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -193,7 +193,7 @@ class ImageMediaItem(MediaManagerItem): bitem = self.listView.item(item.row()) filepath = unicode(bitem.data(QtCore.Qt.UserRole).toString()) if os.path.exists(filepath): - filename = os.path.split(filename)[1] + filename = os.path.split(filepath)[1] self.parent.liveController.display.directImage(filename, filepath) self.resetAction.setVisible(True) From f931bb29f09e330359ea4592f28eeb85fd224886 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 19 Mar 2011 01:46:45 +0000 Subject: [PATCH 06/49] Unused import --- openlp/plugins/remotes/lib/httpserver.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index 0d1e163eb..53603101a 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -111,7 +111,6 @@ import logging import os import urlparse import re -from pprint import pformat try: import json From 4222b0be9fe93a312003ad91561bd5964cd193ed Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 19 Mar 2011 12:57:48 +0000 Subject: [PATCH 07/49] Long line --- openlp/plugins/songs/lib/songbeamerimport.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/songbeamerimport.py b/openlp/plugins/songs/lib/songbeamerimport.py index 6d6b4e932..b28150ad7 100644 --- a/openlp/plugins/songs/lib/songbeamerimport.py +++ b/openlp/plugins/songs/lib/songbeamerimport.py @@ -112,7 +112,8 @@ class SongBeamerImport(SongImport): self.add_verse(self.current_verse, self.current_verse_type) self.current_verse = u'' - self.current_verse_type = VerseType.Tags[VerseType.Verse] + self.current_verse_type = \ + VerseType.Tags[VerseType.Verse] read_verses = True verse_start = True elif read_verses: From 95fad4b2d7509dde0ac824b4f037d2c9ab201c38 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 26 Mar 2011 22:46:56 +0000 Subject: [PATCH 08/49] Alignment --- openlp/core/ui/firsttimewizard.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/firsttimewizard.py b/openlp/core/ui/firsttimewizard.py index 4c7ae6880..71b3f5dfc 100644 --- a/openlp/core/ui/firsttimewizard.py +++ b/openlp/core/ui/firsttimewizard.py @@ -80,9 +80,9 @@ class Ui_FirstTimeWizard(object): self.pluginLayout.addWidget(self.imageCheckBox) self.presentationCheckBox = QtGui.QCheckBox(self.pluginPage) if sys.platform == "darwin": - self.presentationCheckBox.setChecked(False) + self.presentationCheckBox.setChecked(False) else: - self.presentationCheckBox.setChecked(True) + self.presentationCheckBox.setChecked(True) self.presentationCheckBox.setObjectName(u'presentationCheckBox') self.pluginLayout.addWidget(self.presentationCheckBox) self.mediaCheckBox = QtGui.QCheckBox(self.pluginPage) From ac365e5b6a735ce41620cd7e22e35e5f0f4d9580 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 26 Nov 2011 21:26:50 +0000 Subject: [PATCH 09/49] Cleanups --- openlp/core/lib/listwidgetwithdnd.py | 4 ++-- openlp/core/ui/maindisplay.py | 1 - openlp/core/ui/mainwindow.py | 8 ++++---- openlp/core/ui/themelayoutdialog.py | 1 - openlp/core/ui/themelayoutform.py | 3 --- openlp/plugins/alerts/lib/alertstab.py | 2 +- openlp/plugins/bibles/lib/versereferencelist.py | 3 ++- openlp/plugins/custom/forms/editcustomform.py | 3 ++- openlp/plugins/presentations/lib/mediaitem.py | 3 ++- openlp/plugins/songs/forms/editsongform.py | 10 ++++++---- openlp/plugins/songs/lib/upgrade.py | 1 - openlp/plugins/songusage/lib/upgrade.py | 1 - 12 files changed, 19 insertions(+), 21 deletions(-) diff --git a/openlp/core/lib/listwidgetwithdnd.py b/openlp/core/lib/listwidgetwithdnd.py index 69fb23092..31be1f5be 100644 --- a/openlp/core/lib/listwidgetwithdnd.py +++ b/openlp/core/lib/listwidgetwithdnd.py @@ -104,7 +104,7 @@ class ListWidgetWithDnD(QtGui.QListWidget): elif os.path.isdir(localFile): listing = os.listdir(localFile) for file in listing: - files.append(os.path.join(localFile,file)) - Receiver.send_message(u'%s_dnd' % self.mimeDataText,files) + files.append(os.path.join(localFile, file)) + Receiver.send_message(u'%s_dnd' % self.mimeDataText, files) else: event.ignore() diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 2a16867e5..c4f0903c7 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -29,7 +29,6 @@ The :mod:`maindisplay` module provides the functionality to display screens and play multimedia within OpenLP. """ import logging -import os from PyQt4 import QtCore, QtGui, QtWebKit from PyQt4.phonon import Phonon diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 47570cd8a..ed1a9318c 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -35,15 +35,14 @@ from datetime import datetime from PyQt4 import QtCore, QtGui from openlp.core.lib import Renderer, build_icon, OpenLPDockWidget, \ - PluginManager, Receiver, translate, ImageManager, PluginStatus, \ - SettingsManager + PluginManager, Receiver, translate, ImageManager, PluginStatus from openlp.core.lib.ui import UiStrings, base_action, checkable_action, \ icon_action, shortcut_action from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \ ThemeManager, SlideController, PluginForm, MediaDockManager, \ ShortcutListForm, FormattingTagForm from openlp.core.utils import AppLocation, add_actions, LanguageManager, \ - get_application_version, delete_file + get_application_version from openlp.core.utils.actions import ActionList, CategoryOrder from openlp.core.ui.firsttimeform import FirstTimeForm from openlp.core.ui import ScreenList @@ -503,7 +502,8 @@ class Ui_MainWindow(object): self.toolsFirstTimeWizard.setText( translate('OpenLP.MainWindow', 'Re-run First Time Wizard')) self.toolsFirstTimeWizard.setStatusTip(translate('OpenLP.MainWindow', - 'Re-run the First Time Wizard, importing songs, Bibles and themes.')) + 'Re-run the First Time Wizard, importing songs, Bibles and ' + 'themes.')) self.updateThemeImages.setText( translate('OpenLP.MainWindow', 'Update Theme Images')) self.updateThemeImages.setStatusTip( diff --git a/openlp/core/ui/themelayoutdialog.py b/openlp/core/ui/themelayoutdialog.py index 5be08ad65..56bfe79bb 100644 --- a/openlp/core/ui/themelayoutdialog.py +++ b/openlp/core/ui/themelayoutdialog.py @@ -28,7 +28,6 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate -from openlp.core.lib.ui import create_accept_reject_button_box class Ui_ThemeLayoutDialog(object): diff --git a/openlp/core/ui/themelayoutform.py b/openlp/core/ui/themelayoutform.py index 6f77d31da..57d8bd952 100644 --- a/openlp/core/ui/themelayoutform.py +++ b/openlp/core/ui/themelayoutform.py @@ -29,9 +29,6 @@ from PyQt4 import QtGui, QtCore from themelayoutdialog import Ui_ThemeLayoutDialog -from openlp.core.lib import translate -from openlp.core.lib.ui import UiStrings, critical_error_message_box - class ThemeLayoutForm(QtGui.QDialog, Ui_ThemeLayoutDialog): """ The exception dialog diff --git a/openlp/plugins/alerts/lib/alertstab.py b/openlp/plugins/alerts/lib/alertstab.py index bd879fef3..90e06caab 100644 --- a/openlp/plugins/alerts/lib/alertstab.py +++ b/openlp/plugins/alerts/lib/alertstab.py @@ -192,7 +192,7 @@ class AlertsTab(SettingsTab): settings.setValue(u'location', QtCore.QVariant(self.location)) settings.endGroup() if self.changed: - Receiver.send_message(u'update_display_css') + Receiver.send_message(u'update_display_css') self.changed = False def updateDisplay(self): diff --git a/openlp/plugins/bibles/lib/versereferencelist.py b/openlp/plugins/bibles/lib/versereferencelist.py index 471fc6a66..a1727655e 100644 --- a/openlp/plugins/bibles/lib/versereferencelist.py +++ b/openlp/plugins/bibles/lib/versereferencelist.py @@ -72,7 +72,8 @@ class VerseReferenceList(object): continue prev = index - 1 if self.verse_list[prev][u'version'] != verse[u'version']: - result = u'%s (%s)' % (result, self.verse_list[prev][u'version']) + result = u'%s (%s)' % (result, + self.verse_list[prev][u'version']) result = result + u', ' if self.verse_list[prev][u'book'] != verse[u'book']: result = u'%s%s %s:' % (result, verse[u'book'], diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 0eadf6021..a85daa38b 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -30,7 +30,8 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import Receiver, translate -from openlp.core.lib.ui import critical_error_message_box, find_and_set_in_combo_box +from openlp.core.lib.ui import critical_error_message_box, \ + find_and_set_in_combo_box from openlp.plugins.custom.lib import CustomXMLBuilder, CustomXMLParser from openlp.plugins.custom.lib.db import CustomSlide from editcustomdialog import Ui_CustomEditDialog diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index e1dd57271..6dc57373a 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -285,7 +285,8 @@ class PresentationMediaItem(MediaManagerItem): critical_error_message_box( translate('PresentationPlugin.MediaItem', 'Missing Presentation'), - unicode(translate('PresentationPlugin.MediaItem', + unicode(translate( + 'PresentationPlugin.MediaItem', 'The Presentation %s is incomplete,' ' please reload.')) % filename) return False diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 1c254406c..9164ef2a9 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -331,8 +331,10 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.topicsListView.addItem(topic_name) self.audioListWidget.clear() for media in self.song.media_files: - media_file = QtGui.QListWidgetItem(os.path.split(media.file_name)[1]) - media_file.setData(QtCore.Qt.UserRole, QtCore.QVariant(media.file_name)) + media_file = QtGui.QListWidgetItem( + os.path.split(media.file_name)[1]) + media_file.setData(QtCore.Qt.UserRole, + QtCore.QVariant(media.file_name)) self.audioListWidget.addItem(media_file) self.titleEdit.setFocus(QtCore.Qt.OtherFocusReason) # Hide or show the preview button. @@ -721,7 +723,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): """ if self.mediaForm.exec_(): for filename in self.mediaForm.getSelectedFiles(): - item = QtGui.QListWidgetItem(os.path.split(unicode(filename))[1]) + item = QtGui.QListWidgetItem( + os.path.split(unicode(filename))[1]) item.setData(QtCore.Qt.UserRole, filename) self.audioListWidget.addItem(item) @@ -876,7 +879,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): os.remove(audio) except: log.exception('Could not remove file: %s', audio) - pass if not files: try: os.rmdir(save_path) diff --git a/openlp/plugins/songs/lib/upgrade.py b/openlp/plugins/songs/lib/upgrade.py index 21988c267..c1ce65702 100644 --- a/openlp/plugins/songs/lib/upgrade.py +++ b/openlp/plugins/songs/lib/upgrade.py @@ -31,7 +31,6 @@ backend for the Songs plugin from sqlalchemy import Column, Table, types from sqlalchemy.sql.expression import func -from migrate import changeset from migrate.changeset.constraint import ForeignKeyConstraint __version__ = 2 diff --git a/openlp/plugins/songusage/lib/upgrade.py b/openlp/plugins/songusage/lib/upgrade.py index 50ca32fcd..e9a508b76 100644 --- a/openlp/plugins/songusage/lib/upgrade.py +++ b/openlp/plugins/songusage/lib/upgrade.py @@ -30,7 +30,6 @@ backend for the SongsUsage plugin """ from sqlalchemy import Column, Table, types -from migrate import changeset __version__ = 1 From 5b4e8826ec06cf3ee4c3e6a50c100d4ccb1201f6 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 26 Nov 2011 21:59:21 +0000 Subject: [PATCH 10/49] Fix undefined variables --- openlp/plugins/songs/lib/olpimport.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/olpimport.py b/openlp/plugins/songs/lib/olpimport.py index 7d2558ce8..b3acee5aa 100644 --- a/openlp/plugins/songs/lib/olpimport.py +++ b/openlp/plugins/songs/lib/olpimport.py @@ -39,7 +39,7 @@ from openlp.core.lib import translate from openlp.core.lib.db import BaseModel from openlp.core.ui.wizard import WizardStrings from openlp.plugins.songs.lib import clean_song -from openlp.plugins.songs.lib.db import Author, Book, Song, Topic #, MediaFile +from openlp.plugins.songs.lib.db import Author, Book, MediaFile, Song, Topic from songimport import SongImport log = logging.getLogger(__name__) From f970d9462d109bd34deb75f4d45f1c4d5d71e998 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 2 Dec 2011 21:13:05 +0000 Subject: [PATCH 11/49] Cleanups --- openlp/core/ui/firsttimeform.py | 2 +- openlp/core/ui/media/mediacontroller.py | 35 ++++++++++++++----------- openlp/core/ui/media/phononplayer.py | 1 - openlp/core/ui/media/webkitplayer.py | 3 --- openlp/core/ui/slidecontroller.py | 23 ++++++++-------- openlp/plugins/media/lib/mediaitem.py | 4 +-- openlp/plugins/media/lib/mediatab.py | 2 +- openlp/plugins/media/mediaplugin.py | 1 - 8 files changed, 34 insertions(+), 37 deletions(-) diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index bfa4bf6b1..9a5a2ea9d 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -65,7 +65,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): self.downloadCanceled = False self.downloading = unicode(translate('OpenLP.FirstTimeWizard', 'Downloading %s...')) - QtCore.QObject.connect(self.cancelButton,QtCore.SIGNAL('clicked()'), + QtCore.QObject.connect(self.cancelButton, QtCore.SIGNAL('clicked()'), self.onCancelButtonClicked) QtCore.QObject.connect(self.noInternetFinishButton, QtCore.SIGNAL('clicked()'), self.onNoInternetFinishButtonClicked) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 453567d28..aca141271 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -26,13 +26,12 @@ ############################################################################### import logging - -import sys, os,time -from PyQt4 import QtCore, QtGui, QtWebKit +import os +from PyQt4 import QtCore, QtGui from openlp.core.lib import OpenLPToolbar, Receiver, translate from openlp.core.lib.mediaplayer import MediaPlayer -from openlp.core.lib.ui import UiStrings, critical_error_message_box +from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui.media import MediaState, MediaInfo, MediaType from openlp.core.utils import AppLocation @@ -136,8 +135,9 @@ class MediaController(object): savedPlayers = playerSettings.split(u',') invalidMediaPlayers = [mediaPlayer for mediaPlayer in savedPlayers \ if not mediaPlayer in self.mediaPlayers] - if len(invalidMediaPlayers)>0: - [savedPlayers.remove(invalidPlayer) for invalidPlayer in invalidMediaPlayers] + if len(invalidMediaPlayers) > 0: + for invalidPlayer in invalidMediaPlayers: + savedPlayers.remove(invalidPlayer) newPlayerSetting = u','.join(savedPlayers) QtCore.QSettings().setValue(u'media/players', QtCore.QVariant(newPlayerSetting)) @@ -346,7 +346,7 @@ class MediaController(object): def check_file_type(self, controller, display): """ - Used to choose the right media Player type from the prioritized Player list + Select the correct media Player type from the prioritized Player list """ playerSettings = str(QtCore.QSettings().value(u'media/players', QtCore.QVariant(u'webkit')).toString()) @@ -354,19 +354,21 @@ class MediaController(object): if QtCore.QSettings().value(u'media/override player', QtCore.QVariant(QtCore.Qt.Unchecked)) == QtCore.Qt.Checked: if self.overridenPlayer != '': - usedPlayers = [self.overridenPlayer] + usedPlayers = [self.overridenPlayer] if controller.media_info.file_info.isFile(): - suffix = u'*.%s' % controller.media_info.file_info.suffix().toLower() + suffix = u'*.%s' % \ + controller.media_info.file_info.suffix().toLower() for title in usedPlayers: player = self.mediaPlayers[title] if suffix in player.video_extensions_list: if not controller.media_info.is_background or \ - controller.media_info.is_background and player.canBackground: - self.resize(controller, display, player) - if player.load(display): - self.curDisplayMediaPlayer[display] = player - controller.media_info.media_type = MediaType.Video - return True + controller.media_info.is_background and \ + player.canBackground: + self.resize(controller, display, player) + if player.load(display): + self.curDisplayMediaPlayer[display] = player + controller.media_info.media_type = MediaType.Video + return True if suffix in player.audio_extensions_list: if player.load(display): self.curDisplayMediaPlayer[display] = player @@ -399,7 +401,8 @@ class MediaController(object): return False if status: display.frame.evaluateJavaScript(u'show_blank("desktop");') - self.curDisplayMediaPlayer[display].set_visible(display, True) + self.curDisplayMediaPlayer[display].set_visible(display, + True) if controller.isLive: if controller.hideMenu.defaultAction().isChecked(): controller.hideMenu.defaultAction().trigger() diff --git a/openlp/core/ui/media/phononplayer.py b/openlp/core/ui/media/phononplayer.py index abafb1d5c..5203c5960 100644 --- a/openlp/core/ui/media/phononplayer.py +++ b/openlp/core/ui/media/phononplayer.py @@ -29,7 +29,6 @@ import logging import mimetypes from datetime import datetime -from PyQt4 import QtCore, QtGui from PyQt4.phonon import Phonon from openlp.core.lib import Receiver diff --git a/openlp/core/ui/media/webkitplayer.py b/openlp/core/ui/media/webkitplayer.py index 058f30f58..3f7bc37be 100644 --- a/openlp/core/ui/media/webkitplayer.py +++ b/openlp/core/ui/media/webkitplayer.py @@ -27,9 +27,6 @@ import logging -from PyQt4 import QtCore, QtGui, QtWebKit - -from openlp.core.lib import OpenLPToolbar, translate from openlp.core.lib.mediaplayer import MediaPlayer from openlp.core.ui.media import MediaState diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 316243b91..3cb98ff97 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -27,12 +27,10 @@ import os import logging -import time import copy from collections import deque from PyQt4 import QtCore, QtGui -from PyQt4.phonon import Phonon from openlp.core.lib import OpenLPToolbar, Receiver, ItemCapabilities, \ translate, build_icon, ServiceItem, build_html, PluginManager, ServiceItem @@ -68,7 +66,8 @@ class Controller(QtGui.QWidget): created from within other plugins This function is needed to catch the current controller """ - sender = self.sender().objectName() if self.sender().objectName() else self.sender().text() + sender = self.sender().objectName() if self.sender().objectName() \ + else self.sender().text() controller = self Receiver.send_message('%s' % sender, [controller, args]) @@ -573,7 +572,6 @@ class SlideController(Controller): """ self.keypress_queue.append(u'previous') self._process_queue() - def serviceNext(self): """ @@ -581,7 +579,7 @@ class SlideController(Controller): """ self.keypress_queue.append(u'next') self._process_queue() - + def _process_queue(self): """ Process the service item request queue. The key presses can arrive @@ -595,7 +593,6 @@ class SlideController(Controller): else: Receiver.send_message('servicemanager_next_item') self.keypress_loop = False - def screenSizeChanged(self): """ @@ -640,11 +637,12 @@ class SlideController(Controller): self.previewFrame.height()): # We have to take the height as limit. max_height = self.previewFrame.height() - self.grid.margin() * 2 - self.slidePreview.setFixedSize(QtCore.QSize(max_height * self.ratio, - max_height)) - self.previewDisplay.setFixedSize(QtCore.QSize(max_height * self.ratio, - max_height)) - self.previewDisplay.screen = {u'size':self.previewDisplay.geometry()} + self.slidePreview.setFixedSize(QtCore.QSize( + max_height * self.ratio, max_height)) + self.previewDisplay.setFixedSize(QtCore.QSize( + max_height * self.ratio, max_height)) + self.previewDisplay.screen = { + u'size':self.previewDisplay.geometry()} else: # We have to take the width as limit. max_width = self.previewFrame.width() - self.grid.margin() * 2 @@ -652,7 +650,8 @@ class SlideController(Controller): max_width / self.ratio)) self.previewDisplay.setFixedSize(QtCore.QSize(max_width, max_width / self.ratio)) - self.previewDisplay.screen = {u'size':self.previewDisplay.geometry()} + self.previewDisplay.screen = { + u'size':self.previewDisplay.geometry()} # Make sure that the frames have the correct size. self.previewListWidget.setColumnWidth(0, self.previewListWidget.viewport().size().width()) diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index d33aeb47b..0d5d8eeff 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -30,7 +30,6 @@ import os import locale from PyQt4 import QtCore, QtGui -from PyQt4.phonon import Phonon from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, \ SettingsManager, translate, check_item_selected, Receiver, MediaType, \ @@ -139,7 +138,8 @@ class MediaMediaItem(MediaManagerItem): # Add the Media widget to the page layout self.pageLayout.addWidget(self.mediaWidget) QtCore.QObject.connect(self.displayTypeComboBox, - QtCore.SIGNAL(u'currentIndexChanged (int)'), self.overridePlayerChanged) + QtCore.SIGNAL(u'currentIndexChanged (int)'), + self.overridePlayerChanged) def overridePlayerChanged(self, index): Receiver.send_message(u'media_override_player', \ diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index 2b2485dea..4e39bc419 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -28,7 +28,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import SettingsTab, translate, Receiver -from openlp.core.lib.ui import UiStrings, critical_error_message_box +from openlp.core.lib.ui import UiStrings class MediaTab(SettingsTab): """ diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index 13a84b289..97f749689 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -26,7 +26,6 @@ ############################################################################### import logging -import os from openlp.core.lib import Plugin, StringContent, build_icon, translate from openlp.plugins.media.lib import MediaMediaItem, MediaTab From e526687c71df6b15a29aa71249bc8cb76f801b60 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 2 Dec 2011 21:33:11 +0000 Subject: [PATCH 12/49] Cleanup fix --- openlp/core/ui/media/mediacontroller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index aca141271..b05a7fe59 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -354,7 +354,7 @@ class MediaController(object): if QtCore.QSettings().value(u'media/override player', QtCore.QVariant(QtCore.Qt.Unchecked)) == QtCore.Qt.Checked: if self.overridenPlayer != '': - usedPlayers = [self.overridenPlayer] + usedPlayers = [self.overridenPlayer] if controller.media_info.file_info.isFile(): suffix = u'*.%s' % \ controller.media_info.file_info.suffix().toLower() From bd02fb5f30f7d23a85bbda0ed530297d63841846 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 2 Dec 2011 21:49:20 +0000 Subject: [PATCH 13/49] Whitespace --- openlp/core/ui/slidecontroller.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 3cb98ff97..f6d5e3d90 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -582,14 +582,14 @@ class SlideController(Controller): def _process_queue(self): """ - Process the service item request queue. The key presses can arrive - faster than the processing so implement a FIFO queue. + Process the service item request queue. The key presses can arrive + faster than the processing so implement a FIFO queue. """ if len(self.keypress_queue): while len(self.keypress_queue) and not self.keypress_loop: - self.keypress_loop = True + self.keypress_loop = True if self.keypress_queue.popleft() == u'previous': - Receiver.send_message('servicemanager_previous_item') + Receiver.send_message('servicemanager_previous_item') else: Receiver.send_message('servicemanager_next_item') self.keypress_loop = False From 02f5e819fb25ca26d80532ad58076495fe8ea18d Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 2 Dec 2011 22:23:37 +0000 Subject: [PATCH 14/49] Revert broken old incomplete thought --- openlp/core/ui/advancedtab.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index d6d28f053..43e2a9915 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -243,7 +243,8 @@ class AdvancedTab(SettingsTab): file_filters = u'%s;;%s (*.*) (*)' % (get_images_filter(), UiStrings().AllFiles) filename = QtGui.QFileDialog.getOpenFileName(self, - UiStrings.OpenFile, '', file_filters) + translate('OpenLP.AdvancedTab', 'Open File'), '', + file_filters) if filename: self.defaultFileEdit.setText(filename) self.defaultFileEdit.setFocus() From 69c33adba7d74db8ce6252d3d93913ff75763468 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 3 Dec 2011 13:42:49 +0200 Subject: [PATCH 15/49] Added a missing dependency (python-qt4-gl). --- resources/debian/debian/control | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/debian/debian/control b/resources/debian/debian/control index a1c2298e9..a00f5c86f 100644 --- a/resources/debian/debian/control +++ b/resources/debian/debian/control @@ -10,8 +10,9 @@ Homepage: http://openlp.org/ Package: openlp Architecture: all Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends}, python-qt4, - python-qt4-phonon, python-sqlalchemy, python-chardet, python-beautifulsoup, - python-lxml, python-sqlite, python-enchant, python-mako, python-migrate + python-qt4-phonon, python-qt4-gl, python-sqlalchemy, python-chardet, + python-beautifulsoup, python-lxml, python-sqlite, python-enchant, + python-mako, python-migrate Conflicts: python-openlp Description: Church lyrics projection application OpenLP is free church presentation software, or lyrics projection software, From 9c0bde098f604dc53aa03d6af25712e4faf0b97f Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 3 Dec 2011 13:40:48 +0000 Subject: [PATCH 16/49] Fix spacing --- openlp/core/ui/slidecontroller.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index f6d5e3d90..92eb7971e 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -642,7 +642,7 @@ class SlideController(Controller): self.previewDisplay.setFixedSize(QtCore.QSize( max_height * self.ratio, max_height)) self.previewDisplay.screen = { - u'size':self.previewDisplay.geometry()} + u'size': self.previewDisplay.geometry()} else: # We have to take the width as limit. max_width = self.previewFrame.width() - self.grid.margin() * 2 @@ -651,7 +651,7 @@ class SlideController(Controller): self.previewDisplay.setFixedSize(QtCore.QSize(max_width, max_width / self.ratio)) self.previewDisplay.screen = { - u'size':self.previewDisplay.geometry()} + u'size': self.previewDisplay.geometry()} # Make sure that the frames have the correct size. self.previewListWidget.setColumnWidth(0, self.previewListWidget.viewport().size().width()) From eb121abb12590f992707325902cda92459ddb940 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 3 Dec 2011 15:38:30 +0100 Subject: [PATCH 17/49] attempt to fix bug 768495 Fixes: https://launchpad.net/bugs/768495 --- openlp/core/utils/actions.py | 57 +++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 86ee69a48..36c1c2e78 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -188,6 +188,7 @@ class ActionList(object): actions or categories. """ instance = None + action_map = {} def __init__(self): self.categories = CategoryList() @@ -226,17 +227,41 @@ class ActionList(object): self.categories[category].actions.append(action) else: self.categories[category].actions.add(action, weight) - if category is None: - # Stop here, as this action is not configurable. - return # Load the shortcut from the config. settings = QtCore.QSettings() settings.beginGroup(u'shortcuts') shortcuts = settings.value(action.objectName(), QtCore.QVariant(action.shortcuts())).toStringList() + settings.endGroup() + if not shortcuts: + action.setShortcuts([]) + return + shortcuts = map(unicode, shortcuts) + # Check the alternate shortcut first, to avoid problems when the + # alternate shortcut becomes the primary shortcut after removing the + # (initial) primary shortcut due to confllicts. + if len(shortcuts) == 2: + existing_actions = ActionList.action_map.get(shortcuts[1], []) + # Check for conflicts with other actions considering the shortcut + # context. + if self._shortcut_available(existing_actions, action): + actions = ActionList.action_map.get(shortcuts[1], []) + actions.append(action) + ActionList.action_map[shortcuts[1]] = actions + else: + shortcuts.remove(shortcuts[1]) + # Check the primary shortcut. + existing_actions = ActionList.action_map.get(shortcuts[0], []) + # Check for conflicts with other actions considering the shortcut + # context. + if self._shortcut_available(existing_actions, action): + actions = ActionList.action_map.get(shortcuts[0], []) + actions.append(action) + ActionList.action_map[shortcuts[0]] = actions + else: + shortcuts.remove(shortcuts[0]) action.setShortcuts( [QtGui.QKeySequence(shortcut) for shortcut in shortcuts]) - settings.endGroup() def remove_action(self, action, category=None): """ @@ -279,6 +304,30 @@ class ActionList(object): return self.categories.add(name, weight) + def _shortcut_available(self, existing_actions, action): + """ + Checks if the given ``action`` may use its assigned shortcut(s) or not. + Returns ``True`` or ``False. + + ``existing_actions`` + A list of actions which already use a particular shortcut. + + ``action`` + The action which wants to use a particular shortcut. + """ + for existing_action in existing_actions: + if action is existing_action: + continue + if existing_action.parent() is action.parent(): + return False + if existing_action.shortcutContext() in [QtCore.Qt.WindowShortcut, + QtCore.Qt.ApplicationShortcut]: + return False + if action.shortcutContext() in [QtCore.Qt.WindowShortcut, + QtCore.Qt.ApplicationShortcut]: + return False + return True + class CategoryOrder(object): """ From 5bfc101f0978acb6b5a0ae4410e4ae5ced9f8de2 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 3 Dec 2011 16:09:03 +0100 Subject: [PATCH 18/49] changed name --- openlp/core/utils/actions.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 36c1c2e78..525a18f37 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -188,7 +188,7 @@ class ActionList(object): actions or categories. """ instance = None - action_map = {} + shortcut_map = {} def __init__(self): self.categories = CategoryList() @@ -241,23 +241,23 @@ class ActionList(object): # alternate shortcut becomes the primary shortcut after removing the # (initial) primary shortcut due to confllicts. if len(shortcuts) == 2: - existing_actions = ActionList.action_map.get(shortcuts[1], []) + existing_actions = ActionList.shortcut_map.get(shortcuts[1], []) # Check for conflicts with other actions considering the shortcut # context. if self._shortcut_available(existing_actions, action): - actions = ActionList.action_map.get(shortcuts[1], []) + actions = ActionList.shortcut_map.get(shortcuts[1], []) actions.append(action) - ActionList.action_map[shortcuts[1]] = actions + ActionList.shortcut_map[shortcuts[1]] = actions else: shortcuts.remove(shortcuts[1]) # Check the primary shortcut. - existing_actions = ActionList.action_map.get(shortcuts[0], []) + existing_actions = ActionList.shortcut_map.get(shortcuts[0], []) # Check for conflicts with other actions considering the shortcut # context. if self._shortcut_available(existing_actions, action): - actions = ActionList.action_map.get(shortcuts[0], []) + actions = ActionList.shortcut_map.get(shortcuts[0], []) actions.append(action) - ActionList.action_map[shortcuts[0]] = actions + ActionList.shortcut_map[shortcuts[0]] = actions else: shortcuts.remove(shortcuts[0]) action.setShortcuts( @@ -269,7 +269,7 @@ class ActionList(object): automatically removed. ``action`` - The QAction object to be removed. + The ``QAction`` object to be removed. ``category`` The name (unicode string) of the category, which contains the From f34ae80eec59edff957c5a78401d397019d01697 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 3 Dec 2011 19:01:36 +0100 Subject: [PATCH 19/49] fixed bug 887313 Fixes: https://launchpad.net/bugs/887313 --- openlp/core/ui/printserviceform.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index c08b6293e..4d1dc71c8 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -402,6 +402,9 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): settings.endGroup() def update_song_usage(self): + # Only continue when we include the song's text. + if not self.slideTextCheckBox.isChecked(): + return for index, item in enumerate(self.serviceManager.serviceItems): # Trigger Audit requests Receiver.send_message(u'print_service_started', From 5b67d36b3cc91c94ffde82adfba1ab4c9d37350d Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 3 Dec 2011 20:23:46 +0200 Subject: [PATCH 20/49] Fix problem where importing new song databases now does not work. Fixes: https://launchpad.net/bugs/863845 --- openlp/plugins/songs/lib/olpimport.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/lib/olpimport.py b/openlp/plugins/songs/lib/olpimport.py index 75e149fad..29d03a136 100644 --- a/openlp/plugins/songs/lib/olpimport.py +++ b/openlp/plugins/songs/lib/olpimport.py @@ -39,7 +39,7 @@ from openlp.core.lib import translate from openlp.core.lib.db import BaseModel from openlp.core.ui.wizard import WizardStrings from openlp.plugins.songs.lib import clean_song -from openlp.plugins.songs.lib.db import Author, Book, Song, Topic #, MediaFile +from openlp.plugins.songs.lib.db import Author, Book, Song, Topic, MediaFile from songimport import SongImport log = logging.getLogger(__name__) @@ -143,7 +143,8 @@ class OpenLPSongImport(SongImport): secondary=source_media_files_songs_table) else: song_props['media_files'] = relation(OldMediaFile, - backref='songs') + backref='songs', primaryjoin=source_songs_table.c.id==OldMediaFile.song_id, + foreign_keys=[source_media_files_table.c.song_id]) try: class_mapper(OldAuthor) except UnmappedClassError: From b78bb1c7e60547814beb6da01b92cbd79a0743bc Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 3 Dec 2011 21:35:53 +0100 Subject: [PATCH 21/49] fixed tooltip strings --- openlp/core/ui/media/mediacontroller.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index b05a7fe59..c4e3e7fa9 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -206,15 +206,15 @@ class MediaController(object): controller.mediabar = OpenLPToolbar(controller) controller.mediabar.addToolbarButton( u'media_playback_play', u':/slides/media_playback_start.png', - translate('OpenLP.SlideController', 'Start playing media'), + translate('OpenLP.SlideController', 'Start playing media.'), controller.sendToPlugins) controller.mediabar.addToolbarButton( u'media_playback_pause', u':/slides/media_playback_pause.png', - translate('OpenLP.SlideController', 'Pause playing media'), + translate('OpenLP.SlideController', 'Pause playing media.'), controller.sendToPlugins) controller.mediabar.addToolbarButton( u'media_playback_stop', u':/slides/media_playback_stop.png', - translate('OpenLP.SlideController', 'Stop playing media'), + translate('OpenLP.SlideController', 'Stop playing media.'), controller.sendToPlugins) # Build the seekSlider. controller.seekSlider = QtGui.QSlider(QtCore.Qt.Horizontal) @@ -223,7 +223,7 @@ class MediaController(object): 'OpenLP.SlideController', 'Video position.')) controller.seekSlider.setGeometry(QtCore.QRect(90, 260, 221, 24)) controller.seekSlider.setObjectName(u'seek_slider') - controller.mediabar.addToolbarWidget(u'Seek Slider', + controller.mediabar.addToolbarWidget(u'Seek Slider', controller.seekSlider) # Build the volumeSlider. controller.volumeSlider = QtGui.QSlider(QtCore.Qt.Horizontal) @@ -236,7 +236,7 @@ class MediaController(object): controller.volumeSlider.setValue(controller.media_info.volume) controller.volumeSlider.setGeometry(QtCore.QRect(90, 160, 221, 24)) controller.volumeSlider.setObjectName(u'volume_slider') - controller.mediabar.addToolbarWidget(u'Audio Volume', + controller.mediabar.addToolbarWidget(u'Audio Volume', controller.volumeSlider) control_panel.addWidget(controller.mediabar) controller.mediabar.setVisible(False) @@ -255,7 +255,7 @@ class MediaController(object): def setup_display(self, display): """ - After a new display is configured, all media related widget will be + After a new display is configured, all media related widget will be created too """ # clean up possible running old media files @@ -276,13 +276,13 @@ class MediaController(object): def set_controls_visible(self, controller, value): # Generic controls controller.mediabar.setVisible(value) - # Special controls: Here media type specific Controls will be enabled + # Special controls: Here media type specific Controls will be enabled # (e.g. for DVD control, ...) # TODO def resize(self, controller, display, player): """ - After Mainwindow changes or Splitter moved all related media widgets + After Mainwindow changes or Splitter moved all related media widgets have to be resized """ player.resize(display) @@ -389,7 +389,7 @@ class MediaController(object): def video_play(self, msg, status=True): """ Responds to the request to play a loaded video - + ``msg`` First element is the controller which should be used """ From def18307ccc9d1bb7b0c95d1eee4aaae65994900 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 3 Dec 2011 23:49:40 +0200 Subject: [PATCH 22/49] Avoid an error about something not being a Boolean. Fixes: https://launchpad.net/bugs/899532 --- openlp/plugins/songs/lib/olpimport.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/olpimport.py b/openlp/plugins/songs/lib/olpimport.py index 29d03a136..99ca9e748 100644 --- a/openlp/plugins/songs/lib/olpimport.py +++ b/openlp/plugins/songs/lib/olpimport.py @@ -121,6 +121,7 @@ class OpenLPSongImport(SongImport): source_topics_table = source_meta.tables[u'topics'] source_authors_songs_table = source_meta.tables[u'authors_songs'] source_songs_topics_table = source_meta.tables[u'songs_topics'] + source_media_files_songs_table = None if has_media_files: source_media_files_table = source_meta.tables[u'media_files'] source_media_files_songs_table = \ @@ -137,7 +138,7 @@ class OpenLPSongImport(SongImport): secondary=source_songs_topics_table) } if has_media_files: - if source_media_files_songs_table: + if source_media_files_songs_table is not None: song_props['media_files'] = relation(OldMediaFile, backref='songs', secondary=source_media_files_songs_table) From 2016ce61ca220fdc7dcfe5445bb7d35966698657 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sun, 4 Dec 2011 00:30:22 +0200 Subject: [PATCH 23/49] Sometimes the song_id column doesn't exist on the model, so we use the table instead. --- openlp/plugins/songs/lib/olpimport.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/lib/olpimport.py b/openlp/plugins/songs/lib/olpimport.py index 99ca9e748..d7a735033 100644 --- a/openlp/plugins/songs/lib/olpimport.py +++ b/openlp/plugins/songs/lib/olpimport.py @@ -144,8 +144,9 @@ class OpenLPSongImport(SongImport): secondary=source_media_files_songs_table) else: song_props['media_files'] = relation(OldMediaFile, - backref='songs', primaryjoin=source_songs_table.c.id==OldMediaFile.song_id, - foreign_keys=[source_media_files_table.c.song_id]) + backref='songs', + primaryjoin=source_songs_table.c.id == \ + source_media_files_table.c.song_id) try: class_mapper(OldAuthor) except UnmappedClassError: From c825df38fad9bd0a745c09f3f1d9dc5a9bb38a9a Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sun, 4 Dec 2011 15:26:27 +0200 Subject: [PATCH 24/49] Hopefully the final piece of the fix. --- openlp/plugins/songs/lib/olpimport.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openlp/plugins/songs/lib/olpimport.py b/openlp/plugins/songs/lib/olpimport.py index d7a735033..598815c8f 100644 --- a/openlp/plugins/songs/lib/olpimport.py +++ b/openlp/plugins/songs/lib/olpimport.py @@ -145,6 +145,7 @@ class OpenLPSongImport(SongImport): else: song_props['media_files'] = relation(OldMediaFile, backref='songs', + foreign_keys=[source_media_files_table.c.song_id], primaryjoin=source_songs_table.c.id == \ source_media_files_table.c.song_id) try: From 5804dade748154574e775035ca6a5483983f84e5 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sun, 4 Dec 2011 14:42:39 +0000 Subject: [PATCH 25/49] Reduce recent file list duplication (Bug #892668) --- openlp/core/ui/mainwindow.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 9d546629b..b0640513a 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -1312,7 +1312,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): settings.value(u'preview splitter geometry').toByteArray()) self.controlSplitter.restoreState( settings.value(u'mainwindow splitter geometry').toByteArray()) - settings.endGroup() def saveSettings(self): @@ -1388,6 +1387,12 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): maxRecentFiles = QtCore.QSettings().value(u'advanced/max recent files', QtCore.QVariant(20)).toInt()[0] if filename: + # Add some cleanup to reduce duplication in the recent file list + filename = os.path.abspath(filename) + # abspath() only capitalises the drive letter if it wasn't provided + # in the given filename which then causes duplication. + if filename[1:3] == ':\\': + filename = filename[0].upper() + filename[1:] position = self.recentFiles.indexOf(filename) if position != -1: self.recentFiles.removeAt(position) From 06570a9941f89279f9252516cccccdd11d545814 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sun, 4 Dec 2011 22:50:13 +0200 Subject: [PATCH 26/49] Fixed a minor bug where if you imported 2 OpenLP 2.0 databases in the same OpenLP session whose schemas were different, you'd get an error. --- openlp/plugins/songs/lib/olpimport.py | 74 +++++++++++++-------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/openlp/plugins/songs/lib/olpimport.py b/openlp/plugins/songs/lib/olpimport.py index 598815c8f..7187950b7 100644 --- a/openlp/plugins/songs/lib/olpimport.py +++ b/openlp/plugins/songs/lib/olpimport.py @@ -30,7 +30,7 @@ song databases into the current installation database. """ import logging -from sqlalchemy import create_engine, MetaData +from sqlalchemy import create_engine, MetaData, Table from sqlalchemy.orm import class_mapper, mapper, relation, scoped_session, \ sessionmaker from sqlalchemy.orm.exc import UnmappedClassError @@ -44,41 +44,6 @@ from songimport import SongImport log = logging.getLogger(__name__) -class OldAuthor(BaseModel): - """ - Author model - """ - pass - - -class OldBook(BaseModel): - """ - Book model - """ - pass - - -class OldMediaFile(BaseModel): - """ - MediaFile model - """ - pass - - -class OldSong(BaseModel): - """ - Song model - """ - pass - - -class OldTopic(BaseModel): - """ - Topic model - """ - pass - - class OpenLPSongImport(SongImport): """ The :class:`OpenLPSongImport` class provides OpenLP with the ability to @@ -101,6 +66,41 @@ class OpenLPSongImport(SongImport): """ Run the import for an OpenLP version 2 song database. """ + class OldAuthor(BaseModel): + """ + Author model + """ + pass + + + class OldBook(BaseModel): + """ + Book model + """ + pass + + + class OldMediaFile(BaseModel): + """ + MediaFile model + """ + pass + + + class OldSong(BaseModel): + """ + Song model + """ + pass + + + class OldTopic(BaseModel): + """ + Topic model + """ + pass + + if not self.importSource.endswith(u'.sqlite'): self.logError(self.importSource, translate('SongsPlugin.OpenLPSongImport', @@ -138,7 +138,7 @@ class OpenLPSongImport(SongImport): secondary=source_songs_topics_table) } if has_media_files: - if source_media_files_songs_table is not None: + if isinstance(source_media_files_songs_table, Table): song_props['media_files'] = relation(OldMediaFile, backref='songs', secondary=source_media_files_songs_table) From a54e7ff709c6863a3de684760ee267510f114e98 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sun, 4 Dec 2011 20:57:58 +0000 Subject: [PATCH 27/49] Fix non-ascii service filename loading --- openlp/core/ui/mainwindow.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index b0640513a..663f6c75a 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -720,7 +720,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): args = [] for a in self.arguments: args.extend([a]) - self.serviceManagerContents.loadFile(unicode(args[0])) + self.serviceManagerContents.loadFile(unicode(args[0], + sys.getfilesystemencoding())) elif QtCore.QSettings().value( self.generalSettingsSection + u'/auto open', QtCore.QVariant(False)).toBool(): From 04d7669948400497e3b5e067893affaa63c14586 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Mon, 5 Dec 2011 21:40:56 +0000 Subject: [PATCH 28/49] Fix non-ascii file check on Macs --- openlp/core/ui/mainwindow.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 663f6c75a..0974f53fb 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -720,8 +720,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): args = [] for a in self.arguments: args.extend([a]) - self.serviceManagerContents.loadFile(unicode(args[0], - sys.getfilesystemencoding())) + filename = args[0] + if not isinstance(filename, unicode): + filename = unicode(filename, sys.getfilesystemencoding()) + self.serviceManagerContents.loadFile(filename) elif QtCore.QSettings().value( self.generalSettingsSection + u'/auto open', QtCore.QVariant(False)).toBool(): From 36e729303c925705f942d10431f5dc262c2b203f Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 6 Dec 2011 20:25:12 +0100 Subject: [PATCH 29/49] reverted changes --- openlp/core/utils/actions.py | 59 +++--------------------------------- 1 file changed, 5 insertions(+), 54 deletions(-) diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 525a18f37..86ee69a48 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -188,7 +188,6 @@ class ActionList(object): actions or categories. """ instance = None - shortcut_map = {} def __init__(self): self.categories = CategoryList() @@ -227,41 +226,17 @@ class ActionList(object): self.categories[category].actions.append(action) else: self.categories[category].actions.add(action, weight) + if category is None: + # Stop here, as this action is not configurable. + return # Load the shortcut from the config. settings = QtCore.QSettings() settings.beginGroup(u'shortcuts') shortcuts = settings.value(action.objectName(), QtCore.QVariant(action.shortcuts())).toStringList() - settings.endGroup() - if not shortcuts: - action.setShortcuts([]) - return - shortcuts = map(unicode, shortcuts) - # Check the alternate shortcut first, to avoid problems when the - # alternate shortcut becomes the primary shortcut after removing the - # (initial) primary shortcut due to confllicts. - if len(shortcuts) == 2: - existing_actions = ActionList.shortcut_map.get(shortcuts[1], []) - # Check for conflicts with other actions considering the shortcut - # context. - if self._shortcut_available(existing_actions, action): - actions = ActionList.shortcut_map.get(shortcuts[1], []) - actions.append(action) - ActionList.shortcut_map[shortcuts[1]] = actions - else: - shortcuts.remove(shortcuts[1]) - # Check the primary shortcut. - existing_actions = ActionList.shortcut_map.get(shortcuts[0], []) - # Check for conflicts with other actions considering the shortcut - # context. - if self._shortcut_available(existing_actions, action): - actions = ActionList.shortcut_map.get(shortcuts[0], []) - actions.append(action) - ActionList.shortcut_map[shortcuts[0]] = actions - else: - shortcuts.remove(shortcuts[0]) action.setShortcuts( [QtGui.QKeySequence(shortcut) for shortcut in shortcuts]) + settings.endGroup() def remove_action(self, action, category=None): """ @@ -269,7 +244,7 @@ class ActionList(object): automatically removed. ``action`` - The ``QAction`` object to be removed. + The QAction object to be removed. ``category`` The name (unicode string) of the category, which contains the @@ -304,30 +279,6 @@ class ActionList(object): return self.categories.add(name, weight) - def _shortcut_available(self, existing_actions, action): - """ - Checks if the given ``action`` may use its assigned shortcut(s) or not. - Returns ``True`` or ``False. - - ``existing_actions`` - A list of actions which already use a particular shortcut. - - ``action`` - The action which wants to use a particular shortcut. - """ - for existing_action in existing_actions: - if action is existing_action: - continue - if existing_action.parent() is action.parent(): - return False - if existing_action.shortcutContext() in [QtCore.Qt.WindowShortcut, - QtCore.Qt.ApplicationShortcut]: - return False - if action.shortcutContext() in [QtCore.Qt.WindowShortcut, - QtCore.Qt.ApplicationShortcut]: - return False - return True - class CategoryOrder(object): """ From 38a2a3dee229310aaa42f10dbc1ba94b9ea4342e Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 6 Dec 2011 20:30:39 +0100 Subject: [PATCH 30/49] fixed bug 768495 --- openlp/core/utils/actions.py | 59 +++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 5 deletions(-) diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 86ee69a48..525a18f37 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -188,6 +188,7 @@ class ActionList(object): actions or categories. """ instance = None + shortcut_map = {} def __init__(self): self.categories = CategoryList() @@ -226,17 +227,41 @@ class ActionList(object): self.categories[category].actions.append(action) else: self.categories[category].actions.add(action, weight) - if category is None: - # Stop here, as this action is not configurable. - return # Load the shortcut from the config. settings = QtCore.QSettings() settings.beginGroup(u'shortcuts') shortcuts = settings.value(action.objectName(), QtCore.QVariant(action.shortcuts())).toStringList() + settings.endGroup() + if not shortcuts: + action.setShortcuts([]) + return + shortcuts = map(unicode, shortcuts) + # Check the alternate shortcut first, to avoid problems when the + # alternate shortcut becomes the primary shortcut after removing the + # (initial) primary shortcut due to confllicts. + if len(shortcuts) == 2: + existing_actions = ActionList.shortcut_map.get(shortcuts[1], []) + # Check for conflicts with other actions considering the shortcut + # context. + if self._shortcut_available(existing_actions, action): + actions = ActionList.shortcut_map.get(shortcuts[1], []) + actions.append(action) + ActionList.shortcut_map[shortcuts[1]] = actions + else: + shortcuts.remove(shortcuts[1]) + # Check the primary shortcut. + existing_actions = ActionList.shortcut_map.get(shortcuts[0], []) + # Check for conflicts with other actions considering the shortcut + # context. + if self._shortcut_available(existing_actions, action): + actions = ActionList.shortcut_map.get(shortcuts[0], []) + actions.append(action) + ActionList.shortcut_map[shortcuts[0]] = actions + else: + shortcuts.remove(shortcuts[0]) action.setShortcuts( [QtGui.QKeySequence(shortcut) for shortcut in shortcuts]) - settings.endGroup() def remove_action(self, action, category=None): """ @@ -244,7 +269,7 @@ class ActionList(object): automatically removed. ``action`` - The QAction object to be removed. + The ``QAction`` object to be removed. ``category`` The name (unicode string) of the category, which contains the @@ -279,6 +304,30 @@ class ActionList(object): return self.categories.add(name, weight) + def _shortcut_available(self, existing_actions, action): + """ + Checks if the given ``action`` may use its assigned shortcut(s) or not. + Returns ``True`` or ``False. + + ``existing_actions`` + A list of actions which already use a particular shortcut. + + ``action`` + The action which wants to use a particular shortcut. + """ + for existing_action in existing_actions: + if action is existing_action: + continue + if existing_action.parent() is action.parent(): + return False + if existing_action.shortcutContext() in [QtCore.Qt.WindowShortcut, + QtCore.Qt.ApplicationShortcut]: + return False + if action.shortcutContext() in [QtCore.Qt.WindowShortcut, + QtCore.Qt.ApplicationShortcut]: + return False + return True + class CategoryOrder(object): """ From 1830cfbe9e1192bac2925bc7544807f85323a9e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Tue, 6 Dec 2011 23:25:04 +0200 Subject: [PATCH 31/49] Ensure that action category names are unicode, to prevent warnings on comparison. --- openlp/core/utils/actions.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 86ee69a48..26a0c48e8 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -149,6 +149,8 @@ class CategoryList(object): return self.__next__() def has_key(self, key): + if key != None and not isinstance(key, unicode): + key = unicode(key) for category in self.categories: if category.name == key: return True @@ -164,6 +166,8 @@ class CategoryList(object): self.add(name, weight) def add(self, name, weight=0, actions=None): + if name != None and not isinstance(name, unicode): + name = unicode(name) category = ActionCategory(name, weight) if actions: for action in actions: @@ -270,6 +274,8 @@ class ActionList(object): ``weight`` The category's weight (int). """ + if name != None and not isinstance(name, unicode): + name = unicode(name) if name in self.categories: # Only change the weight and resort the categories again. for category in self.categories: From b5dfba86fb42e7a4d56c98cba8e111ff0206fd61 Mon Sep 17 00:00:00 2001 From: rimach Date: Tue, 6 Dec 2011 22:42:34 +0100 Subject: [PATCH 32/49] bugfixing --- openlp/core/ui/media/mediacontroller.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index c4e3e7fa9..b58afeb1e 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -311,8 +311,13 @@ class MediaController(object): isValid = self.check_file_type(controller, display) display.override[u'theme'] = u'' display.override[u'video'] = True - controller.media_info.start_time = display.serviceItem.start_time - controller.media_info.end_time = display.serviceItem.end_time + if controller.media_info.is_background: + # ignore start/end time + controller.media_info.start_time = 0 + controller.media_info.end_time = 0 + else: + controller.media_info.start_time = display.serviceItem.start_time + controller.media_info.end_time = display.serviceItem.end_time elif controller.previewDisplay: display = controller.previewDisplay isValid = self.check_file_type(controller, display) From ef3e3252e77e3e329d89bdac90b8ae88e428982f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Wed, 7 Dec 2011 00:37:56 +0200 Subject: [PATCH 33/49] Comparison to None is discouraged --- openlp/core/utils/actions.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 26a0c48e8..37c2676ac 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -149,7 +149,7 @@ class CategoryList(object): return self.__next__() def has_key(self, key): - if key != None and not isinstance(key, unicode): + if key and not isinstance(key, unicode): key = unicode(key) for category in self.categories: if category.name == key: @@ -166,7 +166,7 @@ class CategoryList(object): self.add(name, weight) def add(self, name, weight=0, actions=None): - if name != None and not isinstance(name, unicode): + if name and not isinstance(name, unicode): name = unicode(name) category = ActionCategory(name, weight) if actions: @@ -274,7 +274,7 @@ class ActionList(object): ``weight`` The category's weight (int). """ - if name != None and not isinstance(name, unicode): + if name and not isinstance(name, unicode): name = unicode(name) if name in self.categories: # Only change the weight and resort the categories again. From 12547fad2a597a20df1a2fb97d84d0a587ce239e Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 7 Dec 2011 21:25:12 +0100 Subject: [PATCH 34/49] doc clean up, removed method with a one liner, fixed media item recreation bug --- openlp/core/lib/plugin.py | 21 ++++++------- openlp/core/lib/pluginmanager.py | 30 ++++--------------- openlp/core/ui/mainwindow.py | 2 +- openlp/plugins/media/mediaplugin.py | 2 +- .../presentations/presentationplugin.py | 4 +-- openlp/plugins/songs/forms/editsongform.py | 2 +- 6 files changed, 22 insertions(+), 39 deletions(-) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 76e54ef8d..92ac0be64 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -91,8 +91,9 @@ class Plugin(QtCore.QObject): ``checkPreConditions()`` Provides the Plugin with a handle to check if it can be loaded. - ``getMediaManagerItem()`` - Returns an instance of MediaManagerItem to be used in the Media Manager. + ``createMediaManagerItem()`` + Creates a new instance of MediaManagerItem to be used in the Media + Manager. ``addImportMenuItem(import_menu)`` Add an item to the Import menu. @@ -100,8 +101,8 @@ class Plugin(QtCore.QObject): ``addExportMenuItem(export_menu)`` Add an item to the Export menu. - ``getSettingsTab()`` - Returns an instance of SettingsTabItem to be used in the Settings + ``createSettingsTab()`` + Creates a new instance of SettingsTabItem to be used in the Settings dialog. ``addToMenu(menubar)`` @@ -178,7 +179,7 @@ class Plugin(QtCore.QObject): Provides the Plugin with a handle to check if it can be loaded. Failing Preconditions does not stop a settings Tab being created - Returns True or False. + Returns ``True`` or ``False``. """ return True @@ -210,10 +211,10 @@ class Plugin(QtCore.QObject): """ return self.status == PluginStatus.Active - def getMediaManagerItem(self): + def createMediaManagerItem(self): """ Construct a MediaManagerItem object with all the buttons and things - you need, and return it for integration into openlp.org. + you need, and return it for integration into OpenLP. """ if self.media_item_class: return self.media_item_class(self.mediadock.media_dock, self, @@ -247,10 +248,10 @@ class Plugin(QtCore.QObject): """ pass - def getSettingsTab(self, parent): + def createSettingsTab(self, parent): """ - Create a tab for the settings window to display the configurable - options for this plugin to the user. + Create a tab for the settings window to display the configurable options + for this plugin to the user. """ if self.settings_tab_class: return self.settings_tab_class(parent, self.name, diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index db5d9b60e..e29176386 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -113,7 +113,7 @@ class PluginManager(object): plugin_objects.append(plugin) except TypeError: log.exception(u'Failed to load plugin %s', unicode(p)) - plugins_list = sorted(plugin_objects, self.order_by_weight) + plugins_list = sorted(plugin_objects, key=lambda plugin: plugin.weight) for plugin in plugins_list: if plugin.checkPreConditions(): log.debug(u'Plugin %s active', unicode(plugin.name)) @@ -122,29 +122,13 @@ class PluginManager(object): plugin.status = PluginStatus.Disabled self.plugins.append(plugin) - def order_by_weight(self, x, y): + def hook_media_manager(self): """ - Sort two plugins and order them by their weight. - - ``x`` - The first plugin. - - ``y`` - The second plugin. - """ - return cmp(x.weight, y.weight) - - def hook_media_manager(self, mediadock): - """ - Loop through all the plugins. If a plugin has a valid media manager - item, add it to the media manager. - - ``mediatoolbox`` - The Media Manager itself. + Create the plugins' media manager items. """ for plugin in self.plugins: if plugin.status is not PluginStatus.Disabled: - plugin.mediaItem = plugin.getMediaManagerItem() + plugin.mediaItem = plugin.createMediaManagerItem() def hook_settings_tabs(self, settings_form=None): """ @@ -152,14 +136,12 @@ class PluginManager(object): item, add it to the settings tab. Tabs are set for all plugins not just Active ones - ``settingsform`` + ``settings_form`` Defaults to *None*. The settings form to add tabs to. """ for plugin in self.plugins: if plugin.status is not PluginStatus.Disabled: - plugin.settings_tab = plugin.getSettingsTab(settings_form) - else: - plugin.settings_tab = None + plugin.settings_tab = plugin.createSettingsTab(settings_form) settings_form.plugins = self.plugins def hook_import_menu(self, import_menu): diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 9d546629b..be04455f6 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -655,7 +655,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.pluginManager.hook_settings_tabs(self.settingsForm) # Find and insert media manager items log.info(u'hook media') - self.pluginManager.hook_media_manager(self.mediaDockManager) + self.pluginManager.hook_media_manager() # Call the hook method to pull in import menus. log.info(u'hook menus') self.pluginManager.hook_import_menu(self.fileImportMenu) diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index 97f749689..41965d612 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -52,7 +52,7 @@ class MediaPlugin(Plugin): for ext in self.video_extensions_list: self.serviceManager.supportedSuffixes(ext[2:]) - def getSettingsTab(self, parent): + def createSettingsTab(self, parent): """ Create the settings Tab """ diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 643ad14ad..7baf659e0 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -57,7 +57,7 @@ class PresentationPlugin(Plugin): self.icon_path = u':/plugins/plugin_presentations.png' self.icon = build_icon(self.icon_path) - def getSettingsTab(self, parent): + def createSettingsTab(self, parent): """ Create the settings Tab """ @@ -94,7 +94,7 @@ class PresentationPlugin(Plugin): controller.kill() Plugin.finalise(self) - def getMediaManagerItem(self): + def createMediaManagerItem(self): """ Create the Media Manager List """ diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index c1566a639..776c3c88b 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -181,7 +181,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): plugin.status == PluginStatus.Active: self.audioAddFromMediaButton.setVisible(True) self.mediaForm.populateFiles( - plugin.getMediaManagerItem().getList(MediaType.Audio)) + plugin.mediaItem.getList(MediaType.Audio)) break def newSong(self): From 32f2dcac59f67adba301a4e018023b14f9ed01b9 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 7 Dec 2011 21:28:26 +0100 Subject: [PATCH 35/49] reverted change --- openlp/core/utils/actions.py | 59 +++--------------------------------- 1 file changed, 5 insertions(+), 54 deletions(-) diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 525a18f37..86ee69a48 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -188,7 +188,6 @@ class ActionList(object): actions or categories. """ instance = None - shortcut_map = {} def __init__(self): self.categories = CategoryList() @@ -227,41 +226,17 @@ class ActionList(object): self.categories[category].actions.append(action) else: self.categories[category].actions.add(action, weight) + if category is None: + # Stop here, as this action is not configurable. + return # Load the shortcut from the config. settings = QtCore.QSettings() settings.beginGroup(u'shortcuts') shortcuts = settings.value(action.objectName(), QtCore.QVariant(action.shortcuts())).toStringList() - settings.endGroup() - if not shortcuts: - action.setShortcuts([]) - return - shortcuts = map(unicode, shortcuts) - # Check the alternate shortcut first, to avoid problems when the - # alternate shortcut becomes the primary shortcut after removing the - # (initial) primary shortcut due to confllicts. - if len(shortcuts) == 2: - existing_actions = ActionList.shortcut_map.get(shortcuts[1], []) - # Check for conflicts with other actions considering the shortcut - # context. - if self._shortcut_available(existing_actions, action): - actions = ActionList.shortcut_map.get(shortcuts[1], []) - actions.append(action) - ActionList.shortcut_map[shortcuts[1]] = actions - else: - shortcuts.remove(shortcuts[1]) - # Check the primary shortcut. - existing_actions = ActionList.shortcut_map.get(shortcuts[0], []) - # Check for conflicts with other actions considering the shortcut - # context. - if self._shortcut_available(existing_actions, action): - actions = ActionList.shortcut_map.get(shortcuts[0], []) - actions.append(action) - ActionList.shortcut_map[shortcuts[0]] = actions - else: - shortcuts.remove(shortcuts[0]) action.setShortcuts( [QtGui.QKeySequence(shortcut) for shortcut in shortcuts]) + settings.endGroup() def remove_action(self, action, category=None): """ @@ -269,7 +244,7 @@ class ActionList(object): automatically removed. ``action`` - The ``QAction`` object to be removed. + The QAction object to be removed. ``category`` The name (unicode string) of the category, which contains the @@ -304,30 +279,6 @@ class ActionList(object): return self.categories.add(name, weight) - def _shortcut_available(self, existing_actions, action): - """ - Checks if the given ``action`` may use its assigned shortcut(s) or not. - Returns ``True`` or ``False. - - ``existing_actions`` - A list of actions which already use a particular shortcut. - - ``action`` - The action which wants to use a particular shortcut. - """ - for existing_action in existing_actions: - if action is existing_action: - continue - if existing_action.parent() is action.parent(): - return False - if existing_action.shortcutContext() in [QtCore.Qt.WindowShortcut, - QtCore.Qt.ApplicationShortcut]: - return False - if action.shortcutContext() in [QtCore.Qt.WindowShortcut, - QtCore.Qt.ApplicationShortcut]: - return False - return True - class CategoryOrder(object): """ From 66c183a6b8ee84f63de92a83680887a85cb4e699 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 7 Dec 2011 21:41:19 +0100 Subject: [PATCH 36/49] break instead of continue --- openlp/core/lib/pluginmanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index e29176386..b124dce9e 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -90,7 +90,7 @@ class PluginManager(object): thisdepth = len(path.split(os.sep)) if thisdepth - startdepth > 2: # skip anything lower down - continue + break modulename = os.path.splitext(path)[0] prefix = os.path.commonprefix([self.basepath, path]) # hack off the plugin base path From 1c79b2846123ab47b8c19429d433f749a78ecd5f Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Wed, 7 Dec 2011 21:56:06 +0000 Subject: [PATCH 37/49] Workaround justify and outline alignment problems --- openlp/core/lib/htmlbuilder.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index 9bce2bcac..a9ef1a38b 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -85,6 +85,7 @@ sup { From c36a13d0a8e85b3c6a17b7f285c0ee503d597923 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Thu, 8 Dec 2011 19:49:43 +0000 Subject: [PATCH 44/49] Remove webkit version in js --- openlp/core/lib/htmlbuilder.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index fba1a25fa..29b8c3335 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -85,7 +85,6 @@ sup {