From f239b2345d223ab65fa733795083a2cb9de88cd8 Mon Sep 17 00:00:00 2001 From: Patrick Zimmermann Date: Tue, 11 Dec 2012 00:35:53 +0100 Subject: [PATCH 01/64] Move changes to new branch. --- openlp/core/__init__.py | 9 ++++--- openlp/core/ui/advancedtab.py | 50 +++++++++++++++++++++++++++++------ 2 files changed, 48 insertions(+), 11 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 4dde8a970..e98438160 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -124,11 +124,14 @@ class OpenLP(QtGui.QApplication): if FirstTimeForm(screens).exec_() == QtGui.QDialog.Accepted: Settings().setValue(u'general/has run wizard', QtCore.QVariant(True)) # Correct stylesheet bugs + application_stylesheet = u'' + if Settings().value(u'advanced/stylesheet fix', QtCore.QVariant(False)).toBool(): + alternate_background_repair_stylesheet = \ + u'QTableWidget, QListWidget, QTreeWidget {alternate-background-color: ' + base_color.name() + ';}\n' + application_stylesheet += alternate_background_repair_stylesheet if os.name == u'nt': - base_color = self.palette().color(QtGui.QPalette.Active, QtGui.QPalette.Base) - application_stylesheet = \ - u'QTableWidget, QListWidget, QTreeWidget {alternate-background-color: ' + base_color.name() + ';}\n' application_stylesheet += nt_repair_stylesheet + if application_stylesheet: self.setStyleSheet(application_stylesheet) # show the splashscreen show_splash = Settings().value(u'general/show splash', QtCore.QVariant(True)).toBool() diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 93c8f4999..af83509e6 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -276,14 +276,18 @@ class AdvancedTab(SettingsTab): self.nextItemRadioButton.setObjectName(u'nextItemRadioButton') self.slideLayout.addWidget(self.nextItemRadioButton) self.rightLayout.addWidget(self.slideGroupBox) - self.x11GroupBox = QtGui.QGroupBox(self.leftColumn) - self.x11GroupBox.setObjectName(u'x11GroupBox') - self.x11Layout = QtGui.QVBoxLayout(self.x11GroupBox) - self.x11Layout.setObjectName(u'x11Layout') - self.x11BypassCheckBox = QtGui.QCheckBox(self.x11GroupBox) + # Workarounds + self.workaroundGroupBox = QtGui.QGroupBox(self.leftColumn) + self.workaroundGroupBox.setObjectName(u'workaroundGroupBox') + self.workaroundLayout = QtGui.QVBoxLayout(self.workaroundGroupBox) + self.workaroundLayout.setObjectName(u'workaroundLayout') + self.x11BypassCheckBox = QtGui.QCheckBox(self.workaroundGroupBox) self.x11BypassCheckBox.setObjectName(u'x11BypassCheckBox') - self.x11Layout.addWidget(self.x11BypassCheckBox) - self.rightLayout.addWidget(self.x11GroupBox) + self.workaroundLayout.addWidget(self.x11BypassCheckBox) + self.stylesheetFixCheckBox = QtGui.QCheckBox(self.workaroundGroupBox) + self.stylesheetFixCheckBox.setObjectName(u'stylesheetFixCheckBox') + self.workaroundLayout.addWidget(self.stylesheetFixCheckBox) + self.rightLayout.addWidget(self.workaroundGroupBox) self.rightLayout.addStretch() self.shouldUpdateServiceNameExample = False QtCore.QObject.connect(self.serviceNameCheckBox, @@ -308,6 +312,8 @@ class AdvancedTab(SettingsTab): QtCore.SIGNAL(u'clicked()'), self.onDefaultRevertButtonClicked) QtCore.QObject.connect(self.x11BypassCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.onX11BypassCheckBoxToggled) + QtCore.QObject.connect(self.stylesheetFixCheckBox, + QtCore.SIGNAL(u'toggled(bool)'), self.onStylesheetFixCheckBoxToggled) QtCore.QObject.connect(self.dataDirectoryBrowseButton, QtCore.SIGNAL(u'clicked()'), self.onDataDirectoryBrowseButtonClicked) @@ -424,9 +430,11 @@ class AdvancedTab(SettingsTab): translate('OpenLP.AdvancedTab', 'WARNING: New data directory location contains ' 'OpenLP data files. These files WILL be replaced during a copy.')) - self.x11GroupBox.setTitle(translate('OpenLP.AdvancedTab', 'X11')) + self.workaroundGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Workarounds')) self.x11BypassCheckBox.setText(translate('OpenLP.AdvancedTab', 'Bypass X11 Window Manager')) + self.stylesheetFixCheckBox.setText(translate('OpenLP.AdvancedTab', + 'Disable alternating row colors in lists')) # Slide Limits self.slideGroupBox.setTitle( translate('OpenLP.GeneralTab', 'Service Item Slide Limits')) @@ -492,6 +500,17 @@ class AdvancedTab(SettingsTab): os.environ.get(u'GNOME_DESKTOP_SESSION_ID')) self.x11BypassCheckBox.setChecked(settings.value( u'x11 bypass wm', QtCore.QVariant(x11_bypass_default)).toBool()) + # Fix for bug #936281. + if sys.platform.startswith(u'win'): + stylesheet_fix_default = True + else: + stylesheet_fix_default = False + # Prevent the dialog displayed by the stylesheetFixCheckBox to display. + signalsBlocked = self.stylesheetFixCheckBox.blockSignals(True) + self.stylesheetFixCheckBox.setChecked(settings.value( + u'stylesheet fix', QtCore.QVariant( + stylesheet_fix_default)).toBool()) + self.stylesheetFixCheckBox.blockSignals(signalsBlocked) self.defaultColor = settings.value(u'default color', QtCore.QVariant(u'#ffffff')).toString() self.defaultFileEdit.setText(settings.value(u'default image', @@ -582,6 +601,8 @@ class AdvancedTab(SettingsTab): QtCore.QVariant(self.hideMouseCheckBox.isChecked())) settings.setValue(u'x11 bypass wm', QtCore.QVariant(self.x11BypassCheckBox.isChecked())) + settings.setValue(u'stylesheet fix', + QtCore.QVariant(self.stylesheetFixCheckBox.isChecked())) settings.setValue(u'default color', self.defaultColor) settings.setValue(u'default image', self.defaultFileEdit.text()) settings.setValue(u'slide limits', QtCore.QVariant(self.slide_limits)) @@ -786,6 +807,18 @@ class AdvancedTab(SettingsTab): The state of the check box (boolean). """ self.displayChanged = True + + def onStylesheetFixCheckBoxToggled(self, checked): + """ + Notify user about required restart. + + ``checked`` + The state of the check box (boolean). + """ + QtGui.QMessageBox.information(self, + translate('OpenLP.AdvancedTab', 'Restart Required'), + translate('OpenLP.AdvancedTab', + 'The change will take effect when OpenLP is restarted.')) def onEndSlideButtonClicked(self): self.slide_limits = SlideLimits.End @@ -795,3 +828,4 @@ class AdvancedTab(SettingsTab): def onnextItemButtonClicked(self): self.slide_limits = SlideLimits.Next + From 97ecefedff11cdb1e6dfe06c58a51ec2a36bedb8 Mon Sep 17 00:00:00 2001 From: Patrick Zimmermann Date: Tue, 11 Dec 2012 20:46:18 +0100 Subject: [PATCH 02/64] Correct an indentation. --- openlp/core/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index e98438160..c3aee1688 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -127,7 +127,7 @@ class OpenLP(QtGui.QApplication): application_stylesheet = u'' if Settings().value(u'advanced/stylesheet fix', QtCore.QVariant(False)).toBool(): alternate_background_repair_stylesheet = \ - u'QTableWidget, QListWidget, QTreeWidget {alternate-background-color: ' + base_color.name() + ';}\n' + u'QTableWidget, QListWidget, QTreeWidget {alternate-background-color: ' + base_color.name() + ';}\n' application_stylesheet += alternate_background_repair_stylesheet if os.name == u'nt': application_stylesheet += nt_repair_stylesheet From e87fe825728e2ba83d2de6e7b6863abc15546ff3 Mon Sep 17 00:00:00 2001 From: Patrick Zimmermann Date: Tue, 11 Dec 2012 21:02:41 +0100 Subject: [PATCH 03/64] Add missing base_color. --- openlp/core/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index c3aee1688..531ea2b07 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -126,6 +126,7 @@ class OpenLP(QtGui.QApplication): # Correct stylesheet bugs application_stylesheet = u'' if Settings().value(u'advanced/stylesheet fix', QtCore.QVariant(False)).toBool(): + base_color = self.palette().color(QtGui.QPalette.Active, QtGui.QPalette.Base) alternate_background_repair_stylesheet = \ u'QTableWidget, QListWidget, QTreeWidget {alternate-background-color: ' + base_color.name() + ';}\n' application_stylesheet += alternate_background_repair_stylesheet From c9624ab37845bd529e13f601a35d06f236ab259a Mon Sep 17 00:00:00 2001 From: Patrick Zimmermann Date: Mon, 17 Dec 2012 20:50:09 +0100 Subject: [PATCH 04/64] Default stylesheet logic to true on Windows even without existing configuration. --- openlp/core/__init__.py | 2 +- openlp/core/ui/advancedtab.py | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 531ea2b07..32db93d15 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -125,7 +125,7 @@ class OpenLP(QtGui.QApplication): Settings().setValue(u'general/has run wizard', QtCore.QVariant(True)) # Correct stylesheet bugs application_stylesheet = u'' - if Settings().value(u'advanced/stylesheet fix', QtCore.QVariant(False)).toBool(): + if Settings().value(u'advanced/stylesheet fix', QtCore.QVariant(sys.platform.startswith(u'win'))).toBool(): base_color = self.palette().color(QtGui.QPalette.Active, QtGui.QPalette.Base) alternate_background_repair_stylesheet = \ u'QTableWidget, QListWidget, QTreeWidget {alternate-background-color: ' + base_color.name() + ';}\n' diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index af83509e6..0a4b14a15 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -501,15 +501,11 @@ class AdvancedTab(SettingsTab): self.x11BypassCheckBox.setChecked(settings.value( u'x11 bypass wm', QtCore.QVariant(x11_bypass_default)).toBool()) # Fix for bug #936281. - if sys.platform.startswith(u'win'): - stylesheet_fix_default = True - else: - stylesheet_fix_default = False # Prevent the dialog displayed by the stylesheetFixCheckBox to display. signalsBlocked = self.stylesheetFixCheckBox.blockSignals(True) self.stylesheetFixCheckBox.setChecked(settings.value( u'stylesheet fix', QtCore.QVariant( - stylesheet_fix_default)).toBool()) + sys.platform.startswith(u'win'))).toBool()) self.stylesheetFixCheckBox.blockSignals(signalsBlocked) self.defaultColor = settings.value(u'default color', QtCore.QVariant(u'#ffffff')).toString() @@ -828,4 +824,3 @@ class AdvancedTab(SettingsTab): def onnextItemButtonClicked(self): self.slide_limits = SlideLimits.Next - From cf36197993d5c863628fa75ddfe6c2edc77f66b8 Mon Sep 17 00:00:00 2001 From: Patrick Zimmermann Date: Wed, 19 Dec 2012 23:22:11 +0100 Subject: [PATCH 05/64] Rename stylesheetFix -> alternateRows. --- openlp/core/__init__.py | 6 +++--- openlp/core/ui/advancedtab.py | 30 +++++++++++++++--------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 32db93d15..c32a633e5 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -125,11 +125,11 @@ class OpenLP(QtGui.QApplication): Settings().setValue(u'general/has run wizard', QtCore.QVariant(True)) # Correct stylesheet bugs application_stylesheet = u'' - if Settings().value(u'advanced/stylesheet fix', QtCore.QVariant(sys.platform.startswith(u'win'))).toBool(): + if Settings().value(u'advanced/alternate rows', QtCore.QVariant(sys.platform.startswith(u'win'))).toBool(): base_color = self.palette().color(QtGui.QPalette.Active, QtGui.QPalette.Base) - alternate_background_repair_stylesheet = \ + alternate_rows_repair_stylesheet = \ u'QTableWidget, QListWidget, QTreeWidget {alternate-background-color: ' + base_color.name() + ';}\n' - application_stylesheet += alternate_background_repair_stylesheet + application_stylesheet += alternate_rows_repair_stylesheet if os.name == u'nt': application_stylesheet += nt_repair_stylesheet if application_stylesheet: diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 0a4b14a15..52cbdf019 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -284,9 +284,9 @@ class AdvancedTab(SettingsTab): self.x11BypassCheckBox = QtGui.QCheckBox(self.workaroundGroupBox) self.x11BypassCheckBox.setObjectName(u'x11BypassCheckBox') self.workaroundLayout.addWidget(self.x11BypassCheckBox) - self.stylesheetFixCheckBox = QtGui.QCheckBox(self.workaroundGroupBox) - self.stylesheetFixCheckBox.setObjectName(u'stylesheetFixCheckBox') - self.workaroundLayout.addWidget(self.stylesheetFixCheckBox) + self.alternateRowsCheckBox = QtGui.QCheckBox(self.workaroundGroupBox) + self.alternateRowsCheckBox.setObjectName(u'alternateRowsCheckBox') + self.workaroundLayout.addWidget(self.alternateRowsCheckBox) self.rightLayout.addWidget(self.workaroundGroupBox) self.rightLayout.addStretch() self.shouldUpdateServiceNameExample = False @@ -312,8 +312,8 @@ class AdvancedTab(SettingsTab): QtCore.SIGNAL(u'clicked()'), self.onDefaultRevertButtonClicked) QtCore.QObject.connect(self.x11BypassCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.onX11BypassCheckBoxToggled) - QtCore.QObject.connect(self.stylesheetFixCheckBox, - QtCore.SIGNAL(u'toggled(bool)'), self.onStylesheetFixCheckBoxToggled) + QtCore.QObject.connect(self.alternateRowsCheckBox, + QtCore.SIGNAL(u'toggled(bool)'), self.onAlternateRowsCheckBoxToggled) QtCore.QObject.connect(self.dataDirectoryBrowseButton, QtCore.SIGNAL(u'clicked()'), self.onDataDirectoryBrowseButtonClicked) @@ -433,7 +433,7 @@ class AdvancedTab(SettingsTab): self.workaroundGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Workarounds')) self.x11BypassCheckBox.setText(translate('OpenLP.AdvancedTab', 'Bypass X11 Window Manager')) - self.stylesheetFixCheckBox.setText(translate('OpenLP.AdvancedTab', + self.alternateRowsCheckBox.setText(translate('OpenLP.AdvancedTab', 'Disable alternating row colors in lists')) # Slide Limits self.slideGroupBox.setTitle( @@ -501,12 +501,12 @@ class AdvancedTab(SettingsTab): self.x11BypassCheckBox.setChecked(settings.value( u'x11 bypass wm', QtCore.QVariant(x11_bypass_default)).toBool()) # Fix for bug #936281. - # Prevent the dialog displayed by the stylesheetFixCheckBox to display. - signalsBlocked = self.stylesheetFixCheckBox.blockSignals(True) - self.stylesheetFixCheckBox.setChecked(settings.value( - u'stylesheet fix', QtCore.QVariant( + # Prevent the dialog displayed by the alternateRowsCheckBox to display. + signalsBlocked = self.alternateRowsCheckBox.blockSignals(True) + self.alternateRowsCheckBox.setChecked(settings.value( + u'alternate rows', QtCore.QVariant( sys.platform.startswith(u'win'))).toBool()) - self.stylesheetFixCheckBox.blockSignals(signalsBlocked) + self.alternateRowsCheckBox.blockSignals(signalsBlocked) self.defaultColor = settings.value(u'default color', QtCore.QVariant(u'#ffffff')).toString() self.defaultFileEdit.setText(settings.value(u'default image', @@ -597,8 +597,8 @@ class AdvancedTab(SettingsTab): QtCore.QVariant(self.hideMouseCheckBox.isChecked())) settings.setValue(u'x11 bypass wm', QtCore.QVariant(self.x11BypassCheckBox.isChecked())) - settings.setValue(u'stylesheet fix', - QtCore.QVariant(self.stylesheetFixCheckBox.isChecked())) + settings.setValue(u'alternate rows', + QtCore.QVariant(self.alternateRowsCheckBox.isChecked())) settings.setValue(u'default color', self.defaultColor) settings.setValue(u'default image', self.defaultFileEdit.text()) settings.setValue(u'slide limits', QtCore.QVariant(self.slide_limits)) @@ -804,7 +804,7 @@ class AdvancedTab(SettingsTab): """ self.displayChanged = True - def onStylesheetFixCheckBoxToggled(self, checked): + def onAlternateRowsCheckBoxToggled(self, checked): """ Notify user about required restart. @@ -814,7 +814,7 @@ class AdvancedTab(SettingsTab): QtGui.QMessageBox.information(self, translate('OpenLP.AdvancedTab', 'Restart Required'), translate('OpenLP.AdvancedTab', - 'The change will take effect when OpenLP is restarted.')) + 'This change will only take effect once OpenLP has been restarted.')) def onEndSlideButtonClicked(self): self.slide_limits = SlideLimits.End From f156c37e907c123babda9f7ff57999d59bc1bb38 Mon Sep 17 00:00:00 2001 From: Patrick Zimmermann Date: Wed, 19 Dec 2012 23:25:52 +0100 Subject: [PATCH 06/64] Fix indentation. --- openlp/core/ui/advancedtab.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 52cbdf019..b6dda7340 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -312,7 +312,7 @@ class AdvancedTab(SettingsTab): QtCore.SIGNAL(u'clicked()'), self.onDefaultRevertButtonClicked) QtCore.QObject.connect(self.x11BypassCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.onX11BypassCheckBoxToggled) - QtCore.QObject.connect(self.alternateRowsCheckBox, + QtCore.QObject.connect(self.alternateRowsCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.onAlternateRowsCheckBoxToggled) QtCore.QObject.connect(self.dataDirectoryBrowseButton, QtCore.SIGNAL(u'clicked()'), From cf9f55d5d28bb17400e18145d037ddbeb41efca2 Mon Sep 17 00:00:00 2001 From: Patrick Zimmermann Date: Tue, 1 Jan 2013 14:38:36 +0100 Subject: [PATCH 07/64] Change blockSignals() to use True & False. Correct line length. --- openlp/core/ui/advancedtab.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index abcecb231..d48cafce0 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -389,9 +389,9 @@ class AdvancedTab(SettingsTab): self.x11BypassCheckBox.setChecked(settings.value(u'x11 bypass wm', x11_bypass_default)) # Fix for bug #936281. # Prevent the dialog displayed by the alternateRowsCheckBox to display. - signalsBlocked = self.alternateRowsCheckBox.blockSignals(True) + self.alternateRowsCheckBox.blockSignals(True) self.alternateRowsCheckBox.setChecked(settings.value(u'alternate rows', sys.platform.startswith(u'win'))) - self.alternateRowsCheckBox.blockSignals(signalsBlocked) + self.alternateRowsCheckBox.blockSignals(False) self.defaultColor = settings.value(u'default color', u'#ffffff') self.defaultFileEdit.setText(settings.value(u'default image', u':/graphics/openlp-splash-screen.png')) self.slide_limits = settings.value(u'slide limits', SlideLimits.End) @@ -659,8 +659,7 @@ class AdvancedTab(SettingsTab): """ QtGui.QMessageBox.information(self, translate('OpenLP.AdvancedTab', 'Restart Required'), - translate('OpenLP.AdvancedTab', - 'This change will only take effect once OpenLP has been restarted.')) + translate('OpenLP.AdvancedTab', 'This change will only take effect once OpenLP has been restarted.')) def onEndSlideButtonClicked(self): self.slide_limits = SlideLimits.End From 33bad251048f6a89633e1960bc39f62c6dca719b Mon Sep 17 00:00:00 2001 From: Patrick Zimmermann Date: Tue, 1 Jan 2013 21:03:12 +0100 Subject: [PATCH 08/64] Rename "workarounds" -> "display workarounds". --- openlp/core/ui/advancedtab.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index d48cafce0..1cefac2d1 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -240,18 +240,18 @@ class AdvancedTab(SettingsTab): self.nextItemRadioButton.setObjectName(u'nextItemRadioButton') self.slideLayout.addWidget(self.nextItemRadioButton) self.rightLayout.addWidget(self.slideGroupBox) - # Workarounds - self.workaroundGroupBox = QtGui.QGroupBox(self.leftColumn) - self.workaroundGroupBox.setObjectName(u'workaroundGroupBox') - self.workaroundLayout = QtGui.QVBoxLayout(self.workaroundGroupBox) - self.workaroundLayout.setObjectName(u'workaroundLayout') - self.x11BypassCheckBox = QtGui.QCheckBox(self.workaroundGroupBox) + # Display Workarounds + self.displayWorkaroundGroupBox = QtGui.QGroupBox(self.leftColumn) + self.displayWorkaroundGroupBox.setObjectName(u'displayWorkaroundGroupBox') + self.displayWorkaroundLayout = QtGui.QVBoxLayout(self.displayWorkaroundGroupBox) + self.displayWorkaroundLayout.setObjectName(u'displayWorkaroundLayout') + self.x11BypassCheckBox = QtGui.QCheckBox(self.displayWorkaroundGroupBox) self.x11BypassCheckBox.setObjectName(u'x11BypassCheckBox') - self.workaroundLayout.addWidget(self.x11BypassCheckBox) - self.alternateRowsCheckBox = QtGui.QCheckBox(self.workaroundGroupBox) + self.displayWorkaroundLayout.addWidget(self.x11BypassCheckBox) + self.alternateRowsCheckBox = QtGui.QCheckBox(self.displayWorkaroundGroupBox) self.alternateRowsCheckBox.setObjectName(u'alternateRowsCheckBox') - self.workaroundLayout.addWidget(self.alternateRowsCheckBox) - self.rightLayout.addWidget(self.workaroundGroupBox) + self.displayWorkaroundLayout.addWidget(self.alternateRowsCheckBox) + self.rightLayout.addWidget(self.displayWorkaroundGroupBox) self.rightLayout.addStretch() self.shouldUpdateServiceNameExample = False QtCore.QObject.connect(self.serviceNameCheckBox, QtCore.SIGNAL(u'toggled(bool)'), @@ -340,7 +340,7 @@ class AdvancedTab(SettingsTab): self.newDataDirectoryHasFilesLabel.setText( translate('OpenLP.AdvancedTab', 'WARNING: New data directory location contains ' 'OpenLP data files. These files WILL be replaced during a copy.')) - self.workaroundGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Workarounds')) + self.displayWorkaroundGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Display Workarounds')) self.x11BypassCheckBox.setText(translate('OpenLP.AdvancedTab','Bypass X11 Window Manager')) self.alternateRowsCheckBox.setText(translate('OpenLP.AdvancedTab', 'Disable alternating row colors in lists')) From 024ba1aac933e91d150fe2581669a3e3b9494278 Mon Sep 17 00:00:00 2001 From: Dmitriy Marmyshev Date: Sat, 12 Jan 2013 00:23:06 +0400 Subject: [PATCH 09/64] Auto separating blank buttons, if width allows this. Fixes: https://launchpad.net/bugs/718797 --- openlp/core/ui/slidecontroller.py | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index bacb6ea60..2f8b48d8d 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -98,6 +98,14 @@ class SlideController(DisplayController): u'audioPauseItem', u'audioTimeLabel' ] + self.wideMenu = [ + u'wideMenu1', + u'wideMenu2', + u'wideMenu3' + ] + self.hideMenuList = [ + u'hideMenu' + ] self.timer_id = 0 self.songEdit = False self.selectedRow = 0 @@ -197,6 +205,19 @@ class SlideController(DisplayController): self.hideMenu.menu().addAction(self.blankScreen) self.hideMenu.menu().addAction(self.themeScreen) self.hideMenu.menu().addAction(self.desktopScreen) + #Wide menu of display control buttons + self.wideMenu1 = QtGui.QToolButton(self.toolbar) + self.wideMenu1.setObjectName(u'wideMenu1') + self.toolbar.addToolbarWidget(self.wideMenu1) + self.wideMenu1.setDefaultAction(self.blankScreen) + self.wideMenu2 = QtGui.QToolButton(self.toolbar) + self.wideMenu2.setObjectName(u'wideMenu2') + self.toolbar.addToolbarWidget(self.wideMenu2) + self.wideMenu2.setDefaultAction(self.themeScreen) + self.wideMenu3 = QtGui.QToolButton(self.toolbar) + self.wideMenu3.setObjectName(u'wideMenu3') + self.toolbar.addToolbarWidget(self.wideMenu3) + self.wideMenu3.setDefaultAction(self.desktopScreen) self.toolbar.addToolbarAction(u'loopSeparator', separator=True) # Play Slides Menu self.playSlidesMenu = QtGui.QToolButton(self.toolbar) @@ -349,6 +370,7 @@ class SlideController(DisplayController): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'slidecontroller_toggle_display'), self.toggleDisplay) self.toolbar.setWidgetVisible(self.loopList, False) + self.toolbar.setWidgetVisible(self.wideMenu, False) else: QtCore.QObject.connect(self.previewListWidget, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onGoLiveClick) @@ -568,7 +590,20 @@ class SlideController(DisplayController): width = self.parent().controlSplitter.sizes()[self.split] for framenumber in range(len(self.serviceItem.get_frames())): self.previewListWidget.setRowHeight(framenumber, width / self.ratio) + self.onControllerSizeChanged(self.controller.width() , self.controller.height()) + def onControllerSizeChanged(self, width, height): + """ + Change layout of display control buttons on controller size change + """ + if self.isLive: + if width > 300 and self.hideMenu.isVisible(): + self.toolbar.setWidgetVisible(self.hideMenuList, False) + self.toolbar.setWidgetVisible(self.wideMenu) + elif width < 300 and not self.hideMenu.isVisible(): + self.toolbar.setWidgetVisible(self.wideMenu, False) + self.toolbar.setWidgetVisible(self.hideMenuList) + def onSongBarHandler(self): request = self.sender().text() slide_no = self.slideList[request] From 4af3798cd34b273b8bb1a330837ae6df68307d9d Mon Sep 17 00:00:00 2001 From: Patrick Zimmermann Date: Sat, 12 Jan 2013 21:51:14 +0100 Subject: [PATCH 10/64] Fix a comment indentation. --- openlp/core/ui/advancedtab.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 1cefac2d1..c0e88beba 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -655,7 +655,7 @@ class AdvancedTab(SettingsTab): Notify user about required restart. ``checked`` - The state of the check box (boolean). + The state of the check box (boolean). """ QtGui.QMessageBox.information(self, translate('OpenLP.AdvancedTab', 'Restart Required'), From ef947355c50cfbfff9417050b3668ce18b6f5e3d Mon Sep 17 00:00:00 2001 From: Dmitriy Marmyshev Date: Wed, 16 Jan 2013 03:59:04 +0400 Subject: [PATCH 11/64] style fixing --- 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 2f8b48d8d..d3c59c783 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -205,7 +205,7 @@ class SlideController(DisplayController): self.hideMenu.menu().addAction(self.blankScreen) self.hideMenu.menu().addAction(self.themeScreen) self.hideMenu.menu().addAction(self.desktopScreen) - #Wide menu of display control buttons + # Wide menu of display control buttons. self.wideMenu1 = QtGui.QToolButton(self.toolbar) self.wideMenu1.setObjectName(u'wideMenu1') self.toolbar.addToolbarWidget(self.wideMenu1) @@ -590,15 +590,15 @@ class SlideController(DisplayController): width = self.parent().controlSplitter.sizes()[self.split] for framenumber in range(len(self.serviceItem.get_frames())): self.previewListWidget.setRowHeight(framenumber, width / self.ratio) - self.onControllerSizeChanged(self.controller.width() , self.controller.height()) + self.onControllerSizeChanged(self.controller.width(), self.controller.height()) - def onControllerSizeChanged(self, width, height): + def onControllerSizeChanged(self, width, height): """ Change layout of display control buttons on controller size change """ if self.isLive: if width > 300 and self.hideMenu.isVisible(): - self.toolbar.setWidgetVisible(self.hideMenuList, False) + self.toolbar.setWidgetVisible(self.hideMenuList, False) self.toolbar.setWidgetVisible(self.wideMenu) elif width < 300 and not self.hideMenu.isVisible(): self.toolbar.setWidgetVisible(self.wideMenu, False) From e3e8693bcccb68be376d9d598a7183aaede52661 Mon Sep 17 00:00:00 2001 From: Dmitriy Marmyshev Date: Fri, 18 Jan 2013 23:00:13 +0400 Subject: [PATCH 12/64] name fix --- openlp/core/ui/slidecontroller.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index d3c59c783..afc0c0492 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -99,9 +99,9 @@ class SlideController(DisplayController): u'audioTimeLabel' ] self.wideMenu = [ - u'wideMenu1', - u'wideMenu2', - u'wideMenu3' + u'buttonBlankScreen', + u'buttonThemeScreen', + u'buttonDesktopScreen' ] self.hideMenuList = [ u'hideMenu' @@ -206,18 +206,18 @@ class SlideController(DisplayController): self.hideMenu.menu().addAction(self.themeScreen) self.hideMenu.menu().addAction(self.desktopScreen) # Wide menu of display control buttons. - self.wideMenu1 = QtGui.QToolButton(self.toolbar) - self.wideMenu1.setObjectName(u'wideMenu1') - self.toolbar.addToolbarWidget(self.wideMenu1) - self.wideMenu1.setDefaultAction(self.blankScreen) - self.wideMenu2 = QtGui.QToolButton(self.toolbar) - self.wideMenu2.setObjectName(u'wideMenu2') - self.toolbar.addToolbarWidget(self.wideMenu2) - self.wideMenu2.setDefaultAction(self.themeScreen) - self.wideMenu3 = QtGui.QToolButton(self.toolbar) - self.wideMenu3.setObjectName(u'wideMenu3') - self.toolbar.addToolbarWidget(self.wideMenu3) - self.wideMenu3.setDefaultAction(self.desktopScreen) + self.buttonBlankScreen = QtGui.QToolButton(self.toolbar) + self.buttonBlankScreen.setObjectName(u'buttonBlankScreen') + self.toolbar.addToolbarWidget(self.buttonBlankScreen) + self.buttonBlankScreen.setDefaultAction(self.blankScreen) + self.buttonThemeScreen = QtGui.QToolButton(self.toolbar) + self.buttonThemeScreen.setObjectName(u'buttonThemeScreen') + self.toolbar.addToolbarWidget(self.buttonThemeScreen) + self.buttonThemeScreen.setDefaultAction(self.themeScreen) + self.buttonDesktopScreen = QtGui.QToolButton(self.toolbar) + self.buttonDesktopScreen.setObjectName(u'buttonDesktopScreen') + self.toolbar.addToolbarWidget(self.buttonDesktopScreen) + self.buttonDesktopScreen.setDefaultAction(self.desktopScreen) self.toolbar.addToolbarAction(u'loopSeparator', separator=True) # Play Slides Menu self.playSlidesMenu = QtGui.QToolButton(self.toolbar) From 768b27101e7c1dc12e1a318eb0b573473018da15 Mon Sep 17 00:00:00 2001 From: Patrick Zimmermann Date: Fri, 18 Jan 2013 22:41:11 +0100 Subject: [PATCH 13/64] Reverse option logic. Now it's "enable alternating row colors". --- openlp/core/__init__.py | 2 +- openlp/core/ui/advancedtab.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index f1dfe4846..7bdeaebda 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -124,7 +124,7 @@ class OpenLP(QtGui.QApplication): Settings().setValue(u'general/has run wizard', True) # Correct stylesheet bugs application_stylesheet = u'' - if Settings().value(u'advanced/alternate rows', sys.platform.startswith(u'win')): + if not Settings().value(u'advanced/alternate rows', not sys.platform.startswith(u'win')): base_color = self.palette().color(QtGui.QPalette.Active, QtGui.QPalette.Base) alternate_rows_repair_stylesheet = \ u'QTableWidget, QListWidget, QTreeWidget {alternate-background-color: ' + base_color.name() + ';}\n' diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 4dd0d3588..b50c582d7 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -342,8 +342,7 @@ class AdvancedTab(SettingsTab): 'OpenLP data files. These files WILL be replaced during a copy.')) self.displayWorkaroundGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Display Workarounds')) self.x11BypassCheckBox.setText(translate('OpenLP.AdvancedTab','Bypass X11 Window Manager')) - self.alternateRowsCheckBox.setText(translate('OpenLP.AdvancedTab', - 'Disable alternating row colors in lists')) + self.alternateRowsCheckBox.setText(translate('OpenLP.AdvancedTab', 'Enable alternating row colors in lists')) # Slide Limits self.slideGroupBox.setTitle(translate('OpenLP.GeneralTab', 'Service Item Slide Limits')) self.slideLabel.setText(translate('OpenLP.GeneralTab', 'Behavior of next/previous on the last/first slide:')) @@ -390,7 +389,7 @@ class AdvancedTab(SettingsTab): # Fix for bug #936281. # Prevent the dialog displayed by the alternateRowsCheckBox to display. self.alternateRowsCheckBox.blockSignals(True) - self.alternateRowsCheckBox.setChecked(settings.value(u'alternate rows', sys.platform.startswith(u'win'))) + self.alternateRowsCheckBox.setChecked(settings.value(u'alternate rows', not sys.platform.startswith(u'win'))) self.alternateRowsCheckBox.blockSignals(False) self.defaultColor = settings.value(u'default color', u'#ffffff') self.defaultFileEdit.setText(settings.value(u'default image', u':/graphics/openlp-splash-screen.png')) From 6e925473982db908205cf4a8c0f2b2fc3e92369d Mon Sep 17 00:00:00 2001 From: Dmitriy Marmyshev Date: Thu, 24 Jan 2013 07:07:41 +0400 Subject: [PATCH 14/64] styling fix --- openlp/core/ui/slidecontroller.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index afc0c0492..67b2e62c4 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -99,9 +99,9 @@ class SlideController(DisplayController): u'audioTimeLabel' ] self.wideMenu = [ - u'buttonBlankScreen', - u'buttonThemeScreen', - u'buttonDesktopScreen' + u'blankScreenButton', + u'themeScreenButton', + u'desktopScreenButton' ] self.hideMenuList = [ u'hideMenu' @@ -206,18 +206,18 @@ class SlideController(DisplayController): self.hideMenu.menu().addAction(self.themeScreen) self.hideMenu.menu().addAction(self.desktopScreen) # Wide menu of display control buttons. - self.buttonBlankScreen = QtGui.QToolButton(self.toolbar) - self.buttonBlankScreen.setObjectName(u'buttonBlankScreen') - self.toolbar.addToolbarWidget(self.buttonBlankScreen) - self.buttonBlankScreen.setDefaultAction(self.blankScreen) - self.buttonThemeScreen = QtGui.QToolButton(self.toolbar) - self.buttonThemeScreen.setObjectName(u'buttonThemeScreen') - self.toolbar.addToolbarWidget(self.buttonThemeScreen) - self.buttonThemeScreen.setDefaultAction(self.themeScreen) - self.buttonDesktopScreen = QtGui.QToolButton(self.toolbar) - self.buttonDesktopScreen.setObjectName(u'buttonDesktopScreen') - self.toolbar.addToolbarWidget(self.buttonDesktopScreen) - self.buttonDesktopScreen.setDefaultAction(self.desktopScreen) + self.blankScreenButton = QtGui.QToolButton(self.toolbar) + self.blankScreenButton.setObjectName(u'blankScreenButton') + self.toolbar.addToolbarWidget(self.blankScreenButton) + self.blankScreenButton.setDefaultAction(self.blankScreen) + self.themeScreenButton = QtGui.QToolButton(self.toolbar) + self.themeScreenButton.setObjectName(u'themeScreenButton') + self.toolbar.addToolbarWidget(self.themeScreenButton) + self.themeScreenButton.setDefaultAction(self.themeScreen) + self.desktopScreenButton = QtGui.QToolButton(self.toolbar) + self.desktopScreenButton.setObjectName(u'desktopScreenButton') + self.toolbar.addToolbarWidget(self.desktopScreenButton) + self.desktopScreenButton.setDefaultAction(self.desktopScreen) self.toolbar.addToolbarAction(u'loopSeparator', separator=True) # Play Slides Menu self.playSlidesMenu = QtGui.QToolButton(self.toolbar) From 6e1f9cd3c1f8d6ee14535d04957956ae08c23ee9 Mon Sep 17 00:00:00 2001 From: Patrick Zimmermann Date: Sun, 27 Jan 2013 23:07:30 +0100 Subject: [PATCH 15/64] Adapt code for new Settings() infrastructure. --- openlp/core/__init__.py | 2 +- openlp/core/lib/settings.py | 1 + openlp/core/ui/advancedtab.py | 3 +-- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 31353121e..e31ff0c5d 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -122,7 +122,7 @@ class OpenLP(QtGui.QApplication): Settings().setValue(u'general/has run wizard', True) # Correct stylesheet bugs application_stylesheet = u'' - if not Settings().value(u'advanced/alternate rows', not sys.platform.startswith(u'win')): + if not Settings().value(u'advanced/alternate rows'): base_color = self.palette().color(QtGui.QPalette.Active, QtGui.QPalette.Base) alternate_rows_repair_stylesheet = \ u'QTableWidget, QListWidget, QTreeWidget {alternate-background-color: ' + base_color.name() + ';}\n' diff --git a/openlp/core/lib/settings.py b/openlp/core/lib/settings.py index aad851dca..37a1c9feb 100644 --- a/openlp/core/lib/settings.py +++ b/openlp/core/lib/settings.py @@ -87,6 +87,7 @@ class Settings(QtCore.QSettings): """ __default_settings__ = { u'advanced/x11 bypass wm': X11_BYPASS_DEFAULT, + u'advanced/alternate rows': not sys.platform.startswith(u'win'), u'advanced/default service enabled': True, u'advanced/enable exit confirmation': True, u'advanced/save current plugin': False, diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index cec1b646d..cb11c0b63 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -368,10 +368,9 @@ class AdvancedTab(SettingsTab): self.defaultColor = settings.value(u'default color') self.defaultFileEdit.setText(settings.value(u'default image')) self.slide_limits = settings.value(u'slide limits') - # Fix for bug #936281. # Prevent the dialog displayed by the alternateRowsCheckBox to display. self.alternateRowsCheckBox.blockSignals(True) - self.alternateRowsCheckBox.setChecked(settings.value(u'alternate rows', not sys.platform.startswith(u'win'))) + self.alternateRowsCheckBox.setChecked(settings.value(u'alternate rows')) self.alternateRowsCheckBox.blockSignals(False) if self.slide_limits == SlideLimits.End: self.endSlideRadioButton.setChecked(True) From cd89c4de9a867ca30ce5434fe9596a9b8c48de5d Mon Sep 17 00:00:00 2001 From: Patrick Zimmermann Date: Sun, 27 Jan 2013 23:10:03 +0100 Subject: [PATCH 16/64] Enable -> Use and British spelling. --- openlp/core/ui/advancedtab.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index cb11c0b63..21a414dbf 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -331,7 +331,7 @@ class AdvancedTab(SettingsTab): 'OpenLP data files. These files WILL be replaced during a copy.')) self.displayWorkaroundGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Display Workarounds')) self.x11BypassCheckBox.setText(translate('OpenLP.AdvancedTab','Bypass X11 Window Manager')) - self.alternateRowsCheckBox.setText(translate('OpenLP.AdvancedTab', 'Enable alternating row colors in lists')) + self.alternateRowsCheckBox.setText(translate('OpenLP.AdvancedTab', 'Use alternating row colours in lists')) # Slide Limits self.slideGroupBox.setTitle(translate('OpenLP.GeneralTab', 'Service Item Slide Limits')) self.slideLabel.setText(translate('OpenLP.GeneralTab', 'Behavior of next/previous on the last/first slide:')) From cc5776c7d3fa73d682ec8ea4706046e354e66c16 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 30 Jan 2013 21:29:33 +0100 Subject: [PATCH 17/64] fixed 'song/ccli number' setting; do not change setting.ini when IMPORTING --- openlp/core/lib/settings.py | 8 +++----- openlp/core/ui/mainwindow.py | 11 +++++++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/openlp/core/lib/settings.py b/openlp/core/lib/settings.py index ba1e63fb9..116aac442 100644 --- a/openlp/core/lib/settings.py +++ b/openlp/core/lib/settings.py @@ -227,10 +227,7 @@ class Settings(QtCore.QSettings): u'user interface/live splitter geometry': QtCore.QByteArray(), u'user interface/main window state': QtCore.QByteArray(), u'media/players': u'webkit', - u'media/override player': QtCore.Qt.Unchecked, - # Old settings (not used anymore). Have to be here, so that old setting.config backups can be imported. - u'advanced/stylesheet fix': u'', - u'servicemanager/last directory': u'' + u'media/override player': QtCore.Qt.Unchecked } __file_path__ = u'' __obsolete_settings__ = [ @@ -243,7 +240,8 @@ class Settings(QtCore.QSettings): (u'bibles/last directory 1', u'bibles/last directory import', []), (u'songusage/last directory 1', u'songusage/last directory export', []), (u'advanced/stylesheet fix', u'', []), - (u'media/background color', u'players/background color', []) + (u'media/background color', u'players/background color', []), + (u'songs/ccli number', u'general/ccli number', []) ] @staticmethod diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 6ab3f7f0a..0fb171c04 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -40,7 +40,7 @@ from datetime import datetime from PyQt4 import QtCore, QtGui from openlp.core.lib import Renderer, build_icon, OpenLPDockWidget, PluginManager, Receiver, translate, ImageManager, \ - PluginStatus, Registry, Settings, ScreenList + PluginStatus, Registry, Settings, ScreenList, check_directory_exists from openlp.core.lib.ui import UiStrings, create_action from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, ThemeManager, SlideController, PluginForm, \ MediaDockManager, ShortcutListForm, FormattingTagForm @@ -819,8 +819,15 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # Add plugin sections. for plugin in self.pluginManager.plugins: setting_sections.extend([plugin.name]) + # Copy the settings file to the tmp dir, because we do not want to overwrite the original one. + temp_directory = os.path.join(unicode(gettempdir()), u'openlp') + check_directory_exists(temp_directory) + temp_config = os.path.join(temp_directory, os.path.basename(import_file_name)) + shutil.copyfile(import_file_name, temp_config) settings = Settings() - import_settings = Settings(import_file_name, Settings.IniFormat) + import_settings = Settings(temp_config, Settings.IniFormat) + # Remove/rename old settings to prepare the import. + import_settings.remove_obsolete_settings() # Lets do a basic sanity check. If it contains this string we can # assume it was created by OpenLP and so we'll load what we can # from it, and just silently ignore anything we don't recognise From d7472876c79736e9dfe77d0f042511172895bfd3 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 30 Jan 2013 21:34:54 +0100 Subject: [PATCH 18/64] change wording --- openlp/core/ui/mainwindow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 0fb171c04..7443f176f 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -819,7 +819,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # Add plugin sections. for plugin in self.pluginManager.plugins: setting_sections.extend([plugin.name]) - # Copy the settings file to the tmp dir, because we do not want to overwrite the original one. + # Copy the settings file to the tmp dir, because we do not want to change the original one. temp_directory = os.path.join(unicode(gettempdir()), u'openlp') check_directory_exists(temp_directory) temp_config = os.path.join(temp_directory, os.path.basename(import_file_name)) From 16ba742d1dc1a5ec62a2696011dd46a8ddbb7184 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 31 Jan 2013 08:56:34 +0100 Subject: [PATCH 19/64] sorted default dict a bit; fixed settings conversion; renamed a setting; removed old setting --- openlp/core/lib/settings.py | 145 ++++++++++++++++++------------ openlp/core/ui/mainwindow.py | 4 +- openlp/core/ui/slidecontroller.py | 2 +- 3 files changed, 89 insertions(+), 62 deletions(-) diff --git a/openlp/core/lib/settings.py b/openlp/core/lib/settings.py index 116aac442..002ac885b 100644 --- a/openlp/core/lib/settings.py +++ b/openlp/core/lib/settings.py @@ -74,7 +74,8 @@ class Settings(QtCore.QSettings): The first entry is the *old key*; it will be removed. - The second entry is the *new key*; we will add it to the config. + The second entry is the *new key*; we will add it to the config. If this is just an empty string, we just remove + the old key. The last entry is a list containing two-pair tuples. If the list is empty, no conversion is made. Otherwise each pair describes how to convert the old setting's value:: @@ -86,65 +87,67 @@ class Settings(QtCore.QSettings): So, if the type of the old value is bool, then there must be two rules. """ __default_settings__ = { - u'advanced/x11 bypass wm': X11_BYPASS_DEFAULT, - u'advanced/default service enabled': True, - u'advanced/enable exit confirmation': True, - u'advanced/save current plugin': False, - u'advanced/single click preview': False, - # 7 stands for now, 0 to 6 is Monday to Sunday. - u'advanced/default service day': 7, - u'advanced/max recent files': 20, - u'advanced/is portable': False, - u'advanced/hide mouse': True, + u'advanced/add page break': False, u'advanced/current media plugin': -1, - u'advanced/double click live': False, u'advanced/data path': u'', - u'advanced/default service hour': 11, u'advanced/default color': u'#ffffff', u'advanced/default image': u':/graphics/openlp-splash-screen.png', - u'advanced/expand service item': False, - u'advanced/recent file count': 4, - u'advanced/default service name': UiStrings().DefaultServiceName, + # 7 stands for now, 0 to 6 is Monday to Sunday. + u'advanced/default service day': 7, + u'advanced/default service enabled': True, + u'advanced/default service hour': 11, u'advanced/default service minute': 0, - u'advanced/slide limits': SlideLimits.End, - u'advanced/print slide text': False, - u'advanced/add page break': False, + u'advanced/default service name': UiStrings().DefaultServiceName, + u'advanced/display size': 0, + u'advanced/double click live': False, + u'advanced/enable exit confirmation': True, + u'advanced/expand service item': False, + u'advanced/hide mouse': True, + u'advanced/is portable': False, + u'advanced/max recent files': 20, u'advanced/print file meta data': False, u'advanced/print notes': False, - u'advanced/display size': 0, + u'advanced/print slide text': False, + u'advanced/recent file count': 4, + u'advanced/save current plugin': False, + u'advanced/slide limits': SlideLimits.End, + u'advanced/single click preview': False, + u'advanced/x11 bypass wm': X11_BYPASS_DEFAULT, u'crashreport/last directory': u'', u'displayTags/html_tags': u'', - u'general/ccli number': u'', - u'general/has run wizard': False, - u'general/update check': True, - u'general/language': u'[en]', - u'general/songselect password': u'', - u'general/recent files': [], - u'general/save prompt': False, - u'general/auto preview': False, - u'general/view mode': u'default', - u'general/auto open': False, - u'general/enable slide loop': True, - u'general/show splash': True, - u'general/screen blank': False, - # The oder display settings (display position and dimensions) are defined in the ScreenList class due to crycle - # dependency. - u'general/override position': False, - u'general/loop delay': 5, - u'general/songselect username': u'', u'general/audio repeat list': False, - u'general/auto unblank': False, - u'general/display on monitor': True, + u'general/auto open': False, + u'general/auto preview': False, u'general/audio start paused': True, + u'general/auto unblank': False, + u'general/blank warning': False, + u'general/ccli number': u'', + #u'general/enable slide loop': True, + u'general/has run wizard': False, + u'general/language': u'[en]', # This defaults to yesterday in order to force the update check to run when you've never run it before. u'general/last version test': datetime.datetime.now().date() - datetime.timedelta(days=1), - u'general/blank warning': False, + u'general/loop delay': 5, + u'general/recent files': [], + u'general/save prompt': False, + u'general/screen blank': False, + u'general/show splash': True, + u'general/songselect password': u'', + u'general/songselect username': u'', + u'general/update check': True, + u'general/view mode': u'default', + # The oder display settings (display position and dimensions) are defined in the ScreenList class due to crycle + # dependency. + u'general/display on monitor': True, + u'general/override position': False, + u'media/players': u'webkit', + u'media/override player': QtCore.Qt.Unchecked, u'players/background color': u'#000000', - u'servicemanager/service theme': u'', u'servicemanager/last file': u'', + u'servicemanager/service theme': u'', + u'SettingsImport/file_date_created': datetime.datetime.now().strftime("%Y-%m-%d %H:%M"), u'SettingsImport/Make_Changes': u'At_Own_RISK', u'SettingsImport/type': u'OpenLP_settings_export', - u'SettingsImport/file_date_created': datetime.datetime.now().strftime("%Y-%m-%d %H:%M"), u'SettingsImport/version': u'', u'shortcuts/aboutItem': [QtGui.QKeySequence(u'Ctrl+F1')], u'shortcuts/audioPauseItem': [], @@ -212,36 +215,37 @@ class Settings(QtCore.QSettings): u'shortcuts/viewLivePanel': [QtGui.QKeySequence(u'F12')], u'shortcuts/viewServiceManagerItem': [QtGui.QKeySequence(u'F9')], u'shortcuts/webSiteItem': [], - u'themes/theme level': ThemeLevel.Song, u'themes/global theme': u'', u'themes/last directory': u'', u'themes/last directory export': u'', u'themes/last directory import': u'', - u'user interface/main window position': QtCore.QPoint(0, 0), - u'user interface/preview panel': True, + u'themes/theme level': ThemeLevel.Song, u'user interface/live panel': True, - u'user interface/main window geometry': QtCore.QByteArray(), - u'user interface/preview splitter geometry': QtCore.QByteArray(), - u'user interface/lock panel': False, - u'user interface/mainwindow splitter geometry': QtCore.QByteArray(), u'user interface/live splitter geometry': QtCore.QByteArray(), + u'user interface/lock panel': False, + u'user interface/main window geometry': QtCore.QByteArray(), + u'user interface/main window position': QtCore.QPoint(0, 0), + u'user interface/main window splitter geometry': QtCore.QByteArray(), u'user interface/main window state': QtCore.QByteArray(), - u'media/players': u'webkit', - u'media/override player': QtCore.Qt.Unchecked + u'user interface/preview panel': True, + u'user interface/preview splitter geometry': QtCore.QByteArray() } __file_path__ = u'' __obsolete_settings__ = [ + # Changed during 1.9.x development. (u'bibles/bookname language', u'bibles/book name language', []), (u'general/enable slide loop', u'advanced/slide limits', [(SlideLimits.Wrap, True), (SlideLimits.End, False)]), + (u'songs/ccli number', u'general/ccli number', []), + # Changed during 2.1.x development. + (u'advanced/stylesheet fix', u'', []), + (u'bibles/last directory 1', u'bibles/last directory import', []), + (u'media/background color', u'players/background color', []), (u'themes/last directory', u'themes/last directory import', []), (u'themes/last directory 1', u'themes/last directory export', []), (u'servicemanager/last directory', u'', []), (u'songs/last directory 1', u'songs/last directory import', []), - (u'bibles/last directory 1', u'bibles/last directory import', []), (u'songusage/last directory 1', u'songusage/last directory export', []), - (u'advanced/stylesheet fix', u'', []), - (u'media/background color', u'players/background color', []), - (u'songs/ccli number', u'general/ccli number', []) + (u'user interface/mainwindow splitter geometry', u'user interface/main window splitter geometry', []) ] @staticmethod @@ -273,6 +277,12 @@ class Settings(QtCore.QSettings): Settings.__default_settings__[u'advanced/default service name'] = UiStrings().DefaultServiceName def __init__(self, *args): + """ + Constructor + + ``args`` + Passed to Qt. But not passed in all cases. + """ if not args and Settings.__file_path__ and Settings.defaultFormat() == Settings.IniFormat: QtCore.QSettings.__init__(self, Settings.__file_path__, Settings.IniFormat) else: @@ -289,6 +299,11 @@ class Settings(QtCore.QSettings): if new_key: # Get the value of the old_key. old_value = super(Settings, self).value(old_key) + # When we want to convert the value, we have to figure out the default value (because we cannot get + # the default value from the central settings dict. + if rules: + default_value = rules[0][1] + old_value = self._convert_value(old_value, default_value) # Iterate over our rules and check what the old_value should be "converted" to. for new, old in rules: # If the value matches with the condition (rule), then use the provided value. This is used to @@ -304,8 +319,6 @@ class Settings(QtCore.QSettings): Returns the value for the given ``key``. The returned ``value`` is of the same type as the default value in the *Settings.__default_settings__* dict. - **Note**, this method only converts a few types and might need to be extended if a certain type is missing! - ``key`` The key to return the value from. """ @@ -315,6 +328,21 @@ class Settings(QtCore.QSettings): else: default_value = Settings.__default_settings__[key] setting = super(Settings, self).value(key, default_value) + return self._convert_value(setting, default_value) + + def _convert_value(self, setting, default_value): + """ + This converts the given ``setting`` to the type of the given ``default_value``. + + ``setting`` + The setting to convert. This could be ``true`` for example.Settings() + + ``default_value`` + Indication the type the setting should be converted to. For example ``True`` (type is boolean), meaning that + we convert the string ``true`` to a python boolean. + + **Note**, this method only converts a few types and might need to be extended if a certain type is missing! + """ # On OS X (and probably on other platforms too) empty value from QSettings is represented as type # PyQt4.QtCore.QPyNullVariant. This type has to be converted to proper 'None' Python type. if isinstance(setting, QtCore.QPyNullVariant) and setting.isNull(): @@ -337,4 +365,3 @@ class Settings(QtCore.QSettings): if isinstance(default_value, int): return int(setting) return setting - diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 7443f176f..998f7541e 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -1191,7 +1191,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.restoreState(settings.value(u'main window state')) self.liveController.splitter.restoreState(settings.value(u'live splitter geometry')) self.previewController.splitter.restoreState(settings.value(u'preview splitter geometry')) - self.controlSplitter.restoreState(settings.value(u'mainwindow splitter geometry')) + self.controlSplitter.restoreState(settings.value(u'main window splitter geometry')) settings.endGroup() def saveSettings(self): @@ -1212,7 +1212,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): settings.setValue(u'main window geometry', self.saveGeometry()) settings.setValue(u'live splitter geometry', self.liveController.splitter.saveState()) settings.setValue(u'preview splitter geometry', self.previewController.splitter.saveState()) - settings.setValue(u'mainwindow splitter geometry', self.controlSplitter.saveState()) + settings.setValue(u'main window splitter geometry', self.controlSplitter.saveState()) settings.endGroup() def updateRecentFilesMenu(self): diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 05151b20e..377d14c76 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -207,7 +207,7 @@ class SlideController(DisplayController): self.playSlidesOnce = create_action(self, u'playSlidesOnce', text=UiStrings().PlaySlidesToEnd, icon=u':/media/media_time.png', checked=False, shortcuts=[], category=self.category, triggers=self.onPlaySlidesOnce) - if Settings().value(self.parent().generalSettingsSection + u'/enable slide loop'): + if Settings().value(self.parent().advancedSettingsSection + u'/slide limits') == SlideLimits.Wrap: self.playSlidesMenu.setDefaultAction(self.playSlidesLoop) else: self.playSlidesMenu.setDefaultAction(self.playSlidesOnce) From bdf94d50bb9ad310f898ef0581d79f313e7e04a1 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Thu, 31 Jan 2013 20:40:17 +0200 Subject: [PATCH 20/64] Rename openlp.pyw to openlp.py as the reason for using a .pyw extension never really existed in the first place. --- openlp.pyw => openlp.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename openlp.pyw => openlp.py (100%) diff --git a/openlp.pyw b/openlp.py similarity index 100% rename from openlp.pyw rename to openlp.py From c7aa0cd0f10e6b185a254e4a5693b71ca42a2105 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 31 Jan 2013 19:46:19 +0100 Subject: [PATCH 21/64] removed commented line --- openlp/core/lib/settings.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/core/lib/settings.py b/openlp/core/lib/settings.py index 002ac885b..9582b4241 100644 --- a/openlp/core/lib/settings.py +++ b/openlp/core/lib/settings.py @@ -122,7 +122,6 @@ class Settings(QtCore.QSettings): u'general/auto unblank': False, u'general/blank warning': False, u'general/ccli number': u'', - #u'general/enable slide loop': True, u'general/has run wizard': False, u'general/language': u'[en]', # This defaults to yesterday in order to force the update check to run when you've never run it before. From 6ef4db5ce840052f563a353bd76ea31e1c350bdb Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 31 Jan 2013 19:41:45 +0000 Subject: [PATCH 22/64] Tests restructure --- tests/interfaces/openlp_core_ui/__init__.py | 0 .../openlp_core_ui/test_servicenotedialog.py | 0 .../openlp_core_ui/test_starttimedialog.py | 0 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/interfaces/openlp_core_ui/__init__.py rename tests/{functional => interfaces}/openlp_core_ui/test_servicenotedialog.py (100%) rename tests/{functional => interfaces}/openlp_core_ui/test_starttimedialog.py (100%) diff --git a/tests/interfaces/openlp_core_ui/__init__.py b/tests/interfaces/openlp_core_ui/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/functional/openlp_core_ui/test_servicenotedialog.py b/tests/interfaces/openlp_core_ui/test_servicenotedialog.py similarity index 100% rename from tests/functional/openlp_core_ui/test_servicenotedialog.py rename to tests/interfaces/openlp_core_ui/test_servicenotedialog.py diff --git a/tests/functional/openlp_core_ui/test_starttimedialog.py b/tests/interfaces/openlp_core_ui/test_starttimedialog.py similarity index 100% rename from tests/functional/openlp_core_ui/test_starttimedialog.py rename to tests/interfaces/openlp_core_ui/test_starttimedialog.py From b0b89fdc054ff84bccd8f12cfaa770acfe932129 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 1 Feb 2013 00:01:41 +0200 Subject: [PATCH 23/64] Some code cleanups to make PyLint happier. --- openlp/plugins/alerts/forms/alertform.py | 15 ++- openlp/plugins/custom/forms/editcustomform.py | 54 ++++++--- .../custom/forms/editcustomslideform.py | 14 ++- openlp/plugins/songs/forms/songbookform.py | 12 +- openlp/plugins/songs/forms/songimportform.py | 105 ++++++++++-------- .../songs/forms/songmaintenanceform.py | 34 +++++- openlp/plugins/songs/forms/topicsform.py | 9 +- 7 files changed, 172 insertions(+), 71 deletions(-) diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index cedb7acfc..c09180702 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -34,6 +34,7 @@ from openlp.plugins.alerts.lib.db import AlertItem from alertdialog import Ui_AlertDialog + class AlertForm(QtGui.QDialog, Ui_AlertDialog): """ Provide UI for the alert system @@ -45,7 +46,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): self.manager = plugin.manager self.plugin = plugin self.item_id = None - QtGui.QDialog.__init__(self, self.plugin.main_window) + super(AlertForm, self).__init__(self.plugin.main_window) self.setupUi(self) QtCore.QObject.connect(self.displayButton, QtCore.SIGNAL(u'clicked()'), self.onDisplayClicked) QtCore.QObject.connect(self.displayCloseButton, QtCore.SIGNAL(u'clicked()'), self.onDisplayCloseClicked) @@ -57,6 +58,9 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): QtCore.QObject.connect(self.alertListWidget, QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged) def exec_(self): + """ + Execute the dialog and return the exit code. + """ self.displayButton.setEnabled(False) self.displayCloseButton.setEnabled(False) self.alertTextEdit.setText(u'') @@ -77,9 +81,15 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): self.alertListWidget.setCurrentRow(self.alertListWidget.row(item_name)) def onDisplayClicked(self): + """ + Display the current alert text. + """ self.triggerAlert(self.alertTextEdit.text()) def onDisplayCloseClicked(self): + """ + Close the alert preview. + """ if self.triggerAlert(self.alertTextEdit.text()): self.close() @@ -97,6 +107,9 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): self.alertTextEdit.setText(u'') def onNewClick(self): + """ + Create a new alert. + """ if not self.alertTextEdit.text(): QtGui.QMessageBox.information(self, translate('AlertsPlugin.AlertForm', 'New Alert'), diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 8e7c18bdf..18f3ab736 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -41,35 +41,42 @@ from editcustomslideform import EditCustomSlideForm log = logging.getLogger(__name__) + class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): """ Class documentation goes here. """ log.info(u'Custom Editor loaded') + def __init__(self, mediaitem, parent, manager): """ Constructor """ - QtGui.QDialog.__init__(self, parent) + super(EditCustomForm, self).__init__(parent) self.manager = manager self.mediaitem = mediaitem self.setupUi(self) # Create other objects and forms. self.editSlideForm = EditCustomSlideForm(self) # Connecting signals and slots - QtCore.QObject.connect(self.previewButton, QtCore.SIGNAL(u'clicked()'), self.onPreviewButtonClicked) - QtCore.QObject.connect(self.addButton, QtCore.SIGNAL(u'clicked()'), self.onAddButtonClicked) - QtCore.QObject.connect(self.editButton, QtCore.SIGNAL(u'clicked()'), self.onEditButtonClicked) - QtCore.QObject.connect(self.editAllButton, QtCore.SIGNAL(u'clicked()'), self.onEditAllButtonClicked) + self.previewButton.clicked.connect(self.on_preview_button_clicked) + self.addButton.clicked.connect(self.on_add_button_clicked) + self.editButton.clicked.connect(self.on_edit_button_clicked) + self.editAllButton.clicked.connect(self.on_edit_all_button_clicked) + self.slideListView.currentRowChanged.connect(self.on_current_row_changed) + self.slideListView.doubleClicked.connect(self.on_edit_button_clicked) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.loadThemes) - QtCore.QObject.connect(self.slideListView, QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged) - QtCore.QObject.connect(self.slideListView, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), - self.onEditButtonClicked) - def loadThemes(self, themelist): + def loadThemes(self, theme_list): + """ + Load a list of themes into the themes combo box. + + ``theme_list`` + The list of themes to load. + """ self.themeComboBox.clear() self.themeComboBox.addItem(u'') - self.themeComboBox.addItems(themelist) + self.themeComboBox.addItems(theme_list) def loadCustom(self, id, preview=False): """ @@ -103,6 +110,9 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.previewButton.setVisible(preview) def accept(self): + """ + Override the QDialog method to check if the custom slide has been saved before closing the dialog. + """ log.debug(u'accept') if self.saveCustom(): QtGui.QDialog.accept(self) @@ -125,6 +135,9 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): return success def onUpButtonClicked(self): + """ + Move a slide up in the list when the "Up" button is clicked. + """ selectedRow = self.slideListView.currentRow() if selectedRow != 0: qw = self.slideListView.takeItem(selectedRow) @@ -132,6 +145,9 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.slideListView.setCurrentRow(selectedRow - 1) def onDownButtonClicked(self): + """ + Move a slide down in the list when the "Down" button is clicked. + """ selectedRow = self.slideListView.currentRow() # zero base arrays if selectedRow != self.slideListView.count() - 1: @@ -139,17 +155,23 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.slideListView.insertItem(selectedRow + 1, qw) self.slideListView.setCurrentRow(selectedRow + 1) - def onAddButtonClicked(self): + def on_add_button_clicked(self): + """ + Add a new blank slide. + """ self.editSlideForm.setText(u'') if self.editSlideForm.exec_(): self.slideListView.addItems(self.editSlideForm.getText()) - def onEditButtonClicked(self): + def on_edit_button_clicked(self): + """ + Edit the currently selected slide. + """ self.editSlideForm.setText(self.slideListView.currentItem().text()) if self.editSlideForm.exec_(): self.updateSlideList(self.editSlideForm.getText()) - def onEditAllButtonClicked(self): + def on_edit_all_button_clicked(self): """ Edits all slides. """ @@ -163,7 +185,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): if self.editSlideForm.exec_(): self.updateSlideList(self.editSlideForm.getText(), True) - def onPreviewButtonClicked(self): + def on_preview_button_clicked(self): """ Save the custom item and preview it. """ @@ -203,9 +225,9 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): Removes the current row from the list. """ self.slideListView.takeItem(self.slideListView.currentRow()) - self.onCurrentRowChanged(self.slideListView.currentRow()) + self.on_current_row_changed(self.slideListView.currentRow()) - def onCurrentRowChanged(self, row): + def on_current_row_changed(self, row): """ Called when the *slideListView*'s current row has been changed. This enables or disables buttons which require an slide to act on. diff --git a/openlp/plugins/custom/forms/editcustomslideform.py b/openlp/plugins/custom/forms/editcustomslideform.py index fce51c4e3..755237345 100644 --- a/openlp/plugins/custom/forms/editcustomslideform.py +++ b/openlp/plugins/custom/forms/editcustomslideform.py @@ -1,3 +1,4 @@ +#lint:disable # -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 @@ -35,16 +36,18 @@ from editcustomslidedialog import Ui_CustomSlideEditDialog log = logging.getLogger(__name__) + class EditCustomSlideForm(QtGui.QDialog, Ui_CustomSlideEditDialog): """ Class documentation goes here. """ log.info(u'Custom Verse Editor loaded') + def __init__(self, parent=None): """ Constructor """ - QtGui.QDialog.__init__(self, parent) + super(EditCustomeEditCustomSlideForm, self).__init__(parent) self.setupUi(self) # Connecting signals and slots QtCore.QObject.connect(self.insertButton, QtCore.SIGNAL(u'clicked()'), self.onInsertButtonClicked) @@ -88,9 +91,10 @@ class EditCustomSlideForm(QtGui.QDialog, Ui_CustomSlideEditDialog): """ full_text = self.slideTextEdit.toPlainText() position = self.slideTextEdit.textCursor().position() - if position and full_text[position-1] != u'\n': - text = u'\n' + text - if position == len(full_text) or full_text[position] != u'\n': - text += u'\n' + if position and full_text[position - 1] != u'\n': + text = u'\n' + text + if position == len(full_text) or full_text[position] != u'\n': + text += u'\n' self.slideTextEdit.insertPlainText(text) +#lint:enable diff --git a/openlp/plugins/songs/forms/songbookform.py b/openlp/plugins/songs/forms/songbookform.py index 96e893a49..85b8e9011 100644 --- a/openlp/plugins/songs/forms/songbookform.py +++ b/openlp/plugins/songs/forms/songbookform.py @@ -33,6 +33,7 @@ from openlp.core.lib import translate from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.songs.forms.songbookdialog import Ui_SongBookDialog + class SongBookForm(QtGui.QDialog, Ui_SongBookDialog): """ Class documentation goes here. @@ -41,10 +42,16 @@ class SongBookForm(QtGui.QDialog, Ui_SongBookDialog): """ Constructor """ - QtGui.QDialog.__init__(self, parent) + super(SongBookForm, self).__init__(parent) self.setupUi(self) def exec_(self, clear=True): + """ + Execute the song book form. + + ``clear`` + Clear the fields on the form before displaying it. + """ if clear: self.nameEdit.clear() self.publisherEdit.clear() @@ -52,6 +59,9 @@ class SongBookForm(QtGui.QDialog, Ui_SongBookDialog): return QtGui.QDialog.exec_(self) def accept(self): + """ + Override the inherited method to check that the name of the book has been typed in. + """ if not self.nameEdit.text(): critical_error_message_box( message=translate('SongsPlugin.SongBookForm', 'You need to type in a name for the book.')) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index efadd6b61..0e014ba96 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -35,13 +35,14 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, Settings, SettingsManager, translate, UiStrings +from openlp.core.lib import Receiver, Settings, UiStrings, translate from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard, WizardStrings from openlp.plugins.songs.lib.importer import SongFormat, SongFormatSelect log = logging.getLogger(__name__) + class SongImportForm(OpenLPWizard): """ This is the Song Import Wizard, which allows easy importing of Songs @@ -211,17 +212,17 @@ class SongImportForm(OpenLPWizard): if self.currentPage() == self.welcomePage: return True elif self.currentPage() == self.sourcePage: - format = self.currentFormat - Settings().setValue(u'songs/last import type', format) - select_mode, class_, error_msg = SongFormat.get(format, u'selectMode', u'class', u'invalidSourceMsg') + this_format = self.currentFormat + Settings().setValue(u'songs/last import type', this_format) + select_mode, class_, error_msg = SongFormat.get(this_format, u'selectMode', u'class', u'invalidSourceMsg') if select_mode == SongFormatSelect.MultipleFiles: - import_source = self.getListOfFiles(self.formatWidgets[format][u'fileListWidget']) + import_source = self.getListOfFiles(self.formatWidgets[this_format][u'fileListWidget']) error_title = UiStrings().IFSp - focus_button = self.formatWidgets[format][u'addButton'] + focus_button = self.formatWidgets[this_format][u'addButton'] else: - import_source = self.formatWidgets[format][u'filepathEdit'].text() + import_source = self.formatWidgets[this_format][u'filepathEdit'].text() error_title = (UiStrings().IFSs if select_mode == SongFormatSelect.SingleFile else UiStrings().IFdSs) - focus_button = self.formatWidgets[format][u'browseButton'] + focus_button = self.formatWidgets[this_format][u'browseButton'] if not class_.isValidSource(import_source): critical_error_message_box(error_title, error_msg) focus_button.setFocus() @@ -271,25 +272,35 @@ class SongImportForm(OpenLPWizard): del item def onBrowseButtonClicked(self): - format = self.currentFormat - select_mode, format_name, filter = SongFormat.get(format, u'selectMode', + """ + Browse for files or a directory. + """ + this_format = self.currentFormat + select_mode, format_name, ext_filter = SongFormat.get(this_format, u'selectMode', u'name', u'filter') - filepathEdit = self.formatWidgets[format][u'filepathEdit'] + filepathEdit = self.formatWidgets[this_format][u'filepathEdit'] if select_mode == SongFormatSelect.SingleFile: - self.getFileName(WizardStrings.OpenTypeFile % format_name, filepathEdit, u'last directory import', filter) + self.getFileName(WizardStrings.OpenTypeFile % format_name, filepathEdit, + u'last directory import', ext_filter) elif select_mode == SongFormatSelect.SingleFolder: self.getFolder(WizardStrings.OpenTypeFolder % format_name, filepathEdit, u'last directory import') def onAddButtonClicked(self): - format = self.currentFormat - select_mode, format_name, filter, custom_title = \ - SongFormat.get(format, u'selectMode', u'name', u'filter', u'getFilesTitle') + """ + Add a file or directory. + """ + this_format = self.currentFormat + select_mode, format_name, ext_filter, custom_title = \ + SongFormat.get(this_format, u'selectMode', u'name', u'filter', u'getFilesTitle') title = custom_title if custom_title else WizardStrings.OpenTypeFile % format_name if select_mode == SongFormatSelect.MultipleFiles: - self.getFiles(title, self.formatWidgets[format][u'fileListWidget'], filter) + self.getFiles(title, self.formatWidgets[this_format][u'fileListWidget'], ext_filter) self.sourcePage.emit(QtCore.SIGNAL(u'completeChanged()')) def onRemoveButtonClicked(self): + """ + Remove a file from the list. + """ self.removeSelectedItems( self.formatWidgets[self.currentFormat][u'fileListWidget']) self.sourcePage.emit(QtCore.SIGNAL(u'completeChanged()')) @@ -340,10 +351,10 @@ class SongImportForm(OpenLPWizard): select_mode = SongFormat.get(source_format, u'selectMode') if select_mode == SongFormatSelect.SingleFile: importer = self.plugin.importSongs(source_format, - filename = self.formatWidgets[source_format][u'filepathEdit'].text()) + filename=self.formatWidgets[source_format][u'filepathEdit'].text()) elif select_mode == SongFormatSelect.SingleFolder: importer = self.plugin.importSongs(source_format, - folder = self.formatWidgets[source_format][u'filepathEdit'].text()) + folder=self.formatWidgets[source_format][u'filepathEdit'].text()) else: importer = self.plugin.importSongs(source_format, filenames=self.getListOfFiles(self.formatWidgets[source_format][u'fileListWidget'])) @@ -369,9 +380,12 @@ class SongImportForm(OpenLPWizard): report_file.close() def addFileSelectItem(self): - format = self.currentFormat + """ + Add a file selection page. + """ + this_format = self.currentFormat prefix, can_disable, description_text, select_mode = \ - SongFormat.get(format, u'prefix', u'canDisable', u'descriptionText', u'selectMode') + SongFormat.get(this_format, u'prefix', u'canDisable', u'descriptionText', u'selectMode') page = QtGui.QWidget() page.setObjectName(prefix + u'Page') if can_disable: @@ -392,8 +406,8 @@ class SongImportForm(OpenLPWizard): descriptionLabel.setObjectName(prefix + u'DescriptionLabel') descriptionLayout.addWidget(descriptionLabel) importLayout.addLayout(descriptionLayout) - self.formatWidgets[format][u'descriptionLabel'] = descriptionLabel - self.formatWidgets[format][u'descriptionSpacer'] = descriptionSpacer + self.formatWidgets[this_format][u'descriptionLabel'] = descriptionLabel + self.formatWidgets[this_format][u'descriptionSpacer'] = descriptionSpacer if select_mode == SongFormatSelect.SingleFile or select_mode == SongFormatSelect.SingleFolder: filepathLayout = QtGui.QHBoxLayout() filepathLayout.setObjectName(prefix + u'FilepathLayout') @@ -412,11 +426,11 @@ class SongImportForm(OpenLPWizard): filepathLayout.addWidget(browseButton) importLayout.addLayout(filepathLayout) importLayout.addSpacerItem(self.stackSpacer) - self.formatWidgets[format][u'filepathLabel'] = filepathLabel - self.formatWidgets[format][u'filepathSpacer'] = filepathSpacer - self.formatWidgets[format][u'filepathLayout'] = filepathLayout - self.formatWidgets[format][u'filepathEdit'] = filepathEdit - self.formatWidgets[format][u'browseButton'] = browseButton + self.formatWidgets[this_format][u'filepathLabel'] = filepathLabel + self.formatWidgets[this_format][u'filepathSpacer'] = filepathSpacer + self.formatWidgets[this_format][u'filepathLayout'] = filepathLayout + self.formatWidgets[this_format][u'filepathEdit'] = filepathEdit + self.formatWidgets[this_format][u'browseButton'] = browseButton elif select_mode == SongFormatSelect.MultipleFiles: fileListWidget = QtGui.QListWidget(importWidget) fileListWidget.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) @@ -434,18 +448,21 @@ class SongImportForm(OpenLPWizard): removeButton.setObjectName(prefix + u'RemoveButton') buttonLayout.addWidget(removeButton) importLayout.addLayout(buttonLayout) - self.formatWidgets[format][u'fileListWidget'] = fileListWidget - self.formatWidgets[format][u'buttonLayout'] = buttonLayout - self.formatWidgets[format][u'addButton'] = addButton - self.formatWidgets[format][u'removeButton'] = removeButton + self.formatWidgets[this_format][u'fileListWidget'] = fileListWidget + self.formatWidgets[this_format][u'buttonLayout'] = buttonLayout + self.formatWidgets[this_format][u'addButton'] = addButton + self.formatWidgets[this_format][u'removeButton'] = removeButton self.formatStack.addWidget(page) - self.formatWidgets[format][u'page'] = page - self.formatWidgets[format][u'importLayout'] = importLayout + self.formatWidgets[this_format][u'page'] = page + self.formatWidgets[this_format][u'importLayout'] = importLayout self.formatComboBox.addItem(u'') def disablableWidget(self, page, prefix): - format = self.currentFormat - self.disablableFormats.append(format) + """ + Disable a widget. + """ + this_format = self.currentFormat + self.disablableFormats.append(this_format) layout = QtGui.QVBoxLayout(page) layout.setMargin(0) layout.setSpacing(0) @@ -465,11 +482,11 @@ class SongImportForm(OpenLPWizard): importWidget = QtGui.QWidget(page) importWidget.setObjectName(prefix + u'ImportWidget') layout.addWidget(importWidget) - self.formatWidgets[format][u'layout'] = layout - self.formatWidgets[format][u'disabledWidget'] = disabledWidget - self.formatWidgets[format][u'disabledLayout'] = disabledLayout - self.formatWidgets[format][u'disabledLabel'] = disabledLabel - self.formatWidgets[format][u'importWidget'] = importWidget + self.formatWidgets[this_format][u'layout'] = layout + self.formatWidgets[this_format][u'disabledWidget'] = disabledWidget + self.formatWidgets[this_format][u'disabledLayout'] = disabledLayout + self.formatWidgets[this_format][u'disabledLabel'] = disabledLabel + self.formatWidgets[this_format][u'importWidget'] = importWidget return importWidget @@ -489,14 +506,14 @@ class SongImportSourcePage(QtGui.QWizardPage): When this method returns True, the wizard's Next button is enabled. """ wizard = self.wizard() - format = wizard.currentFormat - select_mode, format_available = SongFormat.get(format, u'selectMode', u'availability') + this_format = wizard.currentFormat + select_mode, format_available = SongFormat.get(this_format, u'selectMode', u'availability') if format_available: if select_mode == SongFormatSelect.MultipleFiles: - if wizard.formatWidgets[format][u'fileListWidget'].count() > 0: + if wizard.formatWidgets[this_format][u'fileListWidget'].count() > 0: return True else: - filepath = unicode(wizard.formatWidgets[format][u'filepathEdit'].text()) + filepath = unicode(wizard.formatWidgets[this_format][u'filepathEdit'].text()) if filepath: if select_mode == SongFormatSelect.SingleFile and os.path.isfile(filepath): return True diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 474e68040..0c823571b 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -39,6 +39,7 @@ from songmaintenancedialog import Ui_SongMaintenanceDialog log = logging.getLogger(__name__) + class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): """ Class documentation goes here. @@ -47,7 +48,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): """ Constructor """ - QtGui.QDialog.__init__(self, parent) + super(SongMaintenanceForm, self).__init__(parent) self.setupUi(self) self.manager = manager self.authorform = AuthorsForm(self) @@ -93,8 +94,14 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): self.typeListWidget.setFocus() return QtGui.QDialog.exec_(self) - def _getCurrentItemId(self, listWidget): - item = listWidget.currentItem() + def _getCurrentItemId(self, list_widget): + """ + Get the ID of the currently selected item. + + ``list_widget`` + The list widget to examine. + """ + item = list_widget.currentItem() if item: item_id = (item.data(QtCore.Qt.UserRole)) return item_id @@ -102,6 +109,9 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): return -1 def _deleteItem(self, itemClass, listWidget, resetFunc, dlgTitle, del_text, err_text): + """ + Delete an item. + """ item_id = self._getCurrentItemId(listWidget) if item_id != -1: item = self.manager.get_object(itemClass, item_id) @@ -196,6 +206,9 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): return True def onAuthorAddButtonClicked(self): + """ + Add an author to the list. + """ self.authorform.setAutoDisplayName(True) if self.authorform.exec_(): author = Author.populate( @@ -213,6 +226,9 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): message=translate('SongsPlugin.SongMaintenanceForm', 'This author already exists.')) def onTopicAddButtonClicked(self): + """ + Add a topic to the list. + """ if self.topicform.exec_(): topic = Topic.populate(name=self.topicform.nameEdit.text()) if self.checkTopic(topic): @@ -226,6 +242,9 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): message=translate('SongsPlugin.SongMaintenanceForm', 'This topic already exists.')) def onBookAddButtonClicked(self): + """ + Add a book to the list. + """ if self.bookform.exec_(): book = Book.populate(name=self.bookform.nameEdit.text(), publisher=self.bookform.publisherEdit.text()) @@ -240,6 +259,9 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): message=translate('SongsPlugin.SongMaintenanceForm', 'This book already exists.')) def onAuthorEditButtonClicked(self): + """ + Edit an author. + """ author_id = self._getCurrentItemId(self.authorsListWidget) if author_id == -1: return @@ -283,6 +305,9 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): 'Could not save your modified author, because the author already exists.')) def onTopicEditButtonClicked(self): + """ + Edit a topic. + """ topic_id = self._getCurrentItemId(self.topicsListWidget) if topic_id == -1: return @@ -311,6 +336,9 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): 'Could not save your modified topic, because it already exists.')) def onBookEditButtonClicked(self): + """ + Edit a book. + """ book_id = self._getCurrentItemId(self.booksListWidget) if book_id == -1: return diff --git a/openlp/plugins/songs/forms/topicsform.py b/openlp/plugins/songs/forms/topicsform.py index 1fefc5204..70e86efe4 100644 --- a/openlp/plugins/songs/forms/topicsform.py +++ b/openlp/plugins/songs/forms/topicsform.py @@ -33,6 +33,7 @@ from openlp.core.lib import translate from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.songs.forms.topicsdialog import Ui_TopicsDialog + class TopicsForm(QtGui.QDialog, Ui_TopicsDialog): """ Class documentation goes here. @@ -41,16 +42,22 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog): """ Constructor """ - QtGui.QDialog.__init__(self, parent) + super(TopicsForm, self).__init__(parent) self.setupUi(self) def exec_(self, clear=True): + """ + Execute the dialog. + """ if clear: self.nameEdit.clear() self.nameEdit.setFocus() return QtGui.QDialog.exec_(self) def accept(self): + """ + Override the inherited method to check before we close. + """ if not self.nameEdit.text(): critical_error_message_box(message=translate('SongsPlugin.TopicsForm', 'You need to type in a topic name.')) From 18034a2f6a6cf0d85c9c35048ec216657970a315 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 1 Feb 2013 21:58:18 +0200 Subject: [PATCH 24/64] Linting cleanups. --- openlp/__init__.py | 1 - openlp/core/__init__.py | 15 ++++++- openlp/core/lib/db.py | 13 +++--- openlp/core/lib/dockwidget.py | 1 + openlp/core/lib/eventreceiver.py | 1 + openlp/core/lib/formattingtags.py | 1 + openlp/core/lib/htmlbuilder.py | 8 ++++ openlp/core/lib/imagemanager.py | 10 +++++ openlp/core/lib/listwidgetwithdnd.py | 12 +++-- openlp/core/lib/mediamanageritem.py | 38 ++++++++++++---- openlp/core/lib/plugin.py | 3 +- openlp/core/lib/pluginmanager.py | 1 + openlp/core/lib/registry.py | 10 +++-- openlp/core/lib/renderer.py | 4 +- openlp/core/lib/screen.py | 4 +- openlp/core/lib/searchedit.py | 1 + openlp/core/lib/serviceitem.py | 3 +- openlp/core/lib/settings.py | 8 ++-- openlp/core/lib/settingsmanager.py | 3 -- openlp/core/lib/settingstab.py | 5 +++ openlp/core/lib/spelltextedit.py | 14 ++++++ openlp/core/lib/theme.py | 25 +++++++---- openlp/core/lib/toolbar.py | 2 +- openlp/core/lib/uistrings.py | 5 +-- openlp/core/theme/__init__.py | 2 + openlp/core/theme/theme.py | 31 +++++++++---- openlp/core/ui/__init__.py | 9 ++-- openlp/core/ui/aboutdialog.py | 20 ++++++--- openlp/core/ui/aboutform.py | 4 ++ openlp/core/ui/advancedtab.py | 66 +++++++++++++++++++++++----- openlp/core/ui/exceptiondialog.py | 15 ++++++- openlp/core/ui/exceptionform.py | 23 +++++++++- openlp/core/ui/filerenamedialog.py | 14 +++++- 33 files changed, 291 insertions(+), 81 deletions(-) diff --git a/openlp/__init__.py b/openlp/__init__.py index d4e14122b..606d4ef9d 100644 --- a/openlp/__init__.py +++ b/openlp/__init__.py @@ -34,4 +34,3 @@ import core import plugins __all__ = [u'core', u'plugins'] - diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 04badb454..763cd17f2 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -172,6 +172,19 @@ class OpenLP(QtGui.QApplication): return False def hookException(self, exctype, value, traceback): + """ + Add an exception hook so that any uncaught exceptions are displayed in this window rather than somewhere where + users cannot see it and cannot report when we encounter these problems. + + ``exctype`` + The class of exception. + + ``value`` + The actual exception object. + + ``traceback`` + A traceback object with the details of where the exception occurred. + """ if not hasattr(self, u'mainWindow'): log.exception(''.join(format_exception(exctype, value, traceback))) return @@ -283,7 +296,7 @@ def main(args=None): else: app.setApplicationName(u'OpenLP') set_up_logging(AppLocation.get_directory(AppLocation.CacheDir)) - registry = Registry.create() + Registry.create() app.setApplicationVersion(get_application_version()[u'version']) # Instance check if not options.testing: diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index 1e696a107..f14e25297 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -45,6 +45,7 @@ from openlp.core.utils import AppLocation, delete_file log = logging.getLogger(__name__) + def init_db(url, auto_flush=True, auto_commit=False): """ Initialise and return the session and metadata for a database @@ -109,7 +110,7 @@ def upgrade_db(url, upgrade): while hasattr(upgrade, u'upgrade_%d' % version): log.debug(u'Running upgrade_%d', version) try: - getattr(upgrade, u'upgrade_%d' % version) (session, metadata, tables) + getattr(upgrade, u'upgrade_%d' % version)(session, metadata, tables) except (SQLAlchemyError, DBAPIError): log.exception(u'Could not run database upgrade script ' '"upgrade_%s", upgrade process has been halted.', version) @@ -156,6 +157,7 @@ class BaseModel(object): instance.__setattr__(key, value) return instance + class Manager(object): """ Provide generic object persistence management @@ -205,12 +207,9 @@ class Manager(object): if db_ver > up_ver: critical_error_message_box( translate('OpenLP.Manager', 'Database Error'), - translate('OpenLP.Manager', 'The database being ' - 'loaded was created in a more recent version of ' - 'OpenLP. The database is version %d, while OpenLP ' - 'expects version %d. The database will not be loaded.' - '\n\nDatabase: %s') % \ - (db_ver, up_ver, self.db_url) + translate('OpenLP.Manager', 'The database being loaded was created in a more recent version of ' + 'OpenLP. The database is version %d, while OpenLP expects version %d. The database will not ' + 'be loaded.\n\nDatabase: %s') % (db_ver, up_ver, self.db_url) ) return try: diff --git a/openlp/core/lib/dockwidget.py b/openlp/core/lib/dockwidget.py index 1a19a538b..743607dd6 100644 --- a/openlp/core/lib/dockwidget.py +++ b/openlp/core/lib/dockwidget.py @@ -39,6 +39,7 @@ from openlp.core.lib import build_icon, ScreenList log = logging.getLogger(__name__) + class OpenLPDockWidget(QtGui.QDockWidget): """ Custom DockWidget class to handle events diff --git a/openlp/core/lib/eventreceiver.py b/openlp/core/lib/eventreceiver.py index d29652c35..285e92bc9 100644 --- a/openlp/core/lib/eventreceiver.py +++ b/openlp/core/lib/eventreceiver.py @@ -35,6 +35,7 @@ from PyQt4 import QtCore log = logging.getLogger(__name__) + class EventReceiver(QtCore.QObject): """ Class to allow events to be passed from different parts of the system. This diff --git a/openlp/core/lib/formattingtags.py b/openlp/core/lib/formattingtags.py index df24775c8..abbc18f16 100644 --- a/openlp/core/lib/formattingtags.py +++ b/openlp/core/lib/formattingtags.py @@ -33,6 +33,7 @@ import cPickle from openlp.core.lib import translate, Settings + class FormattingTags(object): """ Static Class to HTML Tags to be access around the code the list is managed diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index 3f2b4dfad..a6e8f373e 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -207,6 +207,7 @@ sup { """ + def build_html(item, screen, islive, background, image=None, plugins=None): """ @@ -264,6 +265,7 @@ def build_html(item, screen, islive, background, image=None, build_lyrics_html(item, webkitvers)) return html + def webkit_version(): """ Return the Webkit version in use. @@ -276,6 +278,7 @@ def webkit_version(): webkitvers = 0 return webkitvers + def build_background_css(item, width, height): """ Build the background css @@ -310,6 +313,7 @@ def build_background_css(item, width, height): % (width, width, width, theme.background_start_color, theme.background_end_color) return background + def build_lyrics_css(item, webkitvers): """ Build the lyrics display css @@ -384,6 +388,7 @@ def build_lyrics_css(item, webkitvers): lyrics_css = style % (lyricstable, lyrics, lyricsmain, outline, shadow) return lyrics_css + def build_lyrics_outline_css(theme, is_shadow=False): """ Build the css which controls the theme outline @@ -407,6 +412,7 @@ def build_lyrics_outline_css(theme, is_shadow=False): else: return u'' + def build_lyrics_format_css(theme, width, height): """ Build the css which controls the theme format @@ -451,6 +457,7 @@ def build_lyrics_format_css(theme, width, height): lyrics += u' font-weight:bold; ' return lyrics + def build_lyrics_html(item, webkitvers): """ Build the HTML required to show the lyrics @@ -480,6 +487,7 @@ def build_lyrics_html(item, webkitvers): u'class="lyricscell lyricsmain">' return lyrics + def build_footer_css(item, height): """ Build the display of the item footer diff --git a/openlp/core/lib/imagemanager.py b/openlp/core/lib/imagemanager.py index 72389066b..392737972 100644 --- a/openlp/core/lib/imagemanager.py +++ b/openlp/core/lib/imagemanager.py @@ -43,12 +43,19 @@ from openlp.core.lib import resize_image, image_to_byte, Receiver, Registry, Scr log = logging.getLogger(__name__) + class ImageThread(QtCore.QThread): """ A special Qt thread class to speed up the display of images. This is threaded so it loads the frames and generates byte stream in background. """ def __init__(self, manager): + """ + Constructor for the thread class. + + ``manager`` + The image manager. + """ QtCore.QThread.__init__(self, None) self.imageManager = manager @@ -181,6 +188,9 @@ class ImageManager(QtCore.QObject): log.info(u'Image Manager loaded') def __init__(self): + """ + Consutructor for the image manager. + """ QtCore.QObject.__init__(self) Registry().register(u'image_manager', self) currentScreen = ScreenList().current diff --git a/openlp/core/lib/listwidgetwithdnd.py b/openlp/core/lib/listwidgetwithdnd.py index ca6e10525..daff870ee 100644 --- a/openlp/core/lib/listwidgetwithdnd.py +++ b/openlp/core/lib/listwidgetwithdnd.py @@ -35,6 +35,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import Receiver + class ListWidgetWithDnD(QtGui.QListWidget): """ Provide a list widget to store objects and handle drag and drop events @@ -58,9 +59,8 @@ class ListWidgetWithDnD(QtGui.QListWidget): def mouseMoveEvent(self, event): """ - Drag and drop event does not care what data is selected - as the recipient will use events to request the data move - just tell it what plugin to call + Drag and drop event does not care what data is selected as the recipient will use events to request the data + move just tell it what plugin to call """ if event.buttons() != QtCore.Qt.LeftButton: event.ignore() @@ -75,12 +75,18 @@ class ListWidgetWithDnD(QtGui.QListWidget): drag.start(QtCore.Qt.CopyAction) def dragEnterEvent(self, event): + """ + When something is dragged into this object, check if you should be able to drop it in here. + """ if event.mimeData().hasUrls(): event.accept() else: event.ignore() def dragMoveEvent(self, event): + """ + Make an object droppable, and set it to copy the contents of the object, not move it. + """ if event.mimeData().hasUrls(): event.setDropAction(QtCore.Qt.CopyAction) event.accept() diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 33c0eb1d1..bd384d75d 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -35,14 +35,14 @@ import re from PyQt4 import QtCore, QtGui -from openlp.core.lib import OpenLPToolbar, ServiceItem, StringContent, build_icon, translate, Receiver, \ - ListWidgetWithDnD, ServiceItemContext, Settings, Registry, UiStrings +from openlp.core.lib import OpenLPToolbar, ServiceItem, StringContent, Receiver, ListWidgetWithDnD, \ + ServiceItemContext, Settings, Registry, UiStrings, build_icon, translate from openlp.core.lib.searchedit import SearchEdit from openlp.core.lib.ui import create_widget_action, critical_error_message_box - log = logging.getLogger(__name__) + class MediaManagerItem(QtGui.QWidget): """ MediaManagerItem is a helper widget for plugins. @@ -345,15 +345,15 @@ class MediaManagerItem(QtGui.QWidget): """ new_files = [] error_shown = False - for file in files: - type = file.split(u'.')[-1] - if type.lower() not in self.onNewFileMasks: + for file_name in files: + file_type = file_name.split(u'.')[-1] + if file_type.lower() not in self.onNewFileMasks: if not error_shown: critical_error_message_box(translate('OpenLP.MediaManagerItem', 'Invalid File Type'), - translate('OpenLP.MediaManagerItem', 'Invalid File %s.\nSuffix not supported') % file) + translate('OpenLP.MediaManagerItem', 'Invalid File %s.\nSuffix not supported') % file_name) error_shown = True else: - new_files.append(file) + new_files.append(file_name) if new_files: self.validateAndLoad(new_files) @@ -390,6 +390,9 @@ class MediaManagerItem(QtGui.QWidget): translate('OpenLP.MediaManagerItem', 'Duplicate files were found on import and were ignored.')) def contextMenu(self, point): + """ + Display a context menu + """ item = self.listView.itemAt(point) # Decide if we have to show the context menu or not. if item is None: @@ -412,6 +415,9 @@ class MediaManagerItem(QtGui.QWidget): return file_list def loadList(self, list): + """ + Load a list. Needs to be implemented by the plugin. + """ raise NotImplementedError(u'MediaManagerItem.loadList needs to be defined by the plugin') def onNewClick(self): @@ -427,6 +433,9 @@ class MediaManagerItem(QtGui.QWidget): pass def onDeleteClick(self): + """ + Delete an item. Needs to be implemented by the plugin. + """ raise NotImplementedError(u'MediaManagerItem.onDeleteClick needs to be defined by the plugin') def onFocus(self): @@ -438,6 +447,9 @@ class MediaManagerItem(QtGui.QWidget): def generateSlideData(self, serviceItem, item=None, xmlVersion=False, remote=False, context=ServiceItemContext.Live): + """ + Generate the slide data. Needs to be implemented by the plugin. + """ raise NotImplementedError(u'MediaManagerItem.generateSlideData needs to be defined by the plugin') def onDoubleClicked(self): @@ -486,6 +498,9 @@ class MediaManagerItem(QtGui.QWidget): self.goLive() def goLive(self, item_id=None, remote=False): + """ + Make the currently selected item go live. + """ log.debug(u'%s Live requested', self.plugin.name) item = None if item_id: @@ -499,6 +514,9 @@ class MediaManagerItem(QtGui.QWidget): self.live_controller.add_service_item(serviceItem) def createItemFromId(self, item_id): + """ + Create a media item from an item id. + """ item = QtGui.QListWidgetItem() item.setData(QtCore.Qt.UserRole, item_id) return item @@ -522,6 +540,9 @@ class MediaManagerItem(QtGui.QWidget): self.addToService(item) def addToService(self, item=None, replace=None, remote=False): + """ + Add this item to the current service. + """ serviceItem = self.buildServiceItem(item, True, remote=remote, context=ServiceItemContext.Service) if serviceItem: serviceItem.from_plugin = False @@ -687,4 +708,3 @@ class MediaManagerItem(QtGui.QWidget): return self._service_manager service_manager = property(_get_service_manager) - diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 49a08e32a..1d80435d9 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -38,6 +38,7 @@ from openlp.core.utils import get_application_version log = logging.getLogger(__name__) + class PluginStatus(object): """ Defines the status of the plugin @@ -320,7 +321,6 @@ class Plugin(QtCore.QObject): Settings().setValue(u'%s/%s files' % (self.settingsSection, self.name), loaded_list) settings.endGroup() - def usesTheme(self, theme): """ Called to find out if a plugin is currently using a theme. @@ -418,4 +418,3 @@ class Plugin(QtCore.QObject): return self._main_window main_window = property(_get_main_window) - diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index ae1d9f984..fbc422992 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -37,6 +37,7 @@ from openlp.core.lib import Plugin, PluginStatus, Registry log = logging.getLogger(__name__) + class PluginManager(object): """ This is the Plugin manager, which loads all the plugins, diff --git a/openlp/core/lib/registry.py b/openlp/core/lib/registry.py index 3a42a14c5..511067a80 100644 --- a/openlp/core/lib/registry.py +++ b/openlp/core/lib/registry.py @@ -34,6 +34,7 @@ import sys log = logging.getLogger(__name__) + class Registry(object): """ This is the Component Registry. It is a singleton object and is used to provide a @@ -43,6 +44,9 @@ class Registry(object): __instance__ = None def __new__(cls): + """ + Re-implement the __new__ method to make sure we create a true singleton. + """ if not cls.__instance__: cls.__instance__ = object.__new__(cls) return cls.__instance__ @@ -61,7 +65,6 @@ class Registry(object): registry.running_under_test = True return registry - def get(self, key): """ Extracts the registry value from the list based on the key passed in @@ -87,10 +90,9 @@ class Registry(object): Removes the registry value from the list based on the key passed in (Only valid and active for testing framework) """ - if self.running_under_test == False: + if self.running_under_test is False: log.error(u'Invalid Method call for key %s' % key) raise KeyError(u'Invalid Method call for key %s' % key) return if key in self.service_list: - del self.service_list[key] - + del self.service_list[key] diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 8e6d9d8ad..b67ae36f6 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -315,7 +315,7 @@ class Renderer(object): if text_contains_split: text = slides[-1] + u'\n[---]\n' + text else: - text = slides[-1] + u'\n'+ text + text = slides[-1] + u'\n' + text text = text.replace(u'
', u'\n') else: pages.extend(slides) @@ -543,7 +543,7 @@ class Renderer(object): end_tags.reverse() # Remove the indexes. html_tags = [tag[1] for tag in html_tags] - return raw_text + u''.join(end_tags), u''.join(start_tags), u''.join(html_tags) + return raw_text + u''.join(end_tags), u''.join(start_tags), u''.join(html_tags) def _binary_chop(self, formatted, previous_html, previous_raw, html_list, raw_list, separator, line_end): """ diff --git a/openlp/core/lib/screen.py b/openlp/core/lib/screen.py index 4c9032c97..9c118de99 100644 --- a/openlp/core/lib/screen.py +++ b/openlp/core/lib/screen.py @@ -37,7 +37,6 @@ from PyQt4 import QtCore from openlp.core.lib import Receiver, translate - log = logging.getLogger(__name__) @@ -51,6 +50,9 @@ class ScreenList(object): __instance__ = None def __new__(cls): + """ + Re-implement __new__ to create a true singleton. + """ if not cls.__instance__: cls.__instance__ = object.__new__(cls) return cls.__instance__ diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index b3e76ed7c..f9383792a 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -36,6 +36,7 @@ from openlp.core.lib.ui import create_widget_action log = logging.getLogger(__name__) + class SearchEdit(QtGui.QLineEdit): """ This is a specialised QLineEdit with a "clear" button inside for searches. diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index b6f225cd9..c97923b0a 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -43,6 +43,7 @@ from openlp.core.lib import build_icon, clean_tags, expand_tags, translate, Imag log = logging.getLogger(__name__) + class ServiceItemType(object): """ Defines the type of service item @@ -607,7 +608,7 @@ class ServiceItem(object): ``theme`` The new theme to be replaced in the service item """ - self.theme_overwritten = (theme == None) + self.theme_overwritten = (theme is None) self.theme = theme self._new_item() self.render() diff --git a/openlp/core/lib/settings.py b/openlp/core/lib/settings.py index 0591871cc..9e5053cb8 100644 --- a/openlp/core/lib/settings.py +++ b/openlp/core/lib/settings.py @@ -127,8 +127,8 @@ class Settings(QtCore.QSettings): u'general/enable slide loop': True, u'general/show splash': True, u'general/screen blank': False, - # The oder display settings (display position and dimensions) are defined in the ScreenList class due to crycle - # dependency. + # The other display settings (display position and dimensions) are defined in the ScreenList class due to a + # circular dependency. u'general/override position': False, u'general/loop delay': 5, u'general/songselect username': u'', @@ -276,6 +276,9 @@ class Settings(QtCore.QSettings): Settings.__default_settings__[u'advanced/default service name'] = UiStrings().DefaultServiceName def __init__(self, *args): + """ + Constructor which checks if this should be a native settings object, or an INI file. + """ if not args and Settings.__file_path__ and Settings.defaultFormat() == Settings.IniFormat: QtCore.QSettings.__init__(self, Settings.__file_path__, Settings.IniFormat) else: @@ -340,4 +343,3 @@ class Settings(QtCore.QSettings): if isinstance(default_value, int): return int(setting) return setting - diff --git a/openlp/core/lib/settingsmanager.py b/openlp/core/lib/settingsmanager.py index 8491fe4f1..00bdda350 100644 --- a/openlp/core/lib/settingsmanager.py +++ b/openlp/core/lib/settingsmanager.py @@ -33,9 +33,6 @@ format. """ import os -from PyQt4 import QtCore - -from openlp.core.lib import Settings from openlp.core.utils import AppLocation diff --git a/openlp/core/lib/settingstab.py b/openlp/core/lib/settingstab.py index 0af524877..14a173a19 100644 --- a/openlp/core/lib/settingstab.py +++ b/openlp/core/lib/settingstab.py @@ -26,9 +26,14 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +""" +The :mod:`~openlp.core.lib.settingstab` module contains the base SettingsTab class which plugins use for adding their +own tab to the settings dialog. +""" from PyQt4 import QtGui + class SettingsTab(QtGui.QWidget): """ SettingsTab is a helper widget for plugins to define Tabs for the settings diff --git a/openlp/core/lib/spelltextedit.py b/openlp/core/lib/spelltextedit.py index 4b64f2a3e..34b51ab11 100644 --- a/openlp/core/lib/spelltextedit.py +++ b/openlp/core/lib/spelltextedit.py @@ -26,6 +26,10 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +""" +The :mod:`~openlp.core.lib.spelltextedit` module contains a classes to add spell checking to an edit widget. +""" + import logging import re @@ -47,11 +51,15 @@ from openlp.core.lib.ui import create_action log = logging.getLogger(__name__) + class SpellTextEdit(QtGui.QPlainTextEdit): """ Spell checking widget based on QPlanTextEdit. """ def __init__(self, parent=None, formattingTagsAllowed=True): + """ + Constructor. + """ global ENCHANT_AVAILABLE QtGui.QPlainTextEdit.__init__(self, parent) self.formattingTagsAllowed = formattingTagsAllowed @@ -171,6 +179,9 @@ class Highlighter(QtGui.QSyntaxHighlighter): WORDS = u'(?iu)[\w\']+' def __init__(self, *args): + """ + Constructor + """ QtGui.QSyntaxHighlighter.__init__(self, *args) self.spellingDictionary = None @@ -197,5 +208,8 @@ class SpellAction(QtGui.QAction): correct = QtCore.pyqtSignal(unicode) def __init__(self, *args): + """ + Constructor + """ QtGui.QAction.__init__(self, *args) self.triggered.connect(lambda x: self.correct.emit(self.text())) diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index 8a85c0d86..9e629e214 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -86,6 +86,7 @@ BLANK_THEME_XML = \ ''' + class ThemeLevel(object): """ Provides an enumeration for the level a theme applies to @@ -213,6 +214,7 @@ class ThemeXML(object): """ FIRST_CAMEL_REGEX = re.compile(u'(.)([A-Z][a-z]+)') SECOND_CAMEL_REGEX = re.compile(u'([a-z0-9])([A-Z])') + def __init__(self): """ Initialise the theme object. @@ -608,13 +610,15 @@ class ThemeXML(object): self.add_background_gradient( self.background_start_color, self.background_end_color, - self.background_direction) + self.background_direction + ) elif self.background_type == BackgroundType.to_string(BackgroundType.Image): filename = os.path.split(self.background_filename)[1] self.add_background_image(filename, self.background_border_color) elif self.background_type == BackgroundType.to_string(BackgroundType.Transparent): self.add_background_transparent() - self.add_font(self.font_main_name, + self.add_font( + self.font_main_name, self.font_main_color, self.font_main_size, self.font_main_override, u'main', @@ -630,14 +634,16 @@ class ThemeXML(object): self.font_main_outline_size, self.font_main_shadow, self.font_main_shadow_color, - self.font_main_shadow_size) - self.add_font(self.font_footer_name, + self.font_main_shadow_size + ) + self.add_font( + self.font_footer_name, self.font_footer_color, self.font_footer_size, self.font_footer_override, u'footer', self.font_footer_bold, self.font_footer_italics, - 0, # line adjustment + 0, # line adjustment self.font_footer_x, self.font_footer_y, self.font_footer_width, @@ -647,7 +653,10 @@ class ThemeXML(object): self.font_footer_outline_size, self.font_footer_shadow, self.font_footer_shadow_color, - self.font_footer_shadow_size) - self.add_display(self.display_horizontal_align, + self.font_footer_shadow_size + ) + self.add_display( + self.display_horizontal_align, self.display_vertical_align, - self.display_slide_transition) + self.display_slide_transition + ) diff --git a/openlp/core/lib/toolbar.py b/openlp/core/lib/toolbar.py index cb5db304d..e36d404cc 100644 --- a/openlp/core/lib/toolbar.py +++ b/openlp/core/lib/toolbar.py @@ -37,6 +37,7 @@ from openlp.core.lib.ui import create_widget_action log = logging.getLogger(__name__) + class OpenLPToolbar(QtGui.QToolBar): """ Lots of toolbars around the place, so it makes sense to have a common way @@ -85,4 +86,3 @@ class OpenLPToolbar(QtGui.QToolBar): self.actions[handle].setVisible(visible) else: log.warn(u'No handle "%s" in actions list.', unicode(handle)) - diff --git a/openlp/core/lib/uistrings.py b/openlp/core/lib/uistrings.py index f89b52a98..d1c8b3818 100644 --- a/openlp/core/lib/uistrings.py +++ b/openlp/core/lib/uistrings.py @@ -111,8 +111,8 @@ class UiStrings(object): self.OLPV2x = translate('OpenLP.Ui', 'OpenLP 2.1') self.OpenLPStart = translate('OpenLP.Ui', 'OpenLP is already running. Do you wish to continue?') self.OpenService = translate('OpenLP.Ui', 'Open service.') - self.PlaySlidesInLoop = translate('OpenLP.Ui','Play Slides in Loop') - self.PlaySlidesToEnd = translate('OpenLP.Ui','Play Slides to End') + self.PlaySlidesInLoop = translate('OpenLP.Ui', 'Play Slides in Loop') + self.PlaySlidesToEnd = translate('OpenLP.Ui', 'Play Slides to End') self.Preview = translate('OpenLP.Ui', 'Preview') self.PrintService = translate('OpenLP.Ui', 'Print Service') self.ReplaceBG = translate('OpenLP.Ui', 'Replace Background') @@ -144,4 +144,3 @@ class UiStrings(object): self.Version = translate('OpenLP.Ui', 'Version') self.View = translate('OpenLP.Ui', 'View') self.ViewMode = translate('OpenLP.Ui', 'View Mode') - diff --git a/openlp/core/theme/__init__.py b/openlp/core/theme/__init__.py index 4d1997b82..4db399fa7 100644 --- a/openlp/core/theme/__init__.py +++ b/openlp/core/theme/__init__.py @@ -32,3 +32,5 @@ OpenLP when displaying a song or a scripture. """ from openlp.core.theme.theme import Theme + +__all__ = ['Theme'] diff --git a/openlp/core/theme/theme.py b/openlp/core/theme/theme.py index 2425a3c78..9fe06d741 100644 --- a/openlp/core/theme/theme.py +++ b/openlp/core/theme/theme.py @@ -37,11 +37,21 @@ from xml.etree.ElementTree import ElementTree, XML from PyQt4 import QtGui DELPHI_COLORS = { - u'clAqua': 0x00FFFF, u'clBlack': 0x000000, u'clBlue': 0x0000FF, - u'clFuchsia': 0xFF00FF, u'clGray': 0x808080, u'clGreen': 0x008000, - u'clLime': 0x00FF00, u'clMaroon': 0x800000, u'clNavy': 0x000080, - u'clOlive': 0x808000, u'clPurple': 0x800080, u'clRed': 0xFF0000, - u'clSilver': 0xC0C0C0, u'clTeal': 0x008080, u'clWhite': 0xFFFFFF, + u'clAqua': 0x00FFFF, + u'clBlack': 0x000000, + u'clBlue': 0x0000FF, + u'clFuchsia': 0xFF00FF, + u'clGray': 0x808080, + u'clGreen': 0x008000, + u'clLime': 0x00FF00, + u'clMaroon': 0x800000, + u'clNavy': 0x000080, + u'clOlive': 0x808000, + u'clPurple': 0x800080, + u'clRed': 0xFF0000, + u'clSilver': 0xC0C0C0, + u'clTeal': 0x008080, + u'clWhite': 0xFFFFFF, u'clYellow': 0xFFFF00 } @@ -66,6 +76,7 @@ BLANK_STYLE_XML = \ ''' + class Theme(object): """ Provide a class wrapper storing data from an XML theme @@ -205,10 +216,12 @@ class Theme(object): val = element_text # strings need special handling to sort the colours out if isinstance(element_text, basestring): - if element_text[0] == u'$': # might be a hex number + if element_text[0] == u'$': + # might be a hex number try: val = int(element_text[1:], 16) - except ValueError: # nope + except ValueError: + # nope pass elif element_text in DELPHI_COLORS: val = DELPHI_COLORS[element_text] @@ -222,9 +235,9 @@ class Theme(object): isinstance(val, int))): # convert to a wx.Colour if not delphi_color_change: - val = QtGui.QColor(val&0xFF, (val>>8)&0xFF, (val>>16)&0xFF) + val = QtGui.QColor(val & 0xFF, (val >> 8) & 0xFF, (val >> 16) & 0xFF) else: - val = QtGui.QColor((val>>16)&0xFF, (val>>8)&0xFF, val&0xFF) + val = QtGui.QColor((val >> 16) & 0xFF, (val >> 8) & 0xFF, val & 0xFF) setattr(self, element.tag, val) def __str__(self): diff --git a/openlp/core/ui/__init__.py b/openlp/core/ui/__init__.py index a0065966b..49e59e4c1 100644 --- a/openlp/core/ui/__init__.py +++ b/openlp/core/ui/__init__.py @@ -31,7 +31,6 @@ The :mod:`ui` module provides the core user interface for OpenLP """ - class HideMode(object): """ This is an enumeration class which specifies the different modes of hiding the display. @@ -101,6 +100,8 @@ from mediadockmanager import MediaDockManager from servicemanager import ServiceManager from thememanager import ThemeManager -__all__ = ['SplashScreen', 'AboutForm', 'SettingsForm', 'MainDisplay', - 'SlideController', 'ServiceManager', 'ThemeManager', 'MediaDockManager', - 'ServiceItemEditForm', 'FirstTimeForm'] +__all__ = ['SplashScreen', 'AboutForm', 'SettingsForm', 'MainDisplay', 'SlideController', 'ServiceManager', + 'ThemeManager', 'MediaDockManager', 'ServiceItemEditForm', 'FirstTimeForm', 'FirstTimeLanguageForm', 'ThemeForm', + 'ThemeLayoutForm', 'FileRenameForm', 'StartTimeForm', 'MainDisplay', 'Display', 'ServiceNoteForm', + 'SlideController', 'DisplayController', 'GeneralTab', 'ThemesTab', 'AdvancedTab', 'PluginForm', + 'FormattingTagForm', 'ShortcutListForm'] diff --git a/openlp/core/ui/aboutdialog.py b/openlp/core/ui/aboutdialog.py index a07434b12..cf04f4927 100644 --- a/openlp/core/ui/aboutdialog.py +++ b/openlp/core/ui/aboutdialog.py @@ -34,7 +34,14 @@ from openlp.core.lib.ui import create_button, create_button_box class Ui_AboutDialog(object): + """ + The actual GUI widgets for the About form. + """ + def setupUi(self, aboutDialog): + """ + Set up the UI for the dialog. + """ aboutDialog.setObjectName(u'aboutDialog') aboutDialog.setWindowIcon(build_icon(u':/icon/openlp-logo-16x16.png')) self.aboutDialogLayout = QtGui.QVBoxLayout(aboutDialog) @@ -80,6 +87,9 @@ class Ui_AboutDialog(object): self.aboutNotebook.setCurrentIndex(0) def retranslateUi(self, aboutDialog): + """ + Dynamically translate the UI. + """ aboutDialog.setWindowTitle(u'%s OpenLP' % UiStrings().About) self.aboutTextEdit.setPlainText(translate('OpenLP.AboutForm', 'OpenLP - Open Source Lyrics ' @@ -134,17 +144,17 @@ class Ui_AboutDialog(object): u'en_ZA': [u'Raoul "superfly" Snyman', u'Johan "nuvolari" Mynhardt'], u'el': [u'Alexander Siozos'], - u'es': [u'Josu\xe9 Z\xfa\xf1iga',u'Christian Gonzalez'], + u'es': [u'Josu\xe9 Z\xfa\xf1iga', u'Christian Gonzalez'], u'et': [u'Mattias "mahfiaz" P\xf5ldaru'], u'fi': [u'Jori "joribu" Brander', u'Tobbe "tobbeb" Bildo'], u'fr': [u'Stephan\xe9 "stbrunner" Brunner', u'Jeremie "jnau05"', u'Carl "carl.fischer" Fischer'], u'hu': [u'Gyuris Gell\xe9rt'], - u'id': [u'Mico "bangmico" Siahaan' ,u' ign_christian'], + u'id': [u'Mico "bangmico" Siahaan', u' ign_christian'], u'ja': [u'Kunio "Kunio" Nakamaru', u'Chris Haris'], u'nb': [u'Atle "pendlaren" Weibell', u'Frode "frodus" Woldsund'], u'nl': [u'Arjen "typovar" van Voorst'], - u'pt_BR': [u'David Mederiros',u'Rafael "rafaellerm" Lerm', + u'pt_BR': [u'David Mederiros', u'Rafael "rafaellerm" Lerm', u'Eduardo Levi Chaves', u'Gustavo Bim', u'Rog\xeanio Bel\xe9m', u'Samuel' u'Simon "samscudder" Scudder', u'Van Der Fran'], @@ -260,7 +270,7 @@ class Ui_AboutDialog(object): u'\n '.join(documentors))) self.aboutNotebook.setTabText(self.aboutNotebook.indexOf(self.creditsTab), translate('OpenLP.AboutForm', 'Credits')) - copyright = translate('OpenLP.AboutForm', + copyright_note = translate('OpenLP.AboutForm', 'Copyright \xa9 2004-2013 %s\n' 'Portions copyright \xa9 2004-2013 %s') % (u'Raoul Snyman', u'Tim Bentley, Gerald Britton, Jonathan Corwin, Samuel Findlay, ' @@ -652,7 +662,7 @@ class Ui_AboutDialog(object): 'linking proprietary applications with the library. If this is ' 'what you want to do, use the GNU Lesser General Public License ' 'instead of this License.') - self.licenseTextEdit.setPlainText(u'%s\n\n%s\n\n%s\n\n\n%s' % (copyright, licence, disclaimer, gpltext)) + self.licenseTextEdit.setPlainText(u'%s\n\n%s\n\n%s\n\n\n%s' % (copyright_note, licence, disclaimer, gpltext)) self.aboutNotebook.setTabText(self.aboutNotebook.indexOf(self.licenseTab), translate('OpenLP.AboutForm', 'License')) self.volunteerButton.setText(translate('OpenLP.AboutForm', 'Volunteer')) diff --git a/openlp/core/ui/aboutform.py b/openlp/core/ui/aboutform.py index d62b7dd4e..f814cf8b6 100644 --- a/openlp/core/ui/aboutform.py +++ b/openlp/core/ui/aboutform.py @@ -26,6 +26,9 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +""" +The About dialog. +""" from PyQt4 import QtCore, QtGui @@ -33,6 +36,7 @@ from aboutdialog import Ui_AboutDialog from openlp.core.lib import translate from openlp.core.utils import get_application_version + class AboutForm(QtGui.QDialog, Ui_AboutDialog): """ The About dialog diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 3be6fbeb9..5455b1fb0 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -36,7 +36,7 @@ import sys from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, translate, build_icon, Receiver, Settings, UiStrings +from openlp.core.lib import SettingsTab, Receiver, Settings, UiStrings, translate, build_icon from openlp.core.utils import get_images_filter, AppLocation, format_time from openlp.core.lib import SlideLimits @@ -137,7 +137,7 @@ class AdvancedTab(SettingsTab): self.dataDirectoryLayout = QtGui.QFormLayout(self.dataDirectoryGroupBox) self.dataDirectoryLayout.setObjectName(u'dataDirectoryLayout') self.dataDirectoryCurrentLabel = QtGui.QLabel(self.dataDirectoryGroupBox) - self.dataDirectoryCurrentLabel.setObjectName( u'dataDirectoryCurrentLabel') + self.dataDirectoryCurrentLabel.setObjectName(u'dataDirectoryCurrentLabel') self.dataDirectoryLabel = QtGui.QLabel(self.dataDirectoryGroupBox) self.dataDirectoryLabel.setObjectName(u'dataDirectoryLabel') self.dataDirectoryNewLabel = QtGui.QLabel(self.dataDirectoryGroupBox) @@ -299,7 +299,8 @@ class AdvancedTab(SettingsTab): self.serviceNameLabel.setText(translate('OpenLP.AdvancedTab', 'Name:')) self.serviceNameEdit.setToolTip(translate('OpenLP.AdvancedTab', 'Consult the OpenLP manual for usage.')) self.serviceNameRevertButton.setToolTip( - translate('OpenLP.AdvancedTab', 'Revert to the default service name "%s".') % UiStrings().DefaultServiceName) + translate('OpenLP.AdvancedTab', 'Revert to the default service name "%s".') % + UiStrings().DefaultServiceName) self.serviceNameExampleLabel.setText(translate('OpenLP.AdvancedTab', 'Example:')) self.hideMouseGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Mouse Cursor')) self.hideMouseCheckBox.setText(translate('OpenLP.AdvancedTab', 'Hide mouse cursor when over display window')) @@ -324,7 +325,7 @@ class AdvancedTab(SettingsTab): translate('OpenLP.AdvancedTab', 'WARNING: New data directory location contains ' 'OpenLP data files. These files WILL be replaced during a copy.')) self.x11GroupBox.setTitle(translate('OpenLP.AdvancedTab', 'X11')) - self.x11BypassCheckBox.setText(translate('OpenLP.AdvancedTab','Bypass X11 Window Manager')) + self.x11BypassCheckBox.setText(translate('OpenLP.AdvancedTab', 'Bypass X11 Window Manager')) # Slide Limits self.slideGroupBox.setTitle(translate('OpenLP.GeneralTab', 'Service Item Slide Limits')) self.slideLabel.setText(translate('OpenLP.GeneralTab', 'Behavior of next/previous on the last/first slide:')) @@ -440,11 +441,16 @@ class AdvancedTab(SettingsTab): Receiver.send_message(u'slidecontroller_update_slide_limits') def cancel(self): - # Dialogue was cancelled, remove any pending data path change. + """ + Dialogue was cancelled, remove any pending data path change. + """ self.onDataDirectoryCancelButtonClicked() SettingsTab.cancel(self) def serviceNameCheckBoxToggled(self, default_service_enabled): + """ + Toggle the service name check box. + """ self.serviceNameDay.setEnabled(default_service_enabled) time_enabled = default_service_enabled and self.serviceNameDay.currentIndex() is not 7 self.serviceNameTime.setEnabled(time_enabled) @@ -452,6 +458,9 @@ class AdvancedTab(SettingsTab): self.serviceNameRevertButton.setEnabled(default_service_enabled) def generateServiceNameExample(self): + """ + Generate an example service name. + """ preset_is_valid = True if self.serviceNameDay.currentIndex() == 7: local_time = datetime.now() @@ -461,8 +470,10 @@ class AdvancedTab(SettingsTab): if day_delta < 0: day_delta += 7 time = now + timedelta(days=day_delta) - local_time = time.replace(hour = self.serviceNameTime.time().hour(), - minute = self.serviceNameTime.time().minute()) + local_time = time.replace( + hour=self.serviceNameTime.time().hour(), + minute=self.serviceNameTime.time().minute() + ) try: service_name_example = format_time(unicode(self.serviceNameEdit.text()), local_time) except ValueError: @@ -471,20 +482,32 @@ class AdvancedTab(SettingsTab): return preset_is_valid, service_name_example def updateServiceNameExample(self, returned_value): + """ + Update the example service name. + """ if not self.shouldUpdateServiceNameExample: return name_example = self.generateServiceNameExample()[1] self.serviceNameExample.setText(name_example) def onServiceNameDayChanged(self, service_day): + """ + React to the day of the service name changing. + """ self.serviceNameTime.setEnabled(service_day is not 7) self.updateServiceNameExample(None) def onServiceNameRevertButtonClicked(self): + """ + Revert to the default service name. + """ self.serviceNameEdit.setText(UiStrings().DefaultServiceName) self.serviceNameEdit.setFocus() def onDefaultColorButtonClicked(self): + """ + Select the background colour of the default display screen. + """ new_color = QtGui.QColorDialog.getColor( QtGui.QColor(self.defaultColor), self) if new_color.isValid(): @@ -492,6 +515,9 @@ class AdvancedTab(SettingsTab): self.defaultColorButton.setStyleSheet(u'background-color: %s' % self.defaultColor) def onDefaultBrowseButtonClicked(self): + """ + Select an image for the default display screen. + """ file_filters = u'%s;;%s (*.*) (*)' % (get_images_filter(), UiStrings().AllFiles) filename = QtGui.QFileDialog.getOpenFileName(self, @@ -506,9 +532,9 @@ class AdvancedTab(SettingsTab): """ old_root_path = unicode(self.dataDirectoryLabel.text()) # Get the new directory location. - new_data_path = QtGui.QFileDialog.getExistingDirectory(self, - translate('OpenLP.AdvancedTab', 'Select Data Directory Location'), old_root_path, - options = QtGui.QFileDialog.ShowDirsOnly) + new_data_path = QtGui.QFileDialog.getExistingDirectory( + self, translate('OpenLP.AdvancedTab', 'Select Data Directory Location'), old_root_path, + options=QtGui.QFileDialog.ShowDirsOnly) # Set the new data path. if new_data_path: new_data_path = os.path.normpath(new_data_path) @@ -558,6 +584,9 @@ class AdvancedTab(SettingsTab): self.onDataDirectoryCancelButtonClicked() def onDataDirectoryCopyCheckBoxToggled(self): + """ + Copy existing data when you change your data directory. + """ Receiver.send_message(u'set_copy_data', self.dataDirectoryCopyCheckBox.isChecked()) if self.dataExists: @@ -566,7 +595,10 @@ class AdvancedTab(SettingsTab): else: self.newDataDirectoryHasFilesLabel.hide() - def checkDataOverwrite(self, data_path ): + def checkDataOverwrite(self, data_path): + """ + Check if there's already data in the target directory. + """ test_path = os.path.join(data_path, u'songs') self.dataDirectoryCopyCheckBox.show() if os.path.exists(test_path): @@ -602,6 +634,9 @@ class AdvancedTab(SettingsTab): self.newDataDirectoryHasFilesLabel.hide() def onDefaultRevertButtonClicked(self): + """ + Revert the default screen back to the default settings. + """ self.defaultFileEdit.setText(u':/graphics/openlp-splash-screen.png') self.defaultFileEdit.setFocus() @@ -615,10 +650,19 @@ class AdvancedTab(SettingsTab): self.displayChanged = True def onEndSlideButtonClicked(self): + """ + Set the slide wrap option. + """ self.slide_limits = SlideLimits.End def onWrapSlideButtonClicked(self): + """ + Set the slide wrap option. + """ self.slide_limits = SlideLimits.Wrap def onnextItemButtonClicked(self): + """ + Set the slide wrap option. + """ self.slide_limits = SlideLimits.Next diff --git a/openlp/core/ui/exceptiondialog.py b/openlp/core/ui/exceptiondialog.py index e3736de53..9c1cc140d 100644 --- a/openlp/core/ui/exceptiondialog.py +++ b/openlp/core/ui/exceptiondialog.py @@ -26,14 +26,24 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +""" +The GUI widgets of the exception dialog. +""" from PyQt4 import QtCore, QtGui from openlp.core.lib import translate from openlp.core.lib.ui import create_button, create_button_box + class Ui_ExceptionDialog(object): + """ + The GUI widgets of the exception dialog. + """ def setupUi(self, exceptionDialog): + """ + Set up the UI. + """ exceptionDialog.setObjectName(u'exceptionDialog') self.exceptionLayout = QtGui.QVBoxLayout(exceptionDialog) self.exceptionLayout.setObjectName(u'exceptionLayout') @@ -66,7 +76,7 @@ class Ui_ExceptionDialog(object): self.exceptionLayout.addWidget(self.exceptionTextEdit) self.sendReportButton = create_button(exceptionDialog, u'sendReportButton', icon=u':/general/general_email.png', click=self.onSendReportButtonClicked) - self.saveReportButton = create_button(exceptionDialog,u'saveReportButton', + self.saveReportButton = create_button(exceptionDialog, u'saveReportButton', icon=u':/general/general_save.png', click=self.onSaveReportButtonClicked) self.attachFileButton = create_button(exceptionDialog, u'attachFileButton', icon=u':/general/general_open.png', click=self.onAttachFileButtonClicked) @@ -79,6 +89,9 @@ class Ui_ExceptionDialog(object): QtCore.SIGNAL(u'textChanged()'), self.onDescriptionUpdated) def retranslateUi(self, exceptionDialog): + """ + Translate the widgets on the fly. + """ exceptionDialog.setWindowTitle(translate('OpenLP.ExceptionDialog', 'Error Occurred')) self.descriptionExplanation.setText(translate('OpenLP.ExceptionDialog', 'Please enter a description of what you were doing to cause this ' diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index 213a66388..580e5ae71 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -26,6 +26,9 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +""" +The actual exception dialog form. +""" import logging import re import os @@ -92,22 +95,32 @@ from exceptiondialog import Ui_ExceptionDialog log = logging.getLogger(__name__) + class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): """ The exception dialog """ def __init__(self, parent): + """ + Constructor. + """ QtGui.QDialog.__init__(self, parent) self.setupUi(self) self.settingsSection = u'crashreport' def exec_(self): + """ + Show the dialog. + """ self.descriptionTextEdit.setPlainText(u'') self.onDescriptionUpdated() self.fileAttachment = None return QtGui.QDialog.exec_(self) def _createReport(self): + """ + Create an exception report. + """ openlp_version = get_application_version() description = self.descriptionTextEdit.toPlainText() traceback = self.exceptionTextEdit.toPlainText() @@ -199,6 +212,9 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): QtGui.QDesktopServices.openUrl(mailto_url) def onDescriptionUpdated(self): + """ + Update the minimum number of characters needed in the description. + """ count = int(20 - len(self.descriptionTextEdit.toPlainText())) if count < 0: count = 0 @@ -209,6 +225,9 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): translate('OpenLP.ExceptionDialog', 'Description characters to enter : %s') % count) def onAttachFileButtonClicked(self): + """ + Attache files to the bug report e-mail. + """ files = QtGui.QFileDialog.getOpenFileName( self, translate('ImagePlugin.ExceptionDialog', 'Select Attachment'), Settings().value(self.settingsSection + u'/last directory'), u'%s (*.*) (*)' % UiStrings().AllFiles) @@ -217,6 +236,8 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): self.fileAttachment = unicode(files) def __buttonState(self, state): + """ + Toggle the button state. + """ self.saveReportButton.setEnabled(state) self.sendReportButton.setEnabled(state) - diff --git a/openlp/core/ui/filerenamedialog.py b/openlp/core/ui/filerenamedialog.py index 5cd67a20b..53718a181 100644 --- a/openlp/core/ui/filerenamedialog.py +++ b/openlp/core/ui/filerenamedialog.py @@ -26,14 +26,23 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The UI widgets for the rename dialog +""" from PyQt4 import QtCore, QtGui from openlp.core.lib import translate from openlp.core.lib.ui import create_button_box + class Ui_FileRenameDialog(object): + """ + The UI widgets for the rename dialog + """ def setupUi(self, fileRenameDialog): + """ + Set up the UI + """ fileRenameDialog.setObjectName(u'fileRenameDialog') fileRenameDialog.resize(300, 10) self.dialogLayout = QtGui.QGridLayout(fileRenameDialog) @@ -51,4 +60,7 @@ class Ui_FileRenameDialog(object): self.setMaximumHeight(self.sizeHint().height()) def retranslateUi(self, fileRenameDialog): + """ + Translate the UI on the fly. + """ self.fileNameLabel.setText(translate('OpenLP.FileRenameForm', 'New File Name:')) From 3b6f897f6e533f1fa64b33f008a90cf126880790 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 1 Feb 2013 20:09:47 +0000 Subject: [PATCH 25/64] Cleanup Advance Tab --- openlp/core/lib/registry.py | 2 +- openlp/core/lib/renderer.py | 6 +- openlp/core/lib/settingstab.py | 44 ++ openlp/core/lib/theme.py | 1 + openlp/core/theme/theme.py | 1 + openlp/core/ui/advancedtab.py | 784 ++++++++++++++++-------------- openlp/core/ui/media/playertab.py | 8 +- openlp/core/ui/servicemanager.py | 8 +- openlp/core/ui/settingsform.py | 4 +- openlp/core/ui/themestab.py | 15 +- 10 files changed, 483 insertions(+), 390 deletions(-) diff --git a/openlp/core/lib/registry.py b/openlp/core/lib/registry.py index 3a42a14c5..9ab81bb1b 100644 --- a/openlp/core/lib/registry.py +++ b/openlp/core/lib/registry.py @@ -92,5 +92,5 @@ class Registry(object): raise KeyError(u'Invalid Method call for key %s' % key) return if key in self.service_list: - del self.service_list[key] + del self.service_list[key] diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 8e6d9d8ad..acfade722 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -315,7 +315,7 @@ class Renderer(object): if text_contains_split: text = slides[-1] + u'\n[---]\n' + text else: - text = slides[-1] + u'\n'+ text + text = slides[-1] + u'\n' + text text = text.replace(u'
', u'\n') else: pages.extend(slides) @@ -543,7 +543,7 @@ class Renderer(object): end_tags.reverse() # Remove the indexes. html_tags = [tag[1] for tag in html_tags] - return raw_text + u''.join(end_tags), u''.join(start_tags), u''.join(html_tags) + return raw_text + u''.join(end_tags), u''.join(start_tags), u''.join(html_tags) def _binary_chop(self, formatted, previous_html, previous_raw, html_list, raw_list, separator, line_end): """ @@ -661,4 +661,4 @@ class Renderer(object): self._theme_manager = Registry().get(u'theme_manager') return self._theme_manager - theme_manager = property(_get_theme_manager) \ No newline at end of file + theme_manager = property(_get_theme_manager) diff --git a/openlp/core/lib/settingstab.py b/openlp/core/lib/settingstab.py index 0af524877..aee4b1b5a 100644 --- a/openlp/core/lib/settingstab.py +++ b/openlp/core/lib/settingstab.py @@ -29,6 +29,8 @@ from PyQt4 import QtGui +from openlp.core.lib import Registry + class SettingsTab(QtGui.QWidget): """ SettingsTab is a helper widget for plugins to define Tabs for the settings @@ -131,3 +133,45 @@ class SettingsTab(QtGui.QWidget): Tab has just been made visible to the user """ pass + + def _get_service_manager(self): + """ + Adds the service manager to the class dynamically + """ + if not hasattr(self, u'_service_manager'): + self._service_manager = Registry().get(u'service_manager') + return self._service_manager + + service_manager = property(_get_service_manager) + + def _get_main_window(self): + """ + Adds the main window to the class dynamically + """ + if not hasattr(self, u'_main_window'): + self._main_window = Registry().get(u'main_window') + return self._main_window + + main_window = property(_get_main_window) + + def _get_renderer(self): + """ + Adds the Renderer to the class dynamically + """ + if not hasattr(self, u'_renderer'): + self._renderer = Registry().get(u'renderer') + return self._renderer + + renderer = property(_get_renderer) + + def _get_theme_manager(self): + """ + Adds the theme manager to the class dynamically + """ + if not hasattr(self, u'_theme_manager'): + self._theme_manager = Registry().get(u'theme_manager') + return self._theme_manager + + theme_manager = property(_get_theme_manager) + + diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index 8a85c0d86..68b88d4a5 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -213,6 +213,7 @@ class ThemeXML(object): """ FIRST_CAMEL_REGEX = re.compile(u'(.)([A-Z][a-z]+)') SECOND_CAMEL_REGEX = re.compile(u'([a-z0-9])([A-Z])') + def __init__(self): """ Initialise the theme object. diff --git a/openlp/core/theme/theme.py b/openlp/core/theme/theme.py index 2425a3c78..6d300a9a4 100644 --- a/openlp/core/theme/theme.py +++ b/openlp/core/theme/theme.py @@ -164,6 +164,7 @@ class Theme(object): * ``0`` - normal * ``1`` - lyrics """ + def __init__(self, xml): """ Initialise a theme with data from xml diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 3be6fbeb9..6bcab946d 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -52,10 +52,10 @@ class AdvancedTab(SettingsTab): """ Initialise the settings tab """ - self.displayChanged = False - self.defaultImage = u':/graphics/openlp-splash-screen.png' - self.defaultColor = u'#ffffff' - self.dataExists = False + self.display_changed = False + self.default_image = u':/graphics/openlp-splash-screen.png' + self.default_color = u'#ffffff' + self.data_exists = False self.iconPath = u':/system/system_settings.png' advanced_translated = translate('OpenLP.AdvancedTab', 'Advanced') SettingsTab.__init__(self, parent, u'Advanced', advanced_translated) @@ -66,271 +66,280 @@ class AdvancedTab(SettingsTab): """ self.setObjectName(u'AdvancedTab') SettingsTab.setupUi(self) - self.uiGroupBox = QtGui.QGroupBox(self.leftColumn) - self.uiGroupBox.setObjectName(u'uiGroupBox') - self.uiLayout = QtGui.QFormLayout(self.uiGroupBox) - self.uiLayout.setObjectName(u'uiLayout') - self.recentLabel = QtGui.QLabel(self.uiGroupBox) - self.recentLabel.setObjectName(u'recentLabel') - self.recentSpinBox = QtGui.QSpinBox(self.uiGroupBox) - self.recentSpinBox.setObjectName(u'recentSpinBox') - self.recentSpinBox.setMinimum(0) - self.uiLayout.addRow(self.recentLabel, self.recentSpinBox) - self.mediaPluginCheckBox = QtGui.QCheckBox(self.uiGroupBox) - self.mediaPluginCheckBox.setObjectName(u'mediaPluginCheckBox') - self.uiLayout.addRow(self.mediaPluginCheckBox) - self.doubleClickLiveCheckBox = QtGui.QCheckBox(self.uiGroupBox) - self.doubleClickLiveCheckBox.setObjectName(u'doubleClickLiveCheckBox') - self.uiLayout.addRow(self.doubleClickLiveCheckBox) - self.singleClickPreviewCheckBox = QtGui.QCheckBox(self.uiGroupBox) - self.singleClickPreviewCheckBox.setObjectName(u'singleClickPreviewCheckBox') - self.uiLayout.addRow(self.singleClickPreviewCheckBox) - self.expandServiceItemCheckBox = QtGui.QCheckBox(self.uiGroupBox) - self.expandServiceItemCheckBox.setObjectName(u'expandServiceItemCheckBox') - self.uiLayout.addRow(self.expandServiceItemCheckBox) - self.enableAutoCloseCheckBox = QtGui.QCheckBox(self.uiGroupBox) - self.enableAutoCloseCheckBox.setObjectName(u'enableAutoCloseCheckBox') - self.uiLayout.addRow(self.enableAutoCloseCheckBox) - self.leftLayout.addWidget(self.uiGroupBox) + self.ui_group_box = QtGui.QGroupBox(self.leftColumn) + self.ui_group_box.setObjectName(u'ui_group_box') + self.ui_layout = QtGui.QFormLayout(self.ui_group_box) + self.ui_layout.setObjectName(u'ui_layout') + self.recent_label = QtGui.QLabel(self.ui_group_box) + self.recent_label.setObjectName(u'recent_label') + self.recent_spin_box = QtGui.QSpinBox(self.ui_group_box) + self.recent_spin_box.setObjectName(u'recent_spin_box') + self.recent_spin_box.setMinimum(0) + self.ui_layout.addRow(self.recent_label, self.recent_spin_box) + self.media_plugin_check_box = QtGui.QCheckBox(self.ui_group_box) + self.media_plugin_check_box.setObjectName(u'media_plugin_check_box') + self.ui_layout.addRow(self.media_plugin_check_box) + self.double_click_live_check_box = QtGui.QCheckBox(self.ui_group_box) + self.double_click_live_check_box.setObjectName(u'double_click_live_check_box') + self.ui_layout.addRow(self.double_click_live_check_box) + self.singleclick_preview_check_box = QtGui.QCheckBox(self.ui_group_box) + self.singleclick_preview_check_box.setObjectName(u'singleclick_preview_check_box') + self.ui_layout.addRow(self.singleclick_preview_check_box) + self.expand_service_item_check_box = QtGui.QCheckBox(self.ui_group_box) + self.expand_service_item_check_box.setObjectName(u'expand_service_item_check_box') + self.ui_layout.addRow(self.expand_service_item_check_box) + self.enable_auto_close_check_box = QtGui.QCheckBox(self.ui_group_box) + self.enable_auto_close_check_box.setObjectName(u'enable_auto_close_check_box') + self.ui_layout.addRow(self.enable_auto_close_check_box) + self.leftLayout.addWidget(self.ui_group_box) # Default service name - self.serviceNameGroupBox = QtGui.QGroupBox(self.leftColumn) - self.serviceNameGroupBox.setObjectName(u'serviceNameGroupBox') - self.serviceNameLayout = QtGui.QFormLayout(self.serviceNameGroupBox) - self.serviceNameCheckBox = QtGui.QCheckBox(self.serviceNameGroupBox) - self.serviceNameCheckBox.setObjectName(u'serviceNameCheckBox') - self.serviceNameLayout.setObjectName(u'serviceNameLayout') - self.serviceNameLayout.addRow(self.serviceNameCheckBox) - self.serviceNameTimeLabel = QtGui.QLabel(self.serviceNameGroupBox) - self.serviceNameTimeLabel.setObjectName(u'serviceNameTimeLabel') - self.serviceNameDay = QtGui.QComboBox(self.serviceNameGroupBox) - self.serviceNameDay.addItems([u'', u'', u'', u'', u'', u'', u'', u'']) - self.serviceNameDay.setObjectName(u'serviceNameDay') - self.serviceNameTime = QtGui.QTimeEdit(self.serviceNameGroupBox) - self.serviceNameTime.setObjectName(u'serviceNameTime') - self.serviceNameTimeHBox = QtGui.QHBoxLayout() - self.serviceNameTimeHBox.setObjectName(u'serviceNameTimeHBox') - self.serviceNameTimeHBox.addWidget(self.serviceNameDay) - self.serviceNameTimeHBox.addWidget(self.serviceNameTime) - self.serviceNameLayout.addRow(self.serviceNameTimeLabel, self.serviceNameTimeHBox) - self.serviceNameLabel = QtGui.QLabel(self.serviceNameGroupBox) - self.serviceNameLabel.setObjectName(u'serviceNameLabel') - self.serviceNameEdit = QtGui.QLineEdit(self.serviceNameGroupBox) - self.serviceNameEdit.setObjectName(u'serviceNameEdit') - self.serviceNameEdit.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp(r'[^/\\?*|<>\[\]":+]+'), self)) - self.serviceNameRevertButton = QtGui.QToolButton(self.serviceNameGroupBox) - self.serviceNameRevertButton.setObjectName(u'serviceNameRevertButton') - self.serviceNameRevertButton.setIcon(build_icon(u':/general/general_revert.png')) - self.serviceNameHBox = QtGui.QHBoxLayout() - self.serviceNameHBox.setObjectName(u'serviceNameHBox') - self.serviceNameHBox.addWidget(self.serviceNameEdit) - self.serviceNameHBox.addWidget(self.serviceNameRevertButton) - self.serviceNameLayout.addRow(self.serviceNameLabel, self.serviceNameHBox) - self.serviceNameExampleLabel = QtGui.QLabel(self.serviceNameGroupBox) - self.serviceNameExampleLabel.setObjectName(u'serviceNameExampleLabel') - self.serviceNameExample = QtGui.QLabel(self.serviceNameGroupBox) - self.serviceNameExample.setObjectName(u'serviceNameExample') - self.serviceNameLayout.addRow(self.serviceNameExampleLabel, self.serviceNameExample) - self.leftLayout.addWidget(self.serviceNameGroupBox) + self.service_name_group_box = QtGui.QGroupBox(self.leftColumn) + self.service_name_group_box.setObjectName(u'service_name_group_box') + self.service_name_layout = QtGui.QFormLayout(self.service_name_group_box) + self.service_name_check_box = QtGui.QCheckBox(self.service_name_group_box) + self.service_name_check_box.setObjectName(u'service_name_check_box') + self.service_name_layout.setObjectName(u'service_name_layout') + self.service_name_layout.addRow(self.service_name_check_box) + self.service_name_time_label = QtGui.QLabel(self.service_name_group_box) + self.service_name_time_label.setObjectName(u'service_name_time_label') + self.service_name_day = QtGui.QComboBox(self.service_name_group_box) + self.service_name_day.addItems([u'', u'', u'', u'', u'', u'', u'', u'']) + self.service_name_day.setObjectName(u'service_name_day') + self.service_name_time = QtGui.QTimeEdit(self.service_name_group_box) + self.service_name_time.setObjectName(u'service_name_time') + self.service_name_timeHBox = QtGui.QHBoxLayout() + self.service_name_timeHBox.setObjectName(u'service_name_timeHBox') + self.service_name_timeHBox.addWidget(self.service_name_day) + self.service_name_timeHBox.addWidget(self.service_name_time) + self.service_name_layout.addRow(self.service_name_time_label, self.service_name_timeHBox) + self.service_name_label = QtGui.QLabel(self.service_name_group_box) + self.service_name_label.setObjectName(u'service_name_label') + self.service_name_edit = QtGui.QLineEdit(self.service_name_group_box) + self.service_name_edit.setObjectName(u'service_name_edit') + self.service_name_edit.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp(r'[^/\\?*|<>\[\]":+]+'), self)) + self.service_name_revert_button = QtGui.QToolButton(self.service_name_group_box) + self.service_name_revert_button.setObjectName(u'service_name_revert_button') + self.service_name_revert_button.setIcon(build_icon(u':/general/general_revert.png')) + self.service_name_h_box = QtGui.QHBoxLayout() + self.service_name_h_box.setObjectName(u'service_name_h_box') + self.service_name_h_box.addWidget(self.service_name_edit) + self.service_name_h_box.addWidget(self.service_name_revert_button) + self.service_name_layout.addRow(self.service_name_label, self.service_name_h_box) + self.service_name_example_label = QtGui.QLabel(self.service_name_group_box) + self.service_name_example_label.setObjectName(u'service_name_example_label') + self.service_name_example = QtGui.QLabel(self.service_name_group_box) + self.service_name_example.setObjectName(u'service_name_example') + self.service_name_layout.addRow(self.service_name_example_label, self.service_name_example) + self.leftLayout.addWidget(self.service_name_group_box) # Data Directory - self.dataDirectoryGroupBox = QtGui.QGroupBox(self.leftColumn) - self.dataDirectoryGroupBox.setObjectName(u'dataDirectoryGroupBox') - self.dataDirectoryLayout = QtGui.QFormLayout(self.dataDirectoryGroupBox) - self.dataDirectoryLayout.setObjectName(u'dataDirectoryLayout') - self.dataDirectoryCurrentLabel = QtGui.QLabel(self.dataDirectoryGroupBox) - self.dataDirectoryCurrentLabel.setObjectName( u'dataDirectoryCurrentLabel') - self.dataDirectoryLabel = QtGui.QLabel(self.dataDirectoryGroupBox) - self.dataDirectoryLabel.setObjectName(u'dataDirectoryLabel') - self.dataDirectoryNewLabel = QtGui.QLabel(self.dataDirectoryGroupBox) - self.dataDirectoryNewLabel.setObjectName(u'dataDirectoryCurrentLabel') - self.newDataDirectoryEdit = QtGui.QLineEdit(self.dataDirectoryGroupBox) - self.newDataDirectoryEdit.setObjectName(u'newDataDirectoryEdit') - self.newDataDirectoryEdit.setReadOnly(True) - self.newDataDirectoryHasFilesLabel = QtGui.QLabel(self.dataDirectoryGroupBox) - self.newDataDirectoryHasFilesLabel.setObjectName(u'newDataDirectoryHasFilesLabel') - self.newDataDirectoryHasFilesLabel.setWordWrap(True) - self.dataDirectoryBrowseButton = QtGui.QToolButton(self.dataDirectoryGroupBox) - self.dataDirectoryBrowseButton.setObjectName(u'dataDirectoryBrowseButton') - self.dataDirectoryBrowseButton.setIcon(build_icon(u':/general/general_open.png')) - self.dataDirectoryDefaultButton = QtGui.QToolButton(self.dataDirectoryGroupBox) - self.dataDirectoryDefaultButton.setObjectName(u'dataDirectoryDefaultButton') - self.dataDirectoryDefaultButton.setIcon(build_icon(u':/general/general_revert.png')) - self.dataDirectoryCancelButton = QtGui.QToolButton(self.dataDirectoryGroupBox) - self.dataDirectoryCancelButton.setObjectName(u'dataDirectoryCancelButton') - self.dataDirectoryCancelButton.setIcon(build_icon(u':/general/general_delete.png')) - self.newDataDirectoryLabelHBox = QtGui.QHBoxLayout() - self.newDataDirectoryLabelHBox.setObjectName(u'newDataDirectoryLabelHBox') - self.newDataDirectoryLabelHBox.addWidget(self.newDataDirectoryEdit) - self.newDataDirectoryLabelHBox.addWidget(self.dataDirectoryBrowseButton) - self.newDataDirectoryLabelHBox.addWidget(self.dataDirectoryDefaultButton) - self.dataDirectoryCopyCheckHBox = QtGui.QHBoxLayout() - self.dataDirectoryCopyCheckHBox.setObjectName(u'dataDirectoryCopyCheckHBox') - self.dataDirectoryCopyCheckBox = QtGui.QCheckBox(self.dataDirectoryGroupBox) - self.dataDirectoryCopyCheckBox.setObjectName(u'dataDirectoryCopyCheckBox') - self.dataDirectoryCopyCheckHBox.addWidget(self.dataDirectoryCopyCheckBox) - self.dataDirectoryCopyCheckHBox.addStretch() - self.dataDirectoryCopyCheckHBox.addWidget(self.dataDirectoryCancelButton) - self.dataDirectoryLayout.addRow(self.dataDirectoryCurrentLabel, self.dataDirectoryLabel) - self.dataDirectoryLayout.addRow(self.dataDirectoryNewLabel, self.newDataDirectoryLabelHBox) - self.dataDirectoryLayout.addRow(self.dataDirectoryCopyCheckHBox) - self.dataDirectoryLayout.addRow(self.newDataDirectoryHasFilesLabel) - self.leftLayout.addWidget(self.dataDirectoryGroupBox) + self.data_directory_group_box = QtGui.QGroupBox(self.leftColumn) + self.data_directory_group_box.setObjectName(u'data_directory_group_box') + self.data_directory_layout = QtGui.QFormLayout(self.data_directory_group_box) + self.data_directory_layout.setObjectName(u'data_directory_layout') + self.data_directory_current_label = QtGui.QLabel(self.data_directory_group_box) + self.data_directory_current_label.setObjectName( u'data_directory_current_label') + self.data_directory_label = QtGui.QLabel(self.data_directory_group_box) + self.data_directory_label.setObjectName(u'data_directory_label') + self.data_directory_new_label = QtGui.QLabel(self.data_directory_group_box) + self.data_directory_new_label.setObjectName(u'data_directory_current_label') + self.new_data_directory_edit = QtGui.QLineEdit(self.data_directory_group_box) + self.new_data_directory_edit.setObjectName(u'new_data_directory_edit') + self.new_data_directory_edit.setReadOnly(True) + self.new_data_directory_has_files_label = QtGui.QLabel(self.data_directory_group_box) + self.new_data_directory_has_files_label.setObjectName(u'new_data_directory_has_files_label') + self.new_data_directory_has_files_label.setWordWrap(True) + self.data_directory_browse_button = QtGui.QToolButton(self.data_directory_group_box) + self.data_directory_browse_button.setObjectName(u'data_directory_browse_button') + self.data_directory_browse_button.setIcon(build_icon(u':/general/general_open.png')) + self.data_directory_default_button = QtGui.QToolButton(self.data_directory_group_box) + self.data_directory_default_button.setObjectName(u'data_directory_default_button') + self.data_directory_default_button.setIcon(build_icon(u':/general/general_revert.png')) + self.data_directory_cancel_button = QtGui.QToolButton(self.data_directory_group_box) + self.data_directory_cancel_button.setObjectName(u'data_directory_cancel_button') + self.data_directory_cancel_button.setIcon(build_icon(u':/general/general_delete.png')) + self.new_data_directory_label_H_box = QtGui.QHBoxLayout() + self.new_data_directory_label_H_box.setObjectName(u'new_data_directory_label_H_box') + self.new_data_directory_label_H_box.addWidget(self.new_data_directory_edit) + self.new_data_directory_label_H_box.addWidget(self.data_directory_browse_button) + self.new_data_directory_label_H_box.addWidget(self.data_directory_default_button) + self.data_directory_copy_check_H_box = QtGui.QHBoxLayout() + self.data_directory_copy_check_H_box.setObjectName(u'data_directory_copy_check_H_box') + self.data_directory_copy_check_box = QtGui.QCheckBox(self.data_directory_group_box) + self.data_directory_copy_check_box.setObjectName(u'data_directory_copy_check_box') + self.data_directory_copy_check_H_box.addWidget(self.data_directory_copy_check_box) + self.data_directory_copy_check_H_box.addStretch() + self.data_directory_copy_check_H_box.addWidget(self.data_directory_cancel_button) + self.data_directory_layout.addRow(self.data_directory_current_label, self.data_directory_label) + self.data_directory_layout.addRow(self.data_directory_new_label, self.new_data_directory_label_H_box) + self.data_directory_layout.addRow(self.data_directory_copy_check_H_box) + self.data_directory_layout.addRow(self.new_data_directory_has_files_label) + self.leftLayout.addWidget(self.data_directory_group_box) self.leftLayout.addStretch() # Default Image - self.defaultImageGroupBox = QtGui.QGroupBox(self.rightColumn) - self.defaultImageGroupBox.setObjectName(u'defaultImageGroupBox') - self.defaultImageLayout = QtGui.QFormLayout(self.defaultImageGroupBox) - self.defaultImageLayout.setObjectName(u'defaultImageLayout') - self.defaultColorLabel = QtGui.QLabel(self.defaultImageGroupBox) - self.defaultColorLabel.setObjectName(u'defaultColorLabel') - self.defaultColorButton = QtGui.QPushButton(self.defaultImageGroupBox) - self.defaultColorButton.setObjectName(u'defaultColorButton') - self.defaultImageLayout.addRow(self.defaultColorLabel, self.defaultColorButton) - self.defaultFileLabel = QtGui.QLabel(self.defaultImageGroupBox) - self.defaultFileLabel.setObjectName(u'defaultFileLabel') - self.defaultFileEdit = QtGui.QLineEdit(self.defaultImageGroupBox) - self.defaultFileEdit.setObjectName(u'defaultFileEdit') - self.defaultBrowseButton = QtGui.QToolButton(self.defaultImageGroupBox) - self.defaultBrowseButton.setObjectName(u'defaultBrowseButton') - self.defaultBrowseButton.setIcon(build_icon(u':/general/general_open.png')) - self.defaultRevertButton = QtGui.QToolButton(self.defaultImageGroupBox) - self.defaultRevertButton.setObjectName(u'defaultRevertButton') - self.defaultRevertButton.setIcon(build_icon(u':/general/general_revert.png')) + self.default_image_group_box = QtGui.QGroupBox(self.rightColumn) + self.default_image_group_box.setObjectName(u'default_image_group_box') + self.default_image_layout = QtGui.QFormLayout(self.default_image_group_box) + self.default_image_layout.setObjectName(u'default_image_layout') + self.default_color_label = QtGui.QLabel(self.default_image_group_box) + self.default_color_label.setObjectName(u'default_color_label') + self.default_color_button = QtGui.QPushButton(self.default_image_group_box) + self.default_color_button.setObjectName(u'default_color_button') + self.default_image_layout.addRow(self.default_color_label, self.default_color_button) + self.default_file_label = QtGui.QLabel(self.default_image_group_box) + self.default_file_label.setObjectName(u'default_file_label') + self.default_file_edit = QtGui.QLineEdit(self.default_image_group_box) + self.default_file_edit.setObjectName(u'default_file_edit') + self.default_browse_button = QtGui.QToolButton(self.default_image_group_box) + self.default_browse_button.setObjectName(u'default_browse_button') + self.default_browse_button.setIcon(build_icon(u':/general/general_open.png')) + self.default_revert_button = QtGui.QToolButton(self.default_image_group_box) + self.default_revert_button.setObjectName(u'default_revert_button') + self.default_revert_button.setIcon(build_icon(u':/general/general_revert.png')) self.defaultFileLayout = QtGui.QHBoxLayout() self.defaultFileLayout.setObjectName(u'defaultFileLayout') - self.defaultFileLayout.addWidget(self.defaultFileEdit) - self.defaultFileLayout.addWidget(self.defaultBrowseButton) - self.defaultFileLayout.addWidget(self.defaultRevertButton) - self.defaultImageLayout.addRow(self.defaultFileLabel, self.defaultFileLayout) - self.rightLayout.addWidget(self.defaultImageGroupBox) + self.defaultFileLayout.addWidget(self.default_file_edit) + self.defaultFileLayout.addWidget(self.default_browse_button) + self.defaultFileLayout.addWidget(self.default_revert_button) + self.default_image_layout.addRow(self.default_file_label, self.defaultFileLayout) + self.rightLayout.addWidget(self.default_image_group_box) # Hide mouse - self.hideMouseGroupBox = QtGui.QGroupBox(self.rightColumn) - self.hideMouseGroupBox.setObjectName(u'hideMouseGroupBox') - self.hideMouseLayout = QtGui.QVBoxLayout(self.hideMouseGroupBox) + self.hide_mouse_group_box = QtGui.QGroupBox(self.rightColumn) + self.hide_mouse_group_box.setObjectName(u'hide_mouse_group_box') + self.hideMouseLayout = QtGui.QVBoxLayout(self.hide_mouse_group_box) self.hideMouseLayout.setObjectName(u'hideMouseLayout') - self.hideMouseCheckBox = QtGui.QCheckBox(self.hideMouseGroupBox) - self.hideMouseCheckBox.setObjectName(u'hideMouseCheckBox') - self.hideMouseLayout.addWidget(self.hideMouseCheckBox) - self.rightLayout.addWidget(self.hideMouseGroupBox) + self.hide_mouse_check_box = QtGui.QCheckBox(self.hide_mouse_group_box) + self.hide_mouse_check_box.setObjectName(u'hide_mouse_check_box') + self.hideMouseLayout.addWidget(self.hide_mouse_check_box) + self.rightLayout.addWidget(self.hide_mouse_group_box) # Service Item Slide Limits - self.slideGroupBox = QtGui.QGroupBox(self.rightColumn) - self.slideGroupBox.setObjectName(u'slideGroupBox') - self.slideLayout = QtGui.QVBoxLayout(self.slideGroupBox) + self.slide_group_box = QtGui.QGroupBox(self.rightColumn) + self.slide_group_box.setObjectName(u'slide_group_box') + self.slideLayout = QtGui.QVBoxLayout(self.slide_group_box) self.slideLayout.setObjectName(u'slideLayout') - self.slideLabel = QtGui.QLabel(self.slideGroupBox) - self.slideLabel.setWordWrap(True) - self.slideLayout.addWidget(self.slideLabel) - self.endSlideRadioButton = QtGui.QRadioButton(self.slideGroupBox) - self.endSlideRadioButton.setObjectName(u'endSlideRadioButton') - self.slideLayout.addWidget(self.endSlideRadioButton) - self.wrapSlideRadioButton = QtGui.QRadioButton(self.slideGroupBox) - self.wrapSlideRadioButton.setObjectName(u'wrapSlideRadioButton') - self.slideLayout.addWidget(self.wrapSlideRadioButton) - self.nextItemRadioButton = QtGui.QRadioButton(self.slideGroupBox) - self.nextItemRadioButton.setObjectName(u'nextItemRadioButton') - self.slideLayout.addWidget(self.nextItemRadioButton) - self.rightLayout.addWidget(self.slideGroupBox) - self.x11GroupBox = QtGui.QGroupBox(self.leftColumn) - self.x11GroupBox.setObjectName(u'x11GroupBox') - self.x11Layout = QtGui.QVBoxLayout(self.x11GroupBox) + self.slide_label = QtGui.QLabel(self.slide_group_box) + self.slide_label.setWordWrap(True) + self.slideLayout.addWidget(self.slide_label) + self.end_slide_radio_button = QtGui.QRadioButton(self.slide_group_box) + self.end_slide_radio_button.setObjectName(u'end_slide_radio_button') + self.slideLayout.addWidget(self.end_slide_radio_button) + self.wrap_slide_radio_button = QtGui.QRadioButton(self.slide_group_box) + self.wrap_slide_radio_button.setObjectName(u'wrap_slide_radio_button') + self.slideLayout.addWidget(self.wrap_slide_radio_button) + self.next_item_radio_button = QtGui.QRadioButton(self.slide_group_box) + self.next_item_radio_button.setObjectName(u'next_item_radio_button') + self.slideLayout.addWidget(self.next_item_radio_button) + self.rightLayout.addWidget(self.slide_group_box) + self.x11_group_box = QtGui.QGroupBox(self.leftColumn) + self.x11_group_box.setObjectName(u'x11_group_box') + self.x11Layout = QtGui.QVBoxLayout(self.x11_group_box) self.x11Layout.setObjectName(u'x11Layout') - self.x11BypassCheckBox = QtGui.QCheckBox(self.x11GroupBox) - self.x11BypassCheckBox.setObjectName(u'x11BypassCheckBox') - self.x11Layout.addWidget(self.x11BypassCheckBox) - self.rightLayout.addWidget(self.x11GroupBox) + self.x11_bypass_check_box = QtGui.QCheckBox(self.x11_group_box) + self.x11_bypass_check_box.setObjectName(u'x11_bypass_check_box') + self.x11Layout.addWidget(self.x11_bypass_check_box) + self.rightLayout.addWidget(self.x11_group_box) self.rightLayout.addStretch() - self.shouldUpdateServiceNameExample = False - QtCore.QObject.connect(self.serviceNameCheckBox, QtCore.SIGNAL(u'toggled(bool)'), - self.serviceNameCheckBoxToggled) - QtCore.QObject.connect(self.serviceNameDay, QtCore.SIGNAL(u'currentIndexChanged(int)'), - self.onServiceNameDayChanged) - QtCore.QObject.connect(self.serviceNameTime, QtCore.SIGNAL(u'timeChanged(QTime)'), - self.updateServiceNameExample) - QtCore.QObject.connect(self.serviceNameEdit, QtCore.SIGNAL(u'textChanged(QString)'), - self.updateServiceNameExample) - QtCore.QObject.connect(self.serviceNameRevertButton, QtCore.SIGNAL(u'clicked()'), - self.onServiceNameRevertButtonClicked) - QtCore.QObject.connect(self.defaultColorButton, QtCore.SIGNAL(u'clicked()'), self.onDefaultColorButtonClicked) - QtCore.QObject.connect(self.defaultBrowseButton, QtCore.SIGNAL(u'clicked()'), self.onDefaultBrowseButtonClicked) - QtCore.QObject.connect(self.defaultRevertButton, QtCore.SIGNAL(u'clicked()'), self.onDefaultRevertButtonClicked) - QtCore.QObject.connect(self.x11BypassCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.onX11BypassCheckBoxToggled) - QtCore.QObject.connect(self.dataDirectoryBrowseButton, QtCore.SIGNAL(u'clicked()'), - self.onDataDirectoryBrowseButtonClicked) - QtCore.QObject.connect(self.dataDirectoryDefaultButton, QtCore.SIGNAL(u'clicked()'), - self.onDataDirectoryDefaultButtonClicked) - QtCore.QObject.connect(self.dataDirectoryCancelButton, QtCore.SIGNAL(u'clicked()'), - self.onDataDirectoryCancelButtonClicked) - QtCore.QObject.connect(self.dataDirectoryCopyCheckBox, QtCore.SIGNAL(u'toggled(bool)'), - self.onDataDirectoryCopyCheckBoxToggled) - QtCore.QObject.connect(self.endSlideRadioButton, QtCore.SIGNAL(u'clicked()'), self.onEndSlideButtonClicked) - QtCore.QObject.connect(self.wrapSlideRadioButton, QtCore.SIGNAL(u'clicked()'), self.onWrapSlideButtonClicked) - QtCore.QObject.connect(self.nextItemRadioButton, QtCore.SIGNAL(u'clicked()'), self.onnextItemButtonClicked) + self.should_update_service_name_example = False + QtCore.QObject.connect(self.service_name_check_box, QtCore.SIGNAL(u'toggled(bool)'), + self.service_name_check_box_toggled) + QtCore.QObject.connect(self.service_name_day, QtCore.SIGNAL(u'currentIndexChanged(int)'), + self.on_service_name_day_changed) + QtCore.QObject.connect(self.service_name_time, QtCore.SIGNAL(u'timeChanged(QTime)'), + self.update_service_name_example) + QtCore.QObject.connect(self.service_name_edit, QtCore.SIGNAL(u'textChanged(QString)'), + self.update_service_name_example) + QtCore.QObject.connect(self.service_name_revert_button, QtCore.SIGNAL(u'clicked()'), + self.on_service_name_revert_button_clicked) + QtCore.QObject.connect(self.default_color_button, QtCore.SIGNAL(u'clicked()'), + self.on_default_color_button_clicked) + QtCore.QObject.connect(self.default_browse_button, QtCore.SIGNAL(u'clicked()'), + self.on_default_browse_button_clicked) + QtCore.QObject.connect(self.default_revert_button, QtCore.SIGNAL(u'clicked()'), + self.on_default_revert_button_clicked) + QtCore.QObject.connect(self.x11_bypass_check_box, QtCore.SIGNAL(u'toggled(bool)'), + self.on_X11_bypass_check_box_toggled) + QtCore.QObject.connect(self.data_directory_browse_button, QtCore.SIGNAL(u'clicked()'), + self.on_data_directory_browse_button_clicked) + QtCore.QObject.connect(self.data_directory_default_button, QtCore.SIGNAL(u'clicked()'), + self.on_data_directory_default_button_clicked) + QtCore.QObject.connect(self.data_directory_cancel_button, QtCore.SIGNAL(u'clicked()'), + self.on_data_directory_cancel_button_clicked) + QtCore.QObject.connect(self.data_directory_copy_check_box, QtCore.SIGNAL(u'toggled(bool)'), + self.on_data_directory_copy_check_box_toggled) + QtCore.QObject.connect(self.end_slide_radio_button, QtCore.SIGNAL(u'clicked()'), + self.on_end_slide_button_clicked) + QtCore.QObject.connect(self.wrap_slide_radio_button, QtCore.SIGNAL(u'clicked()'), + self.on_wrap_slide_button_clicked) + QtCore.QObject.connect(self.next_item_radio_button, QtCore.SIGNAL(u'clicked()'), + self.on_next_item_button_clicked) def retranslateUi(self): """ Setup the interface translation strings. """ self.tabTitleVisible = UiStrings().Advanced - self.uiGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'UI Settings')) - self.dataDirectoryGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Data Location')) - self.recentLabel.setText(translate('OpenLP.AdvancedTab', 'Number of recent files to display:')) - self.mediaPluginCheckBox.setText(translate('OpenLP.AdvancedTab', + self.ui_group_box.setTitle(translate('OpenLP.AdvancedTab', 'UI Settings')) + self.data_directory_group_box.setTitle(translate('OpenLP.AdvancedTab', 'Data Location')) + self.recent_label.setText(translate('OpenLP.AdvancedTab', 'Number of recent files to display:')) + self.media_plugin_check_box.setText(translate('OpenLP.AdvancedTab', 'Remember active media manager tab on startup')) - self.doubleClickLiveCheckBox.setText(translate('OpenLP.AdvancedTab', + self.double_click_live_check_box.setText(translate('OpenLP.AdvancedTab', 'Double-click to send items straight to live')) - self.singleClickPreviewCheckBox.setText(translate('OpenLP.AdvancedTab', + self.singleclick_preview_check_box.setText(translate('OpenLP.AdvancedTab', 'Preview items when clicked in Media Manager')) - self.expandServiceItemCheckBox.setText(translate('OpenLP.AdvancedTab', + self.expand_service_item_check_box.setText(translate('OpenLP.AdvancedTab', 'Expand new service items on creation')) - self.enableAutoCloseCheckBox.setText(translate('OpenLP.AdvancedTab', + self.enable_auto_close_check_box.setText(translate('OpenLP.AdvancedTab', 'Enable application exit confirmation')) - self.serviceNameGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Default Service Name')) - self.serviceNameCheckBox.setText(translate('OpenLP.AdvancedTab', 'Enable default service name')) - self.serviceNameTimeLabel.setText(translate('OpenLP.AdvancedTab', 'Date and Time:')) - self.serviceNameDay.setItemText(0, translate('OpenLP.AdvancedTab', 'Monday')) - self.serviceNameDay.setItemText(1, translate('OpenLP.AdvancedTab', 'Tuesday')) - self.serviceNameDay.setItemText(2, translate('OpenLP.AdvancedTab', 'Wednesday')) - self.serviceNameDay.setItemText(3, translate('OpenLP.AdvancedTab', 'Thurdsday')) - self.serviceNameDay.setItemText(4, translate('OpenLP.AdvancedTab', 'Friday')) - self.serviceNameDay.setItemText(5, translate('OpenLP.AdvancedTab', 'Saturday')) - self.serviceNameDay.setItemText(6, translate('OpenLP.AdvancedTab', 'Sunday')) - self.serviceNameDay.setItemText(7, translate('OpenLP.AdvancedTab', 'Now')) - self.serviceNameTime.setToolTip(translate('OpenLP.AdvancedTab', + self.service_name_group_box.setTitle(translate('OpenLP.AdvancedTab', 'Default Service Name')) + self.service_name_check_box.setText(translate('OpenLP.AdvancedTab', 'Enable default service name')) + self.service_name_time_label.setText(translate('OpenLP.AdvancedTab', 'Date and Time:')) + self.service_name_day.setItemText(0, translate('OpenLP.AdvancedTab', 'Monday')) + self.service_name_day.setItemText(1, translate('OpenLP.AdvancedTab', 'Tuesday')) + self.service_name_day.setItemText(2, translate('OpenLP.AdvancedTab', 'Wednesday')) + self.service_name_day.setItemText(3, translate('OpenLP.AdvancedTab', 'Thurdsday')) + self.service_name_day.setItemText(4, translate('OpenLP.AdvancedTab', 'Friday')) + self.service_name_day.setItemText(5, translate('OpenLP.AdvancedTab', 'Saturday')) + self.service_name_day.setItemText(6, translate('OpenLP.AdvancedTab', 'Sunday')) + self.service_name_day.setItemText(7, translate('OpenLP.AdvancedTab', 'Now')) + self.service_name_time.setToolTip(translate('OpenLP.AdvancedTab', 'Time when usual service starts.')) - self.serviceNameLabel.setText(translate('OpenLP.AdvancedTab', 'Name:')) - self.serviceNameEdit.setToolTip(translate('OpenLP.AdvancedTab', 'Consult the OpenLP manual for usage.')) - self.serviceNameRevertButton.setToolTip( - translate('OpenLP.AdvancedTab', 'Revert to the default service name "%s".') % UiStrings().DefaultServiceName) - self.serviceNameExampleLabel.setText(translate('OpenLP.AdvancedTab', 'Example:')) - self.hideMouseGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Mouse Cursor')) - self.hideMouseCheckBox.setText(translate('OpenLP.AdvancedTab', 'Hide mouse cursor when over display window')) - self.defaultImageGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Default Image')) - self.defaultColorLabel.setText(translate('OpenLP.AdvancedTab', 'Background color:')) - self.defaultColorButton.setToolTip(translate('OpenLP.AdvancedTab', 'Click to select a color.')) - self.defaultFileLabel.setText(translate('OpenLP.AdvancedTab', 'Image file:')) - self.defaultBrowseButton.setToolTip(translate('OpenLP.AdvancedTab', 'Browse for an image file to display.')) - self.defaultRevertButton.setToolTip(translate('OpenLP.AdvancedTab', 'Revert to the default OpenLP logo.')) - self.dataDirectoryCurrentLabel.setText(translate('OpenLP.AdvancedTab', 'Current path:')) - self.dataDirectoryNewLabel.setText(translate('OpenLP.AdvancedTab', 'Custom path:')) - self.dataDirectoryBrowseButton.setToolTip(translate('OpenLP.AdvancedTab', 'Browse for new data file location.')) - self.dataDirectoryDefaultButton.setToolTip( + self.service_name_label.setText(translate('OpenLP.AdvancedTab', 'Name:')) + self.service_name_edit.setToolTip(translate('OpenLP.AdvancedTab', 'Consult the OpenLP manual for usage.')) + self.service_name_revert_button.setToolTip( + translate('OpenLP.AdvancedTab', 'Revert to the default service name "%s".') % + UiStrings().DefaultServiceName) + self.service_name_example_label.setText(translate('OpenLP.AdvancedTab', 'Example:')) + self.hide_mouse_group_box.setTitle(translate('OpenLP.AdvancedTab', 'Mouse Cursor')) + self.hide_mouse_check_box.setText(translate('OpenLP.AdvancedTab', 'Hide mouse cursor when over display window')) + self.default_image_group_box.setTitle(translate('OpenLP.AdvancedTab', 'Default Image')) + self.default_color_label.setText(translate('OpenLP.AdvancedTab', 'Background color:')) + self.default_color_button.setToolTip(translate('OpenLP.AdvancedTab', 'Click to select a color.')) + self.default_file_label.setText(translate('OpenLP.AdvancedTab', 'Image file:')) + self.default_browse_button.setToolTip(translate('OpenLP.AdvancedTab', 'Browse for an image file to display.')) + self.default_revert_button.setToolTip(translate('OpenLP.AdvancedTab', 'Revert to the default OpenLP logo.')) + self.data_directory_current_label.setText(translate('OpenLP.AdvancedTab', 'Current path:')) + self.data_directory_new_label.setText(translate('OpenLP.AdvancedTab', 'Custom path:')) + self.data_directory_browse_button.setToolTip(translate('OpenLP.AdvancedTab', + 'Browse for new data file location.')) + self.data_directory_default_button.setToolTip( translate('OpenLP.AdvancedTab', 'Set the data location to the default.')) - self.dataDirectoryCancelButton.setText(translate('OpenLP.AdvancedTab', 'Cancel')) - self.dataDirectoryCancelButton.setToolTip( + self.data_directory_cancel_button.setText(translate('OpenLP.AdvancedTab', 'Cancel')) + self.data_directory_cancel_button.setToolTip( translate('OpenLP.AdvancedTab', 'Cancel OpenLP data directory location change.')) - self.dataDirectoryCopyCheckBox.setText(translate('OpenLP.AdvancedTab', 'Copy data to new location.')) - self.dataDirectoryCopyCheckBox.setToolTip(translate( + self.data_directory_copy_check_box.setText(translate('OpenLP.AdvancedTab', 'Copy data to new location.')) + self.data_directory_copy_check_box.setToolTip(translate( 'OpenLP.AdvancedTab', 'Copy the OpenLP data files to the new location.')) - self.newDataDirectoryHasFilesLabel.setText( + self.new_data_directory_has_files_label.setText( translate('OpenLP.AdvancedTab', 'WARNING: New data directory location contains ' 'OpenLP data files. These files WILL be replaced during a copy.')) - self.x11GroupBox.setTitle(translate('OpenLP.AdvancedTab', 'X11')) - self.x11BypassCheckBox.setText(translate('OpenLP.AdvancedTab','Bypass X11 Window Manager')) + self.x11_group_box.setTitle(translate('OpenLP.AdvancedTab', 'X11')) + self.x11_bypass_check_box.setText(translate('OpenLP.AdvancedTab','Bypass X11 Window Manager')) # Slide Limits - self.slideGroupBox.setTitle(translate('OpenLP.GeneralTab', 'Service Item Slide Limits')) - self.slideLabel.setText(translate('OpenLP.GeneralTab', 'Behavior of next/previous on the last/first slide:')) - self.endSlideRadioButton.setText(translate('OpenLP.GeneralTab', '&Remain on Slide')) - self.wrapSlideRadioButton.setText(translate('OpenLP.GeneralTab', '&Wrap around')) - self.nextItemRadioButton.setText(translate('OpenLP.GeneralTab', '&Move to next/previous service item')) + self.slide_group_box.setTitle(translate('OpenLP.GeneralTab', 'Service Item Slide Limits')) + self.slide_label.setText(translate('OpenLP.GeneralTab', 'Behavior of next/previous on the last/first slide:')) + self.end_slide_radio_button.setText(translate('OpenLP.GeneralTab', '&Remain on Slide')) + self.wrap_slide_radio_button.setText(translate('OpenLP.GeneralTab', '&Wrap around')) + self.next_item_radio_button.setText(translate('OpenLP.GeneralTab', '&Move to next/previous service item')) def load(self): """ @@ -341,40 +350,40 @@ class AdvancedTab(SettingsTab): # The max recent files value does not have an interface and so never # gets actually stored in the settings therefore the default value of # 20 will always be used. - self.recentSpinBox.setMaximum(settings.value(u'max recent files')) - self.recentSpinBox.setValue(settings.value(u'recent file count')) - self.mediaPluginCheckBox.setChecked(settings.value(u'save current plugin')) - self.doubleClickLiveCheckBox.setChecked(settings.value(u'double click live')) - self.singleClickPreviewCheckBox.setChecked(settings.value(u'single click preview')) - self.expandServiceItemCheckBox.setChecked(settings.value(u'expand service item')) - self.enableAutoCloseCheckBox.setChecked(settings.value(u'enable exit confirmation')) - self.hideMouseCheckBox.setChecked(settings.value(u'hide mouse')) - self.serviceNameDay.setCurrentIndex(settings.value(u'default service day')) - self.serviceNameTime.setTime(QtCore.QTime(settings.value(u'default service hour'), + self.recent_spin_box.setMaximum(settings.value(u'max recent files')) + self.recent_spin_box.setValue(settings.value(u'recent file count')) + self.media_plugin_check_box.setChecked(settings.value(u'save current plugin')) + self.double_click_live_check_box.setChecked(settings.value(u'double click live')) + self.singleclick_preview_check_box.setChecked(settings.value(u'single click preview')) + self.expand_service_item_check_box.setChecked(settings.value(u'expand service item')) + self.enable_auto_close_check_box.setChecked(settings.value(u'enable exit confirmation')) + self.hide_mouse_check_box.setChecked(settings.value(u'hide mouse')) + self.service_name_day.setCurrentIndex(settings.value(u'default service day')) + self.service_name_time.setTime(QtCore.QTime(settings.value(u'default service hour'), settings.value(u'default service minute'))) - self.shouldUpdateServiceNameExample = True - self.serviceNameEdit.setText(settings.value(u'default service name')) + self.should_update_service_name_example = True + self.service_name_edit.setText(settings.value(u'default service name')) default_service_enabled = settings.value(u'default service enabled') - self.serviceNameCheckBox.setChecked(default_service_enabled) - self.serviceNameCheckBoxToggled(default_service_enabled) - self.x11BypassCheckBox.setChecked(settings.value(u'x11 bypass wm')) - self.defaultColor = settings.value(u'default color') - self.defaultFileEdit.setText(settings.value(u'default image')) + self.service_name_check_box.setChecked(default_service_enabled) + self.service_name_check_box_toggled(default_service_enabled) + self.x11_bypass_check_box.setChecked(settings.value(u'x11 bypass wm')) + self.default_color = settings.value(u'default color') + self.default_file_edit.setText(settings.value(u'default image')) self.slide_limits = settings.value(u'slide limits') if self.slide_limits == SlideLimits.End: - self.endSlideRadioButton.setChecked(True) + self.end_slide_radio_button.setChecked(True) elif self.slide_limits == SlideLimits.Wrap: - self.wrapSlideRadioButton.setChecked(True) + self.wrap_slide_radio_button.setChecked(True) else: - self.nextItemRadioButton.setChecked(True) + self.next_item_radio_button.setChecked(True) settings.endGroup() - self.dataDirectoryCopyCheckBox.hide() - self.newDataDirectoryHasFilesLabel.hide() - self.dataDirectoryCancelButton.hide() + self.data_directory_copy_check_box.hide() + self.new_data_directory_has_files_label.hide() + self.data_directory_cancel_button.hide() # Since data location can be changed, make sure the path is present. - self.currentDataPath = AppLocation.get_data_path() - if not os.path.exists(self.currentDataPath): - log.error(u'Data path not found %s' % self.currentDataPath) + self.current_data_path = AppLocation.get_data_path() + if not os.path.exists(self.current_data_path): + log.error(u'Data path not found %s' % self.current_data_path) answer = QtGui.QMessageBox.critical(self, translate('OpenLP.AdvancedTab', 'Data Directory Error'), @@ -386,10 +395,8 @@ class AdvancedTab(SettingsTab): 'Click "No" to stop loading OpenLP. allowing you to fix ' 'the the problem.\n\n' 'Click "Yes" to reset the data directory to the default ' - 'location.').replace('%s', self.currentDataPath), - QtGui.QMessageBox.StandardButtons( - QtGui.QMessageBox.Yes | - QtGui.QMessageBox.No), + 'location.').replace('%s', self.current_data_path), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No) if answer == QtGui.QMessageBox.No: log.info(u'User requested termination') @@ -397,13 +404,13 @@ class AdvancedTab(SettingsTab): sys.exit() # Set data location to default. settings.remove(u'advanced/data path') - self.currentDataPath = AppLocation.get_data_path() - log.warning(u'User requested data path set to default %s' % self.currentDataPath) - self.dataDirectoryLabel.setText(os.path.abspath(self.currentDataPath)) - self.defaultColorButton.setStyleSheet(u'background-color: %s' % self.defaultColor) + self.current_data_path = AppLocation.get_data_path() + log.warning(u'User requested data path set to default %s' % self.current_data_path) + self.data_directory_label.setText(os.path.abspath(self.current_data_path)) + self.default_color_button.setStyleSheet(u'background-color: %s' % self.default_color) # Don't allow data directory move if running portable. if settings.value(u'advanced/is portable'): - self.dataDirectoryGroupBox.hide() + self.data_directory_group_box.hide() def save(self): """ @@ -411,100 +418,123 @@ class AdvancedTab(SettingsTab): """ settings = Settings() settings.beginGroup(self.settingsSection) - settings.setValue(u'default service enabled', self.serviceNameCheckBox.isChecked()) - service_name = self.serviceNameEdit.text() - preset_is_valid = self.generateServiceNameExample()[0] + settings.setValue(u'default service enabled', self.service_name_check_box.isChecked()) + service_name = self.service_name_edit.text() + preset_is_valid = self.generate_service_name_example()[0] if service_name == UiStrings().DefaultServiceName or not preset_is_valid: settings.remove(u'default service name') - self.serviceNameEdit.setText(service_name) + self.service_name_edit.setText(service_name) else: settings.setValue(u'default service name', service_name) - settings.setValue(u'default service day', self.serviceNameDay.currentIndex()) - settings.setValue(u'default service hour', self.serviceNameTime.time().hour()) - settings.setValue(u'default service minute', self.serviceNameTime.time().minute()) - settings.setValue(u'recent file count', self.recentSpinBox.value()) - settings.setValue(u'save current plugin', self.mediaPluginCheckBox.isChecked()) - settings.setValue(u'double click live', self.doubleClickLiveCheckBox.isChecked()) - settings.setValue(u'single click preview', self.singleClickPreviewCheckBox.isChecked()) - settings.setValue(u'expand service item', self.expandServiceItemCheckBox.isChecked()) - settings.setValue(u'enable exit confirmation', self.enableAutoCloseCheckBox.isChecked()) - settings.setValue(u'hide mouse', self.hideMouseCheckBox.isChecked()) - settings.setValue(u'x11 bypass wm', self.x11BypassCheckBox.isChecked()) - settings.setValue(u'default color', self.defaultColor) - settings.setValue(u'default image', self.defaultFileEdit.text()) + settings.setValue(u'default service day', self.service_name_day.currentIndex()) + settings.setValue(u'default service hour', self.service_name_time.time().hour()) + settings.setValue(u'default service minute', self.service_name_time.time().minute()) + settings.setValue(u'recent file count', self.recent_spin_box.value()) + settings.setValue(u'save current plugin', self.media_plugin_check_box.isChecked()) + settings.setValue(u'double click live', self.double_click_live_check_box.isChecked()) + settings.setValue(u'single click preview', self.singleclick_preview_check_box.isChecked()) + settings.setValue(u'expand service item', self.expand_service_item_check_box.isChecked()) + settings.setValue(u'enable exit confirmation', self.enable_auto_close_check_box.isChecked()) + settings.setValue(u'hide mouse', self.hide_mouse_check_box.isChecked()) + settings.setValue(u'x11 bypass wm', self.x11_bypass_check_box.isChecked()) + settings.setValue(u'default color', self.default_color) + settings.setValue(u'default image', self.default_file_edit.text()) settings.setValue(u'slide limits', self.slide_limits) settings.endGroup() - if self.displayChanged: + if self.display_changed: Receiver.send_message(u'config_screen_changed') - self.displayChanged = False + self.display_changed = False Receiver.send_message(u'slidecontroller_update_slide_limits') def cancel(self): + """ + Cancel Pressed. + """ # Dialogue was cancelled, remove any pending data path change. - self.onDataDirectoryCancelButtonClicked() + self.on_data_directory_cancel_button_clicked() SettingsTab.cancel(self) - def serviceNameCheckBoxToggled(self, default_service_enabled): - self.serviceNameDay.setEnabled(default_service_enabled) - time_enabled = default_service_enabled and self.serviceNameDay.currentIndex() is not 7 - self.serviceNameTime.setEnabled(time_enabled) - self.serviceNameEdit.setEnabled(default_service_enabled) - self.serviceNameRevertButton.setEnabled(default_service_enabled) + def service_name_check_box_toggled(self, default_service_enabled): + """ + Service Name options changed + """ + self.service_name_day.setEnabled(default_service_enabled) + time_enabled = default_service_enabled and self.service_name_day.currentIndex() is not 7 + self.service_name_time.setEnabled(time_enabled) + self.service_name_edit.setEnabled(default_service_enabled) + self.service_name_revert_button.setEnabled(default_service_enabled) - def generateServiceNameExample(self): + def generate_service_name_example(self): + """ + Display an example of the template used + """ preset_is_valid = True - if self.serviceNameDay.currentIndex() == 7: + if self.service_name_day.currentIndex() == 7: local_time = datetime.now() else: now = datetime.now() - day_delta = self.serviceNameDay.currentIndex() - now.weekday() + day_delta = self.service_name_day.currentIndex() - now.weekday() if day_delta < 0: day_delta += 7 time = now + timedelta(days=day_delta) - local_time = time.replace(hour = self.serviceNameTime.time().hour(), - minute = self.serviceNameTime.time().minute()) + local_time = time.replace(hour = self.service_name_time.time().hour(), + minute = self.service_name_time.time().minute()) try: - service_name_example = format_time(unicode(self.serviceNameEdit.text()), local_time) + service_name_example = format_time(unicode(self.service_name_edit.text()), local_time) except ValueError: preset_is_valid = False service_name_example = translate('OpenLP.AdvancedTab', 'Syntax error.') return preset_is_valid, service_name_example - def updateServiceNameExample(self, returned_value): - if not self.shouldUpdateServiceNameExample: + def update_service_name_example(self, returned_value): + """ + Example Updated + """ + if not self.should_update_service_name_example: return - name_example = self.generateServiceNameExample()[1] - self.serviceNameExample.setText(name_example) + name_example = self.generate_service_name_example()[1] + self.service_name_example.setText(name_example) - def onServiceNameDayChanged(self, service_day): - self.serviceNameTime.setEnabled(service_day is not 7) - self.updateServiceNameExample(None) + def on_service_name_day_changed(self, service_day): + """ + Service Name day changed + """ + self.service_name_time.setEnabled(service_day is not 7) + self.update_service_name_example(None) - def onServiceNameRevertButtonClicked(self): - self.serviceNameEdit.setText(UiStrings().DefaultServiceName) - self.serviceNameEdit.setFocus() + def on_service_name_revert_button_clicked(self): + """ + Service Name reverted + """ + self.service_name_edit.setText(UiStrings().DefaultServiceName) + self.service_name_edit.setFocus() - def onDefaultColorButtonClicked(self): + def on_default_color_button_clicked(self): + """ + Changed the default color + """ new_color = QtGui.QColorDialog.getColor( - QtGui.QColor(self.defaultColor), self) + QtGui.QColor(self.default_color), self) if new_color.isValid(): - self.defaultColor = new_color.name() - self.defaultColorButton.setStyleSheet(u'background-color: %s' % self.defaultColor) + self.default_color = new_color.name() + self.default_color_button.setStyleSheet(u'background-color: %s' % self.default_color) - def onDefaultBrowseButtonClicked(self): - file_filters = u'%s;;%s (*.*) (*)' % (get_images_filter(), - UiStrings().AllFiles) + def on_default_browse_button_clicked(self): + """ + Service Name options changed + """ + file_filters = u'%s;;%s (*.*) (*)' % (get_images_filter(), UiStrings().AllFiles) filename = QtGui.QFileDialog.getOpenFileName(self, translate('OpenLP.AdvancedTab', 'Open File'), '', file_filters) if filename: - self.defaultFileEdit.setText(filename) - self.defaultFileEdit.setFocus() + self.default_file_edit.setText(filename) + self.default_file_edit.setFocus() - def onDataDirectoryBrowseButtonClicked(self): + def on_data_directory_browse_button_clicked(self): """ Browse for a new data directory location. """ - old_root_path = unicode(self.dataDirectoryLabel.text()) + old_root_path = unicode(self.data_directory_label.text()) # Get the new directory location. new_data_path = QtGui.QFileDialog.getExistingDirectory(self, translate('OpenLP.AdvancedTab', 'Select Data Directory Location'), old_root_path, @@ -512,8 +542,8 @@ class AdvancedTab(SettingsTab): # Set the new data path. if new_data_path: new_data_path = os.path.normpath(new_data_path) - if self.currentDataPath.lower() == new_data_path.lower(): - self.onDataDirectoryCancelButtonClicked() + if self.current_data_path.lower() == new_data_path.lower(): + self.on_data_directory_cancel_button_clicked() return else: return @@ -527,18 +557,18 @@ class AdvancedTab(SettingsTab): if answer != QtGui.QMessageBox.Yes: return # Check if data already exists here. - self.checkDataOverwrite(new_data_path) + self.check_data_overwrite(new_data_path) # Save the new location. Receiver.send_message(u'set_new_data_path', new_data_path) - self.newDataDirectoryEdit.setText(new_data_path) - self.dataDirectoryCancelButton.show() + self.new_data_directory_edit.setText(new_data_path) + self.data_directory_cancel_button.show() - def onDataDirectoryDefaultButtonClicked(self): + def on_data_directory_default_button_clicked(self): """ Re-set the data directory location to the 'default' location. """ new_data_path = AppLocation.get_directory(AppLocation.DataDir) - if self.currentDataPath.lower() != new_data_path.lower(): + if self.current_data_path.lower() != new_data_path.lower(): # Make sure they want to change the data location back to the # default. answer = QtGui.QMessageBox.question(self, @@ -548,29 +578,35 @@ class AdvancedTab(SettingsTab): QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No) if answer != QtGui.QMessageBox.Yes: return - self.checkDataOverwrite(new_data_path) + self.check_data_overwrite(new_data_path) # Save the new location. Receiver.send_message(u'set_new_data_path', new_data_path) - self.newDataDirectoryEdit.setText(os.path.abspath(new_data_path)) - self.dataDirectoryCancelButton.show() + self.new_data_directory_edit.setText(os.path.abspath(new_data_path)) + self.data_directory_cancel_button.show() else: # We cancel the change in case user changed their mind. - self.onDataDirectoryCancelButtonClicked() + self.on_data_directory_cancel_button_clicked() - def onDataDirectoryCopyCheckBoxToggled(self): + def on_data_directory_copy_check_box_toggled(self): + """ + Service Name options changed + """ Receiver.send_message(u'set_copy_data', - self.dataDirectoryCopyCheckBox.isChecked()) - if self.dataExists: - if self.dataDirectoryCopyCheckBox.isChecked(): - self.newDataDirectoryHasFilesLabel.show() + self.data_directory_copy_check_box.isChecked()) + if self.data_exists: + if self.data_directory_copy_check_box.isChecked(): + self.new_data_directory_has_files_label.show() else: - self.newDataDirectoryHasFilesLabel.hide() + self.new_data_directory_has_files_label.hide() - def checkDataOverwrite(self, data_path ): + def check_data_overwrite(self, data_path ): + """ + Service Name options changed + """ test_path = os.path.join(data_path, u'songs') - self.dataDirectoryCopyCheckBox.show() + self.data_directory_copy_check_box.show() if os.path.exists(test_path): - self.dataExists = True + self.data_exists = True # Check is they want to replace existing data. answer = QtGui.QMessageBox.warning(self, translate('OpenLP.AdvancedTab', 'Overwrite Existing Data'), @@ -579,46 +615,58 @@ class AdvancedTab(SettingsTab): ).replace('%s', os.path.abspath(data_path,)), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No) if answer == QtGui.QMessageBox.Yes: - self.dataDirectoryCopyCheckBox.setChecked(True) - self.newDataDirectoryHasFilesLabel.show() + self.data_directory_copy_check_box.setChecked(True) + self.new_data_directory_has_files_label.show() else: - self.dataDirectoryCopyCheckBox.setChecked(False) - self.newDataDirectoryHasFilesLabel.hide() + self.data_directory_copy_check_box.setChecked(False) + self.new_data_directory_has_files_label.hide() else: - self.dataExists = False - self.dataDirectoryCopyCheckBox.setChecked(True) - self.newDataDirectoryHasFilesLabel.hide() + self.data_exists = False + self.data_directory_copy_check_box.setChecked(True) + self.new_data_directory_has_files_label.hide() - def onDataDirectoryCancelButtonClicked(self): + def on_data_directory_cancel_button_clicked(self): """ Cancel the data directory location change """ - self.newDataDirectoryEdit.clear() - self.dataDirectoryCopyCheckBox.setChecked(False) + self.new_data_directory_edit.clear() + self.data_directory_copy_check_box.setChecked(False) Receiver.send_message(u'set_new_data_path', u'') Receiver.send_message(u'set_copy_data', False) - self.dataDirectoryCopyCheckBox.hide() - self.dataDirectoryCancelButton.hide() - self.newDataDirectoryHasFilesLabel.hide() + self.data_directory_copy_check_box.hide() + self.data_directory_cancel_button.hide() + self.new_data_directory_has_files_label.hide() - def onDefaultRevertButtonClicked(self): - self.defaultFileEdit.setText(u':/graphics/openlp-splash-screen.png') - self.defaultFileEdit.setFocus() + def on_default_revert_button_clicked(self): + """ + Service Name options changed + """ + self.default_file_edit.setText(u':/graphics/openlp-splash-screen.png') + self.default_file_edit.setFocus() - def onX11BypassCheckBoxToggled(self, checked): + def on_X11_bypass_check_box_toggled(self, checked): """ Toggle X11 bypass flag on maindisplay depending on check box state. ``checked`` The state of the check box (boolean). """ - self.displayChanged = True + self.display_changed = True - def onEndSlideButtonClicked(self): + def on_end_slide_button_clicked(self): + """ + Stop at the end either top ot bottom + """ self.slide_limits = SlideLimits.End - def onWrapSlideButtonClicked(self): + def on_wrap_slide_button_clicked(self): + """ + Wrap round the service item + """ self.slide_limits = SlideLimits.Wrap - def onnextItemButtonClicked(self): + def on_next_item_button_clicked(self): + """ + Advance to the next service item + """ self.slide_limits = SlideLimits.Next diff --git a/openlp/core/ui/media/playertab.py b/openlp/core/ui/media/playertab.py index eb1a36ca6..4d575dfad 100644 --- a/openlp/core/ui/media/playertab.py +++ b/openlp/core/ui/media/playertab.py @@ -45,10 +45,8 @@ class PlayerTab(SettingsTab): """ MediaTab is the Media settings tab in the settings dialog. """ - def __init__(self, parent, mainWindow): - self.parent = parent - self.mainWindow = mainWindow - self.mediaPlayers = mainWindow.mediaController.mediaPlayers + def __init__(self, parent): + self.mediaPlayers = self.main_window.mediaController.mediaPlayers self.savedUsedPlayers = None self.iconPath = u':/media/multimedia-player.png' player_translated = translate('OpenLP.PlayerTab', 'Players') @@ -194,7 +192,7 @@ class PlayerTab(SettingsTab): set_media_players(self.usedPlayers, override_player) player_string_changed = True if player_string_changed: - self.parent.reset_supported_suffixes() + self.service_manager.reset_supported_suffixes() Receiver.send_message(u'mediaitem_media_rebuild') Receiver.send_message(u'config_screen_changed') diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index fe1023bbf..025d9a32a 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -560,7 +560,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): if success: try: shutil.copy(temp_file_name, path_file_name) - except: + except : return self.save_file_as() self.main_window.addRecentFile(path_file_name) self.set_modified(False) @@ -697,7 +697,8 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): try: ucsfile = zip_info.filename.decode(u'utf-8') except UnicodeDecodeError: - log.exception(u'file_name "%s" is not valid UTF-8' % zip_info.file_name.decode(u'utf-8', u'replace')) + log.exception(u'file_name "%s" is not valid UTF-8' % + zip_info.file_name.decode(u'utf-8', u'replace')) critical_error_message_box(message=translate('OpenLP.ServiceManager', 'File is not a valid service.\n The content encoding is not UTF-8.')) continue @@ -809,7 +810,8 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): delay_suffix = u' %s s' % unicode(service_item[u'service_item'].timed_slide_interval) else: delay_suffix = u' ...' - self.timed_slide_interval.setText(translate('OpenLP.ServiceManager', '&Delay between slides') + delay_suffix) + self.timed_slide_interval.setText(translate('OpenLP.ServiceManager', '&Delay between slides') + + delay_suffix) # TODO for future: make group explains itself more visually else: self.auto_play_slides_group.menuAction().setVisible(False) diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 992128dc3..fe141fd0e 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -54,11 +54,11 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): # General tab self.generalTab = GeneralTab(self) # Themes tab - self.themesTab = ThemesTab(self, self.main_window) + self.themesTab = ThemesTab(self) # Advanced tab self.advancedTab = AdvancedTab(self) # Advanced tab - self.playerTab = PlayerTab(self, self.main_window) + self.playerTab = PlayerTab(self) def exec_(self): # load all the settings diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 1867fe872..db77019fe 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -38,8 +38,7 @@ class ThemesTab(SettingsTab): """ ThemesTab is the theme settings tab in the settings dialog. """ - def __init__(self, parent, mainwindow): - self.mainwindow = mainwindow + def __init__(self, parent): generalTranslated = translate('OpenLP.ThemesTab', 'Themes') SettingsTab.__init__(self, parent, u'Themes', generalTranslated) self.iconPath = u':/themes/theme_new.png' @@ -135,8 +134,8 @@ class ThemesTab(SettingsTab): settings.setValue(u'theme level', self.theme_level) settings.setValue(u'global theme', self.global_theme) settings.endGroup() - self.mainwindow.renderer.set_global_theme(self.global_theme) - self.mainwindow.renderer.set_theme_level(self.theme_level) + self.renderer.set_global_theme(self.global_theme) + self.renderer.set_theme_level(self.theme_level) Receiver.send_message(u'theme_update_global', self.global_theme) def postSetUp(self): @@ -153,7 +152,7 @@ class ThemesTab(SettingsTab): def onDefaultComboBoxChanged(self, value): self.global_theme = self.DefaultComboBox.currentText() - self.mainwindow.renderer.set_global_theme(self.global_theme) + self.renderer.set_global_theme(self.global_theme) self.__previewGlobalTheme() def updateThemeList(self, theme_list): @@ -170,8 +169,8 @@ class ThemesTab(SettingsTab): self.DefaultComboBox.clear() self.DefaultComboBox.addItems(theme_list) find_and_set_in_combo_box(self.DefaultComboBox, self.global_theme) - self.mainwindow.renderer.set_global_theme(self.global_theme) - self.mainwindow.renderer.set_theme_level(self.theme_level) + self.renderer.set_global_theme(self.global_theme) + self.renderer.set_theme_level(self.theme_level) if self.global_theme is not u'': self.__previewGlobalTheme() @@ -179,7 +178,7 @@ class ThemesTab(SettingsTab): """ Utility method to update the global theme preview image. """ - image = self.mainwindow.themeManagerContents.getPreviewImage(self.global_theme) + image = self.main_window.themeManagerContents.getPreviewImage(self.global_theme) preview = QtGui.QPixmap(unicode(image)) if not preview.isNull(): preview = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) From 439fc9b8f069070db2d8468007ef891df61527ca Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 1 Feb 2013 22:36:27 +0200 Subject: [PATCH 26/64] More cleanups --- openlp/core/ui/filerenameform.py | 9 ++- openlp/core/ui/firsttimeform.py | 28 ++++++++-- openlp/core/ui/firsttimelanguagedialog.py | 14 ++++- openlp/core/ui/firsttimelanguageform.py | 16 +++++- openlp/core/ui/firsttimewizard.py | 25 +++++++-- openlp/core/ui/formattingtagdialog.py | 14 ++++- openlp/core/ui/formattingtagform.py | 9 ++- openlp/core/ui/generaltab.py | 4 ++ openlp/core/ui/maindisplay.py | 44 ++++++++++++--- openlp/core/ui/mainwindow.py | 67 +++++++++++++++++++---- 10 files changed, 192 insertions(+), 38 deletions(-) diff --git a/openlp/core/ui/filerenameform.py b/openlp/core/ui/filerenameform.py index d13cf5519..0743578a1 100644 --- a/openlp/core/ui/filerenameform.py +++ b/openlp/core/ui/filerenameform.py @@ -26,6 +26,9 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +""" +The file rename dialog. +""" from PyQt4 import QtGui @@ -33,11 +36,15 @@ from filerenamedialog import Ui_FileRenameDialog from openlp.core.lib import translate + class FileRenameForm(QtGui.QDialog, Ui_FileRenameDialog): """ - The exception dialog + The file rename dialog """ def __init__(self, parent): + """ + Constructor + """ QtGui.QDialog.__init__(self, parent) self.setupUi(self) diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 95ae35d5d..1829780d1 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -26,7 +26,9 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +This module contains the first time wizard. +""" import io import logging import os @@ -45,14 +47,15 @@ from firsttimewizard import Ui_FirstTimeWizard, FirstTimePage log = logging.getLogger(__name__) + class ThemeScreenshotThread(QtCore.QThread): """ This thread downloads the theme screenshots. """ - def __init__(self, parent): - QtCore.QThread.__init__(self, parent) - def run(self): + """ + Overridden method to run the thread. + """ themes = self.parent().config.get(u'themes', u'files') themes = themes.split(u',') config = self.parent().config @@ -79,7 +82,10 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): log.info(u'ThemeWizardForm loaded') def __init__(self, screens, parent=None): - QtGui.QWizard.__init__(self, parent) + """ + Create and set up the first time wizard. + """ + super(FirstTimeForm, self).__init__(parent) self.setupUi(self) self.screens = screens # check to see if we have web access @@ -297,11 +303,20 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): screenshot))) def _getFileSize(self, url): + """ + Get the size of a file. + + ``url`` + The URL of the file we want to download. + """ site = urllib.urlopen(url) meta = site.info() return int(meta.getheaders("Content-Length")[0]) def _downloadProgress(self, count, block_size): + """ + Calculate and display the download progress. + """ increment = (count * block_size) - self.previous_size self._incrementProgressBar(None, increment) self.previous_size = count * block_size @@ -459,5 +474,8 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): Settings().setValue(u'themes/global theme', self.themeComboBox.currentText()) def _setPluginStatus(self, field, tag): + """ + Set the status of a plugin. + """ status = PluginStatus.Active if field.checkState() == QtCore.Qt.Checked else PluginStatus.Inactive Settings().setValue(tag, status) diff --git a/openlp/core/ui/firsttimelanguagedialog.py b/openlp/core/ui/firsttimelanguagedialog.py index eae9dc198..21f4dabcd 100644 --- a/openlp/core/ui/firsttimelanguagedialog.py +++ b/openlp/core/ui/firsttimelanguagedialog.py @@ -26,14 +26,23 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The UI widgets of the language selection dialog. +""" from PyQt4 import QtGui from openlp.core.lib import translate from openlp.core.lib.ui import create_button_box + class Ui_FirstTimeLanguageDialog(object): + """ + The UI widgets of the language selection dialog. + """ def setupUi(self, languageDialog): + """ + Set up the UI. + """ languageDialog.setObjectName(u'languageDialog') languageDialog.resize(300, 50) self.dialogLayout = QtGui.QVBoxLayout(languageDialog) @@ -59,6 +68,9 @@ class Ui_FirstTimeLanguageDialog(object): self.setMaximumHeight(self.sizeHint().height()) def retranslateUi(self, languageDialog): + """ + Translate the UI on the fly. + """ self.setWindowTitle(translate('OpenLP.FirstTimeLanguageForm', 'Select Translation')) self.infoLabel.setText( translate('OpenLP.FirstTimeLanguageForm', 'Choose the translation you\'d like to use in OpenLP.')) diff --git a/openlp/core/ui/firsttimelanguageform.py b/openlp/core/ui/firsttimelanguageform.py index c3bf4a07c..8689117d0 100644 --- a/openlp/core/ui/firsttimelanguageform.py +++ b/openlp/core/ui/firsttimelanguageform.py @@ -26,18 +26,24 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The language selection dialog. +""" from PyQt4 import QtGui from openlp.core.lib.ui import create_action from openlp.core.utils import LanguageManager from firsttimelanguagedialog import Ui_FirstTimeLanguageDialog + class FirstTimeLanguageForm(QtGui.QDialog, Ui_FirstTimeLanguageDialog): """ - The exception dialog + The language selection dialog. """ def __init__(self, parent=None): + """ + Constructor + """ QtGui.QDialog.__init__(self, parent) self.setupUi(self) self.qmList = LanguageManager.get_qm_list() @@ -52,6 +58,9 @@ class FirstTimeLanguageForm(QtGui.QDialog, Ui_FirstTimeLanguageDialog): return QtGui.QDialog.exec_(self) def accept(self): + """ + Run when the dialog is OKed. + """ # It's the first row so must be Automatic if self.languageComboBox.currentIndex() == 0: LanguageManager.auto_language = True @@ -63,6 +72,9 @@ class FirstTimeLanguageForm(QtGui.QDialog, Ui_FirstTimeLanguageDialog): return QtGui.QDialog.accept(self) def reject(self): + """ + Run when the dialog is canceled. + """ LanguageManager.auto_language = True LanguageManager.set_language(False, False) return QtGui.QDialog.reject(self) diff --git a/openlp/core/ui/firsttimewizard.py b/openlp/core/ui/firsttimewizard.py index 2c1e9e0da..1602b5254 100644 --- a/openlp/core/ui/firsttimewizard.py +++ b/openlp/core/ui/firsttimewizard.py @@ -26,7 +26,9 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The UI widgets for the first time wizard. +""" from PyQt4 import QtCore, QtGui import sys @@ -34,7 +36,11 @@ import sys from openlp.core.lib import translate from openlp.core.lib.ui import add_welcome_page + class FirstTimePage(object): + """ + An enumeration class with each of the pages of the wizard. + """ Welcome = 0 Plugins = 1 NoInternet = 2 @@ -46,13 +52,19 @@ class FirstTimePage(object): class Ui_FirstTimeWizard(object): + """ + The UI widgets for the first time wizard. + """ def setupUi(self, FirstTimeWizard): + """ + Set up the UI. + """ FirstTimeWizard.setObjectName(u'FirstTimeWizard') FirstTimeWizard.resize(550, 386) FirstTimeWizard.setModal(True) FirstTimeWizard.setWizardStyle(QtGui.QWizard.ModernStyle) FirstTimeWizard.setOptions(QtGui.QWizard.IndependentPages | QtGui.QWizard.NoBackButtonOnStartPage | - QtGui.QWizard.NoBackButtonOnLastPage |QtGui.QWizard.HaveCustomButton1) + QtGui.QWizard.NoBackButtonOnLastPage | QtGui.QWizard.HaveCustomButton1) self.finishButton = self.button(QtGui.QWizard.FinishButton) self.noInternetFinishButton = self.button(QtGui.QWizard.CustomButton1) self.cancelButton = self.button(QtGui.QWizard.CancelButton) @@ -193,17 +205,20 @@ class Ui_FirstTimeWizard(object): self.retranslateUi(FirstTimeWizard) def retranslateUi(self, FirstTimeWizard): + """ + Translate the UI on the fly + """ FirstTimeWizard.setWindowTitle(translate( 'OpenLP.FirstTimeWizard', 'First Time Wizard')) - self.titleLabel.setText(u'%s' % \ + self.titleLabel.setText(u'%s' % translate('OpenLP.FirstTimeWizard', 'Welcome to the First Time Wizard')) self.informationLabel.setText(translate('OpenLP.FirstTimeWizard', 'This wizard will help you to configure OpenLP for initial use.' ' Click the next button below to start.')) self.pluginPage.setTitle(translate('OpenLP.FirstTimeWizard', 'Activate required Plugins')) - self.pluginPage.setSubTitle(translate('OpenLP.FirstTimeWizard','Select the Plugins you wish to use. ')) + self.pluginPage.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Select the Plugins you wish to use. ')) self.songsCheckBox.setText(translate('OpenLP.FirstTimeWizard', 'Songs')) - self.customCheckBox.setText(translate('OpenLP.FirstTimeWizard','Custom Slides')) + self.customCheckBox.setText(translate('OpenLP.FirstTimeWizard', 'Custom Slides')) self.bibleCheckBox.setText(translate('OpenLP.FirstTimeWizard', 'Bible')) self.imageCheckBox.setText(translate('OpenLP.FirstTimeWizard', 'Images')) # TODO Presentation plugin is not yet working on Mac OS X. diff --git a/openlp/core/ui/formattingtagdialog.py b/openlp/core/ui/formattingtagdialog.py index c9cdb15df..fbf5707ed 100644 --- a/openlp/core/ui/formattingtagdialog.py +++ b/openlp/core/ui/formattingtagdialog.py @@ -26,7 +26,9 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The UI widgets for the formatting tags window. +""" from PyQt4 import QtCore, QtGui from openlp.core.lib import translate, UiStrings @@ -34,8 +36,13 @@ from openlp.core.lib.ui import create_button_box class Ui_FormattingTagDialog(object): - + """ + The UI widgets for the formatting tags window. + """ def setupUi(self, formattingTagDialog): + """ + Set up the UI + """ formattingTagDialog.setObjectName(u'formattingTagDialog') formattingTagDialog.resize(725, 548) self.listdataGridLayout = QtGui.QGridLayout(formattingTagDialog) @@ -116,6 +123,9 @@ class Ui_FormattingTagDialog(object): self.retranslateUi(formattingTagDialog) def retranslateUi(self, formattingTagDialog): + """ + Translate the UI on the fly + """ formattingTagDialog.setWindowTitle(translate('OpenLP.FormattingTagDialog', 'Configure Formatting Tags')) self.editGroupBox.setTitle(translate('OpenLP.FormattingTagDialog', 'Edit Selection')) self.savePushButton.setText(translate('OpenLP.FormattingTagDialog', 'Save')) diff --git a/openlp/core/ui/formattingtagform.py b/openlp/core/ui/formattingtagform.py index 2e72bdd65..1085afbcd 100644 --- a/openlp/core/ui/formattingtagform.py +++ b/openlp/core/ui/formattingtagform.py @@ -27,10 +27,9 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`formattingtagform` provides an Tag Edit facility. The Base set are -protected and included each time loaded. Custom tags can be defined and saved. -The Custom Tag arrays are saved in a pickle so QSettings works on them. Base -Tags cannot be changed. +The :mod:`formattingtagform` provides an Tag Edit facility. The Base set are protected and included each time loaded. +Custom tags can be defined and saved. The Custom Tag arrays are saved in a pickle so QSettings works on them. Base Tags +cannot be changed. """ from PyQt4 import QtCore, QtGui @@ -49,7 +48,7 @@ class FormattingTagForm(QtGui.QDialog, Ui_FormattingTagDialog): """ QtGui.QDialog.__init__(self, parent) self.setupUi(self) - QtCore.QObject.connect(self.tagTableWidget, QtCore.SIGNAL(u'itemSelectionChanged()'),self.onRowSelected) + QtCore.QObject.connect(self.tagTableWidget, QtCore.SIGNAL(u'itemSelectionChanged()'), self.onRowSelected) QtCore.QObject.connect(self.newPushButton, QtCore.SIGNAL(u'clicked()'), self.onNewClicked) QtCore.QObject.connect(self.savePushButton, QtCore.SIGNAL(u'clicked()'), self.onSavedClicked) QtCore.QObject.connect(self.deletePushButton, QtCore.SIGNAL(u'clicked()'), self.onDeleteClicked) diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 31a07037a..4626d36d2 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -26,6 +26,9 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +""" +The general tab of the configuration dialog. +""" import logging from PyQt4 import QtCore, QtGui @@ -34,6 +37,7 @@ from openlp.core.lib import Receiver, Settings, SettingsTab, translate, ScreenLi log = logging.getLogger(__name__) + class GeneralTab(SettingsTab): """ GeneralTab is the general settings tab in the settings dialog. diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 3fed96ec4..400d82f5b 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -27,12 +27,16 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`maindisplay` module provides the functionality to display screens -and play multimedia within OpenLP. +The :mod:`maindisplay` module provides the functionality to display screens and play multimedia within OpenLP. + +Some of the code for this form is based on the examples at: + +* `http://www.steveheffernan.com/html5-video-player/demo-video-player.html`_ +* `http://html5demos.com/two-videos`_ + """ import cgi import logging -import os import sys from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL @@ -47,8 +51,6 @@ from openlp.core.ui import HideMode, AlertLocation log = logging.getLogger(__name__) -#http://www.steveheffernan.com/html5-video-player/demo-video-player.html -#http://html5demos.com/two-videos class Display(QtGui.QGraphicsView): """ @@ -57,6 +59,9 @@ class Display(QtGui.QGraphicsView): Preview display. """ def __init__(self, parent, live, controller): + """ + Constructor + """ if live: QtGui.QGraphicsView.__init__(self) # Overwrite the parent() method. @@ -101,6 +106,9 @@ class Display(QtGui.QGraphicsView): QtCore.Qt.ScrollBarAlwaysOff) def resizeEvent(self, event): + """ + React to resizing of this display + """ self.webView.setGeometry(0, 0, self.width(), self.height()) def isWebLoaded(self): @@ -116,6 +124,9 @@ class MainDisplay(Display): This is the display screen as a specialized class from the Display class """ def __init__(self, parent, live, controller): + """ + Constructor + """ Display.__init__(self, parent, live, controller) self.screens = ScreenList() self.rebuildCSS = False @@ -153,6 +164,9 @@ class MainDisplay(Display): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.configChanged) def setTransparency(self, enabled): + """ + Set the transparency of the window + """ if enabled: self.setAutoFillBackground(False) else: @@ -386,7 +400,9 @@ class MainDisplay(Display): BackgroundType.to_string(BackgroundType.Transparent)) if self.serviceItem.themedata.background_filename: self.serviceItem.bg_image_bytes = self.image_manager.getImageBytes( - self.serviceItem.themedata.background_filename,ImageSource.Theme) + self.serviceItem.themedata.background_filename, + ImageSource.Theme + ) if image_path: image_bytes = self.image_manager.getImageBytes(image_path, ImageSource.ImagePlugin) else: @@ -532,6 +548,9 @@ class AudioPlayer(QtCore.QObject): self.mediaObject.enqueue(self.playlist[self.currentIndex]) def onFinished(self): + """ + When the audio track finishes. + """ if self.repeat: log.debug(u'Repeat is enabled... here we go again!') self.mediaObject.clearQueue() @@ -540,6 +559,9 @@ class AudioPlayer(QtCore.QObject): self.play() def connectVolumeSlider(self, slider): + """ + Connect the volume slider to the output channel. + """ slider.setAudioOutput(self.audioObject) def reset(self): @@ -586,6 +608,9 @@ class AudioPlayer(QtCore.QObject): self.playlist.extend(map(Phonon.MediaSource, filenames)) def next(self): + """ + Skip forward to the next track in the list + """ if not self.repeat and self.currentIndex + 1 >= len(self.playlist): return isPlaying = self.mediaObject.state() == Phonon.PlayingState @@ -599,6 +624,9 @@ class AudioPlayer(QtCore.QObject): self.mediaObject.play() def goTo(self, index): + """ + Go to a particular track in the list + """ isPlaying = self.mediaObject.state() == Phonon.PlayingState self.mediaObject.clearQueue() self.mediaObject.clear() @@ -609,5 +637,7 @@ class AudioPlayer(QtCore.QObject): #@todo is this used? def connectSlot(self, signal, slot): + """ + Connect a slot to a signal on the media object + """ QtCore.QObject.connect(self.mediaObject, signal, slot) - diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 77e954943..32058cce9 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -26,7 +26,9 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +This is the main window, where all the action happens. +""" import logging import os import sys @@ -80,6 +82,9 @@ PROGRESSBAR_STYLE = """ class Ui_MainWindow(object): + """ + This is the UI part of the main window. + """ def setupUi(self, mainWindow): """ Set up the user interface @@ -148,7 +153,7 @@ class Ui_MainWindow(object): self.defaultThemeLabel.setObjectName(u'defaultThemeLabel') self.statusBar.addPermanentWidget(self.defaultThemeLabel) # Create the MediaManager - self.mediaManagerDock = OpenLPDockWidget(mainWindow,u'mediaManagerDock', u':/system/system_mediamanager.png') + self.mediaManagerDock = OpenLPDockWidget(mainWindow, u'mediaManagerDock', u':/system/system_mediamanager.png') self.mediaManagerDock.setStyleSheet(MEDIA_MANAGER_STYLE) # Create the media toolbox self.mediaToolBox = QtGui.QToolBox(self.mediaManagerDock) @@ -406,7 +411,8 @@ class Ui_MainWindow(object): 'Toggle the visibility of the service manager.')) self.viewPreviewPanel.setText(translate('OpenLP.MainWindow', '&Preview Panel')) self.viewPreviewPanel.setToolTip(translate('OpenLP.MainWindow', 'Toggle Preview Panel')) - self.viewPreviewPanel.setStatusTip(translate('OpenLP.MainWindow', 'Toggle the visibility of the preview panel.')) + self.viewPreviewPanel.setStatusTip( + translate('OpenLP.MainWindow', 'Toggle the visibility of the preview panel.')) self.viewLivePanel.setText(translate('OpenLP.MainWindow', '&Live Panel')) self.viewLivePanel.setToolTip(translate('OpenLP.MainWindow', 'Toggle Live Panel')) self.lockPanel.setText(translate('OpenLP.MainWindow', 'L&ock Panels')) @@ -517,7 +523,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.onSettingsShortcutsItemClicked) QtCore.QObject.connect(self.settingsImportItem, QtCore.SIGNAL(u'triggered()'), self.onSettingsImportItemClicked) - QtCore.QObject.connect(self.settingsExportItem,QtCore.SIGNAL(u'triggered()'), self.onSettingsExportItemClicked) + QtCore.QObject.connect(self.settingsExportItem, QtCore.SIGNAL(u'triggered()'), self.onSettingsExportItemClicked) # i18n set signals for languages self.languageGroup.triggered.connect(LanguageManager.set_language) QtCore.QObject.connect(self.modeDefaultItem, QtCore.SIGNAL(u'triggered()'), self.onModeDefaultItemClicked) @@ -527,7 +533,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_version_check'), self.versionNotice) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_display_blank_check'), self.blankCheck) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'), self.screenChanged) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'mainwindow_status_text'), self.showStatusMessage) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'mainwindow_status_text'), + self.showStatusMessage) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'cleanup'), self.clean_up) # Media Manager QtCore.QObject.connect(self.mediaToolBox, QtCore.SIGNAL(u'currentChanged(int)'), self.onMediaToolBoxChanged) @@ -583,11 +590,17 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Receiver.send_message(u'cursor_normal') def setAutoLanguage(self, value): + """ + Set the language to automatic. + """ self.languageGroup.setDisabled(value) LanguageManager.auto_language = value LanguageManager.set_language(self.languageGroup.checkedAction()) def onMediaToolBoxChanged(self, index): + """ + Focus a widget when the media toolbox changes. + """ widget = self.mediaToolBox.widget(index) if widget: widget.onFocus() @@ -642,7 +655,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Receiver.send_message(u'openlp_process_events') def firstTime(self): - # Import themes if first time + """ + Import themes if first time + """ Receiver.send_message(u'openlp_process_events') for plugin in self.pluginManager.plugins: if hasattr(plugin, u'firstTime'): @@ -705,14 +720,23 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): translate('OpenLP.MainWindow', 'The Main Display has been blanked out')) def onErrorMessage(self, data): + """ + Display an error message + """ Receiver.send_message(u'close_splash') QtGui.QMessageBox.critical(self, data[u'title'], data[u'message']) def onWarningMessage(self, data): + """ + Display a warning message + """ Receiver.send_message(u'close_splash') QtGui.QMessageBox.warning(self, data[u'title'], data[u'message']) def onInformationMessage(self, data): + """ + Display an informational message + """ Receiver.send_message(u'close_splash') QtGui.QMessageBox.information(self, data[u'title'], data[u'message']) @@ -800,8 +824,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtGui.QMessageBox.No) if answer == QtGui.QMessageBox.No: return - import_file_name = QtGui.QFileDialog.getOpenFileName(self,translate('OpenLP.MainWindow', 'Open File'), '', - translate('OpenLP.MainWindow', 'OpenLP Export Settings Files (*.conf)')) + import_file_name = QtGui.QFileDialog.getOpenFileName(self, translate('OpenLP.MainWindow', 'Open File'), '', + translate('OpenLP.MainWindow', 'OpenLP Export Settings Files (*.conf)')) if not import_file_name: return setting_sections = [] @@ -1100,18 +1124,33 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.setWindowTitle(title) def showStatusMessage(self, message): + """ + Show a message in the status bar + """ self.statusBar.showMessage(message) def defaultThemeChanged(self, theme): + """ + Update the default theme indicator in the status bar + """ self.defaultThemeLabel.setText(translate('OpenLP.MainWindow', 'Default Theme: %s') % theme) def toggleMediaManager(self): + """ + Toggle the visibility of the media manager + """ self.mediaManagerDock.setVisible(not self.mediaManagerDock.isVisible()) def toggleServiceManager(self): + """ + Toggle the visibility of the service manager + """ self.serviceManagerDock.setVisible(not self.serviceManagerDock.isVisible()) def toggleThemeManager(self): + """ + Toggle the visibility of the theme manager + """ self.themeManagerDock.setVisible(not self.themeManagerDock.isVisible()) def setPreviewPanelVisibility(self, visible): @@ -1295,13 +1334,22 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Receiver.send_message(u'openlp_process_events') def setNewDataPath(self, new_data_path): + """ + Set the new data path + """ self.newDataPath = new_data_path def setCopyData(self, copy_data): + """ + Set the flag to copy the data + """ self.copyData = copy_data def changeDataDirectory(self): - log.info(u'Changing data path to %s' % self.newDataPath ) + """ + Change the data directory. + """ + log.info(u'Changing data path to %s' % self.newDataPath) old_data_path = unicode(AppLocation.get_data_path()) # Copy OpenLP data to new location if requested. if self.copyData: @@ -1330,4 +1378,3 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # Check if the new data path is our default. if self.newDataPath == AppLocation.get_directory(AppLocation.DataDir): settings.remove(u'advanced/data path') - From 4c26ff8f803b2ce9773ccb6af4a90d525d840b4c Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 1 Feb 2013 20:40:23 +0000 Subject: [PATCH 27/64] Cleaned up ServiceManager --- openlp/core/ui/__init__.py | 5 +- openlp/core/ui/mainwindow.py | 4 +- openlp/core/ui/servicemanager.py | 255 ++--------------------- openlp/core/ui/servicemanagerdialog.py | 268 +++++++++++++++++++++++++ openlp/core/ui/thememanager.py | 4 +- 5 files changed, 287 insertions(+), 249 deletions(-) create mode 100644 openlp/core/ui/servicemanagerdialog.py diff --git a/openlp/core/ui/__init__.py b/openlp/core/ui/__init__.py index a0065966b..593404206 100644 --- a/openlp/core/ui/__init__.py +++ b/openlp/core/ui/__init__.py @@ -98,9 +98,10 @@ from settingsform import SettingsForm from formattingtagform import FormattingTagForm from shortcutlistform import ShortcutListForm from mediadockmanager import MediaDockManager +from servicemanagerdialog import ServiceManagerDialog from servicemanager import ServiceManager from thememanager import ThemeManager __all__ = ['SplashScreen', 'AboutForm', 'SettingsForm', 'MainDisplay', - 'SlideController', 'ServiceManager', 'ThemeManager', 'MediaDockManager', - 'ServiceItemEditForm', 'FirstTimeForm'] + 'SlideController', 'ServiceManagerDialog', 'ServiceManager', 'ThemeManager', 'MediaDockManager', + 'ServiceItemEditForm', 'FirstTimeForm' ] diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 77e954943..2ea5b5a79 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -578,7 +578,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): log.info(u'Load Themes') self.themeManagerContents.loadThemes(True) # Hide/show the theme combobox on the service manager - self.serviceManagerContents.themeChange() + self.serviceManagerContents.theme_change() # Reset the cursor Receiver.send_message(u'cursor_normal') @@ -1040,7 +1040,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): while self.imageManager.imageThread.isRunning(): time.sleep(0.1) # Clean temporary files used by services - self.serviceManagerContents.cleanUp() + self.serviceManagerContents.clean_up() if save_settings: if Settings().value(u'advanced/save current plugin'): Settings().setValue(u'advanced/current media plugin', self.mediaToolBox.currentIndex()) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 025d9a32a..77082f2d3 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -39,244 +39,13 @@ log = logging.getLogger(__name__) from PyQt4 import QtCore, QtGui -from openlp.core.lib import OpenLPToolbar, ServiceItem, Receiver, build_icon, ItemCapabilities, SettingsManager, \ +from openlp.core.lib import ServiceItem, Receiver, build_icon, ItemCapabilities, SettingsManager, \ translate, str_to_bool, check_directory_exists, Settings, PluginStatus, Registry, UiStrings from openlp.core.lib.theme import ThemeLevel from openlp.core.lib.ui import critical_error_message_box, create_widget_action, find_and_set_in_combo_box -from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm +from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm, ServiceManagerDialog from openlp.core.ui.printserviceform import PrintServiceForm -from openlp.core.utils import AppLocation, delete_file, split_filename, format_time -from openlp.core.utils.actions import ActionList, CategoryOrder - -class ServiceManagerList(QtGui.QTreeWidget): - """ - Set up key bindings and mouse behaviour for the service list - """ - def __init__(self, serviceManager, parent=None): - QtGui.QTreeWidget.__init__(self, parent) - self.serviceManager = serviceManager - - def keyPressEvent(self, event): - """ - Capture Key press and respond accordingly. - """ - if isinstance(event, QtGui.QKeyEvent): - # here accept the event and do something - if event.key() == QtCore.Qt.Key_Up: - self.serviceManager.on_move_selection_up() - event.accept() - elif event.key() == QtCore.Qt.Key_Down: - self.serviceManager.on_move_selection_down() - event.accept() - elif event.key() == QtCore.Qt.Key_Delete: - self.serviceManager.onDeleteFromService() - event.accept() - event.ignore() - else: - event.ignore() - - def mouseMoveEvent(self, event): - """ - Drag and drop event does not care what data is selected - as the recipient will use events to request the data move - just tell it what plugin to call - """ - if event.buttons() != QtCore.Qt.LeftButton: - event.ignore() - return - if not self.itemAt(self.mapFromGlobal(QtGui.QCursor.pos())): - event.ignore() - return - drag = QtGui.QDrag(self) - mime_data = QtCore.QMimeData() - drag.setMimeData(mime_data) - mime_data.setText(u'ServiceManager') - drag.start(QtCore.Qt.CopyAction) - -class ServiceManagerDialog(object): - """ - """ - def setup_ui(self,widget): - # Create the top toolbar - self.toolbar = OpenLPToolbar(self) - self.toolbar.addToolbarAction(u'newService', text=UiStrings().NewService, icon=u':/general/general_new.png', - tooltip=UiStrings().CreateService, triggers=self.on_new_service_clicked) - self.toolbar.addToolbarAction(u'openService', text=UiStrings().OpenService, icon=u':/general/general_open.png', - tooltip=translate('OpenLP.ServiceManager', 'Load an existing service.'), triggers=self.on_load_service_clicked) - self.toolbar.addToolbarAction(u'saveService', text=UiStrings().SaveService, icon=u':/general/general_save.png', - tooltip=translate('OpenLP.ServiceManager', 'Save this service.'), triggers=self.decide_save_method) - self.toolbar.addSeparator() - self.theme_label = QtGui.QLabel(u'%s:' % UiStrings().Theme, self) - self.theme_label.setMargin(3) - self.theme_label.setObjectName(u'theme_label') - self.toolbar.addToolbarWidget(self.theme_label) - self.theme_combo_box = QtGui.QComboBox(self.toolbar) - self.theme_combo_box.setToolTip(translate('OpenLP.ServiceManager', 'Select a theme for the service.')) - self.theme_combo_box.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength) - self.theme_combo_box.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) - self.theme_combo_box.setObjectName(u'theme_combo_box') - self.toolbar.addToolbarWidget(self.theme_combo_box) - self.toolbar.setObjectName(u'toolbar') - self.layout.addWidget(self.toolbar) - # Create the service manager list - self.service_manager_list = ServiceManagerList(self) - self.service_manager_list.setEditTriggers( - QtGui.QAbstractItemView.CurrentChanged | - QtGui.QAbstractItemView.DoubleClicked | - QtGui.QAbstractItemView.EditKeyPressed) - self.service_manager_list.setDragDropMode(QtGui.QAbstractItemView.DragDrop) - self.service_manager_list.setAlternatingRowColors(True) - self.service_manager_list.setHeaderHidden(True) - self.service_manager_list.setExpandsOnDoubleClick(False) - self.service_manager_list.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) - QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL('customContextMenuRequested(QPoint)'), - self.context_menu) - self.service_manager_list.setObjectName(u'service_manager_list') - # enable drop - self.service_manager_list.__class__.dragEnterEvent = self.drag_enter_event - self.service_manager_list.__class__.dragMoveEvent = self.drag_enter_event - self.service_manager_list.__class__.dropEvent = self.drop_event - self.layout.addWidget(self.service_manager_list) - # Add the bottom toolbar - self.order_toolbar = OpenLPToolbar(self) - action_list = ActionList.get_instance() - action_list.add_category(UiStrings().Service, CategoryOrder.standardToolbar) - self.service_manager_list.moveTop = self.order_toolbar.addToolbarAction(u'moveTop', - text=translate('OpenLP.ServiceManager', 'Move to &top'), icon=u':/services/service_top.png', - tooltip=translate('OpenLP.ServiceManager', 'Move item to the top of the service.'), - shortcuts=[QtCore.Qt.Key_Home], category=UiStrings().Service, triggers=self.onServiceTop) - self.service_manager_list.moveUp = self.order_toolbar.addToolbarAction(u'moveUp', - text=translate('OpenLP.ServiceManager', 'Move &up'), icon=u':/services/service_up.png', - tooltip=translate('OpenLP.ServiceManager', 'Move item up one position in the service.'), - shortcuts=[QtCore.Qt.Key_PageUp], category=UiStrings().Service, triggers=self.onServiceUp) - self.service_manager_list.moveDown = self.order_toolbar.addToolbarAction(u'moveDown', - text=translate('OpenLP.ServiceManager', 'Move &down'), icon=u':/services/service_down.png', - tooltip=translate('OpenLP.ServiceManager', 'Move item down one position in the service.'), - shortcuts=[QtCore.Qt.Key_PageDown], category=UiStrings().Service, triggers=self.onServiceDown) - self.service_manager_list.moveBottom = self.order_toolbar.addToolbarAction(u'moveBottom', - text=translate('OpenLP.ServiceManager', 'Move to &bottom'), icon=u':/services/service_bottom.png', - tooltip=translate('OpenLP.ServiceManager', 'Move item to the end of the service.'), - shortcuts=[QtCore.Qt.Key_End], category=UiStrings().Service, triggers=self.onServiceEnd) - self.service_manager_list.down = self.order_toolbar.addToolbarAction(u'down', - text=translate('OpenLP.ServiceManager', 'Move &down'), - tooltip=translate('OpenLP.ServiceManager', 'Moves the selection down the window.'), visible=False, - shortcuts=[QtCore.Qt.Key_Down], triggers=self.on_move_selection_down) - action_list.add_action(self.service_manager_list.down) - self.service_manager_list.up = self.order_toolbar.addToolbarAction(u'up', - text=translate('OpenLP.ServiceManager', 'Move up'), tooltip=translate('OpenLP.ServiceManager', - 'Moves the selection up the window.'), visible=False, shortcuts=[QtCore.Qt.Key_Up], - triggers=self.on_move_selection_up) - action_list.add_action(self.service_manager_list.up) - self.order_toolbar.addSeparator() - self.service_manager_list.delete = self.order_toolbar.addToolbarAction(u'delete', - text=translate('OpenLP.ServiceManager', '&Delete From Service'), icon=u':/general/general_delete.png', - tooltip=translate('OpenLP.ServiceManager', 'Delete the selected item from the service.'), - shortcuts=[QtCore.Qt.Key_Delete], triggers=self.onDeleteFromService) - self.order_toolbar.addSeparator() - self.service_manager_list.expand = self.order_toolbar.addToolbarAction(u'expand', - text=translate('OpenLP.ServiceManager', '&Expand all'), icon=u':/services/service_expand_all.png', - tooltip=translate('OpenLP.ServiceManager', 'Expand all the service items.'), - shortcuts=[QtCore.Qt.Key_Plus], category=UiStrings().Service, triggers=self.onExpandAll) - self.service_manager_list.collapse = self.order_toolbar.addToolbarAction(u'collapse', - text=translate('OpenLP.ServiceManager', '&Collapse all'), icon=u':/services/service_collapse_all.png', - tooltip=translate('OpenLP.ServiceManager', 'Collapse all the service items.'), - shortcuts=[QtCore.Qt.Key_Minus], category=UiStrings().Service, triggers=self.onCollapseAll) - self.order_toolbar.addSeparator() - self.service_manager_list.make_live = self.order_toolbar.addToolbarAction(u'make_live', - text=translate('OpenLP.ServiceManager', 'Go Live'), icon=u':/general/general_live.png', - tooltip=translate('OpenLP.ServiceManager', 'Send the selected item to Live.'), - shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return], category=UiStrings().Service, triggers=self.make_live) - self.layout.addWidget(self.order_toolbar) - # Connect up our signals and slots - QtCore.QObject.connect(self.theme_combo_box, QtCore.SIGNAL(u'activated(int)'), - self.on_theme_combo_box_selected) - QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), - self.on_make_live) - QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL(u'itemCollapsed(QTreeWidgetItem*)'), - self.collapsed) - QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL(u'itemExpanded(QTreeWidgetItem*)'), - self.expanded) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.update_theme_list) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_preview_live'), - self.preview_live) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_next_item'), self.next_item) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_previous_item'), - self.previous_item) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_set_item'), self.on_set_item) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.config_updated) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'), - self.regenerate_service_Items) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_global'), self.themeChange) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'service_item_update'), self.serviceItemUpdate) - # Last little bits of setting up - self.service_theme = Settings().value(self.main_window.serviceManagerSettingsSection + u'/service theme') - self.servicePath = AppLocation.get_section_data_path(u'servicemanager') - # build the drag and drop context menu - self.dndMenu = QtGui.QMenu() - self.newAction = self.dndMenu.addAction(translate('OpenLP.ServiceManager', '&Add New Item')) - self.newAction.setIcon(build_icon(u':/general/general_edit.png')) - self.addToAction = self.dndMenu.addAction(translate('OpenLP.ServiceManager', '&Add to Selected Item')) - self.addToAction.setIcon(build_icon(u':/general/general_edit.png')) - # build the context menu - self.menu = QtGui.QMenu() - self.edit_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Edit Item'), - icon=u':/general/general_edit.png', triggers=self.remote_edit) - self.maintain_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Reorder Item'), - icon=u':/general/general_edit.png', triggers=self.on_service_item_edit_form) - self.notes_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Notes'), - icon=u':/services/service_notes.png', triggers=self.on_service_item_note_form) - self.time_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Start Time'), - icon=u':/media/media_time.png', triggers=self.on_start_time_form) - self.auto_start_action = create_widget_action(self.menu, text=u'', - icon=u':/media/auto-start_active.png', triggers=self.on_auto_start) - # Add already existing delete action to the menu. - self.menu.addAction(self.service_manager_list.delete) - self.create_custom_action = create_widget_action(self.menu, - text=translate('OpenLP.ServiceManager', 'Create New &Custom Slide'), - icon=u':/general/general_edit.png', triggers=self.create_custom) - self.menu.addSeparator() - # Add AutoPlay menu actions - self.auto_play_slides_group = QtGui.QMenu(translate('OpenLP.ServiceManager', '&Auto play slides')) - self.menu.addMenu(self.auto_play_slides_group) - self.auto_play_slides_loop = create_widget_action(self.auto_play_slides_group, - text=translate('OpenLP.ServiceManager', 'Auto play slides &Loop'), - checked=False, triggers=self.toggle_auto_play_slides_loop) - self.auto_play_slides_once = create_widget_action(self.auto_play_slides_group, - text=translate('OpenLP.ServiceManager', 'Auto play slides &Once'), - checked=False, triggers=self.toggle_auto_play_slides_once) - self.auto_play_slides_group.addSeparator() - self.timed_slide_interval = create_widget_action(self.auto_play_slides_group, - text=translate('OpenLP.ServiceManager', '&Delay between slides'), - checked=False, triggers=self.on_timed_slide_interval) - self.menu.addSeparator() - self.preview_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', 'Show &Preview'), - icon=u':/general/general_preview.png', triggers=self.make_preview) - # Add already existing make live action to the menu. - self.menu.addAction(self.service_manager_list.make_live) - self.menu.addSeparator() - self.theme_menu = QtGui.QMenu(translate('OpenLP.ServiceManager', '&Change Item Theme')) - self.menu.addMenu(self.theme_menu) - self.service_manager_list.addActions( - [self.service_manager_list.moveDown, - self.service_manager_list.moveUp, - self.service_manager_list.make_live, - self.service_manager_list.moveTop, - self.service_manager_list.moveBottom, - self.service_manager_list.up, - self.service_manager_list.down, - self.service_manager_list.expand, - self.service_manager_list.collapse - ]) - - def drag_enter_event(self, event): - """ - Accept Drag events - - ``event`` - Handle of the event pint passed - """ - event.accept() - +from openlp.core.utils import delete_file, split_filename, format_time class ServiceManager(QtGui.QWidget, ServiceManagerDialog): """ @@ -560,7 +329,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): if success: try: shutil.copy(temp_file_name, path_file_name) - except : + except shutil.Error: return self.save_file_as() self.main_window.addRecentFile(path_file_name) self.set_modified(False) @@ -618,7 +387,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): if success: try: shutil.copy(temp_file_name, path_file_name) - except: + except shutil.Error: return self.save_file_as() self.main_window.addRecentFile(path_file_name) self.set_modified(False) @@ -1203,13 +972,13 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): self.service_manager_list.setCurrentItem(treewidgetitem) treewidgetitem.setExpanded(item[u'expanded']) - def cleanUp(self): + def clean_up(self): """ Empties the servicePath of temporary files on system exit. """ log.debug(u'Cleaning up servicePath') - for file in os.listdir(self.servicePath): - file_path = os.path.join(self.servicePath, file) + for file_name in os.listdir(self.servicePath): + file_path = os.path.join(self.servicePath, file_name) delete_file(file_path) if os.path.exists(os.path.join(self.servicePath, u'audio')): shutil.rmtree(os.path.join(self.servicePath, u'audio'), True) @@ -1224,12 +993,12 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): Settings().setValue(self.main_window.serviceManagerSettingsSection + u'/service theme', self.service_theme) self.regenerate_service_Items(True) - def themeChange(self): + def theme_change(self): """ The theme may have changed in the settings dialog so make sure the theme combo box is in the correct state. """ - log.debug(u'themeChange') + log.debug(u'theme_change') visible = self.renderer.theme_level == ThemeLevel.Global self.theme_label.setVisible(visible) self.theme_combo_box.setVisible(visible) @@ -1273,7 +1042,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): self.repaint_service_list(-1, -1) Receiver.send_message(u'cursor_normal') - def serviceItemUpdate(self, message): + def service_item_update(self, message): """ Triggered from plugins to update service items. Save the values as they will be used as part of the service load @@ -1408,7 +1177,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): """ Triggers a remote edit to a plugin to allow item to be edited. """ - item, child = self.find_service_item() + item = self.find_service_item()[0] if self.service_items[item][u'service_item'].is_capable(ItemCapabilities.CanEdit): new_item = Registry().get(self.service_items[item][u'service_item'].name). \ onRemoteEdit(self.service_items[item][u'service_item'].edit_id) diff --git a/openlp/core/ui/servicemanagerdialog.py b/openlp/core/ui/servicemanagerdialog.py new file mode 100644 index 000000000..3d0f41b8b --- /dev/null +++ b/openlp/core/ui/servicemanagerdialog.py @@ -0,0 +1,268 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2013 Raoul Snyman # +# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### + +from openlp.core.lib import OpenLPToolbar, translate, UiStrings, Receiver, build_icon, Settings +from openlp.core.lib.ui import create_widget_action +from openlp.core.utils.actions import ActionList, CategoryOrder +from openlp.core.utils import AppLocation + +from PyQt4 import QtCore, QtGui + +class ServiceManagerList(QtGui.QTreeWidget): + """ + Set up key bindings and mouse behaviour for the service list + """ + def __init__(self, serviceManager, parent=None): + QtGui.QTreeWidget.__init__(self, parent) + self.serviceManager = serviceManager + + def keyPressEvent(self, event): + """ + Capture Key press and respond accordingly. + """ + if isinstance(event, QtGui.QKeyEvent): + # here accept the event and do something + if event.key() == QtCore.Qt.Key_Up: + self.serviceManager.on_move_selection_up() + event.accept() + elif event.key() == QtCore.Qt.Key_Down: + self.serviceManager.on_move_selection_down() + event.accept() + elif event.key() == QtCore.Qt.Key_Delete: + self.serviceManager.onDeleteFromService() + event.accept() + event.ignore() + else: + event.ignore() + + def mouseMoveEvent(self, event): + """ + Drag and drop event does not care what data is selected + as the recipient will use events to request the data move + just tell it what plugin to call + """ + if event.buttons() != QtCore.Qt.LeftButton: + event.ignore() + return + if not self.itemAt(self.mapFromGlobal(QtGui.QCursor.pos())): + event.ignore() + return + drag = QtGui.QDrag(self) + mime_data = QtCore.QMimeData() + drag.setMimeData(mime_data) + mime_data.setText(u'ServiceManager') + drag.start(QtCore.Qt.CopyAction) + +class ServiceManagerDialog(object): + """ + UI part of the Service Manager + """ + def setup_ui(self,widget): + # Create the top toolbar + self.toolbar = OpenLPToolbar(self) + self.toolbar.addToolbarAction(u'newService', text=UiStrings().NewService, icon=u':/general/general_new.png', + tooltip=UiStrings().CreateService, triggers=self.on_new_service_clicked) + self.toolbar.addToolbarAction(u'openService', text=UiStrings().OpenService, icon=u':/general/general_open.png', + tooltip=translate('OpenLP.ServiceManager', 'Load an existing service.'), + triggers=self.on_load_service_clicked) + self.toolbar.addToolbarAction(u'saveService', text=UiStrings().SaveService, icon=u':/general/general_save.png', + tooltip=translate('OpenLP.ServiceManager', 'Save this service.'), triggers=self.decide_save_method) + self.toolbar.addSeparator() + self.theme_label = QtGui.QLabel(u'%s:' % UiStrings().Theme, self) + self.theme_label.setMargin(3) + self.theme_label.setObjectName(u'theme_label') + self.toolbar.addToolbarWidget(self.theme_label) + self.theme_combo_box = QtGui.QComboBox(self.toolbar) + self.theme_combo_box.setToolTip(translate('OpenLP.ServiceManager', 'Select a theme for the service.')) + self.theme_combo_box.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength) + self.theme_combo_box.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) + self.theme_combo_box.setObjectName(u'theme_combo_box') + self.toolbar.addToolbarWidget(self.theme_combo_box) + self.toolbar.setObjectName(u'toolbar') + self.layout.addWidget(self.toolbar) + # Create the service manager list + self.service_manager_list = ServiceManagerList(self) + self.service_manager_list.setEditTriggers( + QtGui.QAbstractItemView.CurrentChanged | + QtGui.QAbstractItemView.DoubleClicked | + QtGui.QAbstractItemView.EditKeyPressed) + self.service_manager_list.setDragDropMode(QtGui.QAbstractItemView.DragDrop) + self.service_manager_list.setAlternatingRowColors(True) + self.service_manager_list.setHeaderHidden(True) + self.service_manager_list.setExpandsOnDoubleClick(False) + self.service_manager_list.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL('customContextMenuRequested(QPoint)'), + self.context_menu) + self.service_manager_list.setObjectName(u'service_manager_list') + # enable drop + self.service_manager_list.__class__.dragEnterEvent = self.drag_enter_event + self.service_manager_list.__class__.dragMoveEvent = self.drag_enter_event + self.service_manager_list.__class__.dropEvent = self.drop_event + self.layout.addWidget(self.service_manager_list) + # Add the bottom toolbar + self.order_toolbar = OpenLPToolbar(self) + action_list = ActionList.get_instance() + action_list.add_category(UiStrings().Service, CategoryOrder.standardToolbar) + self.service_manager_list.moveTop = self.order_toolbar.addToolbarAction(u'moveTop', + text=translate('OpenLP.ServiceManager', 'Move to &top'), icon=u':/services/service_top.png', + tooltip=translate('OpenLP.ServiceManager', 'Move item to the top of the service.'), + shortcuts=[QtCore.Qt.Key_Home], category=UiStrings().Service, triggers=self.onServiceTop) + self.service_manager_list.moveUp = self.order_toolbar.addToolbarAction(u'moveUp', + text=translate('OpenLP.ServiceManager', 'Move &up'), icon=u':/services/service_up.png', + tooltip=translate('OpenLP.ServiceManager', 'Move item up one position in the service.'), + shortcuts=[QtCore.Qt.Key_PageUp], category=UiStrings().Service, triggers=self.onServiceUp) + self.service_manager_list.moveDown = self.order_toolbar.addToolbarAction(u'moveDown', + text=translate('OpenLP.ServiceManager', 'Move &down'), icon=u':/services/service_down.png', + tooltip=translate('OpenLP.ServiceManager', 'Move item down one position in the service.'), + shortcuts=[QtCore.Qt.Key_PageDown], category=UiStrings().Service, triggers=self.onServiceDown) + self.service_manager_list.moveBottom = self.order_toolbar.addToolbarAction(u'moveBottom', + text=translate('OpenLP.ServiceManager', 'Move to &bottom'), icon=u':/services/service_bottom.png', + tooltip=translate('OpenLP.ServiceManager', 'Move item to the end of the service.'), + shortcuts=[QtCore.Qt.Key_End], category=UiStrings().Service, triggers=self.onServiceEnd) + self.service_manager_list.down = self.order_toolbar.addToolbarAction(u'down', + text=translate('OpenLP.ServiceManager', 'Move &down'), + tooltip=translate('OpenLP.ServiceManager', 'Moves the selection down the window.'), visible=False, + shortcuts=[QtCore.Qt.Key_Down], triggers=self.on_move_selection_down) + action_list.add_action(self.service_manager_list.down) + self.service_manager_list.up = self.order_toolbar.addToolbarAction(u'up', + text=translate('OpenLP.ServiceManager', 'Move up'), tooltip=translate('OpenLP.ServiceManager', + 'Moves the selection up the window.'), visible=False, shortcuts=[QtCore.Qt.Key_Up], + triggers=self.on_move_selection_up) + action_list.add_action(self.service_manager_list.up) + self.order_toolbar.addSeparator() + self.service_manager_list.delete = self.order_toolbar.addToolbarAction(u'delete', + text=translate('OpenLP.ServiceManager', '&Delete From Service'), icon=u':/general/general_delete.png', + tooltip=translate('OpenLP.ServiceManager', 'Delete the selected item from the service.'), + shortcuts=[QtCore.Qt.Key_Delete], triggers=self.onDeleteFromService) + self.order_toolbar.addSeparator() + self.service_manager_list.expand = self.order_toolbar.addToolbarAction(u'expand', + text=translate('OpenLP.ServiceManager', '&Expand all'), icon=u':/services/service_expand_all.png', + tooltip=translate('OpenLP.ServiceManager', 'Expand all the service items.'), + shortcuts=[QtCore.Qt.Key_Plus], category=UiStrings().Service, triggers=self.onExpandAll) + self.service_manager_list.collapse = self.order_toolbar.addToolbarAction(u'collapse', + text=translate('OpenLP.ServiceManager', '&Collapse all'), icon=u':/services/service_collapse_all.png', + tooltip=translate('OpenLP.ServiceManager', 'Collapse all the service items.'), + shortcuts=[QtCore.Qt.Key_Minus], category=UiStrings().Service, triggers=self.onCollapseAll) + self.order_toolbar.addSeparator() + self.service_manager_list.make_live = self.order_toolbar.addToolbarAction(u'make_live', + text=translate('OpenLP.ServiceManager', 'Go Live'), icon=u':/general/general_live.png', + tooltip=translate('OpenLP.ServiceManager', 'Send the selected item to Live.'), + shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return], category=UiStrings().Service, + triggers=self.make_live) + self.layout.addWidget(self.order_toolbar) + # Connect up our signals and slots + QtCore.QObject.connect(self.theme_combo_box, QtCore.SIGNAL(u'activated(int)'), + self.on_theme_combo_box_selected) + QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), + self.on_make_live) + QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL(u'itemCollapsed(QTreeWidgetItem*)'), + self.collapsed) + QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL(u'itemExpanded(QTreeWidgetItem*)'), + self.expanded) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.update_theme_list) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_preview_live'), + self.preview_live) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_next_item'), self.next_item) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_previous_item'), + self.previous_item) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_set_item'), self.on_set_item) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.config_updated) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'), + self.regenerate_service_Items) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_global'), self.theme_change) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'service_item_update'), + self.service_item_update) + # Last little bits of setting up + self.service_theme = Settings().value(self.main_window.serviceManagerSettingsSection + u'/service theme') + self.servicePath = AppLocation.get_section_data_path(u'servicemanager') + # build the drag and drop context menu + self.dndMenu = QtGui.QMenu() + self.newAction = self.dndMenu.addAction(translate('OpenLP.ServiceManager', '&Add New Item')) + self.newAction.setIcon(build_icon(u':/general/general_edit.png')) + self.addToAction = self.dndMenu.addAction(translate('OpenLP.ServiceManager', '&Add to Selected Item')) + self.addToAction.setIcon(build_icon(u':/general/general_edit.png')) + # build the context menu + self.menu = QtGui.QMenu() + self.edit_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Edit Item'), + icon=u':/general/general_edit.png', triggers=self.remote_edit) + self.maintain_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Reorder Item'), + icon=u':/general/general_edit.png', triggers=self.on_service_item_edit_form) + self.notes_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Notes'), + icon=u':/services/service_notes.png', triggers=self.on_service_item_note_form) + self.time_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Start Time'), + icon=u':/media/media_time.png', triggers=self.on_start_time_form) + self.auto_start_action = create_widget_action(self.menu, text=u'', + icon=u':/media/auto-start_active.png', triggers=self.on_auto_start) + # Add already existing delete action to the menu. + self.menu.addAction(self.service_manager_list.delete) + self.create_custom_action = create_widget_action(self.menu, + text=translate('OpenLP.ServiceManager', 'Create New &Custom Slide'), + icon=u':/general/general_edit.png', triggers=self.create_custom) + self.menu.addSeparator() + # Add AutoPlay menu actions + self.auto_play_slides_group = QtGui.QMenu(translate('OpenLP.ServiceManager', '&Auto play slides')) + self.menu.addMenu(self.auto_play_slides_group) + self.auto_play_slides_loop = create_widget_action(self.auto_play_slides_group, + text=translate('OpenLP.ServiceManager', 'Auto play slides &Loop'), + checked=False, triggers=self.toggle_auto_play_slides_loop) + self.auto_play_slides_once = create_widget_action(self.auto_play_slides_group, + text=translate('OpenLP.ServiceManager', 'Auto play slides &Once'), + checked=False, triggers=self.toggle_auto_play_slides_once) + self.auto_play_slides_group.addSeparator() + self.timed_slide_interval = create_widget_action(self.auto_play_slides_group, + text=translate('OpenLP.ServiceManager', '&Delay between slides'), + checked=False, triggers=self.on_timed_slide_interval) + self.menu.addSeparator() + self.preview_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', 'Show &Preview'), + icon=u':/general/general_preview.png', triggers=self.make_preview) + # Add already existing make live action to the menu. + self.menu.addAction(self.service_manager_list.make_live) + self.menu.addSeparator() + self.theme_menu = QtGui.QMenu(translate('OpenLP.ServiceManager', '&Change Item Theme')) + self.menu.addMenu(self.theme_menu) + self.service_manager_list.addActions( + [self.service_manager_list.moveDown, + self.service_manager_list.moveUp, + self.service_manager_list.make_live, + self.service_manager_list.moveTop, + self.service_manager_list.moveBottom, + self.service_manager_list.up, + self.service_manager_list.down, + self.service_manager_list.expand, + self.service_manager_list.collapse + ]) + + def drag_enter_event(self, event): + """ + Accept Drag events + + ``event`` + Handle of the event pint passed + """ + event.accept() \ No newline at end of file diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 1c7921121..a77fdb3cd 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -346,7 +346,7 @@ class ThemeManager(QtGui.QWidget): try: encoding = get_filesystem_encoding() shutil.rmtree(os.path.join(self.path, theme).encode(encoding)) - except OSError: + except OSError, shutil.Error: log.exception(u'Error deleting theme %s', theme) def onExportTheme(self): @@ -660,7 +660,7 @@ class ThemeManager(QtGui.QWidget): try: encoding = get_filesystem_encoding() shutil.copyfile(unicode(image_from).encode(encoding), unicode(image_to).encode(encoding)) - except IOError: + except IOError, shutil.Error: log.exception(u'Failed to save theme image') self.generateAndSaveImage(self.path, name, theme) From 4bd77075f3cf38028ff5e92c814535ac1507776f Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 1 Feb 2013 22:52:42 +0200 Subject: [PATCH 28/64] Slowly making progress. --- openlp/core/ui/mediadockmanager.py | 5 ++++- openlp/core/ui/plugindialog.py | 13 ++++++++++++- openlp/core/ui/pluginform.py | 20 +++++++++++++++++++- openlp/core/ui/printservicedialog.py | 23 +++++++++++++++++------ openlp/core/ui/printserviceform.py | 17 ++++++++++++++++- 5 files changed, 68 insertions(+), 10 deletions(-) diff --git a/openlp/core/ui/mediadockmanager.py b/openlp/core/ui/mediadockmanager.py index 0c87b3c44..981528fca 100644 --- a/openlp/core/ui/mediadockmanager.py +++ b/openlp/core/ui/mediadockmanager.py @@ -26,13 +26,16 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The media manager dock. +""" import logging from openlp.core.lib import StringContent log = logging.getLogger(__name__) + class MediaDockManager(object): """ Provide a repository for MediaManagerItems diff --git a/openlp/core/ui/plugindialog.py b/openlp/core/ui/plugindialog.py index 401cab924..83f8b21a7 100644 --- a/openlp/core/ui/plugindialog.py +++ b/openlp/core/ui/plugindialog.py @@ -26,7 +26,9 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The UI widgets of the plugin view dialog +#""" from PyQt4 import QtCore, QtGui from openlp.core.lib import translate, UiStrings @@ -34,7 +36,13 @@ from openlp.core.lib.ui import create_button_box class Ui_PluginViewDialog(object): + """ + The UI of the plugin view dialog + """ def setupUi(self, pluginViewDialog): + """ + Set up the UI + """ pluginViewDialog.setObjectName(u'pluginViewDialog') pluginViewDialog.setWindowModality(QtCore.Qt.ApplicationModal) self.pluginLayout = QtGui.QVBoxLayout(pluginViewDialog) @@ -72,6 +80,9 @@ class Ui_PluginViewDialog(object): self.retranslateUi(pluginViewDialog) def retranslateUi(self, pluginViewDialog): + """ + Translate the UI on the fly + """ pluginViewDialog.setWindowTitle(translate('OpenLP.PluginForm', 'Plugin List')) self.pluginInfoGroupBox.setTitle(translate('OpenLP.PluginForm', 'Plugin Details')) self.versionLabel.setText(u'%s:' % UiStrings().Version) diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index 37cae9a0a..d71a778c4 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -26,7 +26,9 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The actual plugin view form +""" import logging from PyQt4 import QtCore, QtGui @@ -36,11 +38,15 @@ from plugindialog import Ui_PluginViewDialog log = logging.getLogger(__name__) + class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): """ The plugin form provides user control over the plugins OpenLP uses. """ def __init__(self, parent=None): + """ + Constructor + """ QtGui.QDialog.__init__(self, parent) self.activePlugin = None self.programaticChange = False @@ -85,12 +91,18 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): self.pluginListWidget.setFixedWidth(pluginListWidth + self.pluginListWidget.iconSize().width() + 48) def _clearDetails(self): + """ + Clear the plugin details widgets + """ self.statusComboBox.setCurrentIndex(-1) self.versionNumberLabel.setText(u'') self.aboutTextBrowser.setHtml(u'') self.statusComboBox.setEnabled(False) def _setDetails(self): + """ + Set the details of the currently selected plugin + """ log.debug(u'PluginStatus: %s', str(self.activePlugin.status)) self.versionNumberLabel.setText(self.activePlugin.version) self.aboutTextBrowser.setHtml(self.activePlugin.about()) @@ -103,6 +115,9 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): self.programaticChange = False def onPluginListWidgetSelectionChanged(self): + """ + If the selected plugin changes, update the form + """ if self.pluginListWidget.currentItem() is None: self._clearDetails() return @@ -120,6 +135,9 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): self._clearDetails() def onStatusComboBoxChanged(self, status): + """ + If the status of a plugin is altered, apply the change + """ if self.programaticChange or status == PluginStatus.Disabled: return if status == PluginStatus.Inactive: diff --git a/openlp/core/ui/printservicedialog.py b/openlp/core/ui/printservicedialog.py index 0a7ab4874..7f7abcf27 100644 --- a/openlp/core/ui/printservicedialog.py +++ b/openlp/core/ui/printservicedialog.py @@ -26,11 +26,14 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The UI widgets of the print service dialog. +""" from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon, translate, SpellTextEdit, UiStrings + class ZoomSize(object): """ Type enumeration for Combo Box sizes @@ -44,7 +47,13 @@ class ZoomSize(object): class Ui_PrintServiceDialog(object): + """ + The UI of the print service dialog + """ def setupUi(self, printServiceDialog): + """ + Set up the UI + """ printServiceDialog.setObjectName(u'printServiceDialog') printServiceDialog.resize(664, 594) self.mainLayout = QtGui.QVBoxLayout(printServiceDialog) @@ -121,9 +130,12 @@ class Ui_PrintServiceDialog(object): self.optionsLayout.addWidget(self.optionsGroupBox) self.retranslateUi(printServiceDialog) - QtCore.QObject.connect(self.optionsButton,QtCore.SIGNAL(u'toggled(bool)'), self.toggleOptions) + QtCore.QObject.connect(self.optionsButton, QtCore.SIGNAL(u'toggled(bool)'), self.toggleOptions) def retranslateUi(self, printServiceDialog): + """ + Translate the UI on the fly + """ printServiceDialog.setWindowTitle(UiStrings().PrintService) self.zoomOutButton.setToolTip(translate('OpenLP.PrintServiceForm', 'Zoom Out')) self.zoomOriginalButton.setToolTip(translate('OpenLP.PrintServiceForm', 'Zoom Original')) @@ -131,7 +143,7 @@ class Ui_PrintServiceDialog(object): self.optionsButton.setText(translate('OpenLP.PrintServiceForm', 'Options')) self.titleLabel.setText(translate('OpenLP.PrintServiceForm', 'Title:')) self.footerLabel.setText(translate('OpenLP.PrintServiceForm', 'Custom Footer Text:')) - self.optionsGroupBox.setTitle(translate('OpenLP.PrintServiceForm','Other Options')) + self.optionsGroupBox.setTitle(translate('OpenLP.PrintServiceForm', 'Other Options')) self.slideTextCheckBox.setText(translate('OpenLP.PrintServiceForm', 'Include slide text if available')) self.pageBreakAfterText.setText(translate('OpenLP.PrintServiceForm', 'Add page break before each text item')) self.notesCheckBox.setText(translate('OpenLP.PrintServiceForm', 'Include service item notes')) @@ -144,6 +156,5 @@ class Ui_PrintServiceDialog(object): u'100%', u'75%', u'50%', - u'25%'] - ) - + u'25%' + ]) diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index d10fe7ba0..101ee9acb 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -26,6 +26,9 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +""" +The actual print service dialog +""" import cgi import datetime import os @@ -106,8 +109,11 @@ http://doc.trolltech.com/4.7/richtext-html-subset.html#css-properties } """ -class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): +class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): + """ + The :class:`~openlp.core.ui.printserviceform.PrintServiceForm` class displays a dialog for printing the service. + """ def __init__(self): """ Constructor @@ -143,6 +149,9 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): self.updatePreviewText() def toggleOptions(self, checked): + """ + Toggle various options + """ self.optionsWidget.setVisible(checked) if checked: left = self.optionsButton.pos().x() @@ -181,6 +190,9 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): self.previewWidget.updatePreview() def _addPreviewItem(self, body, item, index): + """ + Add a preview item + """ div = self._addElement(u'div', classId=u'item', parent=body) # Add the title of the service item. item_title = self._addElement(u'h2', parent=div, classId=u'itemTitle') @@ -388,6 +400,9 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): settings.endGroup() def update_song_usage(self): + """ + Update the song usage + """ # Only continue when we include the song's text. if not self.slideTextCheckBox.isChecked(): return From c891edc40cb60a6e99032a4ff830bafe126202b0 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 1 Feb 2013 23:34:23 +0200 Subject: [PATCH 29/64] Last of the dialogs --- openlp/core/ui/serviceitemeditdialog.py | 14 +++- openlp/core/ui/serviceitemeditform.py | 11 +++- openlp/core/ui/servicemanager.py | 29 ++++++--- openlp/core/ui/servicenoteform.py | 14 +++- openlp/core/ui/settingsdialog.py | 14 +++- openlp/core/ui/settingsform.py | 4 ++ openlp/core/ui/shortcutlistdialog.py | 17 ++++- openlp/core/ui/shortcutlistform.py | 17 ++++- openlp/core/ui/slidecontroller.py | 44 +++++++++++-- openlp/core/ui/splashscreen.py | 13 ++++ openlp/core/ui/starttimedialog.py | 13 +++- openlp/core/ui/starttimeform.py | 16 ++++- openlp/core/ui/themeform.py | 24 ++++++- openlp/core/ui/themelayoutdialog.py | 14 +++- openlp/core/ui/themelayoutform.py | 16 +++-- openlp/core/ui/thememanager.py | 87 ++++++++++++++----------- openlp/core/ui/themestab.py | 34 +++++++++- openlp/core/ui/themewizard.py | 18 ++++- openlp/core/ui/wizard.py | 4 ++ 19 files changed, 325 insertions(+), 78 deletions(-) diff --git a/openlp/core/ui/serviceitemeditdialog.py b/openlp/core/ui/serviceitemeditdialog.py index 638bf4460..645a2921f 100644 --- a/openlp/core/ui/serviceitemeditdialog.py +++ b/openlp/core/ui/serviceitemeditdialog.py @@ -26,14 +26,23 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The UI widgets for the service item edit dialog +""" from PyQt4 import QtGui from openlp.core.lib import translate from openlp.core.lib.ui import create_button_box, create_button + class Ui_ServiceItemEditDialog(object): + """ + The UI widgets for the service item edit dialog + """ def setupUi(self, serviceItemEditDialog): + """ + Set up the UI + """ serviceItemEditDialog.setObjectName(u'serviceItemEditDialog') self.dialog_layout = QtGui.QGridLayout(serviceItemEditDialog) self.dialog_layout.setContentsMargins(8, 8, 8, 8) @@ -61,4 +70,7 @@ class Ui_ServiceItemEditDialog(object): self.retranslateUi(serviceItemEditDialog) def retranslateUi(self, serviceItemEditDialog): + """ + Translate the UI on the fly + """ serviceItemEditDialog.setWindowTitle(translate('OpenLP.ServiceItemEditForm', 'Reorder Service Item')) diff --git a/openlp/core/ui/serviceitemeditform.py b/openlp/core/ui/serviceitemeditform.py index 58d8a5399..c0a03f8e8 100644 --- a/openlp/core/ui/serviceitemeditform.py +++ b/openlp/core/ui/serviceitemeditform.py @@ -26,12 +26,15 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The service item edit dialog +""" from PyQt4 import QtCore, QtGui from openlp.core.lib import Registry from serviceitemeditdialog import Ui_ServiceItemEditDialog + class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog): """ This is the form that is used to edit the verses of the song. @@ -47,6 +50,9 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog): self.on_current_row_changed) def set_service_item(self, item): + """ + Set the service item to be edited. + """ self.item = item self.item_list = [] if self.item.is_image(): @@ -57,6 +63,9 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog): self.list_widget.setCurrentItem(self.list_widget.currentItem()) def get_service_item(self): + """ + Get the modified service item. + """ if self.data: self.item._raw_frames = [] if self.item.is_image(): diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index fe1023bbf..0e6a38c34 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -26,6 +26,9 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +""" +The service manager sets up, loads, saves and manages services. +""" import cgi import cPickle import logging @@ -48,11 +51,15 @@ from openlp.core.ui.printserviceform import PrintServiceForm from openlp.core.utils import AppLocation, delete_file, split_filename, format_time from openlp.core.utils.actions import ActionList, CategoryOrder + class ServiceManagerList(QtGui.QTreeWidget): """ Set up key bindings and mouse behaviour for the service list """ def __init__(self, serviceManager, parent=None): + """ + Constructor + """ QtGui.QTreeWidget.__init__(self, parent) self.serviceManager = serviceManager @@ -93,16 +100,22 @@ class ServiceManagerList(QtGui.QTreeWidget): mime_data.setText(u'ServiceManager') drag.start(QtCore.Qt.CopyAction) + class ServiceManagerDialog(object): """ + The UI for the service manager. """ - def setup_ui(self,widget): + def setup_ui(self, widget): + """ + Set up the UI for the service manager + """ # Create the top toolbar self.toolbar = OpenLPToolbar(self) self.toolbar.addToolbarAction(u'newService', text=UiStrings().NewService, icon=u':/general/general_new.png', tooltip=UiStrings().CreateService, triggers=self.on_new_service_clicked) self.toolbar.addToolbarAction(u'openService', text=UiStrings().OpenService, icon=u':/general/general_open.png', - tooltip=translate('OpenLP.ServiceManager', 'Load an existing service.'), triggers=self.on_load_service_clicked) + tooltip=translate('OpenLP.ServiceManager', 'Load an existing service.'), + triggers=self.on_load_service_clicked) self.toolbar.addToolbarAction(u'saveService', text=UiStrings().SaveService, icon=u':/general/general_save.png', tooltip=translate('OpenLP.ServiceManager', 'Save this service.'), triggers=self.decide_save_method) self.toolbar.addSeparator() @@ -185,7 +198,8 @@ class ServiceManagerDialog(object): self.service_manager_list.make_live = self.order_toolbar.addToolbarAction(u'make_live', text=translate('OpenLP.ServiceManager', 'Go Live'), icon=u':/general/general_live.png', tooltip=translate('OpenLP.ServiceManager', 'Send the selected item to Live.'), - shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return], category=UiStrings().Service, triggers=self.make_live) + shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return], category=UiStrings().Service, + triggers=self.make_live) self.layout.addWidget(self.order_toolbar) # Connect up our signals and slots QtCore.QObject.connect(self.theme_combo_box, QtCore.SIGNAL(u'activated(int)'), @@ -697,7 +711,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): try: ucsfile = zip_info.filename.decode(u'utf-8') except UnicodeDecodeError: - log.exception(u'file_name "%s" is not valid UTF-8' % zip_info.file_name.decode(u'utf-8', u'replace')) + log.exception(u'file_name "%s" is not valid UTF-8', zip_info.file_name.decode(u'utf-8', u'replace')) critical_error_message_box(message=translate('OpenLP.ServiceManager', 'File is not a valid service.\n The content encoding is not UTF-8.')) continue @@ -809,7 +823,8 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): delay_suffix = u' %s s' % unicode(service_item[u'service_item'].timed_slide_interval) else: delay_suffix = u' ...' - self.timed_slide_interval.setText(translate('OpenLP.ServiceManager', '&Delay between slides') + delay_suffix) + self.timed_slide_interval.setText( + translate('OpenLP.ServiceManager', '&Delay between slides') + delay_suffix) # TODO for future: make group explains itself more visually else: self.auto_play_slides_group.menuAction().setVisible(False) @@ -818,7 +833,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): if service_item[u'service_item'].is_capable(ItemCapabilities.CanAutoStartForLive): self.auto_start_action.setVisible(True) self.auto_start_action.setIcon(self.inactive) - self.auto_start_action.setText(translate('OpenLP.ServiceManager','&Auto Start - inactive')) + self.auto_start_action.setText(translate('OpenLP.ServiceManager', '&Auto Start - inactive')) if service_item[u'service_item'].will_auto_start: self.auto_start_action.setText(translate('OpenLP.ServiceManager', '&Auto Start - active')) self.auto_start_action.setIcon(self.active) @@ -876,7 +891,6 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): self.main_window.generalSettingsSection + u'/loop delay') self.set_modified() - def toggle_auto_play_slides_loop(self): """ Toggle Auto play slide loop. @@ -892,7 +906,6 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): self.main_window.generalSettingsSection + u'/loop delay') self.set_modified() - def on_timed_slide_interval(self): """ Shows input dialog for enter interval in seconds for delay diff --git a/openlp/core/ui/servicenoteform.py b/openlp/core/ui/servicenoteform.py index 7e30b18ad..7d624ab8c 100644 --- a/openlp/core/ui/servicenoteform.py +++ b/openlp/core/ui/servicenoteform.py @@ -26,12 +26,15 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The :mod:`~openlp.core.ui.servicenoteform` module contains the `ServiceNoteForm` class. +""" from PyQt4 import QtGui from openlp.core.lib import translate, SpellTextEdit, Registry from openlp.core.lib.ui import create_button_box + class ServiceNoteForm(QtGui.QDialog): """ This is the form that is used to edit the verses of the song. @@ -45,10 +48,16 @@ class ServiceNoteForm(QtGui.QDialog): self.retranslateUi() def exec_(self): + """ + Execute the form and return the result. + """ self.text_edit.setFocus() return QtGui.QDialog.exec_(self) def setupUi(self): + """ + Set up the UI of the dialog + """ self.setObjectName(u'serviceNoteEdit') self.dialog_layout = QtGui.QVBoxLayout(self) self.dialog_layout.setContentsMargins(8, 8, 8, 8) @@ -61,6 +70,9 @@ class ServiceNoteForm(QtGui.QDialog): self.dialog_layout.addWidget(self.button_box) def retranslateUi(self): + """ + Translate the UI on the fly + """ self.setWindowTitle(translate('OpenLP.ServiceNoteForm', 'Service Item Notes')) def _get_main_window(self): diff --git a/openlp/core/ui/settingsdialog.py b/openlp/core/ui/settingsdialog.py index f88e6c81e..4a91f2ad7 100644 --- a/openlp/core/ui/settingsdialog.py +++ b/openlp/core/ui/settingsdialog.py @@ -26,14 +26,23 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The UI widgets of the settings dialog. +""" from PyQt4 import QtCore, QtGui from openlp.core.lib import translate, build_icon from openlp.core.lib.ui import create_button_box + class Ui_SettingsDialog(object): + """ + The UI widgets of the settings dialog. + """ def setupUi(self, settingsDialog): + """ + Set up the UI + """ settingsDialog.setObjectName(u'settingsDialog') settingsDialog.resize(800, 500) settingsDialog.setWindowIcon(build_icon(u':/system/system_settings.png')) @@ -55,4 +64,7 @@ class Ui_SettingsDialog(object): QtCore.QObject.connect(self.settingListWidget, QtCore.SIGNAL(u'currentRowChanged(int)'), self.tabChanged) def retranslateUi(self, settingsDialog): + """ + Translate the UI on the fly + """ settingsDialog.setWindowTitle(translate('OpenLP.SettingsForm', 'Configure OpenLP')) diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 992128dc3..ede764807 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -40,6 +40,7 @@ from settingsdialog import Ui_SettingsDialog log = logging.getLogger(__name__) + class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): """ Provide the form to manipulate the settings for OpenLP @@ -61,6 +62,9 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): self.playerTab = PlayerTab(self, self.main_window) def exec_(self): + """ + Execute the form + """ # load all the settings self.settingListWidget.clear() while self.stackedLayout.count(): diff --git a/openlp/core/ui/shortcutlistdialog.py b/openlp/core/ui/shortcutlistdialog.py index dd72778ef..95d8490e4 100644 --- a/openlp/core/ui/shortcutlistdialog.py +++ b/openlp/core/ui/shortcutlistdialog.py @@ -26,17 +26,23 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The list of shortcuts within a dialog. +""" from PyQt4 import QtCore, QtGui from openlp.core.lib import translate, build_icon from openlp.core.lib.ui import create_button_box + class CaptureShortcutButton(QtGui.QPushButton): """ A class to encapsulate a ``QPushButton``. """ def __init__(self, *args): + """ + Constructor + """ QtGui.QPushButton.__init__(self, *args) self.setCheckable(True) @@ -51,7 +57,13 @@ class CaptureShortcutButton(QtGui.QPushButton): class Ui_ShortcutListDialog(object): + """ + The UI widgets for the shortcut dialog. + """ def setupUi(self, shortcutListDialog): + """ + Set up the UI + """ shortcutListDialog.setObjectName(u'shortcutListDialog') shortcutListDialog.resize(500, 438) self.shortcutListLayout = QtGui.QVBoxLayout(shortcutListDialog) @@ -113,6 +125,9 @@ class Ui_ShortcutListDialog(object): self.retranslateUi(shortcutListDialog) def retranslateUi(self, shortcutListDialog): + """ + Translate the UI on the fly + """ shortcutListDialog.setWindowTitle(translate('OpenLP.ShortcutListDialog', 'Configure Shortcuts')) self.descriptionLabel.setText( translate('OpenLP.ShortcutListDialog', 'Select an action and click one of the buttons below to start ' diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index 5c534ca37..ff07c6242 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -26,7 +26,8 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The :mod:`~openlp.core.ui.shortcutlistform` module contains the form class""" import logging import re @@ -48,6 +49,9 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): """ def __init__(self, parent=None): + """ + Constructor + """ QtGui.QDialog.__init__(self, parent) self.setupUi(self) self.changedActions = {} @@ -72,6 +76,9 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.onCustomRadioButtonClicked) def keyPressEvent(self, event): + """ + Respond to certain key presses + """ if event.key() == QtCore.Qt.Key_Space: self.keyReleaseEvent(event) elif self.primaryPushButton.isChecked() or self.alternatePushButton.isChecked(): @@ -81,6 +88,9 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.close() def keyReleaseEvent(self, event): + """ + Respond to certain key presses + """ if not self.primaryPushButton.isChecked() and not self.alternatePushButton.isChecked(): return key = event.key() @@ -106,6 +116,9 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): False, text=key_sequence.toString()) def exec_(self): + """ + Execute the dialog + """ self.changedActions = {} self.reloadShortcutList() self._adjustButton(self.primaryPushButton, False, False, u'') @@ -422,7 +435,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): if action.shortcutContext() in [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut]: is_valid = False - if changing_action.shortcutContext() in [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut]: + if changing_action.shortcutContext() in [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut]: is_valid = False if not is_valid: Receiver.send_message(u'openlp_warning_message', { diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 75028a514..f50ebc0d7 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -26,7 +26,9 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The :mod:`slidecontroller` module contains argubly the most important part of OpenLP - the slide controller +""" import os import logging import copy @@ -257,7 +259,7 @@ class SlideController(DisplayController): self.audioMenu.addAction(self.nextTrackItem) self.trackMenu = self.audioMenu.addMenu(translate('OpenLP.SlideController', 'Tracks')) self.audioTimeLabel = QtGui.QLabel(u' 00:00 ', self.toolbar) - self.audioTimeLabel.setAlignment(QtCore.Qt.AlignCenter|QtCore.Qt.AlignHCenter) + self.audioTimeLabel.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignHCenter) self.audioTimeLabel.setStyleSheet( u'background-color: palette(background); ' u'border-top-color: palette(shadow); ' @@ -288,7 +290,7 @@ class SlideController(DisplayController): self.slideLayout.setObjectName(u'SlideLayout') self.previewDisplay = Display(self, self.isLive, self) self.previewDisplay.setGeometry(QtCore.QRect(0, 0, 300, 300)) - self.previewDisplay.screen = {u'size':self.previewDisplay.geometry()} + self.previewDisplay.screen = {u'size': self.previewDisplay.geometry()} self.previewDisplay.setup() self.slideLayout.insertWidget(0, self.previewDisplay) self.previewDisplay.hide() @@ -432,6 +434,9 @@ class SlideController(DisplayController): self.current_shortcut = u'' def setLiveHotkeys(self, parent=None): + """ + Set the live hotkeys + """ self.previousService = create_action(parent, u'previousService', text=translate('OpenLP.SlideController', 'Previous Service'), shortcuts=[QtCore.Qt.Key_Left], context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category, @@ -442,10 +447,13 @@ class SlideController(DisplayController): triggers=self.serviceNext) self.escapeItem = create_action(parent, 'escapeItem', text=translate('OpenLP.SlideController', 'Escape Item'), - shortcuts=[QtCore.Qt.Key_Escape],context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category, + shortcuts=[QtCore.Qt.Key_Escape], context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category, triggers=self.liveEscape) def liveEscape(self): + """ + If you press ESC on the live screen it should close the display temporarily. + """ self.display.setVisible(False) self.media_controller.media_stop(self) @@ -520,11 +528,14 @@ class SlideController(DisplayController): serviceItem = ServiceItem() self.previewDisplay.webView.setHtml(build_html(serviceItem, self.previewDisplay.screen, None, self.isLive, plugins=self.plugin_manager.plugins)) - self.media_controller.setup_display(self.previewDisplay,True) + self.media_controller.setup_display(self.previewDisplay, True) if self.serviceItem: self.refreshServiceItem() def __addActionsToWidget(self, widget): + """ + Add actions to the widget specified by `widget` + """ widget.addActions([ self.previousItem, self.nextItem, self.previousService, self.nextService, @@ -564,6 +575,9 @@ class SlideController(DisplayController): self.previewListWidget.setRowHeight(framenumber, width / self.ratio) def onSongBarHandler(self): + """ + Some song handler + """ request = self.sender().text() slide_no = self.slideList[request] self.__updatePreviewSelection(slide_no) @@ -690,7 +704,7 @@ class SlideController(DisplayController): self.playSlidesLoop.setChecked(item.auto_play_slides_loop) self.delaySpinBox.setValue(int(item.timed_slide_interval)) self.onPlaySlidesLoop() - elif self.isLive and item.auto_play_slides_once and item.timed_slide_interval > 0: + elif self.isLive and item.auto_play_slides_once and item.timed_slide_interval > 0: self.playSlidesOnce.setChecked(item.auto_play_slides_once) self.delaySpinBox.setValue(int(item.timed_slide_interval)) self.onPlaySlidesOnce() @@ -1088,6 +1102,9 @@ class SlideController(DisplayController): self.slideSelected() def __checkUpdateSelectedSlide(self, row): + """ + Check if this slide has been updated + """ if row + 1 < self.previewListWidget.rowCount(): self.previewListWidget.scrollToItem(self.previewListWidget.item(row + 1, 0)) self.previewListWidget.selectRow(row) @@ -1160,9 +1177,15 @@ class SlideController(DisplayController): self.onToggleLoop() def setAudioItemsVisibility(self, visible): + """ + Set the visibility of the audio stuff + """ self.toolbar.setWidgetVisible(self.audioList, visible) def onAudioPauseClicked(self, checked): + """ + Pause the audio player + """ if not self.audioPauseItem.isVisible(): return if checked: @@ -1268,15 +1291,24 @@ class SlideController(DisplayController): return None def onNextTrackClicked(self): + """ + Go to the next track when next is clicked + """ self.display.audioPlayer.next() def onAudioTimeRemaining(self, time): + """ + Update how much time is remaining + """ seconds = self.display.audioPlayer.mediaObject.remainingTime() // 1000 minutes = seconds // 60 seconds %= 60 self.audioTimeLabel.setText(u' %02d:%02d ' % (minutes, seconds)) def onTrackTriggered(self): + """ + Start playing a track + """ action = self.sender() self.display.audioPlayer.goTo(action.data()) diff --git a/openlp/core/ui/splashscreen.py b/openlp/core/ui/splashscreen.py index f72135744..39ac8e8d9 100644 --- a/openlp/core/ui/splashscreen.py +++ b/openlp/core/ui/splashscreen.py @@ -26,17 +26,30 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +""" +The splash screen +""" from openlp.core.lib import Receiver from PyQt4 import QtCore, QtGui + class SplashScreen(QtGui.QSplashScreen): + """ + The splash screen + """ def __init__(self): + """ + Constructor + """ QtGui.QSplashScreen.__init__(self) self.setupUi() QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'close_splash'), self.close) def setupUi(self): + """ + Set up the UI + """ self.setObjectName(u'splashScreen') self.setContextMenuPolicy(QtCore.Qt.PreventContextMenu) splash_image = QtGui.QPixmap(u':/graphics/openlp-splash-screen.png') diff --git a/openlp/core/ui/starttimedialog.py b/openlp/core/ui/starttimedialog.py index 0e2f7dc13..e13c86430 100644 --- a/openlp/core/ui/starttimedialog.py +++ b/openlp/core/ui/starttimedialog.py @@ -26,7 +26,9 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The UI widgets for the time dialog +""" from PyQt4 import QtCore, QtGui from openlp.core.lib import translate, UiStrings @@ -34,7 +36,13 @@ from openlp.core.lib.ui import create_button_box class Ui_StartTimeDialog(object): + """ + The UI widgets for the time dialog + """ def setupUi(self, StartTimeDialog): + """ + Set up the UI + """ StartTimeDialog.setObjectName(u'StartTimeDialog') StartTimeDialog.resize(350, 10) self.dialogLayout = QtGui.QGridLayout(StartTimeDialog) @@ -108,6 +116,9 @@ class Ui_StartTimeDialog(object): self.setMaximumHeight(self.sizeHint().height()) def retranslateUi(self, StartTimeDialog): + """ + Update the translations on the fly + """ self.setWindowTitle(translate('OpenLP.StartTimeForm', 'Item Start and Finish Time')) self.hourSpinBox.setSuffix(UiStrings().Hours) self.minuteSpinBox.setSuffix(UiStrings().Minutes) diff --git a/openlp/core/ui/starttimeform.py b/openlp/core/ui/starttimeform.py index f53b995b1..7c9e694f0 100644 --- a/openlp/core/ui/starttimeform.py +++ b/openlp/core/ui/starttimeform.py @@ -26,7 +26,9 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The actual start time form. +""" from PyQt4 import QtGui from starttimedialog import Ui_StartTimeDialog @@ -34,11 +36,15 @@ from starttimedialog import Ui_StartTimeDialog from openlp.core.lib import translate, UiStrings, Registry from openlp.core.lib.ui import critical_error_message_box + class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog): """ - The exception dialog + The start time dialog """ def __init__(self): + """ + Constructor + """ QtGui.QDialog.__init__(self, self.main_window) self.setupUi(self) @@ -60,6 +66,9 @@ class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog): return QtGui.QDialog.exec_(self) def accept(self): + """ + When the dialog succeeds, this is run + """ start = self.hourSpinBox.value() * 3600 + \ self.minuteSpinBox.value() * 60 + \ self.secondSpinBox.value() @@ -79,6 +88,9 @@ class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog): return QtGui.QDialog.accept(self) def _time_split(self, seconds): + """ + Split time up into hours minutes and seconds from secongs + """ hours = seconds / 3600 seconds -= 3600 * hours minutes = seconds / 60 diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 37af3b7b9..2ecaf67d5 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -26,7 +26,9 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The Theme wizard +""" import logging import os @@ -41,6 +43,7 @@ from themewizard import Ui_ThemeWizard log = logging.getLogger(__name__) + class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): """ This is the Theme Import Wizard, which allows easy creation and editing of @@ -72,14 +75,14 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): self.onGradientStartButtonClicked) QtCore.QObject.connect(self.gradientEndButton, QtCore.SIGNAL(u'clicked()'), self.onGradientEndButtonClicked) QtCore.QObject.connect(self.imageBrowseButton, QtCore.SIGNAL(u'clicked()'), self.onImageBrowseButtonClicked) - QtCore.QObject.connect(self.mainColorButton, QtCore.SIGNAL(u'clicked()'), self.onMainColorButtonClicked) + QtCore.QObject.connect(self.mainColorButton, QtCore.SIGNAL(u'clicked()'), self.onMainColorButtonClicked) QtCore.QObject.connect(self.outlineColorButton, QtCore.SIGNAL(u'clicked()'), self.onOutlineColorButtonClicked) QtCore.QObject.connect(self.shadowColorButton, QtCore.SIGNAL(u'clicked()'), self.onShadowColorButtonClicked) QtCore.QObject.connect(self.outlineCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), self.onOutlineCheckCheckBoxStateChanged) QtCore.QObject.connect(self.shadowCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), self.onShadowCheckCheckBoxStateChanged) - QtCore.QObject.connect(self.footerColorButton,QtCore.SIGNAL(u'clicked()'), self.onFooterColorButtonClicked) + QtCore.QObject.connect(self.footerColorButton, QtCore.SIGNAL(u'clicked()'), self.onFooterColorButtonClicked) QtCore.QObject.connect(self, QtCore.SIGNAL(u'customButtonClicked(int)'), self.onCustom1ButtonClicked) QtCore.QObject.connect(self.mainPositionCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), self.onMainPositionCheckBoxStateChanged) @@ -178,6 +181,9 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): pixmapHeight + 2 * frameWidth) def validateCurrentPage(self): + """ + Validate the current page + """ background_image = BackgroundType.to_string(BackgroundType.Image) if self.page(self.currentId()) == self.backgroundPage and \ self.theme.background_type == background_image and not self.imageFileEdit.text(): @@ -444,18 +450,30 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): self.setBackgroundPageValues() def onMainColorButtonClicked(self): + """ + Set the main colour value + """ self.theme.font_main_color = self._colorButton(self.theme.font_main_color) self.setMainAreaPageValues() def onOutlineColorButtonClicked(self): + """ + Set the outline colour value + """ self.theme.font_main_outline_color = self._colorButton(self.theme.font_main_outline_color) self.setMainAreaPageValues() def onShadowColorButtonClicked(self): + """ + Set the shadow colour value + """ self.theme.font_main_shadow_color = self._colorButton(self.theme.font_main_shadow_color) self.setMainAreaPageValues() def onFooterColorButtonClicked(self): + """ + Set the footer colour value + """ self.theme.font_footer_color = self._colorButton(self.theme.font_footer_color) self.setFooterAreaPageValues() diff --git a/openlp/core/ui/themelayoutdialog.py b/openlp/core/ui/themelayoutdialog.py index 123fcbfec..04efecdb6 100644 --- a/openlp/core/ui/themelayoutdialog.py +++ b/openlp/core/ui/themelayoutdialog.py @@ -26,7 +26,9 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The layout of the theme +""" from PyQt4 import QtGui from openlp.core.lib import translate @@ -34,7 +36,13 @@ from openlp.core.lib.ui import create_button_box class Ui_ThemeLayoutDialog(object): + """ + The layout of the theme + """ def setupUi(self, themeLayoutDialog): + """ + Set up the UI + """ themeLayoutDialog.setObjectName(u'themeLayoutDialogDialog') #themeLayoutDialog.resize(300, 200) self.previewLayout = QtGui.QVBoxLayout(themeLayoutDialog) @@ -63,7 +71,9 @@ class Ui_ThemeLayoutDialog(object): self.retranslateUi(themeLayoutDialog) def retranslateUi(self, themeLayoutDialog): + """ + Translate the UI on the fly + """ themeLayoutDialog.setWindowTitle(translate('OpenLP.StartTimeForm', 'Theme Layout')) self.mainColourLabel.setText(translate('OpenLP.StartTimeForm', 'The blue box shows the main area.')) self.footerColourLabel.setText(translate('OpenLP.StartTimeForm', 'The red box shows the footer.')) - diff --git a/openlp/core/ui/themelayoutform.py b/openlp/core/ui/themelayoutform.py index d49676868..a8cb7cb84 100644 --- a/openlp/core/ui/themelayoutform.py +++ b/openlp/core/ui/themelayoutform.py @@ -26,16 +26,22 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The form layout +""" from PyQt4 import QtGui, QtCore from themelayoutdialog import Ui_ThemeLayoutDialog + class ThemeLayoutForm(QtGui.QDialog, Ui_ThemeLayoutDialog): """ The exception dialog """ def __init__(self, parent): + """ + Constructor + """ QtGui.QDialog.__init__(self, parent) self.setupUi(self) @@ -44,11 +50,7 @@ class ThemeLayoutForm(QtGui.QDialog, Ui_ThemeLayoutDialog): Run the Dialog with correct heading. """ pixmap = image.scaledToHeight(400, QtCore.Qt.SmoothTransformation) - self.themeDisplayLabel.setPixmap(image) + self.themeDisplayLabel.setPixmap(pixmap) displayAspectRatio = float(image.width()) / image.height() - self.themeDisplayLabel.setFixedSize(400, 400 / displayAspectRatio ) + self.themeDisplayLabel.setFixedSize(400, 400 / displayAspectRatio) return QtGui.QDialog.exec_(self) - - def accept(self): - return QtGui.QDialog.accept(self) - diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 1c7921121..304462969 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -26,7 +26,9 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The Theme Manager manages adding, deleteing and modifying of themes. +""" import os import zipfile import shutil @@ -47,11 +49,15 @@ from openlp.core.utils import AppLocation, delete_file, locale_compare, get_file log = logging.getLogger(__name__) + class ThemeManager(QtGui.QWidget): """ Manages the orders of Theme. """ def __init__(self, parent=None): + """ + Constructor + """ QtGui.QWidget.__init__(self, parent) Registry().register(u'theme_manager', self) self.settingsSection = u'themes' @@ -149,10 +155,10 @@ class ThemeManager(QtGui.QWidget): """ Receiver.send_message(u'cursor_busy') files = SettingsManager.get_files(self.settingsSection, u'.otz') - for file in files: - file = os.path.join(self.path, file) - self.unzipTheme(file, self.path) - delete_file(file) + for theme_file in files: + theme_file = os.path.join(self.path, theme_file) + self.unzipTheme(theme_file, self.path) + delete_file(theme_file) Receiver.send_message(u'cursor_normal') def configUpdated(self): @@ -197,7 +203,7 @@ class ThemeManager(QtGui.QWidget): tab """ log.debug(u'changeGlobalFromTab %s', theme_name) - for count in range (0, self.themeListWidget.count()): + for count in range(0, self.themeListWidget.count()): # reset the old name item = self.themeListWidget.item(count) old_name = item.text() @@ -218,7 +224,7 @@ class ThemeManager(QtGui.QWidget): """ log.debug(u'changeGlobalFromScreen %s', index) selected_row = self.themeListWidget.currentRow() - for count in range (0, self.themeListWidget.count()): + for count in range(0, self.themeListWidget.count()): item = self.themeListWidget.item(count) old_name = item.text() # reset the old name @@ -365,16 +371,16 @@ class ThemeManager(QtGui.QWidget): if path: Settings().setValue(self.settingsSection + u'/last directory export', path) theme_path = os.path.join(path, theme + u'.otz') - # FIXME: Do not overwrite build-in. - zip = None + theme_zip = None try: - zip = zipfile.ZipFile(theme_path, u'w') + theme_zip = zipfile.ZipFile(theme_path, u'w') source = os.path.join(self.path, theme) for files in os.walk(source): for name in files[2]: - zip.write( + theme_zip.write( os.path.join(source, name).encode(u'utf-8'), - os.path.join(theme, name).encode(u'utf-8')) + os.path.join(theme, name).encode(u'utf-8') + ) QtGui.QMessageBox.information(self, translate('OpenLP.ThemeManager', 'Theme Exported'), translate('OpenLP.ThemeManager', 'Your theme has been successfully exported.')) @@ -384,8 +390,8 @@ class ThemeManager(QtGui.QWidget): translate('OpenLP.ThemeManager', 'Theme Export Failed'), translate('OpenLP.ThemeManager', 'Your theme could not be exported due to an error.')) finally: - if zip: - zip.close() + if theme_zip: + theme_zip.close() Receiver.send_message(u'cursor_normal') def onImportTheme(self): @@ -483,6 +489,9 @@ class ThemeManager(QtGui.QWidget): return self._createThemeFromXml(xml, self.path) def overWriteMessageBox(self, theme_name): + """ + Display a warning box to the user that a theme already exists + """ ret = QtGui.QMessageBox.question(self, translate('OpenLP.ThemeManager', 'Theme Already Exists'), translate('OpenLP.ThemeManager', @@ -491,7 +500,7 @@ class ThemeManager(QtGui.QWidget): QtGui.QMessageBox.No) return ret == QtGui.QMessageBox.Yes - def unzipTheme(self, file_name, dir): + def unzipTheme(self, file_name, directory): """ Unzip the theme, remove the preview file if stored Generate a new preview file. Check the XML theme version and upgrade if @@ -499,32 +508,31 @@ class ThemeManager(QtGui.QWidget): """ log.debug(u'Unzipping theme %s', file_name) file_name = unicode(file_name) - zip = None + theme_zip = None out_file = None file_xml = None abort_import = True try: - zip = zipfile.ZipFile(file_name) - xml_file = filter(lambda name: - os.path.splitext(name)[1].lower() == u'.xml', zip.namelist()) + theme_zip = zipfile.ZipFile(file_name) + xml_file = filter(lambda name: os.path.splitext(name)[1].lower() == u'.xml', theme_zip.namelist()) if len(xml_file) != 1: log.exception(u'Theme contains "%s" XML files' % len(xml_file)) raise Exception(u'validation') - xml_tree = ElementTree(element=XML(zip.read(xml_file[0]))).getroot() + xml_tree = ElementTree(element=XML(theme_zip.read(xml_file[0]))).getroot() v1_background = xml_tree.find(u'BackgroundType') if v1_background is not None: theme_name, file_xml, out_file, abort_import = self.unzipVersion122( - dir, zip, xml_file[0], xml_tree, v1_background, out_file) + directory, theme_zip, xml_file[0], xml_tree, v1_background, out_file) else: theme_name = xml_tree.find(u'name').text.strip() - theme_folder = os.path.join(dir, theme_name) + theme_folder = os.path.join(directory, theme_name) theme_exists = os.path.exists(theme_folder) if theme_exists and not self.overWriteMessageBox(theme_name): abort_import = True return else: abort_import = False - for name in zip.namelist(): + for name in theme_zip.namelist(): try: uname = unicode(name, u'utf-8') except UnicodeDecodeError: @@ -536,15 +544,15 @@ class ThemeManager(QtGui.QWidget): if split_name[-1] == u'' or len(split_name) == 1: # is directory or preview file continue - full_name = os.path.join(dir, uname) + full_name = os.path.join(directory, uname) check_directory_exists(os.path.dirname(full_name)) if os.path.splitext(uname)[1].lower() == u'.xml': - file_xml = unicode(zip.read(name), u'utf-8') + file_xml = unicode(theme_zip.read(name), u'utf-8') out_file = open(full_name, u'w') out_file.write(file_xml.encode(u'utf-8')) else: out_file = open(full_name, u'wb') - out_file.write(zip.read(name)) + out_file.write(theme_zip.read(name)) out_file.close() except (IOError, zipfile.BadZipfile): log.exception(u'Importing theme from zip failed %s' % file_name) @@ -557,24 +565,24 @@ class ThemeManager(QtGui.QWidget): raise finally: # Close the files, to be able to continue creating the theme. - if zip: - zip.close() + if theme_zip: + theme_zip.close() if out_file: out_file.close() if not abort_import: # As all files are closed, we can create the Theme. if file_xml: theme = self._createThemeFromXml(file_xml, self.path) - self.generateAndSaveImage(dir, theme_name, theme) + self.generateAndSaveImage(directory, theme_name, theme) # Only show the error message, when IOError was not raised (in # this case the error message has already been shown). - elif zip is not None: + elif theme_zip is not None: critical_error_message_box( translate('OpenLP.ThemeManager', 'Validation Error'), translate('OpenLP.ThemeManager', 'File is not a valid theme.')) log.exception(u'Theme file does not contain XML data %s' % file_name) - def unzipVersion122(self, dir, zip, xml_file, xml_tree, background, + def unzipVersion122(self, directory, theme_zip, xml_file, xml_tree, background, out_file): """ Unzip openlp.org 1.2x theme file and upgrade the theme xml. When calling @@ -582,13 +590,13 @@ class ThemeManager(QtGui.QWidget): """ theme_name = xml_tree.find(u'Name').text.strip() theme_name = self.badV1NameChars.sub(u'', theme_name) - theme_folder = os.path.join(dir, theme_name) + theme_folder = os.path.join(directory, theme_name) theme_exists = os.path.exists(theme_folder) if theme_exists and not self.overWriteMessageBox(theme_name): return '', '', '', True - themedir = os.path.join(dir, theme_name) + themedir = os.path.join(directory, theme_name) check_directory_exists(themedir) - file_xml = unicode(zip.read(xml_file), u'utf-8') + file_xml = unicode(theme_zip.read(xml_file), u'utf-8') file_xml = self._migrateVersion122(file_xml) out_file = open(os.path.join(themedir, theme_name + u'.xml'), u'w') out_file.write(file_xml.encode(u'utf-8')) @@ -598,10 +606,10 @@ class ThemeManager(QtGui.QWidget): # image file has same extension and is in subfolder image_file = filter(lambda name: os.path.splitext(name)[1].lower() == os.path.splitext(image_name)[1].lower() and name.find(r'/'), - zip.namelist()) + theme_zip.namelist()) if len(image_file) >= 1: out_file = open(os.path.join(themedir, image_name), u'wb') - out_file.write(zip.read(image_file[0])) + out_file.write(theme_zip.read(image_file[0])) out_file.close() else: log.exception(u'Theme file does not contain image file "%s"' % image_name.decode(u'utf-8', u'replace')) @@ -664,8 +672,11 @@ class ThemeManager(QtGui.QWidget): log.exception(u'Failed to save theme image') self.generateAndSaveImage(self.path, name, theme) - def generateAndSaveImage(self, dir, name, theme): - log.debug(u'generateAndSaveImage %s %s', dir, name) + def generateAndSaveImage(self, directory, name, theme): + """ + Generate and save a preview image + """ + log.debug(u'generateAndSaveImage %s %s', directory, name) frame = self.generateImage(theme) sample_path_name = os.path.join(self.path, name + u'.png') if os.path.exists(sample_path_name): diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 1867fe872..b0d598fdd 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -26,7 +26,9 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The Themes configuration tab +""" from PyQt4 import QtCore, QtGui from openlp.core.lib import Receiver, Settings, SettingsTab, translate, UiStrings @@ -39,12 +41,18 @@ class ThemesTab(SettingsTab): ThemesTab is the theme settings tab in the settings dialog. """ def __init__(self, parent, mainwindow): + """ + Constructor + """ self.mainwindow = mainwindow generalTranslated = translate('OpenLP.ThemesTab', 'Themes') SettingsTab.__init__(self, parent, u'Themes', generalTranslated) self.iconPath = u':/themes/theme_new.png' def setupUi(self): + """ + Set up the UI + """ self.setObjectName(u'ThemesTab') SettingsTab.setupUi(self) self.GlobalGroupBox = QtGui.QGroupBox(self.leftColumn) @@ -100,6 +108,9 @@ class ThemesTab(SettingsTab): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.updateThemeList) def retranslateUi(self): + """ + Translate the UI on the fly + """ self.tabTitleVisible = UiStrings().Themes self.GlobalGroupBox.setTitle(translate('OpenLP.ThemesTab', 'Global Theme')) self.LevelGroupBox.setTitle(translate('OpenLP.ThemesTab', 'Theme Level')) @@ -117,6 +128,9 @@ class ThemesTab(SettingsTab): 'any themes associated with either the service or the songs.')) def load(self): + """ + Load the theme settings into the tab + """ settings = Settings() settings.beginGroup(self.settingsSection) self.theme_level = settings.value(u'theme level') @@ -130,6 +144,9 @@ class ThemesTab(SettingsTab): self.SongLevelRadioButton.setChecked(True) def save(self): + """ + Save the settings + """ settings = Settings() settings.beginGroup(self.settingsSection) settings.setValue(u'theme level', self.theme_level) @@ -140,18 +157,33 @@ class ThemesTab(SettingsTab): Receiver.send_message(u'theme_update_global', self.global_theme) def postSetUp(self): + """ + After setting things up... + """ Receiver.send_message(u'theme_update_global', self.global_theme) def onSongLevelButtonClicked(self): + """ + Set the theme level + """ self.theme_level = ThemeLevel.Song def onServiceLevelButtonClicked(self): + """ + Set the theme level + """ self.theme_level = ThemeLevel.Service def onGlobalLevelButtonClicked(self): + """ + Set the theme level + """ self.theme_level = ThemeLevel.Global def onDefaultComboBoxChanged(self, value): + """ + Set the global default theme + """ self.global_theme = self.DefaultComboBox.currentText() self.mainwindow.renderer.set_global_theme(self.global_theme) self.__previewGlobalTheme() diff --git a/openlp/core/ui/themewizard.py b/openlp/core/ui/themewizard.py index 7cabae2bc..7a434e998 100644 --- a/openlp/core/ui/themewizard.py +++ b/openlp/core/ui/themewizard.py @@ -26,15 +26,24 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The Create/Edit theme wizard +""" from PyQt4 import QtCore, QtGui from openlp.core.lib import translate, build_icon, UiStrings from openlp.core.lib.theme import HorizontalType, BackgroundType, BackgroundGradientType from openlp.core.lib.ui import add_welcome_page, create_valign_selection_widgets + class Ui_ThemeWizard(object): + """ + The Create/Edit theme wizard + """ def setupUi(self, themeWizard): + """ + Set up the UI + """ themeWizard.setObjectName(u'OpenLP.ThemeWizard') themeWizard.setModal(True) themeWizard.setWizardStyle(QtGui.QWizard.ModernStyle) @@ -372,7 +381,7 @@ class Ui_ThemeWizard(object): QtCore.SLOT(u'setDisabled(bool)')) QtCore.QObject.connect(self.mainPositionCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.mainHeightSpinBox, QtCore.SLOT(u'setDisabled(bool)')) - QtCore.QObject.connect(self.footerPositionCheckBox,QtCore.SIGNAL(u'toggled(bool)'), self.footerXSpinBox, + QtCore.QObject.connect(self.footerPositionCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.footerXSpinBox, QtCore.SLOT(u'setDisabled(bool)')) QtCore.QObject.connect(self.footerPositionCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.footerYSpinBox, QtCore.SLOT(u'setDisabled(bool)')) @@ -382,8 +391,11 @@ class Ui_ThemeWizard(object): QtCore.SLOT(u'setDisabled(bool)')) def retranslateUi(self, themeWizard): + """ + Translate the UI on the fly + """ themeWizard.setWindowTitle(translate('OpenLP.ThemeWizard', 'Theme Wizard')) - self.titleLabel.setText(u'%s' % \ + self.titleLabel.setText(u'%s' % translate('OpenLP.ThemeWizard', 'Welcome to the Theme Wizard')) self.informationLabel.setText( translate('OpenLP.ThemeWizard', 'This wizard will help you to ' diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index bf7dff269..c876d887b 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -39,6 +39,7 @@ from openlp.core.lib.ui import add_welcome_page log = logging.getLogger(__name__) + class WizardStrings(object): """ Provide standard strings for wizards to use. @@ -80,6 +81,9 @@ class OpenLPWizard(QtGui.QWizard): and feel. """ def __init__(self, parent, plugin, name, image): + """ + Constructor + """ QtGui.QWizard.__init__(self, parent) self.plugin = plugin self.setObjectName(name) From aa14303003d515a51786d13ee7fc90fd17ad5278 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 1 Feb 2013 21:48:06 +0000 Subject: [PATCH 30/64] standards for thememanager and more Registry --- openlp/core/lib/renderer.py | 2 +- openlp/core/ui/firsttimeform.py | 2 +- openlp/core/ui/mainwindow.py | 10 +- openlp/core/ui/themeform.py | 40 ++- openlp/core/ui/thememanager.py | 342 ++++++++++++------------- openlp/core/ui/themestab.py | 2 +- openlp/plugins/songs/lib/olp1import.py | 2 +- 7 files changed, 209 insertions(+), 191 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index acfade722..a7b0756e3 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -128,7 +128,7 @@ class Renderer(object): The theme name. """ if theme_name not in self._theme_dimensions: - theme_data = self.theme_manager.getThemeData(theme_name) + theme_data = self.theme_manager.get_theme_data(theme_name) main_rect = self.get_main_rectangle(theme_data) footer_rect = self.get_footer_rectangle(theme_data) self._theme_dimensions[theme_name] = [theme_data, main_rect, footer_rect] diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 95ae35d5d..c5219320d 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -198,7 +198,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): self.themeComboBox.addItem(item.text()) if self.hasRunWizard: # Add any existing themes to list. - for theme in self.parent().themeManagerContents.getThemes(): + for theme in self.parent().themeManagerContents.get_themes(): index = self.themeComboBox.findText(theme) if index == -1: self.themeComboBox.addItem(theme) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 2ea5b5a79..1af37bac1 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -496,9 +496,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.copyData = False # Set up signals and slots QtCore.QObject.connect(self.importThemeItem, QtCore.SIGNAL(u'triggered()'), - self.themeManagerContents.onImportTheme) + self.themeManagerContents.on_import_theme) QtCore.QObject.connect(self.exportThemeItem, QtCore.SIGNAL(u'triggered()'), - self.themeManagerContents.onExportTheme) + self.themeManagerContents.on_export_theme) QtCore.QObject.connect(self.mediaManagerDock, QtCore.SIGNAL(u'visibilityChanged(bool)'), self.viewMediaManagerItem.setChecked) QtCore.QObject.connect(self.serviceManagerDock, QtCore.SIGNAL(u'visibilityChanged(bool)'), @@ -576,7 +576,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.settingsForm.postSetUp() # Once all components are initialised load the Themes log.info(u'Load Themes') - self.themeManagerContents.loadThemes(True) + self.themeManagerContents.load_themes(True) # Hide/show the theme combobox on the service manager self.serviceManagerContents.theme_change() # Reset the cursor @@ -687,7 +687,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): else: self.activePlugin.toggleStatus(PluginStatus.Inactive) self.themeManagerContents.configUpdated() - self.themeManagerContents.loadThemes(True) + self.themeManagerContents.load_themes(True) Receiver.send_message(u'theme_update_global', self.themeManagerContents.global_theme) # Check if any Bibles downloaded. If there are, they will be # processed. @@ -760,7 +760,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ Updates the new theme preview images. """ - self.themeManagerContents.updatePreviewImages() + self.themeManagerContents.update_preview_images() def onFormattingTagItemClicked(self): """ diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 37af3b7b9..b2ce16386 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -32,7 +32,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, translate, UiStrings +from openlp.core.lib import Receiver, translate, UiStrings, Registry from openlp.core.lib.theme import BackgroundType, BackgroundGradientType from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui import ThemeLayoutForm @@ -56,7 +56,6 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): The QWidget-derived parent of the wizard. """ QtGui.QWizard.__init__(self, parent) - self.thememanager = parent self.setupUi(self) self.registerFields() self.updateThemeAllowed = True @@ -149,7 +148,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): # Do not trigger on start up if self.currentPage != self.welcomePage: self.updateTheme() - self.thememanager.generateImage(self.theme, True) + self.theme_manager.generate_image(self.theme, True) def updateLinesText(self, lines): """ @@ -196,7 +195,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): self.setOption(QtGui.QWizard.HaveCustomButton1, enabled) if self.page(pageId) == self.previewPage: self.updateTheme() - frame = self.thememanager.generateImage(self.theme) + frame = self.theme_manager.generate_image(self.theme) self.previewBoxLabel.setPixmap(frame) self.displayAspectRatio = float(frame.width()) / frame.height() self.resizeEvent() @@ -206,15 +205,15 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): Generate layout preview and display the form. """ self.updateTheme() - width = self.thememanager.mainwindow.renderer.width - height = self.thememanager.mainwindow.renderer.height + width = self.renderer.width + height = self.renderer.height pixmap = QtGui.QPixmap(width, height) pixmap.fill(QtCore.Qt.white) paint = QtGui.QPainter(pixmap) paint.setPen(QtGui.QPen(QtCore.Qt.blue, 2)) - paint.drawRect(self.thememanager.mainwindow.renderer.get_main_rectangle(self.theme)) + paint.drawRect(self.renderer.get_main_rectangle(self.theme)) paint.setPen(QtGui.QPen(QtCore.Qt.red, 2)) - paint.drawRect(self.thememanager.mainwindow.renderer.get_footer_rectangle(self.theme)) + paint.drawRect(self.renderer.get_footer_rectangle(self.theme)) paint.end() self.themeLayoutForm.exec_(pixmap) @@ -514,9 +513,9 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): filename = os.path.split(unicode(self.theme.background_filename))[1] saveTo = os.path.join(self.path, self.theme.theme_name, filename) saveFrom = self.theme.background_filename - if not self.edit_mode and not self.thememanager.checkIfThemeExists(self.theme.theme_name): + if not self.edit_mode and not self.theme_manager.check_if_theme_exists(self.theme.theme_name): return - self.thememanager.saveTheme(self.theme, saveFrom, saveTo) + self.theme_manager.save_theme(self.theme, saveFrom, saveTo) return QtGui.QDialog.accept(self) def _colorButton(self, field): @@ -527,3 +526,24 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): if new_color.isValid(): field = new_color.name() return field + + def _get_renderer(self): + """ + Adds the Renderer to the class dynamically + """ + if not hasattr(self, u'_renderer'): + self._renderer = Registry().get(u'renderer') + return self._renderer + + renderer = property(_get_renderer) + + def _get_theme_manager(self): + """ + Adds the theme manager to the class dynamically + """ + if not hasattr(self, u'_theme_manager'): + self._theme_manager = Registry().get(u'theme_manager') + return self._theme_manager + + theme_manager = property(_get_theme_manager) + \ No newline at end of file diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index a77fdb3cd..ac1d8b02c 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -72,67 +72,67 @@ class ThemeManager(QtGui.QWidget): text=translate('OpenLP.ThemeManager', 'Edit Theme'), icon=u':/themes/theme_edit.png', tooltip=translate('OpenLP.ThemeManager', 'Edit a theme.'), - triggers=self.onEditTheme) - self.deleteToolbarAction = self.toolbar.addToolbarAction(u'deleteTheme', + triggers=self.on_edit_theme) + self.deleteToolbarAction = self.toolbar.addToolbarAction(u'delete_theme', text=translate('OpenLP.ThemeManager', 'Delete Theme'), icon=u':/general/general_delete.png', tooltip=translate('OpenLP.ThemeManager', 'Delete a theme.'), - triggers=self.onDeleteTheme) + triggers=self.on_delete_theme) self.toolbar.addSeparator() self.toolbar.addToolbarAction(u'importTheme', text=translate('OpenLP.ThemeManager', 'Import Theme'), icon=u':/general/general_import.png', tooltip=translate('OpenLP.ThemeManager', 'Import a theme.'), - triggers=self.onImportTheme) + triggers=self.on_import_theme) self.toolbar.addToolbarAction(u'exportTheme', text=translate('OpenLP.ThemeManager', 'Export Theme'), icon=u':/general/general_export.png', tooltip=translate('OpenLP.ThemeManager', 'Export a theme.'), - triggers=self.onExportTheme) + triggers=self.on_export_theme) self.layout.addWidget(self.toolbar) - self.themeWidget = QtGui.QWidgetAction(self.toolbar) - self.themeWidget.setObjectName(u'themeWidget') + self.theme_widget = QtGui.QWidgetAction(self.toolbar) + self.theme_widget.setObjectName(u'theme_widget') # create theme manager list - self.themeListWidget = QtGui.QListWidget(self) - self.themeListWidget.setAlternatingRowColors(True) - self.themeListWidget.setIconSize(QtCore.QSize(88, 50)) - self.themeListWidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) - self.themeListWidget.setObjectName(u'themeListWidget') - self.layout.addWidget(self.themeListWidget) - QtCore.QObject.connect(self.themeListWidget, QtCore.SIGNAL('customContextMenuRequested(QPoint)'), - self.contextMenu) + self.theme_list_widget = QtGui.QListWidget(self) + self.theme_list_widget.setAlternatingRowColors(True) + self.theme_list_widget.setIconSize(QtCore.QSize(88, 50)) + self.theme_list_widget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.theme_list_widget.setObjectName(u'theme_list_widget') + self.layout.addWidget(self.theme_list_widget) + QtCore.QObject.connect(self.theme_list_widget, QtCore.SIGNAL('customContextMenuRequested(QPoint)'), + self.context_menu) # build the context menu self.menu = QtGui.QMenu() - self.editAction = create_widget_action(self.menu, + self.edit_action = create_widget_action(self.menu, text=translate('OpenLP.ThemeManager', '&Edit Theme'), - icon=u':/themes/theme_edit.png', triggers=self.onEditTheme) - self.copyAction = create_widget_action(self.menu, + icon=u':/themes/theme_edit.png', triggers=self.on_edit_theme) + self.copy_action = create_widget_action(self.menu, text=translate('OpenLP.ThemeManager', '&Copy Theme'), - icon=u':/themes/theme_edit.png', triggers=self.onCopyTheme) - self.renameAction = create_widget_action(self.menu, + icon=u':/themes/theme_edit.png', triggers=self.on_copy_theme) + self.rename_action = create_widget_action(self.menu, text=translate('OpenLP.ThemeManager', '&Rename Theme'), - icon=u':/themes/theme_edit.png', triggers=self.onRenameTheme) - self.deleteAction = create_widget_action(self.menu, + icon=u':/themes/theme_edit.png', triggers=self.on_rename_theme) + self.delete_action = create_widget_action(self.menu, text=translate('OpenLP.ThemeManager', '&Delete Theme'), - icon=u':/general/general_delete.png', triggers=self.onDeleteTheme) + icon=u':/general/general_delete.png', triggers=self.on_delete_theme) self.menu.addSeparator() - self.globalAction = create_widget_action(self.menu, + self.global_action = create_widget_action(self.menu, text=translate('OpenLP.ThemeManager', 'Set As &Global Default'), icon=u':/general/general_export.png', triggers=self.changeGlobalFromScreen) self.exportAction = create_widget_action(self.menu, text=translate('OpenLP.ThemeManager', '&Export Theme'), - icon=u':/general/general_export.png', triggers=self.onExportTheme) + icon=u':/general/general_export.png', triggers=self.on_export_theme) # Signals - QtCore.QObject.connect(self.themeListWidget, + QtCore.QObject.connect(self.theme_list_widget, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.changeGlobalFromScreen) - QtCore.QObject.connect(self.themeListWidget, - QtCore.SIGNAL(u'currentItemChanged(QListWidgetItem *, QListWidgetItem *)'), self.checkListState) + QtCore.QObject.connect(self.theme_list_widget, + QtCore.SIGNAL(u'currentItemChanged(QListWidgetItem *, QListWidgetItem *)'), self.check_list_state) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'theme_update_global'), self.changeGlobalFromTab) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.configUpdated) + QtCore.SIGNAL(u'theme_update_global'), self.change_global_from_tab) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.config_updated) # Variables - self.themeList = [] + self.theme_list = [] self.path = AppLocation.get_section_data_path(self.settingsSection) check_directory_exists(self.path) self.thumbPath = os.path.join(self.path, u'thumbnails') @@ -141,27 +141,27 @@ class ThemeManager(QtGui.QWidget): self.oldBackgroundImage = None self.badV1NameChars = re.compile(r'[%+\[\]]') # Last little bits of setting up - self.configUpdated() + self.config_updated() - def firstTime(self): + def first_time(self): """ Import new themes downloaded by the first time wizard """ Receiver.send_message(u'cursor_busy') files = SettingsManager.get_files(self.settingsSection, u'.otz') - for file in files: - file = os.path.join(self.path, file) - self.unzipTheme(file, self.path) + for file_name in files: + file_name = os.path.join(self.path, file_name) + self.unzip_theme(file_name, self.path) delete_file(file) Receiver.send_message(u'cursor_normal') - def configUpdated(self): + def config_updated(self): """ Triggered when Config dialog is updated. """ self.global_theme = Settings().value(self.settingsSection + u'/global theme') - def checkListState(self, item): + def check_list_state(self, item): """ If Default theme selected remove delete button. """ @@ -175,41 +175,41 @@ class ThemeManager(QtGui.QWidget): else: self.deleteToolbarAction.setVisible(False) - def contextMenu(self, point): + def context_menu(self, point): """ Build the Right Click Context menu and set state depending on the type of theme. """ - item = self.themeListWidget.itemAt(point) + item = self.theme_list_widget.itemAt(point) if item is None: return real_theme_name = item.data(QtCore.Qt.UserRole) theme_name = unicode(item.text()) visible = real_theme_name == theme_name - self.deleteAction.setVisible(visible) - self.renameAction.setVisible(visible) - self.globalAction.setVisible(visible) - self.menu.exec_(self.themeListWidget.mapToGlobal(point)) + self.delete_action.setVisible(visible) + self.rename_action.setVisible(visible) + self.global_action.setVisible(visible) + self.menu.exec_(self.theme_list_widget.mapToGlobal(point)) - def changeGlobalFromTab(self, theme_name): + def change_global_from_tab(self, theme_name): """ Change the global theme when it is changed through the Themes settings tab """ - log.debug(u'changeGlobalFromTab %s', theme_name) - for count in range (0, self.themeListWidget.count()): + log.debug(u'change_global_from_tab %s', theme_name) + for count in range (0, self.theme_list_widget.count()): # reset the old name - item = self.themeListWidget.item(count) + item = self.theme_list_widget.item(count) old_name = item.text() new_name = item.data(QtCore.Qt.UserRole) if old_name != new_name: - self.themeListWidget.item(count).setText(new_name) + self.theme_list_widget.item(count).setText(new_name) # Set the new name if theme_name == new_name: name = translate('OpenLP.ThemeManager', '%s (default)') % new_name - self.themeListWidget.item(count).setText(name) + self.theme_list_widget.item(count).setText(name) self.deleteToolbarAction.setVisible( - item not in self.themeListWidget.selectedItems()) + item not in self.theme_list_widget.selectedItems()) def changeGlobalFromScreen(self, index=-1): """ @@ -217,21 +217,21 @@ class ThemeManager(QtGui.QWidget): Theme Manager list """ log.debug(u'changeGlobalFromScreen %s', index) - selected_row = self.themeListWidget.currentRow() - for count in range (0, self.themeListWidget.count()): - item = self.themeListWidget.item(count) + selected_row = self.theme_list_widget.currentRow() + for count in range (0, self.theme_list_widget.count()): + item = self.theme_list_widget.item(count) old_name = item.text() # reset the old name if old_name != item.data(QtCore.Qt.UserRole): - self.themeListWidget.item(count).setText(item.data(QtCore.Qt.UserRole)) + self.theme_list_widget.item(count).setText(item.data(QtCore.Qt.UserRole)) # Set the new name if count == selected_row: - self.global_theme = self.themeListWidget.item(count).text() + self.global_theme = self.theme_list_widget.item(count).text() name = translate('OpenLP.ThemeManager', '%s (default)') % self.global_theme - self.themeListWidget.item(count).setText(name) + self.theme_list_widget.item(count).setText(name) Settings().setValue(self.settingsSection + u'/global theme', self.global_theme) Receiver.send_message(u'theme_update_global', self.global_theme) - self._pushThemes() + self._push_themes() def onAddTheme(self): """ @@ -242,44 +242,44 @@ class ThemeManager(QtGui.QWidget): theme.set_default_header_footer() self.themeForm.theme = theme self.themeForm.exec_() - self.loadThemes() + self.load_themes() - def onRenameTheme(self): + def on_rename_theme(self): """ Renames an existing theme to a new name """ if self._validate_theme_action(translate('OpenLP.ThemeManager', 'You must select a theme to rename.'), translate('OpenLP.ThemeManager', 'Rename Confirmation'), translate('OpenLP.ThemeManager', 'Rename %s theme?'), False, False): - item = self.themeListWidget.currentItem() + item = self.theme_list_widget.currentItem() old_theme_name = item.data(QtCore.Qt.UserRole) self.fileRenameForm.fileNameEdit.setText(old_theme_name) if self.fileRenameForm.exec_(): new_theme_name = self.fileRenameForm.fileNameEdit.text() if old_theme_name == new_theme_name: return - if self.checkIfThemeExists(new_theme_name): - old_theme_data = self.getThemeData(old_theme_name) + if self.check_if_theme_exists(new_theme_name): + old_theme_data = self.get_theme_data(old_theme_name) self.cloneThemeData(old_theme_data, new_theme_name) - self.deleteTheme(old_theme_name) + self.delete_theme(old_theme_name) for plugin in self.plugin_manager.plugins: if plugin.usesTheme(old_theme_name): plugin.renameTheme(old_theme_name, new_theme_name) self.renderer.update_theme(new_theme_name, old_theme_name) - self.loadThemes() + self.load_themes() - def onCopyTheme(self): + def on_copy_theme(self): """ Copies an existing theme to a new name """ - item = self.themeListWidget.currentItem() + item = self.theme_list_widget.currentItem() old_theme_name = item.data(QtCore.Qt.UserRole) self.fileRenameForm.fileNameEdit.setText(translate('OpenLP.ThemeManager', 'Copy of %s', 'Copy of ') % old_theme_name) if self.fileRenameForm.exec_(True): new_theme_name = self.fileRenameForm.fileNameEdit.text() - if self.checkIfThemeExists(new_theme_name): - theme_data = self.getThemeData(old_theme_name) + if self.check_if_theme_exists(new_theme_name): + theme_data = self.get_theme_data(old_theme_name) self.cloneThemeData(theme_data, new_theme_name) def cloneThemeData(self, theme_data, new_theme_name): @@ -295,51 +295,51 @@ class ThemeManager(QtGui.QWidget): save_from = theme_data.background_filename theme_data.theme_name = new_theme_name theme_data.extend_image_filename(self.path) - self.saveTheme(theme_data, save_from, save_to) - self.loadThemes() + self.save_theme(theme_data, save_from, save_to) + self.load_themes() - def onEditTheme(self): + def on_edit_theme(self): """ Loads the settings for the theme that is to be edited and launches the theme editing form so the user can make their changes. """ - if check_item_selected(self.themeListWidget, + if check_item_selected(self.theme_list_widget, translate('OpenLP.ThemeManager', 'You must select a theme to edit.')): - item = self.themeListWidget.currentItem() - theme = self.getThemeData(item.data(QtCore.Qt.UserRole)) + item = self.theme_list_widget.currentItem() + theme = self.get_theme_data(item.data(QtCore.Qt.UserRole)) if theme.background_type == u'image': self.oldBackgroundImage = theme.background_filename self.themeForm.theme = theme self.themeForm.exec_(True) self.oldBackgroundImage = None self.renderer.update_theme(theme.theme_name) - self.loadThemes() + self.load_themes() - def onDeleteTheme(self): + def on_delete_theme(self): """ Delete a theme """ if self._validate_theme_action(translate('OpenLP.ThemeManager', 'You must select a theme to delete.'), translate('OpenLP.ThemeManager', 'Delete Confirmation'), translate('OpenLP.ThemeManager', 'Delete %s theme?')): - item = self.themeListWidget.currentItem() + item = self.theme_list_widget.currentItem() theme = item.text() - row = self.themeListWidget.row(item) - self.themeListWidget.takeItem(row) - self.deleteTheme(theme) + row = self.theme_list_widget.row(item) + self.theme_list_widget.takeItem(row) + self.delete_theme(theme) self.renderer.update_theme(theme, only_delete=True) # As we do not reload the themes, push out the change. Reload the # list as the internal lists and events need to be triggered. - self._pushThemes() + self._push_themes() - def deleteTheme(self, theme): + def delete_theme(self, theme): """ Delete a theme. ``theme`` The theme to delete. """ - self.themeList.remove(theme) + self.theme_list.remove(theme) thumb = u'%s.png' % theme delete_file(os.path.join(self.path, thumb)) delete_file(os.path.join(self.thumbPath, thumb)) @@ -349,11 +349,11 @@ class ThemeManager(QtGui.QWidget): except OSError, shutil.Error: log.exception(u'Error deleting theme %s', theme) - def onExportTheme(self): + def on_export_theme(self): """ Export the theme in a zip file """ - item = self.themeListWidget.currentItem() + item = self.theme_list_widget.currentItem() if item is None: critical_error_message_box(message=translate('OpenLP.ThemeManager', 'You have not selected a theme.')) return @@ -366,29 +366,26 @@ class ThemeManager(QtGui.QWidget): Settings().setValue(self.settingsSection + u'/last directory export', path) theme_path = os.path.join(path, theme + u'.otz') # FIXME: Do not overwrite build-in. - zip = None + zip_file = None try: - zip = zipfile.ZipFile(theme_path, u'w') + zip_file = zipfile.ZipFile(theme_path, u'w') source = os.path.join(self.path, theme) for files in os.walk(source): for name in files[2]: - zip.write( - os.path.join(source, name).encode(u'utf-8'), + zip_file.write(os.path.join(source, name).encode(u'utf-8'), os.path.join(theme, name).encode(u'utf-8')) - QtGui.QMessageBox.information(self, - translate('OpenLP.ThemeManager', 'Theme Exported'), + QtGui.QMessageBox.information(self, translate('OpenLP.ThemeManager', 'Theme Exported'), translate('OpenLP.ThemeManager', 'Your theme has been successfully exported.')) except (IOError, OSError): log.exception(u'Export Theme Failed') - critical_error_message_box( - translate('OpenLP.ThemeManager', 'Theme Export Failed'), + critical_error_message_box(translate('OpenLP.ThemeManager', 'Theme Export Failed'), translate('OpenLP.ThemeManager', 'Your theme could not be exported due to an error.')) finally: - if zip: - zip.close() + if zip_file: + zip_file.close() Receiver.send_message(u'cursor_normal') - def onImportTheme(self): + def on_import_theme(self): """ Opens a file dialog to select the theme file(s) to import before attempting to extract OpenLP themes from those files. This process @@ -402,36 +399,35 @@ class ThemeManager(QtGui.QWidget): if not files: return Receiver.send_message(u'cursor_busy') - for file in files: - Settings().setValue(self.settingsSection + u'/last directory import', unicode(file)) - self.unzipTheme(file, self.path) - self.loadThemes() + for file_name in files: + Settings().setValue(self.settingsSection + u'/last directory import', unicode(file_name)) + self.unzip_theme(file_name, self.path) + self.load_themes() Receiver.send_message(u'cursor_normal') - def loadThemes(self, firstTime=False): + def load_themes(self, first_time=False): """ Loads the theme lists and triggers updates accross the whole system using direct calls or core functions and events for the plugins. The plugins will call back in to get the real list if they want it. """ log.debug(u'Load themes from dir') - self.themeList = [] - self.themeListWidget.clear() + self.theme_list = [] + self.theme_list_widget.clear() files = SettingsManager.get_files(self.settingsSection, u'.png') - if firstTime: - self.firstTime() + if first_time: + self.first_time() files = SettingsManager.get_files(self.settingsSection, u'.png') # No themes have been found so create one if not files: theme = ThemeXML() theme.theme_name = UiStrings().Default - self._writeTheme(theme, None, None) + self._write_theme(theme, None, None) Settings().setValue(self.settingsSection + u'/global theme', theme.theme_name) - self.configUpdated() + self.config_updated() files = SettingsManager.get_files(self.settingsSection, u'.png') # Sort the themes by its name considering language specific - files.sort(key=lambda file_name: unicode(file_name), - cmp=locale_compare) + files.sort(key=lambda file_name: unicode(file_name), cmp=locale_compare) # now process the file list of png files for name in files: # check to see file is in theme root directory @@ -450,23 +446,23 @@ class ThemeManager(QtGui.QWidget): icon = create_thumb(theme, thumb) item_name.setIcon(icon) item_name.setData(QtCore.Qt.UserRole, text_name) - self.themeListWidget.addItem(item_name) - self.themeList.append(text_name) - self._pushThemes() + self.theme_list_widget.addItem(item_name) + self.theme_list.append(text_name) + self._push_themes() - def _pushThemes(self): + def _push_themes(self): """ Notify listeners that the theme list has been updated """ - Receiver.send_message(u'theme_update_list', self.getThemes()) + Receiver.send_message(u'theme_update_list', self.get_themes()) - def getThemes(self): + def get_themes(self): """ Return the list of loaded themes """ - return self.themeList + return self.theme_list - def getThemeData(self, theme_name): + def get_theme_data(self, theme_name): """ Returns a theme object from an XML file @@ -480,18 +476,20 @@ class ThemeManager(QtGui.QWidget): log.debug(u'No theme data - using default theme') return ThemeXML() else: - return self._createThemeFromXml(xml, self.path) + return self._create_theme_fom_Xml(xml, self.path) - def overWriteMessageBox(self, theme_name): - ret = QtGui.QMessageBox.question(self, - translate('OpenLP.ThemeManager', 'Theme Already Exists'), + def over_write_message_box(self, theme_name): + """ + Check before overwriting the theme + """ + ret = QtGui.QMessageBox.question(self, translate('OpenLP.ThemeManager', 'Theme Already Exists'), translate('OpenLP.ThemeManager', 'Theme %s already exists. Do you want to replace it?').replace('%s', theme_name), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No) return ret == QtGui.QMessageBox.Yes - def unzipTheme(self, file_name, dir): + def unzip_theme(self, file_name, dir): """ Unzip the theme, remove the preview file if stored Generate a new preview file. Check the XML theme version and upgrade if @@ -499,32 +497,32 @@ class ThemeManager(QtGui.QWidget): """ log.debug(u'Unzipping theme %s', file_name) file_name = unicode(file_name) - zip = None + zip_file = None out_file = None file_xml = None abort_import = True try: - zip = zipfile.ZipFile(file_name) + zip_file = zipfile.ZipFile(file_name) xml_file = filter(lambda name: - os.path.splitext(name)[1].lower() == u'.xml', zip.namelist()) + os.path.splitext(name)[1].lower() == u'.xml', zip_file.namelist()) if len(xml_file) != 1: log.exception(u'Theme contains "%s" XML files' % len(xml_file)) - raise Exception(u'validation') - xml_tree = ElementTree(element=XML(zip.read(xml_file[0]))).getroot() + raise Exception('validation') + xml_tree = ElementTree(element=XML(zip_file.read(xml_file[0]))).getroot() v1_background = xml_tree.find(u'BackgroundType') if v1_background is not None: - theme_name, file_xml, out_file, abort_import = self.unzipVersion122( - dir, zip, xml_file[0], xml_tree, v1_background, out_file) + theme_name, file_xml, out_file, abort_import = self.unzip_version_122( + dir, zip_file, xml_file[0], xml_tree, v1_background, out_file) else: theme_name = xml_tree.find(u'name').text.strip() theme_folder = os.path.join(dir, theme_name) theme_exists = os.path.exists(theme_folder) - if theme_exists and not self.overWriteMessageBox(theme_name): + if theme_exists and not self.over_write_message_box(theme_name): abort_import = True return else: abort_import = False - for name in zip.namelist(): + for name in zip_file.namelist(): try: uname = unicode(name, u'utf-8') except UnicodeDecodeError: @@ -539,12 +537,12 @@ class ThemeManager(QtGui.QWidget): full_name = os.path.join(dir, uname) check_directory_exists(os.path.dirname(full_name)) if os.path.splitext(uname)[1].lower() == u'.xml': - file_xml = unicode(zip.read(name), u'utf-8') + file_xml = unicode(zip_file.read(name), u'utf-8') out_file = open(full_name, u'w') out_file.write(file_xml.encode(u'utf-8')) else: out_file = open(full_name, u'wb') - out_file.write(zip.read(name)) + out_file.write(zip_file.read(name)) out_file.close() except (IOError, zipfile.BadZipfile): log.exception(u'Importing theme from zip failed %s' % file_name) @@ -557,15 +555,15 @@ class ThemeManager(QtGui.QWidget): raise finally: # Close the files, to be able to continue creating the theme. - if zip: - zip.close() + if zip_file: + zip_file.close() if out_file: out_file.close() if not abort_import: # As all files are closed, we can create the Theme. if file_xml: - theme = self._createThemeFromXml(file_xml, self.path) - self.generateAndSaveImage(dir, theme_name, theme) + theme = self._create_theme_fom_Xml(file_xml, self.path) + self.generate_and_save_image(dir, theme_name, theme) # Only show the error message, when IOError was not raised (in # this case the error message has already been shown). elif zip is not None: @@ -574,22 +572,21 @@ class ThemeManager(QtGui.QWidget): translate('OpenLP.ThemeManager', 'File is not a valid theme.')) log.exception(u'Theme file does not contain XML data %s' % file_name) - def unzipVersion122(self, dir, zip, xml_file, xml_tree, background, - out_file): + def unzip_version_122(self, dir_name, zip_file, xml_file, xml_tree, background, out_file): """ Unzip openlp.org 1.2x theme file and upgrade the theme xml. When calling this method, please keep in mind, that some parameters are redundant. """ theme_name = xml_tree.find(u'Name').text.strip() theme_name = self.badV1NameChars.sub(u'', theme_name) - theme_folder = os.path.join(dir, theme_name) + theme_folder = os.path.join(dir_name, theme_name) theme_exists = os.path.exists(theme_folder) - if theme_exists and not self.overWriteMessageBox(theme_name): + if theme_exists and not self.over_write_message_box(theme_name): return '', '', '', True - themedir = os.path.join(dir, theme_name) + themedir = os.path.join(dir_name, theme_name) check_directory_exists(themedir) - file_xml = unicode(zip.read(xml_file), u'utf-8') - file_xml = self._migrateVersion122(file_xml) + file_xml = unicode(zip_file.read(xml_file), u'utf-8') + file_xml = self._migrate_version_122(file_xml) out_file = open(os.path.join(themedir, theme_name + u'.xml'), u'w') out_file.write(file_xml.encode(u'utf-8')) out_file.close() @@ -597,18 +594,17 @@ class ThemeManager(QtGui.QWidget): image_name = xml_tree.find(u'BackgroundParameter1').text.strip() # image file has same extension and is in subfolder image_file = filter(lambda name: os.path.splitext(name)[1].lower() - == os.path.splitext(image_name)[1].lower() and name.find(r'/'), - zip.namelist()) + == os.path.splitext(image_name)[1].lower() and name.find(r'/'), zip_file.namelist()) if len(image_file) >= 1: out_file = open(os.path.join(themedir, image_name), u'wb') - out_file.write(zip.read(image_file[0])) + out_file.write(zip_file.read(image_file[0])) out_file.close() else: log.exception(u'Theme file does not contain image file "%s"' % image_name.decode(u'utf-8', u'replace')) raise Exception(u'validation') return theme_name, file_xml, out_file, False - def checkIfThemeExists(self, theme_name): + def check_if_theme_exists(self, theme_name): """ Check if theme already exists and displays error message @@ -623,25 +619,25 @@ class ThemeManager(QtGui.QWidget): return False return True - def saveTheme(self, theme, image_from, image_to): + def save_theme(self, theme, image_from, image_to): """ Called by thememaintenance Dialog to save the theme and to trigger the reload of the theme list """ - self._writeTheme(theme, image_from, image_to) + self._write_theme(theme, image_from, image_to) if theme.background_type == BackgroundType.to_string(BackgroundType.Image): self.image_manager.updateImageBorder(theme.background_filename, ImageSource.Theme, QtGui.QColor(theme.background_border_color)) self.image_manager.processUpdates() - def _writeTheme(self, theme, image_from, image_to): + def _write_theme(self, theme, image_from, image_to): """ Writes the theme to the disk and handles the background image if necessary """ name = theme.theme_name theme_pretty_xml = theme.extract_formatted_xml() - log.debug(u'saveTheme %s %s', name, theme_pretty_xml.decode(u'utf-8')) + log.debug(u'save_theme %s %s', name, theme_pretty_xml.decode(u'utf-8')) theme_dir = os.path.join(self.path, name) check_directory_exists(theme_dir) theme_file = os.path.join(theme_dir, name + u'.xml') @@ -662,11 +658,14 @@ class ThemeManager(QtGui.QWidget): shutil.copyfile(unicode(image_from).encode(encoding), unicode(image_to).encode(encoding)) except IOError, shutil.Error: log.exception(u'Failed to save theme image') - self.generateAndSaveImage(self.path, name, theme) + self.generate_and_save_image(self.path, name, theme) - def generateAndSaveImage(self, dir, name, theme): - log.debug(u'generateAndSaveImage %s %s', dir, name) - frame = self.generateImage(theme) + def generate_and_save_image(self, dir, name, theme): + """ + Generate and Save the theme image. + """ + log.debug(u'generate_and_save_image %s %s', dir, name) + frame = self.generate_image(theme) sample_path_name = os.path.join(self.path, name + u'.png') if os.path.exists(sample_path_name): os.unlink(sample_path_name) @@ -675,18 +674,18 @@ class ThemeManager(QtGui.QWidget): create_thumb(sample_path_name, thumb, False) log.debug(u'Theme image written to %s', sample_path_name) - def updatePreviewImages(self): + def update_preview_images(self): """ Called to update the themes' preview images. """ - self.main_window.displayProgressBar(len(self.themeList)) - for theme in self.themeList: + self.main_window.displayProgressBar(len(self.theme_list)) + for theme in self.theme_list: self.main_window.incrementProgressBar() - self.generateAndSaveImage(self.path, theme, self.getThemeData(theme)) + self.generate_and_save_image(self.path, theme, self.get_theme_data(theme)) self.main_window.finishedProgressBar() - self.loadThemes() + self.load_themes() - def generateImage(self, theme_data, forcePage=False): + def generate_image(self, theme_data, forcePage=False): """ Call the renderer to build a Sample Image @@ -696,21 +695,21 @@ class ThemeManager(QtGui.QWidget): ``forcePage`` Flag to tell message lines per page need to be generated. """ - log.debug(u'generateImage \n%s ', theme_data) + log.debug(u'generate_image \n%s ', theme_data) return self.renderer.generate_preview(theme_data, forcePage) - def getPreviewImage(self, theme): + def get_preview_image(self, theme): """ Return an image representing the look of the theme ``theme`` The theme to return the image for """ - log.debug(u'getPreviewImage %s ', theme) + log.debug(u'get_preview_image %s ', theme) image = os.path.join(self.path, theme + u'.png') return image - def _createThemeFromXml(self, theme_xml, path): + def _create_theme_fom_Xml(self, theme_xml, path): """ Return a theme object using information parsed from XML @@ -722,15 +721,14 @@ class ThemeManager(QtGui.QWidget): theme.extend_image_filename(path) return theme - def _validate_theme_action(self, select_text, confirm_title, confirm_text, - testPlugin=True, confirm=True): + def _validate_theme_action(self, select_text, confirm_title, confirm_text, testPlugin=True, confirm=True): """ Check to see if theme has been selected and the destructive action is allowed. """ self.global_theme = Settings().value(self.settingsSection + u'/global theme') - if check_item_selected(self.themeListWidget, select_text): - item = self.themeListWidget.currentItem() + if check_item_selected(self.theme_list_widget, select_text): + item = self.theme_list_widget.currentItem() theme = item.text() # confirm deletion if confirm: @@ -755,7 +753,7 @@ class ThemeManager(QtGui.QWidget): return True return False - def _migrateVersion122(self, xml_data): + def _migrate_version_122(self, xml_data): """ Convert the xml data from version 1 format to the current format. diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index db77019fe..9bad0408a 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -178,7 +178,7 @@ class ThemesTab(SettingsTab): """ Utility method to update the global theme preview image. """ - image = self.main_window.themeManagerContents.getPreviewImage(self.global_theme) + image = self.main_window.themeManagerContents.get_preview_image(self.global_theme) preview = QtGui.QPixmap(unicode(image)) if not preview.isNull(): preview = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) diff --git a/openlp/plugins/songs/lib/olp1import.py b/openlp/plugins/songs/lib/olp1import.py index 178f57ba9..f1f82cdd3 100644 --- a/openlp/plugins/songs/lib/olp1import.py +++ b/openlp/plugins/songs/lib/olp1import.py @@ -62,7 +62,7 @@ class OpenLP1SongImport(SongImport): """ SongImport.__init__(self, manager, **kwargs) self.availableThemes = \ - kwargs[u'plugin'].formParent.themeManagerContents.getThemes() + kwargs[u'plugin'].formParent.themeManagerContents.get_themes() def doImport(self): """ From e25326512dbe31f3b7420ec56fad8e6924689538 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 2 Feb 2013 08:32:29 +0200 Subject: [PATCH 31/64] Now all the media players are looking better --- openlp/core/ui/media/__init__.py | 9 +- openlp/core/ui/media/mediacontroller.py | 27 ++++-- openlp/core/ui/media/mediaplayer.py | 8 +- openlp/core/ui/media/phononplayer.py | 70 +++++++++++++--- openlp/core/ui/media/playertab.py | 40 ++++++++- openlp/core/ui/media/vlcplayer.py | 50 ++++++++++- openlp/core/ui/media/webkitplayer.py | 106 +++++++++++++++++------- 7 files changed, 253 insertions(+), 57 deletions(-) diff --git a/openlp/core/ui/media/__init__.py b/openlp/core/ui/media/__init__.py index 1e4473310..c4afbb0d8 100644 --- a/openlp/core/ui/media/__init__.py +++ b/openlp/core/ui/media/__init__.py @@ -26,6 +26,9 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +""" +The :mod:`~openlp.core.ui.media` module contains classes and objects for media player integration. +""" import logging from openlp.core.lib import Settings @@ -34,6 +37,7 @@ from PyQt4 import QtCore log = logging.getLogger(__name__) + class MediaState(object): """ An enumeration for possible States of the Media Player @@ -70,6 +74,7 @@ class MediaInfo(object): end_time = 0 media_type = MediaType() + def get_media_players(): """ This method extracts the configured media players and overridden player @@ -85,7 +90,7 @@ def get_media_players(): overridden_player = u'auto' else: overridden_player = u'' - saved_players_list = saved_players.replace(u'[', u'').replace(u']',u'').split(u',') + saved_players_list = saved_players.replace(u'[', u'').replace(u']', u'').split(u',') return saved_players_list, overridden_player @@ -108,3 +113,5 @@ def set_media_players(players_list, overridden_player=u'auto'): from mediacontroller import MediaController from playertab import PlayerTab + +__all__ = [u'MediaController', u'PlayerTab'] diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 0ac91c226..6d0c002de 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -26,7 +26,10 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The :mod:`~openlp.core.ui.media.mediacontroller` module contains a base class for media components and other widgets +related to playing media, such as sliders. +""" import logging import os import datetime @@ -41,11 +44,15 @@ from openlp.core.ui import DisplayControllerType log = logging.getLogger(__name__) + class MediaSlider(QtGui.QSlider): """ Allows the mouse events of a slider to be overridden and extra functionality added """ def __init__(self, direction, manager, controller, parent=None): + """ + Constructor + """ QtGui.QSlider.__init__(self, direction) self.manager = manager self.controller = controller @@ -55,7 +62,7 @@ class MediaSlider(QtGui.QSlider): Override event to allow hover time to be displayed. """ timevalue = QtGui.QStyle.sliderValueFromPosition(self.minimum(), self.maximum(), event.x(), self.width()) - self.setToolTip(u'%s' % datetime.timedelta(seconds=int(timevalue/1000))) + self.setToolTip(u'%s' % datetime.timedelta(seconds=int(timevalue / 1000))) QtGui.QSlider.mouseMoveEvent(self, event) def mousePressEvent(self, event): @@ -87,6 +94,9 @@ class MediaController(object): """ def __init__(self, parent): + """ + Constructor + """ self.mainWindow = parent Registry().register(u'media_controller', self) self.mediaPlayers = {} @@ -96,7 +106,7 @@ class MediaController(object): self.timer = QtCore.QTimer() self.timer.setInterval(200) # Signals - QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.media_state) + self.timer.timeout.connect(self.media_state) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'playbackPlay'), self.media_play_msg) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'playbackPause'), self.media_pause_msg) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'playbackStop'), self.media_stop_msg) @@ -298,7 +308,6 @@ class MediaController(object): QtCore.QObject.connect(controller.seekSlider, QtCore.SIGNAL(u'valueChanged(int)'), controller.sendToPlugins) QtCore.QObject.connect(controller.volumeSlider, QtCore.SIGNAL(u'valueChanged(int)'), controller.sendToPlugins) - def setup_display(self, display, preview): """ After a new display is configured, all media related widget will be @@ -428,7 +437,7 @@ class MediaController(object): ``serviceItem`` The ServiceItem containing the details to be played. """ - controller = self.displayControllers[DisplayControllerType.Plugin] + controller = self.displayControllers[DisplayControllerType.Plugin] log.debug(u'media_length') # stop running videos self.media_reset(controller) @@ -500,8 +509,7 @@ class MediaController(object): First element is the controller which should be used """ log.debug(u'media_play_msg') - self.media_play(msg[0],status) - + self.media_play(msg[0], status) def media_play(self, controller, status=True): """ @@ -551,7 +559,7 @@ class MediaController(object): First element is the controller which should be used """ log.debug(u'media_pause_msg') - self.media_pause( msg[0]) + self.media_pause(msg[0]) def media_pause(self, controller): """ @@ -716,6 +724,9 @@ class MediaController(object): self.timer.start() def finalise(self): + """ + Reset all the media controllers when OpenLP shuts down + """ self.timer.stop() for controller in self.displayControllers: self.media_reset(self.displayControllers[controller]) diff --git a/openlp/core/ui/media/mediaplayer.py b/openlp/core/ui/media/mediaplayer.py index 9d09cda6e..1357ead13 100644 --- a/openlp/core/ui/media/mediaplayer.py +++ b/openlp/core/ui/media/mediaplayer.py @@ -26,9 +26,12 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The :mod:`~openlp.core.ui.media.mediaplayer` module contains the MediaPlayer class. +""" from openlp.core.ui.media import MediaState + class MediaPlayer(object): """ This is the base class media Player class to provide OpenLP with a @@ -36,6 +39,9 @@ class MediaPlayer(object): """ def __init__(self, parent, name=u'media_player'): + """ + Constructor + """ self.parent = parent self.name = name self.available = self.check_available() diff --git a/openlp/core/ui/media/phononplayer.py b/openlp/core/ui/media/phononplayer.py index da2d19857..6ec640d2c 100644 --- a/openlp/core/ui/media/phononplayer.py +++ b/openlp/core/ui/media/phononplayer.py @@ -26,7 +26,9 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The :mod:`~openlp.core.ui.media.phononplayer` contains the Phonon player component. +""" import logging import mimetypes from datetime import datetime @@ -56,24 +58,25 @@ ADDITIONAL_EXT = { u'video/x-matroska': [u'.mpv', u'.mkv'], u'video/x-wmv': [u'.wmv'], u'video/x-mpg': [u'.mpg'], - u'video/mpeg' : [u'.mp4', u'.mts', u'.mov'], + u'video/mpeg': [u'.mp4', u'.mts', u'.mov'], u'video/x-ms-wmv': [u'.wmv']} VIDEO_CSS = u""" #videobackboard { z-index:3; - background-color: %s; + background-color: %(bgcolor)s; } #video1 { - background-color: %s; + background-color: %(bgcolor)s; z-index:4; } #video2 { - background-color: %s; + background-color: %(bgcolor)s; z-index:4; } """ + class PhononPlayer(MediaPlayer): """ A specialised version of the MediaPlayer class, which provides a Phonon @@ -81,6 +84,9 @@ class PhononPlayer(MediaPlayer): """ def __init__(self, parent): + """ + Constructor + """ MediaPlayer.__init__(self, parent, u'phonon') self.original_name = u'Phonon' self.display_name = u'&Phonon' @@ -94,13 +100,16 @@ class PhononPlayer(MediaPlayer): elif mimetype.startswith(u'video/'): self._addToList(self.video_extensions_list, mimetype) - def _addToList(self, list, mimetype): + def _addToList(self, mimetype_list, mimetype): + """ + Add mimetypes to the provided list + """ # Add all extensions which mimetypes provides us for supported types. extensions = mimetypes.guess_all_extensions(unicode(mimetype)) for extension in extensions: ext = u'*%s' % extension - if ext not in list: - list.append(ext) + if ext not in mimetype_list: + mimetype_list.append(ext) log.info(u'MediaPlugin: %s extensions: %s' % (mimetype, u' '.join(extensions))) # Add extensions for this mimetype from self.additional_extensions. # This hack clears mimetypes' and operating system's shortcomings @@ -108,12 +117,15 @@ class PhononPlayer(MediaPlayer): if mimetype in self.additional_extensions.keys(): for extension in self.additional_extensions[mimetype]: ext = u'*%s' % extension - if ext not in list: - list.append(ext) + if ext not in mimetype_list: + mimetype_list.append(ext) log.info(u'MediaPlugin: %s additional extensions: %s' % (mimetype, u' '.join(self.additional_extensions[mimetype]))) def setup(self, display): + """ + Set up the player widgets + """ display.phononWidget = Phonon.VideoWidget(display) display.phononWidget.resize(display.size()) display.mediaObject = Phonon.MediaObject(display) @@ -126,9 +138,15 @@ class PhononPlayer(MediaPlayer): self.hasOwnWidget = True def check_available(self): + """ + Check if the player is available + """ return True def load(self, display): + """ + Load a video into the display + """ log.debug(u'load vid in Phonon Controller') controller = display.controller volume = controller.media_info.volume @@ -156,9 +174,15 @@ class PhononPlayer(MediaPlayer): return True def resize(self, display): + """ + Resize the display + """ display.phononWidget.resize(display.size()) def play(self, display): + """ + Play the current media item + """ controller = display.controller start_time = 0 if display.mediaObject.state() != Phonon.PausedState and \ @@ -177,25 +201,40 @@ class PhononPlayer(MediaPlayer): return True def pause(self, display): + """ + Pause the current media item + """ display.mediaObject.pause() if self.media_state_wait(display, Phonon.PausedState): self.state = MediaState.Paused def stop(self, display): + """ + Stop the current media item + """ display.mediaObject.stop() self.set_visible(display, False) self.state = MediaState.Stopped def volume(self, display, vol): + """ + Set the volume + """ # 1.0 is the highest value if display.hasAudio: vol = float(vol) / float(100) display.audio.setVolume(vol) def seek(self, display, seekVal): + """ + Go to a particular point in the current media item + """ display.mediaObject.seek(seekVal) def reset(self, display): + """ + Reset the media player + """ display.mediaObject.stop() display.mediaObject.clearQueue() self.set_visible(display, False) @@ -203,10 +242,16 @@ class PhononPlayer(MediaPlayer): self.state = MediaState.Off def set_visible(self, display, status): + """ + Set the visibility of the widget + """ if self.hasOwnWidget: display.phononWidget.setVisible(status) def update_ui(self, display): + """ + Update the UI + """ if display.mediaObject.state() == Phonon.PausedState and self.state != MediaState.Paused: self.stop(display) controller = display.controller @@ -224,9 +269,12 @@ class PhononPlayer(MediaPlayer): Add css style sheets to htmlbuilder """ background = QtGui.QColor(Settings().value(u'players/background color')).name() - return VIDEO_CSS % (background,background,background) + return VIDEO_CSS % {u'bgcolor': background} def get_info(self): + """ + Return some info about this player + """ return(translate('Media.player', 'Phonon is a media player which ' 'interacts with the operating system to provide media capabilities.') + u'
' + translate('Media.player', 'Audio') + diff --git a/openlp/core/ui/media/playertab.py b/openlp/core/ui/media/playertab.py index eb1a36ca6..707f931fa 100644 --- a/openlp/core/ui/media/playertab.py +++ b/openlp/core/ui/media/playertab.py @@ -26,18 +26,24 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The :mod:`~openlp.core.ui.media.playertab` module holds the configuration tab for the media stuff. +""" from PyQt4 import QtCore, QtGui from openlp.core.lib import SettingsTab, translate, Receiver, Settings, UiStrings from openlp.core.lib.ui import create_button from openlp.core.ui.media import get_media_players, set_media_players + class MediaQCheckBox(QtGui.QCheckBox): """ MediaQCheckBox adds an extra property, playerName to the QCheckBox class. """ def setPlayerName(self, name): + """ + Set the player name + """ self.playerName = name @@ -46,6 +52,9 @@ class PlayerTab(SettingsTab): MediaTab is the Media settings tab in the settings dialog. """ def __init__(self, parent, mainWindow): + """ + Constructor + """ self.parent = parent self.mainWindow = mainWindow self.mediaPlayers = mainWindow.mediaController.mediaPlayers @@ -55,6 +64,9 @@ class PlayerTab(SettingsTab): SettingsTab.__init__(self, parent, u'Players', player_translated) def setupUi(self): + """ + Set up the UI + """ self.setObjectName(u'MediaTab') SettingsTab.setupUi(self) self.bgColorGroupBox = QtGui.QGroupBox(self.leftColumn) @@ -116,6 +128,9 @@ class PlayerTab(SettingsTab): self.onbackgroundColorButtonClicked) def retranslateUi(self): + """ + Translate the UI on the fly + """ self.mediaPlayerGroupBox.setTitle(translate('OpenLP.PlayerTab', 'Available Media Players')) self.playerOrderGroupBox.setTitle(translate('OpenLP.PlayerTab', 'Player Search Order')) self.bgColorGroupBox.setTitle(UiStrings().BackgroundColor) @@ -125,12 +140,18 @@ class PlayerTab(SettingsTab): self.retranslatePlayers() def onbackgroundColorButtonClicked(self): + """ + Set the background color + """ new_color = QtGui.QColorDialog.getColor(QtGui.QColor(self.bg_color), self) if new_color.isValid(): self.bg_color = new_color.name() self.backgroundColorButton.setStyleSheet(u'background-color: %s' % self.bg_color) def onPlayerCheckBoxChanged(self, check_state): + """ + Add or remove players depending on their status + """ player = self.sender().playerName if check_state == QtCore.Qt.Checked: if player not in self.usedPlayers: @@ -141,6 +162,9 @@ class PlayerTab(SettingsTab): self.updatePlayerList() def updatePlayerList(self): + """ + Update the list of media players + """ self.playerOrderlistWidget.clear() for player in self.usedPlayers: if player in self.playerCheckBoxes.keys(): @@ -152,6 +176,9 @@ class PlayerTab(SettingsTab): self.playerOrderlistWidget.addItem(self.mediaPlayers[unicode(player)].original_name) def onUpButtonClicked(self): + """ + Move a media player up in the order + """ row = self.playerOrderlistWidget.currentRow() if row <= 0: return @@ -161,6 +188,9 @@ class PlayerTab(SettingsTab): self.usedPlayers.insert(row - 1, self.usedPlayers.pop(row)) def onDownButtonClicked(self): + """ + Move a media player down in the order + """ row = self.playerOrderlistWidget.currentRow() if row == -1 or row > self.playerOrderlistWidget.count() - 1: return @@ -170,6 +200,9 @@ class PlayerTab(SettingsTab): self.usedPlayers.insert(row + 1, self.usedPlayers.pop(row)) def load(self): + """ + Load the settings + """ if self.savedUsedPlayers: self.usedPlayers = self.savedUsedPlayers self.usedPlayers = get_media_players()[0] @@ -183,6 +216,9 @@ class PlayerTab(SettingsTab): self.backgroundColorButton.setStyleSheet(u'background-color: %s' % self.bg_color) def save(self): + """ + Save the settings + """ player_string_changed = False settings = Settings() settings.beginGroup(self.settingsSection) @@ -211,7 +247,7 @@ class PlayerTab(SettingsTab): checkbox.setToolTip(player.get_info()) checkbox.setPlayerName(player.name) self.playerCheckBoxes[player.name] = checkbox - QtCore.QObject.connect(checkbox,QtCore.SIGNAL(u'stateChanged(int)'), self.onPlayerCheckBoxChanged) + QtCore.QObject.connect(checkbox, QtCore.SIGNAL(u'stateChanged(int)'), self.onPlayerCheckBoxChanged) self.mediaPlayerLayout.addWidget(checkbox) if player.available and player.name in self.usedPlayers: checkbox.setChecked(True) diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 6f3e3d0e7..713a28969 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -26,7 +26,9 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +""" +The :mod:`~openlp.core.ui.media.vlcplayer` module contains our VLC component wrapper +""" from datetime import datetime from distutils.version import LooseVersion import logging @@ -80,8 +82,8 @@ VIDEO_EXT = [ u'*.nsc', u'*.nsv', u'*.nut', - u'*.ra', u'*.ram', u'*.rm', u'*.rv' ,u'*.rmbv', - u'*.a52', u'*.dts', u'*.aac', u'*.flac' ,u'*.dv', u'*.vid', + u'*.ra', u'*.ram', u'*.rm', u'*.rv', u'*.rmbv', + u'*.a52', u'*.dts', u'*.aac', u'*.flac', u'*.dv', u'*.vid', u'*.tta', u'*.tac', u'*.ty', u'*.dts', @@ -99,6 +101,9 @@ class VlcPlayer(MediaPlayer): """ def __init__(self, parent): + """ + Constructor + """ MediaPlayer.__init__(self, parent, u'vlc') self.original_name = u'VLC' self.display_name = u'&VLC' @@ -108,6 +113,9 @@ class VlcPlayer(MediaPlayer): self.video_extensions_list = VIDEO_EXT def setup(self, display): + """ + Set up the media player + """ display.vlcWidget = QtGui.QFrame(display) display.vlcWidget.setFrameStyle(QtGui.QFrame.NoFrame) # creating a basic vlc instance @@ -141,9 +149,15 @@ class VlcPlayer(MediaPlayer): self.hasOwnWidget = True def check_available(self): + """ + Return the availability of VLC + """ return VLC_AVAILABLE def load(self, display): + """ + Load a video into VLC + """ log.debug(u'load vid in Vlc Controller') controller = display.controller volume = controller.media_info.volume @@ -179,9 +193,15 @@ class VlcPlayer(MediaPlayer): return True def resize(self, display): + """ + Resize the player + """ display.vlcWidget.resize(display.size()) def play(self, display): + """ + Play the current item + """ controller = display.controller start_time = 0 if self.state != MediaState.Paused and controller.media_info.start_time > 0: @@ -199,6 +219,9 @@ class VlcPlayer(MediaPlayer): return True def pause(self, display): + """ + Pause the current item + """ if display.vlcMedia.get_state() != vlc.State.Playing: return display.vlcMediaPlayer.pause() @@ -206,27 +229,45 @@ class VlcPlayer(MediaPlayer): self.state = MediaState.Paused def stop(self, display): + """ + Stop the current item + """ display.vlcMediaPlayer.stop() self.state = MediaState.Stopped def volume(self, display, vol): + """ + Set the volume + """ if display.hasAudio: display.vlcMediaPlayer.audio_set_volume(vol) def seek(self, display, seekVal): + """ + Go to a particular position + """ if display.vlcMediaPlayer.is_seekable(): display.vlcMediaPlayer.set_time(seekVal) def reset(self, display): + """ + Reset the player + """ display.vlcMediaPlayer.stop() display.vlcWidget.setVisible(False) self.state = MediaState.Off def set_visible(self, display, status): + """ + Set the visibility + """ if self.hasOwnWidget: display.vlcWidget.setVisible(status) def update_ui(self, display): + """ + Update the UI + """ # Stop video if playback is finished. if display.vlcMedia.get_state() == vlc.State.Ended: self.stop(display) @@ -241,6 +282,9 @@ class VlcPlayer(MediaPlayer): controller.seekSlider.blockSignals(False) def get_info(self): + """ + Return some information about this player + """ return(translate('Media.player', 'VLC is an external player which ' 'supports a number of different formats.') + u'
' + translate('Media.player', 'Audio') + diff --git a/openlp/core/ui/media/webkitplayer.py b/openlp/core/ui/media/webkitplayer.py index ce72f4583..0a768fe37 100644 --- a/openlp/core/ui/media/webkitplayer.py +++ b/openlp/core/ui/media/webkitplayer.py @@ -26,8 +26,10 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - -from PyQt4 import QtCore, QtGui +""" +The :mod:`~openlp.core.ui.media.webkit` module contains our WebKit video player +""" +from PyQt4 import QtGui import logging @@ -40,14 +42,14 @@ log = logging.getLogger(__name__) VIDEO_CSS = u""" #videobackboard { z-index:3; - background-color: %s; + background-color: %(bgcolor)s; } #video1 { - background-color: %s; + background-color: %(bgcolor)s; z-index:4; } #video2 { - background-color: %s; + background-color: %(bgcolor)s; z-index:4; } """ @@ -234,33 +236,33 @@ FLASH_HTML = u""" """ VIDEO_EXT = [ - u'*.3gp' - , u'*.3gpp' - , u'*.3g2' - , u'*.3gpp2' - , u'*.aac' - , u'*.flv' - , u'*.f4a' - , u'*.f4b' - , u'*.f4p' - , u'*.f4v' - , u'*.mov' - , u'*.m4a' - , u'*.m4b' - , u'*.m4p' - , u'*.m4v' - , u'*.mkv' - , u'*.mp4' - , u'*.ogv' - , u'*.webm' - , u'*.mpg', u'*.wmv', u'*.mpeg', u'*.avi' - , u'*.swf' - ] + u'*.3gp', + u'*.3gpp', + u'*.3g2', + u'*.3gpp2', + u'*.aac', + u'*.flv', + u'*.f4a', + u'*.f4b', + u'*.f4p', + u'*.f4v', + u'*.mov', + u'*.m4a', + u'*.m4b', + u'*.m4p', + u'*.m4v', + u'*.mkv', + u'*.mp4', + u'*.ogv', + u'*.webm', + u'*.mpg', u'*.wmv', u'*.mpeg', u'*.avi', + u'*.swf' +] AUDIO_EXT = [ - u'*.mp3' - , u'*.ogg' - ] + u'*.mp3', + u'*.ogg' +] class WebkitPlayer(MediaPlayer): @@ -270,6 +272,9 @@ class WebkitPlayer(MediaPlayer): """ def __init__(self, parent): + """ + Constructor + """ MediaPlayer.__init__(self, parent, u'webkit') self.original_name = u'WebKit' self.display_name = u'&WebKit' @@ -283,7 +288,7 @@ class WebkitPlayer(MediaPlayer): Add css style sheets to htmlbuilder """ background = QtGui.QColor(Settings().value(u'players/background color')).name() - css = VIDEO_CSS % (background,background,background) + css = VIDEO_CSS % {u'bgcolor': background} return css + FLASH_CSS def get_media_display_javascript(self): @@ -299,14 +304,23 @@ class WebkitPlayer(MediaPlayer): return VIDEO_HTML + FLASH_HTML def setup(self, display): + """ + Set up the player + """ display.webView.resize(display.size()) display.webView.raise_() self.hasOwnWidget = False def check_available(self): + """ + Check the availability of the media player + """ return True def load(self, display): + """ + Load a video + """ log.debug(u'load vid in Webkit Controller') controller = display.controller if display.hasAudio and not controller.media_info.is_background: @@ -329,9 +343,15 @@ class WebkitPlayer(MediaPlayer): return True def resize(self, display): + """ + Resize the player + """ display.webView.resize(display.size()) def play(self, display): + """ + Play a video + """ controller = display.controller display.webLoaded = True length = 0 @@ -352,6 +372,9 @@ class WebkitPlayer(MediaPlayer): return True def pause(self, display): + """ + Pause a video + """ controller = display.controller if controller.media_info.is_flash: display.frame.evaluateJavaScript(u'show_flash("pause");') @@ -360,6 +383,9 @@ class WebkitPlayer(MediaPlayer): self.state = MediaState.Paused def stop(self, display): + """ + Stop a video + """ controller = display.controller if controller.media_info.is_flash: display.frame.evaluateJavaScript(u'show_flash("stop");') @@ -368,6 +394,9 @@ class WebkitPlayer(MediaPlayer): self.state = MediaState.Stopped def volume(self, display, vol): + """ + Set the volume + """ controller = display.controller # 1.0 is the highest value if display.hasAudio: @@ -376,6 +405,9 @@ class WebkitPlayer(MediaPlayer): display.frame.evaluateJavaScript(u'show_video(null, null, %s);' % str(vol)) def seek(self, display, seekVal): + """ + Go to a position in the video + """ controller = display.controller if controller.media_info.is_flash: seek = seekVal @@ -385,6 +417,9 @@ class WebkitPlayer(MediaPlayer): display.frame.evaluateJavaScript(u'show_video("seek", null, null, null, "%f");' % (seek)) def reset(self, display): + """ + Reset the player + """ controller = display.controller if controller.media_info.is_flash: display.frame.evaluateJavaScript(u'show_flash("close");') @@ -393,6 +428,9 @@ class WebkitPlayer(MediaPlayer): self.state = MediaState.Off def set_visible(self, display, status): + """ + Set the visibility + """ controller = display.controller if status: is_visible = "visible" @@ -404,6 +442,9 @@ class WebkitPlayer(MediaPlayer): display.frame.evaluateJavaScript(u'show_video("setVisible", null, null, null, "%s");' % (is_visible)) def update_ui(self, display): + """ + Update the UI + """ controller = display.controller if controller.media_info.is_flash: currentTime = display.frame.evaluateJavaScript(u'show_flash("currentTime");') @@ -428,6 +469,9 @@ class WebkitPlayer(MediaPlayer): controller.seekSlider.blockSignals(False) def get_info(self): + """ + Return some information about this player + """ return(translate('Media.player', 'Webkit is a media player which runs ' 'inside a web browser. This player allows text over video to be ' 'rendered.') + From 345b0fcd125557f63f821d21131633da74c0f756 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 2 Feb 2013 07:08:28 +0000 Subject: [PATCH 32/64] Fix up merge request issues --- openlp/core/lib/mediamanageritem.py | 11 +++++++++ openlp/core/ui/advancedtab.py | 33 ++++++++++++++++---------- openlp/core/ui/themestab.py | 2 +- openlp/plugins/songs/lib/olp1import.py | 3 +-- 4 files changed, 33 insertions(+), 16 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 33c0eb1d1..f3cfc6e53 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -688,3 +688,14 @@ class MediaManagerItem(QtGui.QWidget): service_manager = property(_get_service_manager) + def _get_theme_manager(self): + """ + Adds the theme manager to the class dynamically + """ + if not hasattr(self, u'_theme_manager'): + self._theme_manager = Registry().get(u'theme_manager') + return self._theme_manager + + theme_manager = property(_get_theme_manager) + + diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index dd890db90..d27f7cd0c 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -82,9 +82,9 @@ class AdvancedTab(SettingsTab): self.double_click_live_check_box = QtGui.QCheckBox(self.ui_group_box) self.double_click_live_check_box.setObjectName(u'double_click_live_check_box') self.ui_layout.addRow(self.double_click_live_check_box) - self.singleclick_preview_check_box = QtGui.QCheckBox(self.ui_group_box) - self.singleclick_preview_check_box.setObjectName(u'singleclick_preview_check_box') - self.ui_layout.addRow(self.singleclick_preview_check_box) + self.single_click_preview_check_box = QtGui.QCheckBox(self.ui_group_box) + self.single_click_preview_check_box.setObjectName(u'single_click_preview_check_box') + self.ui_layout.addRow(self.single_click_preview_check_box) self.expand_service_item_check_box = QtGui.QCheckBox(self.ui_group_box) self.expand_service_item_check_box.setObjectName(u'expand_service_item_check_box') self.ui_layout.addRow(self.expand_service_item_check_box) @@ -234,6 +234,9 @@ class AdvancedTab(SettingsTab): self.display_workaround_group_box.setObjectName(u'display_workaround_group_box') self.display_workaround_layout = QtGui.QVBoxLayout(self.display_workaround_group_box) self.display_workaround_layout.setObjectName(u'display_workaround_layout') + self.x11_bypass_check_box = QtGui.QCheckBox(self.display_workaround_group_box) + self.x11_bypass_check_box.setObjectName(u'x11_bypass_check_box') + self.display_workaround_layout.addWidget(self.x11_bypass_check_box) self.alternate_rows_check_box = QtGui.QCheckBox(self.display_workaround_group_box) self.alternate_rows_check_box.setObjectName(u'alternate_rows_check_box') self.display_workaround_layout.addWidget(self.alternate_rows_check_box) @@ -250,14 +253,16 @@ class AdvancedTab(SettingsTab): self.update_service_name_example) QtCore.QObject.connect(self.service_name_revert_button, QtCore.SIGNAL(u'clicked()'), self.on_service_name_revert_button_clicked) - QtCore.QObject.connect(self.default_color_button, QtCore.SIGNAL(u'clicked()'), + QtCore.QObject.connect(self.default_color_button, QtCore.SIGNAL(u'clicked()'), self.on_default_color_button_clicked) - QtCore.QObject.connect(self.default_browse_button, QtCore.SIGNAL(u'clicked()'), + QtCore.QObject.connect(self.default_browse_button, QtCore.SIGNAL(u'clicked()'), self.on_default_browse_button_clicked) - QtCore.QObject.connect(self.default_revert_button, QtCore.SIGNAL(u'clicked()'), + QtCore.QObject.connect(self.default_revert_button, QtCore.SIGNAL(u'clicked()'), self.on_default_revert_button_clicked) + QtCore.QObject.connect(self.x11_bypass_check_box, QtCore.SIGNAL(u'toggled(bool)'), + self.on_X11_bypass_check_box_toggled) QtCore.QObject.connect(self.alternate_rows_check_box,QtCore.SIGNAL(u'toggled(bool)'), - self.on_alternate_rows_check_box_toggled) + self.on_alternate_rows_check_box_toggled) QtCore.QObject.connect(self.data_directory_browse_button, QtCore.SIGNAL(u'clicked()'), self.on_data_directory_browse_button_clicked) QtCore.QObject.connect(self.data_directory_default_button, QtCore.SIGNAL(u'clicked()'), @@ -266,11 +271,11 @@ class AdvancedTab(SettingsTab): self.on_data_directory_cancel_button_clicked) QtCore.QObject.connect(self.data_directory_copy_check_box, QtCore.SIGNAL(u'toggled(bool)'), self.on_data_directory_copy_check_box_toggled) - QtCore.QObject.connect(self.end_slide_radio_button, QtCore.SIGNAL(u'clicked()'), + QtCore.QObject.connect(self.end_slide_radio_button, QtCore.SIGNAL(u'clicked()'), self.on_end_slide_button_clicked) - QtCore.QObject.connect(self.wrap_slide_radio_button, QtCore.SIGNAL(u'clicked()'), + QtCore.QObject.connect(self.wrap_slide_radio_button, QtCore.SIGNAL(u'clicked()'), self.on_wrap_slide_button_clicked) - QtCore.QObject.connect(self.next_item_radio_button, QtCore.SIGNAL(u'clicked()'), + QtCore.QObject.connect(self.next_item_radio_button, QtCore.SIGNAL(u'clicked()'), self.on_next_item_button_clicked) @@ -286,7 +291,7 @@ class AdvancedTab(SettingsTab): 'Remember active media manager tab on startup')) self.double_click_live_check_box.setText(translate('OpenLP.AdvancedTab', 'Double-click to send items straight to live')) - self.singleclick_preview_check_box.setText(translate('OpenLP.AdvancedTab', + self.single_click_preview_check_box.setText(translate('OpenLP.AdvancedTab', 'Preview items when clicked in Media Manager')) self.expand_service_item_check_box.setText(translate('OpenLP.AdvancedTab', 'Expand new service items on creation')) @@ -335,6 +340,7 @@ class AdvancedTab(SettingsTab): translate('OpenLP.AdvancedTab', 'WARNING: New data directory location contains ' 'OpenLP data files. These files WILL be replaced during a copy.')) self.display_workaround_group_box.setTitle(translate('OpenLP.AdvancedTab', 'Display Workarounds')) + self.x11_bypass_check_box.setText(translate('OpenLP.AdvancedTab','Bypass X11 Window Manager')) self.alternate_rows_check_box.setText(translate('OpenLP.AdvancedTab', 'Use alternating row colours in lists')) # Slide Limits self.slide_group_box.setTitle(translate('OpenLP.GeneralTab', 'Service Item Slide Limits')) @@ -356,7 +362,7 @@ class AdvancedTab(SettingsTab): self.recent_spin_box.setValue(settings.value(u'recent file count')) self.media_plugin_check_box.setChecked(settings.value(u'save current plugin')) self.double_click_live_check_box.setChecked(settings.value(u'double click live')) - self.singleclick_preview_check_box.setChecked(settings.value(u'single click preview')) + self.single_click_preview_check_box.setChecked(settings.value(u'single click preview')) self.expand_service_item_check_box.setChecked(settings.value(u'expand service item')) self.enable_auto_close_check_box.setChecked(settings.value(u'enable exit confirmation')) self.hide_mouse_check_box.setChecked(settings.value(u'hide mouse')) @@ -368,6 +374,7 @@ class AdvancedTab(SettingsTab): default_service_enabled = settings.value(u'default service enabled') self.service_name_check_box.setChecked(default_service_enabled) self.service_name_check_box_toggled(default_service_enabled) + self.x11_bypass_check_box.setChecked(settings.value(u'x11 bypass wm')) self.default_color = settings.value(u'default color') self.default_file_edit.setText(settings.value(u'default image')) self.slide_limits = settings.value(u'slide limits') @@ -437,7 +444,7 @@ class AdvancedTab(SettingsTab): settings.setValue(u'recent file count', self.recent_spin_box.value()) settings.setValue(u'save current plugin', self.media_plugin_check_box.isChecked()) settings.setValue(u'double click live', self.double_click_live_check_box.isChecked()) - settings.setValue(u'single click preview', self.singleclick_preview_check_box.isChecked()) + settings.setValue(u'single click preview', self.single_click_preview_check_box.isChecked()) settings.setValue(u'expand service item', self.expand_service_item_check_box.isChecked()) settings.setValue(u'enable exit confirmation', self.enable_auto_close_check_box.isChecked()) settings.setValue(u'hide mouse', self.hide_mouse_check_box.isChecked()) diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 9bad0408a..a31dce250 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -178,7 +178,7 @@ class ThemesTab(SettingsTab): """ Utility method to update the global theme preview image. """ - image = self.main_window.themeManagerContents.get_preview_image(self.global_theme) + image = self.theme_manager.get_preview_image(self.global_theme) preview = QtGui.QPixmap(unicode(image)) if not preview.isNull(): preview = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) diff --git a/openlp/plugins/songs/lib/olp1import.py b/openlp/plugins/songs/lib/olp1import.py index f1f82cdd3..75a9e60bd 100644 --- a/openlp/plugins/songs/lib/olp1import.py +++ b/openlp/plugins/songs/lib/olp1import.py @@ -61,8 +61,7 @@ class OpenLP1SongImport(SongImport): The database providing the data to import. """ SongImport.__init__(self, manager, **kwargs) - self.availableThemes = \ - kwargs[u'plugin'].formParent.themeManagerContents.get_themes() + self.availableThemes = kwargs[u'plugin'].theme_manager.get_themes() def doImport(self): """ From 42ff12dc4811e8feb9d8ac83c6e46d0a09f288aa Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 2 Feb 2013 07:34:42 +0000 Subject: [PATCH 33/64] more tweeks --- openlp/core/lib/mediamanageritem.py | 1 - openlp/core/lib/renderer.py | 1 + openlp/core/lib/settingstab.py | 9 +++++++++ openlp/core/ui/firsttimeform.py | 14 ++++++++++++-- openlp/core/ui/media/playertab.py | 2 +- openlp/core/ui/servicemanagerdialog.py | 2 +- openlp/core/ui/themeform.py | 1 - 7 files changed, 24 insertions(+), 6 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index f3cfc6e53..4f559837c 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -698,4 +698,3 @@ class MediaManagerItem(QtGui.QWidget): theme_manager = property(_get_theme_manager) - diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index a7b0756e3..89966c1db 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -662,3 +662,4 @@ class Renderer(object): return self._theme_manager theme_manager = property(_get_theme_manager) + diff --git a/openlp/core/lib/settingstab.py b/openlp/core/lib/settingstab.py index aee4b1b5a..9882dceb6 100644 --- a/openlp/core/lib/settingstab.py +++ b/openlp/core/lib/settingstab.py @@ -174,4 +174,13 @@ class SettingsTab(QtGui.QWidget): theme_manager = property(_get_theme_manager) + def _get_media_controller(self): + """ + Adds the media controller to the class dynamically + """ + if not hasattr(self, u'_media_controller'): + self._media_controller = Registry().get(u'media_controller') + return self._media_controller + + media_controller = property(_get_media_controller) diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index c5219320d..6ba8a8df9 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -39,7 +39,7 @@ from ConfigParser import SafeConfigParser from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, PluginStatus, Receiver, build_icon, check_directory_exists, Settings +from openlp.core.lib import translate, PluginStatus, Receiver, build_icon, check_directory_exists, Settings, Registry from openlp.core.utils import get_web_page, AppLocation, get_filesystem_encoding from firsttimewizard import Ui_FirstTimeWizard, FirstTimePage @@ -198,7 +198,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): self.themeComboBox.addItem(item.text()) if self.hasRunWizard: # Add any existing themes to list. - for theme in self.parent().themeManagerContents.get_themes(): + for theme in self.theme_manager.get_themes(): index = self.themeComboBox.findText(theme) if index == -1: self.themeComboBox.addItem(theme) @@ -461,3 +461,13 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): def _setPluginStatus(self, field, tag): status = PluginStatus.Active if field.checkState() == QtCore.Qt.Checked else PluginStatus.Inactive Settings().setValue(tag, status) + + def _get_theme_manager(self): + """ + Adds the theme manager to the class dynamically + """ + if not hasattr(self, u'_theme_manager'): + self._theme_manager = Registry().get(u'theme_manager') + return self._theme_manager + + theme_manager = property(_get_theme_manager) diff --git a/openlp/core/ui/media/playertab.py b/openlp/core/ui/media/playertab.py index 4d575dfad..f50a32dd9 100644 --- a/openlp/core/ui/media/playertab.py +++ b/openlp/core/ui/media/playertab.py @@ -46,7 +46,7 @@ class PlayerTab(SettingsTab): MediaTab is the Media settings tab in the settings dialog. """ def __init__(self, parent): - self.mediaPlayers = self.main_window.mediaController.mediaPlayers + self.mediaPlayers = self.media_controller.mediaPlayers self.savedUsedPlayers = None self.iconPath = u':/media/multimedia-player.png' player_translated = translate('OpenLP.PlayerTab', 'Players') diff --git a/openlp/core/ui/servicemanagerdialog.py b/openlp/core/ui/servicemanagerdialog.py index 3d0f41b8b..e676d6060 100644 --- a/openlp/core/ui/servicemanagerdialog.py +++ b/openlp/core/ui/servicemanagerdialog.py @@ -265,4 +265,4 @@ class ServiceManagerDialog(object): ``event`` Handle of the event pint passed """ - event.accept() \ No newline at end of file + event.accept() diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index b2ce16386..c90bbce12 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -546,4 +546,3 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): return self._theme_manager theme_manager = property(_get_theme_manager) - \ No newline at end of file From f75b3ffdaf7258833acfa2cd710e7ec87dd99852 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sat, 2 Feb 2013 14:09:22 +0000 Subject: [PATCH 34/64] Fixes bug 1113446 --- .../plugins/presentations/lib/pptviewcontroller.py | 2 +- .../presentations/lib/presentationcontroller.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/presentations/lib/pptviewcontroller.py b/openlp/plugins/presentations/lib/pptviewcontroller.py index 7b0be4c59..ec3adebe4 100644 --- a/openlp/plugins/presentations/lib/pptviewcontroller.py +++ b/openlp/plugins/presentations/lib/pptviewcontroller.py @@ -83,7 +83,7 @@ class PptviewController(PresentationController): if self.process: return log.debug(u'start PPTView') - dllpath = os.path.join(self.plugin.pluginManager.basepath, u'presentations', u'lib', u'pptviewlib', + dllpath = os.path.join(self.plugin_manager.basepath, u'presentations', u'lib', u'pptviewlib', u'pptviewlib.dll') self.process = cdll.LoadLibrary(dllpath) if log.isEnabledFor(logging.DEBUG): diff --git a/openlp/plugins/presentations/lib/presentationcontroller.py b/openlp/plugins/presentations/lib/presentationcontroller.py index 0051b1d0a..bbf9662cd 100644 --- a/openlp/plugins/presentations/lib/presentationcontroller.py +++ b/openlp/plugins/presentations/lib/presentationcontroller.py @@ -33,7 +33,7 @@ import shutil from PyQt4 import QtCore -from openlp.core.lib import Receiver, check_directory_exists, create_thumb, validate_thumb, Settings +from openlp.core.lib import Receiver, Registry, check_directory_exists, create_thumb, validate_thumb, Settings from openlp.core.utils import AppLocation log = logging.getLogger(__name__) @@ -438,3 +438,13 @@ class PresentationController(object): def close_presentation(self): pass + + def _get_plugin_manager(self): + """ + Adds the plugin manager to the class dynamically + """ + if not hasattr(self, u'_plugin_manager'): + self._plugin_manager = Registry().get(u'plugin_manager') + return self._plugin_manager + + plugin_manager = property(_get_plugin_manager) \ No newline at end of file From 7cc695f3bb7088423608a631aa26ef7002695dfa Mon Sep 17 00:00:00 2001 From: phill-ridout Date: Sat, 2 Feb 2013 17:44:07 +0000 Subject: [PATCH 35/64] New line at end of file added. --- openlp/plugins/presentations/lib/presentationcontroller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/presentations/lib/presentationcontroller.py b/openlp/plugins/presentations/lib/presentationcontroller.py index bbf9662cd..8f468de63 100644 --- a/openlp/plugins/presentations/lib/presentationcontroller.py +++ b/openlp/plugins/presentations/lib/presentationcontroller.py @@ -447,4 +447,4 @@ class PresentationController(object): self._plugin_manager = Registry().get(u'plugin_manager') return self._plugin_manager - plugin_manager = property(_get_plugin_manager) \ No newline at end of file + plugin_manager = property(_get_plugin_manager) From 4f2b21ddfae8393f096d2ac607026af06cdeb9a4 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 2 Feb 2013 19:49:56 +0000 Subject: [PATCH 36/64] Fix review comments --- openlp/core/ui/__init__.py | 3 +- openlp/core/ui/advancedtab.py | 74 +++---- openlp/core/ui/servicemanager.py | 244 +++++++++++++++++++++- openlp/core/ui/servicemanagerdialog.py | 268 ------------------------- 4 files changed, 279 insertions(+), 310 deletions(-) delete mode 100644 openlp/core/ui/servicemanagerdialog.py diff --git a/openlp/core/ui/__init__.py b/openlp/core/ui/__init__.py index 593404206..5122c1bd7 100644 --- a/openlp/core/ui/__init__.py +++ b/openlp/core/ui/__init__.py @@ -98,10 +98,9 @@ from settingsform import SettingsForm from formattingtagform import FormattingTagForm from shortcutlistform import ShortcutListForm from mediadockmanager import MediaDockManager -from servicemanagerdialog import ServiceManagerDialog from servicemanager import ServiceManager from thememanager import ThemeManager __all__ = ['SplashScreen', 'AboutForm', 'SettingsForm', 'MainDisplay', - 'SlideController', 'ServiceManagerDialog', 'ServiceManager', 'ThemeManager', 'MediaDockManager', + 'SlideController', 'ServiceManager', 'ThemeManager', 'MediaDockManager', 'ServiceItemEditForm', 'FirstTimeForm' ] diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index d27f7cd0c..a219b8091 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -107,11 +107,11 @@ class AdvancedTab(SettingsTab): self.service_name_day.setObjectName(u'service_name_day') self.service_name_time = QtGui.QTimeEdit(self.service_name_group_box) self.service_name_time.setObjectName(u'service_name_time') - self.service_name_timeHBox = QtGui.QHBoxLayout() - self.service_name_timeHBox.setObjectName(u'service_name_timeHBox') - self.service_name_timeHBox.addWidget(self.service_name_day) - self.service_name_timeHBox.addWidget(self.service_name_time) - self.service_name_layout.addRow(self.service_name_time_label, self.service_name_timeHBox) + self.service_name_time_layout = QtGui.QHBoxLayout() + self.service_name_time_layout.setObjectName(u'service_name_time_layout') + self.service_name_time_layout.addWidget(self.service_name_day) + self.service_name_time_layout.addWidget(self.service_name_time) + self.service_name_layout.addRow(self.service_name_time_label, self.service_name_time_layout) self.service_name_label = QtGui.QLabel(self.service_name_group_box) self.service_name_label.setObjectName(u'service_name_label') self.service_name_edit = QtGui.QLineEdit(self.service_name_group_box) @@ -120,11 +120,11 @@ class AdvancedTab(SettingsTab): self.service_name_revert_button = QtGui.QToolButton(self.service_name_group_box) self.service_name_revert_button.setObjectName(u'service_name_revert_button') self.service_name_revert_button.setIcon(build_icon(u':/general/general_revert.png')) - self.service_name_h_box = QtGui.QHBoxLayout() - self.service_name_h_box.setObjectName(u'service_name_h_box') - self.service_name_h_box.addWidget(self.service_name_edit) - self.service_name_h_box.addWidget(self.service_name_revert_button) - self.service_name_layout.addRow(self.service_name_label, self.service_name_h_box) + self.service_name_button_layout = QtGui.QHBoxLayout() + self.service_name_button_layout.setObjectName(u'service_name_layout_2') + self.service_name_button_layout.addWidget(self.service_name_edit) + self.service_name_button_layout.addWidget(self.service_name_revert_button) + self.service_name_layout.addRow(self.service_name_label, self.service_name_button_layout) self.service_name_example_label = QtGui.QLabel(self.service_name_group_box) self.service_name_example_label.setObjectName(u'service_name_example_label') self.service_name_example = QtGui.QLabel(self.service_name_group_box) @@ -157,21 +157,21 @@ class AdvancedTab(SettingsTab): self.data_directory_cancel_button = QtGui.QToolButton(self.data_directory_group_box) self.data_directory_cancel_button.setObjectName(u'data_directory_cancel_button') self.data_directory_cancel_button.setIcon(build_icon(u':/general/general_delete.png')) - self.new_data_directory_label_H_box = QtGui.QHBoxLayout() - self.new_data_directory_label_H_box.setObjectName(u'new_data_directory_label_H_box') - self.new_data_directory_label_H_box.addWidget(self.new_data_directory_edit) - self.new_data_directory_label_H_box.addWidget(self.data_directory_browse_button) - self.new_data_directory_label_H_box.addWidget(self.data_directory_default_button) - self.data_directory_copy_check_H_box = QtGui.QHBoxLayout() - self.data_directory_copy_check_H_box.setObjectName(u'data_directory_copy_check_H_box') + self.new_data_directory_label_layout = QtGui.QHBoxLayout() + self.new_data_directory_label_layout.setObjectName(u'new_data_directory_label_layout') + self.new_data_directory_label_layout.addWidget(self.new_data_directory_edit) + self.new_data_directory_label_layout.addWidget(self.data_directory_browse_button) + self.new_data_directory_label_layout.addWidget(self.data_directory_default_button) + self.data_directory_copy_check_layout = QtGui.QHBoxLayout() + self.data_directory_copy_check_layout.setObjectName(u'data_directory_copy_check_layout') self.data_directory_copy_check_box = QtGui.QCheckBox(self.data_directory_group_box) self.data_directory_copy_check_box.setObjectName(u'data_directory_copy_check_box') - self.data_directory_copy_check_H_box.addWidget(self.data_directory_copy_check_box) - self.data_directory_copy_check_H_box.addStretch() - self.data_directory_copy_check_H_box.addWidget(self.data_directory_cancel_button) + self.data_directory_copy_check_layout.addWidget(self.data_directory_copy_check_box) + self.data_directory_copy_check_layout.addStretch() + self.data_directory_copy_check_layout.addWidget(self.data_directory_cancel_button) self.data_directory_layout.addRow(self.data_directory_current_label, self.data_directory_label) - self.data_directory_layout.addRow(self.data_directory_new_label, self.new_data_directory_label_H_box) - self.data_directory_layout.addRow(self.data_directory_copy_check_H_box) + self.data_directory_layout.addRow(self.data_directory_new_label, self.new_data_directory_label_layout) + self.data_directory_layout.addRow(self.data_directory_copy_check_layout) self.data_directory_layout.addRow(self.new_data_directory_has_files_label) self.leftLayout.addWidget(self.data_directory_group_box) self.leftLayout.addStretch() @@ -195,39 +195,39 @@ class AdvancedTab(SettingsTab): self.default_revert_button = QtGui.QToolButton(self.default_image_group_box) self.default_revert_button.setObjectName(u'default_revert_button') self.default_revert_button.setIcon(build_icon(u':/general/general_revert.png')) - self.defaultFileLayout = QtGui.QHBoxLayout() - self.defaultFileLayout.setObjectName(u'defaultFileLayout') - self.defaultFileLayout.addWidget(self.default_file_edit) - self.defaultFileLayout.addWidget(self.default_browse_button) - self.defaultFileLayout.addWidget(self.default_revert_button) - self.default_image_layout.addRow(self.default_file_label, self.defaultFileLayout) + self.default_file_layout = QtGui.QHBoxLayout() + self.default_file_layout.setObjectName(u'default_file_layout') + self.default_file_layout.addWidget(self.default_file_edit) + self.default_file_layout.addWidget(self.default_browse_button) + self.default_file_layout.addWidget(self.default_revert_button) + self.default_image_layout.addRow(self.default_file_label, self.default_file_layout) self.rightLayout.addWidget(self.default_image_group_box) # Hide mouse self.hide_mouse_group_box = QtGui.QGroupBox(self.rightColumn) self.hide_mouse_group_box.setObjectName(u'hide_mouse_group_box') - self.hideMouseLayout = QtGui.QVBoxLayout(self.hide_mouse_group_box) - self.hideMouseLayout.setObjectName(u'hideMouseLayout') + self.hide_mouse_layout = QtGui.QVBoxLayout(self.hide_mouse_group_box) + self.hide_mouse_layout.setObjectName(u'hide_mouse_layout') self.hide_mouse_check_box = QtGui.QCheckBox(self.hide_mouse_group_box) self.hide_mouse_check_box.setObjectName(u'hide_mouse_check_box') - self.hideMouseLayout.addWidget(self.hide_mouse_check_box) + self.hide_mouse_layout.addWidget(self.hide_mouse_check_box) self.rightLayout.addWidget(self.hide_mouse_group_box) # Service Item Slide Limits self.slide_group_box = QtGui.QGroupBox(self.rightColumn) self.slide_group_box.setObjectName(u'slide_group_box') - self.slideLayout = QtGui.QVBoxLayout(self.slide_group_box) - self.slideLayout.setObjectName(u'slideLayout') + self.slide_layout = QtGui.QVBoxLayout(self.slide_group_box) + self.slide_layout.setObjectName(u'slide_layout') self.slide_label = QtGui.QLabel(self.slide_group_box) self.slide_label.setWordWrap(True) - self.slideLayout.addWidget(self.slide_label) + self.slide_layout.addWidget(self.slide_label) self.end_slide_radio_button = QtGui.QRadioButton(self.slide_group_box) self.end_slide_radio_button.setObjectName(u'end_slide_radio_button') - self.slideLayout.addWidget(self.end_slide_radio_button) + self.slide_layout.addWidget(self.end_slide_radio_button) self.wrap_slide_radio_button = QtGui.QRadioButton(self.slide_group_box) self.wrap_slide_radio_button.setObjectName(u'wrap_slide_radio_button') - self.slideLayout.addWidget(self.wrap_slide_radio_button) + self.slide_layout.addWidget(self.wrap_slide_radio_button) self.next_item_radio_button = QtGui.QRadioButton(self.slide_group_box) self.next_item_radio_button.setObjectName(u'next_item_radio_button') - self.slideLayout.addWidget(self.next_item_radio_button) + self.slide_layout.addWidget(self.next_item_radio_button) self.rightLayout.addWidget(self.slide_group_box) # Display Workarounds self.display_workaround_group_box = QtGui.QGroupBox(self.leftColumn) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 77082f2d3..ff3d0721e 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -39,13 +39,251 @@ log = logging.getLogger(__name__) from PyQt4 import QtCore, QtGui -from openlp.core.lib import ServiceItem, Receiver, build_icon, ItemCapabilities, SettingsManager, \ +from openlp.core.lib import OpenLPToolbar, ServiceItem, Receiver, build_icon, ItemCapabilities, SettingsManager, \ translate, str_to_bool, check_directory_exists, Settings, PluginStatus, Registry, UiStrings from openlp.core.lib.theme import ThemeLevel from openlp.core.lib.ui import critical_error_message_box, create_widget_action, find_and_set_in_combo_box -from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm, ServiceManagerDialog +from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm from openlp.core.ui.printserviceform import PrintServiceForm -from openlp.core.utils import delete_file, split_filename, format_time +from openlp.core.utils import AppLocation, delete_file, split_filename, format_time +from openlp.core.utils.actions import ActionList, CategoryOrder + +class ServiceManagerList(QtGui.QTreeWidget): + """ + Set up key bindings and mouse behaviour for the service list + """ + def __init__(self, serviceManager, parent=None): + QtGui.QTreeWidget.__init__(self, parent) + self.serviceManager = serviceManager + + def keyPressEvent(self, event): + """ + Capture Key press and respond accordingly. + """ + if isinstance(event, QtGui.QKeyEvent): + # here accept the event and do something + if event.key() == QtCore.Qt.Key_Up: + self.serviceManager.on_move_selection_up() + event.accept() + elif event.key() == QtCore.Qt.Key_Down: + self.serviceManager.on_move_selection_down() + event.accept() + elif event.key() == QtCore.Qt.Key_Delete: + self.serviceManager.onDeleteFromService() + event.accept() + event.ignore() + else: + event.ignore() + + def mouseMoveEvent(self, event): + """ + Drag and drop event does not care what data is selected + as the recipient will use events to request the data move + just tell it what plugin to call + """ + if event.buttons() != QtCore.Qt.LeftButton: + event.ignore() + return + if not self.itemAt(self.mapFromGlobal(QtGui.QCursor.pos())): + event.ignore() + return + drag = QtGui.QDrag(self) + mime_data = QtCore.QMimeData() + drag.setMimeData(mime_data) + mime_data.setText(u'ServiceManager') + drag.start(QtCore.Qt.CopyAction) + +class ServiceManagerDialog(object): + """ + UI part of the Service Manager + """ + def setup_ui(self, widget): + """ + Define the UI + """ + # Create the top toolbar + self.toolbar = OpenLPToolbar(self) + self.toolbar.addToolbarAction(u'newService', text=UiStrings().NewService, icon=u':/general/general_new.png', + tooltip=UiStrings().CreateService, triggers=self.on_new_service_clicked) + self.toolbar.addToolbarAction(u'openService', text=UiStrings().OpenService, icon=u':/general/general_open.png', + tooltip=translate('OpenLP.ServiceManager', 'Load an existing service.'), + triggers=self.on_load_service_clicked) + self.toolbar.addToolbarAction(u'saveService', text=UiStrings().SaveService, icon=u':/general/general_save.png', + tooltip=translate('OpenLP.ServiceManager', 'Save this service.'), triggers=self.decide_save_method) + self.toolbar.addSeparator() + self.theme_label = QtGui.QLabel(u'%s:' % UiStrings().Theme, self) + self.theme_label.setMargin(3) + self.theme_label.setObjectName(u'theme_label') + self.toolbar.addToolbarWidget(self.theme_label) + self.theme_combo_box = QtGui.QComboBox(self.toolbar) + self.theme_combo_box.setToolTip(translate('OpenLP.ServiceManager', 'Select a theme for the service.')) + self.theme_combo_box.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength) + self.theme_combo_box.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) + self.theme_combo_box.setObjectName(u'theme_combo_box') + self.toolbar.addToolbarWidget(self.theme_combo_box) + self.toolbar.setObjectName(u'toolbar') + self.layout.addWidget(self.toolbar) + # Create the service manager list + self.service_manager_list = ServiceManagerList(self) + self.service_manager_list.setEditTriggers( + QtGui.QAbstractItemView.CurrentChanged | + QtGui.QAbstractItemView.DoubleClicked | + QtGui.QAbstractItemView.EditKeyPressed) + self.service_manager_list.setDragDropMode(QtGui.QAbstractItemView.DragDrop) + self.service_manager_list.setAlternatingRowColors(True) + self.service_manager_list.setHeaderHidden(True) + self.service_manager_list.setExpandsOnDoubleClick(False) + self.service_manager_list.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL('customContextMenuRequested(QPoint)'), + self.context_menu) + self.service_manager_list.setObjectName(u'service_manager_list') + # enable drop + self.service_manager_list.__class__.dragEnterEvent = self.drag_enter_event + self.service_manager_list.__class__.dragMoveEvent = self.drag_enter_event + self.service_manager_list.__class__.dropEvent = self.drop_event + self.layout.addWidget(self.service_manager_list) + # Add the bottom toolbar + self.order_toolbar = OpenLPToolbar(self) + action_list = ActionList.get_instance() + action_list.add_category(UiStrings().Service, CategoryOrder.standardToolbar) + self.service_manager_list.moveTop = self.order_toolbar.addToolbarAction(u'moveTop', + text=translate('OpenLP.ServiceManager', 'Move to &top'), icon=u':/services/service_top.png', + tooltip=translate('OpenLP.ServiceManager', 'Move item to the top of the service.'), + shortcuts=[QtCore.Qt.Key_Home], category=UiStrings().Service, triggers=self.onServiceTop) + self.service_manager_list.moveUp = self.order_toolbar.addToolbarAction(u'moveUp', + text=translate('OpenLP.ServiceManager', 'Move &up'), icon=u':/services/service_up.png', + tooltip=translate('OpenLP.ServiceManager', 'Move item up one position in the service.'), + shortcuts=[QtCore.Qt.Key_PageUp], category=UiStrings().Service, triggers=self.onServiceUp) + self.service_manager_list.moveDown = self.order_toolbar.addToolbarAction(u'moveDown', + text=translate('OpenLP.ServiceManager', 'Move &down'), icon=u':/services/service_down.png', + tooltip=translate('OpenLP.ServiceManager', 'Move item down one position in the service.'), + shortcuts=[QtCore.Qt.Key_PageDown], category=UiStrings().Service, triggers=self.onServiceDown) + self.service_manager_list.moveBottom = self.order_toolbar.addToolbarAction(u'moveBottom', + text=translate('OpenLP.ServiceManager', 'Move to &bottom'), icon=u':/services/service_bottom.png', + tooltip=translate('OpenLP.ServiceManager', 'Move item to the end of the service.'), + shortcuts=[QtCore.Qt.Key_End], category=UiStrings().Service, triggers=self.onServiceEnd) + self.service_manager_list.down = self.order_toolbar.addToolbarAction(u'down', + text=translate('OpenLP.ServiceManager', 'Move &down'), + tooltip=translate('OpenLP.ServiceManager', 'Moves the selection down the window.'), visible=False, + shortcuts=[QtCore.Qt.Key_Down], triggers=self.on_move_selection_down) + action_list.add_action(self.service_manager_list.down) + self.service_manager_list.up = self.order_toolbar.addToolbarAction(u'up', + text=translate('OpenLP.ServiceManager', 'Move up'), tooltip=translate('OpenLP.ServiceManager', + 'Moves the selection up the window.'), visible=False, shortcuts=[QtCore.Qt.Key_Up], + triggers=self.on_move_selection_up) + action_list.add_action(self.service_manager_list.up) + self.order_toolbar.addSeparator() + self.service_manager_list.delete = self.order_toolbar.addToolbarAction(u'delete', + text=translate('OpenLP.ServiceManager', '&Delete From Service'), icon=u':/general/general_delete.png', + tooltip=translate('OpenLP.ServiceManager', 'Delete the selected item from the service.'), + shortcuts=[QtCore.Qt.Key_Delete], triggers=self.onDeleteFromService) + self.order_toolbar.addSeparator() + self.service_manager_list.expand = self.order_toolbar.addToolbarAction(u'expand', + text=translate('OpenLP.ServiceManager', '&Expand all'), icon=u':/services/service_expand_all.png', + tooltip=translate('OpenLP.ServiceManager', 'Expand all the service items.'), + shortcuts=[QtCore.Qt.Key_Plus], category=UiStrings().Service, triggers=self.onExpandAll) + self.service_manager_list.collapse = self.order_toolbar.addToolbarAction(u'collapse', + text=translate('OpenLP.ServiceManager', '&Collapse all'), icon=u':/services/service_collapse_all.png', + tooltip=translate('OpenLP.ServiceManager', 'Collapse all the service items.'), + shortcuts=[QtCore.Qt.Key_Minus], category=UiStrings().Service, triggers=self.onCollapseAll) + self.order_toolbar.addSeparator() + self.service_manager_list.make_live = self.order_toolbar.addToolbarAction(u'make_live', + text=translate('OpenLP.ServiceManager', 'Go Live'), icon=u':/general/general_live.png', + tooltip=translate('OpenLP.ServiceManager', 'Send the selected item to Live.'), + shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return], category=UiStrings().Service, + triggers=self.make_live) + self.layout.addWidget(self.order_toolbar) + # Connect up our signals and slots + QtCore.QObject.connect(self.theme_combo_box, QtCore.SIGNAL(u'activated(int)'), + self.on_theme_combo_box_selected) + QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), + self.on_make_live) + QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL(u'itemCollapsed(QTreeWidgetItem*)'), + self.collapsed) + QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL(u'itemExpanded(QTreeWidgetItem*)'), + self.expanded) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.update_theme_list) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_preview_live'), + self.preview_live) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_next_item'), self.next_item) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_previous_item'), + self.previous_item) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_set_item'), self.on_set_item) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.config_updated) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'), + self.regenerate_service_Items) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_global'), self.theme_change) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'service_item_update'), + self.service_item_update) + # Last little bits of setting up + self.service_theme = Settings().value(self.main_window.serviceManagerSettingsSection + u'/service theme') + self.servicePath = AppLocation.get_section_data_path(u'servicemanager') + # build the drag and drop context menu + self.dndMenu = QtGui.QMenu() + self.newAction = self.dndMenu.addAction(translate('OpenLP.ServiceManager', '&Add New Item')) + self.newAction.setIcon(build_icon(u':/general/general_edit.png')) + self.addToAction = self.dndMenu.addAction(translate('OpenLP.ServiceManager', '&Add to Selected Item')) + self.addToAction.setIcon(build_icon(u':/general/general_edit.png')) + # build the context menu + self.menu = QtGui.QMenu() + self.edit_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Edit Item'), + icon=u':/general/general_edit.png', triggers=self.remote_edit) + self.maintain_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Reorder Item'), + icon=u':/general/general_edit.png', triggers=self.on_service_item_edit_form) + self.notes_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Notes'), + icon=u':/services/service_notes.png', triggers=self.on_service_item_note_form) + self.time_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Start Time'), + icon=u':/media/media_time.png', triggers=self.on_start_time_form) + self.auto_start_action = create_widget_action(self.menu, text=u'', + icon=u':/media/auto-start_active.png', triggers=self.on_auto_start) + # Add already existing delete action to the menu. + self.menu.addAction(self.service_manager_list.delete) + self.create_custom_action = create_widget_action(self.menu, + text=translate('OpenLP.ServiceManager', 'Create New &Custom Slide'), + icon=u':/general/general_edit.png', triggers=self.create_custom) + self.menu.addSeparator() + # Add AutoPlay menu actions + self.auto_play_slides_group = QtGui.QMenu(translate('OpenLP.ServiceManager', '&Auto play slides')) + self.menu.addMenu(self.auto_play_slides_group) + self.auto_play_slides_loop = create_widget_action(self.auto_play_slides_group, + text=translate('OpenLP.ServiceManager', 'Auto play slides &Loop'), + checked=False, triggers=self.toggle_auto_play_slides_loop) + self.auto_play_slides_once = create_widget_action(self.auto_play_slides_group, + text=translate('OpenLP.ServiceManager', 'Auto play slides &Once'), + checked=False, triggers=self.toggle_auto_play_slides_once) + self.auto_play_slides_group.addSeparator() + self.timed_slide_interval = create_widget_action(self.auto_play_slides_group, + text=translate('OpenLP.ServiceManager', '&Delay between slides'), + checked=False, triggers=self.on_timed_slide_interval) + self.menu.addSeparator() + self.preview_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', 'Show &Preview'), + icon=u':/general/general_preview.png', triggers=self.make_preview) + # Add already existing make live action to the menu. + self.menu.addAction(self.service_manager_list.make_live) + self.menu.addSeparator() + self.theme_menu = QtGui.QMenu(translate('OpenLP.ServiceManager', '&Change Item Theme')) + self.menu.addMenu(self.theme_menu) + self.service_manager_list.addActions( + [self.service_manager_list.moveDown, + self.service_manager_list.moveUp, + self.service_manager_list.make_live, + self.service_manager_list.moveTop, + self.service_manager_list.moveBottom, + self.service_manager_list.up, + self.service_manager_list.down, + self.service_manager_list.expand, + self.service_manager_list.collapse + ]) + + def drag_enter_event(self, event): + """ + Accept Drag events + + ``event`` + Handle of the event pint passed + """ + event.accept() + class ServiceManager(QtGui.QWidget, ServiceManagerDialog): """ diff --git a/openlp/core/ui/servicemanagerdialog.py b/openlp/core/ui/servicemanagerdialog.py deleted file mode 100644 index e676d6060..000000000 --- a/openlp/core/ui/servicemanagerdialog.py +++ /dev/null @@ -1,268 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2013 Raoul Snyman # -# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan # -# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # -# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # -# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # -# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # -# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # -# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### - -from openlp.core.lib import OpenLPToolbar, translate, UiStrings, Receiver, build_icon, Settings -from openlp.core.lib.ui import create_widget_action -from openlp.core.utils.actions import ActionList, CategoryOrder -from openlp.core.utils import AppLocation - -from PyQt4 import QtCore, QtGui - -class ServiceManagerList(QtGui.QTreeWidget): - """ - Set up key bindings and mouse behaviour for the service list - """ - def __init__(self, serviceManager, parent=None): - QtGui.QTreeWidget.__init__(self, parent) - self.serviceManager = serviceManager - - def keyPressEvent(self, event): - """ - Capture Key press and respond accordingly. - """ - if isinstance(event, QtGui.QKeyEvent): - # here accept the event and do something - if event.key() == QtCore.Qt.Key_Up: - self.serviceManager.on_move_selection_up() - event.accept() - elif event.key() == QtCore.Qt.Key_Down: - self.serviceManager.on_move_selection_down() - event.accept() - elif event.key() == QtCore.Qt.Key_Delete: - self.serviceManager.onDeleteFromService() - event.accept() - event.ignore() - else: - event.ignore() - - def mouseMoveEvent(self, event): - """ - Drag and drop event does not care what data is selected - as the recipient will use events to request the data move - just tell it what plugin to call - """ - if event.buttons() != QtCore.Qt.LeftButton: - event.ignore() - return - if not self.itemAt(self.mapFromGlobal(QtGui.QCursor.pos())): - event.ignore() - return - drag = QtGui.QDrag(self) - mime_data = QtCore.QMimeData() - drag.setMimeData(mime_data) - mime_data.setText(u'ServiceManager') - drag.start(QtCore.Qt.CopyAction) - -class ServiceManagerDialog(object): - """ - UI part of the Service Manager - """ - def setup_ui(self,widget): - # Create the top toolbar - self.toolbar = OpenLPToolbar(self) - self.toolbar.addToolbarAction(u'newService', text=UiStrings().NewService, icon=u':/general/general_new.png', - tooltip=UiStrings().CreateService, triggers=self.on_new_service_clicked) - self.toolbar.addToolbarAction(u'openService', text=UiStrings().OpenService, icon=u':/general/general_open.png', - tooltip=translate('OpenLP.ServiceManager', 'Load an existing service.'), - triggers=self.on_load_service_clicked) - self.toolbar.addToolbarAction(u'saveService', text=UiStrings().SaveService, icon=u':/general/general_save.png', - tooltip=translate('OpenLP.ServiceManager', 'Save this service.'), triggers=self.decide_save_method) - self.toolbar.addSeparator() - self.theme_label = QtGui.QLabel(u'%s:' % UiStrings().Theme, self) - self.theme_label.setMargin(3) - self.theme_label.setObjectName(u'theme_label') - self.toolbar.addToolbarWidget(self.theme_label) - self.theme_combo_box = QtGui.QComboBox(self.toolbar) - self.theme_combo_box.setToolTip(translate('OpenLP.ServiceManager', 'Select a theme for the service.')) - self.theme_combo_box.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength) - self.theme_combo_box.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) - self.theme_combo_box.setObjectName(u'theme_combo_box') - self.toolbar.addToolbarWidget(self.theme_combo_box) - self.toolbar.setObjectName(u'toolbar') - self.layout.addWidget(self.toolbar) - # Create the service manager list - self.service_manager_list = ServiceManagerList(self) - self.service_manager_list.setEditTriggers( - QtGui.QAbstractItemView.CurrentChanged | - QtGui.QAbstractItemView.DoubleClicked | - QtGui.QAbstractItemView.EditKeyPressed) - self.service_manager_list.setDragDropMode(QtGui.QAbstractItemView.DragDrop) - self.service_manager_list.setAlternatingRowColors(True) - self.service_manager_list.setHeaderHidden(True) - self.service_manager_list.setExpandsOnDoubleClick(False) - self.service_manager_list.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) - QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL('customContextMenuRequested(QPoint)'), - self.context_menu) - self.service_manager_list.setObjectName(u'service_manager_list') - # enable drop - self.service_manager_list.__class__.dragEnterEvent = self.drag_enter_event - self.service_manager_list.__class__.dragMoveEvent = self.drag_enter_event - self.service_manager_list.__class__.dropEvent = self.drop_event - self.layout.addWidget(self.service_manager_list) - # Add the bottom toolbar - self.order_toolbar = OpenLPToolbar(self) - action_list = ActionList.get_instance() - action_list.add_category(UiStrings().Service, CategoryOrder.standardToolbar) - self.service_manager_list.moveTop = self.order_toolbar.addToolbarAction(u'moveTop', - text=translate('OpenLP.ServiceManager', 'Move to &top'), icon=u':/services/service_top.png', - tooltip=translate('OpenLP.ServiceManager', 'Move item to the top of the service.'), - shortcuts=[QtCore.Qt.Key_Home], category=UiStrings().Service, triggers=self.onServiceTop) - self.service_manager_list.moveUp = self.order_toolbar.addToolbarAction(u'moveUp', - text=translate('OpenLP.ServiceManager', 'Move &up'), icon=u':/services/service_up.png', - tooltip=translate('OpenLP.ServiceManager', 'Move item up one position in the service.'), - shortcuts=[QtCore.Qt.Key_PageUp], category=UiStrings().Service, triggers=self.onServiceUp) - self.service_manager_list.moveDown = self.order_toolbar.addToolbarAction(u'moveDown', - text=translate('OpenLP.ServiceManager', 'Move &down'), icon=u':/services/service_down.png', - tooltip=translate('OpenLP.ServiceManager', 'Move item down one position in the service.'), - shortcuts=[QtCore.Qt.Key_PageDown], category=UiStrings().Service, triggers=self.onServiceDown) - self.service_manager_list.moveBottom = self.order_toolbar.addToolbarAction(u'moveBottom', - text=translate('OpenLP.ServiceManager', 'Move to &bottom'), icon=u':/services/service_bottom.png', - tooltip=translate('OpenLP.ServiceManager', 'Move item to the end of the service.'), - shortcuts=[QtCore.Qt.Key_End], category=UiStrings().Service, triggers=self.onServiceEnd) - self.service_manager_list.down = self.order_toolbar.addToolbarAction(u'down', - text=translate('OpenLP.ServiceManager', 'Move &down'), - tooltip=translate('OpenLP.ServiceManager', 'Moves the selection down the window.'), visible=False, - shortcuts=[QtCore.Qt.Key_Down], triggers=self.on_move_selection_down) - action_list.add_action(self.service_manager_list.down) - self.service_manager_list.up = self.order_toolbar.addToolbarAction(u'up', - text=translate('OpenLP.ServiceManager', 'Move up'), tooltip=translate('OpenLP.ServiceManager', - 'Moves the selection up the window.'), visible=False, shortcuts=[QtCore.Qt.Key_Up], - triggers=self.on_move_selection_up) - action_list.add_action(self.service_manager_list.up) - self.order_toolbar.addSeparator() - self.service_manager_list.delete = self.order_toolbar.addToolbarAction(u'delete', - text=translate('OpenLP.ServiceManager', '&Delete From Service'), icon=u':/general/general_delete.png', - tooltip=translate('OpenLP.ServiceManager', 'Delete the selected item from the service.'), - shortcuts=[QtCore.Qt.Key_Delete], triggers=self.onDeleteFromService) - self.order_toolbar.addSeparator() - self.service_manager_list.expand = self.order_toolbar.addToolbarAction(u'expand', - text=translate('OpenLP.ServiceManager', '&Expand all'), icon=u':/services/service_expand_all.png', - tooltip=translate('OpenLP.ServiceManager', 'Expand all the service items.'), - shortcuts=[QtCore.Qt.Key_Plus], category=UiStrings().Service, triggers=self.onExpandAll) - self.service_manager_list.collapse = self.order_toolbar.addToolbarAction(u'collapse', - text=translate('OpenLP.ServiceManager', '&Collapse all'), icon=u':/services/service_collapse_all.png', - tooltip=translate('OpenLP.ServiceManager', 'Collapse all the service items.'), - shortcuts=[QtCore.Qt.Key_Minus], category=UiStrings().Service, triggers=self.onCollapseAll) - self.order_toolbar.addSeparator() - self.service_manager_list.make_live = self.order_toolbar.addToolbarAction(u'make_live', - text=translate('OpenLP.ServiceManager', 'Go Live'), icon=u':/general/general_live.png', - tooltip=translate('OpenLP.ServiceManager', 'Send the selected item to Live.'), - shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return], category=UiStrings().Service, - triggers=self.make_live) - self.layout.addWidget(self.order_toolbar) - # Connect up our signals and slots - QtCore.QObject.connect(self.theme_combo_box, QtCore.SIGNAL(u'activated(int)'), - self.on_theme_combo_box_selected) - QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), - self.on_make_live) - QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL(u'itemCollapsed(QTreeWidgetItem*)'), - self.collapsed) - QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL(u'itemExpanded(QTreeWidgetItem*)'), - self.expanded) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.update_theme_list) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_preview_live'), - self.preview_live) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_next_item'), self.next_item) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_previous_item'), - self.previous_item) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_set_item'), self.on_set_item) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.config_updated) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'), - self.regenerate_service_Items) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_global'), self.theme_change) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'service_item_update'), - self.service_item_update) - # Last little bits of setting up - self.service_theme = Settings().value(self.main_window.serviceManagerSettingsSection + u'/service theme') - self.servicePath = AppLocation.get_section_data_path(u'servicemanager') - # build the drag and drop context menu - self.dndMenu = QtGui.QMenu() - self.newAction = self.dndMenu.addAction(translate('OpenLP.ServiceManager', '&Add New Item')) - self.newAction.setIcon(build_icon(u':/general/general_edit.png')) - self.addToAction = self.dndMenu.addAction(translate('OpenLP.ServiceManager', '&Add to Selected Item')) - self.addToAction.setIcon(build_icon(u':/general/general_edit.png')) - # build the context menu - self.menu = QtGui.QMenu() - self.edit_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Edit Item'), - icon=u':/general/general_edit.png', triggers=self.remote_edit) - self.maintain_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Reorder Item'), - icon=u':/general/general_edit.png', triggers=self.on_service_item_edit_form) - self.notes_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Notes'), - icon=u':/services/service_notes.png', triggers=self.on_service_item_note_form) - self.time_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Start Time'), - icon=u':/media/media_time.png', triggers=self.on_start_time_form) - self.auto_start_action = create_widget_action(self.menu, text=u'', - icon=u':/media/auto-start_active.png', triggers=self.on_auto_start) - # Add already existing delete action to the menu. - self.menu.addAction(self.service_manager_list.delete) - self.create_custom_action = create_widget_action(self.menu, - text=translate('OpenLP.ServiceManager', 'Create New &Custom Slide'), - icon=u':/general/general_edit.png', triggers=self.create_custom) - self.menu.addSeparator() - # Add AutoPlay menu actions - self.auto_play_slides_group = QtGui.QMenu(translate('OpenLP.ServiceManager', '&Auto play slides')) - self.menu.addMenu(self.auto_play_slides_group) - self.auto_play_slides_loop = create_widget_action(self.auto_play_slides_group, - text=translate('OpenLP.ServiceManager', 'Auto play slides &Loop'), - checked=False, triggers=self.toggle_auto_play_slides_loop) - self.auto_play_slides_once = create_widget_action(self.auto_play_slides_group, - text=translate('OpenLP.ServiceManager', 'Auto play slides &Once'), - checked=False, triggers=self.toggle_auto_play_slides_once) - self.auto_play_slides_group.addSeparator() - self.timed_slide_interval = create_widget_action(self.auto_play_slides_group, - text=translate('OpenLP.ServiceManager', '&Delay between slides'), - checked=False, triggers=self.on_timed_slide_interval) - self.menu.addSeparator() - self.preview_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', 'Show &Preview'), - icon=u':/general/general_preview.png', triggers=self.make_preview) - # Add already existing make live action to the menu. - self.menu.addAction(self.service_manager_list.make_live) - self.menu.addSeparator() - self.theme_menu = QtGui.QMenu(translate('OpenLP.ServiceManager', '&Change Item Theme')) - self.menu.addMenu(self.theme_menu) - self.service_manager_list.addActions( - [self.service_manager_list.moveDown, - self.service_manager_list.moveUp, - self.service_manager_list.make_live, - self.service_manager_list.moveTop, - self.service_manager_list.moveBottom, - self.service_manager_list.up, - self.service_manager_list.down, - self.service_manager_list.expand, - self.service_manager_list.collapse - ]) - - def drag_enter_event(self, event): - """ - Accept Drag events - - ``event`` - Handle of the event pint passed - """ - event.accept() From 2f8bc1e2bbf8018a4fc96b5f8ca7f6ba4b2fe647 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 2 Feb 2013 22:18:34 +0200 Subject: [PATCH 37/64] More cleanups --- openlp/core/ui/advancedtab.py.orig | 696 +++++++++++++++++++++++++++ openlp/core/utils/__init__.py | 25 +- openlp/core/utils/actions.py | 63 +++ openlp/core/utils/languagemanager.py | 4 +- 4 files changed, 773 insertions(+), 15 deletions(-) create mode 100644 openlp/core/ui/advancedtab.py.orig diff --git a/openlp/core/ui/advancedtab.py.orig b/openlp/core/ui/advancedtab.py.orig new file mode 100644 index 000000000..3267afe08 --- /dev/null +++ b/openlp/core/ui/advancedtab.py.orig @@ -0,0 +1,696 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2013 Raoul Snyman # +# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### +""" +The :mod:`advancedtab` provides an advanced settings facility. +""" +from datetime import datetime, timedelta +import logging +import os +import sys + +from PyQt4 import QtCore, QtGui + +from openlp.core.lib import SettingsTab, Receiver, Settings, UiStrings, translate, build_icon +from openlp.core.utils import get_images_filter, AppLocation, format_time +from openlp.core.lib import SlideLimits + +log = logging.getLogger(__name__) + + +class AdvancedTab(SettingsTab): + """ + The :class:`AdvancedTab` manages the advanced settings tab including the UI + and the loading and saving of the displayed settings. + """ + def __init__(self, parent): + """ + Initialise the settings tab + """ + self.displayChanged = False + self.defaultImage = u':/graphics/openlp-splash-screen.png' + self.defaultColor = u'#ffffff' + self.dataExists = False + self.iconPath = u':/system/system_settings.png' + advanced_translated = translate('OpenLP.AdvancedTab', 'Advanced') + SettingsTab.__init__(self, parent, u'Advanced', advanced_translated) + + def setupUi(self): + """ + Configure the UI elements for the tab. + """ + self.setObjectName(u'AdvancedTab') + SettingsTab.setupUi(self) + self.uiGroupBox = QtGui.QGroupBox(self.leftColumn) + self.uiGroupBox.setObjectName(u'uiGroupBox') + self.uiLayout = QtGui.QFormLayout(self.uiGroupBox) + self.uiLayout.setObjectName(u'uiLayout') + self.recentLabel = QtGui.QLabel(self.uiGroupBox) + self.recentLabel.setObjectName(u'recentLabel') + self.recentSpinBox = QtGui.QSpinBox(self.uiGroupBox) + self.recentSpinBox.setObjectName(u'recentSpinBox') + self.recentSpinBox.setMinimum(0) + self.uiLayout.addRow(self.recentLabel, self.recentSpinBox) + self.mediaPluginCheckBox = QtGui.QCheckBox(self.uiGroupBox) + self.mediaPluginCheckBox.setObjectName(u'mediaPluginCheckBox') + self.uiLayout.addRow(self.mediaPluginCheckBox) + self.doubleClickLiveCheckBox = QtGui.QCheckBox(self.uiGroupBox) + self.doubleClickLiveCheckBox.setObjectName(u'doubleClickLiveCheckBox') + self.uiLayout.addRow(self.doubleClickLiveCheckBox) + self.singleClickPreviewCheckBox = QtGui.QCheckBox(self.uiGroupBox) + self.singleClickPreviewCheckBox.setObjectName(u'singleClickPreviewCheckBox') + self.uiLayout.addRow(self.singleClickPreviewCheckBox) + self.expandServiceItemCheckBox = QtGui.QCheckBox(self.uiGroupBox) + self.expandServiceItemCheckBox.setObjectName(u'expandServiceItemCheckBox') + self.uiLayout.addRow(self.expandServiceItemCheckBox) + self.enableAutoCloseCheckBox = QtGui.QCheckBox(self.uiGroupBox) + self.enableAutoCloseCheckBox.setObjectName(u'enableAutoCloseCheckBox') + self.uiLayout.addRow(self.enableAutoCloseCheckBox) + self.leftLayout.addWidget(self.uiGroupBox) + # Default service name + self.serviceNameGroupBox = QtGui.QGroupBox(self.leftColumn) + self.serviceNameGroupBox.setObjectName(u'serviceNameGroupBox') + self.serviceNameLayout = QtGui.QFormLayout(self.serviceNameGroupBox) + self.serviceNameCheckBox = QtGui.QCheckBox(self.serviceNameGroupBox) + self.serviceNameCheckBox.setObjectName(u'serviceNameCheckBox') + self.serviceNameLayout.setObjectName(u'serviceNameLayout') + self.serviceNameLayout.addRow(self.serviceNameCheckBox) + self.serviceNameTimeLabel = QtGui.QLabel(self.serviceNameGroupBox) + self.serviceNameTimeLabel.setObjectName(u'serviceNameTimeLabel') + self.serviceNameDay = QtGui.QComboBox(self.serviceNameGroupBox) + self.serviceNameDay.addItems([u'', u'', u'', u'', u'', u'', u'', u'']) + self.serviceNameDay.setObjectName(u'serviceNameDay') + self.serviceNameTime = QtGui.QTimeEdit(self.serviceNameGroupBox) + self.serviceNameTime.setObjectName(u'serviceNameTime') + self.serviceNameTimeHBox = QtGui.QHBoxLayout() + self.serviceNameTimeHBox.setObjectName(u'serviceNameTimeHBox') + self.serviceNameTimeHBox.addWidget(self.serviceNameDay) + self.serviceNameTimeHBox.addWidget(self.serviceNameTime) + self.serviceNameLayout.addRow(self.serviceNameTimeLabel, self.serviceNameTimeHBox) + self.serviceNameLabel = QtGui.QLabel(self.serviceNameGroupBox) + self.serviceNameLabel.setObjectName(u'serviceNameLabel') + self.serviceNameEdit = QtGui.QLineEdit(self.serviceNameGroupBox) + self.serviceNameEdit.setObjectName(u'serviceNameEdit') + self.serviceNameEdit.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp(r'[^/\\?*|<>\[\]":+]+'), self)) + self.serviceNameRevertButton = QtGui.QToolButton(self.serviceNameGroupBox) + self.serviceNameRevertButton.setObjectName(u'serviceNameRevertButton') + self.serviceNameRevertButton.setIcon(build_icon(u':/general/general_revert.png')) + self.serviceNameHBox = QtGui.QHBoxLayout() + self.serviceNameHBox.setObjectName(u'serviceNameHBox') + self.serviceNameHBox.addWidget(self.serviceNameEdit) + self.serviceNameHBox.addWidget(self.serviceNameRevertButton) + self.serviceNameLayout.addRow(self.serviceNameLabel, self.serviceNameHBox) + self.serviceNameExampleLabel = QtGui.QLabel(self.serviceNameGroupBox) + self.serviceNameExampleLabel.setObjectName(u'serviceNameExampleLabel') + self.serviceNameExample = QtGui.QLabel(self.serviceNameGroupBox) + self.serviceNameExample.setObjectName(u'serviceNameExample') + self.serviceNameLayout.addRow(self.serviceNameExampleLabel, self.serviceNameExample) + self.leftLayout.addWidget(self.serviceNameGroupBox) + # Data Directory + self.dataDirectoryGroupBox = QtGui.QGroupBox(self.leftColumn) + self.dataDirectoryGroupBox.setObjectName(u'dataDirectoryGroupBox') + self.dataDirectoryLayout = QtGui.QFormLayout(self.dataDirectoryGroupBox) + self.dataDirectoryLayout.setObjectName(u'dataDirectoryLayout') + self.dataDirectoryCurrentLabel = QtGui.QLabel(self.dataDirectoryGroupBox) + self.dataDirectoryCurrentLabel.setObjectName(u'dataDirectoryCurrentLabel') + self.dataDirectoryLabel = QtGui.QLabel(self.dataDirectoryGroupBox) + self.dataDirectoryLabel.setObjectName(u'dataDirectoryLabel') + self.dataDirectoryNewLabel = QtGui.QLabel(self.dataDirectoryGroupBox) + self.dataDirectoryNewLabel.setObjectName(u'dataDirectoryCurrentLabel') + self.newDataDirectoryEdit = QtGui.QLineEdit(self.dataDirectoryGroupBox) + self.newDataDirectoryEdit.setObjectName(u'newDataDirectoryEdit') + self.newDataDirectoryEdit.setReadOnly(True) + self.newDataDirectoryHasFilesLabel = QtGui.QLabel(self.dataDirectoryGroupBox) + self.newDataDirectoryHasFilesLabel.setObjectName(u'newDataDirectoryHasFilesLabel') + self.newDataDirectoryHasFilesLabel.setWordWrap(True) + self.dataDirectoryBrowseButton = QtGui.QToolButton(self.dataDirectoryGroupBox) + self.dataDirectoryBrowseButton.setObjectName(u'dataDirectoryBrowseButton') + self.dataDirectoryBrowseButton.setIcon(build_icon(u':/general/general_open.png')) + self.dataDirectoryDefaultButton = QtGui.QToolButton(self.dataDirectoryGroupBox) + self.dataDirectoryDefaultButton.setObjectName(u'dataDirectoryDefaultButton') + self.dataDirectoryDefaultButton.setIcon(build_icon(u':/general/general_revert.png')) + self.dataDirectoryCancelButton = QtGui.QToolButton(self.dataDirectoryGroupBox) + self.dataDirectoryCancelButton.setObjectName(u'dataDirectoryCancelButton') + self.dataDirectoryCancelButton.setIcon(build_icon(u':/general/general_delete.png')) + self.newDataDirectoryLabelHBox = QtGui.QHBoxLayout() + self.newDataDirectoryLabelHBox.setObjectName(u'newDataDirectoryLabelHBox') + self.newDataDirectoryLabelHBox.addWidget(self.newDataDirectoryEdit) + self.newDataDirectoryLabelHBox.addWidget(self.dataDirectoryBrowseButton) + self.newDataDirectoryLabelHBox.addWidget(self.dataDirectoryDefaultButton) + self.dataDirectoryCopyCheckHBox = QtGui.QHBoxLayout() + self.dataDirectoryCopyCheckHBox.setObjectName(u'dataDirectoryCopyCheckHBox') + self.dataDirectoryCopyCheckBox = QtGui.QCheckBox(self.dataDirectoryGroupBox) + self.dataDirectoryCopyCheckBox.setObjectName(u'dataDirectoryCopyCheckBox') + self.dataDirectoryCopyCheckHBox.addWidget(self.dataDirectoryCopyCheckBox) + self.dataDirectoryCopyCheckHBox.addStretch() + self.dataDirectoryCopyCheckHBox.addWidget(self.dataDirectoryCancelButton) + self.dataDirectoryLayout.addRow(self.dataDirectoryCurrentLabel, self.dataDirectoryLabel) + self.dataDirectoryLayout.addRow(self.dataDirectoryNewLabel, self.newDataDirectoryLabelHBox) + self.dataDirectoryLayout.addRow(self.dataDirectoryCopyCheckHBox) + self.dataDirectoryLayout.addRow(self.newDataDirectoryHasFilesLabel) + self.leftLayout.addWidget(self.dataDirectoryGroupBox) + self.leftLayout.addStretch() + # Default Image + self.defaultImageGroupBox = QtGui.QGroupBox(self.rightColumn) + self.defaultImageGroupBox.setObjectName(u'defaultImageGroupBox') + self.defaultImageLayout = QtGui.QFormLayout(self.defaultImageGroupBox) + self.defaultImageLayout.setObjectName(u'defaultImageLayout') + self.defaultColorLabel = QtGui.QLabel(self.defaultImageGroupBox) + self.defaultColorLabel.setObjectName(u'defaultColorLabel') + self.defaultColorButton = QtGui.QPushButton(self.defaultImageGroupBox) + self.defaultColorButton.setObjectName(u'defaultColorButton') + self.defaultImageLayout.addRow(self.defaultColorLabel, self.defaultColorButton) + self.defaultFileLabel = QtGui.QLabel(self.defaultImageGroupBox) + self.defaultFileLabel.setObjectName(u'defaultFileLabel') + self.defaultFileEdit = QtGui.QLineEdit(self.defaultImageGroupBox) + self.defaultFileEdit.setObjectName(u'defaultFileEdit') + self.defaultBrowseButton = QtGui.QToolButton(self.defaultImageGroupBox) + self.defaultBrowseButton.setObjectName(u'defaultBrowseButton') + self.defaultBrowseButton.setIcon(build_icon(u':/general/general_open.png')) + self.defaultRevertButton = QtGui.QToolButton(self.defaultImageGroupBox) + self.defaultRevertButton.setObjectName(u'defaultRevertButton') + self.defaultRevertButton.setIcon(build_icon(u':/general/general_revert.png')) + self.defaultFileLayout = QtGui.QHBoxLayout() + self.defaultFileLayout.setObjectName(u'defaultFileLayout') + self.defaultFileLayout.addWidget(self.defaultFileEdit) + self.defaultFileLayout.addWidget(self.defaultBrowseButton) + self.defaultFileLayout.addWidget(self.defaultRevertButton) + self.defaultImageLayout.addRow(self.defaultFileLabel, self.defaultFileLayout) + self.rightLayout.addWidget(self.defaultImageGroupBox) + # Hide mouse + self.hideMouseGroupBox = QtGui.QGroupBox(self.rightColumn) + self.hideMouseGroupBox.setObjectName(u'hideMouseGroupBox') + self.hideMouseLayout = QtGui.QVBoxLayout(self.hideMouseGroupBox) + self.hideMouseLayout.setObjectName(u'hideMouseLayout') + self.hideMouseCheckBox = QtGui.QCheckBox(self.hideMouseGroupBox) + self.hideMouseCheckBox.setObjectName(u'hideMouseCheckBox') + self.hideMouseLayout.addWidget(self.hideMouseCheckBox) + self.rightLayout.addWidget(self.hideMouseGroupBox) + # Service Item Slide Limits + self.slideGroupBox = QtGui.QGroupBox(self.rightColumn) + self.slideGroupBox.setObjectName(u'slideGroupBox') + self.slideLayout = QtGui.QVBoxLayout(self.slideGroupBox) + self.slideLayout.setObjectName(u'slideLayout') + self.slideLabel = QtGui.QLabel(self.slideGroupBox) + self.slideLabel.setWordWrap(True) + self.slideLayout.addWidget(self.slideLabel) + self.endSlideRadioButton = QtGui.QRadioButton(self.slideGroupBox) + self.endSlideRadioButton.setObjectName(u'endSlideRadioButton') + self.slideLayout.addWidget(self.endSlideRadioButton) + self.wrapSlideRadioButton = QtGui.QRadioButton(self.slideGroupBox) + self.wrapSlideRadioButton.setObjectName(u'wrapSlideRadioButton') + self.slideLayout.addWidget(self.wrapSlideRadioButton) + self.nextItemRadioButton = QtGui.QRadioButton(self.slideGroupBox) + self.nextItemRadioButton.setObjectName(u'nextItemRadioButton') + self.slideLayout.addWidget(self.nextItemRadioButton) + self.rightLayout.addWidget(self.slideGroupBox) + # Display Workarounds + self.displayWorkaroundGroupBox = QtGui.QGroupBox(self.leftColumn) + self.displayWorkaroundGroupBox.setObjectName(u'displayWorkaroundGroupBox') + self.displayWorkaroundLayout = QtGui.QVBoxLayout(self.displayWorkaroundGroupBox) + self.displayWorkaroundLayout.setObjectName(u'displayWorkaroundLayout') + self.x11BypassCheckBox = QtGui.QCheckBox(self.displayWorkaroundGroupBox) + self.x11BypassCheckBox.setObjectName(u'x11BypassCheckBox') + self.displayWorkaroundLayout.addWidget(self.x11BypassCheckBox) + self.alternateRowsCheckBox = QtGui.QCheckBox(self.displayWorkaroundGroupBox) + self.alternateRowsCheckBox.setObjectName(u'alternateRowsCheckBox') + self.displayWorkaroundLayout.addWidget(self.alternateRowsCheckBox) + self.rightLayout.addWidget(self.displayWorkaroundGroupBox) + self.rightLayout.addStretch() + self.shouldUpdateServiceNameExample = False + QtCore.QObject.connect(self.serviceNameCheckBox, QtCore.SIGNAL(u'toggled(bool)'), + self.serviceNameCheckBoxToggled) + QtCore.QObject.connect(self.serviceNameDay, QtCore.SIGNAL(u'currentIndexChanged(int)'), + self.onServiceNameDayChanged) + QtCore.QObject.connect(self.serviceNameTime, QtCore.SIGNAL(u'timeChanged(QTime)'), + self.updateServiceNameExample) + QtCore.QObject.connect(self.serviceNameEdit, QtCore.SIGNAL(u'textChanged(QString)'), + self.updateServiceNameExample) + QtCore.QObject.connect(self.serviceNameRevertButton, QtCore.SIGNAL(u'clicked()'), + self.onServiceNameRevertButtonClicked) + QtCore.QObject.connect(self.defaultColorButton, QtCore.SIGNAL(u'clicked()'), self.onDefaultColorButtonClicked) + QtCore.QObject.connect(self.defaultBrowseButton, QtCore.SIGNAL(u'clicked()'), self.onDefaultBrowseButtonClicked) + QtCore.QObject.connect(self.defaultRevertButton, QtCore.SIGNAL(u'clicked()'), self.onDefaultRevertButtonClicked) + QtCore.QObject.connect(self.x11BypassCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.onX11BypassCheckBoxToggled) + QtCore.QObject.connect(self.alternateRowsCheckBox, + QtCore.SIGNAL(u'toggled(bool)'), self.onAlternateRowsCheckBoxToggled) + QtCore.QObject.connect(self.dataDirectoryBrowseButton, QtCore.SIGNAL(u'clicked()'), + self.onDataDirectoryBrowseButtonClicked) + QtCore.QObject.connect(self.dataDirectoryDefaultButton, QtCore.SIGNAL(u'clicked()'), + self.onDataDirectoryDefaultButtonClicked) + QtCore.QObject.connect(self.dataDirectoryCancelButton, QtCore.SIGNAL(u'clicked()'), + self.onDataDirectoryCancelButtonClicked) + QtCore.QObject.connect(self.dataDirectoryCopyCheckBox, QtCore.SIGNAL(u'toggled(bool)'), + self.onDataDirectoryCopyCheckBoxToggled) + QtCore.QObject.connect(self.endSlideRadioButton, QtCore.SIGNAL(u'clicked()'), self.onEndSlideButtonClicked) + QtCore.QObject.connect(self.wrapSlideRadioButton, QtCore.SIGNAL(u'clicked()'), self.onWrapSlideButtonClicked) + QtCore.QObject.connect(self.nextItemRadioButton, QtCore.SIGNAL(u'clicked()'), self.onnextItemButtonClicked) + + def retranslateUi(self): + """ + Setup the interface translation strings. + """ + self.tabTitleVisible = UiStrings().Advanced + self.uiGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'UI Settings')) + self.dataDirectoryGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Data Location')) + self.recentLabel.setText(translate('OpenLP.AdvancedTab', 'Number of recent files to display:')) + self.mediaPluginCheckBox.setText(translate('OpenLP.AdvancedTab', + 'Remember active media manager tab on startup')) + self.doubleClickLiveCheckBox.setText(translate('OpenLP.AdvancedTab', + 'Double-click to send items straight to live')) + self.singleClickPreviewCheckBox.setText(translate('OpenLP.AdvancedTab', + 'Preview items when clicked in Media Manager')) + self.expandServiceItemCheckBox.setText(translate('OpenLP.AdvancedTab', + 'Expand new service items on creation')) + self.enableAutoCloseCheckBox.setText(translate('OpenLP.AdvancedTab', + 'Enable application exit confirmation')) + self.serviceNameGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Default Service Name')) + self.serviceNameCheckBox.setText(translate('OpenLP.AdvancedTab', 'Enable default service name')) + self.serviceNameTimeLabel.setText(translate('OpenLP.AdvancedTab', 'Date and Time:')) + self.serviceNameDay.setItemText(0, translate('OpenLP.AdvancedTab', 'Monday')) + self.serviceNameDay.setItemText(1, translate('OpenLP.AdvancedTab', 'Tuesday')) + self.serviceNameDay.setItemText(2, translate('OpenLP.AdvancedTab', 'Wednesday')) + self.serviceNameDay.setItemText(3, translate('OpenLP.AdvancedTab', 'Thurdsday')) + self.serviceNameDay.setItemText(4, translate('OpenLP.AdvancedTab', 'Friday')) + self.serviceNameDay.setItemText(5, translate('OpenLP.AdvancedTab', 'Saturday')) + self.serviceNameDay.setItemText(6, translate('OpenLP.AdvancedTab', 'Sunday')) + self.serviceNameDay.setItemText(7, translate('OpenLP.AdvancedTab', 'Now')) + self.serviceNameTime.setToolTip(translate('OpenLP.AdvancedTab', + 'Time when usual service starts.')) + self.serviceNameLabel.setText(translate('OpenLP.AdvancedTab', 'Name:')) + self.serviceNameEdit.setToolTip(translate('OpenLP.AdvancedTab', 'Consult the OpenLP manual for usage.')) + self.serviceNameRevertButton.setToolTip( + translate('OpenLP.AdvancedTab', 'Revert to the default service name "%s".') % + UiStrings().DefaultServiceName) + self.serviceNameExampleLabel.setText(translate('OpenLP.AdvancedTab', 'Example:')) + self.hideMouseGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Mouse Cursor')) + self.hideMouseCheckBox.setText(translate('OpenLP.AdvancedTab', 'Hide mouse cursor when over display window')) + self.defaultImageGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Default Image')) + self.defaultColorLabel.setText(translate('OpenLP.AdvancedTab', 'Background color:')) + self.defaultColorButton.setToolTip(translate('OpenLP.AdvancedTab', 'Click to select a color.')) + self.defaultFileLabel.setText(translate('OpenLP.AdvancedTab', 'Image file:')) + self.defaultBrowseButton.setToolTip(translate('OpenLP.AdvancedTab', 'Browse for an image file to display.')) + self.defaultRevertButton.setToolTip(translate('OpenLP.AdvancedTab', 'Revert to the default OpenLP logo.')) + self.dataDirectoryCurrentLabel.setText(translate('OpenLP.AdvancedTab', 'Current path:')) + self.dataDirectoryNewLabel.setText(translate('OpenLP.AdvancedTab', 'Custom path:')) + self.dataDirectoryBrowseButton.setToolTip(translate('OpenLP.AdvancedTab', 'Browse for new data file location.')) + self.dataDirectoryDefaultButton.setToolTip( + translate('OpenLP.AdvancedTab', 'Set the data location to the default.')) + self.dataDirectoryCancelButton.setText(translate('OpenLP.AdvancedTab', 'Cancel')) + self.dataDirectoryCancelButton.setToolTip( + translate('OpenLP.AdvancedTab', 'Cancel OpenLP data directory location change.')) + self.dataDirectoryCopyCheckBox.setText(translate('OpenLP.AdvancedTab', 'Copy data to new location.')) + self.dataDirectoryCopyCheckBox.setToolTip(translate( + 'OpenLP.AdvancedTab', 'Copy the OpenLP data files to the new location.')) + self.newDataDirectoryHasFilesLabel.setText( + translate('OpenLP.AdvancedTab', 'WARNING: New data directory location contains ' + 'OpenLP data files. These files WILL be replaced during a copy.')) +<<<<<<< TREE + self.x11GroupBox.setTitle(translate('OpenLP.AdvancedTab', 'X11')) + self.x11BypassCheckBox.setText(translate('OpenLP.AdvancedTab', 'Bypass X11 Window Manager')) +======= + self.displayWorkaroundGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Display Workarounds')) + self.x11BypassCheckBox.setText(translate('OpenLP.AdvancedTab','Bypass X11 Window Manager')) + self.alternateRowsCheckBox.setText(translate('OpenLP.AdvancedTab', 'Use alternating row colours in lists')) +>>>>>>> MERGE-SOURCE + # Slide Limits + self.slideGroupBox.setTitle(translate('OpenLP.GeneralTab', 'Service Item Slide Limits')) + self.slideLabel.setText(translate('OpenLP.GeneralTab', 'Behavior of next/previous on the last/first slide:')) + self.endSlideRadioButton.setText(translate('OpenLP.GeneralTab', '&Remain on Slide')) + self.wrapSlideRadioButton.setText(translate('OpenLP.GeneralTab', '&Wrap around')) + self.nextItemRadioButton.setText(translate('OpenLP.GeneralTab', '&Move to next/previous service item')) + + def load(self): + """ + Load settings from disk. + """ + settings = Settings() + settings.beginGroup(self.settingsSection) + # The max recent files value does not have an interface and so never + # gets actually stored in the settings therefore the default value of + # 20 will always be used. + self.recentSpinBox.setMaximum(settings.value(u'max recent files')) + self.recentSpinBox.setValue(settings.value(u'recent file count')) + self.mediaPluginCheckBox.setChecked(settings.value(u'save current plugin')) + self.doubleClickLiveCheckBox.setChecked(settings.value(u'double click live')) + self.singleClickPreviewCheckBox.setChecked(settings.value(u'single click preview')) + self.expandServiceItemCheckBox.setChecked(settings.value(u'expand service item')) + self.enableAutoCloseCheckBox.setChecked(settings.value(u'enable exit confirmation')) + self.hideMouseCheckBox.setChecked(settings.value(u'hide mouse')) + self.serviceNameDay.setCurrentIndex(settings.value(u'default service day')) + self.serviceNameTime.setTime(QtCore.QTime(settings.value(u'default service hour'), + settings.value(u'default service minute'))) + self.shouldUpdateServiceNameExample = True + self.serviceNameEdit.setText(settings.value(u'default service name')) + default_service_enabled = settings.value(u'default service enabled') + self.serviceNameCheckBox.setChecked(default_service_enabled) + self.serviceNameCheckBoxToggled(default_service_enabled) + self.x11BypassCheckBox.setChecked(settings.value(u'x11 bypass wm')) + self.defaultColor = settings.value(u'default color') + self.defaultFileEdit.setText(settings.value(u'default image')) + self.slide_limits = settings.value(u'slide limits') + # Prevent the dialog displayed by the alternateRowsCheckBox to display. + self.alternateRowsCheckBox.blockSignals(True) + self.alternateRowsCheckBox.setChecked(settings.value(u'alternate rows')) + self.alternateRowsCheckBox.blockSignals(False) + if self.slide_limits == SlideLimits.End: + self.endSlideRadioButton.setChecked(True) + elif self.slide_limits == SlideLimits.Wrap: + self.wrapSlideRadioButton.setChecked(True) + else: + self.nextItemRadioButton.setChecked(True) + settings.endGroup() + self.dataDirectoryCopyCheckBox.hide() + self.newDataDirectoryHasFilesLabel.hide() + self.dataDirectoryCancelButton.hide() + # Since data location can be changed, make sure the path is present. + self.currentDataPath = AppLocation.get_data_path() + if not os.path.exists(self.currentDataPath): + log.error(u'Data path not found %s' % self.currentDataPath) + answer = QtGui.QMessageBox.critical(self, + translate('OpenLP.AdvancedTab', + 'Data Directory Error'), + translate('OpenLP.AdvancedTab', + 'OpenLP data directory was not found\n\n%s\n\n' + 'This data directory was previously changed from the OpenLP ' + 'default location. If the new location was on removable ' + 'media, that media needs to be made available.\n\n' + 'Click "No" to stop loading OpenLP. allowing you to fix ' + 'the the problem.\n\n' + 'Click "Yes" to reset the data directory to the default ' + 'location.').replace('%s', self.currentDataPath), + QtGui.QMessageBox.StandardButtons( + QtGui.QMessageBox.Yes | + QtGui.QMessageBox.No), + QtGui.QMessageBox.No) + if answer == QtGui.QMessageBox.No: + log.info(u'User requested termination') + Receiver.send_message(u'cleanup') + sys.exit() + # Set data location to default. + settings.remove(u'advanced/data path') + self.currentDataPath = AppLocation.get_data_path() + log.warning(u'User requested data path set to default %s' % self.currentDataPath) + self.dataDirectoryLabel.setText(os.path.abspath(self.currentDataPath)) + self.defaultColorButton.setStyleSheet(u'background-color: %s' % self.defaultColor) + # Don't allow data directory move if running portable. + if settings.value(u'advanced/is portable'): + self.dataDirectoryGroupBox.hide() + + def save(self): + """ + Save settings to disk. + """ + settings = Settings() + settings.beginGroup(self.settingsSection) + settings.setValue(u'default service enabled', self.serviceNameCheckBox.isChecked()) + service_name = self.serviceNameEdit.text() + preset_is_valid = self.generateServiceNameExample()[0] + if service_name == UiStrings().DefaultServiceName or not preset_is_valid: + settings.remove(u'default service name') + self.serviceNameEdit.setText(service_name) + else: + settings.setValue(u'default service name', service_name) + settings.setValue(u'default service day', self.serviceNameDay.currentIndex()) + settings.setValue(u'default service hour', self.serviceNameTime.time().hour()) + settings.setValue(u'default service minute', self.serviceNameTime.time().minute()) + settings.setValue(u'recent file count', self.recentSpinBox.value()) + settings.setValue(u'save current plugin', self.mediaPluginCheckBox.isChecked()) + settings.setValue(u'double click live', self.doubleClickLiveCheckBox.isChecked()) + settings.setValue(u'single click preview', self.singleClickPreviewCheckBox.isChecked()) + settings.setValue(u'expand service item', self.expandServiceItemCheckBox.isChecked()) + settings.setValue(u'enable exit confirmation', self.enableAutoCloseCheckBox.isChecked()) + settings.setValue(u'hide mouse', self.hideMouseCheckBox.isChecked()) + settings.setValue(u'x11 bypass wm', self.x11BypassCheckBox.isChecked()) + settings.setValue(u'alternate rows', self.alternateRowsCheckBox.isChecked()) + settings.setValue(u'default color', self.defaultColor) + settings.setValue(u'default image', self.defaultFileEdit.text()) + settings.setValue(u'slide limits', self.slide_limits) + settings.endGroup() + if self.displayChanged: + Receiver.send_message(u'config_screen_changed') + self.displayChanged = False + Receiver.send_message(u'slidecontroller_update_slide_limits') + + def cancel(self): + """ + Dialogue was cancelled, remove any pending data path change. + """ + self.onDataDirectoryCancelButtonClicked() + SettingsTab.cancel(self) + + def serviceNameCheckBoxToggled(self, default_service_enabled): + """ + Toggle the service name check box. + """ + self.serviceNameDay.setEnabled(default_service_enabled) + time_enabled = default_service_enabled and self.serviceNameDay.currentIndex() is not 7 + self.serviceNameTime.setEnabled(time_enabled) + self.serviceNameEdit.setEnabled(default_service_enabled) + self.serviceNameRevertButton.setEnabled(default_service_enabled) + + def generateServiceNameExample(self): + """ + Generate an example service name. + """ + preset_is_valid = True + if self.serviceNameDay.currentIndex() == 7: + local_time = datetime.now() + else: + now = datetime.now() + day_delta = self.serviceNameDay.currentIndex() - now.weekday() + if day_delta < 0: + day_delta += 7 + time = now + timedelta(days=day_delta) + local_time = time.replace( + hour=self.serviceNameTime.time().hour(), + minute=self.serviceNameTime.time().minute() + ) + try: + service_name_example = format_time(unicode(self.serviceNameEdit.text()), local_time) + except ValueError: + preset_is_valid = False + service_name_example = translate('OpenLP.AdvancedTab', 'Syntax error.') + return preset_is_valid, service_name_example + + def updateServiceNameExample(self, returned_value): + """ + Update the example service name. + """ + if not self.shouldUpdateServiceNameExample: + return + name_example = self.generateServiceNameExample()[1] + self.serviceNameExample.setText(name_example) + + def onServiceNameDayChanged(self, service_day): + """ + React to the day of the service name changing. + """ + self.serviceNameTime.setEnabled(service_day is not 7) + self.updateServiceNameExample(None) + + def onServiceNameRevertButtonClicked(self): + """ + Revert to the default service name. + """ + self.serviceNameEdit.setText(UiStrings().DefaultServiceName) + self.serviceNameEdit.setFocus() + + def onDefaultColorButtonClicked(self): + """ + Select the background colour of the default display screen. + """ + new_color = QtGui.QColorDialog.getColor( + QtGui.QColor(self.defaultColor), self) + if new_color.isValid(): + self.defaultColor = new_color.name() + self.defaultColorButton.setStyleSheet(u'background-color: %s' % self.defaultColor) + + def onDefaultBrowseButtonClicked(self): + """ + Select an image for the default display screen. + """ + file_filters = u'%s;;%s (*.*) (*)' % (get_images_filter(), + UiStrings().AllFiles) + filename = QtGui.QFileDialog.getOpenFileName(self, + translate('OpenLP.AdvancedTab', 'Open File'), '', file_filters) + if filename: + self.defaultFileEdit.setText(filename) + self.defaultFileEdit.setFocus() + + def onDataDirectoryBrowseButtonClicked(self): + """ + Browse for a new data directory location. + """ + old_root_path = unicode(self.dataDirectoryLabel.text()) + # Get the new directory location. + new_data_path = QtGui.QFileDialog.getExistingDirectory( + self, translate('OpenLP.AdvancedTab', 'Select Data Directory Location'), old_root_path, + options=QtGui.QFileDialog.ShowDirsOnly) + # Set the new data path. + if new_data_path: + new_data_path = os.path.normpath(new_data_path) + if self.currentDataPath.lower() == new_data_path.lower(): + self.onDataDirectoryCancelButtonClicked() + return + else: + return + # Make sure they want to change the data. + answer = QtGui.QMessageBox.question(self, + translate('OpenLP.AdvancedTab', 'Confirm Data Directory Change'), + translate('OpenLP.AdvancedTab', 'Are you sure you want to change the location of the OpenLP ' + 'data directory to:\n\n%s\n\n ' + 'The data directory will be changed when OpenLP is closed.').replace('%s', new_data_path), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No) + if answer != QtGui.QMessageBox.Yes: + return + # Check if data already exists here. + self.checkDataOverwrite(new_data_path) + # Save the new location. + Receiver.send_message(u'set_new_data_path', new_data_path) + self.newDataDirectoryEdit.setText(new_data_path) + self.dataDirectoryCancelButton.show() + + def onDataDirectoryDefaultButtonClicked(self): + """ + Re-set the data directory location to the 'default' location. + """ + new_data_path = AppLocation.get_directory(AppLocation.DataDir) + if self.currentDataPath.lower() != new_data_path.lower(): + # Make sure they want to change the data location back to the + # default. + answer = QtGui.QMessageBox.question(self, + translate('OpenLP.AdvancedTab', 'Reset Data Directory'), + translate('OpenLP.AdvancedTab', 'Are you sure you want to change the location of the OpenLP ' + 'data directory to the default location?\n\nThis location will be used after OpenLP is closed.'), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No) + if answer != QtGui.QMessageBox.Yes: + return + self.checkDataOverwrite(new_data_path) + # Save the new location. + Receiver.send_message(u'set_new_data_path', new_data_path) + self.newDataDirectoryEdit.setText(os.path.abspath(new_data_path)) + self.dataDirectoryCancelButton.show() + else: + # We cancel the change in case user changed their mind. + self.onDataDirectoryCancelButtonClicked() + + def onDataDirectoryCopyCheckBoxToggled(self): + """ + Copy existing data when you change your data directory. + """ + Receiver.send_message(u'set_copy_data', + self.dataDirectoryCopyCheckBox.isChecked()) + if self.dataExists: + if self.dataDirectoryCopyCheckBox.isChecked(): + self.newDataDirectoryHasFilesLabel.show() + else: + self.newDataDirectoryHasFilesLabel.hide() + + def checkDataOverwrite(self, data_path): + """ + Check if there's already data in the target directory. + """ + test_path = os.path.join(data_path, u'songs') + self.dataDirectoryCopyCheckBox.show() + if os.path.exists(test_path): + self.dataExists = True + # Check is they want to replace existing data. + answer = QtGui.QMessageBox.warning(self, + translate('OpenLP.AdvancedTab', 'Overwrite Existing Data'), + translate('OpenLP.AdvancedTab', 'WARNING: \n\nThe location you have selected \n\n%s\n\n' + 'appears to contain OpenLP data files. Do you wish to replace these files with the current data files?' + ).replace('%s', os.path.abspath(data_path,)), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No) + if answer == QtGui.QMessageBox.Yes: + self.dataDirectoryCopyCheckBox.setChecked(True) + self.newDataDirectoryHasFilesLabel.show() + else: + self.dataDirectoryCopyCheckBox.setChecked(False) + self.newDataDirectoryHasFilesLabel.hide() + else: + self.dataExists = False + self.dataDirectoryCopyCheckBox.setChecked(True) + self.newDataDirectoryHasFilesLabel.hide() + + def onDataDirectoryCancelButtonClicked(self): + """ + Cancel the data directory location change + """ + self.newDataDirectoryEdit.clear() + self.dataDirectoryCopyCheckBox.setChecked(False) + Receiver.send_message(u'set_new_data_path', u'') + Receiver.send_message(u'set_copy_data', False) + self.dataDirectoryCopyCheckBox.hide() + self.dataDirectoryCancelButton.hide() + self.newDataDirectoryHasFilesLabel.hide() + + def onDefaultRevertButtonClicked(self): + """ + Revert the default screen back to the default settings. + """ + self.defaultFileEdit.setText(u':/graphics/openlp-splash-screen.png') + self.defaultFileEdit.setFocus() + + def onX11BypassCheckBoxToggled(self, checked): + """ + Toggle X11 bypass flag on maindisplay depending on check box state. + + ``checked`` + The state of the check box (boolean). + """ + self.displayChanged = True + + def onAlternateRowsCheckBoxToggled(self, checked): + """ + Notify user about required restart. + + ``checked`` + The state of the check box (boolean). + """ + QtGui.QMessageBox.information(self, + translate('OpenLP.AdvancedTab', 'Restart Required'), + translate('OpenLP.AdvancedTab', 'This change will only take effect once OpenLP has been restarted.')) + + def onEndSlideButtonClicked(self): + """ + Set the slide wrap option. + """ + self.slide_limits = SlideLimits.End + + def onWrapSlideButtonClicked(self): + """ + Set the slide wrap option. + """ + self.slide_limits = SlideLimits.Wrap + + def onnextItemButtonClicked(self): + """ + Set the slide wrap option. + """ + self.slide_limits = SlideLimits.Next diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index ba5e08c7f..14aa19b30 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -29,7 +29,7 @@ """ The :mod:`openlp.core.utils` module provides the utility libraries for OpenLP. """ -from datetime import datetime, timedelta +from datetime import datetime from distutils.version import LooseVersion import logging import locale @@ -61,14 +61,12 @@ UNO_CONNECTION_TYPE = u'pipe' CONTROL_CHARS = re.compile(r'[\x00-\x1F\x7F-\x9F]', re.UNICODE) INVALID_FILE_CHARS = re.compile(r'[\\/:\*\?"<>\|\+\[\]%]', re.UNICODE) + class VersionThread(QtCore.QThread): """ A special Qt thread class to fetch the version of OpenLP from the website. This is threaded so that it doesn't affect the loading time of OpenLP. """ - def __init__(self, parent): - QtCore.QThread.__init__(self, parent) - def run(self): """ Run the thread. @@ -157,7 +155,8 @@ def _get_os_dir_path(dir_type): return os.path.join(unicode(os.getenv(u'APPDATA'), encoding), u'openlp') elif sys.platform == u'darwin': if dir_type == AppLocation.DataDir: - return os.path.join(unicode(os.getenv(u'HOME'), encoding), u'Library', u'Application Support', u'openlp', u'Data') + return os.path.join(unicode(os.getenv(u'HOME'), encoding), + u'Library', u'Application Support', u'openlp', u'Data') elif dir_type == AppLocation.LanguageDir: return os.path.split(openlp.__file__)[0] return os.path.join(unicode(os.getenv(u'HOME'), encoding), u'Library', u'Application Support', u'openlp') @@ -472,6 +471,9 @@ def format_time(text, local_time): The time to be used to add to the string. This is a time object """ def match_formatting(match): + """ + Format the match + """ return local_time.strftime(match.group()) return re.sub('\%[a-zA-Z]', match_formatting, text) @@ -488,17 +490,14 @@ def locale_compare(string1, string2): return locale.strcoll(string1.lower(), string2.lower()) -# For performance reasons provide direct reference to compare function -# without wrapping it in another function making te string lowercase. -# This is needed for sorting songs. +# For performance reasons provide direct reference to compare function without wrapping it in another function making +# the string lowercase. This is needed for sorting songs. locale_direct_compare = locale.strcoll from languagemanager import LanguageManager from actions import ActionList -__all__ = [u'AppLocation', u'get_application_version', u'check_latest_version', - u'add_actions', u'get_filesystem_encoding', u'LanguageManager', - u'ActionList', u'get_web_page', u'get_uno_command', u'get_uno_instance', - u'delete_file', u'clean_filename', u'format_time', u'locale_compare', - u'locale_direct_compare'] +__all__ = [u'AppLocation', u'ActionList', u'LanguageManager', u'get_application_version', u'check_latest_version', + u'add_actions', u'get_filesystem_encoding', u'get_web_page', u'get_uno_command', u'get_uno_instance', + u'delete_file', u'clean_filename', u'format_time', u'locale_compare', u'locale_direct_compare'] diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 88bcbb44a..c7b2bae49 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -41,6 +41,9 @@ class ActionCategory(object): category for the :class:`~openlp.core.utils.CategoryList` class. """ def __init__(self, name, weight=0): + """ + Constructor + """ self.name = name self.weight = weight self.actions = CategoryActionList() @@ -52,22 +55,37 @@ class CategoryActionList(object): list of actions within a category. """ def __init__(self): + """ + Constructor + """ self.index = 0 self.actions = [] def __getitem__(self, key): + """ + Implement the __getitem__() method to make this class a dictionary type + """ for weight, action in self.actions: if action.text() == key: return action raise KeyError(u'Action "%s" does not exist.' % key) def __contains__(self, item): + """ + Implement the __contains__() method to make this class a dictionary type + """ return self.has_key(item) def __len__(self): + """ + Implement the __len__() method to make this class a dictionary type + """ return len(self.actions) def __iter__(self): + """ + Implement the __getitem__() method to make this class iterable + """ return self def __next__(self): @@ -88,22 +106,34 @@ class CategoryActionList(object): return self.__next__() def has_key(self, key): + """ + Implement the has_key() method to make this class a dictionary type + """ for weight, action in self.actions: if action.text() == key: return True return False def append(self, name): + """ + Append an action + """ weight = 0 if self.actions: weight = self.actions[-1][0] + 1 self.add(name, weight) def add(self, action, weight=0): + """ + Add an action. + """ self.actions.append((weight, action)) self.actions.sort(key=lambda act: act[0]) def remove(self, remove_action): + """ + Remove an action + """ for action in self.actions: if action[1] == remove_action: self.actions.remove(action) @@ -118,22 +148,37 @@ class CategoryList(object): """ def __init__(self): + """ + Constructor + """ self.index = 0 self.categories = [] def __getitem__(self, key): + """ + Implement the __getitem__() method to make this class like a dictionary + """ for category in self.categories: if category.name == key: return category raise KeyError(u'Category "%s" does not exist.' % key) def __contains__(self, item): + """ + Implement the __contains__() method to make this class like a dictionary + """ return self.has_key(item) def __len__(self): + """ + Implement the __len__() method to make this class like a dictionary + """ return len(self.categories) def __iter__(self): + """ + Implement the __iter__() method to make this class like a dictionary + """ return self def __next__(self): @@ -154,12 +199,18 @@ class CategoryList(object): return self.__next__() def has_key(self, key): + """ + Implement the has_key() method to make this class like a dictionary + """ for category in self.categories: if category.name == key: return True return False def append(self, name, actions=None): + """ + Append a category + """ weight = 0 if self.categories: weight = self.categories[-1].weight + 1 @@ -169,6 +220,9 @@ class CategoryList(object): self.add(name, weight) def add(self, name, weight=0, actions=None): + """ + Add a category + """ category = ActionCategory(name, weight) if actions: for action in actions: @@ -180,6 +234,9 @@ class CategoryList(object): self.categories.sort(key=lambda cat: cat.weight) def remove(self, name): + """ + Remove a category + """ for category in self.categories: if category.name == name: self.categories.remove(category) @@ -196,10 +253,16 @@ class ActionList(object): shortcut_map = {} def __init__(self): + """ + Constructor + """ self.categories = CategoryList() @staticmethod def get_instance(): + """ + Get the instance of this class. + """ if ActionList.instance is None: ActionList.instance = ActionList() return ActionList.instance diff --git a/openlp/core/utils/languagemanager.py b/openlp/core/utils/languagemanager.py index 355f35915..f69bb40c6 100644 --- a/openlp/core/utils/languagemanager.py +++ b/openlp/core/utils/languagemanager.py @@ -27,8 +27,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`languagemanager` module provides all the translation settings and -language file loading for OpenLP. +The :mod:`languagemanager` module provides all the translation settings and language file loading for OpenLP. """ import logging import re @@ -41,6 +40,7 @@ from openlp.core.lib import translate, Settings log = logging.getLogger(__name__) + class LanguageManager(object): """ Helper for Language selection From e61bb30d754eba9dde16c324fce6f44ec75685a3 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 2 Feb 2013 20:21:14 +0000 Subject: [PATCH 38/64] missed one --- openlp/core/ui/advancedtab.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index a219b8091..72d308c51 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -121,7 +121,7 @@ class AdvancedTab(SettingsTab): self.service_name_revert_button.setObjectName(u'service_name_revert_button') self.service_name_revert_button.setIcon(build_icon(u':/general/general_revert.png')) self.service_name_button_layout = QtGui.QHBoxLayout() - self.service_name_button_layout.setObjectName(u'service_name_layout_2') + self.service_name_button_layout.setObjectName(u'service_name_button_layout') self.service_name_button_layout.addWidget(self.service_name_edit) self.service_name_button_layout.addWidget(self.service_name_revert_button) self.service_name_layout.addRow(self.service_name_label, self.service_name_button_layout) From 922c392ecbeab59273ecb3136f0d01235394c10c Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 2 Feb 2013 22:54:34 +0200 Subject: [PATCH 39/64] Slowly start moving names to PEP8 style names. --- openlp/core/__init__.py | 55 +++++++-------- openlp/core/lib/__init__.py | 5 +- openlp/core/lib/db.py | 14 ++-- openlp/core/lib/htmlbuilder.py | 29 ++++---- openlp/core/lib/imagemanager.py | 94 +++++++++++++------------- openlp/core/lib/renderer.py | 6 +- openlp/core/lib/serviceitem.py | 4 +- openlp/core/ui/maindisplay.py | 10 +-- openlp/core/ui/mainwindow.py | 18 ++--- openlp/core/ui/pluginform.py | 2 +- openlp/core/ui/slidecontroller.py | 6 +- openlp/core/ui/thememanager.py | 4 +- openlp/plugins/bibles/lib/mediaitem.py | 2 +- openlp/plugins/images/imageplugin.py | 2 +- 14 files changed, 128 insertions(+), 123 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 60a3c7d74..0ff7cb838 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -43,7 +43,7 @@ from traceback import format_exception from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, Settings, check_directory_exists, ScreenList, UiStrings, Registry +from openlp.core.lib import Receiver, Settings, ScreenList, UiStrings, Registry, check_directory_exists from openlp.core.resources import qInitResources from openlp.core.ui.mainwindow import MainWindow from openlp.core.ui.firsttimelanguageform import FirstTimeLanguageForm @@ -92,15 +92,16 @@ class OpenLP(QtGui.QApplication): """ Override exec method to allow the shared memory to be released on exit """ - self.eventLoopIsActive = True - QtGui.QApplication.exec_() - self.sharedMemory.detach() + self.event_loop_is_active = True + result = QtGui.QApplication.exec_(self) + self.shared_memory.detach() + return result def run(self, args, testing=False): """ Run the OpenLP application. """ - self.eventLoopIsActive = False + self.event_loop_is_active = False # On Windows, the args passed into the constructor are ignored. Not # very handy, so set the ones we want to use. On Linux and FreeBSD, in # order to set the WM_CLASS property for X11, we pass "OpenLP" in as a @@ -111,8 +112,8 @@ class OpenLP(QtGui.QApplication): self.args.extend(args) # provide a listener for widgets to reqest a screen update. QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_process_events'), self.processEvents) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'cursor_busy'), self.setBusyCursor) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'cursor_normal'), self.setNormalCursor) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'cursor_busy'), self.set_busy_cursor) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'cursor_normal'), self.set_normal_cursor) # Decide how many screens we have and their size screens = ScreenList.create(self.desktop()) # First time checks in settings @@ -138,44 +139,44 @@ class OpenLP(QtGui.QApplication): # make sure Qt really display the splash screen self.processEvents() # start the main app window - self.mainWindow = MainWindow(self) - self.mainWindow.show() + self.main_window = MainWindow(self) + self.main_window.show() if show_splash: # now kill the splashscreen - self.splash.finish(self.mainWindow) + self.splash.finish(self.main_window) log.debug(u'Splashscreen closed') # make sure Qt really display the splash screen self.processEvents() - self.mainWindow.repaint() + self.main_window.repaint() self.processEvents() if not has_run_wizard: - self.mainWindow.firstTime() + self.main_window.first_time() update_check = Settings().value(u'general/update check') if update_check: - VersionThread(self.mainWindow).start() + VersionThread(self.main_window).start() Receiver.send_message(u'live_display_blank_check') - self.mainWindow.appStartup() + self.main_window.app_startup() # Skip exec_() for gui tests if not testing: return self.exec_() - def isAlreadyRunning(self): + def is_already_running(self): """ Look to see if OpenLP is already running and ask if a 2nd copy is to be started. """ - self.sharedMemory = QtCore.QSharedMemory('OpenLP') - if self.sharedMemory.attach(): + self.shared_memory = QtCore.QSharedMemory('OpenLP') + if self.shared_memory.attach(): status = QtGui.QMessageBox.critical(None, UiStrings().Error, UiStrings().OpenLPStart, QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)) if status == QtGui.QMessageBox.No: return True return False else: - self.sharedMemory.create(1) + self.shared_memory.create(1) return False - def hookException(self, exctype, value, traceback): + def hook_exception(self, exctype, value, traceback): """ Add an exception hook so that any uncaught exceptions are displayed in this window rather than somewhere where users cannot see it and cannot report when we encounter these problems. @@ -193,19 +194,19 @@ class OpenLP(QtGui.QApplication): log.exception(''.join(format_exception(exctype, value, traceback))) return if not hasattr(self, u'exceptionForm'): - self.exceptionForm = ExceptionForm(self.mainWindow) - self.exceptionForm.exceptionTextEdit.setPlainText(''.join(format_exception(exctype, value, traceback))) - self.setNormalCursor() - self.exceptionForm.exec_() + self.exception_form = ExceptionForm(self.main_window) + self.exception_form.exceptionTextEdit.setPlainText(''.join(format_exception(exctype, value, traceback))) + self.set_normal_cursor() + self.exception_form.exec_() - def setBusyCursor(self): + def set_busy_cursor(self): """ Sets the Busy Cursor for the Application """ self.setOverrideCursor(QtCore.Qt.BusyCursor) self.processEvents() - def setNormalCursor(self): + def set_normal_cursor(self): """ Sets the Normal Cursor for the Application """ @@ -305,7 +306,7 @@ def main(args=None): # Instance check if not options.testing: # Instance check - if app.isAlreadyRunning(): + if app.is_already_running(): sys.exit() # First time checks in settings if not Settings().value(u'general/has run wizard'): @@ -322,7 +323,7 @@ def main(args=None): else: log.debug(u'Could not find default_translator.') if not options.no_error_form: - sys.excepthook = app.hookException + sys.excepthook = app.hook_exception # Do not run method app.exec_() when running gui tests if options.testing: app.run(qt_args, testing=True) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 5cbfec11f..c34c824db 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -90,9 +90,8 @@ class ServiceItemAction(object): Next = 3 -def translate(context, text, comment=None, - encoding=QtCore.QCoreApplication.CodecForTr, n=-1, - translate=QtCore.QCoreApplication.translate): +def translate(context, text, comment=None, encoding=QtCore.QCoreApplication.CodecForTr, n=-1, + translate=QtCore.QCoreApplication.translate): """ A special shortcut method to wrap around the Qt4 translation functions. This abstracts the translation procedure so that we can change it if at a diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index f14e25297..5601fa530 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -110,14 +110,17 @@ def upgrade_db(url, upgrade): while hasattr(upgrade, u'upgrade_%d' % version): log.debug(u'Running upgrade_%d', version) try: - getattr(upgrade, u'upgrade_%d' % version)(session, metadata, tables) + upgrade_func = getattr(upgrade, u'upgrade_%d' % version) + upgrade_func(session, metadata, tables) + session.commit() + # Update the version number AFTER a commit so that we are sure the previous transaction happened + version_meta.value = unicode(version) + session.commit() + version += 1 except (SQLAlchemyError, DBAPIError): log.exception(u'Could not run database upgrade script ' '"upgrade_%s", upgrade process has been halted.', version) break - version_meta.value = unicode(version) - session.commit() - version += 1 else: version_meta = Metadata.populate(key=u'version', value=int(upgrade.__version__)) session.commit() @@ -216,7 +219,8 @@ class Manager(object): self.session = init_schema(self.db_url) except (SQLAlchemyError, DBAPIError): log.exception(u'Error loading database: %s', self.db_url) - critical_error_message_box(translate('OpenLP.Manager', 'Database Error'), + critical_error_message_box( + translate('OpenLP.Manager', 'Database Error'), translate('OpenLP.Manager', 'OpenLP cannot load your database.\n\nDatabase: %s') % self.db_url ) diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index a6e8f373e..05c71e419 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -208,8 +208,7 @@ sup { """ -def build_html(item, screen, islive, background, image=None, - plugins=None): +def build_html(item, screen, is_live, background, image=None, plugins=None): """ Build the full web paged structure for display @@ -234,7 +233,7 @@ def build_html(item, screen, islive, background, image=None, width = screen[u'size'].width() height = screen[u'size'].height() theme = item.themedata - webkitvers = webkit_version() + webkit_ver = webkit_version() # Image generated and poked in if background: bgimage_src = u'src="data:image/png;base64,%s"' % background @@ -254,15 +253,17 @@ def build_html(item, screen, islive, background, image=None, css_additions += plugin.getDisplayCss() js_additions += plugin.getDisplayJavaScript() html_additions += plugin.getDisplayHtml() - html = HTMLSRC % (build_background_css(item, width, height), + html = HTMLSRC % ( + build_background_css(item, width, height), css_additions, build_footer_css(item, height), - build_lyrics_css(item, webkitvers), - u'true' if theme and theme.display_slide_transition and islive else u'false', + build_lyrics_css(item, webkit_ver), + u'true' if theme and theme.display_slide_transition and is_live else u'false', js_additions, bgimage_src, image_src, html_additions, - build_lyrics_html(item, webkitvers)) + build_lyrics_html(item, webkit_ver) + ) return html @@ -272,11 +273,11 @@ def webkit_version(): Note method added relatively recently, so return 0 if prior to this """ try: - webkitvers = float(QtWebKit.qWebKitVersion()) - log.debug(u'Webkit version = %s' % webkitvers) + webkit_ver = float(QtWebKit.qWebKitVersion()) + log.debug(u'Webkit version = %s' % webkit_ver) except AttributeError: - webkitvers = 0 - return webkitvers + webkit_ver = 0 + return webkit_ver def build_background_css(item, width, height): @@ -314,7 +315,7 @@ def build_background_css(item, width, height): return background -def build_lyrics_css(item, webkitvers): +def build_lyrics_css(item, webkit_ver): """ Build the lyrics display css @@ -371,12 +372,12 @@ def build_lyrics_css(item, webkitvers): # Up to 534.3 the text-shadow didn't get displayed when # webkit-text-stroke was used. So use an offset text layer underneath. # https://bugs.webkit.org/show_bug.cgi?id=19728 - if webkitvers >= 533.3: + if webkit_ver >= 533.3: lyricsmain += build_lyrics_outline_css(theme) else: outline = build_lyrics_outline_css(theme) if theme.font_main_shadow: - if theme.font_main_outline and webkitvers <= 534.3: + if theme.font_main_outline and webkit_ver <= 534.3: shadow = u'padding-left: %spx; padding-top: %spx;' % \ (int(theme.font_main_shadow_size) + (int(theme.font_main_outline_size) * 2), theme.font_main_shadow_size) diff --git a/openlp/core/lib/imagemanager.py b/openlp/core/lib/imagemanager.py index 392737972..9726079f7 100644 --- a/openlp/core/lib/imagemanager.py +++ b/openlp/core/lib/imagemanager.py @@ -57,13 +57,13 @@ class ImageThread(QtCore.QThread): The image manager. """ QtCore.QThread.__init__(self, None) - self.imageManager = manager + self.image_manager = manager def run(self): """ Run the thread. """ - self.imageManager._process() + self.image_manager._process() class Priority(object): @@ -189,74 +189,74 @@ class ImageManager(QtCore.QObject): def __init__(self): """ - Consutructor for the image manager. + Constructor for the image manager. """ QtCore.QObject.__init__(self) Registry().register(u'image_manager', self) - currentScreen = ScreenList().current - self.width = currentScreen[u'size'].width() - self.height = currentScreen[u'size'].height() + current_screen = ScreenList().current + self.width = current_screen[u'size'].width() + self.height = current_screen[u'size'].height() self._cache = {} - self.imageThread = ImageThread(self) - self._conversionQueue = PriorityQueue() - self.stopManager = False - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.processUpdates) + self.image_thread = ImageThread(self) + self._conversion_queue = PriorityQueue() + self.stop_manager = False + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.process_updates) - def updateDisplay(self): + def update_display(self): """ Screen has changed size so rebuild the cache to new size. """ - log.debug(u'updateDisplay') - currentScreen = ScreenList().current - self.width = currentScreen[u'size'].width() - self.height = currentScreen[u'size'].height() + log.debug(u'update_display') + current_screen = ScreenList().current + self.width = current_screen[u'size'].width() + self.height = current_screen[u'size'].height() # Mark the images as dirty for a rebuild by setting the image and byte # stream to None. for image in self._cache.values(): - self._resetImage(image) + self._reset_image(image) - def updateImagesBorder(self, source, background): + def update_images_border(self, source, background): """ Border has changed so update all the images affected. """ - log.debug(u'updateImages') + log.debug(u'update_images_border') # Mark the images as dirty for a rebuild by setting the image and byte # stream to None. for image in self._cache.values(): if image.source == source: image.background = background - self._resetImage(image) + self._reset_image(image) - def updateImageBorder(self, path, source, background): + def update_image_border(self, path, source, background): """ Border has changed so update the image affected. """ - log.debug(u'updateImage') + log.debug(u'update_image_border') # Mark the image as dirty for a rebuild by setting the image and byte # stream to None. image = self._cache[(path, source)] if image.source == source: image.background = background - self._resetImage(image) + self._reset_image(image) - def _resetImage(self, image): + def _reset_image(self, image): """ Mark the given :class:`Image` instance as dirty by setting its ``image`` and ``image_bytes`` attributes to None. """ image.image = None image.image_bytes = None - self._conversionQueue.modify_priority(image, Priority.Normal) + self._conversion_queue.modify_priority(image, Priority.Normal) - def processUpdates(self): + def process_updates(self): """ Flush the queue to updated any data to update """ # We want only one thread. - if not self.imageThread.isRunning(): - self.imageThread.start() + if not self.image_thread.isRunning(): + self.image_thread.start() - def getImage(self, path, source): + def get_image(self, path, source): """ Return the ``QImage`` from the cache. If not present wait for the background thread to process it. @@ -264,9 +264,9 @@ class ImageManager(QtCore.QObject): log.debug(u'getImage %s' % path) image = self._cache[(path, source)] if image.image is None: - self._conversionQueue.modify_priority(image, Priority.High) + self._conversion_queue.modify_priority(image, Priority.High) # make sure we are running and if not give it a kick - self.processUpdates() + self.process_updates() while image.image is None: log.debug(u'getImage - waiting') time.sleep(0.1) @@ -275,74 +275,74 @@ class ImageManager(QtCore.QObject): # byte stream was not generated yet. However, we only need to do # this, when the image was generated before it was requested # (otherwise this is already taken care of). - self._conversionQueue.modify_priority(image, Priority.Low) + self._conversion_queue.modify_priority(image, Priority.Low) return image.image - def getImageBytes(self, path, source): + def get_image_bytes(self, path, source): """ Returns the byte string for an image. If not present wait for the background thread to process it. """ - log.debug(u'getImageBytes %s' % path) + log.debug(u'get_image_bytes %s' % path) image = self._cache[(path, source)] if image.image_bytes is None: - self._conversionQueue.modify_priority(image, Priority.Urgent) + self._conversion_queue.modify_priority(image, Priority.Urgent) # make sure we are running and if not give it a kick - self.processUpdates() + self.process_updates() while image.image_bytes is None: log.debug(u'getImageBytes - waiting') time.sleep(0.1) return image.image_bytes - def addImage(self, path, source, background): + def add_image(self, path, source, background): """ Add image to cache if it is not already there. """ - log.debug(u'addImage %s' % path) + log.debug(u'add_image %s' % path) if not (path, source) in self._cache: image = Image(path, source, background) self._cache[(path, source)] = image - self._conversionQueue.put((image.priority, image.secondary_priority, image)) + self._conversion_queue.put((image.priority, image.secondary_priority, image)) # Check if the there are any images with the same path and check if the # timestamp has changed. for image in self._cache.values(): if os.path.exists(path): if image.path == path and image.timestamp != os.stat(path).st_mtime: image.timestamp = os.stat(path).st_mtime - self._resetImage(image) + self._reset_image(image) # We want only one thread. - if not self.imageThread.isRunning(): - self.imageThread.start() + if not self.image_thread.isRunning(): + self.image_thread.start() def _process(self): """ Controls the processing called from a ``QtCore.QThread``. """ log.debug(u'_process - started') - while not self._conversionQueue.empty() and not self.stopManager: - self._processCache() + while not self._conversion_queue.empty() and not self.stop_manager: + self._process_cache() log.debug(u'_process - ended') - def _processCache(self): + def _process_cache(self): """ Actually does the work. """ log.debug(u'_processCache') - image = self._conversionQueue.get()[2] + image = self._conversion_queue.get()[2] # Generate the QImage for the image. if image.image is None: image.image = resize_image(image.path, self.width, self.height, image.background) # Set the priority to Lowest and stop here as we need to process # more important images first. if image.priority == Priority.Normal: - self._conversionQueue.modify_priority(image, Priority.Lowest) + self._conversion_queue.modify_priority(image, Priority.Lowest) return # For image with high priority we set the priority to Low, as the # byte stream might be needed earlier the byte stream of image with # Normal priority. We stop here as we need to process more important # images first. elif image.priority == Priority.High: - self._conversionQueue.modify_priority(image, Priority.Low) + self._conversion_queue.modify_priority(image, Priority.Low) return # Generate the byte stream for the image. if image.image_bytes is None: diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index b67ae36f6..23a7edc67 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -136,7 +136,7 @@ class Renderer(object): theme_data, main_rect, footer_rect = self._theme_dimensions[theme_name] # if No file do not update cache if theme_data.background_filename: - self.image_manager.addImage(theme_data.background_filename, + self.image_manager.add_image(theme_data.background_filename, ImageSource.Theme, QtGui.QColor(theme_data.background_border_color)) def pre_render(self, override_theme_data=None): @@ -238,7 +238,7 @@ class Renderer(object): serviceItem.raw_footer = FOOTER # if No file do not update cache if theme_data.background_filename: - self.image_manager.addImage(theme_data.background_filename, + self.image_manager.add_image(theme_data.background_filename, ImageSource.Theme, QtGui.QColor(theme_data.background_border_color)) theme_data, main, footer = self.pre_render(theme_data) @@ -661,4 +661,4 @@ class Renderer(object): self._theme_manager = Registry().get(u'theme_manager') return self._theme_manager - theme_manager = property(_get_theme_manager) \ No newline at end of file + theme_manager = property(_get_theme_manager) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index c97923b0a..743f6b00a 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -293,7 +293,7 @@ class ServiceItem(object): self.image_border = background self.service_item_type = ServiceItemType.Image self._raw_frames.append({u'title': title, u'path': path}) - self.image_manager.addImage(path, ImageSource.ImagePlugin, self.image_border) + self.image_manager.add_image(path, ImageSource.ImagePlugin, self.image_border) self._new_item() def add_from_text(self, raw_slide, verse_tag=None): @@ -663,4 +663,4 @@ class ServiceItem(object): self._image_manager = Registry().get(u'image_manager') return self._image_manager - image_manager = property(_get_image_manager) \ No newline at end of file + image_manager = property(_get_image_manager) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 400d82f5b..04567a16e 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -292,7 +292,7 @@ class MainDisplay(Display): """ API for replacement backgrounds so Images are added directly to cache. """ - self.image_manager.addImage(path, ImageSource.ImagePlugin, background) + self.image_manager.add_image(path, ImageSource.ImagePlugin, background) if not hasattr(self, u'serviceItem'): return False self.override[u'image'] = path @@ -314,7 +314,7 @@ class MainDisplay(Display): re-added to the image manager. """ log.debug(u'image to display') - image = self.image_manager.getImageBytes(path, ImageSource.ImagePlugin) + image = self.image_manager.get_image_bytes(path, ImageSource.ImagePlugin) self.controller.media_controller.media_reset(self.controller) self.displayImage(image) @@ -395,16 +395,16 @@ class MainDisplay(Display): self.override = {} else: # replace the background - background = self.image_manager.getImageBytes(self.override[u'image'], ImageSource.ImagePlugin) + background = self.image_manager.get_image_bytes(self.override[u'image'], ImageSource.ImagePlugin) self.setTransparency(self.serviceItem.themedata.background_type == BackgroundType.to_string(BackgroundType.Transparent)) if self.serviceItem.themedata.background_filename: - self.serviceItem.bg_image_bytes = self.image_manager.getImageBytes( + self.serviceItem.bg_image_bytes = self.image_manager.get_image_bytes( self.serviceItem.themedata.background_filename, ImageSource.Theme ) if image_path: - image_bytes = self.image_manager.getImageBytes(image_path, ImageSource.ImagePlugin) + image_bytes = self.image_manager.get_image_bytes(image_path, ImageSource.ImagePlugin) else: image_bytes = None html = build_html(self.serviceItem, self.screen, self.isLive, background, image_bytes, diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 32058cce9..3fcb0a8f8 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -644,17 +644,17 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.setViewMode(False, True, False, False, True) self.modeLiveItem.setChecked(True) - def appStartup(self): + def app_startup(self): """ Give all the plugins a chance to perform some tasks at startup """ Receiver.send_message(u'openlp_process_events') for plugin in self.pluginManager.plugins: if plugin.isActive(): - plugin.appStartup() + plugin.app_startup() Receiver.send_message(u'openlp_process_events') - def firstTime(self): + def first_time(self): """ Import themes if first time """ @@ -662,7 +662,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): for plugin in self.pluginManager.plugins: if hasattr(plugin, u'firstTime'): Receiver.send_message(u'openlp_process_events') - plugin.firstTime() + plugin.first_time() Receiver.send_message(u'openlp_process_events') temp_dir = os.path.join(unicode(gettempdir()), u'openlp') shutil.rmtree(temp_dir, True) @@ -690,7 +690,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): firstTime.exec_() if firstTime.downloadCancelled: return - self.firstTime() + self.first_time() for plugin in self.pluginManager.plugins: self.activePlugin = plugin oldStatus = self.activePlugin.status @@ -698,7 +698,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): if oldStatus != self.activePlugin.status: if self.activePlugin.status == PluginStatus.Active: self.activePlugin.toggleStatus(PluginStatus.Active) - self.activePlugin.appStartup() + self.activePlugin.app_startup() else: self.activePlugin.toggleStatus(PluginStatus.Inactive) self.themeManagerContents.configUpdated() @@ -1004,7 +1004,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ log.debug(u'screenChanged') Receiver.send_message(u'cursor_busy') - self.imageManager.updateDisplay() + self.imageManager.update_display() self.renderer.update_display() self.previewController.screenSizeChanged() self.liveController.screenSizeChanged() @@ -1060,8 +1060,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): ``save_settings`` Switch to prevent saving settings. Defaults to **True**. """ - self.imageManager.stopManager = True - while self.imageManager.imageThread.isRunning(): + self.imageManager.stop_manager = True + while self.imageManager.image_thread.isRunning(): time.sleep(0.1) # Clean temporary files used by services self.serviceManagerContents.cleanUp() diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index d71a778c4..bb133a225 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -144,7 +144,7 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): Receiver.send_message(u'cursor_busy') self.activePlugin.toggleStatus(PluginStatus.Active) Receiver.send_message(u'cursor_normal') - self.activePlugin.appStartup() + self.activePlugin.app_startup() else: self.activePlugin.toggleStatus(PluginStatus.Inactive) status_text = translate('OpenLP.PluginForm', '%s (Inactive)') diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 19e15f5c5..de50f0ddd 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -819,9 +819,9 @@ class SlideController(DisplayController): else: # If current slide set background to image if framenumber == slideno: - self.serviceItem.bg_image_bytes = self.image_manager.getImageBytes(frame[u'path'], + self.serviceItem.bg_image_bytes = self.image_manager.get_image_bytes(frame[u'path'], ImageSource.ImagePlugin) - image = self.image_manager.getImage(frame[u'path'], ImageSource.ImagePlugin) + image = self.image_manager.get_image(frame[u'path'], ImageSource.ImagePlugin) label.setPixmap(QtGui.QPixmap.fromImage(image)) self.previewListWidget.setCellWidget(framenumber, 0, label) slideHeight = width * (1 / self.ratio) @@ -1395,4 +1395,4 @@ class SlideController(DisplayController): self._live_controller = Registry().get(u'live_controller') return self._live_controller - live_controller = property(_get_live_controller) \ No newline at end of file + live_controller = property(_get_live_controller) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 304462969..c0b4f437a 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -638,9 +638,9 @@ class ThemeManager(QtGui.QWidget): """ self._writeTheme(theme, image_from, image_to) if theme.background_type == BackgroundType.to_string(BackgroundType.Image): - self.image_manager.updateImageBorder(theme.background_filename, + self.image_manager.update_image_border(theme.background_filename, ImageSource.Theme, QtGui.QColor(theme.background_border_color)) - self.image_manager.processUpdates() + self.image_manager.process_updates() def _writeTheme(self, theme, image_from, image_to): """ diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index fd1109221..f9a49ebb1 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -349,7 +349,7 @@ class BibleMediaItem(MediaManagerItem): self.loadBibles() # If called from first time wizard re-run, process any new bibles. if process: - self.plugin.appStartup() + self.plugin.app_startup() self.updateAutoCompleter() def initialiseAdvancedBible(self, bible, last_book_id=None): diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index 11e542e60..0827e645c 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -98,4 +98,4 @@ class ImagePlugin(Plugin): last part of saving the config. """ background = QtGui.QColor(Settings().value(self.settingsSection + u'/background color')) - self.liveController.imageManager.updateImagesBorder(ImageSource.ImagePlugin, background) + self.liveController.imageManager.update_images_border(ImageSource.ImagePlugin, background) From 27cd63ebcdc292b40b193ab1c57fbe55e719a6bf Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 3 Feb 2013 09:07:31 +0000 Subject: [PATCH 40/64] Remove events and move to Registry --- openlp/core/__init__.py | 18 +++-- openlp/core/lib/eventreceiver.py | 32 -------- openlp/core/lib/mediamanageritem.py | 14 +++- openlp/core/lib/plugin.py | 17 ++++ openlp/core/lib/pluginmanager.py | 10 +++ openlp/core/ui/firsttimeform.py | 51 ++++++------ openlp/core/ui/maindisplay.py | 18 ++++- openlp/core/ui/mainwindow.py | 42 ++++++---- openlp/core/ui/media/mediaplayer.py | 11 +++ openlp/core/ui/media/phononplayer.py | 4 +- openlp/core/ui/media/vlcplayer.py | 4 +- openlp/core/ui/pluginform.py | 33 ++++++-- openlp/core/ui/servicemanager.py | 77 +++++++++++-------- openlp/core/ui/slidecontroller.py | 9 +-- openlp/core/ui/thememanager.py | 22 ++++-- openlp/core/ui/wizard.py | 16 +++- openlp/core/utils/__init__.py | 4 +- .../plugins/bibles/forms/bibleimportform.py | 4 +- .../plugins/bibles/forms/bibleupgradeform.py | 6 +- openlp/plugins/bibles/forms/editbibleform.py | 17 +++- openlp/plugins/bibles/lib/csvbible.py | 4 +- openlp/plugins/bibles/lib/db.py | 12 ++- openlp/plugins/bibles/lib/http.py | 53 +++++++------ openlp/plugins/bibles/lib/mediaitem.py | 14 ++-- openlp/plugins/bibles/lib/openlp1.py | 2 +- openlp/plugins/bibles/lib/opensong.py | 4 +- openlp/plugins/bibles/lib/osis.py | 4 +- openlp/plugins/custom/lib/mediaitem.py | 2 +- openlp/plugins/images/lib/mediaitem.py | 8 +- openlp/plugins/presentations/lib/mediaitem.py | 10 +-- openlp/plugins/songs/forms/songexportform.py | 6 +- openlp/plugins/songs/forms/songimportform.py | 4 +- .../songs/forms/songmaintenanceform.py | 13 +++- openlp/plugins/songs/lib/mediaitem.py | 6 +- openlp/plugins/songs/lib/openlyricsexport.py | 14 +++- openlp/plugins/songs/songsplugin.py | 28 +++---- 36 files changed, 368 insertions(+), 225 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index e31ff0c5d..211a02fef 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -109,10 +109,6 @@ class OpenLP(QtGui.QApplication): if 'OpenLP' in args: args.remove('OpenLP') self.args.extend(args) - # provide a listener for widgets to reqest a screen update. - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_process_events'), self.processEvents) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'cursor_busy'), self.setBusyCursor) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'cursor_normal'), self.setNormalCursor) # Decide how many screens we have and their size screens = ScreenList.create(self.desktop()) # First time checks in settings @@ -182,21 +178,28 @@ class OpenLP(QtGui.QApplication): if not hasattr(self, u'exceptionForm'): self.exceptionForm = ExceptionForm(self.mainWindow) self.exceptionForm.exceptionTextEdit.setPlainText(''.join(format_exception(exctype, value, traceback))) - self.setNormalCursor() + self.set_normal_cursor() self.exceptionForm.exec_() - def setBusyCursor(self): + def process_events(self): + """ + Wrapper to make ProcessEvents visible and named correctly + """ + self.processEvents() + + def set_busy_cursor(self): """ Sets the Busy Cursor for the Application """ self.setOverrideCursor(QtCore.Qt.BusyCursor) self.processEvents() - def setNormalCursor(self): + def set_normal_cursor(self): """ Sets the Normal Cursor for the Application """ self.restoreOverrideCursor() + self.processEvents() def event(self, event): """ @@ -288,6 +291,7 @@ def main(args=None): app.setApplicationName(u'OpenLP') set_up_logging(AppLocation.get_directory(AppLocation.CacheDir)) registry = Registry.create() + Registry().register(u'openlp_core', app) app.setApplicationVersion(get_application_version()[u'version']) # Instance check if not options.testing: diff --git a/openlp/core/lib/eventreceiver.py b/openlp/core/lib/eventreceiver.py index d29652c35..29c8e75a3 100644 --- a/openlp/core/lib/eventreceiver.py +++ b/openlp/core/lib/eventreceiver.py @@ -55,15 +55,6 @@ class EventReceiver(QtCore.QObject): ``openlp_information_message`` Displays a standalone Information Message. - ``cursor_busy`` - Makes the cursor got to a busy form. - - ``cursor_normal`` - Resets the cursor to default. - - ``openlp_process_events`` - Requests the Application to flush the events queue. - ``openlp_version_check`` Version has changed so pop up window. @@ -120,29 +111,6 @@ class EventReceiver(QtCore.QObject): ``slidecontroller_live_stop_loop`` Stop the loop on the main display. - - **Servicemanager related signals** - - ``servicemanager_new_service`` - A new service is being loaded or created. - - ``servicemanager_previous_item`` - Display the previous item in the service. - - ``servicemanager_preview_live`` - Requests a Preview item from the Service Manager to update live and add - a new item to the preview panel. - - ``servicemanager_next_item`` - Display the next item in the service. - - ``servicemanager_set_item`` - Go live on a specific item, by index. - - ``service_item_update`` - Passes back to the service manager the service item after it has been - processed by the plugin. - **Display signals** ``update_display_css`` diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 4f559837c..53a61c788 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -332,9 +332,9 @@ class MediaManagerItem(QtGui.QWidget): Settings().value(self.settingsSection + u'/last directory'), self.onNewFileMasks) log.info(u'New files(s) %s', files) if files: - Receiver.send_message(u'cursor_busy') + self.openlp_core.set_busy_cursor() self.validateAndLoad(files) - Receiver.send_message(u'cursor_normal') + self.openlp_core.set_normal_cursor() def loadFile(self, files): """ @@ -698,3 +698,13 @@ class MediaManagerItem(QtGui.QWidget): theme_manager = property(_get_theme_manager) + def _get_openlp_core(self): + """ + Adds the openlp to the class dynamically + """ + if not hasattr(self, u'_openlp_core'): + self._openlp_core = Registry().get(u'openlp_core') + return self._openlp_core + + openlp_core = property(_get_openlp_core) + diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 49a08e32a..390614bad 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -409,6 +409,12 @@ class Plugin(QtCore.QObject): """ pass + def new_service_created(self): + """ + The plugin's needs to handle a new song creation + """ + pass + def _get_main_window(self): """ Adds the main window to the class dynamically @@ -419,3 +425,14 @@ class Plugin(QtCore.QObject): main_window = property(_get_main_window) + def _get_openlp_core(self): + """ + Adds the openlp to the class dynamically + """ + if not hasattr(self, u'_openlp_core'): + self._openlp_core = Registry().get(u'openlp_core') + return self._openlp_core + + openlp_core = property(_get_openlp_core) + + diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index ae1d9f984..6cba7104c 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -211,3 +211,13 @@ class PluginManager(object): if plugin.name == name: return plugin return None + + def new_service_created(self): + """ + Loop through all the plugins and give them an opportunity to handle a new service + """ + log.info(u'plugins - new service created') + for plugin in self.plugins: + if plugin.isActive(): + plugin.new_service_created() + diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 6ba8a8df9..b15d3a94f 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -146,13 +146,13 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): # Download the theme screenshots. self.themeScreenshotThread = ThemeScreenshotThread(self) self.themeScreenshotThread.start() - Receiver.send_message(u'cursor_normal') + self.openlp_core.set_normal_cursor() def nextId(self): """ Determine the next page in the Wizard to go to. """ - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() if self.currentId() == FirstTimePage.Plugins: if not self.webAccess: return FirstTimePage.NoInternet @@ -163,14 +163,13 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): elif self.currentId() == FirstTimePage.NoInternet: return FirstTimePage.Progress elif self.currentId() == FirstTimePage.Themes: - Receiver.send_message(u'cursor_busy') - Receiver.send_message(u'openlp_process_events') + self.openlp_core.set_busy_cursor() while not self.themeScreenshotThread.isFinished(): time.sleep(0.1) - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() # Build the screenshot icons, as this can not be done in the thread. self._buildThemeScreenshots() - Receiver.send_message(u'cursor_normal') + self.openlp_core.set_normal_cursor() return FirstTimePage.Defaults else: return self.currentId() + 1 @@ -181,7 +180,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): """ # Keep track of the page we are at. Triggering "Cancel" causes pageId # to be a -1. - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() if pageId != -1: self.lastId = pageId if pageId == FirstTimePage.Plugins: @@ -213,16 +212,15 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): if self.hasRunWizard: self.cancelButton.setVisible(False) elif pageId == FirstTimePage.Progress: - Receiver.send_message(u'cursor_busy') + self.openlp_core.set_busy_cursor() self.repaint() - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() # Try to give the wizard a chance to redraw itself time.sleep(0.2) self._preWizard() self._performWizard() self._postWizard() - Receiver.send_message(u'cursor_normal') - Receiver.send_message(u'openlp_process_events') + self.openlp_core.set_normal_cursor() def updateScreenListCombo(self): """ @@ -244,16 +242,15 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): self.downloadCancelled = True while self.themeScreenshotThread.isRunning(): time.sleep(0.1) - Receiver.send_message(u'cursor_normal') + self.openlp_core.set_normal_cursor() def onNoInternetFinishButtonClicked(self): """ Process the triggering of the "Finish" button on the No Internet page. """ - Receiver.send_message(u'cursor_busy') + self.openlp_core.set_busy_cursor() self._performWizard() - Receiver.send_message(u'cursor_normal') - Receiver.send_message(u'openlp_process_events') + self.openlp_core.set_normal_cursor() Settings().setValue(u'general/has run wizard', True) self.close() @@ -320,7 +317,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): self.progressLabel.setText(status_text) if increment > 0: self.progressBar.setValue(self.progressBar.value() + increment) - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() def _preWizard(self): """ @@ -328,10 +325,10 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): """ self.max_progress = 0 self.finishButton.setVisible(False) - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() # Loop through the songs list and increase for each selected item for i in xrange(self.songsListWidget.count()): - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() item = self.songsListWidget.item(i) if item.checkState() == QtCore.Qt.Checked: filename = item.data(QtCore.Qt.UserRole) @@ -340,7 +337,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): # Loop through the Bibles list and increase for each selected item iterator = QtGui.QTreeWidgetItemIterator(self.biblesTreeWidget) while iterator.value(): - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() item = iterator.value() if item.parent() and item.checkState(0) == QtCore.Qt.Checked: filename = item.data(0, QtCore.Qt.UserRole) @@ -349,7 +346,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): iterator += 1 # Loop through the themes list and increase for each selected item for i in xrange(self.themesListWidget.count()): - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() item = self.themesListWidget.item(i) if item.checkState() == QtCore.Qt.Checked: filename = item.data(QtCore.Qt.UserRole) @@ -369,7 +366,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): self.progressPage.setTitle(translate('OpenLP.FirstTimeWizard', 'Setting Up')) self.progressPage.setSubTitle(u'Setup complete.') self.repaint() - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() # Try to give the wizard a chance to repaint itself time.sleep(0.1) @@ -396,7 +393,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): self.finishButton.setEnabled(True) self.cancelButton.setVisible(False) self.nextButton.setVisible(False) - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() def _performWizard(self): """ @@ -471,3 +468,13 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): return self._theme_manager theme_manager = property(_get_theme_manager) + + def _get_openlp_core(self): + """ + Adds the openlp to the class dynamically + """ + if not hasattr(self, u'_openlp_core'): + self._openlp_core = Registry().get(u'openlp_core') + return self._openlp_core + + openlp_core = property(_get_openlp_core) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 3fed96ec4..a8e22db22 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -229,7 +229,7 @@ class MainDisplay(Display): log.debug(u'text to display') # Wait for the webview to update before displaying text. while not self.webLoaded: - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() self.setGeometry(self.screen[u'size']) if animate: self.frame.evaluateJavaScript(u'show_text("%s")' % slide.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"')) @@ -333,18 +333,18 @@ class MainDisplay(Display): Generates a preview of the image displayed. """ log.debug(u'preview for %s', self.isLive) - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() # We must have a service item to preview. if self.isLive and hasattr(self, u'serviceItem'): # Wait for the fade to finish before geting the preview. # Important otherwise preview will have incorrect text if at all! if self.serviceItem.themedata and self.serviceItem.themedata.display_slide_transition: while self.frame.evaluateJavaScript(u'show_text_complete()') == u'false': - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() # Wait for the webview to update before getting the preview. # Important otherwise first preview will miss the background ! while not self.webLoaded: - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() # if was hidden keep it hidden if self.isLive: if self.hideMode: @@ -486,6 +486,16 @@ class MainDisplay(Display): return self._image_manager image_manager = property(_get_image_manager) + + def _get_openlp_core(self): + """ + Adds the openlp to the class dynamically + """ + if not hasattr(self, u'_openlp_core'): + self._openlp_core = Registry().get(u'openlp_core') + return self._openlp_core + + openlp_core = property(_get_openlp_core) class AudioPlayer(QtCore.QObject): diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 1af37bac1..564542db7 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -531,7 +531,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'cleanup'), self.clean_up) # Media Manager QtCore.QObject.connect(self.mediaToolBox, QtCore.SIGNAL(u'currentChanged(int)'), self.onMediaToolBoxChanged) - Receiver.send_message(u'cursor_busy') + self.openlp_core.set_busy_cursor() # Simple message boxes QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_error_message'), self.onErrorMessage) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_warning_message'), self.onWarningMessage) @@ -580,7 +580,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # Hide/show the theme combobox on the service manager self.serviceManagerContents.theme_change() # Reset the cursor - Receiver.send_message(u'cursor_normal') + self.openlp_core.set_busy_cursor() def setAutoLanguage(self, value): self.languageGroup.setDisabled(value) @@ -635,20 +635,20 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ Give all the plugins a chance to perform some tasks at startup """ - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() for plugin in self.pluginManager.plugins: if plugin.isActive(): plugin.appStartup() - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() def firstTime(self): # Import themes if first time - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() for plugin in self.pluginManager.plugins: if hasattr(plugin, u'firstTime'): - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() plugin.firstTime() - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() temp_dir = os.path.join(unicode(gettempdir()), u'openlp') shutil.rmtree(temp_dir, True) @@ -669,7 +669,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtGui.QMessageBox.No) if answer == QtGui.QMessageBox.No: return - Receiver.send_message(u'cursor_busy') + self.openlp_core.set_busy_cursor() screens = ScreenList() firstTime = FirstTimeForm(screens, self) firstTime.exec_() @@ -979,14 +979,14 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): renderer. """ log.debug(u'screenChanged') - Receiver.send_message(u'cursor_busy') + self.openlp_core.set_busy_cursor() self.imageManager.updateDisplay() self.renderer.update_display() self.previewController.screenSizeChanged() self.liveController.screenSizeChanged() self.setFocus() self.activateWindow() - Receiver.send_message(u'cursor_normal') + self.openlp_core.set_busy_cursor() def closeEvent(self, event): """ @@ -1270,14 +1270,14 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.loadProgressBar.show() self.loadProgressBar.setMaximum(size) self.loadProgressBar.setValue(0) - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() def incrementProgressBar(self): """ Increase the Progress Bar value by 1 """ self.loadProgressBar.setValue(self.loadProgressBar.value() + 1) - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() def finishedProgressBar(self): """ @@ -1292,7 +1292,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): if event.timerId() == self.timer_id: self.timer_id = 0 self.loadProgressBar.hide() - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() def setNewDataPath(self, new_data_path): self.newDataPath = new_data_path @@ -1307,20 +1307,19 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): if self.copyData: log.info(u'Copying data to new path') try: - Receiver.send_message(u'openlp_process_events') - Receiver.send_message(u'cursor_busy') + self.openlp_core.set_busy_cursor() self.showStatusMessage( translate('OpenLP.MainWindow', 'Copying OpenLP data to new data directory location - %s ' '- Please wait for copy to finish').replace('%s', self.newDataPath)) dir_util.copy_tree(old_data_path, self.newDataPath) log.info(u'Copy sucessful') except (IOError, os.error, DistutilsFileError), why: - Receiver.send_message(u'cursor_normal') + self.openlp_core.set_normal_cursor() log.exception(u'Data copy failed %s' % unicode(why)) QtGui.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'New Data Directory Error'), translate('OpenLP.MainWindow', 'OpenLP Data directory copy failed\n\n%s').replace('%s', unicode(why)), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) return False else: log.info(u'No data copy requested') @@ -1331,3 +1330,12 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): if self.newDataPath == AppLocation.get_directory(AppLocation.DataDir): settings.remove(u'advanced/data path') + def _get_openlp_core(self): + """ + Adds the openlp to the class dynamically + """ + if not hasattr(self, u'_openlp_core'): + self._openlp_core = Registry().get(u'openlp_core') + return self._openlp_core + + openlp_core = property(_get_openlp_core) \ No newline at end of file diff --git a/openlp/core/ui/media/mediaplayer.py b/openlp/core/ui/media/mediaplayer.py index 9d09cda6e..f907ef872 100644 --- a/openlp/core/ui/media/mediaplayer.py +++ b/openlp/core/ui/media/mediaplayer.py @@ -27,6 +27,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +from openlp.core.lib import Registry from openlp.core.ui.media import MediaState class MediaPlayer(object): @@ -143,3 +144,13 @@ class MediaPlayer(object): Returns Information about the player """ return u'' + + def _get_openlp_core(self): + """ + Adds the openlp to the class dynamically + """ + if not hasattr(self, u'_openlp_core'): + self._openlp_core = Registry().get(u'openlp_core') + return self._openlp_core + + openlp_core = property(_get_openlp_core) \ No newline at end of file diff --git a/openlp/core/ui/media/phononplayer.py b/openlp/core/ui/media/phononplayer.py index da2d19857..6cb09bdf5 100644 --- a/openlp/core/ui/media/phononplayer.py +++ b/openlp/core/ui/media/phononplayer.py @@ -34,7 +34,7 @@ from datetime import datetime from PyQt4 import QtGui from PyQt4.phonon import Phonon -from openlp.core.lib import Receiver, translate, Settings +from openlp.core.lib import translate, Settings from openlp.core.ui.media import MediaState from openlp.core.ui.media.mediaplayer import MediaPlayer @@ -150,7 +150,7 @@ class PhononPlayer(MediaPlayer): current_state = display.mediaObject.state() if current_state == Phonon.ErrorState: return False - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() if (datetime.now() - start).seconds > 5: return False return True diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 6f3e3d0e7..e09f043af 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -35,7 +35,7 @@ import sys from PyQt4 import QtGui -from openlp.core.lib import Receiver, translate, Settings +from openlp.core.lib import translate, Settings from openlp.core.ui.media import MediaState from openlp.core.ui.media.mediaplayer import MediaPlayer @@ -173,7 +173,7 @@ class VlcPlayer(MediaPlayer): while not mediaState == display.vlcMedia.get_state(): if display.vlcMedia.get_state() == vlc.State.Error: return False - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() if (datetime.now() - start).seconds > 60: return False return True diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index 37cae9a0a..d11606366 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -31,7 +31,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import PluginStatus, Receiver, translate +from openlp.core.lib import PluginStatus, Registry, translate from plugindialog import Ui_PluginViewDialog log = logging.getLogger(__name__) @@ -62,7 +62,7 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): self._clearDetails() self.programaticChange = True pluginListWidth = 0 - for plugin in self.parent().pluginManager.plugins: + for plugin in self.plugin_manager.plugins: item = QtGui.QListWidgetItem(self.pluginListWidget) # We do this just to make 100% sure the status is an integer as # sometimes when it's loaded from the config, it isn't cast to int. @@ -106,10 +106,9 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): if self.pluginListWidget.currentItem() is None: self._clearDetails() return - plugin_name_singular = \ - self.pluginListWidget.currentItem().text().split(u'(')[0][:-1] + plugin_name_singular = self.pluginListWidget.currentItem().text().split(u'(')[0][:-1] self.activePlugin = None - for plugin in self.parent().pluginManager.plugins: + for plugin in self.plugin_manager.plugins: if plugin.status != PluginStatus.Disabled: if plugin.nameStrings[u'singular'] == plugin_name_singular: self.activePlugin = plugin @@ -123,9 +122,9 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): if self.programaticChange or status == PluginStatus.Disabled: return if status == PluginStatus.Inactive: - Receiver.send_message(u'cursor_busy') + self.openlp_core.set_busy_cursor() self.activePlugin.toggleStatus(PluginStatus.Active) - Receiver.send_message(u'cursor_normal') + self.openlp_core.set_normal_cursor() self.activePlugin.appStartup() else: self.activePlugin.toggleStatus(PluginStatus.Inactive) @@ -138,3 +137,23 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): status_text = translate('OpenLP.PluginForm', '%s (Disabled)') self.pluginListWidget.currentItem().setText( status_text % self.activePlugin.nameStrings[u'singular']) + + def _get_plugin_manager(self): + """ + Adds the plugin manager to the class dynamically + """ + if not hasattr(self, u'_plugin_manager'): + self._plugin_manager = Registry().get(u'plugin_manager') + return self._plugin_manager + + plugin_manager = property(_get_plugin_manager) + + def _get_openlp_core(self): + """ + Adds the openlp to the class dynamically + """ + if not hasattr(self, u'_openlp_core'): + self._openlp_core = Registry().get(u'openlp_core') + return self._openlp_core + + openlp_core = property(_get_openlp_core) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index ff3d0721e..eb354a9c5 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -203,18 +203,10 @@ class ServiceManagerDialog(object): QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL(u'itemExpanded(QTreeWidgetItem*)'), self.expanded) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.update_theme_list) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_preview_live'), - self.preview_live) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_next_item'), self.next_item) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_previous_item'), - self.previous_item) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_set_item'), self.on_set_item) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.config_updated) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'), self.regenerate_service_Items) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_global'), self.theme_change) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'service_item_update'), - self.service_item_update) # Last little bits of setting up self.service_theme = Settings().value(self.main_window.serviceManagerSettingsSection + u'/service theme') self.servicePath = AppLocation.get_section_data_path(u'servicemanager') @@ -448,7 +440,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): self.service_id += 1 self.set_modified(False) Settings().setValue(u'servicemanager/last file', u'') - Receiver.send_message(u'servicemanager_new_service') + self.plugin_manager.new_service_created() def save_file(self): """ @@ -476,7 +468,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): missing_list = [] audio_files = [] total_size = 0 - Receiver.send_message(u'cursor_busy') + self.openlp_core.set_busy_cursor() # Number of items + 1 to zip it self.main_window.displayProgressBar(len(self.service_items) + 1) # Get list of missing files, and list of files to write @@ -492,7 +484,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): else: write_list.append(path_from) if missing_list: - Receiver.send_message(u'cursor_normal') + self.openlp_core.set_normal_cursor() title = translate('OpenLP.ServiceManager', 'Service File(s) Missing') message = translate('OpenLP.ServiceManager', 'The following file(s) in the service are missing:\n\t%s\n\n' @@ -502,7 +494,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): if answer == QtGui.QMessageBox.Cancel: self.main_window.finishedProgressBar() return False - Receiver.send_message(u'cursor_busy') + self.openlp_core.set_busy_cursor() # Check if item contains a missing file. for item in list(self.service_items): self.main_window.incrementProgressBar() @@ -563,7 +555,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): if zip_file: zip_file.close() self.main_window.finishedProgressBar() - Receiver.send_message(u'cursor_normal') + self.openlp_core.set_normal_cursor() if success: try: shutil.copy(temp_file_name, path_file_name) @@ -592,7 +584,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): log.debug(u'ServiceManager.save_file - %s', path_file_name) Settings().setValue(self.main_window.serviceManagerSettingsSection + u'/last directory', path) service = [] - Receiver.send_message(u'cursor_busy') + self.openlp_core.set_busy_cursor() # Number of items + 1 to zip it self.main_window.displayProgressBar(len(self.service_items) + 1) for item in self.service_items: @@ -621,7 +613,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): if zip_file: zip_file.close() self.main_window.finishedProgressBar() - Receiver.send_message(u'cursor_normal') + self.openlp_core.set_normal_cursor() if success: try: shutil.copy(temp_file_name, path_file_name) @@ -718,7 +710,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): if osfile.endswith(u'osd'): p_file = os.path.join(self.servicePath, osfile) if 'p_file' in locals(): - Receiver.send_message(u'cursor_busy') + self.openlp_core.set_busy_cursor() file_to = open(p_file, u'r') items = cPickle.load(file_to) file_to.close() @@ -763,6 +755,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): QtGui.QMessageBox.information(self, translate('OpenLP.ServiceManager', 'Corrupt File'), translate('OpenLP.ServiceManager', 'This file is either corrupt or it is not an OpenLP 2 service file.')) + self.openlp_core.set_normal_cursor() return finally: if file_to: @@ -770,7 +763,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): if zip_file: zip_file.close() self.main_window.finishedProgressBar() - Receiver.send_message(u'cursor_normal') + self.openlp_core.set_normal_cursor() self.repaint_service_list(-1, -1) def load_Last_file(self): @@ -944,12 +937,20 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): self.add_service_item(self.serviceItemEditForm.get_service_item(), replace=True, expand=self.service_items[item][u'expanded']) - def preview_live(self, message): + def preview_live(self, unique_identifier, row): """ Called by the SlideController to request a preview item be made live - and allows the next preview to be updated if relevant. + and allows the next preview to be updated if relevant + + + ``unique_identifier`` + Reference to the service_item + + + ``row`` + individual row number + """ - unique_identifier, row = message.split(u':') for sitem in self.service_items: if sitem[u'service_item'].unique_identifier == unique_identifier: item = self.service_manager_list.topLevelItem(sitem[u'order'] - 1) @@ -975,9 +976,13 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): lookFor = 1 serviceIterator += 1 - def previous_item(self, message): + def previous_item(self, last_slide=False): """ Called by the SlideController to select the previous service item. + + ``last_slide`` + Is this the last slide in the service_item + """ if not self.service_manager_list.selectedItems(): return @@ -987,7 +992,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): serviceIterator = QtGui.QTreeWidgetItemIterator(self.service_manager_list) while serviceIterator.value(): if serviceIterator.value() == selected: - if message == u'last slide' and prevItemLastSlide: + if last_slide and prevItemLastSlide: pos = prevItem.data(0, QtCore.Qt.UserRole) check_expanded = self.service_items[pos - 1][u'expanded'] self.service_manager_list.setCurrentItem(prevItemLastSlide) @@ -1246,7 +1251,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): Rebuild the service list as things have changed and a repaint is the easiest way to do this. """ - Receiver.send_message(u'cursor_busy') + self.openlp_core.set_busy_cursor() log.debug(u'regenerate_service_Items') # force reset of renderer as theme data has changed self.service_has_all_original_files = True @@ -1278,14 +1283,14 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): self.set_modified() # Repaint it once only at the end self.repaint_service_list(-1, -1) - Receiver.send_message(u'cursor_normal') + self.openlp_core.set_normal_cursor() - def service_item_update(self, message): + def service_item_update(self, edit_id, unique_identifier, temporary=False): """ Triggered from plugins to update service items. Save the values as they will be used as part of the service load """ - edit_id, self.load_item_unique_identifier, temporary = message.split(u':') + self.load_item_unique_identifier = unique_identifier self.load_item_edit_id = int(edit_id) self.load_item_temporary = str_to_bool(temporary) @@ -1353,7 +1358,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): """ Send the current item to the Preview slide controller """ - Receiver.send_message(u'cursor_busy') + self.openlp_core.set_busy_cursor() item, child = self.find_service_item() if self.service_items[item][u'service_item'].is_valid: self.preview_controller.addServiceManagerItem(self.service_items[item][u'service_item'], child) @@ -1361,7 +1366,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): critical_error_message_box(translate('OpenLP.ServiceManager', 'Missing Display Handler'), translate('OpenLP.ServiceManager', 'Your item cannot be displayed as there is no handler to display it')) - Receiver.send_message(u'cursor_normal') + self.openlp_core.set_normal_cursor() def get_service_item(self): """ @@ -1394,7 +1399,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): return if row != -1: child = row - Receiver.send_message(u'cursor_busy') + self.openlp_core.set_busy_cursor() if self.service_items[item][u'service_item'].is_valid: self.live_controller.addServiceManagerItem(self.service_items[item][u'service_item'], child) if Settings().value(self.main_window.generalSettingsSection + u'/auto preview'): @@ -1409,7 +1414,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): critical_error_message_box(translate('OpenLP.ServiceManager', 'Missing Display Handler'), translate('OpenLP.ServiceManager', 'Your item cannot be displayed as the plugin required to display it is missing or inactive')) - Receiver.send_message(u'cursor_normal') + self.openlp_core.set_normal_cursor() def remote_edit(self): """ @@ -1621,4 +1626,14 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): self._main_window = Registry().get(u'main_window') return self._main_window - main_window = property(_get_main_window) \ No newline at end of file + main_window = property(_get_main_window) + + def _get_openlp_core(self): + """ + Adds the openlp to the class dynamically + """ + if not hasattr(self, u'_openlp_core'): + self._openlp_core = Registry().get(u'openlp_core') + return self._openlp_core + + openlp_core = property(_get_openlp_core) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index c2216da58..002c1e49d 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -510,12 +510,12 @@ class SlideController(DisplayController): self.keypress_loop = True keypressCommand = self.keypress_queue.popleft() if keypressCommand == ServiceItemAction.Previous: - Receiver.send_message('servicemanager_previous_item') + self.service_manager.previous_item() elif keypressCommand == ServiceItemAction.PreviousLastSlide: # Go to the last slide of the previous item - Receiver.send_message('servicemanager_previous_item', u'last slide') + self.service_manager.previous_item(last_slide=True) else: - Receiver.send_message('servicemanager_next_item') + self.service_manager.next_item() self.keypress_loop = False def screenSizeChanged(self): @@ -1248,8 +1248,7 @@ class SlideController(DisplayController): row = self.previewListWidget.currentRow() if -1 < row < self.previewListWidget.rowCount(): if self.serviceItem.from_service: - Receiver.send_message('servicemanager_preview_live', u'%s:%s' % - (self.serviceItem.unique_identifier, row)) + self.service_manager.preview_live(self.serviceItem.unique_identifier, row) else: self.live_controller.addServiceManagerItem(self.serviceItem, row) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index ac1d8b02c..ba2602277 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -147,13 +147,13 @@ class ThemeManager(QtGui.QWidget): """ Import new themes downloaded by the first time wizard """ - Receiver.send_message(u'cursor_busy') + self.openlp_core.set_busy_cursor() files = SettingsManager.get_files(self.settingsSection, u'.otz') for file_name in files: file_name = os.path.join(self.path, file_name) self.unzip_theme(file_name, self.path) delete_file(file) - Receiver.send_message(u'cursor_normal') + self.openlp_core.set_normal_cursor() def config_updated(self): """ @@ -361,7 +361,7 @@ class ThemeManager(QtGui.QWidget): path = QtGui.QFileDialog.getExistingDirectory(self, translate('OpenLP.ThemeManager', 'Save Theme - (%s)') % theme, Settings().value(self.settingsSection + u'/last directory export')) - Receiver.send_message(u'cursor_busy') + self.openlp_core.set_busy_cursor() if path: Settings().setValue(self.settingsSection + u'/last directory export', path) theme_path = os.path.join(path, theme + u'.otz') @@ -383,7 +383,7 @@ class ThemeManager(QtGui.QWidget): finally: if zip_file: zip_file.close() - Receiver.send_message(u'cursor_normal') + self.openlp_core.set_normal_cursor() def on_import_theme(self): """ @@ -398,12 +398,12 @@ class ThemeManager(QtGui.QWidget): log.info(u'New Themes %s', unicode(files)) if not files: return - Receiver.send_message(u'cursor_busy') + self.openlp_core.set_busy_cursor() for file_name in files: Settings().setValue(self.settingsSection + u'/last directory import', unicode(file_name)) self.unzip_theme(file_name, self.path) self.load_themes() - Receiver.send_message(u'cursor_normal') + self.openlp_core.set_normal_cursor() def load_themes(self, first_time=False): """ @@ -841,3 +841,13 @@ class ThemeManager(QtGui.QWidget): return self._main_window main_window = property(_get_main_window) + + def _get_openlp_core(self): + """ + Adds the openlp to the class dynamically + """ + if not hasattr(self, u'_openlp_core'): + self._openlp_core = Registry().get(u'openlp_core') + return self._openlp_core + + openlp_core = property(_get_openlp_core) \ No newline at end of file diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index bf7dff269..f5dc26101 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -34,7 +34,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, Receiver, Settings, translate, UiStrings +from openlp.core.lib import build_icon, Receiver, Registry, Settings, translate, UiStrings from openlp.core.lib.ui import add_welcome_page log = logging.getLogger(__name__) @@ -215,7 +215,7 @@ class OpenLPWizard(QtGui.QWizard): self.progressLabel.setText(status_text) if increment > 0: self.progressBar.setValue(self.progressBar.value() + increment) - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() def preWizard(self): """ @@ -233,7 +233,7 @@ class OpenLPWizard(QtGui.QWizard): self.progressBar.setValue(self.progressBar.maximum()) self.finishButton.setVisible(True) self.cancelButton.setVisible(False) - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() def getFileName(self, title, editbox, setting_name, filters=u''): """ @@ -282,3 +282,13 @@ class OpenLPWizard(QtGui.QWizard): if folder: editbox.setText(folder) Settings().setValue(self.plugin.settingsSection + u'/' + setting_name, folder) + + def _get_openlp_core(self): + """ + Adds the openlp to the class dynamically + """ + if not hasattr(self, u'_openlp_core'): + self._openlp_core = Registry().get(u'openlp_core') + return self._openlp_core + + openlp_core = property(_get_openlp_core) \ No newline at end of file diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index ba5e08c7f..d8bf1e7e8 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -39,7 +39,7 @@ from subprocess import Popen, PIPE import sys import urllib2 -from openlp.core.lib import Settings +from openlp.core.lib import Registry, Settings from PyQt4 import QtGui, QtCore @@ -425,7 +425,7 @@ def get_web_page(url, header=None, update_openlp=False): if not page: return None if update_openlp: - Receiver.send_message(u'openlp_process_events') + Registry().get(u'openlp_core').process_events() log.debug(page) return page diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 05469eae9..93ee35154 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -34,7 +34,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, translate, Settings, UiStrings +from openlp.core.lib import translate, Settings, UiStrings from openlp.core.lib.db import delete_database from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard, WizardStrings @@ -578,7 +578,7 @@ class BibleImportForm(OpenLPWizard): self.progressLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Registering Bible...')) else: self.progressLabel.setText(WizardStrings.StartingImport) - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() def performWizard(self): """ diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 0b2f214f7..d46af6e36 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -335,7 +335,7 @@ class BibleUpgradeForm(OpenLPWizard): """ OpenLPWizard.preWizard(self) self.progressLabel.setText(translate('BiblesPlugin.UpgradeWizardForm', 'Starting upgrade...')) - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() def performWizard(self): """ @@ -465,7 +465,7 @@ class BibleUpgradeForm(OpenLPWizard): self.newbibles[number].create_verse(db_book.id, int(verse[u'chapter']), int(verse[u'verse']), unicode(verse[u'text'])) - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() self.newbibles[number].session.commit() else: language_id = self.newbibles[number].get_object(BibleMeta, u'language_id') @@ -511,7 +511,7 @@ class BibleUpgradeForm(OpenLPWizard): self.newbibles[number].create_verse(db_book.id, int(verse[u'chapter']), int(verse[u'verse']), unicode(verse[u'text'])) - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() self.newbibles[number].session.commit() if not self.success.get(number, True): self.incrementProgressBar(translate('BiblesPlugin.UpgradeWizardForm', diff --git a/openlp/plugins/bibles/forms/editbibleform.py b/openlp/plugins/bibles/forms/editbibleform.py index 26a58d14b..52093dffc 100644 --- a/openlp/plugins/bibles/forms/editbibleform.py +++ b/openlp/plugins/bibles/forms/editbibleform.py @@ -32,7 +32,7 @@ import re from PyQt4 import QtGui -from openlp.core.lib import Receiver, translate, UiStrings +from openlp.core.lib import Registry, translate, UiStrings from openlp.core.lib.ui import critical_error_message_box from editbibledialog import Ui_EditBibleDialog from openlp.plugins.bibles.lib import BibleStrings @@ -122,8 +122,7 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog): if book.name != custom_names[abbr]: if not self.validateBook(custom_names[abbr], abbr): return - Receiver.send_message(u'openlp_process_events') - Receiver.send_message(u'cursor_busy') + self.openlp_core.set_busy_cursor() self.manager.save_meta_data(self.bible, version, copyright, permissions, book_name_language) if not self.webbible: for abbr, book in self.books.iteritems(): @@ -132,7 +131,7 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog): book.name = custom_names[abbr] self.manager.update_book(self.bible, book) self.bible = None - Receiver.send_message(u'cursor_normal') + self.openlp_core.set_normal_cursor() QtGui.QDialog.accept(self) def validateMeta(self, name, copyright): @@ -189,3 +188,13 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog): % new_book_name) return False return True + + def _get_openlp_core(self): + """ + Adds the openlp to the class dynamically + """ + if not hasattr(self, u'_openlp_core'): + self._openlp_core = Registry().get(u'openlp_core') + return self._openlp_core + + openlp_core = property(_get_openlp_core) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index c09461721..20c92ffd6 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -118,7 +118,7 @@ class CSVBible(BibleDB): book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) self.create_book(unicode(line[2], details['encoding']), book_ref_id, book_details[u'testament_id']) book_list[int(line[0])] = unicode(line[2], details['encoding']) - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() except (IOError, IndexError): log.exception(u'Loading books from file failed') success = False @@ -157,7 +157,7 @@ class CSVBible(BibleDB): verse_text = unicode(line[3], u'cp1252') self.create_verse(book.id, line[1], line[2], verse_text) self.wizard.incrementProgressBar(translate('BiblesPlugin.CSVBible', 'Importing verses... done.')) - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() self.session.commit() except IOError: log.exception(u'Loading verses from file failed') diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 11bdd09e7..5b492d10e 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -38,7 +38,7 @@ from sqlalchemy import Column, ForeignKey, or_, Table, types, func from sqlalchemy.orm import class_mapper, mapper, relation from sqlalchemy.orm.exc import UnmappedClassError -from openlp.core.lib import Receiver, translate +from openlp.core.lib import Receiver, Registry, translate from openlp.core.lib.db import BaseModel, init_db, Manager from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import AppLocation, clean_filename @@ -549,6 +549,16 @@ class BibleDB(QtCore.QObject, Manager): verses = self.session.query(Verse).all() log.debug(verses) + def _get_openlp_core(self): + """ + Adds the openlp to the class dynamically + """ + if not hasattr(self, u'_openlp_core'): + self._openlp_core = Registry().get(u'openlp_core') + return self._openlp_core + + openlp_core = property(_get_openlp_core) + class BiblesResourcesDB(QtCore.QObject, Manager): """ diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 327f03565..522dd08c3 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -38,7 +38,7 @@ from HTMLParser import HTMLParseError from BeautifulSoup import BeautifulSoup, NavigableString, Tag -from openlp.core.lib import Receiver, translate +from openlp.core.lib import Receiver, Registry,translate from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import get_web_page from openlp.plugins.bibles.lib import SearchResults @@ -164,7 +164,7 @@ class BGExtract(object): if len(verse_parts) > 1: verse = int(verse_parts[0]) except TypeError: - log.warn(u'Illegal verse number: %s', unicode(raw_verse_num)) + log.warn(u'Illegal verse number: %s', unicode(verse)) verses.append((verse, text)) verse_list = {} for verse, text in verses[::-1]: @@ -235,9 +235,10 @@ class BGExtract(object): soup = get_soup_for_bible_ref( u'http://www.biblegateway.com/passage/?%s' % url_params, pre_parse_regex=r'', pre_parse_substitute='', cleaner=cleaner) + self.openlp_core.process_events() if not soup: return None - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() div = soup.find('div', 'result-text-style-normal') self._clean_soup(div) span_list = div.findAll('span', 'text') @@ -281,7 +282,7 @@ class BGExtract(object): if not soup: send_error_message(u'parse') return None - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() content = soup.find(u'table', u'infotable') if content: content = content.findAll(u'tr') @@ -329,7 +330,7 @@ class BSExtract(object): soup = get_soup_for_bible_ref(chapter_url, header) if not soup: return None - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() content = soup.find(u'div', u'content') if not content: log.error(u'No verses found in the Bibleserver response.') @@ -339,7 +340,7 @@ class BSExtract(object): verse_number = re.compile(r'v(\d{1,2})(\d{3})(\d{3}) verse.*') verses = {} for verse in content: - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() versenumber = int(verse_number.sub(r'\3', verse[u'class'])) verses[versenumber] = verse.contents[1].rstrip(u'\n') return SearchResults(book_name, chapter, verses) @@ -402,7 +403,7 @@ class CWExtract(object): soup = get_soup_for_bible_ref(chapter_url) if not soup: return None - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() html_verses = soup.findAll(u'span', u'versetext') if not html_verses: log.error(u'No verses found in the CrossWalk response.') @@ -412,27 +413,25 @@ class CWExtract(object): reduce_spaces = re.compile(r'[ ]{2,}') fix_punctuation = re.compile(r'[ ]+([.,;])') for verse in html_verses: - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() verse_number = int(verse.contents[0].contents[0]) verse_text = u'' for part in verse.contents: - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() if isinstance(part, NavigableString): verse_text = verse_text + part elif part and part.attrMap and \ - (part.attrMap[u'class'] == u'WordsOfChrist' or \ - part.attrMap[u'class'] == u'strongs'): + (part.attrMap[u'class'] == u'WordsOfChrist' or part.attrMap[u'class'] == u'strongs'): for subpart in part.contents: - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() if isinstance(subpart, NavigableString): verse_text = verse_text + subpart - elif subpart and subpart.attrMap and \ - subpart.attrMap[u'class'] == u'strongs': + elif subpart and subpart.attrMap and subpart.attrMap[u'class'] == u'strongs': for subsub in subpart.contents: - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() if isinstance(subsub, NavigableString): verse_text = verse_text + subsub - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() # Fix up leading and trailing spaces, multiple spaces, and spaces # between text and , and . verse_text = verse_text.strip(u'\n\r\t ') @@ -598,7 +597,7 @@ class HTTPBible(BibleDB): return [] book = db_book.name if BibleDB.get_verse_count(self, book_id, reference[1]) == 0: - Receiver.send_message(u'cursor_busy') + self.openlp_core.set_busy_cursor() search_results = self.get_chapter(book, reference[1]) if search_results and search_results.has_verselist(): ## We have found a book of the bible lets check to see @@ -606,14 +605,14 @@ class HTTPBible(BibleDB): ## we get a correct book. For example it is possible ## to request ac and get Acts back. book_name = search_results.book - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() # Check to see if book/chapter exists. db_book = self.get_book(book_name) self.create_chapter(db_book.id, search_results.chapter, search_results.verselist) - Receiver.send_message(u'openlp_process_events') - Receiver.send_message(u'cursor_normal') - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() + self.openlp_core.set_normal_cursor() + self.openlp_core.process_events() return BibleDB.get_verses(self, reference_list, show_error) def get_chapter(self, book, chapter): @@ -660,6 +659,16 @@ class HTTPBible(BibleDB): log.debug(u'HTTPBible.get_verse_count("%s", %s)', book_id, chapter) return BiblesResourcesDB.get_verse_count(book_id, chapter) + def _get_openlp_core(self): + """ + Adds the openlp to the class dynamically + """ + if not hasattr(self, u'_openlp_core'): + self._openlp_core = Registry().get(u'openlp_core') + return self._openlp_core + + openlp_core = property(_get_openlp_core) + def get_soup_for_bible_ref(reference_url, header=None, pre_parse_regex=None, pre_parse_substitute=None, cleaner=None): """ @@ -698,10 +707,10 @@ def get_soup_for_bible_ref(reference_url, header=None, pre_parse_regex=None, soup = BeautifulSoup(page_source) except HTMLParseError: log.exception(u'BeautifulSoup could not parse the bible page.') + Registry().get(u'openlp_core').process_events() if not soup: send_error_message(u'parse') return None - Receiver.send_message(u'openlp_process_events') return soup def send_error_message(error_type): diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index fd1109221..02fe135e3 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -614,7 +614,7 @@ class BibleMediaItem(MediaManagerItem): """ log.debug(u'Advanced Search Button clicked') self.advancedSearchButton.setEnabled(False) - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() bible = self.advancedVersionComboBox.currentText() second_bible = self.advancedSecondComboBox.currentText() book = self.advancedBookComboBox.currentText() @@ -628,7 +628,7 @@ class BibleMediaItem(MediaManagerItem): verse_range = chapter_from + verse_separator + verse_from + range_separator + chapter_to + \ verse_separator + verse_to versetext = u'%s %s' % (book, verse_range) - Receiver.send_message(u'cursor_busy') + self.openlp_core.set_busy_cursor() self.search_results = self.plugin.manager.get_verses(bible, versetext, book_ref_id) if second_bible: self.second_search_results = self.plugin.manager.get_verses(second_bible, versetext, book_ref_id) @@ -640,8 +640,7 @@ class BibleMediaItem(MediaManagerItem): self.displayResults(bible, second_bible) self.advancedSearchButton.setEnabled(True) self.checkSearchResult() - Receiver.send_message(u'cursor_normal') - Receiver.send_message(u'openlp_process_events') + self.openlp_core.set_normal_cursor() def onQuickSearchButton(self): """ @@ -650,7 +649,7 @@ class BibleMediaItem(MediaManagerItem): """ log.debug(u'Quick Search Button clicked') self.quickSearchButton.setEnabled(False) - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() bible = self.quickVersionComboBox.currentText() second_bible = self.quickSecondComboBox.currentText() text = self.quickSearchEdit.text() @@ -662,7 +661,7 @@ class BibleMediaItem(MediaManagerItem): self.search_results[0].book.book_reference_id) else: # We are doing a 'Text Search'. - Receiver.send_message(u'cursor_busy') + self.openlp_core.set_busy_cursor() bibles = self.plugin.manager.get_bibles() self.search_results = self.plugin.manager.verse_search(bible, second_bible, text) if second_bible and self.search_results: @@ -697,8 +696,7 @@ class BibleMediaItem(MediaManagerItem): self.displayResults(bible, second_bible) self.quickSearchButton.setEnabled(True) self.checkSearchResult() - Receiver.send_message(u'cursor_normal') - Receiver.send_message(u'openlp_process_events') + self.openlp_core.set_normal_cursor() def displayResults(self, bible, second_bible=u''): """ diff --git a/openlp/plugins/bibles/lib/openlp1.py b/openlp/plugins/bibles/lib/openlp1.py index 732fdc23b..ab049625d 100644 --- a/openlp/plugins/bibles/lib/openlp1.py +++ b/openlp/plugins/bibles/lib/openlp1.py @@ -108,7 +108,7 @@ class OpenLP1Bible(BibleDB): verse_number = int(verse[1]) text = unicode(verse[2], u'cp1252') self.create_verse(db_book.id, chapter, verse_number, text) - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() self.session.commit() connection.close() return True diff --git a/openlp/plugins/bibles/lib/opensong.py b/openlp/plugins/bibles/lib/opensong.py index 271af883a..00d7c1318 100644 --- a/openlp/plugins/bibles/lib/opensong.py +++ b/openlp/plugins/bibles/lib/opensong.py @@ -30,7 +30,7 @@ import logging from lxml import etree, objectify -from openlp.core.lib import Receiver, translate +from openlp.core.lib import translate from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB @@ -129,7 +129,7 @@ class OpenSongBible(BibleDB): self.wizard.incrementProgressBar(translate('BiblesPlugin.Opensong', 'Importing %s %s...', 'Importing ...')) % (db_book.name, chapter_number) self.session.commit() - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() except etree.XMLSyntaxError as inst: critical_error_message_box(message=translate('BiblesPlugin.OpenSongImport', 'Incorrect Bible file type supplied. OpenSong Bibles may be ' diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index 3fddd7a4b..5996448ad 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -33,7 +33,7 @@ import chardet import codecs import re -from openlp.core.lib import Receiver, translate +from openlp.core.lib import translate from openlp.core.utils import AppLocation from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB @@ -182,7 +182,7 @@ class OSISBible(BibleDB): .replace(u'', u'').replace(u'', u'') verse_text = self.spaces_regex.sub(u' ', verse_text) self.create_verse(db_book.id, chapter, verse, verse_text) - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() self.session.commit() if match_count == 0: success = False diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index e434f516a..7b87dbef5 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -250,7 +250,7 @@ class CustomMediaItem(MediaManagerItem): and_(CustomSlide.title == item.title, CustomSlide.theme_name == item.theme, CustomSlide.credits == item.raw_footer[0][len(item.title) + 1:])) if custom: - Receiver.send_message(u'service_item_update', u'%s:%s:%s' % (custom.id, item.unique_identifier, False)) + self.service_manager.service_item_update(custom.id, item.unique_identifier) else: if self.add_custom_from_service: self.create_from_service_item(item) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 85024229a..7af23b0ec 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -99,7 +99,7 @@ class ImageMediaItem(MediaManagerItem): if check_item_selected(self.listView, translate('ImagePlugin.MediaItem','You must select an image to delete.')): row_list = [item.row() for item in self.listView.selectedIndexes()] row_list.sort(reverse=True) - Receiver.send_message(u'cursor_busy') + self.openlp_core.set_busy_cursor() self.main_window.displayProgressBar(len(row_list)) for row in row_list: text = self.listView.item(row) @@ -109,12 +109,12 @@ class ImageMediaItem(MediaManagerItem): self.main_window.incrementProgressBar() SettingsManager.setValue(self.settingsSection + u'/images files', self.getFileList()) self.main_window.finishedProgressBar() - Receiver.send_message(u'cursor_normal') + self.openlp_core.set_normal_cursor() self.listView.blockSignals(False) def loadList(self, images, initialLoad=False): + self.openlp_core.set_busy_cursor() if not initialLoad: - Receiver.send_message(u'cursor_busy') self.main_window.displayProgressBar(len(images)) # Sort the images by its filename considering language specific # characters. @@ -138,7 +138,7 @@ class ImageMediaItem(MediaManagerItem): self.main_window.incrementProgressBar() if not initialLoad: self.main_window.finishedProgressBar() - Receiver.send_message(u'cursor_normal') + self.openlp_core.set_busy_cursor() def generateSlideData(self, service_item, item=None, xmlVersion=False, remote=False, context=ServiceItemContext.Service): diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index eee1c5801..ab7659a2b 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -150,9 +150,8 @@ class PresentationMediaItem(MediaManagerItem): """ currlist = self.getFileList() titles = [os.path.split(file)[1] for file in currlist] - Receiver.send_message(u'cursor_busy') + self.openlp_core.set_busy_cursor() if not initialLoad: - Receiver.send_message(u'cursor_busy') self.main_window.displayProgressBar(len(files)) # Sort the presentations by its filename considering language specific characters. files.sort(cmp=locale_compare, @@ -206,10 +205,9 @@ class PresentationMediaItem(MediaManagerItem): item_name.setIcon(icon) item_name.setToolTip(file) self.listView.addItem(item_name) - Receiver.send_message(u'cursor_normal') if not initialLoad: self.main_window.finishedProgressBar() - Receiver.send_message(u'cursor_normal') + self.openlp_core.set_busy_cursor() def onDeleteClick(self): """ @@ -219,7 +217,7 @@ class PresentationMediaItem(MediaManagerItem): items = self.listView.selectedIndexes() row_list = [item.row() for item in items] row_list.sort(reverse=True) - Receiver.send_message(u'cursor_busy') + self.openlp_core.set_busy_cursor() self.main_window.displayProgressBar(len(row_list)) for item in items: filepath = unicode(item.data(QtCore.Qt.UserRole)) @@ -229,7 +227,7 @@ class PresentationMediaItem(MediaManagerItem): doc.close_presentation() self.main_window.incrementProgressBar() self.main_window.finishedProgressBar() - Receiver.send_message(u'cursor_normal') + self.openlp_core.set_busy_cursor() for row in row_list: self.listView.takeItem(row) Settings().setValue(self.settingsSection + u'/presentations files', self.getFileList()) diff --git a/openlp/plugins/songs/forms/songexportform.py b/openlp/plugins/songs/forms/songexportform.py index 29d4b8609..d0444913e 100644 --- a/openlp/plugins/songs/forms/songexportform.py +++ b/openlp/plugins/songs/forms/songexportform.py @@ -226,7 +226,7 @@ class SongExportForm(OpenLPWizard): self.directoryLineEdit.clear() self.searchLineEdit.clear() # Load the list of songs. - Receiver.send_message(u'cursor_busy') + self.openlp_core.set_busy_cursor() songs = self.plugin.manager.get_all_objects(Song) songs.sort(cmp=natcmp, key=lambda song: song.sort_key) for song in songs: @@ -240,7 +240,7 @@ class SongExportForm(OpenLPWizard): item.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled) item.setCheckState(QtCore.Qt.Unchecked) self.availableListWidget.addItem(item) - Receiver.send_message(u'cursor_normal') + self.openlp_core.set_normal_cursor() def preWizard(self): """ @@ -248,7 +248,7 @@ class SongExportForm(OpenLPWizard): """ OpenLPWizard.preWizard(self) self.progressLabel.setText(translate('SongsPlugin.ExportWizardForm', 'Starting export...')) - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() def performWizard(self): """ diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index efadd6b61..68b23a2a6 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -35,7 +35,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, Settings, SettingsManager, translate, UiStrings +from openlp.core.lib import Settings, SettingsManager, translate, UiStrings from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard, WizardStrings from openlp.plugins.songs.lib.importer import SongFormat, SongFormatSelect @@ -328,7 +328,7 @@ class SongImportForm(OpenLPWizard): """ OpenLPWizard.preWizard(self) self.progressLabel.setText(WizardStrings.StartingImport) - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() def performWizard(self): """ diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 474e68040..175d3e503 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -346,12 +346,12 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): """ Utility method to merge two objects to leave one in the database. """ - Receiver.send_message(u'cursor_busy') + self.openlp_core.set_busy_cursor() merge(dbObject) reset() if not self.fromSongEdit: Receiver.send_message(u'songs_load_list') - Receiver.send_message(u'cursor_normal') + self.openlp_core.set_normal_cursor() def mergeAuthors(self, oldAuthor): """ @@ -481,3 +481,12 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): deleteButton.setEnabled(True) editButton.setEnabled(True) + def _get_openlp_core(self): + """ + Adds the openlp to the class dynamically + """ + if not hasattr(self, u'_openlp_core'): + self._openlp_core = Registry().get(u'openlp_core') + return self._openlp_core + + openlp_core = property(_get_openlp_core) \ No newline at end of file diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index de1ad22ff..a8af9f407 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -361,7 +361,7 @@ class SongMediaItem(MediaManagerItem): QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No: return - Receiver.send_message(u'cursor_busy') + self.openlp_core.set_busy_cursor() self.main_window.displayProgressBar(len(items)) for item in items: item_id = item.data(QtCore.Qt.UserRole) @@ -380,7 +380,7 @@ class SongMediaItem(MediaManagerItem): self.plugin.manager.delete_object(Song, item_id) self.main_window.incrementProgressBar() self.main_window.finishedProgressBar() - Receiver.send_message(u'cursor_normal') + self.openlp_core.set_normal_cursor() self.onSearchTextButtonClicked() def onCloneClick(self): @@ -526,7 +526,7 @@ class SongMediaItem(MediaManagerItem): temporary = True # Update service with correct song id. if editId: - Receiver.send_message(u'service_item_update%s:%s:%s' % (editId, item.unique_identifier, temporary)) + self.service_manager.service_item_update(editId, item.unique_identifier, temporary) def search(self, string, showError): """ diff --git a/openlp/plugins/songs/lib/openlyricsexport.py b/openlp/plugins/songs/lib/openlyricsexport.py index 7db466dfc..9c1ee3513 100644 --- a/openlp/plugins/songs/lib/openlyricsexport.py +++ b/openlp/plugins/songs/lib/openlyricsexport.py @@ -35,7 +35,7 @@ import os from lxml import etree -from openlp.core.lib import check_directory_exists, Receiver, translate +from openlp.core.lib import Registry, check_directory_exists, translate from openlp.core.utils import clean_filename from openlp.plugins.songs.lib import OpenLyrics @@ -64,7 +64,7 @@ class OpenLyricsExport(object): openLyrics = OpenLyrics(self.manager) self.parent.progressBar.setMaximum(len(self.songs)) for song in self.songs: - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() if self.parent.stop_export_flag: return False self.parent.incrementProgressBar(translate('SongsPlugin.OpenLyricsExport', 'Exporting "%s"...') % @@ -80,3 +80,13 @@ class OpenLyricsExport(object): tree.write(open(os.path.join(self.save_path, filename), u'w'), encoding=u'utf-8', xml_declaration=True, pretty_print=True) return True + + def _get_openlp_core(self): + """ + Adds the openlp to the class dynamically + """ + if not hasattr(self, u'_openlp_core'): + self._openlp_core = Registry().get(u'openlp_core') + return self._openlp_core + + openlp_core = property(_get_openlp_core) diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 4f57d3e21..8818746b7 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -38,7 +38,7 @@ import sqlite3 from PyQt4 import QtCore, QtGui -from openlp.core.lib import Plugin, StringContent, build_icon, translate, Receiver, UiStrings +from openlp.core.lib import Plugin, StringContent, build_icon, translate, UiStrings from openlp.core.lib.db import Manager from openlp.core.lib.ui import create_action from openlp.core.utils import get_filesystem_encoding @@ -96,9 +96,6 @@ class SongsPlugin(Plugin): action_list.add_action(self.songImportItem, UiStrings().Import) action_list.add_action(self.songExportItem, UiStrings().Export) action_list.add_action(self.toolsReindexItem, UiStrings().Tools) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_new_service'), - self.clearTemporarySongs) - def addImportMenuItem(self, import_menu): """ @@ -244,9 +241,9 @@ class SongsPlugin(Plugin): If the first time wizard has run, this function is run to import all the new songs into the database. """ - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() self.onToolsReindexItemTriggered() - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() db_dir = unicode(os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp')) if not os.path.exists(db_dir): return @@ -254,12 +251,12 @@ class SongsPlugin(Plugin): song_count = 0 for sfile in os.listdir(db_dir): if sfile.startswith(u'songs_') and sfile.endswith(u'.sqlite'): - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() song_dbs.append(os.path.join(db_dir, sfile)) song_count += self._countSongs(os.path.join(db_dir, sfile)) if not song_dbs: return - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() progress = QtGui.QProgressDialog(self.main_window) progress.setWindowModality(QtCore.Qt.WindowModal) progress.setWindowTitle(translate('OpenLP.Ui', 'Importing Songs')) @@ -268,11 +265,11 @@ class SongsPlugin(Plugin): progress.setRange(0, song_count) progress.setMinimumDuration(0) progress.forceShow() - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() for db in song_dbs: importer = OpenLPSongImport(self.manager, filename=db) importer.doImport(progress) - Receiver.send_message(u'openlp_process_events') + self.openlp_core.process_events() progress.setValue(song_count) self.mediaItem.onSearchTextButtonClicked() @@ -281,7 +278,7 @@ class SongsPlugin(Plugin): Time to tidy up on exit """ log.info(u'Songs Finalising') - self.clearTemporarySongs() + self.new_service_created() # Clean up files and connections self.manager.finalise() self.songImportItem.setVisible(False) @@ -293,13 +290,18 @@ class SongsPlugin(Plugin): action_list.remove_action(self.toolsReindexItem, UiStrings().Tools) Plugin.finalise(self) - def clearTemporarySongs(self): - # Remove temporary songs + def new_service_created(self): + """ + Remove temporary songs from the database + """ songs = self.manager.get_all_objects(Song, Song.temporary == True) for song in songs: self.manager.delete_object(Song, song.id) def _countSongs(self, db_file): + """ + Provide a count of the songs in the database + """ connection = sqlite3.connect(db_file) cursor = connection.cursor() cursor.execute(u'SELECT COUNT(id) AS song_count FROM songs') From 00039fbdefe150ef215152ac377dbc1140895973 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sun, 3 Feb 2013 15:31:05 +0200 Subject: [PATCH 41/64] Removed an accidental commit --- openlp/core/ui/advancedtab.py.orig | 697 ----------------------------- 1 file changed, 697 deletions(-) delete mode 100644 openlp/core/ui/advancedtab.py.orig diff --git a/openlp/core/ui/advancedtab.py.orig b/openlp/core/ui/advancedtab.py.orig deleted file mode 100644 index 71a18bd1b..000000000 --- a/openlp/core/ui/advancedtab.py.orig +++ /dev/null @@ -1,697 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2013 Raoul Snyman # -# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan # -# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # -# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # -# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # -# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # -# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # -# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### -""" -The :mod:`advancedtab` provides an advanced settings facility. -""" -from datetime import datetime, timedelta -import logging -import os -import sys - -from PyQt4 import QtCore, QtGui - -from openlp.core.lib import SettingsTab, Receiver, Settings, UiStrings, translate, build_icon -from openlp.core.utils import get_images_filter, AppLocation, format_time -from openlp.core.lib import SlideLimits - -log = logging.getLogger(__name__) - - -class AdvancedTab(SettingsTab): - """ - The :class:`AdvancedTab` manages the advanced settings tab including the UI - and the loading and saving of the displayed settings. - """ - def __init__(self, parent): - """ - Initialise the settings tab - """ - self.display_changed = False - self.default_image = u':/graphics/openlp-splash-screen.png' - self.default_color = u'#ffffff' - self.data_exists = False - self.iconPath = u':/system/system_settings.png' - advanced_translated = translate('OpenLP.AdvancedTab', 'Advanced') - SettingsTab.__init__(self, parent, u'Advanced', advanced_translated) - - def setupUi(self): - """ - Configure the UI elements for the tab. - """ - self.setObjectName(u'AdvancedTab') - SettingsTab.setupUi(self) - self.ui_group_box = QtGui.QGroupBox(self.leftColumn) - self.ui_group_box.setObjectName(u'ui_group_box') - self.ui_layout = QtGui.QFormLayout(self.ui_group_box) - self.ui_layout.setObjectName(u'ui_layout') - self.recent_label = QtGui.QLabel(self.ui_group_box) - self.recent_label.setObjectName(u'recent_label') - self.recent_spin_box = QtGui.QSpinBox(self.ui_group_box) - self.recent_spin_box.setObjectName(u'recent_spin_box') - self.recent_spin_box.setMinimum(0) - self.ui_layout.addRow(self.recent_label, self.recent_spin_box) - self.media_plugin_check_box = QtGui.QCheckBox(self.ui_group_box) - self.media_plugin_check_box.setObjectName(u'media_plugin_check_box') - self.ui_layout.addRow(self.media_plugin_check_box) - self.double_click_live_check_box = QtGui.QCheckBox(self.ui_group_box) - self.double_click_live_check_box.setObjectName(u'double_click_live_check_box') - self.ui_layout.addRow(self.double_click_live_check_box) - self.single_click_preview_check_box = QtGui.QCheckBox(self.ui_group_box) - self.single_click_preview_check_box.setObjectName(u'single_click_preview_check_box') - self.ui_layout.addRow(self.single_click_preview_check_box) - self.expand_service_item_check_box = QtGui.QCheckBox(self.ui_group_box) - self.expand_service_item_check_box.setObjectName(u'expand_service_item_check_box') - self.ui_layout.addRow(self.expand_service_item_check_box) - self.enable_auto_close_check_box = QtGui.QCheckBox(self.ui_group_box) - self.enable_auto_close_check_box.setObjectName(u'enable_auto_close_check_box') - self.ui_layout.addRow(self.enable_auto_close_check_box) - self.leftLayout.addWidget(self.ui_group_box) - # Default service name - self.service_name_group_box = QtGui.QGroupBox(self.leftColumn) - self.service_name_group_box.setObjectName(u'service_name_group_box') - self.service_name_layout = QtGui.QFormLayout(self.service_name_group_box) - self.service_name_check_box = QtGui.QCheckBox(self.service_name_group_box) - self.service_name_check_box.setObjectName(u'service_name_check_box') - self.service_name_layout.setObjectName(u'service_name_layout') - self.service_name_layout.addRow(self.service_name_check_box) - self.service_name_time_label = QtGui.QLabel(self.service_name_group_box) - self.service_name_time_label.setObjectName(u'service_name_time_label') - self.service_name_day = QtGui.QComboBox(self.service_name_group_box) - self.service_name_day.addItems([u'', u'', u'', u'', u'', u'', u'', u'']) - self.service_name_day.setObjectName(u'service_name_day') - self.service_name_time = QtGui.QTimeEdit(self.service_name_group_box) - self.service_name_time.setObjectName(u'service_name_time') - self.service_name_time_layout = QtGui.QHBoxLayout() - self.service_name_time_layout.setObjectName(u'service_name_time_layout') - self.service_name_time_layout.addWidget(self.service_name_day) - self.service_name_time_layout.addWidget(self.service_name_time) - self.service_name_layout.addRow(self.service_name_time_label, self.service_name_time_layout) - self.service_name_label = QtGui.QLabel(self.service_name_group_box) - self.service_name_label.setObjectName(u'service_name_label') - self.service_name_edit = QtGui.QLineEdit(self.service_name_group_box) - self.service_name_edit.setObjectName(u'service_name_edit') - self.service_name_edit.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp(r'[^/\\?*|<>\[\]":+]+'), self)) - self.service_name_revert_button = QtGui.QToolButton(self.service_name_group_box) - self.service_name_revert_button.setObjectName(u'service_name_revert_button') - self.service_name_revert_button.setIcon(build_icon(u':/general/general_revert.png')) - self.service_name_button_layout = QtGui.QHBoxLayout() - self.service_name_button_layout.setObjectName(u'service_name_button_layout') - self.service_name_button_layout.addWidget(self.service_name_edit) - self.service_name_button_layout.addWidget(self.service_name_revert_button) - self.service_name_layout.addRow(self.service_name_label, self.service_name_button_layout) - self.service_name_example_label = QtGui.QLabel(self.service_name_group_box) - self.service_name_example_label.setObjectName(u'service_name_example_label') - self.service_name_example = QtGui.QLabel(self.service_name_group_box) - self.service_name_example.setObjectName(u'service_name_example') - self.service_name_layout.addRow(self.service_name_example_label, self.service_name_example) - self.leftLayout.addWidget(self.service_name_group_box) - # Data Directory - self.data_directory_group_box = QtGui.QGroupBox(self.leftColumn) - self.data_directory_group_box.setObjectName(u'data_directory_group_box') - self.data_directory_layout = QtGui.QFormLayout(self.data_directory_group_box) - self.data_directory_layout.setObjectName(u'data_directory_layout') - self.data_directory_current_label = QtGui.QLabel(self.data_directory_group_box) - self.data_directory_current_label.setObjectName( u'data_directory_current_label') - self.data_directory_label = QtGui.QLabel(self.data_directory_group_box) - self.data_directory_label.setObjectName(u'data_directory_label') - self.data_directory_new_label = QtGui.QLabel(self.data_directory_group_box) - self.data_directory_new_label.setObjectName(u'data_directory_current_label') - self.new_data_directory_edit = QtGui.QLineEdit(self.data_directory_group_box) - self.new_data_directory_edit.setObjectName(u'new_data_directory_edit') - self.new_data_directory_edit.setReadOnly(True) - self.new_data_directory_has_files_label = QtGui.QLabel(self.data_directory_group_box) - self.new_data_directory_has_files_label.setObjectName(u'new_data_directory_has_files_label') - self.new_data_directory_has_files_label.setWordWrap(True) - self.data_directory_browse_button = QtGui.QToolButton(self.data_directory_group_box) - self.data_directory_browse_button.setObjectName(u'data_directory_browse_button') - self.data_directory_browse_button.setIcon(build_icon(u':/general/general_open.png')) - self.data_directory_default_button = QtGui.QToolButton(self.data_directory_group_box) - self.data_directory_default_button.setObjectName(u'data_directory_default_button') - self.data_directory_default_button.setIcon(build_icon(u':/general/general_revert.png')) - self.data_directory_cancel_button = QtGui.QToolButton(self.data_directory_group_box) - self.data_directory_cancel_button.setObjectName(u'data_directory_cancel_button') - self.data_directory_cancel_button.setIcon(build_icon(u':/general/general_delete.png')) - self.new_data_directory_label_layout = QtGui.QHBoxLayout() - self.new_data_directory_label_layout.setObjectName(u'new_data_directory_label_layout') - self.new_data_directory_label_layout.addWidget(self.new_data_directory_edit) - self.new_data_directory_label_layout.addWidget(self.data_directory_browse_button) - self.new_data_directory_label_layout.addWidget(self.data_directory_default_button) - self.data_directory_copy_check_layout = QtGui.QHBoxLayout() - self.data_directory_copy_check_layout.setObjectName(u'data_directory_copy_check_layout') - self.data_directory_copy_check_box = QtGui.QCheckBox(self.data_directory_group_box) - self.data_directory_copy_check_box.setObjectName(u'data_directory_copy_check_box') - self.data_directory_copy_check_layout.addWidget(self.data_directory_copy_check_box) - self.data_directory_copy_check_layout.addStretch() - self.data_directory_copy_check_layout.addWidget(self.data_directory_cancel_button) - self.data_directory_layout.addRow(self.data_directory_current_label, self.data_directory_label) - self.data_directory_layout.addRow(self.data_directory_new_label, self.new_data_directory_label_layout) - self.data_directory_layout.addRow(self.data_directory_copy_check_layout) - self.data_directory_layout.addRow(self.new_data_directory_has_files_label) - self.leftLayout.addWidget(self.data_directory_group_box) - self.leftLayout.addStretch() - # Default Image - self.default_image_group_box = QtGui.QGroupBox(self.rightColumn) - self.default_image_group_box.setObjectName(u'default_image_group_box') - self.default_image_layout = QtGui.QFormLayout(self.default_image_group_box) - self.default_image_layout.setObjectName(u'default_image_layout') - self.default_color_label = QtGui.QLabel(self.default_image_group_box) - self.default_color_label.setObjectName(u'default_color_label') - self.default_color_button = QtGui.QPushButton(self.default_image_group_box) - self.default_color_button.setObjectName(u'default_color_button') - self.default_image_layout.addRow(self.default_color_label, self.default_color_button) - self.default_file_label = QtGui.QLabel(self.default_image_group_box) - self.default_file_label.setObjectName(u'default_file_label') - self.default_file_edit = QtGui.QLineEdit(self.default_image_group_box) - self.default_file_edit.setObjectName(u'default_file_edit') - self.default_browse_button = QtGui.QToolButton(self.default_image_group_box) - self.default_browse_button.setObjectName(u'default_browse_button') - self.default_browse_button.setIcon(build_icon(u':/general/general_open.png')) - self.default_revert_button = QtGui.QToolButton(self.default_image_group_box) - self.default_revert_button.setObjectName(u'default_revert_button') - self.default_revert_button.setIcon(build_icon(u':/general/general_revert.png')) - self.default_file_layout = QtGui.QHBoxLayout() - self.default_file_layout.setObjectName(u'default_file_layout') - self.default_file_layout.addWidget(self.default_file_edit) - self.default_file_layout.addWidget(self.default_browse_button) - self.default_file_layout.addWidget(self.default_revert_button) - self.default_image_layout.addRow(self.default_file_label, self.default_file_layout) - self.rightLayout.addWidget(self.default_image_group_box) - # Hide mouse - self.hide_mouse_group_box = QtGui.QGroupBox(self.rightColumn) - self.hide_mouse_group_box.setObjectName(u'hide_mouse_group_box') - self.hide_mouse_layout = QtGui.QVBoxLayout(self.hide_mouse_group_box) - self.hide_mouse_layout.setObjectName(u'hide_mouse_layout') - self.hide_mouse_check_box = QtGui.QCheckBox(self.hide_mouse_group_box) - self.hide_mouse_check_box.setObjectName(u'hide_mouse_check_box') - self.hide_mouse_layout.addWidget(self.hide_mouse_check_box) - self.rightLayout.addWidget(self.hide_mouse_group_box) - # Service Item Slide Limits - self.slide_group_box = QtGui.QGroupBox(self.rightColumn) - self.slide_group_box.setObjectName(u'slide_group_box') - self.slide_layout = QtGui.QVBoxLayout(self.slide_group_box) - self.slide_layout.setObjectName(u'slide_layout') - self.slide_label = QtGui.QLabel(self.slide_group_box) - self.slide_label.setWordWrap(True) - self.slide_layout.addWidget(self.slide_label) - self.end_slide_radio_button = QtGui.QRadioButton(self.slide_group_box) - self.end_slide_radio_button.setObjectName(u'end_slide_radio_button') - self.slide_layout.addWidget(self.end_slide_radio_button) - self.wrap_slide_radio_button = QtGui.QRadioButton(self.slide_group_box) - self.wrap_slide_radio_button.setObjectName(u'wrap_slide_radio_button') - self.slide_layout.addWidget(self.wrap_slide_radio_button) - self.next_item_radio_button = QtGui.QRadioButton(self.slide_group_box) - self.next_item_radio_button.setObjectName(u'next_item_radio_button') - self.slide_layout.addWidget(self.next_item_radio_button) - self.rightLayout.addWidget(self.slide_group_box) - # Display Workarounds - self.display_workaround_group_box = QtGui.QGroupBox(self.leftColumn) - self.display_workaround_group_box.setObjectName(u'display_workaround_group_box') - self.display_workaround_layout = QtGui.QVBoxLayout(self.display_workaround_group_box) - self.display_workaround_layout.setObjectName(u'display_workaround_layout') - self.x11_bypass_check_box = QtGui.QCheckBox(self.display_workaround_group_box) - self.x11_bypass_check_box.setObjectName(u'x11_bypass_check_box') - self.display_workaround_layout.addWidget(self.x11_bypass_check_box) - self.alternate_rows_check_box = QtGui.QCheckBox(self.display_workaround_group_box) - self.alternate_rows_check_box.setObjectName(u'alternate_rows_check_box') - self.display_workaround_layout.addWidget(self.alternate_rows_check_box) - self.rightLayout.addWidget(self.display_workaround_group_box) - self.rightLayout.addStretch() - self.should_update_service_name_example = False - QtCore.QObject.connect(self.service_name_check_box, QtCore.SIGNAL(u'toggled(bool)'), - self.service_name_check_box_toggled) - QtCore.QObject.connect(self.service_name_day, QtCore.SIGNAL(u'currentIndexChanged(int)'), - self.on_service_name_day_changed) - QtCore.QObject.connect(self.service_name_time, QtCore.SIGNAL(u'timeChanged(QTime)'), - self.update_service_name_example) - QtCore.QObject.connect(self.service_name_edit, QtCore.SIGNAL(u'textChanged(QString)'), - self.update_service_name_example) - QtCore.QObject.connect(self.service_name_revert_button, QtCore.SIGNAL(u'clicked()'), - self.on_service_name_revert_button_clicked) - QtCore.QObject.connect(self.default_color_button, QtCore.SIGNAL(u'clicked()'), - self.on_default_color_button_clicked) - QtCore.QObject.connect(self.default_browse_button, QtCore.SIGNAL(u'clicked()'), - self.on_default_browse_button_clicked) - QtCore.QObject.connect(self.default_revert_button, QtCore.SIGNAL(u'clicked()'), - self.on_default_revert_button_clicked) - QtCore.QObject.connect(self.x11_bypass_check_box, QtCore.SIGNAL(u'toggled(bool)'), - self.on_X11_bypass_check_box_toggled) - QtCore.QObject.connect(self.alternate_rows_check_box,QtCore.SIGNAL(u'toggled(bool)'), - self.on_alternate_rows_check_box_toggled) - QtCore.QObject.connect(self.data_directory_browse_button, QtCore.SIGNAL(u'clicked()'), - self.on_data_directory_browse_button_clicked) - QtCore.QObject.connect(self.data_directory_default_button, QtCore.SIGNAL(u'clicked()'), - self.on_data_directory_default_button_clicked) - QtCore.QObject.connect(self.data_directory_cancel_button, QtCore.SIGNAL(u'clicked()'), - self.on_data_directory_cancel_button_clicked) - QtCore.QObject.connect(self.data_directory_copy_check_box, QtCore.SIGNAL(u'toggled(bool)'), - self.on_data_directory_copy_check_box_toggled) - QtCore.QObject.connect(self.end_slide_radio_button, QtCore.SIGNAL(u'clicked()'), - self.on_end_slide_button_clicked) - QtCore.QObject.connect(self.wrap_slide_radio_button, QtCore.SIGNAL(u'clicked()'), - self.on_wrap_slide_button_clicked) - QtCore.QObject.connect(self.next_item_radio_button, QtCore.SIGNAL(u'clicked()'), - self.on_next_item_button_clicked) - - - def retranslateUi(self): - """ - Setup the interface translation strings. - """ - self.tabTitleVisible = UiStrings().Advanced - self.ui_group_box.setTitle(translate('OpenLP.AdvancedTab', 'UI Settings')) - self.data_directory_group_box.setTitle(translate('OpenLP.AdvancedTab', 'Data Location')) - self.recent_label.setText(translate('OpenLP.AdvancedTab', 'Number of recent files to display:')) - self.media_plugin_check_box.setText(translate('OpenLP.AdvancedTab', - 'Remember active media manager tab on startup')) - self.double_click_live_check_box.setText(translate('OpenLP.AdvancedTab', - 'Double-click to send items straight to live')) - self.single_click_preview_check_box.setText(translate('OpenLP.AdvancedTab', - 'Preview items when clicked in Media Manager')) - self.expand_service_item_check_box.setText(translate('OpenLP.AdvancedTab', - 'Expand new service items on creation')) - self.enable_auto_close_check_box.setText(translate('OpenLP.AdvancedTab', - 'Enable application exit confirmation')) - self.service_name_group_box.setTitle(translate('OpenLP.AdvancedTab', 'Default Service Name')) - self.service_name_check_box.setText(translate('OpenLP.AdvancedTab', 'Enable default service name')) - self.service_name_time_label.setText(translate('OpenLP.AdvancedTab', 'Date and Time:')) - self.service_name_day.setItemText(0, translate('OpenLP.AdvancedTab', 'Monday')) - self.service_name_day.setItemText(1, translate('OpenLP.AdvancedTab', 'Tuesday')) - self.service_name_day.setItemText(2, translate('OpenLP.AdvancedTab', 'Wednesday')) - self.service_name_day.setItemText(3, translate('OpenLP.AdvancedTab', 'Thurdsday')) - self.service_name_day.setItemText(4, translate('OpenLP.AdvancedTab', 'Friday')) - self.service_name_day.setItemText(5, translate('OpenLP.AdvancedTab', 'Saturday')) - self.service_name_day.setItemText(6, translate('OpenLP.AdvancedTab', 'Sunday')) - self.service_name_day.setItemText(7, translate('OpenLP.AdvancedTab', 'Now')) - self.service_name_time.setToolTip(translate('OpenLP.AdvancedTab', - 'Time when usual service starts.')) - self.service_name_label.setText(translate('OpenLP.AdvancedTab', 'Name:')) - self.service_name_edit.setToolTip(translate('OpenLP.AdvancedTab', 'Consult the OpenLP manual for usage.')) - self.service_name_revert_button.setToolTip( - translate('OpenLP.AdvancedTab', 'Revert to the default service name "%s".') % - UiStrings().DefaultServiceName) - self.service_name_example_label.setText(translate('OpenLP.AdvancedTab', 'Example:')) - self.hide_mouse_group_box.setTitle(translate('OpenLP.AdvancedTab', 'Mouse Cursor')) - self.hide_mouse_check_box.setText(translate('OpenLP.AdvancedTab', 'Hide mouse cursor when over display window')) - self.default_image_group_box.setTitle(translate('OpenLP.AdvancedTab', 'Default Image')) - self.default_color_label.setText(translate('OpenLP.AdvancedTab', 'Background color:')) - self.default_color_button.setToolTip(translate('OpenLP.AdvancedTab', 'Click to select a color.')) - self.default_file_label.setText(translate('OpenLP.AdvancedTab', 'Image file:')) - self.default_browse_button.setToolTip(translate('OpenLP.AdvancedTab', 'Browse for an image file to display.')) - self.default_revert_button.setToolTip(translate('OpenLP.AdvancedTab', 'Revert to the default OpenLP logo.')) - self.data_directory_current_label.setText(translate('OpenLP.AdvancedTab', 'Current path:')) - self.data_directory_new_label.setText(translate('OpenLP.AdvancedTab', 'Custom path:')) - self.data_directory_browse_button.setToolTip(translate('OpenLP.AdvancedTab', - 'Browse for new data file location.')) - self.data_directory_default_button.setToolTip( - translate('OpenLP.AdvancedTab', 'Set the data location to the default.')) - self.data_directory_cancel_button.setText(translate('OpenLP.AdvancedTab', 'Cancel')) - self.data_directory_cancel_button.setToolTip( - translate('OpenLP.AdvancedTab', 'Cancel OpenLP data directory location change.')) - self.data_directory_copy_check_box.setText(translate('OpenLP.AdvancedTab', 'Copy data to new location.')) - self.data_directory_copy_check_box.setToolTip(translate( - 'OpenLP.AdvancedTab', 'Copy the OpenLP data files to the new location.')) - self.new_data_directory_has_files_label.setText( - translate('OpenLP.AdvancedTab', 'WARNING: New data directory location contains ' - 'OpenLP data files. These files WILL be replaced during a copy.')) - self.display_workaround_group_box.setTitle(translate('OpenLP.AdvancedTab', 'Display Workarounds')) - self.x11_bypass_check_box.setText(translate('OpenLP.AdvancedTab','Bypass X11 Window Manager')) - self.alternate_rows_check_box.setText(translate('OpenLP.AdvancedTab', 'Use alternating row colours in lists')) - # Slide Limits - self.slide_group_box.setTitle(translate('OpenLP.GeneralTab', 'Service Item Slide Limits')) - self.slide_label.setText(translate('OpenLP.GeneralTab', 'Behavior of next/previous on the last/first slide:')) - self.end_slide_radio_button.setText(translate('OpenLP.GeneralTab', '&Remain on Slide')) - self.wrap_slide_radio_button.setText(translate('OpenLP.GeneralTab', '&Wrap around')) - self.next_item_radio_button.setText(translate('OpenLP.GeneralTab', '&Move to next/previous service item')) - - def load(self): - """ - Load settings from disk. - """ - settings = Settings() - settings.beginGroup(self.settingsSection) - # The max recent files value does not have an interface and so never - # gets actually stored in the settings therefore the default value of - # 20 will always be used. - self.recent_spin_box.setMaximum(settings.value(u'max recent files')) - self.recent_spin_box.setValue(settings.value(u'recent file count')) - self.media_plugin_check_box.setChecked(settings.value(u'save current plugin')) - self.double_click_live_check_box.setChecked(settings.value(u'double click live')) - self.single_click_preview_check_box.setChecked(settings.value(u'single click preview')) - self.expand_service_item_check_box.setChecked(settings.value(u'expand service item')) - self.enable_auto_close_check_box.setChecked(settings.value(u'enable exit confirmation')) - self.hide_mouse_check_box.setChecked(settings.value(u'hide mouse')) - self.service_name_day.setCurrentIndex(settings.value(u'default service day')) - self.service_name_time.setTime(QtCore.QTime(settings.value(u'default service hour'), - settings.value(u'default service minute'))) - self.should_update_service_name_example = True - self.service_name_edit.setText(settings.value(u'default service name')) - default_service_enabled = settings.value(u'default service enabled') - self.service_name_check_box.setChecked(default_service_enabled) - self.service_name_check_box_toggled(default_service_enabled) - self.x11_bypass_check_box.setChecked(settings.value(u'x11 bypass wm')) - self.default_color = settings.value(u'default color') - self.default_file_edit.setText(settings.value(u'default image')) - self.slide_limits = settings.value(u'slide limits') - # Prevent the dialog displayed by the alternate_rows_check_box to display. - self.alternate_rows_check_box.blockSignals(True) - self.alternate_rows_check_box.setChecked(settings.value(u'alternate rows')) - self.alternate_rows_check_box.blockSignals(False) - if self.slide_limits == SlideLimits.End: - self.end_slide_radio_button.setChecked(True) - elif self.slide_limits == SlideLimits.Wrap: - self.wrap_slide_radio_button.setChecked(True) - else: - self.next_item_radio_button.setChecked(True) - settings.endGroup() - self.data_directory_copy_check_box.hide() - self.new_data_directory_has_files_label.hide() - self.data_directory_cancel_button.hide() - # Since data location can be changed, make sure the path is present. - self.current_data_path = AppLocation.get_data_path() - if not os.path.exists(self.current_data_path): - log.error(u'Data path not found %s' % self.current_data_path) - answer = QtGui.QMessageBox.critical(self, - translate('OpenLP.AdvancedTab', - 'Data Directory Error'), - translate('OpenLP.AdvancedTab', - 'OpenLP data directory was not found\n\n%s\n\n' - 'This data directory was previously changed from the OpenLP ' - 'default location. If the new location was on removable ' - 'media, that media needs to be made available.\n\n' - 'Click "No" to stop loading OpenLP. allowing you to fix ' - 'the the problem.\n\n' - 'Click "Yes" to reset the data directory to the default ' - 'location.').replace('%s', self.current_data_path), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), - QtGui.QMessageBox.No) - if answer == QtGui.QMessageBox.No: - log.info(u'User requested termination') - Receiver.send_message(u'cleanup') - sys.exit() - # Set data location to default. - settings.remove(u'advanced/data path') - self.current_data_path = AppLocation.get_data_path() - log.warning(u'User requested data path set to default %s' % self.current_data_path) - self.data_directory_label.setText(os.path.abspath(self.current_data_path)) - self.default_color_button.setStyleSheet(u'background-color: %s' % self.default_color) - # Don't allow data directory move if running portable. - if settings.value(u'advanced/is portable'): - self.data_directory_group_box.hide() - - def save(self): - """ - Save settings to disk. - """ - settings = Settings() - settings.beginGroup(self.settingsSection) - settings.setValue(u'default service enabled', self.service_name_check_box.isChecked()) - service_name = self.service_name_edit.text() - preset_is_valid = self.generate_service_name_example()[0] - if service_name == UiStrings().DefaultServiceName or not preset_is_valid: - settings.remove(u'default service name') - self.service_name_edit.setText(service_name) - else: - settings.setValue(u'default service name', service_name) - settings.setValue(u'default service day', self.service_name_day.currentIndex()) - settings.setValue(u'default service hour', self.service_name_time.time().hour()) - settings.setValue(u'default service minute', self.service_name_time.time().minute()) - settings.setValue(u'recent file count', self.recent_spin_box.value()) - settings.setValue(u'save current plugin', self.media_plugin_check_box.isChecked()) - settings.setValue(u'double click live', self.double_click_live_check_box.isChecked()) - settings.setValue(u'single click preview', self.single_click_preview_check_box.isChecked()) - settings.setValue(u'expand service item', self.expand_service_item_check_box.isChecked()) - settings.setValue(u'enable exit confirmation', self.enable_auto_close_check_box.isChecked()) - settings.setValue(u'hide mouse', self.hide_mouse_check_box.isChecked()) - settings.setValue(u'x11 bypass wm', self.x11_bypass_check_box.isChecked()) - settings.setValue(u'alternate rows', self.alternate_rows_check_box.isChecked()) - settings.setValue(u'default color', self.default_color) - settings.setValue(u'default image', self.default_file_edit.text()) - settings.setValue(u'slide limits', self.slide_limits) - settings.endGroup() - if self.display_changed: - Receiver.send_message(u'config_screen_changed') - self.display_changed = False - Receiver.send_message(u'slidecontroller_update_slide_limits') - - def cancel(self): - """ - Dialogue was cancelled, remove any pending data path change. - """ - self.on_data_directory_cancel_button_clicked() - SettingsTab.cancel(self) - - def service_name_check_box_toggled(self, default_service_enabled): - """ - Service Name options changed - """ - self.service_name_day.setEnabled(default_service_enabled) - time_enabled = default_service_enabled and self.service_name_day.currentIndex() is not 7 - self.service_name_time.setEnabled(time_enabled) - self.service_name_edit.setEnabled(default_service_enabled) - self.service_name_revert_button.setEnabled(default_service_enabled) - - def generate_service_name_example(self): - """ - Display an example of the template used - """ - preset_is_valid = True - if self.service_name_day.currentIndex() == 7: - local_time = datetime.now() - else: - now = datetime.now() - day_delta = self.service_name_day.currentIndex() - now.weekday() - if day_delta < 0: - day_delta += 7 - time = now + timedelta(days=day_delta) - local_time = time.replace( - hour=self.service_name_time.time().hour(), - minute=self.service_name_time.time().minute() - ) - try: - service_name_example = format_time(unicode(self.service_name_edit.text()), local_time) - except ValueError: - preset_is_valid = False - service_name_example = translate('OpenLP.AdvancedTab', 'Syntax error.') - return preset_is_valid, service_name_example - - def update_service_name_example(self, returned_value): - """ - Update the example service name. - """ - if not self.should_update_service_name_example: - return - name_example = self.generate_service_name_example()[1] - self.service_name_example.setText(name_example) - - def on_service_name_day_changed(self, service_day): - """ - React to the day of the service name changing. - """ - self.service_name_time.setEnabled(service_day is not 7) - self.update_service_name_example(None) - - def on_service_name_revert_button_clicked(self): - """ - Revert to the default service name. - """ - self.service_name_edit.setText(UiStrings().DefaultServiceName) - self.service_name_edit.setFocus() - - def on_default_color_button_clicked(self): - """ - Select the background colour of the default display screen. - """ - new_color = QtGui.QColorDialog.getColor( - QtGui.QColor(self.default_color), self) - if new_color.isValid(): - self.default_color = new_color.name() - self.default_color_button.setStyleSheet(u'background-color: %s' % self.default_color) - - def on_default_browse_button_clicked(self): - """ - Select an image for the default display screen. - """ - file_filters = u'%s;;%s (*.*) (*)' % (get_images_filter(), UiStrings().AllFiles) - filename = QtGui.QFileDialog.getOpenFileName(self, - translate('OpenLP.AdvancedTab', 'Open File'), '', file_filters) - if filename: - self.default_file_edit.setText(filename) - self.default_file_edit.setFocus() - - def on_data_directory_browse_button_clicked(self): - """ - Browse for a new data directory location. - """ - old_root_path = unicode(self.data_directory_label.text()) - # Get the new directory location. - new_data_path = QtGui.QFileDialog.getExistingDirectory( - self, translate('OpenLP.AdvancedTab', 'Select Data Directory Location'), old_root_path, - options=QtGui.QFileDialog.ShowDirsOnly) - # Set the new data path. - if new_data_path: - new_data_path = os.path.normpath(new_data_path) - if self.current_data_path.lower() == new_data_path.lower(): - self.on_data_directory_cancel_button_clicked() - return - else: - return - # Make sure they want to change the data. - answer = QtGui.QMessageBox.question(self, - translate('OpenLP.AdvancedTab', 'Confirm Data Directory Change'), - translate('OpenLP.AdvancedTab', 'Are you sure you want to change the location of the OpenLP ' - 'data directory to:\n\n%s\n\n ' - 'The data directory will be changed when OpenLP is closed.').replace('%s', new_data_path), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No) - if answer != QtGui.QMessageBox.Yes: - return - # Check if data already exists here. - self.check_data_overwrite(new_data_path) - # Save the new location. - Receiver.send_message(u'set_new_data_path', new_data_path) - self.new_data_directory_edit.setText(new_data_path) - self.data_directory_cancel_button.show() - - def on_data_directory_default_button_clicked(self): - """ - Re-set the data directory location to the 'default' location. - """ - new_data_path = AppLocation.get_directory(AppLocation.DataDir) - if self.current_data_path.lower() != new_data_path.lower(): - # Make sure they want to change the data location back to the - # default. - answer = QtGui.QMessageBox.question(self, - translate('OpenLP.AdvancedTab', 'Reset Data Directory'), - translate('OpenLP.AdvancedTab', 'Are you sure you want to change the location of the OpenLP ' - 'data directory to the default location?\n\nThis location will be used after OpenLP is closed.'), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No) - if answer != QtGui.QMessageBox.Yes: - return - self.check_data_overwrite(new_data_path) - # Save the new location. - Receiver.send_message(u'set_new_data_path', new_data_path) - self.new_data_directory_edit.setText(os.path.abspath(new_data_path)) - self.data_directory_cancel_button.show() - else: - # We cancel the change in case user changed their mind. - self.on_data_directory_cancel_button_clicked() - - def on_data_directory_copy_check_box_toggled(self): - """ - Copy existing data when you change your data directory. - """ - Receiver.send_message(u'set_copy_data', - self.data_directory_copy_check_box.isChecked()) - if self.data_exists: - if self.data_directory_copy_check_box.isChecked(): - self.new_data_directory_has_files_label.show() - else: - self.new_data_directory_has_files_label.hide() - - def check_data_overwrite(self, data_path ): - """ - Check if there's already data in the target directory. - """ - test_path = os.path.join(data_path, u'songs') - self.data_directory_copy_check_box.show() - if os.path.exists(test_path): - self.data_exists = True - # Check is they want to replace existing data. - answer = QtGui.QMessageBox.warning(self, - translate('OpenLP.AdvancedTab', 'Overwrite Existing Data'), - translate('OpenLP.AdvancedTab', 'WARNING: \n\nThe location you have selected \n\n%s\n\n' - 'appears to contain OpenLP data files. Do you wish to replace these files with the current data files?' - ).replace('%s', os.path.abspath(data_path,)), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No) - if answer == QtGui.QMessageBox.Yes: - self.data_directory_copy_check_box.setChecked(True) - self.new_data_directory_has_files_label.show() - else: - self.data_directory_copy_check_box.setChecked(False) - self.new_data_directory_has_files_label.hide() - else: - self.data_exists = False - self.data_directory_copy_check_box.setChecked(True) - self.new_data_directory_has_files_label.hide() - - def on_data_directory_cancel_button_clicked(self): - """ - Cancel the data directory location change - """ - self.new_data_directory_edit.clear() - self.data_directory_copy_check_box.setChecked(False) - Receiver.send_message(u'set_new_data_path', u'') - Receiver.send_message(u'set_copy_data', False) - self.data_directory_copy_check_box.hide() - self.data_directory_cancel_button.hide() - self.new_data_directory_has_files_label.hide() - - def on_default_revert_button_clicked(self): - """ - Revert the default screen back to the default settings. - """ - self.default_file_edit.setText(u':/graphics/openlp-splash-screen.png') - self.default_file_edit.setFocus() - - def on_X11_bypass_check_box_toggled(self, checked): - """ - Toggle X11 bypass flag on maindisplay depending on check box state. - - ``checked`` - The state of the check box (boolean). - """ - self.display_changed = True - - def on_alternate_rows_check_box_toggled(self, checked): - """ - Notify user about required restart. - - ``checked`` - The state of the check box (boolean). - """ - QtGui.QMessageBox.information(self, - translate('OpenLP.AdvancedTab', 'Restart Required'), - translate('OpenLP.AdvancedTab', 'This change will only take effect once OpenLP has been restarted.')) - - def on_end_slide_button_clicked(self): - """ - Stop at the end either top ot bottom - """ - self.slide_limits = SlideLimits.End - - def on_wrap_slide_button_clicked(self): - """ - Wrap round the service item - """ - self.slide_limits = SlideLimits.Wrap - - def on_next_item_button_clicked(self): - """ - Advance to the next service item - """ - self.slide_limits = SlideLimits.Next From b60cfba63f951af41851565e774ec86e168a56c4 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sun, 3 Feb 2013 15:35:20 +0200 Subject: [PATCH 42/64] Ignore some files that might appear at times. --- .bzrignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.bzrignore b/.bzrignore index ab4adde18..7084e1563 100644 --- a/.bzrignore +++ b/.bzrignore @@ -25,3 +25,5 @@ openlp.cfg openlp.pro .kdev4 tests.kdev4 +*.nja +*.orig From 12fc795c9c68d5932ec04619333699293f66bfaa Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sun, 3 Feb 2013 16:40:48 +0200 Subject: [PATCH 43/64] Fix up some issues caused by my refactor and some apparent merge conflict somewhere. --- openlp/core/__init__.py | 6 +- openlp/core/lib/plugin.py | 2 +- openlp/core/ui/firsttimeform.py | 8 +- openlp/core/ui/mainwindow.py | 120 +++++++++--------- openlp/core/ui/servicemanager.py | 10 +- openlp/plugins/bibles/bibleplugin.py | 4 +- .../custom/forms/editcustomslideform.py | 2 +- openlp/plugins/media/mediaplugin.py | 4 +- openlp/plugins/songs/songsplugin.py | 2 +- 9 files changed, 80 insertions(+), 78 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 0ff7cb838..831babcf5 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -92,8 +92,8 @@ class OpenLP(QtGui.QApplication): """ Override exec method to allow the shared memory to be released on exit """ - self.event_loop_is_active = True - result = QtGui.QApplication.exec_(self) + self.is_event_loop_active = True + result = QtGui.QApplication.exec_() self.shared_memory.detach() return result @@ -101,7 +101,7 @@ class OpenLP(QtGui.QApplication): """ Run the OpenLP application. """ - self.event_loop_is_active = False + self.is_event_loop_active = False # On Windows, the args passed into the constructor are ignored. Not # very handy, so set the ones we want to use. On Linux and FreeBSD, in # order to set the WM_CLASS property for X11, we pass "OpenLP" in as a diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 1d80435d9..0fd5ec2e3 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -295,7 +295,7 @@ class Plugin(QtCore.QObject): if self.mediaItem: self.main_window.mediaDockManager.remove_dock(self.mediaItem) - def appStartup(self): + def app_startup(self): """ Perform tasks on application startup """ diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 3ecf3167c..ca80b9f10 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -96,7 +96,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): files = self.webAccess.read() self.config.readfp(io.BytesIO(files)) self.updateScreenListCombo() - self.downloadCancelled = False + self.was_download_cancelled = False self.downloading = translate('OpenLP.FirstTimeWizard', 'Downloading %s...') QtCore.QObject.connect(self.cancelButton, QtCore.SIGNAL('clicked()'), self.onCancelButtonClicked) @@ -247,7 +247,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): (self.lastId <= FirstTimePage.Plugins and not self.hasRunWizard): QtCore.QCoreApplication.exit() sys.exit() - self.downloadCancelled = True + self.was_download_cancelled = True while self.themeScreenshotThread.isRunning(): time.sleep(0.1) Receiver.send_message(u'cursor_normal') @@ -273,7 +273,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): urlfile = urllib2.urlopen(url) filename = open(fpath, "wb") # Download until finished or canceled. - while not self.downloadCancelled: + while not self.was_download_cancelled: data = urlfile.read(block_size) if not data: break @@ -282,7 +282,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): self._downloadProgress(block_count, block_size) filename.close() # Delete file if cancelled, it may be a partial file. - if self.downloadCancelled: + if self.was_download_cancelled: os.remove(fpath) def _buildThemeScreenshots(self): diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 69409a540..5ab76f464 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -85,21 +85,21 @@ class Ui_MainWindow(object): """ This is the UI part of the main window. """ - def setupUi(self, mainWindow): + def setupUi(self, main_window): """ Set up the user interface """ - mainWindow.setObjectName(u'MainWindow') - mainWindow.setWindowIcon(build_icon(u':/icon/openlp-logo-64x64.png')) - mainWindow.setDockNestingEnabled(True) + main_window.setObjectName(u'MainWindow') + main_window.setWindowIcon(build_icon(u':/icon/openlp-logo-64x64.png')) + main_window.setDockNestingEnabled(True) # Set up the main container, which contains all the other form widgets. - self.mainContent = QtGui.QWidget(mainWindow) + self.mainContent = QtGui.QWidget(main_window) self.mainContent.setObjectName(u'mainContent') self.mainContentLayout = QtGui.QHBoxLayout(self.mainContent) self.mainContentLayout.setSpacing(0) self.mainContentLayout.setMargin(0) self.mainContentLayout.setObjectName(u'mainContentLayout') - mainWindow.setCentralWidget(self.mainContent) + main_window.setCentralWidget(self.mainContent) self.controlSplitter = QtGui.QSplitter(self.mainContent) self.controlSplitter.setOrientation(QtCore.Qt.Horizontal) self.controlSplitter.setObjectName(u'controlSplitter') @@ -113,7 +113,7 @@ class Ui_MainWindow(object): panelLocked = Settings().value(u'user interface/lock panel') self.liveController.panel.setVisible(liveVisible) # Create menu - self.menuBar = QtGui.QMenuBar(mainWindow) + self.menuBar = QtGui.QMenuBar(main_window) self.menuBar.setObjectName(u'menuBar') self.fileMenu = QtGui.QMenu(self.menuBar) self.fileMenu.setObjectName(u'fileMenu') @@ -139,10 +139,10 @@ class Ui_MainWindow(object): # Help Menu self.helpMenu = QtGui.QMenu(self.menuBar) self.helpMenu.setObjectName(u'helpMenu') - mainWindow.setMenuBar(self.menuBar) - self.statusBar = QtGui.QStatusBar(mainWindow) + main_window.setMenuBar(self.menuBar) + self.statusBar = QtGui.QStatusBar(main_window) self.statusBar.setObjectName(u'statusBar') - mainWindow.setStatusBar(self.statusBar) + main_window.setStatusBar(self.statusBar) self.loadProgressBar = QtGui.QProgressBar(self.statusBar) self.loadProgressBar.setObjectName(u'loadProgressBar') self.statusBar.addPermanentWidget(self.loadProgressBar) @@ -153,142 +153,142 @@ class Ui_MainWindow(object): self.defaultThemeLabel.setObjectName(u'defaultThemeLabel') self.statusBar.addPermanentWidget(self.defaultThemeLabel) # Create the MediaManager - self.mediaManagerDock = OpenLPDockWidget(mainWindow, u'mediaManagerDock', u':/system/system_mediamanager.png') + self.mediaManagerDock = OpenLPDockWidget(main_window, u'mediaManagerDock', u':/system/system_mediamanager.png') self.mediaManagerDock.setStyleSheet(MEDIA_MANAGER_STYLE) # Create the media toolbox self.mediaToolBox = QtGui.QToolBox(self.mediaManagerDock) self.mediaToolBox.setObjectName(u'mediaToolBox') self.mediaManagerDock.setWidget(self.mediaToolBox) - mainWindow.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self.mediaManagerDock) + main_window.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self.mediaManagerDock) # Create the service manager - self.serviceManagerDock = OpenLPDockWidget(mainWindow, u'serviceManagerDock', + self.serviceManagerDock = OpenLPDockWidget(main_window, u'serviceManagerDock', u':/system/system_servicemanager.png') self.serviceManagerContents = ServiceManager(self.serviceManagerDock) self.serviceManagerDock.setWidget(self.serviceManagerContents) - mainWindow.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.serviceManagerDock) + main_window.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.serviceManagerDock) # Create the theme manager - self.themeManagerDock = OpenLPDockWidget(mainWindow, u'themeManagerDock', u':/system/system_thememanager.png') + self.themeManagerDock = OpenLPDockWidget(main_window, u'themeManagerDock', u':/system/system_thememanager.png') self.themeManagerContents = ThemeManager(self.themeManagerDock) self.themeManagerContents.setObjectName(u'themeManagerContents') self.themeManagerDock.setWidget(self.themeManagerContents) - mainWindow.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.themeManagerDock) + main_window.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.themeManagerDock) # Create the menu items action_list = ActionList.get_instance() action_list.add_category(UiStrings().File, CategoryOrder.standardMenu) - self.fileNewItem = create_action(mainWindow, u'fileNewItem', + self.fileNewItem = create_action(main_window, u'fileNewItem', icon=u':/general/general_new.png', shortcuts=[QtGui.QKeySequence(u'Ctrl+N')], category=UiStrings().File, triggers=self.serviceManagerContents.on_new_service_clicked) - self.fileOpenItem = create_action(mainWindow, u'fileOpenItem', + self.fileOpenItem = create_action(main_window, u'fileOpenItem', icon=u':/general/general_open.png', shortcuts=[QtGui.QKeySequence(u'Ctrl+O')], category=UiStrings().File, triggers=self.serviceManagerContents.on_load_service_clicked) - self.fileSaveItem = create_action(mainWindow, u'fileSaveItem', + self.fileSaveItem = create_action(main_window, u'fileSaveItem', icon=u':/general/general_save.png', shortcuts=[QtGui.QKeySequence(u'Ctrl+S')], category=UiStrings().File, triggers=self.serviceManagerContents.save_file) - self.fileSaveAsItem = create_action(mainWindow, u'fileSaveAsItem', + self.fileSaveAsItem = create_action(main_window, u'fileSaveAsItem', shortcuts=[QtGui.QKeySequence(u'Ctrl+Shift+S')], category=UiStrings().File, triggers=self.serviceManagerContents.save_file_as) - self.printServiceOrderItem = create_action(mainWindow, + self.printServiceOrderItem = create_action(main_window, u'printServiceItem', shortcuts=[QtGui.QKeySequence(u'Ctrl+P')], category=UiStrings().File, triggers=self.serviceManagerContents.print_service_order) - self.fileExitItem = create_action(mainWindow, u'fileExitItem', + self.fileExitItem = create_action(main_window, u'fileExitItem', icon=u':/system/system_exit.png', shortcuts=[QtGui.QKeySequence(u'Alt+F4')], - category=UiStrings().File, triggers=mainWindow.close) + category=UiStrings().File, triggers=main_window.close) # Give QT Extra Hint that this is the Exit Menu Item self.fileExitItem.setMenuRole(QtGui.QAction.QuitRole) action_list.add_category(UiStrings().Import, CategoryOrder.standardMenu) - self.importThemeItem = create_action(mainWindow, u'importThemeItem', category=UiStrings().Import) - self.importLanguageItem = create_action(mainWindow, u'importLanguageItem') + self.importThemeItem = create_action(main_window, u'importThemeItem', category=UiStrings().Import) + self.importLanguageItem = create_action(main_window, u'importLanguageItem') action_list.add_category(UiStrings().Export, CategoryOrder.standardMenu) - self.exportThemeItem = create_action(mainWindow, u'exportThemeItem', category=UiStrings().Export) - self.exportLanguageItem = create_action(mainWindow, u'exportLanguageItem') + self.exportThemeItem = create_action(main_window, u'exportThemeItem', category=UiStrings().Export) + self.exportLanguageItem = create_action(main_window, u'exportLanguageItem') action_list.add_category(UiStrings().View, CategoryOrder.standardMenu) - self.viewMediaManagerItem = create_action(mainWindow, + self.viewMediaManagerItem = create_action(main_window, u'viewMediaManagerItem', shortcuts=[QtGui.QKeySequence(u'F8')], icon=u':/system/system_mediamanager.png', checked=self.mediaManagerDock.isVisible(), category=UiStrings().View, triggers=self.toggleMediaManager) - self.viewThemeManagerItem = create_action(mainWindow, + self.viewThemeManagerItem = create_action(main_window, u'viewThemeManagerItem', shortcuts=[QtGui.QKeySequence(u'F10')], icon=u':/system/system_thememanager.png', checked=self.themeManagerDock.isVisible(), category=UiStrings().View, triggers=self.toggleThemeManager) - self.viewServiceManagerItem = create_action(mainWindow, + self.viewServiceManagerItem = create_action(main_window, u'viewServiceManagerItem', shortcuts=[QtGui.QKeySequence(u'F9')], icon=u':/system/system_servicemanager.png', checked=self.serviceManagerDock.isVisible(), category=UiStrings().View, triggers=self.toggleServiceManager) - self.viewPreviewPanel = create_action(mainWindow, u'viewPreviewPanel', + self.viewPreviewPanel = create_action(main_window, u'viewPreviewPanel', shortcuts=[QtGui.QKeySequence(u'F11')], checked=previewVisible, category=UiStrings().View, triggers=self.setPreviewPanelVisibility) - self.viewLivePanel = create_action(mainWindow, u'viewLivePanel', + self.viewLivePanel = create_action(main_window, u'viewLivePanel', shortcuts=[QtGui.QKeySequence(u'F12')], checked=liveVisible, category=UiStrings().View, triggers=self.setLivePanelVisibility) - self.lockPanel = create_action(mainWindow, u'lockPanel', + self.lockPanel = create_action(main_window, u'lockPanel', checked=panelLocked, triggers=self.setLockPanel) action_list.add_category(UiStrings().ViewMode, CategoryOrder.standardMenu) - self.modeDefaultItem = create_action(mainWindow, u'modeDefaultItem', checked=False, + self.modeDefaultItem = create_action(main_window, u'modeDefaultItem', checked=False, category=UiStrings().ViewMode) - self.modeSetupItem = create_action(mainWindow, u'modeSetupItem', checked=False, category=UiStrings().ViewMode) - self.modeLiveItem = create_action(mainWindow, u'modeLiveItem', checked=True, category=UiStrings().ViewMode) - self.modeGroup = QtGui.QActionGroup(mainWindow) + self.modeSetupItem = create_action(main_window, u'modeSetupItem', checked=False, category=UiStrings().ViewMode) + self.modeLiveItem = create_action(main_window, u'modeLiveItem', checked=True, category=UiStrings().ViewMode) + self.modeGroup = QtGui.QActionGroup(main_window) self.modeGroup.addAction(self.modeDefaultItem) self.modeGroup.addAction(self.modeSetupItem) self.modeGroup.addAction(self.modeLiveItem) self.modeDefaultItem.setChecked(True) action_list.add_category(UiStrings().Tools, CategoryOrder.standardMenu) - self.toolsAddToolItem = create_action(mainWindow, + self.toolsAddToolItem = create_action(main_window, u'toolsAddToolItem', icon=u':/tools/tools_add.png', category=UiStrings().Tools) - self.toolsOpenDataFolder = create_action(mainWindow, + self.toolsOpenDataFolder = create_action(main_window, u'toolsOpenDataFolder', icon=u':/general/general_open.png', category=UiStrings().Tools) - self.toolsFirstTimeWizard = create_action(mainWindow, + self.toolsFirstTimeWizard = create_action(main_window, u'toolsFirstTimeWizard', icon=u':/general/general_revert.png', category=UiStrings().Tools) - self.updateThemeImages = create_action(mainWindow, + self.updateThemeImages = create_action(main_window, u'updateThemeImages', category=UiStrings().Tools) action_list.add_category(UiStrings().Settings, CategoryOrder.standardMenu) - self.settingsPluginListItem = create_action(mainWindow, + self.settingsPluginListItem = create_action(main_window, u'settingsPluginListItem', icon=u':/system/settings_plugin_list.png', shortcuts=[QtGui.QKeySequence(u'Alt+F7')], category=UiStrings().Settings, triggers=self.onPluginItemClicked) # i18n Language Items - self.autoLanguageItem = create_action(mainWindow, u'autoLanguageItem', + self.autoLanguageItem = create_action(main_window, u'autoLanguageItem', checked=LanguageManager.auto_language) - self.languageGroup = QtGui.QActionGroup(mainWindow) + self.languageGroup = QtGui.QActionGroup(main_window) self.languageGroup.setExclusive(True) self.languageGroup.setObjectName(u'languageGroup') add_actions(self.languageGroup, [self.autoLanguageItem]) qmList = LanguageManager.get_qm_list() savedLanguage = LanguageManager.get_language() for key in sorted(qmList.keys()): - languageItem = create_action(mainWindow, key, checked=qmList[key] == savedLanguage) + languageItem = create_action(main_window, key, checked=qmList[key] == savedLanguage) add_actions(self.languageGroup, [languageItem]) - self.settingsShortcutsItem = create_action(mainWindow, u'settingsShortcutsItem', + self.settingsShortcutsItem = create_action(main_window, u'settingsShortcutsItem', icon=u':/system/system_configure_shortcuts.png', category=UiStrings().Settings) # Formatting Tags were also known as display tags. - self.formattingTagItem = create_action(mainWindow, u'displayTagItem', + self.formattingTagItem = create_action(main_window, u'displayTagItem', icon=u':/system/tag_editor.png', category=UiStrings().Settings) - self.settingsConfigureItem = create_action(mainWindow, u'settingsConfigureItem', + self.settingsConfigureItem = create_action(main_window, u'settingsConfigureItem', icon=u':/system/system_settings.png', category=UiStrings().Settings) # Give QT Extra Hint that this is the Preferences Menu Item self.settingsConfigureItem.setMenuRole(QtGui.QAction.PreferencesRole) - self.settingsImportItem = create_action(mainWindow, u'settingsImportItem', category=UiStrings().Settings) - self.settingsExportItem = create_action(mainWindow, u'settingsExportItem', category=UiStrings().Settings) + self.settingsImportItem = create_action(main_window, u'settingsImportItem', category=UiStrings().Settings) + self.settingsExportItem = create_action(main_window, u'settingsExportItem', category=UiStrings().Settings) action_list.add_category(UiStrings().Help, CategoryOrder.standardMenu) - self.aboutItem = create_action(mainWindow, u'aboutItem', icon=u':/system/system_about.png', + self.aboutItem = create_action(main_window, u'aboutItem', icon=u':/system/system_about.png', shortcuts=[QtGui.QKeySequence(u'Ctrl+F1')], category=UiStrings().Help, triggers=self.onAboutItemClicked) # Give QT Extra Hint that this is an About Menu Item @@ -296,15 +296,15 @@ class Ui_MainWindow(object): if os.name == u'nt': self.localHelpFile = os.path.join( AppLocation.get_directory(AppLocation.AppDir), 'OpenLP.chm') - self.offlineHelpItem = create_action(mainWindow, u'offlineHelpItem', + self.offlineHelpItem = create_action(main_window, u'offlineHelpItem', icon=u':/system/system_help_contents.png', shortcuts=[QtGui.QKeySequence(u'F1')], category=UiStrings().Help, triggers=self.onOfflineHelpClicked) - self.onlineHelpItem = create_action(mainWindow, u'onlineHelpItem', + self.onlineHelpItem = create_action(main_window, u'onlineHelpItem', icon=u':/system/system_online_help.png', shortcuts=[QtGui.QKeySequence(u'Alt+F1')], category=UiStrings().Help, triggers=self.onOnlineHelpClicked) - self.webSiteItem = create_action(mainWindow, u'webSiteItem', category=UiStrings().Help) + self.webSiteItem = create_action(main_window, u'webSiteItem', category=UiStrings().Help) add_actions(self.fileImportMenu, (self.settingsImportItem, None, self.importThemeItem, self.importLanguageItem)) add_actions(self.fileExportMenu, (self.settingsExportItem, None, self.exportThemeItem, self.exportLanguageItem)) add_actions(self.fileMenu, (self.fileNewItem, self.fileOpenItem, @@ -338,7 +338,7 @@ class Ui_MainWindow(object): add_actions(self.menuBar, (self.fileMenu.menuAction(), self.viewMenu.menuAction(), self.toolsMenu.menuAction(), self.settingsMenu.menuAction(), self.helpMenu.menuAction())) # Initialise the translation - self.retranslateUi(mainWindow) + self.retranslateUi(main_window) self.mediaToolBox.setCurrentIndex(0) # Connect up some signals and slots QtCore.QObject.connect(self.fileMenu, QtCore.SIGNAL(u'aboutToShow()'), self.updateRecentFilesMenu) @@ -660,7 +660,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ Receiver.send_message(u'openlp_process_events') for plugin in self.pluginManager.plugins: - if hasattr(plugin, u'firstTime'): + if hasattr(plugin, u'first_time'): Receiver.send_message(u'openlp_process_events') plugin.first_time() Receiver.send_message(u'openlp_process_events') @@ -686,9 +686,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): return Receiver.send_message(u'cursor_busy') screens = ScreenList() - firstTime = FirstTimeForm(screens, self) - firstTime.exec_() - if firstTime.downloadCancelled: + first_run_wizard = FirstTimeForm(screens, self) + first_run_wizard.exec_() + if first_run_wizard.was_download_cancelled: return self.first_time() for plugin in self.pluginManager.plugins: @@ -1018,7 +1018,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ # The MainApplication did not even enter the event loop (this happens # when OpenLP is not fully loaded). Just ignore the event. - if not self.application.eventLoopIsActive: + if not self.application.is_event_loop_active: event.ignore() return # If we just did a settings import, close without saving changes. diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 0ddebe1f8..fb4c7e84e 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -417,10 +417,12 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): elif result == QtGui.QMessageBox.Save: self.decide_save_method() if not load_file: - file_name = QtGui.QFileDialog.getOpenfile_name(self.main_window, + file_name = QtGui.QFileDialog.getOpenFileName( + self.main_window, translate('OpenLP.ServiceManager', 'Open File'), - SettingsManager.get_last_dir(self.main_window.serviceManagerSettingsSection), - translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz *.oszl)')) + Settings().value(self.main_window.serviceManagerSettingsSection + u'/last directory'), + translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz *.oszl)') + ) if not file_name: return False else: @@ -1627,4 +1629,4 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): self._main_window = Registry().get(u'main_window') return self._main_window - main_window = property(_get_main_window) \ No newline at end of file + main_window = property(_get_main_window) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index d24858db5..9a584dc63 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -102,11 +102,11 @@ class BiblePlugin(Plugin): #action_list.remove_action(self.exportBibleItem, UiStrings().Export) self.exportBibleItem.setVisible(False) - def appStartup(self): + def app_startup(self): """ Perform tasks on application startup """ - Plugin.appStartup(self) + Plugin.app_startup(self) if self.manager.old_bible_databases: if QtGui.QMessageBox.information(self.main_window, translate('OpenLP', 'Information'), diff --git a/openlp/plugins/custom/forms/editcustomslideform.py b/openlp/plugins/custom/forms/editcustomslideform.py index 755237345..7e489317a 100644 --- a/openlp/plugins/custom/forms/editcustomslideform.py +++ b/openlp/plugins/custom/forms/editcustomslideform.py @@ -47,7 +47,7 @@ class EditCustomSlideForm(QtGui.QDialog, Ui_CustomSlideEditDialog): """ Constructor """ - super(EditCustomeEditCustomSlideForm, self).__init__(parent) + super(EditCustomSlideForm, self).__init__(parent) self.setupUi(self) # Connecting signals and slots QtCore.QObject.connect(self.insertButton, QtCore.SIGNAL(u'clicked()'), self.onInsertButtonClicked) diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index d93f120ec..2a1fcf112 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -118,13 +118,13 @@ class MediaPlugin(Plugin): """ return self.media_controller.get_media_display_html() - def appStartup(self): + def app_startup(self): """ Do a couple of things when the app starts up. In this particular case we want to check if we have the old "Use Phonon" setting, and convert it to "enable Phonon" and "make it the first one in the list". """ - Plugin.appStartup(self) + Plugin.app_startup(self) settings = Settings() settings.beginGroup(self.settingsSection) if settings.contains(u'use phonon'): diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 4f57d3e21..5285efafc 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -239,7 +239,7 @@ class SongsPlugin(Plugin): } self.setPluginUiTextStrings(tooltips) - def firstTime(self): + def first_time(self): """ If the first time wizard has run, this function is run to import all the new songs into the database. From 123f460f7ee7d7062da4255d92bcf5b61af8025c Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 3 Feb 2013 15:06:17 +0000 Subject: [PATCH 44/64] Fix up Receiver code changes --- openlp/core/__init__.py | 23 +++------ openlp/core/ui/maindisplay.py | 2 +- openlp/core/ui/mainwindow.py | 49 ++++++++++--------- openlp/core/ui/servicemanager.py | 9 ++-- openlp/plugins/bibles/lib/http.py | 4 +- openlp/plugins/images/lib/mediaitem.py | 2 +- openlp/plugins/presentations/lib/mediaitem.py | 2 +- 7 files changed, 41 insertions(+), 50 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 211a02fef..d9f99ad7c 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -96,7 +96,7 @@ class OpenLP(QtGui.QApplication): QtGui.QApplication.exec_() self.sharedMemory.detach() - def run(self, args, testing=False): + def run(self, args): """ Run the OpenLP application. """ @@ -150,10 +150,8 @@ class OpenLP(QtGui.QApplication): if update_check: VersionThread(self.mainWindow).start() Receiver.send_message(u'live_display_blank_check') - self.mainWindow.appStartup() - # Skip exec_() for gui tests - if not testing: - return self.exec_() + self.mainWindow.app_startup() + return self.exec_() def isAlreadyRunning(self): """ @@ -244,7 +242,6 @@ def main(args=None): parser.add_option('-d', '--dev-version', dest='dev_version', action='store_true', help='Ignore the version file and pull the version directly from Bazaar') parser.add_option('-s', '--style', dest='style', help='Set the Qt4 style (passed directly to Qt4).') - parser.add_option('--testing', dest='testing', action='store_true', help='Run by testing framework') # Parse command line options and deal with them. # Use args supplied programatically if possible. (options, args) = parser.parse_args(args) if args else parser.parse_args() @@ -294,10 +291,8 @@ def main(args=None): Registry().register(u'openlp_core', app) app.setApplicationVersion(get_application_version()[u'version']) # Instance check - if not options.testing: - # Instance check - if app.isAlreadyRunning(): - sys.exit() + if app.isAlreadyRunning(): + sys.exit() # First time checks in settings if not Settings().value(u'general/has run wizard'): if not FirstTimeLanguageForm().exec_(): @@ -314,10 +309,4 @@ def main(args=None): log.debug(u'Could not find default_translator.') if not options.no_error_form: sys.excepthook = app.hookException - # Do not run method app.exec_() when running gui tests - if options.testing: - app.run(qt_args, testing=True) - # For gui tests we need access to window instances and their components - return app - else: - sys.exit(app.run(qt_args)) + sys.exit(app.run(qt_args)) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index a8e22db22..b33e96fe4 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -486,7 +486,7 @@ class MainDisplay(Display): return self._image_manager image_manager = property(_get_image_manager) - + def _get_openlp_core(self): """ Adds the openlp to the class dynamically diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 564542db7..a0da951fa 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -481,7 +481,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.recentFiles = [] # Set up the path with plugins plugin_path = AppLocation.get_directory(AppLocation.PluginsDir) - self.pluginManager = PluginManager(plugin_path) + self.plugin_manager = PluginManager(plugin_path) self.imageManager = ImageManager() # Set up the interface self.setupUi(self) @@ -546,25 +546,25 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # Define the media Dock Manager self.mediaDockManager = MediaDockManager(self.mediaToolBox) log.info(u'Load Plugins') - self.pluginManager.find_plugins(plugin_path) + self.plugin_manager.find_plugins(plugin_path) # hook methods have to happen after find_plugins. Find plugins needs # the controllers hence the hooks have moved from setupUI() to here # Find and insert settings tabs log.info(u'hook settings') - self.pluginManager.hook_settings_tabs(self.settingsForm) + self.plugin_manager.hook_settings_tabs(self.settingsForm) # Find and insert media manager items log.info(u'hook media') - self.pluginManager.hook_media_manager() + self.plugin_manager.hook_media_manager() # Call the hook method to pull in import menus. log.info(u'hook menus') - self.pluginManager.hook_import_menu(self.fileImportMenu) + self.plugin_manager.hook_import_menu(self.fileImportMenu) # Call the hook method to pull in export menus. - self.pluginManager.hook_export_menu(self.fileExportMenu) + self.plugin_manager.hook_export_menu(self.fileExportMenu) # Call the hook method to pull in tools menus. - self.pluginManager.hook_tools_menu(self.toolsMenu) + self.plugin_manager.hook_tools_menu(self.toolsMenu) # Call the initialise method to setup plugins. log.info(u'initialise plugins') - self.pluginManager.initialise_plugins() + self.plugin_manager.initialise_plugins() # Create the displays as all necessary components are loaded. self.previewController.screenSizeChanged() self.liveController.screenSizeChanged() @@ -580,7 +580,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # Hide/show the theme combobox on the service manager self.serviceManagerContents.theme_change() # Reset the cursor - self.openlp_core.set_busy_cursor() + self.openlp_core.set_normal_cursor() def setAutoLanguage(self, value): self.languageGroup.setDisabled(value) @@ -631,12 +631,12 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.setViewMode(False, True, False, False, True) self.modeLiveItem.setChecked(True) - def appStartup(self): + def app_startup(self): """ Give all the plugins a chance to perform some tasks at startup """ self.openlp_core.process_events() - for plugin in self.pluginManager.plugins: + for plugin in self.plugin_manager.plugins: if plugin.isActive(): plugin.appStartup() self.openlp_core.process_events() @@ -644,7 +644,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def firstTime(self): # Import themes if first time self.openlp_core.process_events() - for plugin in self.pluginManager.plugins: + for plugin in self.plugin_manager.plugins: if hasattr(plugin, u'firstTime'): self.openlp_core.process_events() plugin.firstTime() @@ -669,14 +669,14 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtGui.QMessageBox.No) if answer == QtGui.QMessageBox.No: return - self.openlp_core.set_busy_cursor() screens = ScreenList() - firstTime = FirstTimeForm(screens, self) - firstTime.exec_() - if firstTime.downloadCancelled: + first_time = FirstTimeForm(screens, self) + first_time.exec_() + if first_time.downloadCancelled: return - self.firstTime() - for plugin in self.pluginManager.plugins: + self.openlp_core.set_busy_cursor() + self.first_time() + for plugin in self.plugin_manager.plugins: self.activePlugin = plugin oldStatus = self.activePlugin.status self.activePlugin.setStatus() @@ -692,6 +692,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # Check if any Bibles downloaded. If there are, they will be # processed. Receiver.send_message(u'bibles_load_list', True) + self.openlp_core.set_normal_cursor() def blankCheck(self): """ @@ -817,7 +818,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): setting_sections.extend([self.headerSection]) setting_sections.extend([u'crashreport']) # Add plugin sections. - for plugin in self.pluginManager.plugins: + for plugin in self.plugin_manager.plugins: setting_sections.extend([plugin.name]) settings = Settings() import_settings = Settings(import_file_name, Settings.IniFormat) @@ -894,7 +895,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): setting_sections.extend([self.themesSettingsSection]) setting_sections.extend([self.displayTagsSection]) # Add plugin sections. - for plugin in self.pluginManager.plugins: + for plugin in self.plugin_manager.plugins: setting_sections.extend([plugin.name]) # Delete old files if found. if os.path.exists(temp_file): @@ -986,7 +987,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.liveController.screenSizeChanged() self.setFocus() self.activateWindow() - self.openlp_core.set_busy_cursor() + self.openlp_core.set_normal_cursor() def closeEvent(self, event): """ @@ -1046,7 +1047,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Settings().setValue(u'advanced/current media plugin', self.mediaToolBox.currentIndex()) # Call the cleanup method to shutdown plugins. log.info(u'cleanup plugins') - self.pluginManager.finalise_plugins() + self.plugin_manager.finalise_plugins() if save_settings: # Save settings self.saveSettings() @@ -1304,16 +1305,17 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): log.info(u'Changing data path to %s' % self.newDataPath ) old_data_path = unicode(AppLocation.get_data_path()) # Copy OpenLP data to new location if requested. + self.openlp_core.set_busy_cursor() if self.copyData: log.info(u'Copying data to new path') try: - self.openlp_core.set_busy_cursor() self.showStatusMessage( translate('OpenLP.MainWindow', 'Copying OpenLP data to new data directory location - %s ' '- Please wait for copy to finish').replace('%s', self.newDataPath)) dir_util.copy_tree(old_data_path, self.newDataPath) log.info(u'Copy sucessful') except (IOError, os.error, DistutilsFileError), why: + print "A5" self.openlp_core.set_normal_cursor() log.exception(u'Data copy failed %s' % unicode(why)) QtGui.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'New Data Directory Error'), @@ -1329,6 +1331,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # Check if the new data path is our default. if self.newDataPath == AppLocation.get_directory(AppLocation.DataDir): settings.remove(u'advanced/data path') + self.openlp_core.set_normal_cursor() def _get_openlp_core(self): """ diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index eb354a9c5..edf1cd902 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -401,9 +401,9 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): elif result == QtGui.QMessageBox.Save: self.decide_save_method() if not load_file: - file_name = QtGui.QFileDialog.getOpenfile_name(self.main_window, + file_name = QtGui.QFileDialog.getOpenFileName(self.main_window, translate('OpenLP.ServiceManager', 'Open File'), - SettingsManager.get_last_dir(self.main_window.serviceManagerSettingsSection), + Settings().value(self.main_window.serviceManagerSettingsSection + u'/last directory'), translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz *.oszl)')) if not file_name: return False @@ -494,7 +494,6 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): if answer == QtGui.QMessageBox.Cancel: self.main_window.finishedProgressBar() return False - self.openlp_core.set_busy_cursor() # Check if item contains a missing file. for item in list(self.service_items): self.main_window.incrementProgressBar() @@ -690,6 +689,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): return False zip_file = None file_to = None + self.openlp_core.set_busy_cursor() try: zip_file = zipfile.ZipFile(file_name) for zip_info in zip_file.infolist(): @@ -710,7 +710,6 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): if osfile.endswith(u'osd'): p_file = os.path.join(self.servicePath, osfile) if 'p_file' in locals(): - self.openlp_core.set_busy_cursor() file_to = open(p_file, u'r') items = cPickle.load(file_to) file_to.close() @@ -940,7 +939,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): def preview_live(self, unique_identifier, row): """ Called by the SlideController to request a preview item be made live - and allows the next preview to be updated if relevant + and allows the next preview to be updated if relevant. ``unique_identifier`` diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 522dd08c3..f26b74b14 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -611,7 +611,7 @@ class HTTPBible(BibleDB): self.create_chapter(db_book.id, search_results.chapter, search_results.verselist) self.openlp_core.process_events() - self.openlp_core.set_normal_cursor() + self.openlp_core.set_normal_cursor() self.openlp_core.process_events() return BibleDB.get_verses(self, reference_list, show_error) @@ -707,10 +707,10 @@ def get_soup_for_bible_ref(reference_url, header=None, pre_parse_regex=None, soup = BeautifulSoup(page_source) except HTMLParseError: log.exception(u'BeautifulSoup could not parse the bible page.') - Registry().get(u'openlp_core').process_events() if not soup: send_error_message(u'parse') return None + Registry().get(u'openlp_core').process_events() return soup def send_error_message(error_type): diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 7af23b0ec..bc93bf80f 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -138,7 +138,7 @@ class ImageMediaItem(MediaManagerItem): self.main_window.incrementProgressBar() if not initialLoad: self.main_window.finishedProgressBar() - self.openlp_core.set_busy_cursor() + self.openlp_core.set_normal_cursor() def generateSlideData(self, service_item, item=None, xmlVersion=False, remote=False, context=ServiceItemContext.Service): diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index ab7659a2b..df772ce5b 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -207,7 +207,7 @@ class PresentationMediaItem(MediaManagerItem): self.listView.addItem(item_name) if not initialLoad: self.main_window.finishedProgressBar() - self.openlp_core.set_busy_cursor() + self.openlp_core.set_normal_cursor() def onDeleteClick(self): """ From 084da9c1bd5b27d29fbdfcb1483eff18ca611855 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 3 Feb 2013 16:44:03 +0000 Subject: [PATCH 45/64] Minor fixes --- openlp/core/__init__.py | 4 ++-- openlp/core/ui/media/mediaplayer.py | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index a750feb1f..18c5c6648 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -305,7 +305,7 @@ def main(args=None): Registry().register(u'openlp_core', app) app.setApplicationVersion(get_application_version()[u'version']) # Instance check - if app.isAlreadyRunning(): + if app.is_already_running(): sys.exit() # First time checks in settings if not Settings().value(u'general/has run wizard'): @@ -322,6 +322,6 @@ def main(args=None): else: log.debug(u'Could not find default_translator.') if not options.no_error_form: - sys.excepthook = app.hookException + sys.excepthook = app.hook_exception sys.exit(app.run(qt_args)) diff --git a/openlp/core/ui/media/mediaplayer.py b/openlp/core/ui/media/mediaplayer.py index 08909c013..61550acfc 100644 --- a/openlp/core/ui/media/mediaplayer.py +++ b/openlp/core/ui/media/mediaplayer.py @@ -26,14 +26,10 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -<<<<<<< TREE - -from openlp.core.lib import Registry -======= """ The :mod:`~openlp.core.ui.media.mediaplayer` module contains the MediaPlayer class. """ ->>>>>>> MERGE-SOURCE +from openlp.core.lib import Registry from openlp.core.ui.media import MediaState From ad438ba4b2056a96e5d6c078e0385868e45cd1c5 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 3 Feb 2013 16:56:19 +0000 Subject: [PATCH 46/64] Remove rogue print --- openlp/core/ui/mainwindow.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 9fe81b01f..9a5429d9d 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -1363,7 +1363,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): dir_util.copy_tree(old_data_path, self.newDataPath) log.info(u'Copy sucessful') except (IOError, os.error, DistutilsFileError), why: - print "A5" self.openlp_core.set_normal_cursor() log.exception(u'Data copy failed %s' % unicode(why)) QtGui.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'New Data Directory Error'), From 28aeed815fc3d9974d50b047040fbde5848ce46a Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 3 Feb 2013 17:42:31 +0000 Subject: [PATCH 47/64] Minor fixes --- openlp/core/__init__.py | 42 +++++++++++++++++------------- openlp/core/lib/eventreceiver.py | 3 --- openlp/core/ui/mainwindow.py | 11 ++++---- openlp/core/ui/shortcutlistform.py | 14 ++++++++-- openlp/core/ui/splashscreen.py | 1 - 5 files changed, 41 insertions(+), 30 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 18c5c6648..fb35803d1 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -154,6 +154,12 @@ class OpenLP(QtGui.QApplication): self.main_window.app_startup() return self.exec_() + def close_splash_screen(self): + """ + Close the splash screen when requested. + """ + self.splash.close() + def is_already_running(self): """ Look to see if OpenLP is already running and ask if a 2nd copy @@ -276,36 +282,36 @@ def main(args=None): # Initialise the resources qInitResources() # Now create and actually run the application. - app = OpenLP(qt_args) - app.setOrganizationName(u'OpenLP') - app.setOrganizationDomain(u'openlp.org') + application = OpenLP(qt_args) + application.setOrganizationName(u'OpenLP') + application.setOrganizationDomain(u'openlp.org') if options.portable: - app.setApplicationName(u'OpenLPPortable') + application.setApplicationName(u'OpenLPPortable') Settings.setDefaultFormat(Settings.IniFormat) # Get location OpenLPPortable.ini - app_path = AppLocation.get_directory(AppLocation.AppDir) - set_up_logging(os.path.abspath(os.path.join(app_path, u'..', u'..', u'Other'))) + application_path = AppLocation.get_directory(AppLocation.AppDir) + set_up_logging(os.path.abspath(os.path.join(application_path, u'..', u'..', u'Other'))) log.info(u'Running portable') - portable_settings_file = os.path.abspath(os.path.join(app_path, u'..', u'..', u'Data', u'OpenLP.ini')) + portable_settings_file = os.path.abspath(os.path.join(application_path, u'..', u'..', u'Data', u'OpenLP.ini')) # Make this our settings file log.info(u'INI file: %s', portable_settings_file) Settings.set_filename(portable_settings_file) portable_settings = Settings() # Set our data path - data_path = os.path.abspath(os.path.join(app_path, u'..', u'..', u'Data',)) + data_path = os.path.abspath(os.path.join(application_path, u'..', u'..', u'Data',)) log.info(u'Data path: %s', data_path) # Point to our data path portable_settings.setValue(u'advanced/data path', data_path) portable_settings.setValue(u'advanced/is portable', True) portable_settings.sync() else: - app.setApplicationName(u'OpenLP') + application.setApplicationName(u'OpenLP') set_up_logging(AppLocation.get_directory(AppLocation.CacheDir)) Registry.create() - Registry().register(u'openlp_core', app) - app.setApplicationVersion(get_application_version()[u'version']) + Registry().register(u'openlp_core', application) + application.setApplicationVersion(get_application_version()[u'version']) # Instance check - if app.is_already_running(): + if application.is_already_running(): sys.exit() # First time checks in settings if not Settings().value(u'general/has run wizard'): @@ -314,14 +320,14 @@ def main(args=None): sys.exit() # i18n Set Language language = LanguageManager.get_language() - app_translator, default_translator = LanguageManager.get_translator(language) - if not app_translator.isEmpty(): - app.installTranslator(app_translator) + application_translator, default_translator = LanguageManager.get_translator(language) + if not application_translator.isEmpty(): + application.installTranslator(application_translator) if not default_translator.isEmpty(): - app.installTranslator(default_translator) + application.installTranslator(default_translator) else: log.debug(u'Could not find default_translator.') if not options.no_error_form: - sys.excepthook = app.hook_exception - sys.exit(app.run(qt_args)) + sys.excepthook = application.hook_exception + sys.exit(application.run(qt_args)) diff --git a/openlp/core/lib/eventreceiver.py b/openlp/core/lib/eventreceiver.py index a1b123530..df24694b0 100644 --- a/openlp/core/lib/eventreceiver.py +++ b/openlp/core/lib/eventreceiver.py @@ -47,9 +47,6 @@ class EventReceiver(QtCore.QObject): ``mainwindow_status_text`` Changes the bottom status bar text on the mainwindow. - ``openlp_warning_message`` - Displays a standalone Warning Message. - ``openlp_error_message`` Displays a standalone Error Message. diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 9a5429d9d..f8bd6b6ed 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -541,7 +541,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.openlp_core.set_busy_cursor() # Simple message boxes QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_error_message'), self.onErrorMessage) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_warning_message'), self.onWarningMessage) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_information_message'), self.onInformationMessage) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'set_new_data_path'), self.setNewDataPath) @@ -724,21 +723,21 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ Display an error message """ - Receiver.send_message(u'close_splash') + self.openlp_core.close_splash_screen() QtGui.QMessageBox.critical(self, data[u'title'], data[u'message']) - def onWarningMessage(self, data): + def warning_message(self, message): """ Display a warning message """ - Receiver.send_message(u'close_splash') - QtGui.QMessageBox.warning(self, data[u'title'], data[u'message']) + self.openlp_core.close_splash_screen() + QtGui.QMessageBox.warning(self, message[u'title'], message[u'message']) def onInformationMessage(self, data): """ Display an informational message """ - Receiver.send_message(u'close_splash') + self.openlp_core.close_splash_screen() QtGui.QMessageBox.information(self, data[u'title'], data[u'message']) def onHelpWebSiteClicked(self): diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index ff07c6242..b628156b8 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -33,7 +33,7 @@ import re from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, Settings +from openlp.core.lib import Registry, Settings from openlp.core.utils import translate from openlp.core.utils.actions import ActionList from shortcutlistdialog import Ui_ShortcutListDialog @@ -438,7 +438,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): if changing_action.shortcutContext() in [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut]: is_valid = False if not is_valid: - Receiver.send_message(u'openlp_warning_message', { + self.main_window.warning_message( { u'title': translate('OpenLP.ShortcutListDialog', 'Duplicate Shortcut'), u'message': translate('OpenLP.ShortcutListDialog', 'The shortcut "%s" is already assigned to another action, ' @@ -478,3 +478,13 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): button.setChecked(checked) if enabled is not None: button.setEnabled(enabled) + + def _get_main_window(self): + """ + Adds the main window to the class dynamically + """ + if not hasattr(self, u'_main_window'): + self._main_window = Registry().get(u'main_window') + return self._main_window + + main_window = property(_get_main_window) \ No newline at end of file diff --git a/openlp/core/ui/splashscreen.py b/openlp/core/ui/splashscreen.py index 39ac8e8d9..d2b41d067 100644 --- a/openlp/core/ui/splashscreen.py +++ b/openlp/core/ui/splashscreen.py @@ -44,7 +44,6 @@ class SplashScreen(QtGui.QSplashScreen): """ QtGui.QSplashScreen.__init__(self) self.setupUi() - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'close_splash'), self.close) def setupUi(self): """ From a9a4c7938ef509c41280bdc9e30a36f6be6902cd Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 3 Feb 2013 19:23:12 +0000 Subject: [PATCH 48/64] Fix name and other bugs --- openlp/core/__init__.py | 4 +- openlp/core/lib/mediamanageritem.py | 14 ++--- openlp/core/lib/plugin.py | 10 ++-- openlp/core/ui/firsttimeform.py | 48 ++++++++--------- openlp/core/ui/maindisplay.py | 18 +++---- openlp/core/ui/mainwindow.py | 53 +++++++++---------- openlp/core/ui/media/mediaplayer.py | 10 ++-- openlp/core/ui/media/phononplayer.py | 2 +- openlp/core/ui/media/vlcplayer.py | 2 +- openlp/core/ui/pluginform.py | 14 ++--- openlp/core/ui/printserviceform.py | 2 +- openlp/core/ui/servicemanager.py | 38 ++++++------- openlp/core/ui/thememanager.py | 22 ++++---- openlp/core/ui/wizard.py | 14 ++--- openlp/core/utils/__init__.py | 2 +- .../plugins/bibles/forms/bibleimportform.py | 2 +- .../plugins/bibles/forms/bibleupgradeform.py | 6 +-- openlp/plugins/bibles/forms/editbibleform.py | 14 ++--- openlp/plugins/bibles/lib/csvbible.py | 4 +- openlp/plugins/bibles/lib/db.py | 10 ++-- openlp/plugins/bibles/lib/http.py | 44 +++++++-------- openlp/plugins/bibles/lib/mediaitem.py | 12 ++--- openlp/plugins/bibles/lib/openlp1.py | 2 +- openlp/plugins/bibles/lib/opensong.py | 2 +- openlp/plugins/bibles/lib/osis.py | 2 +- openlp/plugins/images/lib/mediaitem.py | 8 +-- openlp/plugins/presentations/lib/mediaitem.py | 8 +-- openlp/plugins/songs/forms/songexportform.py | 6 +-- openlp/plugins/songs/forms/songimportform.py | 2 +- .../songs/forms/songmaintenanceform.py | 14 ++--- openlp/plugins/songs/lib/mediaitem.py | 4 +- openlp/plugins/songs/lib/openlyricsexport.py | 12 ++--- openlp/plugins/songs/songsplugin.py | 12 ++--- 33 files changed, 208 insertions(+), 209 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index fb35803d1..33eb916be 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -135,7 +135,7 @@ class OpenLP(QtGui.QApplication): # make sure Qt really display the splash screen self.processEvents() # start the main app window - self.main_window = MainWindow(self) + self.main_window = MainWindow() self.main_window.show() if show_splash: # now kill the splashscreen @@ -308,7 +308,7 @@ def main(args=None): application.setApplicationName(u'OpenLP') set_up_logging(AppLocation.get_directory(AppLocation.CacheDir)) Registry.create() - Registry().register(u'openlp_core', application) + Registry().register(u'application', application) application.setApplicationVersion(get_application_version()[u'version']) # Instance check if application.is_already_running(): diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index b235efe06..bb8ee2f70 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -332,9 +332,9 @@ class MediaManagerItem(QtGui.QWidget): Settings().value(self.settingsSection + u'/last directory'), self.onNewFileMasks) log.info(u'New files(s) %s', files) if files: - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() self.validateAndLoad(files) - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() def loadFile(self, files): """ @@ -719,12 +719,12 @@ class MediaManagerItem(QtGui.QWidget): theme_manager = property(_get_theme_manager) - def _get_openlp_core(self): + def _get_application(self): """ Adds the openlp to the class dynamically """ - if not hasattr(self, u'_openlp_core'): - self._openlp_core = Registry().get(u'openlp_core') - return self._openlp_core + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application - openlp_core = property(_get_openlp_core) + application = property(_get_application) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 195759e94..bad7defb8 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -425,12 +425,12 @@ class Plugin(QtCore.QObject): main_window = property(_get_main_window) - def _get_openlp_core(self): + def _get_application(self): """ Adds the openlp to the class dynamically """ - if not hasattr(self, u'_openlp_core'): - self._openlp_core = Registry().get(u'openlp_core') - return self._openlp_core + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application - openlp_core = property(_get_openlp_core) + application = property(_get_application) diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 5f7608f55..29e2cd97a 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -152,13 +152,13 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): # Download the theme screenshots. self.themeScreenshotThread = ThemeScreenshotThread(self) self.themeScreenshotThread.start() - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() def nextId(self): """ Determine the next page in the Wizard to go to. """ - self.openlp_core.process_events() + self.application.process_events() if self.currentId() == FirstTimePage.Plugins: if not self.webAccess: return FirstTimePage.NoInternet @@ -169,13 +169,13 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): elif self.currentId() == FirstTimePage.NoInternet: return FirstTimePage.Progress elif self.currentId() == FirstTimePage.Themes: - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() while not self.themeScreenshotThread.isFinished(): time.sleep(0.1) - self.openlp_core.process_events() + self.application.process_events() # Build the screenshot icons, as this can not be done in the thread. self._buildThemeScreenshots() - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() return FirstTimePage.Defaults else: return self.currentId() + 1 @@ -186,7 +186,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): """ # Keep track of the page we are at. Triggering "Cancel" causes pageId # to be a -1. - self.openlp_core.process_events() + self.application.process_events() if pageId != -1: self.lastId = pageId if pageId == FirstTimePage.Plugins: @@ -218,15 +218,15 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): if self.hasRunWizard: self.cancelButton.setVisible(False) elif pageId == FirstTimePage.Progress: - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() self.repaint() - self.openlp_core.process_events() + self.application.process_events() # Try to give the wizard a chance to redraw itself time.sleep(0.2) self._preWizard() self._performWizard() self._postWizard() - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() def updateScreenListCombo(self): """ @@ -248,15 +248,15 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): self.was_download_cancelled = True while self.themeScreenshotThread.isRunning(): time.sleep(0.1) - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() def onNoInternetFinishButtonClicked(self): """ Process the triggering of the "Finish" button on the No Internet page. """ - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() self._performWizard() - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() Settings().setValue(u'general/has run wizard', True) self.close() @@ -332,7 +332,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): self.progressLabel.setText(status_text) if increment > 0: self.progressBar.setValue(self.progressBar.value() + increment) - self.openlp_core.process_events() + self.application.process_events() def _preWizard(self): """ @@ -340,10 +340,10 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): """ self.max_progress = 0 self.finishButton.setVisible(False) - self.openlp_core.process_events() + self.application.process_events() # Loop through the songs list and increase for each selected item for i in xrange(self.songsListWidget.count()): - self.openlp_core.process_events() + self.application.process_events() item = self.songsListWidget.item(i) if item.checkState() == QtCore.Qt.Checked: filename = item.data(QtCore.Qt.UserRole) @@ -352,7 +352,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): # Loop through the Bibles list and increase for each selected item iterator = QtGui.QTreeWidgetItemIterator(self.biblesTreeWidget) while iterator.value(): - self.openlp_core.process_events() + self.application.process_events() item = iterator.value() if item.parent() and item.checkState(0) == QtCore.Qt.Checked: filename = item.data(0, QtCore.Qt.UserRole) @@ -361,7 +361,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): iterator += 1 # Loop through the themes list and increase for each selected item for i in xrange(self.themesListWidget.count()): - self.openlp_core.process_events() + self.application.process_events() item = self.themesListWidget.item(i) if item.checkState() == QtCore.Qt.Checked: filename = item.data(QtCore.Qt.UserRole) @@ -381,7 +381,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): self.progressPage.setTitle(translate('OpenLP.FirstTimeWizard', 'Setting Up')) self.progressPage.setSubTitle(u'Setup complete.') self.repaint() - self.openlp_core.process_events() + self.application.process_events() # Try to give the wizard a chance to repaint itself time.sleep(0.1) @@ -408,7 +408,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): self.finishButton.setEnabled(True) self.cancelButton.setVisible(False) self.nextButton.setVisible(False) - self.openlp_core.process_events() + self.application.process_events() def _performWizard(self): """ @@ -487,12 +487,12 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): theme_manager = property(_get_theme_manager) - def _get_openlp_core(self): + def _get_application(self): """ Adds the openlp to the class dynamically """ - if not hasattr(self, u'_openlp_core'): - self._openlp_core = Registry().get(u'openlp_core') - return self._openlp_core + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application - openlp_core = property(_get_openlp_core) + application = property(_get_application) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 9ec3e8265..9cae5dfac 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -243,7 +243,7 @@ class MainDisplay(Display): log.debug(u'text to display') # Wait for the webview to update before displaying text. while not self.webLoaded: - self.openlp_core.process_events() + self.application.process_events() self.setGeometry(self.screen[u'size']) if animate: self.frame.evaluateJavaScript(u'show_text("%s")' % slide.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"')) @@ -347,18 +347,18 @@ class MainDisplay(Display): Generates a preview of the image displayed. """ log.debug(u'preview for %s', self.isLive) - self.openlp_core.process_events() + self.application.process_events() # We must have a service item to preview. if self.isLive and hasattr(self, u'serviceItem'): # Wait for the fade to finish before geting the preview. # Important otherwise preview will have incorrect text if at all! if self.serviceItem.themedata and self.serviceItem.themedata.display_slide_transition: while self.frame.evaluateJavaScript(u'show_text_complete()') == u'false': - self.openlp_core.process_events() + self.application.process_events() # Wait for the webview to update before getting the preview. # Important otherwise first preview will miss the background ! while not self.webLoaded: - self.openlp_core.process_events() + self.application.process_events() # if was hidden keep it hidden if self.isLive: if self.hideMode: @@ -503,15 +503,15 @@ class MainDisplay(Display): image_manager = property(_get_image_manager) - def _get_openlp_core(self): + def _get_application(self): """ Adds the openlp to the class dynamically """ - if not hasattr(self, u'_openlp_core'): - self._openlp_core = Registry().get(u'openlp_core') - return self._openlp_core + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application - openlp_core = property(_get_openlp_core) + application = property(_get_application) class AudioPlayer(QtCore.QObject): diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index f8bd6b6ed..e1cba9762 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -455,14 +455,13 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ log.info(u'MainWindow loaded') - def __init__(self, application): + def __init__(self): """ This constructor sets up the interface, the various managers, and the plugins. """ QtGui.QMainWindow.__init__(self) Registry().register(u'main_window', self) - self.application = application self.clipboard = self.application.clipboard() self.arguments = self.application.args # Set up settings sections for the main application (not for use by plugins). @@ -538,7 +537,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'cleanup'), self.clean_up) # Media Manager QtCore.QObject.connect(self.mediaToolBox, QtCore.SIGNAL(u'currentChanged(int)'), self.onMediaToolBoxChanged) - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() # Simple message boxes QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_error_message'), self.onErrorMessage) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_information_message'), @@ -586,7 +585,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # Hide/show the theme combobox on the service manager self.serviceManagerContents.theme_change() # Reset the cursor - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() def setAutoLanguage(self, value): """ @@ -647,22 +646,22 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ Give all the plugins a chance to perform some tasks at startup """ - self.openlp_core.process_events() + self.application.process_events() for plugin in self.plugin_manager.plugins: if plugin.isActive(): plugin.app_startup() - self.openlp_core.process_events() + self.application.process_events() def first_time(self): """ Import themes if first time """ - self.openlp_core.process_events() + self.application.process_events() for plugin in self.plugin_manager.plugins: if hasattr(plugin, u'first_time'): - self.openlp_core.process_events() + self.application.process_events() plugin.first_time() - self.openlp_core.process_events() + self.application.process_events() temp_dir = os.path.join(unicode(gettempdir()), u'openlp') shutil.rmtree(temp_dir, True) @@ -688,7 +687,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): first_run_wizard.exec_() if first_run_wizard.was_download_cancelled: return - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() self.first_time() for plugin in self.plugin_manager.plugins: self.activePlugin = plugin @@ -706,7 +705,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # Check if any Bibles downloaded. If there are, they will be # processed. Receiver.send_message(u'bibles_load_list', True) - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() def blankCheck(self): """ @@ -723,21 +722,21 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ Display an error message """ - self.openlp_core.close_splash_screen() + self.application.close_splash_screen() QtGui.QMessageBox.critical(self, data[u'title'], data[u'message']) def warning_message(self, message): """ Display a warning message """ - self.openlp_core.close_splash_screen() + self.application.close_splash_screen() QtGui.QMessageBox.warning(self, message[u'title'], message[u'message']) def onInformationMessage(self, data): """ Display an informational message """ - self.openlp_core.close_splash_screen() + self.application.close_splash_screen() QtGui.QMessageBox.information(self, data[u'title'], data[u'message']) def onHelpWebSiteClicked(self): @@ -1003,14 +1002,14 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): renderer. """ log.debug(u'screenChanged') - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() self.imageManager.update_display() self.renderer.update_display() self.previewController.screenSizeChanged() self.liveController.screenSizeChanged() self.setFocus() self.activateWindow() - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() def closeEvent(self, event): """ @@ -1309,14 +1308,14 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.loadProgressBar.show() self.loadProgressBar.setMaximum(size) self.loadProgressBar.setValue(0) - self.openlp_core.process_events() + self.application.process_events() def incrementProgressBar(self): """ Increase the Progress Bar value by 1 """ self.loadProgressBar.setValue(self.loadProgressBar.value() + 1) - self.openlp_core.process_events() + self.application.process_events() def finishedProgressBar(self): """ @@ -1331,7 +1330,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): if event.timerId() == self.timer_id: self.timer_id = 0 self.loadProgressBar.hide() - self.openlp_core.process_events() + self.application.process_events() def setNewDataPath(self, new_data_path): """ @@ -1352,7 +1351,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): log.info(u'Changing data path to %s' % self.newDataPath) old_data_path = unicode(AppLocation.get_data_path()) # Copy OpenLP data to new location if requested. - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() if self.copyData: log.info(u'Copying data to new path') try: @@ -1362,7 +1361,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): dir_util.copy_tree(old_data_path, self.newDataPath) log.info(u'Copy sucessful') except (IOError, os.error, DistutilsFileError), why: - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() log.exception(u'Data copy failed %s' % unicode(why)) QtGui.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'New Data Directory Error'), translate('OpenLP.MainWindow', @@ -1377,14 +1376,14 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # Check if the new data path is our default. if self.newDataPath == AppLocation.get_directory(AppLocation.DataDir): settings.remove(u'advanced/data path') - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() - def _get_openlp_core(self): + def _get_application(self): """ Adds the openlp to the class dynamically """ - if not hasattr(self, u'_openlp_core'): - self._openlp_core = Registry().get(u'openlp_core') - return self._openlp_core + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application - openlp_core = property(_get_openlp_core) + application = property(_get_application) diff --git a/openlp/core/ui/media/mediaplayer.py b/openlp/core/ui/media/mediaplayer.py index 61550acfc..df9254706 100644 --- a/openlp/core/ui/media/mediaplayer.py +++ b/openlp/core/ui/media/mediaplayer.py @@ -151,12 +151,12 @@ class MediaPlayer(object): """ return u'' - def _get_openlp_core(self): + def _get_application(self): """ Adds the openlp to the class dynamically """ - if not hasattr(self, u'_openlp_core'): - self._openlp_core = Registry().get(u'openlp_core') - return self._openlp_core + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application - openlp_core = property(_get_openlp_core) \ No newline at end of file + application = property(_get_application) \ No newline at end of file diff --git a/openlp/core/ui/media/phononplayer.py b/openlp/core/ui/media/phononplayer.py index 9b218bbc8..ede7b2169 100644 --- a/openlp/core/ui/media/phononplayer.py +++ b/openlp/core/ui/media/phononplayer.py @@ -168,7 +168,7 @@ class PhononPlayer(MediaPlayer): current_state = display.mediaObject.state() if current_state == Phonon.ErrorState: return False - self.openlp_core.process_events() + self.application.process_events() if (datetime.now() - start).seconds > 5: return False return True diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 05cc734fa..948577aac 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -187,7 +187,7 @@ class VlcPlayer(MediaPlayer): while not mediaState == display.vlcMedia.get_state(): if display.vlcMedia.get_state() == vlc.State.Error: return False - self.openlp_core.process_events() + self.application.process_events() if (datetime.now() - start).seconds > 60: return False return True diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index 1cbf91824..c371bc689 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -140,9 +140,9 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): if self.programaticChange or status == PluginStatus.Disabled: return if status == PluginStatus.Inactive: - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() self.activePlugin.toggleStatus(PluginStatus.Active) - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() self.activePlugin.app_startup() else: self.activePlugin.toggleStatus(PluginStatus.Inactive) @@ -166,12 +166,12 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): plugin_manager = property(_get_plugin_manager) - def _get_openlp_core(self): + def _get_application(self): """ Adds the openlp to the class dynamically """ - if not hasattr(self, u'_openlp_core'): - self._openlp_core = Registry().get(u'openlp_core') - return self._openlp_core + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application - openlp_core = property(_get_openlp_core) + application = property(_get_application) diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index 101ee9acb..689323cd5 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -178,7 +178,7 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): self._addElement(u'body', parent=html_data) self._addElement(u'h1', cgi.escape(self.titleLineEdit.text()), html_data.body, classId=u'serviceTitle') - for index, item in enumerate(self.service_manager.serviceItems): + for index, item in enumerate(self.service_manager.service_items): self._addPreviewItem(html_data.body, item[u'service_item'], index) # Add the custom service notes: if self.footerTextEdit.toPlainText(): diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 5c16ae8af..b45794556 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -478,7 +478,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): missing_list = [] audio_files = [] total_size = 0 - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() # Number of items + 1 to zip it self.main_window.displayProgressBar(len(self.service_items) + 1) # Get list of missing files, and list of files to write @@ -494,7 +494,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): else: write_list.append(path_from) if missing_list: - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() title = translate('OpenLP.ServiceManager', 'Service File(s) Missing') message = translate('OpenLP.ServiceManager', 'The following file(s) in the service are missing:\n\t%s\n\n' @@ -564,7 +564,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): if zip_file: zip_file.close() self.main_window.finishedProgressBar() - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() if success: try: shutil.copy(temp_file_name, path_file_name) @@ -593,7 +593,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): log.debug(u'ServiceManager.save_file - %s', path_file_name) Settings().setValue(self.main_window.serviceManagerSettingsSection + u'/last directory', path) service = [] - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() # Number of items + 1 to zip it self.main_window.displayProgressBar(len(self.service_items) + 1) for item in self.service_items: @@ -622,7 +622,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): if zip_file: zip_file.close() self.main_window.finishedProgressBar() - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() if success: try: shutil.copy(temp_file_name, path_file_name) @@ -699,7 +699,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): return False zip_file = None file_to = None - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() try: zip_file = zipfile.ZipFile(file_name) for zip_info in zip_file.infolist(): @@ -764,7 +764,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): QtGui.QMessageBox.information(self, translate('OpenLP.ServiceManager', 'Corrupt File'), translate('OpenLP.ServiceManager', 'This file is either corrupt or it is not an OpenLP 2 service file.')) - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() return finally: if file_to: @@ -772,7 +772,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): if zip_file: zip_file.close() self.main_window.finishedProgressBar() - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() self.repaint_service_list(-1, -1) def load_Last_file(self): @@ -1258,7 +1258,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): Rebuild the service list as things have changed and a repaint is the easiest way to do this. """ - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() log.debug(u'regenerate_service_Items') # force reset of renderer as theme data has changed self.service_has_all_original_files = True @@ -1290,7 +1290,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): self.set_modified() # Repaint it once only at the end self.repaint_service_list(-1, -1) - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() def service_item_update(self, edit_id, unique_identifier, temporary=False): """ @@ -1365,7 +1365,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): """ Send the current item to the Preview slide controller """ - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() item, child = self.find_service_item() if self.service_items[item][u'service_item'].is_valid: self.preview_controller.addServiceManagerItem(self.service_items[item][u'service_item'], child) @@ -1373,7 +1373,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): critical_error_message_box(translate('OpenLP.ServiceManager', 'Missing Display Handler'), translate('OpenLP.ServiceManager', 'Your item cannot be displayed as there is no handler to display it')) - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() def get_service_item(self): """ @@ -1406,7 +1406,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): return if row != -1: child = row - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() if self.service_items[item][u'service_item'].is_valid: self.live_controller.addServiceManagerItem(self.service_items[item][u'service_item'], child) if Settings().value(self.main_window.generalSettingsSection + u'/auto preview'): @@ -1421,7 +1421,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): critical_error_message_box(translate('OpenLP.ServiceManager', 'Missing Display Handler'), translate('OpenLP.ServiceManager', 'Your item cannot be displayed as the plugin required to display it is missing or inactive')) - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() def remote_edit(self): """ @@ -1635,12 +1635,12 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): main_window = property(_get_main_window) - def _get_openlp_core(self): + def _get_application(self): """ Adds the openlp to the class dynamically """ - if not hasattr(self, u'_openlp_core'): - self._openlp_core = Registry().get(u'openlp_core') - return self._openlp_core + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application - openlp_core = property(_get_openlp_core) + application = property(_get_application) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 78765fc1a..a482a3c44 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -153,13 +153,13 @@ class ThemeManager(QtGui.QWidget): """ Import new themes downloaded by the first time wizard """ - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() files = SettingsManager.get_files(self.settingsSection, u'.otz') for theme_file in files: theme_file = os.path.join(self.path, theme_file) self.unzipTheme(theme_file, self.path) delete_file(theme_file) - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() def config_updated(self): @@ -368,7 +368,7 @@ class ThemeManager(QtGui.QWidget): path = QtGui.QFileDialog.getExistingDirectory(self, translate('OpenLP.ThemeManager', 'Save Theme - (%s)') % theme, Settings().value(self.settingsSection + u'/last directory export')) - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() if path: Settings().setValue(self.settingsSection + u'/last directory export', path) theme_path = os.path.join(path, theme + u'.otz') @@ -392,7 +392,7 @@ class ThemeManager(QtGui.QWidget): finally: if theme_zip: theme_zip.close() - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() def on_import_theme(self): @@ -408,12 +408,12 @@ class ThemeManager(QtGui.QWidget): log.info(u'New Themes %s', unicode(files)) if not files: return - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() for file_name in files: Settings().setValue(self.settingsSection + u'/last directory import', unicode(file_name)) self.unzip_theme(file_name, self.path) self.load_themes() - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() def load_themes(self, first_time=False): """ @@ -851,12 +851,12 @@ class ThemeManager(QtGui.QWidget): main_window = property(_get_main_window) - def _get_openlp_core(self): + def _get_application(self): """ Adds the openlp to the class dynamically """ - if not hasattr(self, u'_openlp_core'): - self._openlp_core = Registry().get(u'openlp_core') - return self._openlp_core + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application - openlp_core = property(_get_openlp_core) \ No newline at end of file + application = property(_get_application) \ No newline at end of file diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index cc7f16a8d..46ef55fd1 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -219,7 +219,7 @@ class OpenLPWizard(QtGui.QWizard): self.progressLabel.setText(status_text) if increment > 0: self.progressBar.setValue(self.progressBar.value() + increment) - self.openlp_core.process_events() + self.application.process_events() def preWizard(self): """ @@ -237,7 +237,7 @@ class OpenLPWizard(QtGui.QWizard): self.progressBar.setValue(self.progressBar.maximum()) self.finishButton.setVisible(True) self.cancelButton.setVisible(False) - self.openlp_core.process_events() + self.application.process_events() def getFileName(self, title, editbox, setting_name, filters=u''): """ @@ -287,12 +287,12 @@ class OpenLPWizard(QtGui.QWizard): editbox.setText(folder) Settings().setValue(self.plugin.settingsSection + u'/' + setting_name, folder) - def _get_openlp_core(self): + def _get_application(self): """ Adds the openlp to the class dynamically """ - if not hasattr(self, u'_openlp_core'): - self._openlp_core = Registry().get(u'openlp_core') - return self._openlp_core + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application - openlp_core = property(_get_openlp_core) \ No newline at end of file + application = property(_get_application) \ No newline at end of file diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index daa858219..f1c05e668 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -424,7 +424,7 @@ def get_web_page(url, header=None, update_openlp=False): if not page: return None if update_openlp: - Registry().get(u'openlp_core').process_events() + Registry().get(u'application').process_events() log.debug(page) return page diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 93ee35154..10d50a9af 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -578,7 +578,7 @@ class BibleImportForm(OpenLPWizard): self.progressLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Registering Bible...')) else: self.progressLabel.setText(WizardStrings.StartingImport) - self.openlp_core.process_events() + self.application.process_events() def performWizard(self): """ diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index d46af6e36..10589cbee 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -335,7 +335,7 @@ class BibleUpgradeForm(OpenLPWizard): """ OpenLPWizard.preWizard(self) self.progressLabel.setText(translate('BiblesPlugin.UpgradeWizardForm', 'Starting upgrade...')) - self.openlp_core.process_events() + self.application.process_events() def performWizard(self): """ @@ -465,7 +465,7 @@ class BibleUpgradeForm(OpenLPWizard): self.newbibles[number].create_verse(db_book.id, int(verse[u'chapter']), int(verse[u'verse']), unicode(verse[u'text'])) - self.openlp_core.process_events() + self.application.process_events() self.newbibles[number].session.commit() else: language_id = self.newbibles[number].get_object(BibleMeta, u'language_id') @@ -511,7 +511,7 @@ class BibleUpgradeForm(OpenLPWizard): self.newbibles[number].create_verse(db_book.id, int(verse[u'chapter']), int(verse[u'verse']), unicode(verse[u'text'])) - self.openlp_core.process_events() + self.application.process_events() self.newbibles[number].session.commit() if not self.success.get(number, True): self.incrementProgressBar(translate('BiblesPlugin.UpgradeWizardForm', diff --git a/openlp/plugins/bibles/forms/editbibleform.py b/openlp/plugins/bibles/forms/editbibleform.py index 52093dffc..a6e9e6d6b 100644 --- a/openlp/plugins/bibles/forms/editbibleform.py +++ b/openlp/plugins/bibles/forms/editbibleform.py @@ -122,7 +122,7 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog): if book.name != custom_names[abbr]: if not self.validateBook(custom_names[abbr], abbr): return - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() self.manager.save_meta_data(self.bible, version, copyright, permissions, book_name_language) if not self.webbible: for abbr, book in self.books.iteritems(): @@ -131,7 +131,7 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog): book.name = custom_names[abbr] self.manager.update_book(self.bible, book) self.bible = None - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() QtGui.QDialog.accept(self) def validateMeta(self, name, copyright): @@ -189,12 +189,12 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog): return False return True - def _get_openlp_core(self): + def _get_application(self): """ Adds the openlp to the class dynamically """ - if not hasattr(self, u'_openlp_core'): - self._openlp_core = Registry().get(u'openlp_core') - return self._openlp_core + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application - openlp_core = property(_get_openlp_core) + application = property(_get_application) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index 20c92ffd6..492702fe7 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -118,7 +118,7 @@ class CSVBible(BibleDB): book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) self.create_book(unicode(line[2], details['encoding']), book_ref_id, book_details[u'testament_id']) book_list[int(line[0])] = unicode(line[2], details['encoding']) - self.openlp_core.process_events() + self.application.process_events() except (IOError, IndexError): log.exception(u'Loading books from file failed') success = False @@ -157,7 +157,7 @@ class CSVBible(BibleDB): verse_text = unicode(line[3], u'cp1252') self.create_verse(book.id, line[1], line[2], verse_text) self.wizard.incrementProgressBar(translate('BiblesPlugin.CSVBible', 'Importing verses... done.')) - self.openlp_core.process_events() + self.application.process_events() self.session.commit() except IOError: log.exception(u'Loading verses from file failed') diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 5b492d10e..c728aee6a 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -549,15 +549,15 @@ class BibleDB(QtCore.QObject, Manager): verses = self.session.query(Verse).all() log.debug(verses) - def _get_openlp_core(self): + def _get_application(self): """ Adds the openlp to the class dynamically """ - if not hasattr(self, u'_openlp_core'): - self._openlp_core = Registry().get(u'openlp_core') - return self._openlp_core + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application - openlp_core = property(_get_openlp_core) + application = property(_get_application) class BiblesResourcesDB(QtCore.QObject, Manager): diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index f26b74b14..799c11129 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -235,10 +235,10 @@ class BGExtract(object): soup = get_soup_for_bible_ref( u'http://www.biblegateway.com/passage/?%s' % url_params, pre_parse_regex=r'', pre_parse_substitute='', cleaner=cleaner) - self.openlp_core.process_events() + self.application.process_events() if not soup: return None - self.openlp_core.process_events() + self.application.process_events() div = soup.find('div', 'result-text-style-normal') self._clean_soup(div) span_list = div.findAll('span', 'text') @@ -282,7 +282,7 @@ class BGExtract(object): if not soup: send_error_message(u'parse') return None - self.openlp_core.process_events() + self.application.process_events() content = soup.find(u'table', u'infotable') if content: content = content.findAll(u'tr') @@ -330,7 +330,7 @@ class BSExtract(object): soup = get_soup_for_bible_ref(chapter_url, header) if not soup: return None - self.openlp_core.process_events() + self.application.process_events() content = soup.find(u'div', u'content') if not content: log.error(u'No verses found in the Bibleserver response.') @@ -340,7 +340,7 @@ class BSExtract(object): verse_number = re.compile(r'v(\d{1,2})(\d{3})(\d{3}) verse.*') verses = {} for verse in content: - self.openlp_core.process_events() + self.application.process_events() versenumber = int(verse_number.sub(r'\3', verse[u'class'])) verses[versenumber] = verse.contents[1].rstrip(u'\n') return SearchResults(book_name, chapter, verses) @@ -403,7 +403,7 @@ class CWExtract(object): soup = get_soup_for_bible_ref(chapter_url) if not soup: return None - self.openlp_core.process_events() + self.application.process_events() html_verses = soup.findAll(u'span', u'versetext') if not html_verses: log.error(u'No verses found in the CrossWalk response.') @@ -413,25 +413,25 @@ class CWExtract(object): reduce_spaces = re.compile(r'[ ]{2,}') fix_punctuation = re.compile(r'[ ]+([.,;])') for verse in html_verses: - self.openlp_core.process_events() + self.application.process_events() verse_number = int(verse.contents[0].contents[0]) verse_text = u'' for part in verse.contents: - self.openlp_core.process_events() + self.application.process_events() if isinstance(part, NavigableString): verse_text = verse_text + part elif part and part.attrMap and \ (part.attrMap[u'class'] == u'WordsOfChrist' or part.attrMap[u'class'] == u'strongs'): for subpart in part.contents: - self.openlp_core.process_events() + self.application.process_events() if isinstance(subpart, NavigableString): verse_text = verse_text + subpart elif subpart and subpart.attrMap and subpart.attrMap[u'class'] == u'strongs': for subsub in subpart.contents: - self.openlp_core.process_events() + self.application.process_events() if isinstance(subsub, NavigableString): verse_text = verse_text + subsub - self.openlp_core.process_events() + self.application.process_events() # Fix up leading and trailing spaces, multiple spaces, and spaces # between text and , and . verse_text = verse_text.strip(u'\n\r\t ') @@ -597,7 +597,7 @@ class HTTPBible(BibleDB): return [] book = db_book.name if BibleDB.get_verse_count(self, book_id, reference[1]) == 0: - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() search_results = self.get_chapter(book, reference[1]) if search_results and search_results.has_verselist(): ## We have found a book of the bible lets check to see @@ -605,14 +605,14 @@ class HTTPBible(BibleDB): ## we get a correct book. For example it is possible ## to request ac and get Acts back. book_name = search_results.book - self.openlp_core.process_events() + self.application.process_events() # Check to see if book/chapter exists. db_book = self.get_book(book_name) self.create_chapter(db_book.id, search_results.chapter, search_results.verselist) - self.openlp_core.process_events() - self.openlp_core.set_normal_cursor() - self.openlp_core.process_events() + self.application.process_events() + self.application.set_normal_cursor() + self.application.process_events() return BibleDB.get_verses(self, reference_list, show_error) def get_chapter(self, book, chapter): @@ -659,15 +659,15 @@ class HTTPBible(BibleDB): log.debug(u'HTTPBible.get_verse_count("%s", %s)', book_id, chapter) return BiblesResourcesDB.get_verse_count(book_id, chapter) - def _get_openlp_core(self): + def _get_application(self): """ Adds the openlp to the class dynamically """ - if not hasattr(self, u'_openlp_core'): - self._openlp_core = Registry().get(u'openlp_core') - return self._openlp_core + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application - openlp_core = property(_get_openlp_core) + application = property(_get_application) def get_soup_for_bible_ref(reference_url, header=None, pre_parse_regex=None, pre_parse_substitute=None, cleaner=None): @@ -710,7 +710,7 @@ def get_soup_for_bible_ref(reference_url, header=None, pre_parse_regex=None, if not soup: send_error_message(u'parse') return None - Registry().get(u'openlp_core').process_events() + Registry().get(u'application').process_events() return soup def send_error_message(error_type): diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 89689d841..13d770909 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -614,7 +614,7 @@ class BibleMediaItem(MediaManagerItem): """ log.debug(u'Advanced Search Button clicked') self.advancedSearchButton.setEnabled(False) - self.openlp_core.process_events() + self.application.process_events() bible = self.advancedVersionComboBox.currentText() second_bible = self.advancedSecondComboBox.currentText() book = self.advancedBookComboBox.currentText() @@ -628,7 +628,7 @@ class BibleMediaItem(MediaManagerItem): verse_range = chapter_from + verse_separator + verse_from + range_separator + chapter_to + \ verse_separator + verse_to versetext = u'%s %s' % (book, verse_range) - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() self.search_results = self.plugin.manager.get_verses(bible, versetext, book_ref_id) if second_bible: self.second_search_results = self.plugin.manager.get_verses(second_bible, versetext, book_ref_id) @@ -640,7 +640,7 @@ class BibleMediaItem(MediaManagerItem): self.displayResults(bible, second_bible) self.advancedSearchButton.setEnabled(True) self.checkSearchResult() - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() def onQuickSearchButton(self): """ @@ -649,7 +649,7 @@ class BibleMediaItem(MediaManagerItem): """ log.debug(u'Quick Search Button clicked') self.quickSearchButton.setEnabled(False) - self.openlp_core.process_events() + self.application.process_events() bible = self.quickVersionComboBox.currentText() second_bible = self.quickSecondComboBox.currentText() text = self.quickSearchEdit.text() @@ -661,7 +661,7 @@ class BibleMediaItem(MediaManagerItem): self.search_results[0].book.book_reference_id) else: # We are doing a 'Text Search'. - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() bibles = self.plugin.manager.get_bibles() self.search_results = self.plugin.manager.verse_search(bible, second_bible, text) if second_bible and self.search_results: @@ -696,7 +696,7 @@ class BibleMediaItem(MediaManagerItem): self.displayResults(bible, second_bible) self.quickSearchButton.setEnabled(True) self.checkSearchResult() - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() def displayResults(self, bible, second_bible=u''): """ diff --git a/openlp/plugins/bibles/lib/openlp1.py b/openlp/plugins/bibles/lib/openlp1.py index ab049625d..0088c80bd 100644 --- a/openlp/plugins/bibles/lib/openlp1.py +++ b/openlp/plugins/bibles/lib/openlp1.py @@ -108,7 +108,7 @@ class OpenLP1Bible(BibleDB): verse_number = int(verse[1]) text = unicode(verse[2], u'cp1252') self.create_verse(db_book.id, chapter, verse_number, text) - self.openlp_core.process_events() + self.application.process_events() self.session.commit() connection.close() return True diff --git a/openlp/plugins/bibles/lib/opensong.py b/openlp/plugins/bibles/lib/opensong.py index 00d7c1318..5c8d7803c 100644 --- a/openlp/plugins/bibles/lib/opensong.py +++ b/openlp/plugins/bibles/lib/opensong.py @@ -129,7 +129,7 @@ class OpenSongBible(BibleDB): self.wizard.incrementProgressBar(translate('BiblesPlugin.Opensong', 'Importing %s %s...', 'Importing ...')) % (db_book.name, chapter_number) self.session.commit() - self.openlp_core.process_events() + self.application.process_events() except etree.XMLSyntaxError as inst: critical_error_message_box(message=translate('BiblesPlugin.OpenSongImport', 'Incorrect Bible file type supplied. OpenSong Bibles may be ' diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index 5996448ad..fe095ab02 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -182,7 +182,7 @@ class OSISBible(BibleDB): .replace(u'', u'').replace(u'', u'') verse_text = self.spaces_regex.sub(u' ', verse_text) self.create_verse(db_book.id, chapter, verse, verse_text) - self.openlp_core.process_events() + self.application.process_events() self.session.commit() if match_count == 0: success = False diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index bc93bf80f..64ba220c0 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -99,7 +99,7 @@ class ImageMediaItem(MediaManagerItem): if check_item_selected(self.listView, translate('ImagePlugin.MediaItem','You must select an image to delete.')): row_list = [item.row() for item in self.listView.selectedIndexes()] row_list.sort(reverse=True) - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() self.main_window.displayProgressBar(len(row_list)) for row in row_list: text = self.listView.item(row) @@ -109,11 +109,11 @@ class ImageMediaItem(MediaManagerItem): self.main_window.incrementProgressBar() SettingsManager.setValue(self.settingsSection + u'/images files', self.getFileList()) self.main_window.finishedProgressBar() - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() self.listView.blockSignals(False) def loadList(self, images, initialLoad=False): - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() if not initialLoad: self.main_window.displayProgressBar(len(images)) # Sort the images by its filename considering language specific @@ -138,7 +138,7 @@ class ImageMediaItem(MediaManagerItem): self.main_window.incrementProgressBar() if not initialLoad: self.main_window.finishedProgressBar() - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() def generateSlideData(self, service_item, item=None, xmlVersion=False, remote=False, context=ServiceItemContext.Service): diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index df772ce5b..ad48a4d8c 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -150,7 +150,7 @@ class PresentationMediaItem(MediaManagerItem): """ currlist = self.getFileList() titles = [os.path.split(file)[1] for file in currlist] - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() if not initialLoad: self.main_window.displayProgressBar(len(files)) # Sort the presentations by its filename considering language specific characters. @@ -207,7 +207,7 @@ class PresentationMediaItem(MediaManagerItem): self.listView.addItem(item_name) if not initialLoad: self.main_window.finishedProgressBar() - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() def onDeleteClick(self): """ @@ -217,7 +217,7 @@ class PresentationMediaItem(MediaManagerItem): items = self.listView.selectedIndexes() row_list = [item.row() for item in items] row_list.sort(reverse=True) - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() self.main_window.displayProgressBar(len(row_list)) for item in items: filepath = unicode(item.data(QtCore.Qt.UserRole)) @@ -227,7 +227,7 @@ class PresentationMediaItem(MediaManagerItem): doc.close_presentation() self.main_window.incrementProgressBar() self.main_window.finishedProgressBar() - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() for row in row_list: self.listView.takeItem(row) Settings().setValue(self.settingsSection + u'/presentations files', self.getFileList()) diff --git a/openlp/plugins/songs/forms/songexportform.py b/openlp/plugins/songs/forms/songexportform.py index d0444913e..2a1564f8b 100644 --- a/openlp/plugins/songs/forms/songexportform.py +++ b/openlp/plugins/songs/forms/songexportform.py @@ -226,7 +226,7 @@ class SongExportForm(OpenLPWizard): self.directoryLineEdit.clear() self.searchLineEdit.clear() # Load the list of songs. - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() songs = self.plugin.manager.get_all_objects(Song) songs.sort(cmp=natcmp, key=lambda song: song.sort_key) for song in songs: @@ -240,7 +240,7 @@ class SongExportForm(OpenLPWizard): item.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled) item.setCheckState(QtCore.Qt.Unchecked) self.availableListWidget.addItem(item) - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() def preWizard(self): """ @@ -248,7 +248,7 @@ class SongExportForm(OpenLPWizard): """ OpenLPWizard.preWizard(self) self.progressLabel.setText(translate('SongsPlugin.ExportWizardForm', 'Starting export...')) - self.openlp_core.process_events() + self.application.process_events() def performWizard(self): """ diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index e6f86de16..9a842f401 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -339,7 +339,7 @@ class SongImportForm(OpenLPWizard): """ OpenLPWizard.preWizard(self) self.progressLabel.setText(WizardStrings.StartingImport) - self.openlp_core.process_events() + self.application.process_events() def performWizard(self): """ diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index e0fc0c6d0..9d0c0c306 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -374,12 +374,12 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): """ Utility method to merge two objects to leave one in the database. """ - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() merge(dbObject) reset() if not self.fromSongEdit: Receiver.send_message(u'songs_load_list') - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() def mergeAuthors(self, oldAuthor): """ @@ -509,12 +509,12 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): deleteButton.setEnabled(True) editButton.setEnabled(True) - def _get_openlp_core(self): + def _get_application(self): """ Adds the openlp to the class dynamically """ - if not hasattr(self, u'_openlp_core'): - self._openlp_core = Registry().get(u'openlp_core') - return self._openlp_core + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application - openlp_core = property(_get_openlp_core) \ No newline at end of file + application = property(_get_application) \ No newline at end of file diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index a8af9f407..883865bb8 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -361,7 +361,7 @@ class SongMediaItem(MediaManagerItem): QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No: return - self.openlp_core.set_busy_cursor() + self.application.set_busy_cursor() self.main_window.displayProgressBar(len(items)) for item in items: item_id = item.data(QtCore.Qt.UserRole) @@ -380,7 +380,7 @@ class SongMediaItem(MediaManagerItem): self.plugin.manager.delete_object(Song, item_id) self.main_window.incrementProgressBar() self.main_window.finishedProgressBar() - self.openlp_core.set_normal_cursor() + self.application.set_normal_cursor() self.onSearchTextButtonClicked() def onCloneClick(self): diff --git a/openlp/plugins/songs/lib/openlyricsexport.py b/openlp/plugins/songs/lib/openlyricsexport.py index 9c1ee3513..b1698418a 100644 --- a/openlp/plugins/songs/lib/openlyricsexport.py +++ b/openlp/plugins/songs/lib/openlyricsexport.py @@ -64,7 +64,7 @@ class OpenLyricsExport(object): openLyrics = OpenLyrics(self.manager) self.parent.progressBar.setMaximum(len(self.songs)) for song in self.songs: - self.openlp_core.process_events() + self.application.process_events() if self.parent.stop_export_flag: return False self.parent.incrementProgressBar(translate('SongsPlugin.OpenLyricsExport', 'Exporting "%s"...') % @@ -81,12 +81,12 @@ class OpenLyricsExport(object): encoding=u'utf-8', xml_declaration=True, pretty_print=True) return True - def _get_openlp_core(self): + def _get_application(self): """ Adds the openlp to the class dynamically """ - if not hasattr(self, u'_openlp_core'): - self._openlp_core = Registry().get(u'openlp_core') - return self._openlp_core + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application - openlp_core = property(_get_openlp_core) + application = property(_get_application) diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 31f38dbf4..937e5b374 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -241,9 +241,9 @@ class SongsPlugin(Plugin): If the first time wizard has run, this function is run to import all the new songs into the database. """ - self.openlp_core.process_events() + self.application.process_events() self.onToolsReindexItemTriggered() - self.openlp_core.process_events() + self.application.process_events() db_dir = unicode(os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp')) if not os.path.exists(db_dir): return @@ -251,12 +251,12 @@ class SongsPlugin(Plugin): song_count = 0 for sfile in os.listdir(db_dir): if sfile.startswith(u'songs_') and sfile.endswith(u'.sqlite'): - self.openlp_core.process_events() + self.application.process_events() song_dbs.append(os.path.join(db_dir, sfile)) song_count += self._countSongs(os.path.join(db_dir, sfile)) if not song_dbs: return - self.openlp_core.process_events() + self.application.process_events() progress = QtGui.QProgressDialog(self.main_window) progress.setWindowModality(QtCore.Qt.WindowModal) progress.setWindowTitle(translate('OpenLP.Ui', 'Importing Songs')) @@ -265,11 +265,11 @@ class SongsPlugin(Plugin): progress.setRange(0, song_count) progress.setMinimumDuration(0) progress.forceShow() - self.openlp_core.process_events() + self.application.process_events() for db in song_dbs: importer = OpenLPSongImport(self.manager, filename=db) importer.doImport(progress) - self.openlp_core.process_events() + self.application.process_events() progress.setValue(song_count) self.mediaItem.onSearchTextButtonClicked() From 17252dafd2f83ad3188a2458640f2b2dc29c0530 Mon Sep 17 00:00:00 2001 From: phill-ridout Date: Mon, 4 Feb 2013 17:47:02 +0000 Subject: [PATCH 49/64] fixes bug 1098075 trunk version --- openlp/plugins/songs/lib/__init__.py | 2 ++ openlp/plugins/songs/lib/ewimport.py | 5 ++++- openlp/plugins/songs/lib/songproimport.py | 5 ++++- openlp/plugins/songs/lib/sundayplusimport.py | 5 ++++- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index 39ecb0ae2..c7c24533b 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -571,6 +571,8 @@ def strip_rtf(text, default_encoding=None): while True: try: encoding, default_encoding = get_encoding(font, font_table, default_encoding, failed=failed) + if not encoding: + return None out.append(chr(charcode).decode(encoding)) except UnicodeDecodeError: failed = True diff --git a/openlp/plugins/songs/lib/ewimport.py b/openlp/plugins/songs/lib/ewimport.py index 3289c0e7f..86fba0562 100644 --- a/openlp/plugins/songs/lib/ewimport.py +++ b/openlp/plugins/songs/lib/ewimport.py @@ -174,7 +174,10 @@ class EasyWorshipSongImport(SongImport): self.addAuthor(author_name.strip()) if words: # Format the lyrics - words, self.encoding = strip_rtf(words, self.encoding) + result = strip_rtf(words, self.encoding) + if result is None: + return + words, self.encoding = result verse_type = VerseType.Tags[VerseType.Verse] for verse in SLIDE_BREAK_REGEX.split(words): verse = verse.strip() diff --git a/openlp/plugins/songs/lib/songproimport.py b/openlp/plugins/songs/lib/songproimport.py index 7556454d8..0e6b5ee97 100644 --- a/openlp/plugins/songs/lib/songproimport.py +++ b/openlp/plugins/songs/lib/songproimport.py @@ -107,7 +107,10 @@ class SongProImport(SongImport): self.finish() return if u'rtf1' in text: - text, self.encoding = strip_rtf(text, self.encoding) + result = strip_rtf(text, self.encoding) + if result is None: + return + text, self.encoding = result text = text.rstrip() if not text: return diff --git a/openlp/plugins/songs/lib/sundayplusimport.py b/openlp/plugins/songs/lib/sundayplusimport.py index 14bac8526..30a33c034 100644 --- a/openlp/plugins/songs/lib/sundayplusimport.py +++ b/openlp/plugins/songs/lib/sundayplusimport.py @@ -148,7 +148,10 @@ class SundayPlusImport(SongImport): verse_type = HOTKEY_TO_VERSE_TYPE[value] if name == 'rtf': value = self.unescape(value) - verse, self.encoding = strip_rtf(value, self.encoding) + result = strip_rtf(value, self.encoding) + if result is None: + return + verse, self.encoding = result lines = verse.strip().split('\n') # If any line inside any verse contains CCLI or # only Public Domain, we treat this as special data: From 86912ec2c3560eaf12dfbc11c460bf2283e06e8f Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 4 Feb 2013 22:22:12 +0100 Subject: [PATCH 50/64] removed not needed imports; removed not needed script --- openlp/core/ui/splashscreen.py | 1 - openlp/plugins/alerts/alertsplugin.py | 2 +- openlp/plugins/alerts/lib/alertstab.py | 1 - openlp/plugins/bibles/bibleplugin.py | 2 +- openlp/plugins/bibles/lib/csvbible.py | 2 +- openlp/plugins/bibles/lib/http.py | 2 +- openlp/plugins/bibles/lib/openlp1.py | 1 - openlp/plugins/custom/forms/editcustomslidedialog.py | 2 +- openlp/plugins/media/lib/mediaitem.py | 2 +- openlp/plugins/media/lib/mediatab.py | 4 +--- openlp/plugins/presentations/lib/mediaitem.py | 2 +- openlp/plugins/presentations/lib/presentationtab.py | 2 +- openlp/plugins/songs/forms/editsongform.py | 2 +- openlp/plugins/songs/forms/editverseform.py | 3 +-- openlp/plugins/songs/lib/test/test_import_file.py | 2 +- openlp/plugins/songs/lib/test/test_importing_lots.py | 6 +----- scripts/translation_utils.py | 3 --- tests/interfaces/openlp_core_ui/test_starttimedialog.py | 1 - 18 files changed, 13 insertions(+), 27 deletions(-) diff --git a/openlp/core/ui/splashscreen.py b/openlp/core/ui/splashscreen.py index d2b41d067..c6f259499 100644 --- a/openlp/core/ui/splashscreen.py +++ b/openlp/core/ui/splashscreen.py @@ -29,7 +29,6 @@ """ The splash screen """ -from openlp.core.lib import Receiver from PyQt4 import QtCore, QtGui diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 29727b79d..7366664ac 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -29,7 +29,7 @@ import logging -from PyQt4 import QtCore, QtGui +from PyQt4 import QtGui from openlp.core.lib import Plugin, StringContent, build_icon, translate, Settings from openlp.core.lib.db import Manager diff --git a/openlp/plugins/alerts/lib/alertstab.py b/openlp/plugins/alerts/lib/alertstab.py index 60451f20c..126c64766 100644 --- a/openlp/plugins/alerts/lib/alertstab.py +++ b/openlp/plugins/alerts/lib/alertstab.py @@ -30,7 +30,6 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import SettingsTab, translate, Receiver, Settings, UiStrings -from openlp.core.ui import AlertLocation from openlp.core.lib.ui import create_valign_selection_widgets class AlertsTab(SettingsTab): diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 9a584dc63..bf5a056eb 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -31,7 +31,7 @@ import logging from PyQt4 import QtGui -from openlp.core.lib import Plugin, StringContent, build_icon, translate, Settings +from openlp.core.lib import Plugin, StringContent, build_icon, translate from openlp.core.lib.ui import create_action, UiStrings from openlp.core.utils.actions import ActionList from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem, LayoutStyle, DisplayStyle, \ diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index 492702fe7..bbf8bd937 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -62,7 +62,7 @@ import logging import chardet import csv -from openlp.core.lib import Receiver, translate +from openlp.core.lib import translate from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB log = logging.getLogger(__name__) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 799c11129..8a7b6e03e 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -38,7 +38,7 @@ from HTMLParser import HTMLParseError from BeautifulSoup import BeautifulSoup, NavigableString, Tag -from openlp.core.lib import Receiver, Registry,translate +from openlp.core.lib import Registry,translate from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import get_web_page from openlp.plugins.bibles.lib import SearchResults diff --git a/openlp/plugins/bibles/lib/openlp1.py b/openlp/plugins/bibles/lib/openlp1.py index 0088c80bd..5100a732f 100644 --- a/openlp/plugins/bibles/lib/openlp1.py +++ b/openlp/plugins/bibles/lib/openlp1.py @@ -31,7 +31,6 @@ import logging import sqlite import sys -from openlp.core.lib import Receiver from openlp.core.ui.wizard import WizardStrings from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB diff --git a/openlp/plugins/custom/forms/editcustomslidedialog.py b/openlp/plugins/custom/forms/editcustomslidedialog.py index ee47ba52b..5dfb79adc 100644 --- a/openlp/plugins/custom/forms/editcustomslidedialog.py +++ b/openlp/plugins/custom/forms/editcustomslidedialog.py @@ -29,7 +29,7 @@ from PyQt4 import QtGui -from openlp.core.lib import translate, SpellTextEdit, build_icon, UiStrings +from openlp.core.lib import translate, SpellTextEdit, UiStrings from openlp.core.lib.ui import create_button, create_button_box class Ui_CustomSlideEditDialog(object): diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index deca81f77..1645164ae 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -32,7 +32,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, SettingsManager, translate, \ +from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, translate, \ check_item_selected, Receiver, MediaType, ServiceItem, ServiceItemContext, Settings, UiStrings, \ check_directory_exists from openlp.core.lib.ui import critical_error_message_box, create_horizontal_adjusting_combo_box diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index 87a56f238..60796d823 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -27,11 +27,9 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtCore, QtGui +from PyQt4 import QtGui from openlp.core.lib import Receiver, Settings, SettingsTab, translate, UiStrings -from openlp.core.lib.ui import create_button -from openlp.core.ui.media import get_media_players, set_media_players class MediaQCheckBox(QtGui.QCheckBox): """ diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index ad48a4d8c..1eb463bdc 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -32,7 +32,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import MediaManagerItem, build_icon, SettingsManager, translate, check_item_selected, Receiver, \ +from openlp.core.lib import MediaManagerItem, build_icon, translate, check_item_selected, Receiver, \ ItemCapabilities, create_thumb, validate_thumb, ServiceItemContext, Settings, UiStrings from openlp.core.lib.ui import critical_error_message_box, create_horizontal_adjusting_combo_box from openlp.core.utils import locale_compare diff --git a/openlp/plugins/presentations/lib/presentationtab.py b/openlp/plugins/presentations/lib/presentationtab.py index c72676860..9e886e5fa 100644 --- a/openlp/plugins/presentations/lib/presentationtab.py +++ b/openlp/plugins/presentations/lib/presentationtab.py @@ -27,7 +27,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtCore, QtGui +from PyQt4 import QtGui from openlp.core.lib import Receiver, Settings, SettingsTab, translate, UiStrings diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 0c0e5c196..0693a3443 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -40,7 +40,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import PluginStatus, Receiver, MediaType, translate, create_separated_list, \ check_directory_exists, Registry, UiStrings -from openlp.core.lib.ui import UiStrings, set_case_insensitive_completer, critical_error_message_box, \ +from openlp.core.lib.ui import set_case_insensitive_completer, critical_error_message_box, \ find_and_set_in_combo_box from openlp.core.utils import AppLocation from openlp.plugins.songs.forms import EditVerseForm, MediaFilesForm diff --git a/openlp/plugins/songs/forms/editverseform.py b/openlp/plugins/songs/forms/editverseform.py index d39f84de2..6e5c0127e 100644 --- a/openlp/plugins/songs/forms/editverseform.py +++ b/openlp/plugins/songs/forms/editverseform.py @@ -32,8 +32,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib.ui import critical_error_message_box -from openlp.plugins.songs.lib import VerseType, translate +from openlp.plugins.songs.lib import VerseType from editversedialog import Ui_EditVerseDialog diff --git a/openlp/plugins/songs/lib/test/test_import_file.py b/openlp/plugins/songs/lib/test/test_import_file.py index 231ca1a21..06d1af38f 100644 --- a/openlp/plugins/songs/lib/test/test_import_file.py +++ b/openlp/plugins/songs/lib/test/test_import_file.py @@ -36,7 +36,7 @@ import logging LOG_FILENAME = 'test_import_file.log' logging.basicConfig(filename=LOG_FILENAME,level=logging.INFO) -from test_opensongimport import wizard_stub, progbar_stub +from test_opensongimport import wizard_stub def test(filenames): manager = Manager(u'songs', init_schema) diff --git a/openlp/plugins/songs/lib/test/test_importing_lots.py b/openlp/plugins/songs/lib/test/test_importing_lots.py index b0e0b34dc..f6bac243b 100644 --- a/openlp/plugins/songs/lib/test/test_importing_lots.py +++ b/openlp/plugins/songs/lib/test/test_importing_lots.py @@ -30,18 +30,14 @@ from openlp.plugins.songs.lib.opensongimport import OpenSongImport from openlp.plugins.songs.lib.db import init_schema from openlp.core.lib.db import Manager -from glob import glob -from zipfile import ZipFile import os -from traceback import print_exc -import sys import codecs import logging LOG_FILENAME = 'import.log' logging.basicConfig(filename=LOG_FILENAME,level=logging.INFO) -from test_opensongimport import wizard_stub, progbar_stub +from test_opensongimport import wizard_stub # Useful test function for importing a variety of different files # Uncomment below depending on what problem trying to make occur! diff --git a/scripts/translation_utils.py b/scripts/translation_utils.py index dc1d47189..e8ad6d64b 100755 --- a/scripts/translation_utils.py +++ b/scripts/translation_utils.py @@ -53,8 +53,6 @@ This is done easily via the ``-d``, ``-p`` and ``-u`` options:: """ import os import urllib2 -import re -from shutil import copy from getpass import getpass import base64 import json @@ -62,7 +60,6 @@ import webbrowser from optparse import OptionParser from PyQt4 import QtCore -from BeautifulSoup import BeautifulSoup SERVER_URL = u'http://www.transifex.net/api/2/project/openlp/' IGNORED_PATHS = [u'scripts'] diff --git a/tests/interfaces/openlp_core_ui/test_starttimedialog.py b/tests/interfaces/openlp_core_ui/test_starttimedialog.py index 918c6637c..990f753ba 100644 --- a/tests/interfaces/openlp_core_ui/test_starttimedialog.py +++ b/tests/interfaces/openlp_core_ui/test_starttimedialog.py @@ -1,7 +1,6 @@ """ Package to test the openlp.core.ui package. """ -import sys from unittest import TestCase from mock import MagicMock, patch From 3df730db09a0098b0d3194e06cad2b2e8ef0a2e4 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 4 Feb 2013 22:26:27 +0100 Subject: [PATCH 51/64] used += instead --- openlp/core/ui/exceptionform.py | 4 ++-- openlp/core/ui/firsttimeform.py | 2 +- openlp/core/ui/mainwindow.py | 2 +- openlp/plugins/bibles/lib/http.py | 6 +++--- openlp/plugins/bibles/lib/versereferencelist.py | 8 ++++---- .../presentations/lib/impresscontroller.py | 4 ++-- openlp/plugins/presentations/lib/mediaitem.py | 2 +- .../plugins/presentations/lib/messagelistener.py | 4 ++-- .../presentations/lib/pptviewlib/ppttest.py | 16 ++++++++-------- openlp/plugins/remotes/lib/remotetab.py | 2 +- openlp/plugins/songs/lib/easyslidesimport.py | 4 ++-- openlp/plugins/songs/lib/songshowplusimport.py | 2 +- 12 files changed, 28 insertions(+), 28 deletions(-) diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index 580e5ae71..2fc0be053 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -141,9 +141,9 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): u'pyUNO bridge: %s\n' % UNO_VERSION if platform.system() == u'Linux': if os.environ.get(u'KDE_FULL_SESSION') == u'true': - system = system + u'Desktop: KDE SC\n' + system += u'Desktop: KDE SC\n' elif os.environ.get(u'GNOME_DESKTOP_SESSION_ID'): - system = system + u'Desktop: GNOME\n' + system += u'Desktop: GNOME\n' return (openlp_version, description, traceback, system, libraries) def onSaveReportButtonClicked(self): diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 29e2cd97a..441d840fa 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -369,7 +369,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): self.max_progress += size if self.max_progress: # Add on 2 for plugins status setting plus a "finished" point. - self.max_progress = self.max_progress + 2 + self.max_progress += 2 self.progressBar.setValue(0) self.progressBar.setMinimum(0) self.progressBar.setMaximum(self.max_progress) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index e1cba9762..532430fad 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -903,7 +903,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): return # Make sure it's a .conf file. if not export_file_name.endswith(u'conf'): - export_file_name = export_file_name + u'.conf' + export_file_name += u'.conf' temp_file = os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp', u'exportConf.tmp') self.saveSettings() diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 8a7b6e03e..affe7a2b6 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -419,18 +419,18 @@ class CWExtract(object): for part in verse.contents: self.application.process_events() if isinstance(part, NavigableString): - verse_text = verse_text + part + verse_text += part elif part and part.attrMap and \ (part.attrMap[u'class'] == u'WordsOfChrist' or part.attrMap[u'class'] == u'strongs'): for subpart in part.contents: self.application.process_events() if isinstance(subpart, NavigableString): - verse_text = verse_text + subpart + verse_text += subpart elif subpart and subpart.attrMap and subpart.attrMap[u'class'] == u'strongs': for subsub in subpart.contents: self.application.process_events() if isinstance(subsub, NavigableString): - verse_text = verse_text + subsub + verse_text += subsub self.application.process_events() # Fix up leading and trailing spaces, multiple spaces, and spaces # between text and , and . diff --git a/openlp/plugins/bibles/lib/versereferencelist.py b/openlp/plugins/bibles/lib/versereferencelist.py index 7b936fdc8..1cb76ffff 100644 --- a/openlp/plugins/bibles/lib/versereferencelist.py +++ b/openlp/plugins/bibles/lib/versereferencelist.py @@ -72,12 +72,12 @@ class VerseReferenceList(object): 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 = result + u', ' + result += u', ' if self.verse_list[prev][u'book'] != verse[u'book']: result = u'%s%s %s:' % (result, verse[u'book'], verse[u'chapter']) elif self.verse_list[prev][u'chapter'] != verse[u'chapter']: result = u'%s%s:' % (result, verse[u'chapter']) - result = result + str(verse[u'start']) + result += str(verse[u'start']) if verse[u'start'] != verse[u'end']: result = u'%s-%s' % (result, verse[u'end']) if len(self.version_list) > 1: @@ -89,8 +89,8 @@ class VerseReferenceList(object): for index, version in enumerate(self.version_list): if index > 0: if result[-1] not in [u';', u',', u'.']: - result = result + u';' - result = result + u' ' + result += u';' + result += u' ' result = u'%s%s, %s' % (result, version[u'version'], version[u'copyright']) if version[u'permission'].strip(): result = result + u', ' + version[u'permission'] diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index c19653b78..5a8106f7d 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -189,7 +189,7 @@ class ImpressController(PresentationController): while list.hasMoreElements(): doc = list.nextElement() if doc.getImplementationName() != u'com.sun.star.comp.framework.BackingComp': - cnt = cnt + 1 + cnt += 1 if cnt > 0: log.debug(u'OpenOffice not terminated as docs are still open') else: @@ -399,7 +399,7 @@ class ImpressDocument(PresentationDocument): i = 1 while not self.control and i < 150: time.sleep(0.1) - i = i + 1 + i += 1 self.control = self.presentation.getController() else: self.control.activate() diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 1eb463bdc..85a21781a 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -269,7 +269,7 @@ class PresentationMediaItem(MediaManagerItem): if img: while img: service_item.add_from_command(path, name, img) - i = i + 1 + i += 1 img = doc.get_thumbnail_path(i, True) doc.close_presentation() return True diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index 3063bfa7b..cde59209a 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -177,7 +177,7 @@ class Controller(object): if not self.doc.is_active(): return if self.doc.slidenumber < self.doc.get_slide_count(): - self.doc.slidenumber = self.doc.slidenumber + 1 + self.doc.slidenumber += 1 self.poll() return if not self.activate(): @@ -203,7 +203,7 @@ class Controller(object): if not self.doc.is_active(): return if self.doc.slidenumber > 1: - self.doc.slidenumber = self.doc.slidenumber - 1 + self.doc.slidenumber -= 1 self.poll() return if not self.activate(): diff --git a/openlp/plugins/presentations/lib/pptviewlib/ppttest.py b/openlp/plugins/presentations/lib/pptviewlib/ppttest.py index 5ec629840..c8573c807 100644 --- a/openlp/plugins/presentations/lib/pptviewlib/ppttest.py +++ b/openlp/plugins/presentations/lib/pptviewlib/ppttest.py @@ -71,35 +71,35 @@ class PPTViewer(QtGui.QWidget): row = 0 grid.addWidget(folder_label, 0, 0) grid.addWidget(self.folderEdit, 0, 1) - row = row + 1 + row += 1 grid.addWidget(x_label, row, 0) grid.addWidget(self.xEdit, row, 1) grid.addWidget(y_label, row, 2) grid.addWidget(self.yEdit, row, 3) - row = row + 1 + row += 1 grid.addWidget(width_label, row, 0) grid.addWidget(self.widthEdit, row, 1) grid.addWidget(height_label, row, 2) grid.addWidget(self.heightEdit, row, 3) - row = row + 1 + row += 1 grid.addWidget(ppt_label, row, 0) grid.addWidget(self.pptEdit, row, 1) grid.addWidget(ppt_dlg_btn, row, 2) grid.addWidget(ppt_btn, row, 3) - row = row + 1 + row += 1 grid.addWidget(slide_label, row, 0) grid.addWidget(self.slideEdit, row, 1) grid.addWidget(slide_btn, row, 2) - row = row + 1 + row += 1 grid.addWidget(prev, row, 0) grid.addWidget(next, row, 1) - row = row + 1 + row += 1 grid.addWidget(blank, row, 0) grid.addWidget(unblank, row, 1) - row = row + 1 + row += 1 grid.addWidget(restart, row, 0) grid.addWidget(close, row, 1) - row = row + 1 + row += 1 grid.addWidget(stop, row, 0) grid.addWidget(resume, row, 1) self.connect(ppt_btn, QtCore.SIGNAL(u'clicked()'), self.openClick) diff --git a/openlp/plugins/remotes/lib/remotetab.py b/openlp/plugins/remotes/lib/remotetab.py index 1d28355c4..c3ccd46c5 100644 --- a/openlp/plugins/remotes/lib/remotetab.py +++ b/openlp/plugins/remotes/lib/remotetab.py @@ -133,7 +133,7 @@ class RemoteTab(SettingsTab): ipAddress = self.addressEdit.text() url = u'http://%s:%s/' % (ipAddress, self.portSpinBox.value()) self.remoteUrl.setText(u'%s' % (url, url)) - url = url + u'stage' + url += u'stage' self.stageUrl.setText(u'%s' % (url, url)) def load(self): diff --git a/openlp/plugins/songs/lib/easyslidesimport.py b/openlp/plugins/songs/lib/easyslidesimport.py index 207628b9f..7f9143b70 100644 --- a/openlp/plugins/songs/lib/easyslidesimport.py +++ b/openlp/plugins/songs/lib/easyslidesimport.py @@ -162,7 +162,7 @@ class EasySlidesImport(SongImport): region = self._extractRegion(line) regionlines[region] = 1 + regionlines.get(region, 0) elif line[0] == u'[': - separatorlines = separatorlines + 1 + separatorlines += 1 # if the song has separators separators = (separatorlines > 0) # the number of different regions in song - 1 @@ -200,7 +200,7 @@ class EasySlidesImport(SongImport): # separators are used, so empty line means slide break # inside verse if self._listHas(verses, [reg, vt, vn, inst]): - inst = inst + 1 + inst += 1 else: # separators are not used, so empty line starts a new verse vt = u'V' diff --git a/openlp/plugins/songs/lib/songshowplusimport.py b/openlp/plugins/songs/lib/songshowplusimport.py index ae7e403f7..8677c82c2 100644 --- a/openlp/plugins/songs/lib/songshowplusimport.py +++ b/openlp/plugins/songs/lib/songshowplusimport.py @@ -203,7 +203,7 @@ class SongShowPlusImport(SongImport): if verse_name not in self.otherList: if ignore_unique: return None - self.otherCount = self.otherCount + 1 + self.otherCount += 1 self.otherList[verse_name] = str(self.otherCount) verse_tag = VerseType.Tags[VerseType.Other] verse_number = self.otherList[verse_name] From a72b4283bf9d72e3e8b9d9ba262e85f6dc87e3c2 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 4 Feb 2013 22:27:50 +0100 Subject: [PATCH 52/64] removed mutable as parameters --- openlp/core/lib/ui.py | 4 +++- openlp/plugins/remotes/lib/httpserver.py | 4 +++- openlp/plugins/songs/lib/sundayplusimport.py | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 0d869d724..c6860d7cd 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -67,7 +67,7 @@ def add_welcome_page(parent, image): parent.addPage(parent.welcomePage) -def create_button_box(dialog, name, standard_buttons, custom_buttons=[]): +def create_button_box(dialog, name, standard_buttons, custom_buttons=None): """ Creates a QDialogButtonBox with the given buttons. The ``accepted()`` and ``rejected()`` signals of the button box are connected with the dialogs @@ -88,6 +88,8 @@ def create_button_box(dialog, name, standard_buttons, custom_buttons=[]): QtGui.QAbstractButton it is added with QDialogButtonBox.ActionRole. Otherwhise the item has to be a tuple of a button and a ButtonRole. """ + if custom_buttons is None: + custom_buttons = [] buttons = QtGui.QDialogButtonBox.NoButton if u'ok' in standard_buttons: buttons |= QtGui.QDialogButtonBox.Ok diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index af12cc9c4..d444fc1c4 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -138,7 +138,9 @@ class HttpResponse(object): 'Content-Type': 'text/html; charset="utf-8"\r\n' } - def __init__(self, content='', headers={}, code=None): + def __init__(self, content='', headers=None, code=None): + if headers is None: + headers = {} self.content = content for key, value in headers.iteritems(): self.headers[key] = value diff --git a/openlp/plugins/songs/lib/sundayplusimport.py b/openlp/plugins/songs/lib/sundayplusimport.py index 14bac8526..bfa03b24e 100644 --- a/openlp/plugins/songs/lib/sundayplusimport.py +++ b/openlp/plugins/songs/lib/sundayplusimport.py @@ -121,7 +121,7 @@ class SundayPlusImport(SongImport): end = data.find(')', i) + 1 value = data[i:end] # If we are in the main group. - if cell == False: + if not cell: if name == 'title': self.title = self.decode(self.unescape(value)) elif name == 'Author': From 8f5fe64d3e442875e5ccc9f50a80838e49063f8f Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 4 Feb 2013 22:39:44 +0100 Subject: [PATCH 53/64] fixed short lines --- openlp/core/lib/db.py | 3 +- openlp/core/lib/screen.py | 6 ++-- openlp/plugins/bibles/lib/http.py | 46 ++++++++++--------------------- 3 files changed, 18 insertions(+), 37 deletions(-) diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index 5601fa530..398e8c29c 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -61,8 +61,7 @@ def init_db(url, auto_flush=True, auto_commit=False): """ engine = create_engine(url, poolclass=NullPool) metadata = MetaData(bind=engine) - session = scoped_session(sessionmaker(autoflush=auto_flush, - autocommit=auto_commit, bind=engine)) + session = scoped_session(sessionmaker(autoflush=auto_flush, autocommit=auto_commit, bind=engine)) return session, metadata diff --git a/openlp/core/lib/screen.py b/openlp/core/lib/screen.py index 9c118de99..c0272ff81 100644 --- a/openlp/core/lib/screen.py +++ b/openlp/core/lib/screen.py @@ -139,8 +139,7 @@ class ScreenList(object): """ screen_list = [] for screen in self.screen_list: - screen_name = u'%s %d' % (translate('OpenLP.ScreenList', 'Screen'), - screen[u'number'] + 1) + screen_name = u'%s %d' % (translate('OpenLP.ScreenList', 'Screen'), screen[u'number'] + 1) if screen[u'primary']: screen_name = u'%s (%s)' % (screen_name, translate('OpenLP.ScreenList', 'primary')) screen_list.append(screen_name) @@ -237,8 +236,7 @@ class ScreenList(object): y = window.y() + (window.height() / 2) for screen in self.screen_list: size = screen[u'size'] - if x >= size.x() and x <= (size.x() + size.width()) and \ - y >= size.y() and y <= (size.y() + size.height()): + if x >= size.x() and x <= (size.x() + size.width()) and y >= size.y() and y <= (size.y() + size.height()): return screen[u'number'] def load_screen_settings(self): diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index affe7a2b6..13906375d 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -203,8 +203,7 @@ class BGExtract(object): if clean_verse_num: verse_text = raw_verse_num.next part = raw_verse_num.next.next - while not (isinstance(part, Tag) and - part.get(u'class') == u'versenum'): + while not (isinstance(part, Tag) and part.get(u'class') == u'versenum'): # While we are still in the same verse grab all the text. if isinstance(part, NavigableString): verse_text += part @@ -320,12 +319,10 @@ class BSExtract(object): ``chapter`` Chapter number """ - log.debug(u'BSExtract.get_bible_chapter("%s", "%s", "%s")', version, - book_name, chapter) + log.debug(u'BSExtract.get_bible_chapter("%s", "%s", "%s")', version, book_name, chapter) url_version = urllib.quote(version.encode("utf-8")) url_book_name = urllib.quote(book_name.encode("utf-8")) - chapter_url = u'http://m.bibleserver.com/text/%s/%s%d' % \ - (url_version, url_book_name, chapter) + chapter_url = u'http://m.bibleserver.com/text/%s/%s%d' % (url_version, url_book_name, chapter) header = (u'Accept-Language', u'en') soup = get_soup_for_bible_ref(chapter_url, header) if not soup: @@ -355,8 +352,7 @@ class BSExtract(object): """ log.debug(u'BSExtract.get_books_from_http("%s")', version) urlversion = urllib.quote(version.encode("utf-8")) - chapter_url = u'http://m.bibleserver.com/overlay/selectBook?'\ - 'translation=%s' % (urlversion) + chapter_url = u'http://m.bibleserver.com/overlay/selectBook?translation=%s' % (urlversion) soup = get_soup_for_bible_ref(chapter_url) if not soup: return None @@ -366,9 +362,7 @@ class BSExtract(object): send_error_message(u'parse') return None content = content.findAll(u'li') - return [ - book.contents[0].contents[0] for book in content - ] + return [book.contents[0].contents[0] for book in content] class CWExtract(object): @@ -393,13 +387,11 @@ class CWExtract(object): ``chapter`` Chapter number """ - log.debug(u'CWExtract.get_bible_chapter("%s", "%s", "%s")', version, - book_name, chapter) + log.debug(u'CWExtract.get_bible_chapter("%s", "%s", "%s")', version, book_name, chapter) url_book_name = book_name.replace(u' ', u'-') url_book_name = url_book_name.lower() url_book_name = urllib.quote(url_book_name.encode("utf-8")) - chapter_url = u'http://www.biblestudytools.com/%s/%s/%s.html' % \ - (version, url_book_name, chapter) + chapter_url = u'http://www.biblestudytools.com/%s/%s/%s.html' % (version, url_book_name, chapter) soup = get_soup_for_bible_ref(chapter_url) if not soup: return None @@ -448,8 +440,7 @@ class CWExtract(object): The version of the bible like NIV for New International Version """ log.debug(u'CWExtract.get_books_from_http("%s")', version) - chapter_url = u'http://www.biblestudytools.com/%s/'\ - % (version) + chapter_url = u'http://www.biblestudytools.com/%s/' % (version) soup = get_soup_for_bible_ref(chapter_url) if not soup: return None @@ -503,9 +494,7 @@ class HTTPBible(BibleDB): ``True`` on success, ``False`` on failure. """ self.wizard.progressBar.setMaximum(68) - self.wizard.incrementProgressBar(translate( - 'BiblesPlugin.HTTPBible', - 'Registering Bible and loading books...')) + self.wizard.incrementProgressBar(translate('BiblesPlugin.HTTPBible', 'Registering Bible and loading books...')) self.save_meta(u'download_source', self.download_source) self.save_meta(u'download_name', self.download_name) if self.proxy_server: @@ -527,19 +516,16 @@ class HTTPBible(BibleDB): log.exception(u'Importing books from %s - download name: "%s" '\ 'failed' % (self.download_source, self.download_name)) return False - self.wizard.progressBar.setMaximum(len(books)+2) - self.wizard.incrementProgressBar(translate( - 'BiblesPlugin.HTTPBible', 'Registering Language...')) - bible = BiblesResourcesDB.get_webbible(self.download_name, - self.download_source.lower()) + self.wizard.progressBar.setMaximum(len(books) + 2) + self.wizard.incrementProgressBar(translate( 'BiblesPlugin.HTTPBible', 'Registering Language...')) + bible = BiblesResourcesDB.get_webbible(self.download_name, self.download_source.lower()) if bible[u'language_id']: language_id = bible[u'language_id'] self.save_meta(u'language_id', language_id) else: language_id = self.get_language(bible_name) if not language_id: - log.exception(u'Importing books from %s " '\ - 'failed' % self.filename) + log.exception(u'Importing books from %s failed' % self.filename) return False for book in books: if self.stop_import_flag: @@ -547,8 +533,7 @@ class HTTPBible(BibleDB): self.wizard.incrementProgressBar(translate( 'BiblesPlugin.HTTPBible', 'Importing %s...', 'Importing ...') % book) - book_ref_id = self.get_book_ref_id_by_name(book, len(books), - language_id) + book_ref_id = self.get_book_ref_id_by_name(book, len(books), language_id) if not book_ref_id: log.exception(u'Importing books from %s - download name: "%s" '\ 'failed' % (self.download_source, self.download_name)) @@ -608,8 +593,7 @@ class HTTPBible(BibleDB): self.application.process_events() # Check to see if book/chapter exists. db_book = self.get_book(book_name) - self.create_chapter(db_book.id, search_results.chapter, - search_results.verselist) + self.create_chapter(db_book.id, search_results.chapter, search_results.verselist) self.application.process_events() self.application.set_normal_cursor() self.application.process_events() From 8a36430659c255952205360124e2039c0cb31d62 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 4 Feb 2013 22:42:31 +0100 Subject: [PATCH 54/64] removed not needed script --- scripts/openlp-remoteclient.py | 70 ---------------------------------- 1 file changed, 70 deletions(-) delete mode 100644 scripts/openlp-remoteclient.py diff --git a/scripts/openlp-remoteclient.py b/scripts/openlp-remoteclient.py deleted file mode 100644 index d29ddd501..000000000 --- a/scripts/openlp-remoteclient.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2013 Raoul Snyman # -# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan # -# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # -# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # -# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # -# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # -# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # -# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### - -import urllib -import sys -from optparse import OptionParser - -def sendData(options): - addr = 'http://%s:%s/send/%s?q=%s' % (options.address, options.port, - options.event, options.message) - try: - urllib.urlopen(addr) - print u'Message sent ', addr - except: - print u'Error thrown ', sys.exc_info()[1] - -def main(): - usage = "usage: %prog [-a address] [-p port] [-e event] [-m message]" - parser = OptionParser(usage=usage) - parser.add_option("-p", "--port", default=4316, - help="IP Port number %default ") - parser.add_option("-a", "--address", - help="Recipient address ", - default="localhost") - parser.add_option("-e", "--event", - help="Action to be performed", - default="alerts_text") - parser.add_option("-m", "--message", - help="Message to be passed for the action", - default="") - - (options, args) = parser.parse_args() - if args: - parser.print_help() - parser.error("incorrect number of arguments") - elif options.address is None: - parser.print_help() - parser.error("IP address missing") - else: - sendData(options) - -if __name__ == u'__main__': - main() From 7cf10df7e88ce634c06be53ae414bb1025d4d68f Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 4 Feb 2013 23:05:19 +0100 Subject: [PATCH 55/64] converted print statements --- openlp/core/__init__.py | 2 +- scripts/translation_utils.py | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 33eb916be..f6ce8bb06 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -242,7 +242,7 @@ def set_up_logging(log_path): logfile.setFormatter(logging.Formatter(u'%(asctime)s %(name)-55s %(levelname)-8s %(message)s')) log.addHandler(logfile) if log.isEnabledFor(logging.DEBUG): - print 'Logging to:', filename + print('Logging to: %s' % filename) def main(args=None): diff --git a/scripts/translation_utils.py b/scripts/translation_utils.py index e8ad6d64b..40000946d 100755 --- a/scripts/translation_utils.py +++ b/scripts/translation_utils.py @@ -159,7 +159,7 @@ def print_verbose(text): """ global verbose_mode, quiet_mode if not quiet_mode and verbose_mode: - print u' %s' % text + print(u' %s' % text) def run(command): """ @@ -266,8 +266,7 @@ def prepare_project(): def update_translations(): print_quiet(u'Update the translation files') if not os.path.exists(os.path.join(os.path.abspath(u'..'), u'openlp.pro')): - print u'You have not generated a project file yet, please run this ' + \ - u'script with the -p option.' + print(u'You have not generated a project file yet, please run this script with the -p option.') return else: os.chdir(os.path.abspath(u'..')) @@ -277,10 +276,8 @@ def update_translations(): def generate_binaries(): print_quiet(u'Generate the related *.qm files') if not os.path.exists(os.path.join(os.path.abspath(u'..'), u'openlp.pro')): - print u'You have not generated a project file yet, please run this ' + \ - u'script with the -p option. It is also recommended that you ' + \ - u'this script with the -u option to update the translation ' + \ - u'files as well.' + print(u'You have not generated a project file yet, please run this script with the -p option. It is also ' + + u'recommended that you this script with the -u option to update the translation files as well.') return else: os.chdir(os.path.abspath(u'..')) @@ -380,6 +377,6 @@ def main(): if __name__ == u'__main__': if os.path.split(os.path.abspath(u'.'))[1] != u'scripts': - print u'You need to run this script from the scripts directory.' + print(u'You need to run this script from the scripts directory.') else: main() From f94da5c22c5ae7e2be974adc62d01beb260aad6e Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 5 Feb 2013 07:47:03 +0100 Subject: [PATCH 56/64] fixed spaces --- openlp/plugins/alerts/alertsplugin.py | 2 +- openlp/plugins/bibles/lib/csvbible.py | 2 +- openlp/plugins/bibles/lib/http.py | 2 +- openlp/plugins/media/lib/mediatab.py | 2 +- openlp/plugins/presentations/lib/presentationtab.py | 2 +- openlp/plugins/songs/forms/editsongform.py | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 7366664ac..1c9203348 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -29,7 +29,7 @@ import logging -from PyQt4 import QtGui +from PyQt4 import QtGui from openlp.core.lib import Plugin, StringContent, build_icon, translate, Settings from openlp.core.lib.db import Manager diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index bbf8bd937..4f491c5cc 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -62,7 +62,7 @@ import logging import chardet import csv -from openlp.core.lib import translate +from openlp.core.lib import translate from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB log = logging.getLogger(__name__) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 13906375d..20ab70ade 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -38,7 +38,7 @@ from HTMLParser import HTMLParseError from BeautifulSoup import BeautifulSoup, NavigableString, Tag -from openlp.core.lib import Registry,translate +from openlp.core.lib import Registrytranslate from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import get_web_page from openlp.plugins.bibles.lib import SearchResults diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index 60796d823..d874686a6 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -27,7 +27,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtGui +from PyQt4 import QtGui from openlp.core.lib import Receiver, Settings, SettingsTab, translate, UiStrings diff --git a/openlp/plugins/presentations/lib/presentationtab.py b/openlp/plugins/presentations/lib/presentationtab.py index 9e886e5fa..06cd84568 100644 --- a/openlp/plugins/presentations/lib/presentationtab.py +++ b/openlp/plugins/presentations/lib/presentationtab.py @@ -27,7 +27,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtGui +from PyQt4 import QtGui from openlp.core.lib import Receiver, Settings, SettingsTab, translate, UiStrings diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 0693a3443..f31b487e1 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -40,7 +40,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import PluginStatus, Receiver, MediaType, translate, create_separated_list, \ check_directory_exists, Registry, UiStrings -from openlp.core.lib.ui import set_case_insensitive_completer, critical_error_message_box, \ +from openlp.core.lib.ui import set_case_insensitive_completer, critical_error_message_box, \ find_and_set_in_combo_box from openlp.core.utils import AppLocation from openlp.plugins.songs.forms import EditVerseForm, MediaFilesForm From 682460132c988f282bd4cd68cc2130430d1ef498 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 5 Feb 2013 07:54:55 +0100 Subject: [PATCH 57/64] search and replace does evil things --- openlp/plugins/bibles/lib/http.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 20ab70ade..17791cef3 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -38,7 +38,7 @@ from HTMLParser import HTMLParseError from BeautifulSoup import BeautifulSoup, NavigableString, Tag -from openlp.core.lib import Registrytranslate +from openlp.core.lib import Registry, translate from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import get_web_page from openlp.plugins.bibles.lib import SearchResults From f94ae4d7c248880fb26238780e72182b1ff7c22c Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 5 Feb 2013 09:05:28 +0100 Subject: [PATCH 58/64] reordered imports --- openlp/core/lib/dockwidget.py | 2 +- openlp/core/lib/formattingtags.py | 2 +- openlp/core/lib/imagemanager.py | 2 +- openlp/core/lib/renderer.py | 4 ++-- openlp/core/lib/serviceitem.py | 2 +- openlp/core/lib/ui.py | 2 +- openlp/core/ui/aboutdialog.py | 2 +- openlp/core/ui/advancedtab.py | 14 +++++++------- openlp/core/ui/exceptionform.py | 2 +- openlp/core/ui/firsttimeform.py | 4 ++-- openlp/core/ui/formattingtagdialog.py | 2 +- openlp/core/ui/formattingtagform.py | 2 +- openlp/core/ui/generaltab.py | 2 +- openlp/core/ui/maindisplay.py | 4 ++-- openlp/core/ui/mainwindow.py | 6 +++--- openlp/core/ui/media/mediacontroller.py | 4 ++-- openlp/core/ui/media/phononplayer.py | 2 +- openlp/core/ui/media/playertab.py | 2 +- openlp/core/ui/media/vlcplayer.py | 2 +- openlp/core/ui/media/webkitplayer.py | 2 +- openlp/core/ui/plugindialog.py | 2 +- openlp/core/ui/printservicedialog.py | 2 +- openlp/core/ui/printserviceform.py | 4 ++-- openlp/core/ui/servicemanager.py | 4 ++-- openlp/core/ui/servicenoteform.py | 4 ++-- openlp/core/ui/settingsform.py | 4 ++-- openlp/core/ui/slidecontroller.py | 6 +++--- openlp/core/ui/starttimedialog.py | 2 +- openlp/core/ui/starttimeform.py | 4 ++-- openlp/core/ui/themeform.py | 2 +- openlp/core/ui/thememanager.py | 8 ++++---- openlp/core/ui/themestab.py | 2 +- openlp/core/ui/themewizard.py | 2 +- openlp/core/ui/wizard.py | 4 ++-- openlp/core/utils/languagemanager.py | 2 +- openlp/plugins/alerts/alertsplugin.py | 2 +- openlp/plugins/alerts/lib/alertstab.py | 2 +- openlp/plugins/bibles/bibleplugin.py | 2 +- openlp/plugins/bibles/forms/bibleimportform.py | 2 +- openlp/plugins/bibles/forms/bibleupgradeform.py | 2 +- openlp/plugins/bibles/forms/editbibleform.py | 2 +- openlp/plugins/bibles/lib/__init__.py | 2 +- openlp/plugins/bibles/lib/biblestab.py | 2 +- openlp/plugins/bibles/lib/db.py | 4 ++-- openlp/plugins/bibles/lib/manager.py | 2 +- openlp/plugins/bibles/lib/mediaitem.py | 4 ++-- openlp/plugins/custom/forms/editcustomdialog.py | 2 +- .../plugins/custom/forms/editcustomslidedialog.py | 2 +- openlp/plugins/custom/lib/customtab.py | 2 +- openlp/plugins/custom/lib/mediaitem.py | 4 ++-- openlp/plugins/images/imageplugin.py | 2 +- openlp/plugins/images/lib/imagetab.py | 2 +- openlp/plugins/images/lib/mediaitem.py | 6 +++--- openlp/plugins/media/lib/mediaitem.py | 5 ++--- openlp/plugins/media/lib/mediatab.py | 2 +- openlp/plugins/media/mediaplugin.py | 2 +- openlp/plugins/presentations/lib/mediaitem.py | 4 ++-- .../presentations/lib/presentationcontroller.py | 2 +- .../plugins/presentations/lib/presentationtab.py | 2 +- openlp/plugins/remotes/lib/remotetab.py | 2 +- openlp/plugins/songs/forms/editsongdialog.py | 2 +- openlp/plugins/songs/forms/editsongform.py | 6 +++--- openlp/plugins/songs/forms/editversedialog.py | 4 ++-- openlp/plugins/songs/forms/songexportform.py | 2 +- openlp/plugins/songs/forms/songimportform.py | 2 +- .../plugins/songs/forms/songmaintenancedialog.py | 2 +- openlp/plugins/songs/forms/songmaintenanceform.py | 4 ++-- openlp/plugins/songs/lib/mediaitem.py | 4 ++-- openlp/plugins/songs/lib/xml.py | 2 +- openlp/plugins/songs/songsplugin.py | 2 +- .../plugins/songusage/forms/songusagedeleteform.py | 2 +- openlp/plugins/songusage/songusageplugin.py | 2 +- 72 files changed, 107 insertions(+), 108 deletions(-) diff --git a/openlp/core/lib/dockwidget.py b/openlp/core/lib/dockwidget.py index 743607dd6..c7fa0e6eb 100644 --- a/openlp/core/lib/dockwidget.py +++ b/openlp/core/lib/dockwidget.py @@ -35,7 +35,7 @@ import logging from PyQt4 import QtGui -from openlp.core.lib import build_icon, ScreenList +from openlp.core.lib import ScreenList, build_icon log = logging.getLogger(__name__) diff --git a/openlp/core/lib/formattingtags.py b/openlp/core/lib/formattingtags.py index abbc18f16..b7bbd7322 100644 --- a/openlp/core/lib/formattingtags.py +++ b/openlp/core/lib/formattingtags.py @@ -31,7 +31,7 @@ Provide HTML Tag management and Formatting Tag access class """ import cPickle -from openlp.core.lib import translate, Settings +from openlp.core.lib import Settings, translate class FormattingTags(object): diff --git a/openlp/core/lib/imagemanager.py b/openlp/core/lib/imagemanager.py index 9726079f7..7d738a664 100644 --- a/openlp/core/lib/imagemanager.py +++ b/openlp/core/lib/imagemanager.py @@ -39,7 +39,7 @@ import Queue from PyQt4 import QtCore -from openlp.core.lib import resize_image, image_to_byte, Receiver, Registry, ScreenList +from openlp.core.lib import Receiver, Registry, ScreenList, resize_image, image_to_byte log = logging.getLogger(__name__) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 7b7027efd..ca2a3b073 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -31,8 +31,8 @@ import logging from PyQt4 import QtGui, QtCore, QtWebKit -from openlp.core.lib import ServiceItem, expand_tags, build_lyrics_format_css, build_lyrics_outline_css, Receiver, \ - ItemCapabilities, FormattingTags, ImageSource, Registry, ScreenList +from openlp.core.lib import FormattingTags, ImageSource, ItemCapabilities, Receiver, Registry, ScreenList, \ + ServiceItem, expand_tags, build_lyrics_format_css, build_lyrics_outline_css from openlp.core.lib.theme import ThemeLevel from openlp.core.ui import MainDisplay diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 743f6b00a..47c9852a8 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -39,7 +39,7 @@ import uuid from PyQt4 import QtGui -from openlp.core.lib import build_icon, clean_tags, expand_tags, translate, ImageSource, Settings, Registry +from openlp.core.lib import ImageSource, Settings, Registry, build_icon, clean_tags, expand_tags, translate log = logging.getLogger(__name__) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index c6860d7cd..4f4aa0596 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -33,7 +33,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, translate, Receiver, UiStrings +from openlp.core.lib import Receiver, UiStrings, build_icon, translate from openlp.core.utils.actions import ActionList diff --git a/openlp/core/ui/aboutdialog.py b/openlp/core/ui/aboutdialog.py index cf04f4927..0115d8af2 100644 --- a/openlp/core/ui/aboutdialog.py +++ b/openlp/core/ui/aboutdialog.py @@ -29,7 +29,7 @@ from PyQt4 import QtGui -from openlp.core.lib import build_icon, translate, UiStrings +from openlp.core.lib import UiStrings, build_icon, translate from openlp.core.lib.ui import create_button, create_button_box diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 08a98d918..7cd89c252 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -37,7 +37,7 @@ import sys from PyQt4 import QtCore, QtGui from openlp.core.lib import SettingsTab, Receiver, Settings, UiStrings, translate, build_icon -from openlp.core.utils import get_images_filter, AppLocation, format_time +from openlp.core.utils import AppLocation, format_time, get_images_filter from openlp.core.lib import SlideLimits log = logging.getLogger(__name__) @@ -449,7 +449,7 @@ class AdvancedTab(SettingsTab): settings.setValue(u'enable exit confirmation', self.enable_auto_close_check_box.isChecked()) settings.setValue(u'hide mouse', self.hide_mouse_check_box.isChecked()) settings.setValue(u'x11 bypass wm', self.x11_bypass_check_box.isChecked()) - settings.setValue(u'alternate rows', self.alternate_rows_check_box.isChecked()) + settings.setValue(u'alternate rows', self.alternate_rows_check_box.isChecked()) settings.setValue(u'default color', self.default_color) settings.setValue(u'default image', self.default_file_edit.text()) settings.setValue(u'slide limits', self.slide_limits) @@ -666,7 +666,7 @@ class AdvancedTab(SettingsTab): The state of the check box (boolean). """ self.display_changed = True - + def on_alternate_rows_check_box_toggled(self, checked): """ Notify user about required restart. @@ -681,17 +681,17 @@ class AdvancedTab(SettingsTab): def on_end_slide_button_clicked(self): """ Stop at the end either top ot bottom - """ + """ self.slide_limits = SlideLimits.End def on_wrap_slide_button_clicked(self): """ - Wrap round the service item - """ + Wrap round the service item + """ self.slide_limits = SlideLimits.Wrap def on_next_item_button_clicked(self): """ Advance to the next service item - """ + """ self.slide_limits = SlideLimits.Next diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index 2fc0be053..0d8a7c74f 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -88,7 +88,7 @@ except AttributeError: WEBKIT_VERSION = u'-' -from openlp.core.lib import translate, UiStrings, Settings +from openlp.core.lib import UiStrings, Settings, translate from openlp.core.utils import get_application_version from exceptiondialog import Ui_ExceptionDialog diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 441d840fa..daedbb94e 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -41,8 +41,8 @@ from ConfigParser import SafeConfigParser from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, PluginStatus, Receiver, build_icon, check_directory_exists, Settings, Registry -from openlp.core.utils import get_web_page, AppLocation, get_filesystem_encoding +from openlp.core.lib import PluginStatus, Receiver, Settings, Registry, build_icon, check_directory_exists, translate +from openlp.core.utils import AppLocation, get_web_page, get_filesystem_encoding from firsttimewizard import Ui_FirstTimeWizard, FirstTimePage log = logging.getLogger(__name__) diff --git a/openlp/core/ui/formattingtagdialog.py b/openlp/core/ui/formattingtagdialog.py index fbf5707ed..8c72a9120 100644 --- a/openlp/core/ui/formattingtagdialog.py +++ b/openlp/core/ui/formattingtagdialog.py @@ -31,7 +31,7 @@ The UI widgets for the formatting tags window. """ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, UiStrings +from openlp.core.lib import UiStrings, translate from openlp.core.lib.ui import create_button_box diff --git a/openlp/core/ui/formattingtagform.py b/openlp/core/ui/formattingtagform.py index 1085afbcd..b3611b1d7 100644 --- a/openlp/core/ui/formattingtagform.py +++ b/openlp/core/ui/formattingtagform.py @@ -33,7 +33,7 @@ cannot be changed. """ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, FormattingTags +from openlp.core.lib import FormattingTags, translate from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui.formattingtagdialog import Ui_FormattingTagDialog diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 4626d36d2..e88ae2b15 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -33,7 +33,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, Settings, SettingsTab, translate, ScreenList, UiStrings +from openlp.core.lib import Receiver, Settings, SettingsTab, ScreenList, UiStrings, translate log = logging.getLogger(__name__) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 9cae5dfac..badf55548 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -42,8 +42,8 @@ import sys from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL from PyQt4.phonon import Phonon -from openlp.core.lib import Receiver, build_html, ServiceItem, image_to_byte, translate, expand_tags,\ - Settings, ImageSource, Registry +from openlp.core.lib import Receiver, ServiceItem, Settings, ImageSource, Registry, build_html, expand_tags, \ + image_to_byte, translate from openlp.core.lib.theme import BackgroundType from openlp.core.lib import ScreenList diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 532430fad..404103d58 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -41,13 +41,13 @@ from datetime import datetime from PyQt4 import QtCore, QtGui -from openlp.core.lib import Renderer, build_icon, OpenLPDockWidget, PluginManager, Receiver, translate, ImageManager, \ - PluginStatus, Registry, Settings, ScreenList +from openlp.core.lib import Renderer, OpenLPDockWidget, PluginManager, Receiver, ImageManager, PluginStatus, Registry, \ + Settings, ScreenList, build_icon, translate from openlp.core.lib.ui import UiStrings, create_action from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, ThemeManager, SlideController, PluginForm, \ MediaDockManager, ShortcutListForm, FormattingTagForm from openlp.core.ui.media import MediaController -from openlp.core.utils import AppLocation, add_actions, LanguageManager, get_application_version, \ +from openlp.core.utils import AppLocation, LanguageManager, add_actions, get_application_version, \ get_filesystem_encoding from openlp.core.utils.actions import ActionList, CategoryOrder from openlp.core.ui.firsttimeform import FirstTimeForm diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 6d0c002de..73cd5b263 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -35,7 +35,7 @@ import os import datetime from PyQt4 import QtCore, QtGui -from openlp.core.lib import OpenLPToolbar, Receiver, translate, Settings, Registry, UiStrings +from openlp.core.lib import OpenLPToolbar, Receiver, Settings, Registry, UiStrings, translate from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui.media import MediaState, MediaInfo, MediaType, get_media_players, set_media_players from openlp.core.ui.media.mediaplayer import MediaPlayer @@ -750,4 +750,4 @@ class MediaController(object): self._service_manager = Registry().get(u'service_manager') return self._service_manager - service_manager = property(_get_service_manager) \ No newline at end of file + service_manager = property(_get_service_manager) diff --git a/openlp/core/ui/media/phononplayer.py b/openlp/core/ui/media/phononplayer.py index ede7b2169..267466a98 100644 --- a/openlp/core/ui/media/phononplayer.py +++ b/openlp/core/ui/media/phononplayer.py @@ -36,7 +36,7 @@ from datetime import datetime from PyQt4 import QtGui from PyQt4.phonon import Phonon -from openlp.core.lib import translate, Settings +from openlp.core.lib import Settings, translate from openlp.core.ui.media import MediaState from openlp.core.ui.media.mediaplayer import MediaPlayer diff --git a/openlp/core/ui/media/playertab.py b/openlp/core/ui/media/playertab.py index cfa274d0c..c2224369a 100644 --- a/openlp/core/ui/media/playertab.py +++ b/openlp/core/ui/media/playertab.py @@ -31,7 +31,7 @@ The :mod:`~openlp.core.ui.media.playertab` module holds the configuration tab fo """ from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, translate, Receiver, Settings, UiStrings +from openlp.core.lib import SettingsTab, Receiver, Settings, UiStrings, translate from openlp.core.lib.ui import create_button from openlp.core.ui.media import get_media_players, set_media_players diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 948577aac..6d5a45549 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -37,7 +37,7 @@ import sys from PyQt4 import QtGui -from openlp.core.lib import translate, Settings +from openlp.core.lib import Settings, translate from openlp.core.ui.media import MediaState from openlp.core.ui.media.mediaplayer import MediaPlayer diff --git a/openlp/core/ui/media/webkitplayer.py b/openlp/core/ui/media/webkitplayer.py index 0a768fe37..963e4e6f7 100644 --- a/openlp/core/ui/media/webkitplayer.py +++ b/openlp/core/ui/media/webkitplayer.py @@ -33,7 +33,7 @@ from PyQt4 import QtGui import logging -from openlp.core.lib import translate, Settings +from openlp.core.lib import Settings, translate from openlp.core.ui.media import MediaState from openlp.core.ui.media.mediaplayer import MediaPlayer diff --git a/openlp/core/ui/plugindialog.py b/openlp/core/ui/plugindialog.py index 83f8b21a7..77fcf66c7 100644 --- a/openlp/core/ui/plugindialog.py +++ b/openlp/core/ui/plugindialog.py @@ -31,7 +31,7 @@ The UI widgets of the plugin view dialog #""" from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, UiStrings +from openlp.core.lib import UiStrings, translate from openlp.core.lib.ui import create_button_box diff --git a/openlp/core/ui/printservicedialog.py b/openlp/core/ui/printservicedialog.py index 7f7abcf27..03ad043d2 100644 --- a/openlp/core/ui/printservicedialog.py +++ b/openlp/core/ui/printservicedialog.py @@ -31,7 +31,7 @@ The UI widgets of the print service dialog. """ from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, translate, SpellTextEdit, UiStrings +from openlp.core.lib import SpellTextEdit, UiStrings, build_icon, translate class ZoomSize(object): diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index 689323cd5..d9fa54f36 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -36,7 +36,7 @@ import os from PyQt4 import QtCore, QtGui from lxml import html -from openlp.core.lib import translate, get_text_file_string, Receiver, Settings, UiStrings, Registry +from openlp.core.lib import Receiver, Settings, UiStrings, Registry, translate, get_text_file_string from openlp.core.ui.printservicedialog import Ui_PrintServiceDialog, ZoomSize from openlp.core.utils import AppLocation @@ -428,4 +428,4 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): self._main_window = Registry().get(u'main_window') return self._main_window - main_window = property(_get_main_window) \ No newline at end of file + main_window = property(_get_main_window) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index b45794556..778f8d8cb 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -42,8 +42,8 @@ log = logging.getLogger(__name__) from PyQt4 import QtCore, QtGui -from openlp.core.lib import OpenLPToolbar, ServiceItem, Receiver, build_icon, ItemCapabilities, \ - translate, str_to_bool, check_directory_exists, Settings, PluginStatus, Registry, UiStrings +from openlp.core.lib import OpenLPToolbar, ServiceItem, Receiver, ItemCapabilities, Settings, PluginStatus, Registry, \ + UiStrings, build_icon, translate, str_to_bool, check_directory_exists from openlp.core.lib.theme import ThemeLevel from openlp.core.lib.ui import critical_error_message_box, create_widget_action, find_and_set_in_combo_box from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm diff --git a/openlp/core/ui/servicenoteform.py b/openlp/core/ui/servicenoteform.py index 7d624ab8c..c62349104 100644 --- a/openlp/core/ui/servicenoteform.py +++ b/openlp/core/ui/servicenoteform.py @@ -31,7 +31,7 @@ The :mod:`~openlp.core.ui.servicenoteform` module contains the `ServiceNoteForm` """ from PyQt4 import QtGui -from openlp.core.lib import translate, SpellTextEdit, Registry +from openlp.core.lib import SpellTextEdit, Registry, translate from openlp.core.lib.ui import create_button_box @@ -83,4 +83,4 @@ class ServiceNoteForm(QtGui.QDialog): self._main_window = Registry().get(u'main_window') return self._main_window - main_window = property(_get_main_window) \ No newline at end of file + main_window = property(_get_main_window) diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 0543f1087..438898048 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -33,7 +33,7 @@ import logging from PyQt4 import QtGui -from openlp.core.lib import Receiver, build_icon, PluginStatus, Registry +from openlp.core.lib import Receiver, PluginStatus, Registry, build_icon from openlp.core.ui import AdvancedTab, GeneralTab, ThemesTab from openlp.core.ui.media import PlayerTab from settingsdialog import Ui_SettingsDialog @@ -165,4 +165,4 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): self._service_manager = Registry().get(u'service_manager') return self._service_manager - service_manager = property(_get_service_manager) \ No newline at end of file + service_manager = property(_get_service_manager) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 4b0651930..37a77eaa1 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -36,8 +36,8 @@ from collections import deque from PyQt4 import QtCore, QtGui -from openlp.core.lib import OpenLPToolbar, Receiver, ItemCapabilities, translate, build_icon, build_html, \ - ServiceItem, ImageSource, SlideLimits, ServiceItemAction, Settings, Registry, UiStrings, ScreenList +from openlp.core.lib import OpenLPToolbar, Receiver, ItemCapabilities, ServiceItem, ImageSource, SlideLimits, \ + ServiceItemAction, Settings, Registry, UiStrings, ScreenList, build_icon, build_html, translate from openlp.core.ui import HideMode, MainDisplay, Display, DisplayControllerType from openlp.core.lib.ui import create_action from openlp.core.utils.actions import ActionList, CategoryOrder @@ -608,7 +608,7 @@ class SlideController(DisplayController): elif width < 300 and not self.hideMenu.isVisible(): self.toolbar.setWidgetVisible(self.wideMenu, False) self.toolbar.setWidgetVisible(self.hideMenuList) - + def onSongBarHandler(self): """ Some song handler diff --git a/openlp/core/ui/starttimedialog.py b/openlp/core/ui/starttimedialog.py index e13c86430..7e370abbc 100644 --- a/openlp/core/ui/starttimedialog.py +++ b/openlp/core/ui/starttimedialog.py @@ -31,7 +31,7 @@ The UI widgets for the time dialog """ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, UiStrings +from openlp.core.lib import UiStrings, translate from openlp.core.lib.ui import create_button_box diff --git a/openlp/core/ui/starttimeform.py b/openlp/core/ui/starttimeform.py index 7c9e694f0..2ab918b6f 100644 --- a/openlp/core/ui/starttimeform.py +++ b/openlp/core/ui/starttimeform.py @@ -33,7 +33,7 @@ from PyQt4 import QtGui from starttimedialog import Ui_StartTimeDialog -from openlp.core.lib import translate, UiStrings, Registry +from openlp.core.lib import UiStrings, Registry, translate from openlp.core.lib.ui import critical_error_message_box @@ -105,4 +105,4 @@ class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog): self._main_window = Registry().get(u'main_window') return self._main_window - main_window = property(_get_main_window) \ No newline at end of file + main_window = property(_get_main_window) diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index f1a7a3010..a23e08207 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -34,7 +34,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, translate, UiStrings, Registry +from openlp.core.lib import Receiver, UiStrings, Registry, translate from openlp.core.lib.theme import BackgroundType, BackgroundGradientType from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui import ThemeLayoutForm diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index a482a3c44..08746b884 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -38,9 +38,9 @@ import re from xml.etree.ElementTree import ElementTree, XML from PyQt4 import QtCore, QtGui -from openlp.core.lib import OpenLPToolbar, get_text_file_string, build_icon, Receiver, SettingsManager, translate, \ - check_item_selected, check_directory_exists, create_thumb, validate_thumb, ImageSource, Settings, Registry, \ - UiStrings +from openlp.core.lib import ImageSource, OpenLPToolbar, Receiver, Registry, SettingsManager, Settings, UiStrings, \ + get_text_file_string, build_icon, translate, check_item_selected, check_directory_exists, create_thumb, \ + validate_thumb from openlp.core.lib.theme import ThemeXML, BackgroundType, VerticalType, BackgroundGradientType from openlp.core.lib.ui import critical_error_message_box, create_widget_action from openlp.core.theme import Theme @@ -859,4 +859,4 @@ class ThemeManager(QtGui.QWidget): self._application = Registry().get(u'application') return self._application - application = property(_get_application) \ No newline at end of file + application = property(_get_application) diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index b502d11e0..0cf491e72 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -31,7 +31,7 @@ The Themes configuration tab """ from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, Settings, SettingsTab, translate, UiStrings +from openlp.core.lib import Receiver, Settings, SettingsTab, UiStrings, translate from openlp.core.lib.theme import ThemeLevel from openlp.core.lib.ui import find_and_set_in_combo_box diff --git a/openlp/core/ui/themewizard.py b/openlp/core/ui/themewizard.py index 7a434e998..fb23a2ac6 100644 --- a/openlp/core/ui/themewizard.py +++ b/openlp/core/ui/themewizard.py @@ -31,7 +31,7 @@ The Create/Edit theme wizard """ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, build_icon, UiStrings +from openlp.core.lib import UiStrings, build_icon, translate from openlp.core.lib.theme import HorizontalType, BackgroundType, BackgroundGradientType from openlp.core.lib.ui import add_welcome_page, create_valign_selection_widgets diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index 46ef55fd1..744dd8087 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -34,7 +34,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, Receiver, Registry, Settings, translate, UiStrings +from openlp.core.lib import Receiver, Registry, Settings, UiStrings, build_icon, translate from openlp.core.lib.ui import add_welcome_page log = logging.getLogger(__name__) @@ -295,4 +295,4 @@ class OpenLPWizard(QtGui.QWizard): self._application = Registry().get(u'application') return self._application - application = property(_get_application) \ No newline at end of file + application = property(_get_application) diff --git a/openlp/core/utils/languagemanager.py b/openlp/core/utils/languagemanager.py index f69bb40c6..00a0d0079 100644 --- a/openlp/core/utils/languagemanager.py +++ b/openlp/core/utils/languagemanager.py @@ -36,7 +36,7 @@ import sys from PyQt4 import QtCore, QtGui from openlp.core.utils import AppLocation -from openlp.core.lib import translate, Settings +from openlp.core.lib import Settings, translate log = logging.getLogger(__name__) diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 1c9203348..de2c92f7e 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -31,7 +31,7 @@ import logging from PyQt4 import QtGui -from openlp.core.lib import Plugin, StringContent, build_icon, translate, Settings +from openlp.core.lib import Plugin, Settings, StringContent, build_icon, translate from openlp.core.lib.db import Manager from openlp.core.lib.ui import create_action, UiStrings from openlp.core.lib.theme import VerticalType diff --git a/openlp/plugins/alerts/lib/alertstab.py b/openlp/plugins/alerts/lib/alertstab.py index 126c64766..05aff7fd6 100644 --- a/openlp/plugins/alerts/lib/alertstab.py +++ b/openlp/plugins/alerts/lib/alertstab.py @@ -29,7 +29,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, translate, Receiver, Settings, UiStrings +from openlp.core.lib import SettingsTab, Receiver, Settings, UiStrings, translate from openlp.core.lib.ui import create_valign_selection_widgets class AlertsTab(SettingsTab): diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index bf5a056eb..8fcbaebc1 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -32,7 +32,7 @@ import logging from PyQt4 import QtGui from openlp.core.lib import Plugin, StringContent, build_icon, translate -from openlp.core.lib.ui import create_action, UiStrings +from openlp.core.lib.ui import UiStrings, create_action from openlp.core.utils.actions import ActionList from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem, LayoutStyle, DisplayStyle, \ LanguageSelection diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 10d50a9af..3b1455f68 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -34,7 +34,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, Settings, UiStrings +from openlp.core.lib import Settings, UiStrings, translate from openlp.core.lib.db import delete_database from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard, WizardStrings diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 10589cbee..f7f16aace 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -36,7 +36,7 @@ from tempfile import gettempdir from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, translate, check_directory_exists, Settings, UiStrings +from openlp.core.lib import Receiver, Settings, UiStrings, translate, check_directory_exists from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard, WizardStrings from openlp.core.utils import AppLocation, delete_file, get_filesystem_encoding diff --git a/openlp/plugins/bibles/forms/editbibleform.py b/openlp/plugins/bibles/forms/editbibleform.py index a6e9e6d6b..939cd8383 100644 --- a/openlp/plugins/bibles/forms/editbibleform.py +++ b/openlp/plugins/bibles/forms/editbibleform.py @@ -32,7 +32,7 @@ import re from PyQt4 import QtGui -from openlp.core.lib import Registry, translate, UiStrings +from openlp.core.lib import Registry, UiStrings, translate from openlp.core.lib.ui import critical_error_message_box from editbibledialog import Ui_EditBibleDialog from openlp.plugins.bibles.lib import BibleStrings diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py index 2ba2ff590..219b91f90 100644 --- a/openlp/plugins/bibles/lib/__init__.py +++ b/openlp/plugins/bibles/lib/__init__.py @@ -33,7 +33,7 @@ plugin. import logging import re -from openlp.core.lib import translate, Settings +from openlp.core.lib import Settings, translate log = logging.getLogger(__name__) diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 291930a4b..0ac667697 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -31,7 +31,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, SettingsTab, translate, Settings, UiStrings +from openlp.core.lib import Receiver, SettingsTab, Settings, UiStrings, translate from openlp.core.lib.ui import find_and_set_in_combo_box from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, update_reference_separators, \ get_reference_separator, LanguageSelection diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index c728aee6a..7b6c94353 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -34,7 +34,7 @@ import re import sqlite3 from PyQt4 import QtCore -from sqlalchemy import Column, ForeignKey, or_, Table, types, func +from sqlalchemy import Column, ForeignKey, Table, or_, types, func from sqlalchemy.orm import class_mapper, mapper, relation from sqlalchemy.orm.exc import UnmappedClassError @@ -360,7 +360,7 @@ class BibleDB(QtCore.QObject, Manager): ``book`` The name of the book, according to the selected language. - + ``language_selection`` The language selection the user has chosen in the settings section of the Bible. diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index aaf91d2c0..83428c35b 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -30,7 +30,7 @@ import logging import os -from openlp.core.lib import Receiver, SettingsManager, translate, Settings +from openlp.core.lib import Receiver, SettingsManager, Settings, translate from openlp.core.utils import AppLocation, delete_file from openlp.plugins.bibles.lib import parse_reference, get_reference_separator, LanguageSelection from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 13d770909..2df57e626 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -31,8 +31,8 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, translate, create_separated_list, \ - ServiceItemContext, Settings, UiStrings +from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, ServiceItemContext, Settings, UiStrings, \ + create_separated_list, translate from openlp.core.lib.searchedit import SearchEdit from openlp.core.lib.ui import set_case_insensitive_completer, create_horizontal_adjusting_combo_box, \ critical_error_message_box, find_and_set_in_combo_box, build_icon diff --git a/openlp/plugins/custom/forms/editcustomdialog.py b/openlp/plugins/custom/forms/editcustomdialog.py index 5792e7aae..1972228d2 100644 --- a/openlp/plugins/custom/forms/editcustomdialog.py +++ b/openlp/plugins/custom/forms/editcustomdialog.py @@ -29,7 +29,7 @@ from PyQt4 import QtGui -from openlp.core.lib import build_icon, translate, UiStrings +from openlp.core.lib import UiStrings, build_icon, translate from openlp.core.lib.ui import create_button_box, create_button class Ui_CustomEditDialog(object): diff --git a/openlp/plugins/custom/forms/editcustomslidedialog.py b/openlp/plugins/custom/forms/editcustomslidedialog.py index 5dfb79adc..972759e7c 100644 --- a/openlp/plugins/custom/forms/editcustomslidedialog.py +++ b/openlp/plugins/custom/forms/editcustomslidedialog.py @@ -29,7 +29,7 @@ from PyQt4 import QtGui -from openlp.core.lib import translate, SpellTextEdit, UiStrings +from openlp.core.lib import SpellTextEdit, UiStrings, translate from openlp.core.lib.ui import create_button, create_button_box class Ui_CustomSlideEditDialog(object): diff --git a/openlp/plugins/custom/lib/customtab.py b/openlp/plugins/custom/lib/customtab.py index 5b0b7f11f..ba57a6fc2 100644 --- a/openlp/plugins/custom/lib/customtab.py +++ b/openlp/plugins/custom/lib/customtab.py @@ -33,7 +33,7 @@ for the Custom Slides plugin, which is inserted into the configuration dialog. from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, translate, Settings +from openlp.core.lib import SettingsTab, Settings, translate class CustomTab(SettingsTab): """ diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 7b87dbef5..369d3e419 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -32,8 +32,8 @@ import logging from PyQt4 import QtCore, QtGui from sqlalchemy.sql import or_, func, and_ -from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, check_item_selected, translate, \ - ServiceItemContext, Settings, PluginStatus, UiStrings +from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, ServiceItemContext, Settings, PluginStatus, \ + UiStrings, check_item_selected, translate from openlp.plugins.custom.forms import EditCustomForm from openlp.plugins.custom.lib import CustomXMLParser, CustomXMLBuilder from openlp.plugins.custom.lib.db import CustomSlide diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index 0827e645c..0f2829dbc 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -31,7 +31,7 @@ from PyQt4 import QtCore, QtGui import logging -from openlp.core.lib import Plugin, StringContent, build_icon, translate, Receiver, ImageSource, Settings +from openlp.core.lib import Plugin, StringContent, Receiver, ImageSource, Settings, build_icon, translate from openlp.plugins.images.lib import ImageMediaItem, ImageTab log = logging.getLogger(__name__) diff --git a/openlp/plugins/images/lib/imagetab.py b/openlp/plugins/images/lib/imagetab.py index 8e3f1c657..ce3e9b957 100644 --- a/openlp/plugins/images/lib/imagetab.py +++ b/openlp/plugins/images/lib/imagetab.py @@ -29,7 +29,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, translate, Receiver, Settings, UiStrings +from openlp.core.lib import SettingsTab, Receiver, Settings, UiStrings, translate class ImageTab(SettingsTab): """ diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 64ba220c0..0ab73aa46 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -32,9 +32,9 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, SettingsManager, translate, \ - check_item_selected, check_directory_exists, Receiver, create_thumb, validate_thumb, ServiceItemContext, Settings, \ - UiStrings +from openlp.core.lib import MediaManagerItem, ItemCapabilities, Receiver, SettingsManager, ServiceItemContext, \ + Settings, UiStrings, build_icon, check_item_selected, check_directory_exists, create_thumb, translate, \ + validate_thumb from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import AppLocation, delete_file, locale_compare, get_images_filter diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 1645164ae..02d624c1e 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -32,9 +32,8 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, translate, \ - check_item_selected, Receiver, MediaType, ServiceItem, ServiceItemContext, Settings, UiStrings, \ - check_directory_exists +from openlp.core.lib import ItemCapabilities, MediaManagerItem,MediaType, Receiver, ServiceItem, ServiceItemContext, \ + Settings, UiStrings, build_icon, check_item_selected, check_directory_exists, translate from openlp.core.lib.ui import critical_error_message_box, create_horizontal_adjusting_combo_box from openlp.core.ui import DisplayController, Display, DisplayControllerType from openlp.core.ui.media import get_media_players, set_media_players diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index d874686a6..69a21d0a4 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -29,7 +29,7 @@ from PyQt4 import QtGui -from openlp.core.lib import Receiver, Settings, SettingsTab, translate, UiStrings +from openlp.core.lib import Receiver, Settings, SettingsTab, UiStrings, translate class MediaQCheckBox(QtGui.QCheckBox): """ diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index 2a1fcf112..bb463b857 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -31,7 +31,7 @@ import logging from PyQt4 import QtCore -from openlp.core.lib import Plugin, StringContent, build_icon, translate, Settings, Registry +from openlp.core.lib import Plugin, Registry, StringContent, Settings, build_icon, translate from openlp.plugins.media.lib import MediaMediaItem, MediaTab log = logging.getLogger(__name__) diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 85a21781a..1875ca66c 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -32,8 +32,8 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import MediaManagerItem, build_icon, translate, check_item_selected, Receiver, \ - ItemCapabilities, create_thumb, validate_thumb, ServiceItemContext, Settings, UiStrings +from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, ServiceItemContext, Settings, UiStrings, \ + build_icon, check_item_selected, create_thumb, translate, validate_thumb from openlp.core.lib.ui import critical_error_message_box, create_horizontal_adjusting_combo_box from openlp.core.utils import locale_compare from openlp.plugins.presentations.lib import MessageListener diff --git a/openlp/plugins/presentations/lib/presentationcontroller.py b/openlp/plugins/presentations/lib/presentationcontroller.py index 8f468de63..fad88d7cd 100644 --- a/openlp/plugins/presentations/lib/presentationcontroller.py +++ b/openlp/plugins/presentations/lib/presentationcontroller.py @@ -33,7 +33,7 @@ import shutil from PyQt4 import QtCore -from openlp.core.lib import Receiver, Registry, check_directory_exists, create_thumb, validate_thumb, Settings +from openlp.core.lib import Receiver, Registry, Settings, check_directory_exists, create_thumb, validate_thumb from openlp.core.utils import AppLocation log = logging.getLogger(__name__) diff --git a/openlp/plugins/presentations/lib/presentationtab.py b/openlp/plugins/presentations/lib/presentationtab.py index 06cd84568..15b3b2590 100644 --- a/openlp/plugins/presentations/lib/presentationtab.py +++ b/openlp/plugins/presentations/lib/presentationtab.py @@ -29,7 +29,7 @@ from PyQt4 import QtGui -from openlp.core.lib import Receiver, Settings, SettingsTab, translate, UiStrings +from openlp.core.lib import Receiver, Settings, SettingsTab, UiStrings, translate class PresentationTab(SettingsTab): """ diff --git a/openlp/plugins/remotes/lib/remotetab.py b/openlp/plugins/remotes/lib/remotetab.py index c3ccd46c5..2e42a2b1e 100644 --- a/openlp/plugins/remotes/lib/remotetab.py +++ b/openlp/plugins/remotes/lib/remotetab.py @@ -29,7 +29,7 @@ from PyQt4 import QtCore, QtGui, QtNetwork -from openlp.core.lib import Settings, SettingsTab, translate, Receiver +from openlp.core.lib import Settings, SettingsTab, Receiver, translate ZERO_URL = u'0.0.0.0' diff --git a/openlp/plugins/songs/forms/editsongdialog.py b/openlp/plugins/songs/forms/editsongdialog.py index 3f6e1e61a..76f190931 100644 --- a/openlp/plugins/songs/forms/editsongdialog.py +++ b/openlp/plugins/songs/forms/editsongdialog.py @@ -29,7 +29,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, translate, UiStrings +from openlp.core.lib import UiStrings, build_icon, translate from openlp.core.lib.ui import create_button_box, create_button from openlp.plugins.songs.lib.ui import SongStrings diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index f31b487e1..9da5adc6e 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -38,8 +38,8 @@ import shutil from PyQt4 import QtCore, QtGui -from openlp.core.lib import PluginStatus, Receiver, MediaType, translate, create_separated_list, \ - check_directory_exists, Registry, UiStrings +from openlp.core.lib import PluginStatus, Receiver, MediaType, Registry, UiStrings, translate, create_separated_list, \ + check_directory_exists from openlp.core.lib.ui import set_case_insensitive_completer, critical_error_message_box, \ find_and_set_in_combo_box from openlp.core.utils import AppLocation @@ -915,4 +915,4 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self._theme_manager = Registry().get(u'theme_manager') return self._theme_manager - theme_manager = property(_get_theme_manager) \ No newline at end of file + theme_manager = property(_get_theme_manager) diff --git a/openlp/plugins/songs/forms/editversedialog.py b/openlp/plugins/songs/forms/editversedialog.py index 603af2180..e97a898f7 100644 --- a/openlp/plugins/songs/forms/editversedialog.py +++ b/openlp/plugins/songs/forms/editversedialog.py @@ -29,8 +29,8 @@ from PyQt4 import QtGui -from openlp.core.lib import build_icon, translate, SpellTextEdit -from openlp.core.lib.ui import create_button_box, UiStrings +from openlp.core.lib import SpellTextEdit, build_icon, translate +from openlp.core.lib.ui import UiStrings, create_button_box from openlp.plugins.songs.lib import VerseType class Ui_EditVerseDialog(object): diff --git a/openlp/plugins/songs/forms/songexportform.py b/openlp/plugins/songs/forms/songexportform.py index 2a1564f8b..f4773b3da 100644 --- a/openlp/plugins/songs/forms/songexportform.py +++ b/openlp/plugins/songs/forms/songexportform.py @@ -34,7 +34,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, Receiver, translate, create_separated_list, UiStrings +from openlp.core.lib import Receiver, UiStrings, create_separated_list, build_icon, translate from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard, WizardStrings from openlp.plugins.songs.lib import natcmp diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 9a842f401..b635b309b 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -35,7 +35,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import Settings, translate, UiStrings +from openlp.core.lib import Settings, UiStrings, translate from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard, WizardStrings from openlp.plugins.songs.lib.importer import SongFormat, SongFormatSelect diff --git a/openlp/plugins/songs/forms/songmaintenancedialog.py b/openlp/plugins/songs/forms/songmaintenancedialog.py index 389579284..2f7ad7915 100644 --- a/openlp/plugins/songs/forms/songmaintenancedialog.py +++ b/openlp/plugins/songs/forms/songmaintenancedialog.py @@ -29,7 +29,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, UiStrings +from openlp.core.lib import UiStrings, build_icon from openlp.core.lib.ui import create_button_box from openlp.plugins.songs.lib.ui import SongStrings diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 9d0c0c306..546791778 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -31,7 +31,7 @@ import logging from PyQt4 import QtGui, QtCore from sqlalchemy.sql import and_ -from openlp.core.lib import Receiver, translate, UiStrings +from openlp.core.lib import Receiver, UiStrings, translate from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.songs.forms import AuthorsForm, TopicsForm, SongBookForm from openlp.plugins.songs.lib.db import Author, Book, Topic, Song @@ -517,4 +517,4 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): self._application = Registry().get(u'application') return self._application - application = property(_get_application) \ No newline at end of file + application = property(_get_application) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 883865bb8..6c38c84da 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -35,8 +35,8 @@ import shutil from PyQt4 import QtCore, QtGui from sqlalchemy.sql import or_ -from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, translate, check_item_selected, \ - PluginStatus, create_separated_list, check_directory_exists, ServiceItemContext, Settings, UiStrings +from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, PluginStatus, ServiceItemContext, Settings, \ + UiStrings, translate, check_item_selected, create_separated_list, check_directory_exists from openlp.core.lib.ui import create_widget_action from openlp.core.utils import AppLocation from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm, SongImportForm, SongExportForm diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index 859bef075..22a4d803f 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -69,7 +69,7 @@ import re from lxml import etree, objectify from openlp.core.lib import FormattingTags, translate -from openlp.plugins.songs.lib import clean_song, VerseType +from openlp.plugins.songs.lib import VerseType, clean_song from openlp.plugins.songs.lib.db import Author, Book, Song, Topic from openlp.core.utils import get_application_version diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 937e5b374..74a5ce216 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -38,7 +38,7 @@ import sqlite3 from PyQt4 import QtCore, QtGui -from openlp.core.lib import Plugin, StringContent, build_icon, translate, UiStrings +from openlp.core.lib import Plugin, StringContent, UiStrings, build_icon, translate from openlp.core.lib.db import Manager from openlp.core.lib.ui import create_action from openlp.core.utils import get_filesystem_encoding diff --git a/openlp/plugins/songusage/forms/songusagedeleteform.py b/openlp/plugins/songusage/forms/songusagedeleteform.py index 8174060bd..b13be8ad2 100644 --- a/openlp/plugins/songusage/forms/songusagedeleteform.py +++ b/openlp/plugins/songusage/forms/songusagedeleteform.py @@ -29,7 +29,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, Receiver +from openlp.core.lib import Receiver, translate from openlp.plugins.songusage.lib.db import SongUsageItem from songusagedeletedialog import Ui_SongUsageDeleteDialog diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index 398997715..3b3611f0e 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -32,7 +32,7 @@ from datetime import datetime from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, Plugin, Receiver, Settings, StringContent, translate +from openlp.core.lib import Plugin, Receiver, Settings, StringContent, build_icon, translate from openlp.core.lib.db import Manager from openlp.core.lib.ui import create_action from openlp.core.utils.actions import ActionList From f1e8f9812c118631fe9ebc8467172bdd48a87b47 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 5 Feb 2013 18:47:57 +0100 Subject: [PATCH 59/64] fixed rename error --- openlp/plugins/songs/forms/editsongform.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 0c0e5c196..0758b18f7 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -184,7 +184,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): Load the media files into a combobox. """ self.audioAddFromMediaButton.setVisible(False) - for plugin in self.parent().pluginManager.plugins: + for plugin in self.parent().plugin_manager.plugins: if plugin.name == u'media' and plugin.status == PluginStatus.Active: self.audioAddFromMediaButton.setVisible(True) self.mediaForm.populateFiles(plugin.mediaItem.getList(MediaType.Audio)) @@ -915,4 +915,5 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self._theme_manager = Registry().get(u'theme_manager') return self._theme_manager - theme_manager = property(_get_theme_manager) \ No newline at end of file + theme_manager = property(_get_theme_manager) + From ea3e24096c38aceb629aace25de76790a48ac913 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 5 Feb 2013 20:29:31 +0100 Subject: [PATCH 60/64] use registry --- openlp/plugins/songs/forms/editsongform.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 0758b18f7..253225411 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -184,7 +184,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): Load the media files into a combobox. """ self.audioAddFromMediaButton.setVisible(False) - for plugin in self.parent().plugin_manager.plugins: + for plugin in self.plugin_manager.plugins: if plugin.name == u'media' and plugin.status == PluginStatus.Active: self.audioAddFromMediaButton.setVisible(True) self.mediaForm.populateFiles(plugin.mediaItem.getList(MediaType.Audio)) @@ -907,6 +907,16 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): except: log.exception(u'Problem processing song Lyrics \n%s', sxml.dump_xml()) + def _get_plugin_manager(self): + """ + Adds the plugin manager to the class dynamically + """ + if not hasattr(self, u'_plugin_manager'): + self._plugin_manager = Registry().get(u'plugin_manager') + return self._plugin_manager + + plugin_manager = property(_get_plugin_manager) + def _get_theme_manager(self): """ Adds the theme manager to the class dynamically From 28ea251866c06749750a676df170a4710ac93b9d Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 7 Feb 2013 19:00:40 +0100 Subject: [PATCH 61/64] fixed servicemanager bugs preventing saving/opening a service --- openlp/core/lib/settings.py | 2 +- openlp/core/ui/servicemanager.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/core/lib/settings.py b/openlp/core/lib/settings.py index 78e8004c4..7e72c6d4c 100644 --- a/openlp/core/lib/settings.py +++ b/openlp/core/lib/settings.py @@ -143,6 +143,7 @@ class Settings(QtCore.QSettings): u'media/players': u'webkit', u'media/override player': QtCore.Qt.Unchecked, u'players/background color': u'#000000', + u'servicemanager/last directory': u'', u'servicemanager/last file': u'', u'servicemanager/service theme': u'', u'SettingsImport/file_date_created': datetime.datetime.now().strftime("%Y-%m-%d %H:%M"), @@ -242,7 +243,6 @@ class Settings(QtCore.QSettings): (u'media/background color', u'players/background color', []), (u'themes/last directory', u'themes/last directory import', []), (u'themes/last directory 1', u'themes/last directory export', []), - (u'servicemanager/last directory', u'', []), (u'songs/last directory 1', u'songs/last directory import', []), (u'songusage/last directory 1', u'songusage/last directory export', []), (u'user interface/mainwindow splitter geometry', u'user interface/main window splitter geometry', []), diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 778f8d8cb..cfa0d4707 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -661,11 +661,11 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): # SaveAs from osz to oszl is not valid as the files will be deleted # on exit which is not sensible or usable in the long term. if self._file_name.endswith(u'oszl') or self.service_has_all_original_files: - file_name = QtGui.QFileDialog.getSavefile_name(self.main_window, UiStrings().SaveService, path, + file_name = QtGui.QFileDialog.getSaveFileName(self.main_window, UiStrings().SaveService, path, translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz);; OpenLP Service Files - lite (*.oszl)')) else: - file_name = QtGui.QFileDialog.getSavefile_name(self.main_window, UiStrings().SaveService, path, + file_name = QtGui.QFileDialog.getSaveFileName(self.main_window, UiStrings().SaveService, path, translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz);;')) if not file_name: return False From d6128a4f0694d176e6279150c1d268dcf70aa2ac Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 9 Feb 2013 15:13:38 +0100 Subject: [PATCH 62/64] fixed first time wizard --- openlp/core/ui/firsttimeform.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index daedbb94e..efeac2d25 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -61,7 +61,7 @@ class ThemeScreenshotThread(QtCore.QThread): config = self.parent().config for theme in themes: # Stop if the wizard has been cancelled. - if self.parent().downloadCancelled: + if self.parent().was_download_cancelled: return title = config.get(u'theme_%s' % theme, u'title') filename = config.get(u'theme_%s' % theme, u'filename') @@ -91,9 +91,9 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): # check to see if we have web access self.web = u'http://openlp.org/files/frw/' self.config = SafeConfigParser() - self.webAccess = get_web_page(u'%s%s' % (self.web, u'download.cfg')) - if self.webAccess: - files = self.webAccess.read() + self.web_access = get_web_page(u'%s%s' % (self.web, u'download.cfg')) + if self.web_access: + files = self.web_access.read() self.config.readfp(io.BytesIO(files)) self.updateScreenListCombo() self.was_download_cancelled = False @@ -118,13 +118,12 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): Set up display at start of theme edit. """ self.restart() - check_directory_exists(os.path.join( - unicode(gettempdir(), get_filesystem_encoding()), u'openlp')) + check_directory_exists(os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp')) self.noInternetFinishButton.setVisible(False) # Check if this is a re-run of the wizard. self.hasRunWizard = Settings().value(u'general/has run wizard') # Sort out internet access for downloads - if self.webAccess: + if self.web_access: songs = self.config.get(u'songs', u'languages') songs = songs.split(u',') for song in songs: @@ -160,7 +159,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): """ self.application.process_events() if self.currentId() == FirstTimePage.Plugins: - if not self.webAccess: + if not self.web_access: return FirstTimePage.NoInternet else: return FirstTimePage.Songs @@ -169,6 +168,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): elif self.currentId() == FirstTimePage.NoInternet: return FirstTimePage.Progress elif self.currentId() == FirstTimePage.Themes: + self.application.process_events() self.application.set_busy_cursor() while not self.themeScreenshotThread.isFinished(): time.sleep(0.1) @@ -241,8 +241,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): """ Process the triggering of the cancel button. """ - if self.lastId == FirstTimePage.NoInternet or \ - (self.lastId <= FirstTimePage.Plugins and not self.hasRunWizard): + if self.lastId == FirstTimePage.NoInternet or (self.lastId <= FirstTimePage.Plugins and not self.hasRunWizard): QtCore.QCoreApplication.exit() sys.exit() self.was_download_cancelled = True @@ -428,7 +427,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): self._setPluginStatus(self.customCheckBox, u'custom/status') self._setPluginStatus(self.songUsageCheckBox, u'songusage/status') self._setPluginStatus(self.alertCheckBox, u'alerts/status') - if self.webAccess: + if self.web_access: # Build directories for downloads songs_destination = os.path.join( unicode(gettempdir(), get_filesystem_encoding()), u'openlp') From b0065d808cc113132f42bc237baf9f9300cb7f54 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 9 Feb 2013 15:45:07 +0100 Subject: [PATCH 63/64] removed not needed call --- openlp/core/ui/firsttimeform.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index efeac2d25..16f39b85e 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -168,7 +168,6 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): elif self.currentId() == FirstTimePage.NoInternet: return FirstTimePage.Progress elif self.currentId() == FirstTimePage.Themes: - self.application.process_events() self.application.set_busy_cursor() while not self.themeScreenshotThread.isFinished(): time.sleep(0.1) From 5739536d8cd469ef383533af450ca4547734d067 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 9 Feb 2013 16:27:35 +0100 Subject: [PATCH 64/64] fixed more regression --- openlp/core/ui/mainwindow.py | 2 +- openlp/core/ui/thememanager.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 5e21a6c28..cb94a0914 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -699,7 +699,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.activePlugin.app_startup() else: self.activePlugin.toggleStatus(PluginStatus.Inactive) - self.themeManagerContents.configUpdated() + self.themeManagerContents.config_updated() self.themeManagerContents.load_themes(True) Receiver.send_message(u'theme_update_global', self.themeManagerContents.global_theme) # Check if any Bibles downloaded. If there are, they will be diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 08746b884..a60244257 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -157,7 +157,7 @@ class ThemeManager(QtGui.QWidget): files = SettingsManager.get_files(self.settingsSection, u'.otz') for theme_file in files: theme_file = os.path.join(self.path, theme_file) - self.unzipTheme(theme_file, self.path) + self.unzip_theme(theme_file, self.path) delete_file(theme_file) self.application.set_normal_cursor()