openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #19033
[Merge] lp:~trb143/openlp/media into lp:openlp
Tim Bentley has proposed merging lp:~trb143/openlp/media into lp:openlp.
Requested reviews:
Jonathan Corwin (j-corwin)
Related bugs:
Bug #885150 in OpenLP: "Need non self contained service files"
https://bugs.launchpad.net/openlp/+bug/885150
Bug #899714 in OpenLP: "Play/Pause button should be merged"
https://bugs.launchpad.net/openlp/+bug/899714
Bug #927829 in OpenLP: "media backends should provide some information about themselves in the settings"
https://bugs.launchpad.net/openlp/+bug/927829
Bug #952821 in OpenLP: "Unable to play videos from web"
https://bugs.launchpad.net/openlp/+bug/952821
Bug #958198 in OpenLP: "Replacing live background with a video shows theme behind"
https://bugs.launchpad.net/openlp/+bug/958198
Bug #999618 in OpenLP: "Video position slider jumps to part way through video"
https://bugs.launchpad.net/openlp/+bug/999618
Bug #1022053 in OpenLP: "Previewing media item interferes with live media item"
https://bugs.launchpad.net/openlp/+bug/1022053
Bug #1063211 in OpenLP: "Media and Presentation Plugins do not update the service suffix lists if players are added or removed without a restart"
https://bugs.launchpad.net/openlp/+bug/1063211
Bug #1105688 in OpenLP: "Main Window Will not Display"
https://bugs.launchpad.net/openlp/+bug/1105688
For more details, see:
https://code.launchpad.net/~trb143/openlp/media/+merge/145737
Fix up the tests so they work better and UI test now works
Pylint fixes
bug fixes from the conversion
Clean up ServiceManager field names and move child windows to Registry
Clean up Remote Edit using Registry instead of events.
New test for Service Note Form.
All tests to remove Register Entries to help switching between Mocks and Real in same class
all pass
http://ci.openlp.org/view/Specific%20Branch/job/OpenLP-Pull_and_Run_Functional_Tests/26/console
--
https://code.launchpad.net/~trb143/openlp/media/+merge/145737
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/eventreceiver.py'
--- openlp/core/lib/eventreceiver.py 2012-12-29 20:56:56 +0000
+++ openlp/core/lib/eventreceiver.py 2013-01-30 22:10:34 +0000
@@ -200,12 +200,6 @@
``{plugin}_unblank``
Requests a plugin to handle an unblank screen event.
- ``{plugin}_edit``
- Requests a plugin edit a database item with the key as the payload.
-
- ``{plugin}_edit_clear``
- Editing has been completed.
-
``{plugin}_load_list``
Tells the the plugin to reload the media manager list.
=== modified file 'openlp/core/lib/mediamanageritem.py'
--- openlp/core/lib/mediamanageritem.py 2013-01-23 21:05:25 +0000
+++ openlp/core/lib/mediamanageritem.py 2013-01-30 22:10:34 +0000
@@ -99,7 +99,7 @@
self.plugin = plugin
visible_title = self.plugin.getString(StringContent.VisibleName)
self.title = unicode(visible_title[u'title'])
- Registry().register(self.title, self)
+ Registry().register(self.plugin.name, self)
self.settingsSection = self.plugin.name
self.icon = None
if icon:
@@ -436,8 +436,8 @@
"""
pass
- def generateSlideData(self, serviceItem, item=None, xmlVersion=False,
- remote=False, context=ServiceItemContext.Live):
+ def generateSlideData(self, serviceItem, item=None, xmlVersion=False, remote=False,
+ context=ServiceItemContext.Live):
raise NotImplementedError(u'MediaManagerItem.generateSlideData needs to be defined by the plugin')
def onDoubleClicked(self):
@@ -470,7 +470,7 @@
serviceItem = self.buildServiceItem()
if serviceItem:
serviceItem.from_plugin = True
- self.preview_controller.addServiceItem(serviceItem)
+ self.preview_controller.add_service_item(serviceItem)
if keepFocus:
self.listView.setFocus()
@@ -496,7 +496,7 @@
serviceItem.from_plugin = True
if remote:
serviceItem.will_auto_start = True
- self.live_controller.addServiceItem(serviceItem)
+ self.live_controller.add_service_item(serviceItem)
def createItemFromId(self, item_id):
item = QtGui.QListWidgetItem()
@@ -507,13 +507,13 @@
"""
Add a selected item to the current service
"""
- if not self.listView.selectedIndexes() and not self.remoteTriggered:
+ if not self.listView.selectedIndexes():
QtGui.QMessageBox.information(self, UiStrings().NISp,
translate('OpenLP.MediaManagerItem', 'You must select one or more items to add.'))
else:
# Is it possible to process multiple list items to generate
# multiple service items?
- if self.singleServiceItem or self.remoteTriggered:
+ if self.singleServiceItem:
log.debug(u'%s Add requested', self.plugin.name)
self.addToService(replace=self.remoteTriggered)
else:
@@ -525,7 +525,7 @@
serviceItem = self.buildServiceItem(item, True, remote=remote, context=ServiceItemContext.Service)
if serviceItem:
serviceItem.from_plugin = False
- self.service_manager.addServiceItem(serviceItem, replace=replace)
+ self.service_manager.add_service_item(serviceItem, replace=replace)
def onAddEditClick(self):
"""
@@ -536,13 +536,13 @@
translate('OpenLP.MediaManagerItem', 'You must select one or more items.'))
else:
log.debug(u'%s Add requested', self.plugin.name)
- serviceItem = self.plugin.serviceManager.getServiceItem()
+ serviceItem = self.service_manager.get_service_item()
if not serviceItem:
QtGui.QMessageBox.information(self, UiStrings().NISs,
translate('OpenLP.MediaManagerItem', 'You must select an existing service item to add to.'))
elif self.plugin.name == serviceItem.name:
self.generateSlideData(serviceItem)
- self.service_manager.addServiceItem(serviceItem, replace=True)
+ self.service_manager.add_service_item(serviceItem, replace=True)
else:
# Turn off the remote edit update message indicator
QtGui.QMessageBox.information(self, translate('OpenLP.MediaManagerItem', 'Invalid Service Item'),
@@ -554,8 +554,7 @@
"""
serviceItem = ServiceItem(self.plugin)
serviceItem.add_icon(self.plugin.iconPath)
- if self.generateSlideData(serviceItem, item, xmlVersion, remote,
- context):
+ if self.generateSlideData(serviceItem, item, xmlVersion, remote, context):
return serviceItem
else:
return None
@@ -681,10 +680,11 @@
def _get_service_manager(self):
"""
- Adds the plugin manager to the class dynamically
+ 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)
\ No newline at end of file
+ service_manager = property(_get_service_manager)
+
=== modified file 'openlp/core/lib/registry.py'
--- openlp/core/lib/registry.py 2013-01-24 20:04:18 +0000
+++ openlp/core/lib/registry.py 2013-01-30 22:10:34 +0000
@@ -30,6 +30,7 @@
Provide Registry Services
"""
import logging
+import sys
log = logging.getLogger(__name__)
@@ -54,8 +55,13 @@
log.info(u'Registry Initialising')
registry = cls()
registry.service_list = {}
+ registry.running_under_test = False
+ # Allow the tests to remove Registry entries but not the live system
+ if u'nosetest' in sys.argv[0]:
+ registry.running_under_test = True
return registry
+
def get(self, key):
"""
Extracts the registry value from the list based on the key passed in
@@ -75,3 +81,16 @@
raise KeyError(u'Duplicate service exception %s' % key)
else:
self.service_list[key] = reference
+
+ def remove(self, key):
+ """
+ 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:
+ 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]
+
=== modified file 'openlp/core/lib/settings.py'
--- openlp/core/lib/settings.py 2013-01-30 19:16:51 +0000
+++ openlp/core/lib/settings.py 2013-01-30 22:10:34 +0000
@@ -165,7 +165,7 @@
u'shortcuts/importBibleItem': [],
u'shortcuts/modeDefaultItem': [],
u'shortcuts/modeLiveItem': [],
- u'shortcuts/makeLive': [QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return],
+ u'shortcuts/make_live': [QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return],
u'shortcuts/moveUp': [QtCore.Qt.Key_PageUp],
u'shortcuts/moveTop': [QtCore.Qt.Key_Home],
u'shortcuts/modeSetupItem': [],
@@ -242,6 +242,7 @@
(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'shortcuts/makeLive', u'shortcuts/make_live', []),
(u'advanced/stylesheet fix', u'', []),
(u'media/background color', u'players/background color', [])
]
=== modified file 'openlp/core/ui/aboutdialog.py'
--- openlp/core/ui/aboutdialog.py 2013-01-11 00:19:11 +0000
+++ openlp/core/ui/aboutdialog.py 2013-01-30 22:10:34 +0000
@@ -74,8 +74,8 @@
self.aboutNotebook.addTab(self.licenseTab, u'')
self.aboutDialogLayout.addWidget(self.aboutNotebook)
self.volunteerButton = create_button(None, u'volunteerButton', icon=u':/system/system_volunteer.png')
- self.buttonBox = create_button_box(aboutDialog, u'buttonBox', [u'close'], [self.volunteerButton])
- self.aboutDialogLayout.addWidget(self.buttonBox)
+ self.button_box = create_button_box(aboutDialog, u'button_box', [u'close'], [self.volunteerButton])
+ self.aboutDialogLayout.addWidget(self.button_box)
self.retranslateUi(aboutDialog)
self.aboutNotebook.setCurrentIndex(0)
=== modified file 'openlp/core/ui/exceptiondialog.py'
--- openlp/core/ui/exceptiondialog.py 2013-01-20 12:14:34 +0000
+++ openlp/core/ui/exceptiondialog.py 2013-01-30 22:10:34 +0000
@@ -70,9 +70,9 @@
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)
- self.buttonBox = create_button_box(exceptionDialog, u'buttonBox',
+ self.button_box = create_button_box(exceptionDialog, u'button_box',
[u'close'], [self.sendReportButton, self.saveReportButton, self.attachFileButton])
- self.exceptionLayout.addWidget(self.buttonBox)
+ self.exceptionLayout.addWidget(self.button_box)
self.retranslateUi(exceptionDialog)
QtCore.QObject.connect(self.descriptionTextEdit,
=== modified file 'openlp/core/ui/filerenamedialog.py'
--- openlp/core/ui/filerenamedialog.py 2012-12-29 20:56:56 +0000
+++ openlp/core/ui/filerenamedialog.py 2013-01-30 22:10:34 +0000
@@ -37,7 +37,7 @@
fileRenameDialog.setObjectName(u'fileRenameDialog')
fileRenameDialog.resize(300, 10)
self.dialogLayout = QtGui.QGridLayout(fileRenameDialog)
- self.dialogLayout.setObjectName(u'dialogLayout')
+ self.dialogLayout.setObjectName(u'dialog_layout')
self.fileNameLabel = QtGui.QLabel(fileRenameDialog)
self.fileNameLabel.setObjectName(u'fileNameLabel')
self.dialogLayout.addWidget(self.fileNameLabel, 0, 0)
@@ -45,8 +45,8 @@
self.fileNameEdit.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp(r'[^/\\?*|<>\[\]":+%]+'), self))
self.fileNameEdit.setObjectName(u'fileNameEdit')
self.dialogLayout.addWidget(self.fileNameEdit, 0, 1)
- self.buttonBox = create_button_box(fileRenameDialog, u'buttonBox', [u'cancel', u'ok'])
- self.dialogLayout.addWidget(self.buttonBox, 1, 0, 1, 2)
+ self.button_box = create_button_box(fileRenameDialog, u'button_box', [u'cancel', u'ok'])
+ self.dialogLayout.addWidget(self.button_box, 1, 0, 1, 2)
self.retranslateUi(fileRenameDialog)
self.setMaximumHeight(self.sizeHint().height())
=== modified file 'openlp/core/ui/firsttimelanguagedialog.py'
--- openlp/core/ui/firsttimelanguagedialog.py 2012-12-29 20:56:56 +0000
+++ openlp/core/ui/firsttimelanguagedialog.py 2013-01-30 22:10:34 +0000
@@ -39,7 +39,7 @@
self.dialogLayout = QtGui.QVBoxLayout(languageDialog)
self.dialogLayout.setContentsMargins(8, 8, 8, 8)
self.dialogLayout.setSpacing(8)
- self.dialogLayout.setObjectName(u'dialogLayout')
+ self.dialogLayout.setObjectName(u'dialog_layout')
self.infoLabel = QtGui.QLabel(languageDialog)
self.infoLabel.setObjectName(u'infoLabel')
self.dialogLayout.addWidget(self.infoLabel)
@@ -53,8 +53,8 @@
self.languageComboBox.setObjectName("languageComboBox")
self.languageLayout.addWidget(self.languageComboBox)
self.dialogLayout.addLayout(self.languageLayout)
- self.buttonBox = create_button_box(languageDialog, u'buttonBox', [u'cancel', u'ok'])
- self.dialogLayout.addWidget(self.buttonBox)
+ self.button_box = create_button_box(languageDialog, u'button_box', [u'cancel', u'ok'])
+ self.dialogLayout.addWidget(self.button_box)
self.retranslateUi(languageDialog)
self.setMaximumHeight(self.sizeHint().height())
=== modified file 'openlp/core/ui/formattingtagdialog.py'
--- openlp/core/ui/formattingtagdialog.py 2013-01-11 00:19:11 +0000
+++ openlp/core/ui/formattingtagdialog.py 2013-01-30 22:10:34 +0000
@@ -110,8 +110,8 @@
self.savePushButton.setObjectName(u'savePushButton')
self.dataGridLayout.addWidget(self.savePushButton, 4, 2, 1, 1)
self.listdataGridLayout.addWidget(self.editGroupBox, 2, 0, 1, 1)
- self.buttonBox = create_button_box(formattingTagDialog, u'buttonBox', [u'close'])
- self.listdataGridLayout.addWidget(self.buttonBox, 3, 0, 1, 1)
+ self.button_box = create_button_box(formattingTagDialog, u'button_box', [u'close'])
+ self.listdataGridLayout.addWidget(self.button_box, 3, 0, 1, 1)
self.retranslateUi(formattingTagDialog)
=== modified file 'openlp/core/ui/formattingtagform.py'
--- openlp/core/ui/formattingtagform.py 2012-12-29 20:56:56 +0000
+++ openlp/core/ui/formattingtagform.py 2013-01-30 22:10:34 +0000
@@ -53,7 +53,7 @@
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)
- QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'), self.close)
+ QtCore.QObject.connect(self.button_box, QtCore.SIGNAL(u'rejected()'), self.close)
QtCore.QObject.connect(self.descriptionLineEdit, QtCore.SIGNAL(u'textEdited(QString)'), self.onTextEdited)
QtCore.QObject.connect(self.tagLineEdit, QtCore.SIGNAL(u'textEdited(QString)'), self.onTextEdited)
QtCore.QObject.connect(self.startTagLineEdit, QtCore.SIGNAL(u'textEdited(QString)'), self.onTextEdited)
=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py 2013-01-30 18:29:10 +0000
+++ openlp/core/ui/mainwindow.py 2013-01-30 22:10:34 +0000
@@ -174,25 +174,25 @@
icon=u':/general/general_new.png',
shortcuts=[QtGui.QKeySequence(u'Ctrl+N')],
category=UiStrings().File,
- triggers=self.serviceManagerContents.onNewServiceClicked)
+ triggers=self.serviceManagerContents.on_new_service_clicked)
self.fileOpenItem = create_action(mainWindow, u'fileOpenItem',
icon=u':/general/general_open.png',
shortcuts=[QtGui.QKeySequence(u'Ctrl+O')],
category=UiStrings().File,
- triggers=self.serviceManagerContents.onLoadServiceClicked)
+ triggers=self.serviceManagerContents.on_load_service_clicked)
self.fileSaveItem = create_action(mainWindow, u'fileSaveItem',
icon=u':/general/general_save.png',
shortcuts=[QtGui.QKeySequence(u'Ctrl+S')],
category=UiStrings().File,
- triggers=self.serviceManagerContents.saveFile)
+ triggers=self.serviceManagerContents.save_file)
self.fileSaveAsItem = create_action(mainWindow, u'fileSaveAsItem',
shortcuts=[QtGui.QKeySequence(u'Ctrl+Shift+S')],
category=UiStrings().File,
- triggers=self.serviceManagerContents.saveFileAs)
+ triggers=self.serviceManagerContents.save_file_as)
self.printServiceOrderItem = create_action(mainWindow,
u'printServiceItem', shortcuts=[QtGui.QKeySequence(u'Ctrl+P')],
category=UiStrings().File,
- triggers=self.serviceManagerContents.printServiceOrder)
+ triggers=self.serviceManagerContents.print_service_order)
self.fileExitItem = create_action(mainWindow, u'fileExitItem',
icon=u':/system/system_exit.png',
shortcuts=[QtGui.QKeySequence(u'Alt+F4')],
@@ -528,7 +528,7 @@
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'cleanup'), self.cleanUp)
+ 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')
@@ -618,9 +618,9 @@
filename = args[0]
if not isinstance(filename, unicode):
filename = unicode(filename, sys.getfilesystemencoding())
- self.serviceManagerContents.loadFile(filename)
+ self.serviceManagerContents.load_file(filename)
elif Settings().value(self.generalSettingsSection + u'/auto open'):
- self.serviceManagerContents.loadLastFile()
+ self.serviceManagerContents.load_Last_file()
view_mode = Settings().value(u'%s/view mode' % self.generalSettingsSection)
if view_mode == u'default':
self.modeDefaultItem.setChecked(True)
@@ -866,7 +866,7 @@
'be applied the next time you start OpenLP.'),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
self.settingsImported = True
- self.cleanUp()
+ self.clean_up()
QtCore.QCoreApplication.exit()
def onSettingsExportItemClicked(self):
@@ -999,18 +999,18 @@
return
# If we just did a settings import, close without saving changes.
if self.settingsImported:
- self.cleanUp(False)
+ self.clean_up(False)
event.accept()
- if self.serviceManagerContents.isModified():
- ret = self.serviceManagerContents.saveModifiedService()
+ if self.serviceManagerContents.is_modified():
+ ret = self.serviceManagerContents.save_modified_service()
if ret == QtGui.QMessageBox.Save:
- if self.serviceManagerContents.decideSaveMethod():
- self.cleanUp()
+ if self.serviceManagerContents.decide_save_method():
+ self.clean_up()
event.accept()
else:
event.ignore()
elif ret == QtGui.QMessageBox.Discard:
- self.cleanUp()
+ self.clean_up()
event.accept()
else:
event.ignore()
@@ -1021,15 +1021,15 @@
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
QtGui.QMessageBox.Yes)
if ret == QtGui.QMessageBox.Yes:
- self.cleanUp()
+ self.clean_up()
event.accept()
else:
event.ignore()
else:
- self.cleanUp()
+ self.clean_up()
event.accept()
- def cleanUp(self, save_settings=True):
+ def clean_up(self, save_settings=True):
"""
Runs all the cleanup code before OpenLP shuts down.
@@ -1223,7 +1223,7 @@
action = create_action(self, u'',
text=u'&%d %s' % (fileId + 1, os.path.splitext(os.path.basename(
unicode(filename)))[0]), data=filename,
- triggers=self.serviceManagerContents.onRecentServiceClicked)
+ triggers=self.serviceManagerContents.on_recent_service_clicked)
self.recentFilesMenu.addAction(action)
clearRecentFilesAction = create_action(self, u'',
text=translate('OpenLP.MainWindow', 'Clear List', 'Clear List of recent files'),
=== modified file 'openlp/core/ui/media/mediacontroller.py'
--- openlp/core/ui/media/mediacontroller.py 2013-01-23 20:29:43 +0000
+++ openlp/core/ui/media/mediacontroller.py 2013-01-30 22:10:34 +0000
@@ -131,14 +131,14 @@
for item in player.audio_extensions_list:
if not item in self.audio_extensions_list:
self.audio_extensions_list.append(item)
- self.service_manager.supportedSuffixes(item[2:])
+ self.service_manager.supported_suffixes(item[2:])
self.video_extensions_list = []
for player in self.mediaPlayers.values():
if player.isActive:
for item in player.video_extensions_list:
if item not in self.video_extensions_list:
self.video_extensions_list.extend(item)
- self.service_manager.supportedSuffixes(item[2:])
+ self.service_manager.supported_suffixes(item[2:])
def register_players(self, player):
"""
=== modified file 'openlp/core/ui/media/playertab.py'
--- openlp/core/ui/media/playertab.py 2013-01-11 00:19:11 +0000
+++ openlp/core/ui/media/playertab.py 2013-01-30 22:10:34 +0000
@@ -194,7 +194,7 @@
set_media_players(self.usedPlayers, override_player)
player_string_changed = True
if player_string_changed:
- self.parent.resetSupportedSuffixes()
+ self.parent.reset_supported_suffixes()
Receiver.send_message(u'mediaitem_media_rebuild')
Receiver.send_message(u'config_screen_changed')
=== modified file 'openlp/core/ui/plugindialog.py'
--- openlp/core/ui/plugindialog.py 2013-01-11 00:19:11 +0000
+++ openlp/core/ui/plugindialog.py 2013-01-30 22:10:34 +0000
@@ -67,8 +67,8 @@
self.pluginInfoLayout.addRow(self.aboutLabel, self.aboutTextBrowser)
self.listLayout.addWidget(self.pluginInfoGroupBox)
self.pluginLayout.addLayout(self.listLayout)
- self.buttonBox = create_button_box(pluginViewDialog, u'buttonBox', [u'ok'])
- self.pluginLayout.addWidget(self.buttonBox)
+ self.button_box = create_button_box(pluginViewDialog, u'button_box', [u'ok'])
+ self.pluginLayout.addWidget(self.button_box)
self.retranslateUi(pluginViewDialog)
def retranslateUi(self, pluginViewDialog):
=== modified file 'openlp/core/ui/printserviceform.py'
--- openlp/core/ui/printserviceform.py 2013-01-11 00:19:11 +0000
+++ openlp/core/ui/printserviceform.py 2013-01-30 22:10:34 +0000
@@ -33,7 +33,7 @@
from PyQt4 import QtCore, QtGui
from lxml import html
-from openlp.core.lib import translate, get_text_file_string, Receiver, Settings, UiStrings
+from openlp.core.lib import translate, get_text_file_string, Receiver, Settings, UiStrings, Registry
from openlp.core.ui.printservicedialog import Ui_PrintServiceDialog, ZoomSize
from openlp.core.utils import AppLocation
@@ -108,13 +108,11 @@
class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
- def __init__(self, mainWindow, serviceManager):
+ def __init__(self):
"""
Constructor
"""
- QtGui.QDialog.__init__(self, mainWindow)
- self.mainWindow = mainWindow
- self.serviceManager = serviceManager
+ QtGui.QDialog.__init__(self, self.main_window)
self.printer = QtGui.QPrinter()
self.printDialog = QtGui.QPrintDialog(self.printer, self)
self.document = QtGui.QTextDocument()
@@ -140,7 +138,8 @@
QtCore.QObject.connect(self.zoomComboBox, QtCore.SIGNAL(u'currentIndexChanged(int)'), self.displaySizeChanged)
QtCore.QObject.connect(self.plainCopy, QtCore.SIGNAL(u'triggered()'), self.copyText)
QtCore.QObject.connect(self.htmlCopy, QtCore.SIGNAL(u'triggered()'), self.copyHtmlText)
- QtCore.QObject.connect(self.slideTextCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), self.onSlideTextCheckBoxChanged)
+ QtCore.QObject.connect(self.slideTextCheckBox, QtCore.SIGNAL(u'stateChanged(int)'),
+ self.onSlideTextCheckBoxChanged)
self.updatePreviewText()
def toggleOptions(self, checked):
@@ -170,7 +169,7 @@
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.serviceManager.serviceItems):
+ for index, item in enumerate(self.service_manager.serviceItems):
self._addPreviewItem(html_data.body, item[u'service_item'], index)
# Add the custom service notes:
if self.footerTextEdit.toPlainText():
@@ -319,14 +318,14 @@
# remove the icon from the text
clipboard_text = clipboard_text.replace(u'\ufffc\xa0', u'')
# and put it all on the clipboard
- self.mainWindow.clipboard.setText(clipboard_text)
+ self.main_window.clipboard.setText(clipboard_text)
def copyHtmlText(self):
"""
Copies the display text to the clipboard as Html
"""
self.update_song_usage()
- self.mainWindow.clipboard.setText(self.document.toHtml())
+ self.main_window.clipboard.setText(self.document.toHtml())
def printServiceOrder(self):
"""
@@ -392,6 +391,26 @@
# Only continue when we include the song's text.
if not self.slideTextCheckBox.isChecked():
return
- for item in self.serviceManager.serviceItems:
+ for item in self.service_manager.serviceItems:
# Trigger Audit requests
Receiver.send_message(u'print_service_started', [item[u'service_item']])
+
+ 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)
\ No newline at end of file
=== modified file 'openlp/core/ui/serviceitemeditdialog.py'
--- openlp/core/ui/serviceitemeditdialog.py 2012-12-29 20:56:56 +0000
+++ openlp/core/ui/serviceitemeditdialog.py 2013-01-30 22:10:34 +0000
@@ -35,29 +35,29 @@
class Ui_ServiceItemEditDialog(object):
def setupUi(self, serviceItemEditDialog):
serviceItemEditDialog.setObjectName(u'serviceItemEditDialog')
- self.dialogLayout = QtGui.QGridLayout(serviceItemEditDialog)
- self.dialogLayout.setContentsMargins(8, 8, 8, 8)
- self.dialogLayout.setSpacing(8)
- self.dialogLayout.setObjectName(u'dialogLayout')
- self.listWidget = QtGui.QListWidget(serviceItemEditDialog)
- self.listWidget.setAlternatingRowColors(True)
- self.listWidget.setObjectName(u'listWidget')
- self.dialogLayout.addWidget(self.listWidget, 0, 0)
- self.buttonLayout = QtGui.QVBoxLayout()
- self.buttonLayout.setObjectName(u'buttonLayout')
- self.deleteButton = create_button(serviceItemEditDialog, u'deleteButton', role=u'delete',
- click=serviceItemEditDialog.onDeleteButtonClicked)
- self.buttonLayout.addWidget(self.deleteButton)
- self.buttonLayout.addStretch()
- self.upButton = create_button(serviceItemEditDialog, u'upButton', role=u'up',
- click=serviceItemEditDialog.onUpButtonClicked)
- self.downButton = create_button(serviceItemEditDialog, u'downButton', role=u'down',
- click=serviceItemEditDialog.onDownButtonClicked)
- self.buttonLayout.addWidget(self.upButton)
- self.buttonLayout.addWidget(self.downButton)
- self.dialogLayout.addLayout(self.buttonLayout, 0, 1)
- self.buttonBox = create_button_box(serviceItemEditDialog, u'buttonBox', [u'cancel', u'save'])
- self.dialogLayout.addWidget(self.buttonBox, 1, 0, 1, 2)
+ self.dialog_layout = QtGui.QGridLayout(serviceItemEditDialog)
+ self.dialog_layout.setContentsMargins(8, 8, 8, 8)
+ self.dialog_layout.setSpacing(8)
+ self.dialog_layout.setObjectName(u'dialog_layout')
+ self.list_widget = QtGui.QListWidget(serviceItemEditDialog)
+ self.list_widget.setAlternatingRowColors(True)
+ self.list_widget.setObjectName(u'list_widget')
+ self.dialog_layout.addWidget(self.list_widget, 0, 0)
+ self.button_layout = QtGui.QVBoxLayout()
+ self.button_layout.setObjectName(u'button_layout')
+ self.delete_button = create_button(serviceItemEditDialog, u'deleteButton', role=u'delete',
+ click=serviceItemEditDialog.on_delete_button_clicked)
+ self.button_layout.addWidget(self.delete_button)
+ self.button_layout.addStretch()
+ self.up_button = create_button(serviceItemEditDialog, u'upButton', role=u'up',
+ click=serviceItemEditDialog.on_up_button_clicked)
+ self.down_button = create_button(serviceItemEditDialog, u'downButton', role=u'down',
+ click=serviceItemEditDialog.on_down_button_clicked)
+ self.button_layout.addWidget(self.up_button)
+ self.button_layout.addWidget(self.down_button)
+ self.dialog_layout.addLayout(self.button_layout, 0, 1)
+ self.button_box = create_button_box(serviceItemEditDialog, u'button_box', [u'cancel', u'save'])
+ self.dialog_layout.addWidget(self.button_box, 1, 0, 1, 2)
self.retranslateUi(serviceItemEditDialog)
def retranslateUi(self, serviceItemEditDialog):
=== modified file 'openlp/core/ui/serviceitemeditform.py'
--- openlp/core/ui/serviceitemeditform.py 2012-12-29 20:56:56 +0000
+++ openlp/core/ui/serviceitemeditform.py 2013-01-30 22:10:34 +0000
@@ -28,6 +28,7 @@
###############################################################################
from PyQt4 import QtCore, QtGui
+from openlp.core.lib import Registry
from serviceitemeditdialog import Ui_ServiceItemEditDialog
@@ -35,91 +36,92 @@
"""
This is the form that is used to edit the verses of the song.
"""
- def __init__(self, parent=None):
+ def __init__(self):
"""
Constructor
"""
- QtGui.QDialog.__init__(self, parent)
+ QtGui.QDialog.__init__(self, self.main_window)
self.setupUi(self)
- self.itemList = []
- QtCore.QObject.connect(self.listWidget, QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged)
+ self.item_list = []
+ QtCore.QObject.connect(self.list_widget, QtCore.SIGNAL(u'currentRowChanged(int)'),
+ self.on_current_row_changed)
- def setServiceItem(self, item):
+ def set_service_item(self, item):
self.item = item
- self.itemList = []
+ self.item_list = []
if self.item.is_image():
self.data = True
for frame in self.item._raw_frames:
- self.itemList.append(frame)
- self.loadData()
- self.listWidget.setCurrentItem(self.listWidget.currentItem())
+ self.item_list.append(frame)
+ self.load_data()
+ self.list_widget.setCurrentItem(self.list_widget.currentItem())
- def getServiceItem(self):
+ def get_service_item(self):
if self.data:
self.item._raw_frames = []
if self.item.is_image():
- for item in self.itemList:
+ for item in self.item_list:
self.item.add_from_image(item[u'path'], item[u'title'])
self.item.render()
return self.item
- def loadData(self):
+ def load_data(self):
"""
Loads the image list.
"""
- self.listWidget.clear()
- for frame in self.itemList:
+ self.list_widget.clear()
+ for frame in self.item_list:
item_name = QtGui.QListWidgetItem(frame[u'title'])
- self.listWidget.addItem(item_name)
+ self.list_widget.addItem(item_name)
- def onDeleteButtonClicked(self):
+ def on_delete_button_clicked(self):
"""
Delete the current row.
"""
- item = self.listWidget.currentItem()
+ item = self.list_widget.currentItem()
if not item:
return
- row = self.listWidget.row(item)
- self.itemList.pop(row)
- self.loadData()
- if row == self.listWidget.count():
- self.listWidget.setCurrentRow(row - 1)
+ row = self.list_widget.row(item)
+ self.item_list.pop(row)
+ self.load_data()
+ if row == self.list_widget.count():
+ self.list_widget.setCurrentRow(row - 1)
else:
- self.listWidget.setCurrentRow(row)
+ self.list_widget.setCurrentRow(row)
- def onUpButtonClicked(self):
+ def on_up_button_clicked(self):
"""
Move the current row up in the list.
"""
- self.__moveItem(u'up')
+ self.__move_item(u'up')
- def onDownButtonClicked(self):
+ def on_down_button_clicked(self):
"""
Move the current row down in the list
"""
- self.__moveItem(u'down')
+ self.__move_item(u'down')
- def __moveItem(self, direction=u''):
+ def __move_item(self, direction=u''):
"""
Move the current item.
"""
if not direction:
return
- item = self.listWidget.currentItem()
+ item = self.list_widget.currentItem()
if not item:
return
- row = self.listWidget.row(item)
- temp = self.itemList[row]
- self.itemList.pop(row)
+ row = self.list_widget.row(item)
+ temp = self.item_list[row]
+ self.item_list.pop(row)
if direction == u'up':
row -= 1
else:
row += 1
- self.itemList.insert(row, temp)
- self.loadData()
- self.listWidget.setCurrentRow(row)
+ self.item_list.insert(row, temp)
+ self.load_data()
+ self.list_widget.setCurrentRow(row)
- def onCurrentRowChanged(self, row):
+ def on_current_row_changed(self, row):
"""
Called when the currentRow has changed.
@@ -127,19 +129,29 @@
The row number (int).
"""
# Disable all buttons, as no row is selected or only one image is left.
- if row == -1 or self.listWidget.count() == 1:
- self.downButton.setEnabled(False)
- self.upButton.setEnabled(False)
- self.deleteButton.setEnabled(False)
+ if row == -1 or self.list_widget.count() == 1:
+ self.down_button.setEnabled(False)
+ self.up_button.setEnabled(False)
+ self.delete_button.setEnabled(False)
else:
# Check if we are at the end of the list.
- if self.listWidget.count() == row + 1:
- self.downButton.setEnabled(False)
+ if self.list_widget.count() == row + 1:
+ self.down_button.setEnabled(False)
else:
- self.downButton.setEnabled(True)
+ self.down_button.setEnabled(True)
# Check if we are at the beginning of the list.
if row == 0:
- self.upButton.setEnabled(False)
+ self.up_button.setEnabled(False)
else:
- self.upButton.setEnabled(True)
- self.deleteButton.setEnabled(True)
+ self.up_button.setEnabled(True)
+ self.delete_button.setEnabled(True)
+
+ 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
=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py 2013-01-30 17:56:00 +0000
+++ openlp/core/ui/servicemanager.py 2013-01-30 22:10:34 +0000
@@ -57,13 +57,16 @@
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.onMoveSelectionUp()
+ self.serviceManager.on_move_selection_up()
event.accept()
elif event.key() == QtCore.Qt.Key_Down:
- self.serviceManager.onMoveSelectionDown()
+ self.serviceManager.on_move_selection_down()
event.accept()
elif event.key() == QtCore.Qt.Key_Delete:
self.serviceManager.onDeleteFromService()
@@ -85,148 +88,124 @@
event.ignore()
return
drag = QtGui.QDrag(self)
- mimeData = QtCore.QMimeData()
- drag.setMimeData(mimeData)
- mimeData.setText(u'ServiceManager')
+ mime_data = QtCore.QMimeData()
+ drag.setMimeData(mime_data)
+ mime_data.setText(u'ServiceManager')
drag.start(QtCore.Qt.CopyAction)
-
-class ServiceManager(QtGui.QWidget):
- """
- Manages the services. This involves taking text strings from plugins and
- adding them to the service. This service can then be zipped up with all
- the resources used into one OSZ or oszl file for use on any OpenLP v2
- installation. Also handles the UI tasks of moving things up and down etc.
- """
- def __init__(self, parent=None):
- """
- Sets up the service manager, toolbars, list view, et al.
- """
- QtGui.QWidget.__init__(self, parent)
- self.active = build_icon(QtGui.QImage(u':/media/auto-start_active.png'))
- self.inactive = build_icon(QtGui.QImage(u':/media/auto-start_inactive.png'))
- Registry().register(u'service_manager', self)
- self.serviceItems = []
- self.suffixes = []
- self.dropPosition = 0
- self.expandTabs = False
- self.service_id = 0
- # is a new service and has not been saved
- self._modified = False
- self._fileName = u''
- self.service_has_all_original_files = True
- self.serviceNoteForm = ServiceNoteForm(self.main_window)
- self.serviceItemEditForm = ServiceItemEditForm(self.main_window)
- self.startTimeForm = StartTimeForm(self.main_window)
- # start with the layout
- self.layout = QtGui.QVBoxLayout(self)
- self.layout.setSpacing(0)
- self.layout.setMargin(0)
+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.onNewServiceClicked)
+ 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.onLoadServiceClicked)
+ 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.decideSaveMethod)
+ tooltip=translate('OpenLP.ServiceManager', 'Save this service.'), triggers=self.decide_save_method)
self.toolbar.addSeparator()
- self.themeLabel = QtGui.QLabel(u'%s:' % UiStrings().Theme, self)
- self.themeLabel.setMargin(3)
- self.themeLabel.setObjectName(u'themeLabel')
- self.toolbar.addToolbarWidget(self.themeLabel)
- self.themeComboBox = QtGui.QComboBox(self.toolbar)
- self.themeComboBox.setToolTip(translate('OpenLP.ServiceManager', 'Select a theme for the service.'))
- self.themeComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength)
- self.themeComboBox.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
- self.themeComboBox.setObjectName(u'themeComboBox')
- self.toolbar.addToolbarWidget(self.themeComboBox)
+ 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.serviceManagerList = ServiceManagerList(self)
- self.serviceManagerList.setEditTriggers(
+ self.service_manager_list = ServiceManagerList(self)
+ self.service_manager_list.setEditTriggers(
QtGui.QAbstractItemView.CurrentChanged |
QtGui.QAbstractItemView.DoubleClicked |
QtGui.QAbstractItemView.EditKeyPressed)
- self.serviceManagerList.setDragDropMode(QtGui.QAbstractItemView.DragDrop)
- self.serviceManagerList.setAlternatingRowColors(True)
- self.serviceManagerList.setHeaderHidden(True)
- self.serviceManagerList.setExpandsOnDoubleClick(False)
- self.serviceManagerList.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
- QtCore.QObject.connect(self.serviceManagerList, QtCore.SIGNAL('customContextMenuRequested(QPoint)'),
- self.contextMenu)
- self.serviceManagerList.setObjectName(u'serviceManagerList')
+ 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.serviceManagerList.__class__.dragEnterEvent = self.dragEnterEvent
- self.serviceManagerList.__class__.dragMoveEvent = self.dragEnterEvent
- self.serviceManagerList.__class__.dropEvent = self.dropEvent
- self.layout.addWidget(self.serviceManagerList)
+ 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.orderToolbar = OpenLPToolbar(self)
+ self.order_toolbar = OpenLPToolbar(self)
action_list = ActionList.get_instance()
action_list.add_category(UiStrings().Service, CategoryOrder.standardToolbar)
- self.serviceManagerList.moveTop = self.orderToolbar.addToolbarAction(u'moveTop',
+ 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.serviceManagerList.moveUp = self.orderToolbar.addToolbarAction(u'moveUp',
+ 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.serviceManagerList.moveDown = self.orderToolbar.addToolbarAction(u'moveDown',
+ 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.serviceManagerList.moveBottom = self.orderToolbar.addToolbarAction(u'moveBottom',
+ 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.serviceManagerList.down = self.orderToolbar.addToolbarAction(u'down',
+ 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.onMoveSelectionDown)
- action_list.add_action(self.serviceManagerList.down)
- self.serviceManagerList.up = self.orderToolbar.addToolbarAction(u'up',
+ 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.onMoveSelectionUp)
- action_list.add_action(self.serviceManagerList.up)
- self.orderToolbar.addSeparator()
- self.serviceManagerList.delete = self.orderToolbar.addToolbarAction(u'delete',
+ '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.orderToolbar.addSeparator()
- self.serviceManagerList.expand = self.orderToolbar.addToolbarAction(u'expand',
+ 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.serviceManagerList.collapse = self.orderToolbar.addToolbarAction(u'collapse',
+ 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.orderToolbar.addSeparator()
- self.serviceManagerList.makeLive = self.orderToolbar.addToolbarAction(u'makeLive',
+ 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.makeLive)
- self.layout.addWidget(self.orderToolbar)
+ 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.themeComboBox, QtCore.SIGNAL(u'activated(int)'), self.onThemeComboBoxSelected)
- QtCore.QObject.connect(self.serviceManagerList, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onMakeLive)
- QtCore.QObject.connect(self.serviceManagerList, QtCore.SIGNAL(u'itemCollapsed(QTreeWidgetItem*)'),
+ 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.serviceManagerList, QtCore.SIGNAL(u'itemExpanded(QTreeWidgetItem*)'), self.expanded)
- QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.updateThemeList)
- QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_preview_live'), self.previewLive)
- QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_next_item'), self.nextItem)
+ 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.previousItem)
- QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_set_item'), self.onSetItem)
- QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.configUpdated)
+ 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.regenerateServiceItems)
+ 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
@@ -240,57 +219,100 @@
self.addToAction.setIcon(build_icon(u':/general/general_edit.png'))
# build the context menu
self.menu = QtGui.QMenu()
- self.editAction = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Edit Item'),
- icon=u':/general/general_edit.png', triggers=self.remoteEdit)
- self.maintainAction = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Reorder Item'),
- icon=u':/general/general_edit.png', triggers=self.onServiceItemEditForm)
- self.notesAction = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Notes'),
- icon=u':/services/service_notes.png', triggers=self.onServiceItemNoteForm)
- self.timeAction = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Start Time'),
- icon=u':/media/media_time.png', triggers=self.onStartTimeForm)
- self.autoStartAction = create_widget_action(self.menu, text=u'',
- icon=u':/media/auto-start_active.png', triggers=self.onAutoStart)
+ 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.serviceManagerList.delete)
+ 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.autoPlaySlidesGroup = QtGui.QMenu(translate('OpenLP.ServiceManager', '&Auto play slides'))
- self.menu.addMenu(self.autoPlaySlidesGroup)
- self.autoPlaySlidesLoop = create_widget_action(self.autoPlaySlidesGroup,
+ 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.toggleAutoPlaySlidesLoop)
- self.autoPlaySlidesOnce = create_widget_action(self.autoPlaySlidesGroup,
+ 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.toggleAutoPlaySlidesOnce)
- self.autoPlaySlidesGroup.addSeparator()
- self.timedSlideInterval = create_widget_action(self.autoPlaySlidesGroup,
+ 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.onTimedSlideInterval)
+ checked=False, triggers=self.on_timed_slide_interval)
self.menu.addSeparator()
- self.previewAction = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', 'Show &Preview'),
- icon=u':/general/general_preview.png', triggers=self.makePreview)
+ 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.serviceManagerList.makeLive)
+ self.menu.addAction(self.service_manager_list.make_live)
self.menu.addSeparator()
- self.themeMenu = QtGui.QMenu(translate('OpenLP.ServiceManager', '&Change Item Theme'))
- self.menu.addMenu(self.themeMenu)
- self.serviceManagerList.addActions(
- [self.serviceManagerList.moveDown,
- self.serviceManagerList.moveUp,
- self.serviceManagerList.makeLive,
- self.serviceManagerList.moveTop,
- self.serviceManagerList.moveBottom,
- self.serviceManagerList.up,
- self.serviceManagerList.down,
- self.serviceManagerList.expand,
- self.serviceManagerList.collapse
+ 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
])
- self.configUpdated()
-
- def setModified(self, modified=True):
+
+ def drag_enter_event(self, event):
+ """
+ Accept Drag events
+
+ ``event``
+ Handle of the event pint passed
+ """
+ event.accept()
+
+
+class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
+ """
+ Manages the services. This involves taking text strings from plugins and
+ adding them to the service. This service can then be zipped up with all
+ the resources used into one OSZ or oszl file for use on any OpenLP v2
+ installation. Also handles the UI tasks of moving things up and down etc.
+ """
+ def __init__(self, parent=None):
+ """
+ Sets up the service manager, toolbars, list view, et al.
+ """
+ QtGui.QWidget.__init__(self, parent)
+ self.active = build_icon(QtGui.QImage(u':/media/auto-start_active.png'))
+ self.inactive = build_icon(QtGui.QImage(u':/media/auto-start_inactive.png'))
+ Registry().register(u'service_manager', self)
+ self.service_items = []
+ self.suffixes = []
+ self.drop_position = 0
+ self.expand_tabs = False
+ self.service_id = 0
+ # is a new service and has not been saved
+ self._modified = False
+ self._file_name = u''
+ self.service_has_all_original_files = True
+ self.serviceNoteForm = ServiceNoteForm()
+ self.serviceItemEditForm = ServiceItemEditForm()
+ self.startTimeForm = StartTimeForm()
+ # start with the layout
+ self.layout = QtGui.QVBoxLayout(self)
+ self.layout.setSpacing(0)
+ self.layout.setMargin(0)
+ self.setup_ui(self)
+ self.config_updated()
+
+ def set_modified(self, modified=True):
"""
Setter for property "modified". Sets whether or not the current service
has been modified.
@@ -298,50 +320,50 @@
if modified:
self.service_id += 1
self._modified = modified
- serviceFile = self.shortFileName() or translate('OpenLP.ServiceManager', 'Untitled Service')
- self.main_window.setServiceModified(modified, serviceFile)
+ service_file = self.short_file_name() or translate('OpenLP.ServiceManager', 'Untitled Service')
+ self.main_window.setServiceModified(modified, service_file)
- def isModified(self):
+ def is_modified(self):
"""
Getter for boolean property "modified".
"""
return self._modified
- def setFileName(self, fileName):
+ def set_file_name(self, file_name):
"""
Setter for service file.
"""
- self._fileName = unicode(fileName)
- self.main_window.setServiceModified(self.isModified(), self.shortFileName())
- Settings().setValue(u'servicemanager/last file', fileName)
- self._saveLite = self._fileName.endswith(u'.oszl')
+ self._file_name = unicode(file_name)
+ self.main_window.setServiceModified(self.is_modified(), self.short_file_name())
+ Settings().setValue(u'servicemanager/last file', file_name)
+ self._saveLite = self._file_name.endswith(u'.oszl')
- def fileName(self):
+ def file_name(self):
"""
Return the current file name including path.
"""
- return self._fileName
+ return self._file_name
- def shortFileName(self):
+ def short_file_name(self):
"""
Return the current file name, excluding the path.
"""
- return split_filename(self._fileName)[1]
+ return split_filename(self._file_name)[1]
- def configUpdated(self):
+ def config_updated(self):
"""
Triggered when Config dialog is updated.
"""
- self.expandTabs = Settings().value(u'advanced/expand service item')
+ self.expand_tabs = Settings().value(u'advanced/expand service item')
- def resetSupportedSuffixes(self):
+ def reset_supported_suffixes(self):
"""
Resets the Suffixes list.
"""
self.suffixes = []
- def supportedSuffixes(self, suffix):
+ def supported_suffixes(self, suffix):
"""
Adds Suffixes supported to the master list. Called from Plugins.
@@ -351,48 +373,48 @@
if not suffix in self.suffixes:
self.suffixes.append(suffix)
- def onNewServiceClicked(self):
+ def on_new_service_clicked(self):
"""
Create a new service.
"""
- if self.isModified():
- result = self.saveModifiedService()
+ if self.is_modified():
+ result = self.save_modified_service()
if result == QtGui.QMessageBox.Cancel:
return False
elif result == QtGui.QMessageBox.Save:
- if not self.decideSaveMethod():
+ if not self.decide_save_method():
return False
- self.newFile()
+ self.new_file()
- def onLoadServiceClicked(self, loadFile=None):
+ def on_load_service_clicked(self, load_file=None):
"""
Loads the service file and saves the existing one it there is one
unchanged
- ``loadFile``
+ ``load_file``
The service file to the loaded. Will be None is from menu so
selection will be required.
"""
- if self.isModified():
- result = self.saveModifiedService()
+ if self.is_modified():
+ result = self.save_modified_service()
if result == QtGui.QMessageBox.Cancel:
return False
elif result == QtGui.QMessageBox.Save:
- self.decideSaveMethod()
- if not loadFile:
- fileName = QtGui.QFileDialog.getOpenFileName(self.main_window,
+ self.decide_save_method()
+ if not load_file:
+ file_name = QtGui.QFileDialog.getOpenfile_name(self.main_window,
translate('OpenLP.ServiceManager', 'Open File'),
SettingsManager.get_last_dir(self.main_window.serviceManagerSettingsSection),
translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz *.oszl)'))
- if not fileName:
+ if not file_name:
return False
else:
- fileName = loadFile
+ file_name = load_file
Settings().setValue(self.main_window.serviceManagerSettingsSection + u'/last directory',
- split_filename(fileName)[0])
- self.loadFile(fileName)
+ split_filename(file_name)[0])
+ self.load_file(file_name)
- def saveModifiedService(self):
+ def save_modified_service(self):
"""
Check to see if a service needs to be saved.
"""
@@ -402,26 +424,26 @@
'The current service has been modified. Would you like to save this service?'),
QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard | QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Save)
- def onRecentServiceClicked(self):
+ def on_recent_service_clicked(self):
"""
Load a recent file as the service triggered by mainwindow recent service list.
"""
sender = self.sender()
- self.loadFile(sender.data())
+ self.load_file(sender.data())
- def newFile(self):
+ def new_file(self):
"""
Create a blank new service file.
"""
- self.serviceManagerList.clear()
- self.serviceItems = []
- self.setFileName(u'')
+ self.service_manager_list.clear()
+ self.service_items = []
+ self.set_file_name(u'')
self.service_id += 1
- self.setModified(False)
+ self.set_modified(False)
Settings().setValue(u'servicemanager/last file', u'')
Receiver.send_message(u'servicemanager_new_service')
- def saveFile(self):
+ def save_file(self):
"""
Save the current service file.
@@ -430,17 +452,17 @@
Audio files are also copied into the service manager directory, and
then packaged into the zip file.
"""
- if not self.fileName():
- return self.saveFileAs()
+ if not self.file_name():
+ return self.save_file_as()
temp_file, temp_file_name = mkstemp(u'.osz', u'openlp_')
# We don't need the file handle.
os.close(temp_file)
log.debug(temp_file_name)
- path_file_name = unicode(self.fileName())
+ path_file_name = unicode(self.file_name())
path, file_name = os.path.split(path_file_name)
- basename = os.path.splitext(file_name)[0]
- service_file_name = '%s.osd' % basename
- log.debug(u'ServiceManager.saveFile - %s', path_file_name)
+ base_name = os.path.splitext(file_name)[0]
+ service_file_name = '%s.osd' % base_name
+ log.debug(u'ServiceManager.save_file - %s', path_file_name)
Settings().setValue(self.main_window.serviceManagerSettingsSection + u'/last directory', path)
service = []
write_list = []
@@ -449,9 +471,9 @@
total_size = 0
Receiver.send_message(u'cursor_busy')
# Number of items + 1 to zip it
- self.main_window.displayProgressBar(len(self.serviceItems) + 1)
+ self.main_window.displayProgressBar(len(self.service_items) + 1)
# Get list of missing files, and list of files to write
- for item in self.serviceItems:
+ for item in self.service_items:
if not item[u'service_item'].uses_file():
continue
for frame in item[u'service_item'].get_frames():
@@ -475,37 +497,37 @@
return False
Receiver.send_message(u'cursor_busy')
# Check if item contains a missing file.
- for item in list(self.serviceItems):
+ for item in list(self.service_items):
self.main_window.incrementProgressBar()
item[u'service_item'].remove_invalid_frames(missing_list)
if item[u'service_item'].missing_frames():
- self.serviceItems.remove(item)
+ self.service_items.remove(item)
else:
service_item = item[u'service_item'].get_service_repr(self._saveLite)
if service_item[u'header'][u'background_audio']:
- for i, filename in enumerate(service_item[u'header'][u'background_audio']):
- new_file = os.path.join(u'audio', item[u'service_item'].unique_identifier, filename)
- audio_files.append((filename, new_file))
+ for i, file_name in enumerate(service_item[u'header'][u'background_audio']):
+ new_file = os.path.join(u'audio', item[u'service_item'].unique_identifier, file_name)
+ audio_files.append((file_name, new_file))
service_item[u'header'][u'background_audio'][i] = new_file
# Add the service item to the service.
service.append({u'serviceitem': service_item})
- self.repaintServiceList(-1, -1)
+ self.repaint_service_list(-1, -1)
for file_item in write_list:
file_size = os.path.getsize(file_item)
total_size += file_size
- log.debug(u'ServiceManager.savefile - ZIP contents size is %i bytes' % total_size)
+ log.debug(u'ServiceManager.save_file - ZIP contents size is %i bytes' % total_size)
service_content = cPickle.dumps(service)
# Usual Zip file cannot exceed 2GiB, file with Zip64 cannot be
# extracted using unzip in UNIX.
allow_zip_64 = (total_size > 2147483648 + len(service_content))
- log.debug(u'ServiceManager.saveFile - allowZip64 is %s' % allow_zip_64)
+ log.debug(u'ServiceManager.save_file - allowZip64 is %s' % allow_zip_64)
zip_file = None
success = True
self.main_window.incrementProgressBar()
try:
zip_file = zipfile.ZipFile(temp_file_name, 'w', zipfile.ZIP_STORED, allow_zip_64)
# First we add service contents.
- # We save ALL filenames into ZIP using UTF-8.
+ # We save ALL file_names into ZIP using UTF-8.
zip_file.writestr(service_file_name.encode(u'utf-8'), service_content)
# Finally add all the listed media files.
for write_from in write_list:
@@ -539,34 +561,34 @@
try:
shutil.copy(temp_file_name, path_file_name)
except:
- return self.saveFileAs()
+ return self.save_file_as()
self.main_window.addRecentFile(path_file_name)
- self.setModified(False)
+ self.set_modified(False)
delete_file(temp_file_name)
return success
- def saveLocalFile(self):
+ def save_local_file(self):
"""
Save the current service file but leave all the file references alone to point to the current machine.
This format is not transportable as it will not contain any files.
"""
- if not self.fileName():
- return self.saveFileAs()
+ if not self.file_name():
+ return self.save_file_as()
temp_file, temp_file_name = mkstemp(u'.oszl', u'openlp_')
# We don't need the file handle.
os.close(temp_file)
log.debug(temp_file_name)
- path_file_name = unicode(self.fileName())
+ path_file_name = unicode(self.file_name())
path, file_name = os.path.split(path_file_name)
base_name = os.path.splitext(file_name)[0]
service_file_name = '%s.osd' % base_name
- log.debug(u'ServiceManager.saveFile - %s', path_file_name)
+ 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')
# Number of items + 1 to zip it
- self.main_window.displayProgressBar(len(self.serviceItems) + 1)
- for item in self.serviceItems:
+ self.main_window.displayProgressBar(len(self.service_items) + 1)
+ for item in self.service_items:
self.main_window.incrementProgressBar()
service_item = item[u'service_item'].get_service_repr(self._saveLite)
#@todo check for file item on save.
@@ -597,15 +619,15 @@
try:
shutil.copy(temp_file_name, path_file_name)
except:
- return self.saveFileAs()
+ return self.save_file_as()
self.main_window.addRecentFile(path_file_name)
- self.setModified(False)
+ self.set_modified(False)
delete_file(temp_file_name)
return success
- def saveFileAs(self):
+ def save_file_as(self):
"""
- Get a file name and then call :func:`ServiceManager.saveFile` to
+ Get a file name and then call :func:`ServiceManager.save_file` to
save the file.
"""
default_service_enabled = Settings().value(u'advanced/default service enabled')
@@ -623,59 +645,59 @@
time = now + timedelta(days=day_delta)
local_time = time.replace(hour=service_hour, minute=service_minute)
default_pattern = Settings().value(u'advanced/default service name')
- default_filename = format_time(default_pattern, local_time)
+ default_file_name = format_time(default_pattern, local_time)
else:
- default_filename = u''
+ default_file_name = u''
directory = Settings().value(self.main_window.serviceManagerSettingsSection + u'/last directory')
- path = os.path.join(directory, default_filename)
+ path = os.path.join(directory, default_file_name)
# 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._fileName.endswith(u'oszl') or self.service_has_all_original_files:
- fileName = QtGui.QFileDialog.getSaveFileName(self.main_window, UiStrings().SaveService, path,
+ 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,
translate('OpenLP.ServiceManager',
'OpenLP Service Files (*.osz);; OpenLP Service Files - lite (*.oszl)'))
else:
- fileName = QtGui.QFileDialog.getSaveFileName(self.main_window, UiStrings().SaveService, path,
+ file_name = QtGui.QFileDialog.getSavefile_name(self.main_window, UiStrings().SaveService, path,
translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz);;'))
- if not fileName:
+ if not file_name:
return False
- if os.path.splitext(fileName)[1] == u'':
- fileName += u'.osz'
+ if os.path.splitext(file_name)[1] == u'':
+ file_name += u'.osz'
else:
- ext = os.path.splitext(fileName)[1]
- fileName.replace(ext, u'.osz')
- self.setFileName(fileName)
- self.decideSaveMethod()
+ ext = os.path.splitext(file_name)[1]
+ file_name.replace(ext, u'.osz')
+ self.set_file_name(file_name)
+ self.decide_save_method()
- def decideSaveMethod(self):
+ def decide_save_method(self):
"""
Determine which type of save method to use.
"""
- if not self.fileName():
- return self.saveFileAs()
+ if not self.file_name():
+ return self.save_file_as()
if self._saveLite:
- return self.saveLocalFile()
+ return self.save_local_file()
else:
- return self.saveFile()
+ return self.save_file()
- def loadFile(self, fileName):
+ def load_file(self, file_name):
"""
Load an existing service file
"""
- if not fileName:
- return False
- fileName = unicode(fileName)
- if not os.path.exists(fileName):
- return False
- zip = None
- fileTo = None
+ if not file_name:
+ return False
+ file_name = unicode(file_name)
+ if not os.path.exists(file_name):
+ return False
+ zip_file = None
+ file_to = None
try:
- zip = zipfile.ZipFile(fileName)
- for zipinfo in zip.infolist():
+ zip_file = zipfile.ZipFile(file_name)
+ for zip_info in zip_file.infolist():
try:
- ucsfile = zipinfo.filename.decode(u'utf-8')
+ ucsfile = zip_info.filename.decode(u'utf-8')
except UnicodeDecodeError:
- log.exception(u'Filename "%s" is not valid UTF-8' % zipinfo.filename.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
@@ -683,197 +705,200 @@
if not osfile.startswith(u'audio'):
osfile = os.path.split(osfile)[1]
log.debug(u'Extract file: %s', osfile)
- zipinfo.filename = osfile
- zip.extract(zipinfo, self.servicePath)
+ zip_info.filename = osfile
+ zip_file.extract(zip_info, self.servicePath)
if osfile.endswith(u'osd'):
p_file = os.path.join(self.servicePath, osfile)
if 'p_file' in locals():
Receiver.send_message(u'cursor_busy')
- fileTo = open(p_file, u'r')
- items = cPickle.load(fileTo)
- fileTo.close()
- self.newFile()
- self.setFileName(fileName)
+ file_to = open(p_file, u'r')
+ items = cPickle.load(file_to)
+ file_to.close()
+ self.new_file()
+ self.set_file_name(file_name)
self.main_window.displayProgressBar(len(items))
for item in items:
self.main_window.incrementProgressBar()
- serviceItem = ServiceItem()
+ service_item = ServiceItem()
if self._saveLite:
- serviceItem.set_from_service(item)
+ service_item.set_from_service(item)
else:
- serviceItem.set_from_service(item, self.servicePath)
- serviceItem.validate_item(self.suffixes)
+ service_item.set_from_service(item, self.servicePath)
+ service_item.validate_item(self.suffixes)
self.load_item_unique_identifier = 0
- if serviceItem.is_capable(ItemCapabilities.OnLoadUpdate):
- Receiver.send_message(u'%s_service_load' % serviceItem.name.lower(), serviceItem)
+ if service_item.is_capable(ItemCapabilities.OnLoadUpdate):
+ Receiver.send_message(u'%s_service_load' % service_item.name.lower(), service_item)
# if the item has been processed
- if serviceItem.unique_identifier == self.load_item_unique_identifier:
- serviceItem.edit_id = int(self.load_item_edit_id)
- serviceItem.temporary_edit = self.load_item_temporary
- self.addServiceItem(serviceItem, repaint=False)
+ if service_item.unique_identifier == self.load_item_unique_identifier:
+ service_item.edit_id = int(self.load_item_edit_id)
+ service_item.temporary_edit = self.load_item_temporary
+ self.add_service_item(service_item, repaint=False)
delete_file(p_file)
- self.main_window.addRecentFile(fileName)
- self.setModified(False)
- Settings().setValue('servicemanager/last file', fileName)
+ self.main_window.addRecentFile(file_name)
+ self.set_modified(False)
+ Settings().setValue('servicemanager/last file', file_name)
else:
critical_error_message_box(message=translate('OpenLP.ServiceManager', 'File is not a valid service.'))
log.exception(u'File contains no service data')
except (IOError, NameError, zipfile.BadZipfile):
- log.exception(u'Problem loading service file %s' % fileName)
+ log.exception(u'Problem loading service file %s' % file_name)
critical_error_message_box(message=translate('OpenLP.ServiceManager',
'File could not be opened because it is corrupt.'))
except zipfile.BadZipfile:
- if os.path.getsize(fileName) == 0:
- log.exception(u'Service file is zero sized: %s' % fileName)
+ if os.path.getsize(file_name) == 0:
+ log.exception(u'Service file is zero sized: %s' % file_name)
QtGui.QMessageBox.information(self, translate('OpenLP.ServiceManager', 'Empty File'),
translate('OpenLP.ServiceManager', 'This service file does not contain any data.'))
else:
log.exception(u'Service file is cannot be extracted as zip: '
- u'%s' % fileName)
+ u'%s' % file_name)
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.'))
return
finally:
- if fileTo:
- fileTo.close()
- if zip:
- zip.close()
+ if file_to:
+ file_to.close()
+ if zip_file:
+ zip_file.close()
self.main_window.finishedProgressBar()
Receiver.send_message(u'cursor_normal')
- self.repaintServiceList(-1, -1)
+ self.repaint_service_list(-1, -1)
- def loadLastFile(self):
+ def load_Last_file(self):
"""
Load the last service item from the service manager when the
service was last closed. Can be blank if there was no service
present.
"""
- fileName = Settings().value(u'servicemanager/last file')
- if fileName:
- self.loadFile(fileName)
+ file_name = Settings().value(u'servicemanager/last file')
+ if file_name:
+ self.load_file(file_name)
- def contextMenu(self, point):
+ def context_menu(self, point):
"""
The Right click context menu from the Serviceitem list
"""
- item = self.serviceManagerList.itemAt(point)
+ item = self.service_manager_list.itemAt(point)
if item is None:
return
if item.parent():
pos = item.parent().data(0, QtCore.Qt.UserRole)
else:
pos = item.data(0, QtCore.Qt.UserRole)
- serviceItem = self.serviceItems[pos - 1]
- self.editAction.setVisible(False)
+ service_item = self.service_items[pos - 1]
+ self.edit_action.setVisible(False)
self.create_custom_action.setVisible(False)
- self.maintainAction.setVisible(False)
- self.notesAction.setVisible(False)
- self.timeAction.setVisible(False)
- self.autoStartAction.setVisible(False)
- if serviceItem[u'service_item'].is_capable(ItemCapabilities.CanEdit) and serviceItem[u'service_item'].edit_id:
- self.editAction.setVisible(True)
- if serviceItem[u'service_item'].is_capable(ItemCapabilities.CanMaintain):
- self.maintainAction.setVisible(True)
+ self.maintain_action.setVisible(False)
+ self.notes_action.setVisible(False)
+ self.time_action.setVisible(False)
+ self.auto_start_action.setVisible(False)
+ if service_item[u'service_item'].is_capable(ItemCapabilities.CanEdit) and service_item[u'service_item'].edit_id:
+ self.edit_action.setVisible(True)
+ if service_item[u'service_item'].is_capable(ItemCapabilities.CanMaintain):
+ self.maintain_action.setVisible(True)
if item.parent() is None:
- self.notesAction.setVisible(True)
- if serviceItem[u'service_item'].is_capable(ItemCapabilities.CanLoop) and \
- len(serviceItem[u'service_item'].get_frames()) > 1:
- self.autoPlaySlidesGroup.menuAction().setVisible(True)
- self.autoPlaySlidesOnce.setChecked(serviceItem[u'service_item'].auto_play_slides_once)
- self.autoPlaySlidesLoop.setChecked(serviceItem[u'service_item'].auto_play_slides_loop)
- self.timedSlideInterval.setChecked(serviceItem[u'service_item'].timed_slide_interval > 0)
- if serviceItem[u'service_item'].timed_slide_interval > 0:
- delay_suffix = u' %s s' % unicode(serviceItem[u'service_item'].timed_slide_interval)
+ self.notes_action.setVisible(True)
+ if service_item[u'service_item'].is_capable(ItemCapabilities.CanLoop) and \
+ len(service_item[u'service_item'].get_frames()) > 1:
+ self.auto_play_slides_group.menuAction().setVisible(True)
+ self.auto_play_slides_once.setChecked(service_item[u'service_item'].auto_play_slides_once)
+ self.auto_play_slides_loop.setChecked(service_item[u'service_item'].auto_play_slides_loop)
+ self.timed_slide_interval.setChecked(service_item[u'service_item'].timed_slide_interval > 0)
+ if service_item[u'service_item'].timed_slide_interval > 0:
+ delay_suffix = u' %s s' % unicode(service_item[u'service_item'].timed_slide_interval)
else:
delay_suffix = u' ...'
- self.timedSlideInterval.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.autoPlaySlidesGroup.menuAction().setVisible(False)
- if serviceItem[u'service_item'].is_capable(ItemCapabilities.HasVariableStartTime):
- self.timeAction.setVisible(True)
- if serviceItem[u'service_item'].is_capable(ItemCapabilities.CanAutoStartForLive):
- self.autoStartAction.setVisible(True)
- self.autoStartAction.setIcon(self.inactive)
- self.autoStartAction.setText(translate('OpenLP.ServiceManager','&Auto Start - inactive'))
- if serviceItem[u'service_item'].will_auto_start:
- self.autoStartAction.setText(translate('OpenLP.ServiceManager', '&Auto Start - active'))
- self.autoStartAction.setIcon(self.active)
- if serviceItem[u'service_item'].is_text():
+ self.auto_play_slides_group.menuAction().setVisible(False)
+ if service_item[u'service_item'].is_capable(ItemCapabilities.HasVariableStartTime):
+ self.time_action.setVisible(True)
+ 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'))
+ 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)
+ if service_item[u'service_item'].is_text():
for plugin in self.plugin_manager.plugins:
if plugin.name == u'custom' and plugin.status == PluginStatus.Active:
self.create_custom_action.setVisible(True)
break
- self.themeMenu.menuAction().setVisible(False)
+ self.theme_menu.menuAction().setVisible(False)
# Set up the theme menu.
- if serviceItem[u'service_item'].is_text() and self.renderer.theme_level == ThemeLevel.Song:
- self.themeMenu.menuAction().setVisible(True)
+ if service_item[u'service_item'].is_text() and self.renderer.theme_level == ThemeLevel.Song:
+ self.theme_menu.menuAction().setVisible(True)
# The service item does not have a theme, check the "Default".
- if serviceItem[u'service_item'].theme is None:
- themeAction = self.themeMenu.defaultAction()
+ if service_item[u'service_item'].theme is None:
+ theme_action = self.theme_menu.defaultAction()
else:
- themeAction = self.themeMenu.findChild(QtGui.QAction, serviceItem[u'service_item'].theme)
- if themeAction is not None:
- themeAction.setChecked(True)
- self.menu.exec_(self.serviceManagerList.mapToGlobal(point))
+ theme_action = self.theme_menu.findChild(QtGui.QAction, service_item[u'service_item'].theme)
+ if theme_action is not None:
+ theme_action.setChecked(True)
+ self.menu.exec_(self.service_manager_list.mapToGlobal(point))
- def onServiceItemNoteForm(self):
- item = self.findServiceItem()[0]
- self.serviceNoteForm.textEdit.setPlainText(
- self.serviceItems[item][u'service_item'].notes)
+ def on_service_item_note_form(self):
+ """
+ Allow the service note to be edited
+ """
+ item = self.find_service_item()[0]
+ self.serviceNoteForm.text_edit.setPlainText(self.service_items[item][u'service_item'].notes)
if self.serviceNoteForm.exec_():
- self.serviceItems[item][u'service_item'].notes = self.serviceNoteForm.textEdit.toPlainText()
- self.repaintServiceList(item, -1)
- self.setModified()
+ self.service_items[item][u'service_item'].notes = self.serviceNoteForm.text_edit.toPlainText()
+ self.repaint_service_list(item, -1)
+ self.set_modified()
- def onStartTimeForm(self):
+ def on_start_time_form(self):
"""
Opens a dialog to type in service item notes.
"""
- item = self.findServiceItem()[0]
- self.startTimeForm.item = self.serviceItems[item]
+ item = self.find_service_item()[0]
+ self.startTimeForm.item = self.service_items[item]
if self.startTimeForm.exec_():
- self.repaintServiceList(item, -1)
+ self.repaint_service_list(item, -1)
- def toggleAutoPlaySlidesOnce(self):
+ def toggle_auto_play_slides_once(self):
"""
Toggle Auto play slide once.
Inverts auto play once option for the item
"""
- item = self.findServiceItem()[0]
- service_item = self.serviceItems[item][u'service_item']
+ item = self.find_service_item()[0]
+ service_item = self.service_items[item][u'service_item']
service_item.auto_play_slides_once = not service_item.auto_play_slides_once
if service_item.auto_play_slides_once:
service_item.auto_play_slides_loop = False
- self.autoPlaySlidesLoop.setChecked(False)
+ self.auto_play_slides_loop.setChecked(False)
if service_item.auto_play_slides_once and service_item.timed_slide_interval == 0:
service_item.timed_slide_interval = Settings().value(
- self.mainwindow.generalSettingsSection + u'/loop delay')
- self.setModified()
-
- def toggleAutoPlaySlidesLoop(self):
+ self.main_window.generalSettingsSection + u'/loop delay')
+ self.set_modified()
+
+
+ def toggle_auto_play_slides_loop(self):
"""
Toggle Auto play slide loop.
"""
- item = self.findServiceItem()[0]
- service_item = self.serviceItems[item][u'service_item']
+ item = self.find_service_item()[0]
+ service_item = self.service_items[item][u'service_item']
service_item.auto_play_slides_loop = not service_item.auto_play_slides_loop
if service_item.auto_play_slides_loop:
service_item.auto_play_slides_once = False
- self.autoPlaySlidesOnce.setChecked(False)
+ self.auto_play_slides_once.setChecked(False)
if service_item.auto_play_slides_loop and service_item.timed_slide_interval == 0:
service_item.timed_slide_interval = Settings().value(
- self.mainwindow.generalSettingsSection + u'/loop delay')
- self.setModified()
-
- def onTimedSlideInterval(self):
+ self.main_window.generalSettingsSection + u'/loop delay')
+ self.set_modified()
+
+
+ def on_timed_slide_interval(self):
"""
- on set times slide interval.
Shows input dialog for enter interval in seconds for delay
"""
- item = self.findServiceItem()[0]
- service_item = self.serviceItems[item][u'service_item']
+ item = self.find_service_item()[0]
+ service_item = self.service_items[item][u'service_item']
if service_item.timed_slide_interval == 0:
timed_slide_interval = Settings().value(self.mainwindow.generalSettingsSection + u'/loop delay')
else:
@@ -889,82 +914,81 @@
elif service_item.timed_slide_interval == 0:
service_item.auto_play_slides_loop = False
service_item.auto_play_slides_once = False
- self.setModified()
+ self.set_modified()
- def onAutoStart(self):
+ def on_auto_start(self):
"""
Toggles to Auto Start Setting.
"""
- item = self.findServiceItem()[0]
- self.serviceItems[item][u'service_item'].will_auto_start = \
- not self.serviceItems[item][u'service_item'].will_auto_start
+ item = self.find_service_item()[0]
+ self.service_items[item][u'service_item'].will_auto_start = \
+ not self.service_items[item][u'service_item'].will_auto_start
- def onServiceItemEditForm(self):
+ def on_service_item_edit_form(self):
"""
Opens a dialog to edit the service item and update the service
display if changes are saved.
"""
- item = self.findServiceItem()[0]
- self.serviceItemEditForm.setServiceItem(
- self.serviceItems[item][u'service_item'])
+ item = self.find_service_item()[0]
+ self.serviceItemEditForm.set_service_item(self.service_items[item][u'service_item'])
if self.serviceItemEditForm.exec_():
- self.addServiceItem(self.serviceItemEditForm.getServiceItem(),
- replace=True, expand=self.serviceItems[item][u'expanded'])
+ self.add_service_item(self.serviceItemEditForm.get_service_item(),
+ replace=True, expand=self.service_items[item][u'expanded'])
- def previewLive(self, message):
+ def preview_live(self, message):
"""
Called by the SlideController to request a preview item be made live
and allows the next preview to be updated if relevant.
"""
unique_identifier, row = message.split(u':')
- for sitem in self.serviceItems:
+ for sitem in self.service_items:
if sitem[u'service_item'].unique_identifier == unique_identifier:
- item = self.serviceManagerList.topLevelItem(sitem[u'order'] - 1)
- self.serviceManagerList.setCurrentItem(item)
- self.makeLive(int(row))
+ item = self.service_manager_list.topLevelItem(sitem[u'order'] - 1)
+ self.service_manager_list.setCurrentItem(item)
+ self.make_live(int(row))
return
- def nextItem(self):
+ def next_item(self):
"""
Called by the SlideController to select the next service item.
"""
- if not self.serviceManagerList.selectedItems():
+ if not self.service_manager_list.selectedItems():
return
- selected = self.serviceManagerList.selectedItems()[0]
+ selected = self.service_manager_list.selectedItems()[0]
lookFor = 0
- serviceIterator = QtGui.QTreeWidgetItemIterator(self.serviceManagerList)
+ serviceIterator = QtGui.QTreeWidgetItemIterator(self.service_manager_list)
while serviceIterator.value():
if lookFor == 1 and serviceIterator.value().parent() is None:
- self.serviceManagerList.setCurrentItem(serviceIterator.value())
- self.makeLive()
+ self.service_manager_list.setCurrentItem(serviceIterator.value())
+ self.make_live()
return
if serviceIterator.value() == selected:
lookFor = 1
serviceIterator += 1
- def previousItem(self, message):
+ def previous_item(self, message):
"""
Called by the SlideController to select the previous service item.
"""
- if not self.serviceManagerList.selectedItems():
+ if not self.service_manager_list.selectedItems():
return
- selected = self.serviceManagerList.selectedItems()[0]
+ selected = self.service_manager_list.selectedItems()[0]
prevItem = None
prevItemLastSlide = None
- serviceIterator = QtGui.QTreeWidgetItemIterator(self.serviceManagerList)
+ serviceIterator = QtGui.QTreeWidgetItemIterator(self.service_manager_list)
while serviceIterator.value():
if serviceIterator.value() == selected:
if message == u'last slide' and prevItemLastSlide:
pos = prevItem.data(0, QtCore.Qt.UserRole)
- check_expanded = self.serviceItems[pos - 1][u'expanded']
- self.serviceManagerList.setCurrentItem(prevItemLastSlide)
+ check_expanded = self.service_items[pos - 1][u'expanded']
+ self.service_manager_list.setCurrentItem(prevItemLastSlide)
if not check_expanded:
- self.serviceManagerList.collapseItem(prevItem)
- self.makeLive()
- self.serviceManagerList.setCurrentItem(prevItem)
+ self.service_manager_list.collapseItem(prevItem)
+ self.make_live()
+ self.service_manager_list.setCurrentItem(prevItem)
elif prevItem:
- self.serviceManagerList.setCurrentItem(prevItem)
- self.makeLive()
+ self.service_manager_list.setCurrentItem(prevItem)
+ self.make_live()
return
if serviceIterator.value().parent() is None:
prevItem = serviceIterator.value()
@@ -972,50 +996,50 @@
prevItemLastSlide = serviceIterator.value()
serviceIterator += 1
- def onSetItem(self, message):
+ def on_set_item(self, message):
"""
Called by a signal to select a specific item.
"""
- self.setItem(int(message))
+ self.set_item(int(message))
- def setItem(self, index):
+ def set_item(self, index):
"""
Makes a specific item in the service live.
"""
- if index >= 0 and index < self.serviceManagerList.topLevelItemCount:
- item = self.serviceManagerList.topLevelItem(index)
- self.serviceManagerList.setCurrentItem(item)
- self.makeLive()
+ if index >= 0 and index < self.service_manager_list.topLevelItemCount:
+ item = self.service_manager_list.topLevelItem(index)
+ self.service_manager_list.setCurrentItem(item)
+ self.make_live()
- def onMoveSelectionUp(self):
+ def on_move_selection_up(self):
"""
Moves the cursor selection up the window.
Called by the up arrow.
"""
- item = self.serviceManagerList.currentItem()
- itemBefore = self.serviceManagerList.itemAbove(item)
+ item = self.service_manager_list.currentItem()
+ itemBefore = self.service_manager_list.itemAbove(item)
if itemBefore is None:
return
- self.serviceManagerList.setCurrentItem(itemBefore)
+ self.service_manager_list.setCurrentItem(itemBefore)
- def onMoveSelectionDown(self):
+ def on_move_selection_down(self):
"""
Moves the cursor selection down the window.
Called by the down arrow.
"""
- item = self.serviceManagerList.currentItem()
- itemAfter = self.serviceManagerList.itemBelow(item)
+ item = self.service_manager_list.currentItem()
+ itemAfter = self.service_manager_list.itemBelow(item)
if itemAfter is None:
return
- self.serviceManagerList.setCurrentItem(itemAfter)
+ self.service_manager_list.setCurrentItem(itemAfter)
def onCollapseAll(self):
"""
Collapse all the service items.
"""
- for item in self.serviceItems:
+ for item in self.service_items:
item[u'expanded'] = False
- self.serviceManagerList.collapseAll()
+ self.service_manager_list.collapseAll()
def collapsed(self, item):
"""
@@ -1023,15 +1047,15 @@
correct state.
"""
pos = item.data(0, QtCore.Qt.UserRole)
- self.serviceItems[pos - 1][u'expanded'] = False
+ self.service_items[pos - 1][u'expanded'] = False
def onExpandAll(self):
"""
Collapse all the service items.
"""
- for item in self.serviceItems:
+ for item in self.service_items:
item[u'expanded'] = True
- self.serviceManagerList.expandAll()
+ self.service_manager_list.expandAll()
def expanded(self, item):
"""
@@ -1039,67 +1063,67 @@
correct state.
"""
pos = item.data(0, QtCore.Qt.UserRole)
- self.serviceItems[pos - 1][u'expanded'] = True
+ self.service_items[pos - 1][u'expanded'] = True
def onServiceTop(self):
"""
Move the current ServiceItem to the top of the list.
"""
- item, child = self.findServiceItem()
- if item < len(self.serviceItems) and item != -1:
- temp = self.serviceItems[item]
- self.serviceItems.remove(self.serviceItems[item])
- self.serviceItems.insert(0, temp)
- self.repaintServiceList(0, child)
- self.setModified()
+ item, child = self.find_service_item()
+ if item < len(self.service_items) and item != -1:
+ temp = self.service_items[item]
+ self.service_items.remove(self.service_items[item])
+ self.service_items.insert(0, temp)
+ self.repaint_service_list(0, child)
+ self.set_modified()
def onServiceUp(self):
"""
Move the current ServiceItem one position up in the list.
"""
- item, child = self.findServiceItem()
+ item, child = self.find_service_item()
if item > 0:
- temp = self.serviceItems[item]
- self.serviceItems.remove(self.serviceItems[item])
- self.serviceItems.insert(item - 1, temp)
- self.repaintServiceList(item - 1, child)
- self.setModified()
+ temp = self.service_items[item]
+ self.service_items.remove(self.service_items[item])
+ self.service_items.insert(item - 1, temp)
+ self.repaint_service_list(item - 1, child)
+ self.set_modified()
def onServiceDown(self):
"""
Move the current ServiceItem one position down in the list.
"""
- item, child = self.findServiceItem()
- if item < len(self.serviceItems) and item != -1:
- temp = self.serviceItems[item]
- self.serviceItems.remove(self.serviceItems[item])
- self.serviceItems.insert(item + 1, temp)
- self.repaintServiceList(item + 1, child)
- self.setModified()
+ item, child = self.find_service_item()
+ if item < len(self.service_items) and item != -1:
+ temp = self.service_items[item]
+ self.service_items.remove(self.service_items[item])
+ self.service_items.insert(item + 1, temp)
+ self.repaint_service_list(item + 1, child)
+ self.set_modified()
def onServiceEnd(self):
"""
Move the current ServiceItem to the bottom of the list.
"""
- item, child = self.findServiceItem()
- if item < len(self.serviceItems) and item != -1:
- temp = self.serviceItems[item]
- self.serviceItems.remove(self.serviceItems[item])
- self.serviceItems.insert(len(self.serviceItems), temp)
- self.repaintServiceList(len(self.serviceItems) - 1, child)
- self.setModified()
+ item, child = self.find_service_item()
+ if item < len(self.service_items) and item != -1:
+ temp = self.service_items[item]
+ self.service_items.remove(self.service_items[item])
+ self.service_items.insert(len(self.service_items), temp)
+ self.repaint_service_list(len(self.service_items) - 1, child)
+ self.set_modified()
def onDeleteFromService(self):
"""
Remove the current ServiceItem from the list.
"""
- item = self.findServiceItem()[0]
+ item = self.find_service_item()[0]
if item != -1:
- self.serviceItems.remove(self.serviceItems[item])
- self.repaintServiceList(item - 1, -1)
- self.setModified()
+ self.service_items.remove(self.service_items[item])
+ self.repaint_service_list(item - 1, -1)
+ self.set_modified()
- def repaintServiceList(self, serviceItem, serviceItemChild):
+ def repaint_service_list(self, serviceItem, serviceItemChild):
"""
Clear the existing service list and prepaint all the items. This is
used when moving items as the move takes place in a supporting list,
@@ -1114,16 +1138,16 @@
# Correct order of items in array
count = 1
self.service_has_all_original_files = True
- for item in self.serviceItems:
+ for item in self.service_items:
item[u'order'] = count
count += 1
if not item[u'service_item'].has_original_files:
self.service_has_all_original_files = False
# Repaint the screen
- self.serviceManagerList.clear()
- for item_count, item in enumerate(self.serviceItems):
+ self.service_manager_list.clear()
+ for item_count, item in enumerate(self.service_items):
serviceitem = item[u'service_item']
- treewidgetitem = QtGui.QTreeWidgetItem(self.serviceManagerList)
+ treewidgetitem = QtGui.QTreeWidgetItem(self.service_manager_list)
if serviceitem.is_valid:
if serviceitem.notes:
icon = QtGui.QImage(serviceitem.icon)
@@ -1172,9 +1196,9 @@
child.setData(0, QtCore.Qt.UserRole, count)
if serviceItem == item_count:
if item[u'expanded'] and serviceItemChild == count:
- self.serviceManagerList.setCurrentItem(child)
+ self.service_manager_list.setCurrentItem(child)
elif serviceItemChild == -1:
- self.serviceManagerList.setCurrentItem(treewidgetitem)
+ self.service_manager_list.setCurrentItem(treewidgetitem)
treewidgetitem.setExpanded(item[u'expanded'])
def cleanUp(self):
@@ -1188,15 +1212,15 @@
if os.path.exists(os.path.join(self.servicePath, u'audio')):
shutil.rmtree(os.path.join(self.servicePath, u'audio'), True)
- def onThemeComboBoxSelected(self, currentIndex):
+ def on_theme_combo_box_selected(self, currentIndex):
"""
Set the theme for the current service.
"""
- log.debug(u'onThemeComboBoxSelected')
- self.service_theme = self.themeComboBox.currentText()
+ log.debug(u'ontheme_combo_box_selected')
+ self.service_theme = self.theme_combo_box.currentText()
self.renderer.set_service_theme(self.service_theme)
Settings().setValue(self.main_window.serviceManagerSettingsSection + u'/service theme', self.service_theme)
- self.regenerateServiceItems(True)
+ self.regenerate_service_Items(True)
def themeChange(self):
"""
@@ -1205,22 +1229,22 @@
"""
log.debug(u'themeChange')
visible = self.renderer.theme_level == ThemeLevel.Global
- self.themeLabel.setVisible(visible)
- self.themeComboBox.setVisible(visible)
+ self.theme_label.setVisible(visible)
+ self.theme_combo_box.setVisible(visible)
- def regenerateServiceItems(self, changed=False):
+ def regenerate_service_Items(self, changed=False):
"""
Rebuild the service list as things have changed and a
repaint is the easiest way to do this.
"""
Receiver.send_message(u'cursor_busy')
- log.debug(u'regenerateServiceItems')
+ log.debug(u'regenerate_service_Items')
# force reset of renderer as theme data has changed
self.service_has_all_original_files = True
- if self.serviceItems:
- for item in self.serviceItems:
+ if self.service_items:
+ for item in self.service_items:
item[u'selected'] = False
- serviceIterator = QtGui.QTreeWidgetItemIterator(self.serviceManagerList)
+ serviceIterator = QtGui.QTreeWidgetItemIterator(self.service_manager_list)
selectedItem = None
while serviceIterator.value():
if serviceIterator.value().isSelected():
@@ -1231,20 +1255,20 @@
pos = selectedItem.data(0, QtCore.Qt.UserRole)
else:
pos = selectedItem.parent().data(0, QtCore.Qt.UserRole)
- self.serviceItems[pos - 1][u'selected'] = True
- tempServiceItems = self.serviceItems
- self.serviceManagerList.clear()
- self.serviceItems = []
+ self.service_items[pos - 1][u'selected'] = True
+ tempServiceItems = self.service_items
+ self.service_manager_list.clear()
+ self.service_items = []
self.isNew = True
for item in tempServiceItems:
- self.addServiceItem(item[u'service_item'], False, expand=item[u'expanded'], repaint=False,
+ self.add_service_item(item[u'service_item'], False, expand=item[u'expanded'], repaint=False,
selected=item[u'selected'])
# Set to False as items may have changed rendering
# does not impact the saved song so True may also be valid
if changed:
- self.setModified()
+ self.set_modified()
# Repaint it once only at the end
- self.repaintServiceList(-1, -1)
+ self.repaint_service_list(-1, -1)
Receiver.send_message(u'cursor_normal')
def serviceItemUpdate(self, message):
@@ -1256,21 +1280,21 @@
self.load_item_edit_id = int(edit_id)
self.load_item_temporary = str_to_bool(temporary)
- def replaceServiceItem(self, newItem):
+ def replace_service_item(self, newItem):
"""
Using the service item passed replace the one with the same edit id
if found.
"""
- for item_count, item in enumerate(self.serviceItems):
+ for item_count, item in enumerate(self.service_items):
if item[u'service_item'].edit_id == newItem.edit_id and item[u'service_item'].name == newItem.name:
newItem.render()
newItem.merge(item[u'service_item'])
item[u'service_item'] = newItem
- self.repaintServiceList(item_count + 1, 0)
+ self.repaint_service_list(item_count + 1, 0)
self.live_controller.replaceServiceManagerItem(newItem)
- self.setModified()
+ self.set_modified()
- def addServiceItem(self, item, rebuild=False, expand=None, replace=False, repaint=True, selected=False):
+ def add_service_item(self, item, rebuild=False, expand=None, replace=False, repaint=True, selected=False):
"""
Add a Service item to the list
@@ -1282,72 +1306,72 @@
"""
# if not passed set to config value
if expand is None:
- expand = self.expandTabs
+ expand = self.expand_tabs
item.from_service = True
if replace:
- sitem, child = self.findServiceItem()
- item.merge(self.serviceItems[sitem][u'service_item'])
- self.serviceItems[sitem][u'service_item'] = item
- self.repaintServiceList(sitem, child)
+ sitem, child = self.find_service_item()
+ item.merge(self.service_items[sitem][u'service_item'])
+ self.service_items[sitem][u'service_item'] = item
+ self.repaint_service_list(sitem, child)
self.live_controller.replaceServiceManagerItem(item)
else:
item.render()
# nothing selected for dnd
- if self.dropPosition == 0:
+ if self.drop_position == 0:
if isinstance(item, list):
for inditem in item:
- self.serviceItems.append({u'service_item': inditem,
- u'order': len(self.serviceItems) + 1,
+ self.service_items.append({u'service_item': inditem,
+ u'order': len(self.service_items) + 1,
u'expanded': expand, u'selected': selected})
else:
- self.serviceItems.append({u'service_item': item,
- u'order': len(self.serviceItems) + 1,
+ self.service_items.append({u'service_item': item,
+ u'order': len(self.service_items) + 1,
u'expanded': expand, u'selected': selected})
if repaint:
- self.repaintServiceList(len(self.serviceItems) - 1, -1)
+ self.repaint_service_list(len(self.service_items) - 1, -1)
else:
- self.serviceItems.insert(self.dropPosition,
- {u'service_item': item, u'order': self.dropPosition,
+ self.service_items.insert(self.drop_position,
+ {u'service_item': item, u'order': self.drop_position,
u'expanded': expand, u'selected': selected})
- self.repaintServiceList(self.dropPosition, -1)
+ self.repaint_service_list(self.drop_position, -1)
# if rebuilding list make sure live is fixed.
if rebuild:
self.live_controller.replaceServiceManagerItem(item)
- self.dropPosition = 0
- self.setModified()
+ self.drop_position = 0
+ self.set_modified()
- def makePreview(self):
+ def make_preview(self):
"""
Send the current item to the Preview slide controller
"""
Receiver.send_message(u'cursor_busy')
- item, child = self.findServiceItem()
- if self.serviceItems[item][u'service_item'].is_valid:
- self.preview_controller.addServiceManagerItem(self.serviceItems[item][u'service_item'], child)
+ 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)
else:
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')
- def getServiceItem(self):
+ def get_service_item(self):
"""
Send the current item to the Preview slide controller
"""
- item = self.findServiceItem()[0]
+ item = self.find_service_item()[0]
if item == -1:
return False
else:
- return self.serviceItems[item][u'service_item']
+ return self.service_items[item][u'service_item']
- def onMakeLive(self):
+ def on_make_live(self):
"""
Send the current item to the Live slide controller but triggered
by a tablewidget click event.
"""
- self.makeLive()
+ self.make_live()
- def makeLive(self, row=-1):
+ def make_live(self, row=-1):
"""
Send the current item to the Live slide controller
@@ -1355,22 +1379,22 @@
Row number to be displayed if from preview.
-1 is passed if the value is not set
"""
- item, child = self.findServiceItem()
+ item, child = self.find_service_item()
# No items in service
if item == -1:
return
if row != -1:
child = row
Receiver.send_message(u'cursor_busy')
- if self.serviceItems[item][u'service_item'].is_valid:
- self.live_controller.addServiceManagerItem(self.serviceItems[item][u'service_item'], child)
+ 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'):
item += 1
- if self.serviceItems and item < len(self.serviceItems) and \
- self.serviceItems[item][u'service_item'].is_capable(ItemCapabilities.CanPreview):
- self.preview_controller.addServiceManagerItem(self.serviceItems[item][u'service_item'], 0)
- next_item = self.serviceManagerList.topLevelItem(item)
- self.serviceManagerList.setCurrentItem(next_item)
+ if self.service_items and item < len(self.service_items) and \
+ self.service_items[item][u'service_item'].is_capable(ItemCapabilities.CanPreview):
+ self.preview_controller.addServiceManagerItem(self.service_items[item][u'service_item'], 0)
+ next_item = self.service_manager_list.topLevelItem(item)
+ self.service_manager_list.setCurrentItem(next_item)
self.live_controller.previewListWidget.setFocus()
else:
critical_error_message_box(translate('OpenLP.ServiceManager', 'Missing Display Handler'),
@@ -1378,23 +1402,25 @@
'Your item cannot be displayed as the plugin required to display it is missing or inactive'))
Receiver.send_message(u'cursor_normal')
- def remoteEdit(self):
- """
- Posts a remote edit message to a plugin to allow item to be edited.
- """
- item = self.findServiceItem()[0]
- if self.serviceItems[item][u'service_item'].is_capable(ItemCapabilities.CanEdit):
- Receiver.send_message(u'%s_edit' % self.serviceItems[item][u'service_item'].name.lower(),
- u'L:%s' % self.serviceItems[item][u'service_item'].edit_id)
+ def remote_edit(self):
+ """
+ Triggers a remote edit to a plugin to allow item to be edited.
+ """
+ item, child = self.find_service_item()
+ 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)
+ if new_item:
+ self.add_service_item(new_item, replace=True)
def create_custom(self):
"""
Saves the current text item as a custom slide
"""
- item = self.findServiceItem()[0]
- Receiver.send_message(u'custom_create_from_service', self.serviceItems[item][u'service_item'])
+ item = self.find_service_item()[0]
+ Receiver.send_message(u'custom_create_from_service', self.service_items[item][u'service_item'])
- def findServiceItem(self):
+ def find_service_item(self):
"""
Finds the first selected ServiceItem in the list and returns the
position of the serviceitem and its selected child item. For example,
@@ -1403,7 +1429,7 @@
(1, 2)
"""
- items = self.serviceManagerList.selectedItems()
+ items = self.service_manager_list.selectedItems()
serviceItem = -1
serviceItemChild = -1
for item in items:
@@ -1419,16 +1445,7 @@
break
return serviceItem, serviceItemChild
- def dragEnterEvent(self, event):
- """
- Accept Drag events
-
- ``event``
- Handle of the event pint passed
- """
- event.accept()
-
- def dropEvent(self, event):
+ def drop_event(self, event):
"""
Receive drop event and trigger an internal event to get the
plugins to build and push the correct service item
@@ -1442,83 +1459,83 @@
event.setDropAction(QtCore.Qt.CopyAction)
event.accept()
for url in link.urls():
- filename = url.toLocalFile()
- if filename.endswith(u'.osz'):
- self.onLoadServiceClicked(filename)
- elif filename.endswith(u'.oszl'):
+ file_name = url.toLocalFile()
+ if file_name.endswith(u'.osz'):
+ self.on_load_service_clicked(file_name)
+ elif file_name.endswith(u'.oszl'):
# todo correct
- self.onLoadServiceClicked(filename)
+ self.on_load_service_clicked(file_name)
elif link.hasText():
plugin = link.text()
- item = self.serviceManagerList.itemAt(event.pos())
+ item = self.service_manager_list.itemAt(event.pos())
# ServiceManager started the drag and drop
if plugin == u'ServiceManager':
- startpos, child = self.findServiceItem()
+ startpos, child = self.find_service_item()
# If no items selected
if startpos == -1:
return
if item is None:
- endpos = len(self.serviceItems)
+ endpos = len(self.service_items)
else:
endpos = self._get_parent_item_data(item) - 1
- serviceItem = self.serviceItems[startpos]
- self.serviceItems.remove(serviceItem)
- self.serviceItems.insert(endpos, serviceItem)
- self.repaintServiceList(endpos, child)
- self.setModified()
+ serviceItem = self.service_items[startpos]
+ self.service_items.remove(serviceItem)
+ self.service_items.insert(endpos, serviceItem)
+ self.repaint_service_list(endpos, child)
+ self.set_modified()
else:
# we are not over anything so drop
replace = False
if item is None:
- self.dropPosition = len(self.serviceItems)
+ self.drop_position = len(self.service_items)
else:
# we are over something so lets investigate
pos = self._get_parent_item_data(item) - 1
- serviceItem = self.serviceItems[pos]
+ serviceItem = self.service_items[pos]
if (plugin == serviceItem[u'service_item'].name and
serviceItem[u'service_item'].is_capable(ItemCapabilities.CanAppend)):
action = self.dndMenu.exec_(QtGui.QCursor.pos())
# New action required
if action == self.newAction:
- self.dropPosition = self._get_parent_item_data(item)
+ self.drop_position = self._get_parent_item_data(item)
# Append to existing action
if action == self.addToAction:
- self.dropPosition = self._get_parent_item_data(item)
+ self.drop_position = self._get_parent_item_data(item)
item.setSelected(True)
replace = True
else:
- self.dropPosition = self._get_parent_item_data(item)
+ self.drop_position = self._get_parent_item_data(item)
Receiver.send_message(u'%s_add_service_item' % plugin, replace)
- def updateThemeList(self, theme_list):
+ def update_theme_list(self, theme_list):
"""
Called from ThemeManager when the Themes have changed
``theme_list``
A list of current themes to be displayed
"""
- self.themeComboBox.clear()
- self.themeMenu.clear()
- self.themeComboBox.addItem(u'')
- themeGroup = QtGui.QActionGroup(self.themeMenu)
- themeGroup.setExclusive(True)
- themeGroup.setObjectName(u'themeGroup')
+ self.theme_combo_box.clear()
+ self.theme_menu.clear()
+ self.theme_combo_box.addItem(u'')
+ theme_group = QtGui.QActionGroup(self.theme_menu)
+ theme_group.setExclusive(True)
+ theme_group.setObjectName(u'theme_group')
# Create a "Default" theme, which allows the user to reset the item's
# theme to the service theme or global theme.
- defaultTheme = create_widget_action(self.themeMenu, text=UiStrings().Default, checked=False,
- triggers=self.onThemeChangeAction)
- self.themeMenu.setDefaultAction(defaultTheme)
- themeGroup.addAction(defaultTheme)
- self.themeMenu.addSeparator()
+ defaultTheme = create_widget_action(self.theme_menu, text=UiStrings().Default, checked=False,
+ triggers=self.on_theme_change_action)
+ self.theme_menu.setDefaultAction(defaultTheme)
+ theme_group.addAction(defaultTheme)
+ self.theme_menu.addSeparator()
for theme in theme_list:
- self.themeComboBox.addItem(theme)
- themeGroup.addAction(create_widget_action(self.themeMenu, theme, text=theme, checked=False,
- triggers=self.onThemeChangeAction))
- find_and_set_in_combo_box(self.themeComboBox, self.service_theme)
+ self.theme_combo_box.addItem(theme)
+ theme_group.addAction(create_widget_action(self.theme_menu, theme, text=theme, checked=False,
+ triggers=self.on_theme_change_action))
+ find_and_set_in_combo_box(self.theme_combo_box, self.service_theme)
self.renderer.set_service_theme(self.service_theme)
- self.regenerateServiceItems()
+ self.regenerate_service_Items()
- def onThemeChangeAction(self):
+ def on_theme_change_action(self):
"""
Handles theme change events
"""
@@ -1526,9 +1543,9 @@
# No object name means that the "Default" theme is supposed to be used.
if not theme:
theme = None
- item = self.findServiceItem()[0]
- self.serviceItems[item][u'service_item'].update_theme(theme)
- self.regenerateServiceItems(True)
+ item = self.find_service_item()[0]
+ self.service_items[item][u'service_item'].update_theme(theme)
+ self.regenerate_service_Items(True)
def _get_parent_item_data(self, item):
"""
@@ -1540,11 +1557,11 @@
else:
return parent_item.data(0, QtCore.Qt.UserRole)
- def printServiceOrder(self):
+ def print_service_order(self):
"""
Print a Service Order Sheet.
"""
- settingDialog = PrintServiceForm(self.main_window, self)
+ settingDialog = PrintServiceForm()
settingDialog.exec_()
def _get_renderer(self):
=== modified file 'openlp/core/ui/servicenoteform.py'
--- openlp/core/ui/servicenoteform.py 2012-12-29 20:56:56 +0000
+++ openlp/core/ui/servicenoteform.py 2013-01-30 22:10:34 +0000
@@ -29,36 +29,46 @@
from PyQt4 import QtGui
-from openlp.core.lib import translate, SpellTextEdit
+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.
"""
- def __init__(self, parent=None):
+ def __init__(self):
"""
Constructor
"""
- QtGui.QDialog.__init__(self, parent)
+ QtGui.QDialog.__init__(self, self.main_window)
self.setupUi()
self.retranslateUi()
def exec_(self):
- self.textEdit.setFocus()
+ self.text_edit.setFocus()
return QtGui.QDialog.exec_(self)
def setupUi(self):
self.setObjectName(u'serviceNoteEdit')
- self.dialogLayout = QtGui.QVBoxLayout(self)
- self.dialogLayout.setContentsMargins(8, 8, 8, 8)
- self.dialogLayout.setSpacing(8)
- self.dialogLayout.setObjectName(u'verticalLayout')
- self.textEdit = SpellTextEdit(self, False)
- self.textEdit.setObjectName(u'textEdit')
- self.dialogLayout.addWidget(self.textEdit)
- self.buttonBox = create_button_box(self, u'buttonBox', [u'cancel', u'save'])
- self.dialogLayout.addWidget(self.buttonBox)
+ self.dialog_layout = QtGui.QVBoxLayout(self)
+ self.dialog_layout.setContentsMargins(8, 8, 8, 8)
+ self.dialog_layout.setSpacing(8)
+ self.dialog_layout.setObjectName(u'verticalLayout')
+ self.text_edit = SpellTextEdit(self, False)
+ self.text_edit.setObjectName(u'textEdit')
+ self.dialog_layout.addWidget(self.text_edit)
+ self.button_box = create_button_box(self, u'button_box', [u'cancel', u'save'])
+ self.dialog_layout.addWidget(self.button_box)
def retranslateUi(self):
self.setWindowTitle(translate('OpenLP.ServiceNoteForm', 'Service Item Notes'))
+
+ 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
=== modified file 'openlp/core/ui/settingsdialog.py'
--- openlp/core/ui/settingsdialog.py 2012-12-29 20:56:56 +0000
+++ openlp/core/ui/settingsdialog.py 2013-01-30 22:10:34 +0000
@@ -38,7 +38,7 @@
settingsDialog.resize(800, 500)
settingsDialog.setWindowIcon(build_icon(u':/system/system_settings.png'))
self.dialogLayout = QtGui.QGridLayout(settingsDialog)
- self.dialogLayout.setObjectName(u'dialogLayout')
+ self.dialogLayout.setObjectName(u'dialog_layout')
self.dialogLayout.setMargin(8)
self.settingListWidget = QtGui.QListWidget(settingsDialog)
self.settingListWidget.setUniformItemSizes(True)
@@ -49,8 +49,8 @@
self.stackedLayout = QtGui.QStackedLayout()
self.stackedLayout.setObjectName(u'stackedLayout')
self.dialogLayout.addLayout(self.stackedLayout, 0, 1, 1, 1)
- self.buttonBox = create_button_box(settingsDialog, u'buttonBox', [u'cancel', u'ok'])
- self.dialogLayout.addWidget(self.buttonBox, 1, 1, 1, 1)
+ self.button_box = create_button_box(settingsDialog, u'button_box', [u'cancel', u'ok'])
+ self.dialogLayout.addWidget(self.button_box, 1, 1, 1, 1)
self.retranslateUi(settingsDialog)
QtCore.QObject.connect(self.settingListWidget, QtCore.SIGNAL(u'currentRowChanged(int)'), self.tabChanged)
=== modified file 'openlp/core/ui/settingsform.py'
--- openlp/core/ui/settingsform.py 2013-01-23 19:53:40 +0000
+++ openlp/core/ui/settingsform.py 2013-01-30 22:10:34 +0000
@@ -140,7 +140,7 @@
per save.
"""
if self.resetSuffixes:
- self.mainWindow.serviceManagerContents.resetSupportedSuffixes()
+ self.service_manager.reset_supported_suffixes()
self.resetSuffixes = False
def _get_main_window(self):
@@ -151,4 +151,14 @@
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_service_manager(self):
+ """
+ Adds the plugin 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)
\ No newline at end of file
=== modified file 'openlp/core/ui/shortcutlistdialog.py'
--- openlp/core/ui/shortcutlistdialog.py 2012-12-29 20:56:56 +0000
+++ openlp/core/ui/shortcutlistdialog.py 2013-01-30 22:10:34 +0000
@@ -107,9 +107,9 @@
self.alternateLabel.setObjectName(u'alternateLabel')
self.detailsLayout.addWidget(self.alternateLabel, 0, 2, 1, 1)
self.shortcutListLayout.addLayout(self.detailsLayout)
- self.buttonBox = create_button_box(shortcutListDialog, u'buttonBox', [u'cancel', u'ok', u'defaults'])
- self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
- self.shortcutListLayout.addWidget(self.buttonBox)
+ self.button_box = create_button_box(shortcutListDialog, u'button_box', [u'cancel', u'ok', u'defaults'])
+ self.button_box.setOrientation(QtCore.Qt.Horizontal)
+ self.shortcutListLayout.addWidget(self.button_box)
self.retranslateUi(shortcutListDialog)
def retranslateUi(self, shortcutListDialog):
=== modified file 'openlp/core/ui/shortcutlistform.py'
--- openlp/core/ui/shortcutlistform.py 2013-01-10 20:14:49 +0000
+++ openlp/core/ui/shortcutlistform.py 2013-01-30 22:10:34 +0000
@@ -64,7 +64,7 @@
self.onClearPrimaryButtonClicked)
QtCore.QObject.connect(self.clearAlternateButton, QtCore.SIGNAL(u'clicked(bool)'),
self.onClearAlternateButtonClicked)
- QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'clicked(QAbstractButton*)'),
+ QtCore.QObject.connect(self.button_box, QtCore.SIGNAL(u'clicked(QAbstractButton*)'),
self.onRestoreDefaultsClicked)
QtCore.QObject.connect(self.defaultRadioButton, QtCore.SIGNAL(u'clicked(bool)'),
self.onDefaultRadioButtonClicked)
@@ -274,7 +274,7 @@
"""
Restores all default shortcuts.
"""
- if self.buttonBox.buttonRole(button) != QtGui.QDialogButtonBox.ResetRole:
+ if self.button_box.buttonRole(button) != QtGui.QDialogButtonBox.ResetRole:
return
if QtGui.QMessageBox.question(self, translate('OpenLP.ShortcutListDialog', 'Restore Default Shortcuts'),
translate('OpenLP.ShortcutListDialog', 'Do you want to restore all '
=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py 2013-01-24 20:08:52 +0000
+++ openlp/core/ui/slidecontroller.py 2013-01-30 22:10:34 +0000
@@ -297,8 +297,7 @@
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
- sizePolicy.setHeightForWidth(
- self.slidePreview.sizePolicy().hasHeightForWidth())
+ sizePolicy.setHeightForWidth(self.slidePreview.sizePolicy().hasHeightForWidth())
self.slidePreview.setSizePolicy(sizePolicy)
self.slidePreview.setFrameShape(QtGui.QFrame.Box)
self.slidePreview.setFrameShadow(QtGui.QFrame.Plain)
@@ -649,12 +648,12 @@
item.render()
self._processItem(item, self.selectedRow)
- def addServiceItem(self, item):
+ def add_service_item(self, item):
"""
Method to install the service item into the controller
Called by plugins
"""
- log.debug(u'addServiceItem live = %s' % self.isLive)
+ log.debug(u'add_service_item live = %s' % self.isLive)
item.render()
slideno = 0
if self.songEdit:
@@ -1183,14 +1182,16 @@
From the preview display requires the service Item to be editied
"""
self.songEdit = True
- Receiver.send_message(u'%s_edit' % self.serviceItem.name.lower(), u'P:%s' % self.serviceItem.edit_id)
+ new_item = Registry().get(self.serviceItem.name).onRemoteEdit(self.serviceItem.edit_id, True)
+ if new_item:
+ self.add_service_item(new_item)
def onPreviewAddToService(self):
"""
From the preview display request the Item to be added to service
"""
if self.serviceItem:
- self.parent().serviceManagerContents.addServiceItem(self.serviceItem)
+ self.service_manager.add_service_item(self.serviceItem)
def onGoLiveClick(self):
"""
@@ -1215,7 +1216,7 @@
Receiver.send_message('servicemanager_preview_live', u'%s:%s' %
(self.serviceItem.unique_identifier, row))
else:
- self.parent().liveController.addServiceManagerItem(self.serviceItem, row)
+ self.live_controller.addServiceManagerItem(self.serviceItem, row)
def onMediaStart(self, item):
"""
@@ -1309,3 +1310,22 @@
media_controller = property(_get_media_controller)
+ 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_live_controller(self):
+ """
+ Adds the live controller to the class dynamically
+ """
+ if not hasattr(self, u'_live_controller'):
+ self._live_controller = Registry().get(u'live_controller')
+ return self._live_controller
+
+ live_controller = property(_get_live_controller)
\ No newline at end of file
=== modified file 'openlp/core/ui/starttimedialog.py'
--- openlp/core/ui/starttimedialog.py 2013-01-11 00:19:11 +0000
+++ openlp/core/ui/starttimedialog.py 2013-01-30 22:10:34 +0000
@@ -38,7 +38,7 @@
StartTimeDialog.setObjectName(u'StartTimeDialog')
StartTimeDialog.resize(350, 10)
self.dialogLayout = QtGui.QGridLayout(StartTimeDialog)
- self.dialogLayout.setObjectName(u'dialogLayout')
+ self.dialogLayout.setObjectName(u'dialog_layout')
self.startLabel = QtGui.QLabel(StartTimeDialog)
self.startLabel.setObjectName(u'startLabel')
self.startLabel.setAlignment(QtCore.Qt.AlignHCenter)
@@ -102,8 +102,8 @@
self.secondFinishLabel.setAlignment(QtCore.Qt.AlignRight)
self.dialogLayout.addWidget(self.secondFinishLabel, 3, 3, 1, 1)
self.dialogLayout.addWidget(self.secondSpinBox, 3, 1, 1, 1)
- self.buttonBox = create_button_box(StartTimeDialog, u'buttonBox', [u'cancel', u'ok'])
- self.dialogLayout.addWidget(self.buttonBox, 5, 2, 1, 2)
+ self.button_box = create_button_box(StartTimeDialog, u'button_box', [u'cancel', u'ok'])
+ self.dialogLayout.addWidget(self.button_box, 5, 2, 1, 2)
self.retranslateUi(StartTimeDialog)
self.setMaximumHeight(self.sizeHint().height())
=== modified file 'openlp/core/ui/starttimeform.py'
--- openlp/core/ui/starttimeform.py 2013-01-11 00:19:11 +0000
+++ openlp/core/ui/starttimeform.py 2013-01-30 22:10:34 +0000
@@ -31,15 +31,15 @@
from starttimedialog import Ui_StartTimeDialog
-from openlp.core.lib import translate, UiStrings
+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
"""
- def __init__(self, parent):
- QtGui.QDialog.__init__(self, parent)
+ def __init__(self):
+ QtGui.QDialog.__init__(self, self.main_window)
self.setupUi(self)
def exec_(self):
@@ -84,3 +84,13 @@
minutes = seconds / 60
seconds -= 60 * minutes
return hours, minutes, seconds
+
+ 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
=== modified file 'openlp/core/ui/themelayoutdialog.py'
--- openlp/core/ui/themelayoutdialog.py 2012-12-29 20:56:56 +0000
+++ openlp/core/ui/themelayoutdialog.py 2013-01-30 22:10:34 +0000
@@ -58,8 +58,8 @@
self.footerColourLabel = QtGui.QLabel(self.previewArea)
self.footerColourLabel.setObjectName(u'footerColourLabel')
self.previewLayout.addWidget(self.footerColourLabel)
- self.buttonBox = create_button_box(themeLayoutDialog, u'buttonBox', [u'ok'])
- self.previewLayout.addWidget(self.buttonBox)
+ self.button_box = create_button_box(themeLayoutDialog, u'button_box', [u'ok'])
+ self.previewLayout.addWidget(self.button_box)
self.retranslateUi(themeLayoutDialog)
def retranslateUi(self, themeLayoutDialog):
=== modified file 'openlp/plugins/alerts/forms/alertdialog.py'
--- openlp/plugins/alerts/forms/alertdialog.py 2013-01-01 16:33:41 +0000
+++ openlp/plugins/alerts/forms/alertdialog.py 2013-01-30 22:10:34 +0000
@@ -77,9 +77,9 @@
displayIcon = build_icon(u':/general/general_live.png')
self.displayButton = create_button(alertDialog, u'displayButton', icon=displayIcon, enabled=False)
self.displayCloseButton = create_button(alertDialog, u'displayCloseButton', icon=displayIcon, enabled=False)
- self.buttonBox = create_button_box(alertDialog, u'buttonBox', [u'close'],
+ self.button_box = create_button_box(alertDialog, u'button_box', [u'close'],
[self.displayButton, self.displayCloseButton])
- self.alertDialogLayout.addWidget(self.buttonBox, 2, 0, 1, 2)
+ self.alertDialogLayout.addWidget(self.button_box, 2, 0, 1, 2)
self.retranslateUi(alertDialog)
def retranslateUi(self, alertDialog):
=== modified file 'openlp/plugins/bibles/forms/booknamedialog.py'
--- openlp/plugins/bibles/forms/booknamedialog.py 2013-01-01 16:33:41 +0000
+++ openlp/plugins/bibles/forms/booknamedialog.py 2013-01-30 22:10:34 +0000
@@ -80,8 +80,8 @@
self.apocryphaCheckBox.setCheckState(QtCore.Qt.Checked)
self.optionsLayout.addWidget(self.apocryphaCheckBox)
self.bookNameLayout.addWidget(self.optionsGroupBox)
- self.buttonBox = create_button_box(bookNameDialog, u'buttonBox', [u'cancel', u'ok'])
- self.bookNameLayout.addWidget(self.buttonBox)
+ self.button_box = create_button_box(bookNameDialog, u'button_box', [u'cancel', u'ok'])
+ self.bookNameLayout.addWidget(self.button_box)
self.retranslateUi(bookNameDialog)
=== modified file 'openlp/plugins/bibles/forms/editbibledialog.py'
--- openlp/plugins/bibles/forms/editbibledialog.py 2013-01-01 16:33:41 +0000
+++ openlp/plugins/bibles/forms/editbibledialog.py 2013-01-30 22:10:34 +0000
@@ -44,7 +44,7 @@
self.dialogLayout = QtGui.QVBoxLayout(editBibleDialog)
self.dialogLayout.setSpacing(8)
self.dialogLayout.setContentsMargins(8, 8, 8, 8)
- self.dialogLayout.setObjectName(u'dialogLayout')
+ self.dialogLayout.setObjectName(u'dialog_layout')
self.bibleTabWidget = QtGui.QTabWidget(editBibleDialog)
self.bibleTabWidget.setObjectName(u'BibleTabWidget')
# Meta tab
@@ -121,8 +121,8 @@
self.bibleTabWidget.addTab(self.bookNameTab, u'')
# Last few bits
self.dialogLayout.addWidget(self.bibleTabWidget)
- self.buttonBox = create_button_box(editBibleDialog, u'buttonBox', [u'cancel', u'save'])
- self.dialogLayout.addWidget(self.buttonBox)
+ self.button_box = create_button_box(editBibleDialog, u'button_box', [u'cancel', u'save'])
+ self.dialogLayout.addWidget(self.button_box)
self.retranslateUi(editBibleDialog)
QtCore.QMetaObject.connectSlotsByName(editBibleDialog)
=== modified file 'openlp/plugins/bibles/forms/languagedialog.py'
--- openlp/plugins/bibles/forms/languagedialog.py 2013-01-01 16:33:41 +0000
+++ openlp/plugins/bibles/forms/languagedialog.py 2013-01-30 22:10:34 +0000
@@ -62,8 +62,8 @@
self.languageComboBox.setObjectName(u'languageComboBox')
self.languageHBoxLayout.addWidget(self.languageComboBox)
self.languageLayout.addLayout(self.languageHBoxLayout)
- self.buttonBox = create_button_box(languageDialog, u'buttonBox', [u'cancel', u'ok'])
- self.languageLayout.addWidget(self.buttonBox)
+ self.button_box = create_button_box(languageDialog, u'button_box', [u'cancel', u'ok'])
+ self.languageLayout.addWidget(self.button_box)
self.retranslateUi(languageDialog)
=== modified file 'openlp/plugins/custom/forms/editcustomdialog.py'
--- openlp/plugins/custom/forms/editcustomdialog.py 2013-01-11 00:19:11 +0000
+++ openlp/plugins/custom/forms/editcustomdialog.py 2013-01-30 22:10:34 +0000
@@ -38,7 +38,7 @@
customEditDialog.resize(450, 350)
customEditDialog.setWindowIcon(build_icon(u':/icon/openlp-logo-16x16.png'))
self.dialogLayout = QtGui.QVBoxLayout(customEditDialog)
- self.dialogLayout.setObjectName(u'dialogLayout')
+ self.dialogLayout.setObjectName(u'dialog_layout')
self.titleLayout = QtGui.QHBoxLayout()
self.titleLayout.setObjectName(u'titleLayout')
self.titleLabel = QtGui.QLabel(customEditDialog)
@@ -97,8 +97,8 @@
self.bottomFormLayout.addRow(self.creditLabel, self.creditEdit)
self.dialogLayout.addLayout(self.bottomFormLayout)
self.previewButton = QtGui.QPushButton()
- self.buttonBox = create_button_box(customEditDialog, u'buttonBox', [u'cancel', u'save'], [self.previewButton])
- self.dialogLayout.addWidget(self.buttonBox)
+ self.button_box = create_button_box(customEditDialog, u'button_box', [u'cancel', u'save'], [self.previewButton])
+ self.dialogLayout.addWidget(self.button_box)
self.retranslateUi(customEditDialog)
def retranslateUi(self, customEditDialog):
=== modified file 'openlp/plugins/custom/forms/editcustomform.py'
--- openlp/plugins/custom/forms/editcustomform.py 2013-01-05 22:17:30 +0000
+++ openlp/plugins/custom/forms/editcustomform.py 2013-01-30 22:10:34 +0000
@@ -102,10 +102,6 @@
# If not preview hide the preview button.
self.previewButton.setVisible(preview)
- def reject(self):
- Receiver.send_message(u'custom_edit_clear')
- QtGui.QDialog.reject(self)
-
def accept(self):
log.debug(u'accept')
if self.saveCustom():
=== modified file 'openlp/plugins/custom/forms/editcustomslidedialog.py'
--- openlp/plugins/custom/forms/editcustomslidedialog.py 2013-01-11 00:19:11 +0000
+++ openlp/plugins/custom/forms/editcustomslidedialog.py 2013-01-30 22:10:34 +0000
@@ -42,9 +42,9 @@
self.dialogLayout.addWidget(self.slideTextEdit)
self.splitButton = create_button(customSlideEditDialog, u'splitButton', icon=u':/general/general_add.png')
self.insertButton = create_button(customSlideEditDialog, u'insertButton', icon=u':/general/general_add.png')
- self.buttonBox = create_button_box(customSlideEditDialog, u'buttonBox', [u'cancel', u'save'],
+ self.button_box = create_button_box(customSlideEditDialog, u'button_box', [u'cancel', u'save'],
[self.splitButton, self.insertButton])
- self.dialogLayout.addWidget(self.buttonBox)
+ self.dialogLayout.addWidget(self.button_box)
self.retranslateUi(customSlideEditDialog)
def retranslateUi(self, customSlideEditDialog):
=== modified file 'openlp/plugins/custom/lib/mediaitem.py'
--- openlp/plugins/custom/lib/mediaitem.py 2013-01-24 20:08:52 +0000
+++ openlp/plugins/custom/lib/mediaitem.py 2013-01-30 22:10:34 +0000
@@ -73,8 +73,6 @@
QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'cleared()'), self.onClearTextButtonClick)
QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'searchTypeChanged(int)'),
self.onSearchTextButtonClicked)
- QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_edit'), self.onRemoteEdit)
- QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_edit_clear'), self.onRemoteEditClear)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_load_list'), self.loadList)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_preview'), self.onPreviewClick)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.config_updated)
@@ -115,11 +113,6 @@
# Called to redisplay the custom list screen edith from a search
# or from the exit of the Custom edit dialog. If remote editing is
# active trigger it and clean up so it will not update again.
- if self.remoteTriggered == u'L':
- self.onAddClick()
- if self.remoteTriggered == u'P':
- self.onPreviewClick()
- self.onRemoteEditClear()
def onNewClick(self):
self.edit_custom_form.loadCustom(0)
@@ -127,26 +120,27 @@
self.onClearTextButtonClick()
self.onSelectionChange()
- def onRemoteEditClear(self):
- self.remoteTriggered = None
- self.remoteCustom = -1
-
- def onRemoteEdit(self, message):
+ def onRemoteEdit(self, custom_id, preview=False):
"""
Called by ServiceManager or SlideController by event passing
the custom Id in the payload along with an indicator to say which
type of display is required.
"""
- remote_type, custom_id = message.split(u':')
custom_id = int(custom_id)
valid = self.manager.get_object(CustomSlide, custom_id)
if valid:
- self.remoteCustom = custom_id
- self.remoteTriggered = remote_type
- self.edit_custom_form.loadCustom(custom_id, (remote_type == u'P'))
- self.edit_custom_form.exec_()
- self.autoSelectId = -1
- self.onSearchTextButtonClicked()
+ self.edit_custom_form.loadCustom(custom_id, preview)
+ if self.edit_custom_form.exec_() == QtGui.QDialog.Accepted:
+ self.remoteTriggered = True
+ self.remoteCustom = custom_id
+ self.autoSelectId = -1
+ self.onSearchTextButtonClicked()
+ item = self.buildServiceItem(remote=True)
+ self.remoteTriggered = None
+ self.remoteCustom = 1
+ if item:
+ return item
+ return None
def onEditClick(self):
"""
=== modified file 'openlp/plugins/images/lib/mediaitem.py'
--- openlp/plugins/images/lib/mediaitem.py 2013-01-23 20:29:43 +0000
+++ openlp/plugins/images/lib/mediaitem.py 2013-01-30 22:10:34 +0000
@@ -189,10 +189,10 @@
def onResetClick(self):
"""
- Called to reset the Live backgound with the image selected,
+ Called to reset the Live background with the image selected,
"""
self.resetAction.setVisible(False)
- self.plugin.liveController.display.resetImage()
+ self.live_controller.display.resetImage()
def liveThemeChanged(self):
"""
@@ -211,7 +211,7 @@
bitem = self.listView.item(item.row())
filename = bitem.data(QtCore.Qt.UserRole)
if os.path.exists(filename):
- if self.plugin.liveController.display.directImage(filename, background):
+ if self.live_controller.display.directImage(filename, background):
self.resetAction.setVisible(True)
else:
critical_error_message_box(UiStrings().LiveBGError,
=== modified file 'openlp/plugins/media/lib/mediaitem.py'
--- openlp/plugins/media/lib/mediaitem.py 2013-01-23 20:29:43 +0000
+++ openlp/plugins/media/lib/mediaitem.py 2013-01-30 22:10:34 +0000
@@ -131,7 +131,7 @@
"""
Called to reset the Live background with the media selected,
"""
- self.live_controller.mediaController.media_reset(self.plugin.liveController)
+ self.media_controller.media_reset(self.live_controller)
self.resetAction.setVisible(False)
def videobackgroundReplaced(self):
@@ -154,7 +154,7 @@
service_item.shortname = service_item.title
(path, name) = os.path.split(filename)
service_item.add_from_command(path, name,CLAPPERBOARD)
- if self.live_controller.mediaController.video(DisplayControllerType.Live, service_item,
+ if self.media_controller.video(DisplayControllerType.Live, service_item,
videoBehindText=True):
self.resetAction.setVisible(True)
else:
=== modified file 'openlp/plugins/media/lib/mediatab.py'
--- openlp/plugins/media/lib/mediatab.py 2013-01-11 00:19:11 +0000
+++ openlp/plugins/media/lib/mediatab.py 2013-01-30 22:10:34 +0000
@@ -85,6 +85,6 @@
if Settings().value(setting_key) != self.autoStartCheckBox.checkState():
Settings().setValue(setting_key, self.autoStartCheckBox.checkState())
if override_changed:
- self.parent.resetSupportedSuffixes()
+ self.parent.reset_supported_suffixes()
Receiver.send_message(u'mediaitem_media_rebuild')
Receiver.send_message(u'mediaitem_suffixes')
=== modified file 'openlp/plugins/presentations/lib/mediaitem.py'
--- openlp/plugins/presentations/lib/mediaitem.py 2013-01-23 20:29:43 +0000
+++ openlp/plugins/presentations/lib/mediaitem.py 2013-01-30 22:10:34 +0000
@@ -85,7 +85,7 @@
for type in types:
if fileType.find(type) == -1:
fileType += u'*.%s ' % type
- self.plugin.serviceManager.supportedSuffixes(type)
+ self.service_manager.supported_suffixes(type)
self.onNewFileMasks = translate('PresentationPlugin.MediaItem', 'Presentations (%s)') % fileType
def requiredIcons(self):
=== modified file 'openlp/plugins/presentations/lib/presentationtab.py'
--- openlp/plugins/presentations/lib/presentationtab.py 2013-01-11 00:19:11 +0000
+++ openlp/plugins/presentations/lib/presentationtab.py 2013-01-30 22:10:34 +0000
@@ -129,7 +129,7 @@
Settings().setValue(setting_key, self.OverrideAppCheckBox.checkState())
changed = True
if changed:
- self.parent.resetSupportedSuffixes()
+ self.parent.reset_supported_suffixes()
Receiver.send_message(u'mediaitem_presentation_rebuild')
Receiver.send_message(u'mediaitem_suffixes')
=== modified file 'openlp/plugins/songs/forms/authorsdialog.py'
--- openlp/plugins/songs/forms/authorsdialog.py 2013-01-05 22:17:30 +0000
+++ openlp/plugins/songs/forms/authorsdialog.py 2013-01-30 22:10:34 +0000
@@ -37,7 +37,7 @@
authorsDialog.setObjectName(u'AuthorsDialog')
authorsDialog.resize(300, 10)
self.dialogLayout = QtGui.QVBoxLayout(authorsDialog)
- self.dialogLayout.setObjectName(u'dialogLayout')
+ self.dialogLayout.setObjectName(u'dialog_layout')
self.authorLayout = QtGui.QFormLayout()
self.authorLayout.setObjectName(u'authorLayout')
self.firstNameLabel = QtGui.QLabel(authorsDialog)
@@ -59,8 +59,8 @@
self.displayLabel.setBuddy(self.displayEdit)
self.authorLayout.addRow(self.displayLabel, self.displayEdit)
self.dialogLayout.addLayout(self.authorLayout)
- self.buttonBox = create_button_box(authorsDialog, u'buttonBox', [u'cancel', u'save'])
- self.dialogLayout.addWidget(self.buttonBox)
+ self.button_box = create_button_box(authorsDialog, u'button_box', [u'cancel', u'save'])
+ self.dialogLayout.addWidget(self.button_box)
self.retranslateUi(authorsDialog)
authorsDialog.setMaximumHeight(authorsDialog.sizeHint().height())
=== modified file 'openlp/plugins/songs/forms/editsongdialog.py'
--- openlp/plugins/songs/forms/editsongdialog.py 2013-01-11 00:19:11 +0000
+++ openlp/plugins/songs/forms/editsongdialog.py 2013-01-30 22:10:34 +0000
@@ -42,7 +42,7 @@
self.dialogLayout = QtGui.QVBoxLayout(editSongDialog)
self.dialogLayout.setSpacing(8)
self.dialogLayout.setContentsMargins(8, 8, 8, 8)
- self.dialogLayout.setObjectName(u'dialogLayout')
+ self.dialogLayout.setObjectName(u'dialog_layout')
self.songTabWidget = QtGui.QTabWidget(editSongDialog)
self.songTabWidget.setObjectName(u'songTabWidget')
# lyrics tab
@@ -272,8 +272,8 @@
self.warningLabel.setObjectName(u'warningLabel')
self.warningLabel.setVisible(False)
self.bottomLayout.addWidget(self.warningLabel)
- self.buttonBox = create_button_box(editSongDialog, u'buttonBox', [u'cancel', u'save'])
- self.bottomLayout.addWidget(self.buttonBox)
+ self.button_box = create_button_box(editSongDialog, u'button_box', [u'cancel', u'save'])
+ self.bottomLayout.addWidget(self.button_box)
self.dialogLayout.addLayout(self.bottomLayout)
self.retranslateUi(editSongDialog)
=== modified file 'openlp/plugins/songs/forms/editsongform.py'
--- openlp/plugins/songs/forms/editsongform.py 2013-01-23 20:29:43 +0000
+++ openlp/plugins/songs/forms/editsongform.py 2013-01-30 22:10:34 +0000
@@ -101,8 +101,8 @@
self.previewButton = QtGui.QPushButton()
self.previewButton.setObjectName(u'previewButton')
self.previewButton.setText(UiStrings().SaveAndPreview)
- self.buttonBox.addButton(self.previewButton, QtGui.QDialogButtonBox.ActionRole)
- QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'clicked(QAbstractButton*)'), self.onPreview)
+ self.button_box.addButton(self.previewButton, QtGui.QDialogButtonBox.ActionRole)
+ QtCore.QObject.connect(self.button_box, QtCore.SIGNAL(u'clicked(QAbstractButton*)'), self.onPreview)
# Create other objects and forms
self.manager = manager
self.verseForm = EditVerseForm(self)
@@ -775,7 +775,6 @@
Exit Dialog and do not save
"""
log.debug (u'SongEditForm.reject')
- Receiver.send_message(u'songs_edit_clear')
self.clearCaches()
QtGui.QDialog.reject(self)
=== modified file 'openlp/plugins/songs/forms/editversedialog.py'
--- openlp/plugins/songs/forms/editversedialog.py 2013-01-05 22:17:30 +0000
+++ openlp/plugins/songs/forms/editversedialog.py 2013-01-30 22:10:34 +0000
@@ -39,7 +39,7 @@
editVerseDialog.resize(400, 400)
editVerseDialog.setModal(True)
self.dialogLayout = QtGui.QVBoxLayout(editVerseDialog)
- self.dialogLayout.setObjectName(u'dialogLayout')
+ self.dialogLayout.setObjectName(u'dialog_layout')
self.verseTextEdit = SpellTextEdit(editVerseDialog)
self.verseTextEdit.setObjectName(u'verseTextEdit')
self.dialogLayout.addWidget(self.verseTextEdit)
@@ -67,8 +67,8 @@
self.verseTypeLayout.addWidget(self.insertButton)
self.verseTypeLayout.addStretch()
self.dialogLayout.addLayout(self.verseTypeLayout)
- self.buttonBox = create_button_box(editVerseDialog, u'buttonBox', [u'cancel', u'ok'])
- self.dialogLayout.addWidget(self.buttonBox)
+ self.button_box = create_button_box(editVerseDialog, u'button_box', [u'cancel', u'ok'])
+ self.dialogLayout.addWidget(self.button_box)
self.retranslateUi(editVerseDialog)
def retranslateUi(self, editVerseDialog):
=== modified file 'openlp/plugins/songs/forms/mediafilesdialog.py'
--- openlp/plugins/songs/forms/mediafilesdialog.py 2013-01-05 22:17:30 +0000
+++ openlp/plugins/songs/forms/mediafilesdialog.py 2013-01-30 22:10:34 +0000
@@ -52,8 +52,8 @@
self.fileListWidget.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
self.fileListWidget.setObjectName(u'fileListWidget')
self.filesVerticalLayout.addWidget(self.fileListWidget)
- self.buttonBox = create_button_box(mediaFilesDialog, u'buttonBox', [u'cancel', u'ok'])
- self.filesVerticalLayout.addWidget(self.buttonBox)
+ self.button_box = create_button_box(mediaFilesDialog, u'button_box', [u'cancel', u'ok'])
+ self.filesVerticalLayout.addWidget(self.button_box)
self.retranslateUi(mediaFilesDialog)
def retranslateUi(self, mediaFilesDialog):
=== modified file 'openlp/plugins/songs/forms/songbookdialog.py'
--- openlp/plugins/songs/forms/songbookdialog.py 2013-01-05 22:17:30 +0000
+++ openlp/plugins/songs/forms/songbookdialog.py 2013-01-30 22:10:34 +0000
@@ -37,7 +37,7 @@
songBookDialog.setObjectName(u'songBookDialog')
songBookDialog.resize(300, 10)
self.dialogLayout = QtGui.QVBoxLayout(songBookDialog)
- self.dialogLayout.setObjectName(u'dialogLayout')
+ self.dialogLayout.setObjectName(u'dialog_layout')
self.bookLayout = QtGui.QFormLayout()
self.bookLayout.setObjectName(u'bookLayout')
self.nameLabel = QtGui.QLabel(songBookDialog)
@@ -53,8 +53,8 @@
self.publisherLabel.setBuddy(self.publisherEdit)
self.bookLayout.addRow(self.publisherLabel, self.publisherEdit)
self.dialogLayout.addLayout(self.bookLayout)
- self.buttonBox = create_button_box(songBookDialog, u'buttonBox', [u'cancel', u'save'])
- self.dialogLayout.addWidget(self.buttonBox)
+ self.button_box = create_button_box(songBookDialog, u'button_box', [u'cancel', u'save'])
+ self.dialogLayout.addWidget(self.button_box)
self.retranslateUi(songBookDialog)
songBookDialog.setMaximumHeight(songBookDialog.sizeHint().height())
=== modified file 'openlp/plugins/songs/forms/songmaintenancedialog.py'
--- openlp/plugins/songs/forms/songmaintenancedialog.py 2013-01-11 00:19:11 +0000
+++ openlp/plugins/songs/forms/songmaintenancedialog.py 2013-01-30 22:10:34 +0000
@@ -39,7 +39,7 @@
songMaintenanceDialog.setWindowModality(QtCore.Qt.ApplicationModal)
songMaintenanceDialog.resize(10, 350)
self.dialogLayout = QtGui.QGridLayout(songMaintenanceDialog)
- self.dialogLayout.setObjectName(u'dialogLayout')
+ self.dialogLayout.setObjectName(u'dialog_layout')
self.typeListWidget = QtGui.QListWidget(songMaintenanceDialog)
self.typeListWidget.setIconSize(QtCore.QSize(32, 32))
self.typeListWidget.setUniformItemSizes(True)
@@ -130,8 +130,8 @@
self.stackedLayout.addWidget(self.booksPage)
#
self.dialogLayout.addLayout(self.stackedLayout, 0, 1)
- self.buttonBox = create_button_box(songMaintenanceDialog, u'buttonBox', [u'close'])
- self.dialogLayout.addWidget(self.buttonBox, 1, 0, 1, 2)
+ self.button_box = create_button_box(songMaintenanceDialog, u'button_box', [u'close'])
+ self.dialogLayout.addWidget(self.button_box, 1, 0, 1, 2)
self.retranslateUi(songMaintenanceDialog)
self.stackedLayout.setCurrentIndex(0)
QtCore.QObject.connect(self.typeListWidget, QtCore.SIGNAL(u'currentRowChanged(int)'),
=== modified file 'openlp/plugins/songs/forms/topicsdialog.py'
--- openlp/plugins/songs/forms/topicsdialog.py 2013-01-06 17:25:49 +0000
+++ openlp/plugins/songs/forms/topicsdialog.py 2013-01-30 22:10:34 +0000
@@ -37,7 +37,7 @@
topicsDialog.setObjectName(u'topicsDialog')
topicsDialog.resize(300, 10)
self.dialogLayout = QtGui.QVBoxLayout(topicsDialog)
- self.dialogLayout.setObjectName(u'dialogLayout')
+ self.dialogLayout.setObjectName(u'dialog_layout')
self.nameLayout = QtGui.QFormLayout()
self.nameLayout.setObjectName(u'nameLayout')
self.nameLabel = QtGui.QLabel(topicsDialog)
@@ -47,8 +47,8 @@
self.nameLabel.setBuddy(self.nameEdit)
self.nameLayout.addRow(self.nameLabel, self.nameEdit)
self.dialogLayout.addLayout(self.nameLayout)
- self.buttonBox = create_button_box(topicsDialog, u'buttonBox', [u'cancel', u'save'])
- self.dialogLayout.addWidget(self.buttonBox)
+ self.button_box = create_button_box(topicsDialog, u'button_box', [u'cancel', u'save'])
+ self.dialogLayout.addWidget(self.button_box)
self.retranslateUi(topicsDialog)
topicsDialog.setMaximumHeight(topicsDialog.sizeHint().height())
=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py 2013-01-24 20:08:52 +0000
+++ openlp/plugins/songs/lib/mediaitem.py 2013-01-30 22:10:34 +0000
@@ -35,15 +35,12 @@
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, translate, check_item_selected, \
+ PluginStatus, create_separated_list, check_directory_exists, ServiceItemContext, Settings, UiStrings
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
-from openlp.plugins.songs.lib import OpenLyrics, SongXML, VerseType, \
- clean_string, natcmp
+from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm, SongImportForm, SongExportForm
+from openlp.plugins.songs.lib import OpenLyrics, SongXML, VerseType, clean_string, natcmp
from openlp.plugins.songs.lib.db import Author, Song, Book, MediaFile
from openlp.plugins.songs.lib.ui import SongStrings
@@ -105,8 +102,6 @@
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'songs_load_list'), self.onSongListLoad)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.configUpdated)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'songs_preview'), self.onPreviewClick)
- QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'songs_edit'), self.onRemoteEdit)
- QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'songs_edit_clear'), self.onRemoteEditClear)
QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'cleared()'), self.onClearTextButtonClick)
QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'searchTypeChanged(int)'),
self.onSearchTextButtonClicked)
@@ -212,15 +207,10 @@
# Called to redisplay the song list screen edit from a search
# or from the exit of the Song edit dialog. If remote editing is active
# Trigger it and clean up so it will not update again.
- if self.remoteTriggered == u'L':
- self.onAddClick()
- if self.remoteTriggered == u'P':
- self.onPreviewClick()
# Push edits to the service manager to update items
if self.editItem and self.updateServiceOnEdit and not self.remoteTriggered:
item = self.buildServiceItem(self.editItem)
- self.plugin.serviceManager.replaceServiceItem(item)
- self.onRemoteEditClear()
+ self.service_manager.replace_service_item(item)
self.onSearchTextButtonClicked()
log.debug(u'onSongListLoad - finished')
@@ -321,28 +311,28 @@
def onSongMaintenanceClick(self):
self.songMaintenanceForm.exec_()
- def onRemoteEditClear(self):
- log.debug(u'onRemoteEditClear')
- self.remoteTriggered = None
- self.remoteSong = -1
-
- def onRemoteEdit(self, message):
+ def onRemoteEdit(self, song_id, preview=False):
"""
Called by ServiceManager or SlideController by event passing
the Song Id in the payload along with an indicator to say which
type of display is required.
"""
- log.debug(u'onRemoteEdit %s' % message)
- remote_type, song_id = message.split(u':')
+ log.debug(u'onRemoteEdit for song %s' % song_id)
song_id = int(song_id)
valid = self.plugin.manager.get_object(Song, song_id)
if valid:
- self.remoteSong = song_id
- self.remoteTriggered = remote_type
- self.editSongForm.loadSong(song_id, remote_type == u'P')
- self.editSongForm.exec_()
- self.autoSelectId = -1
- self.onSongListLoad()
+ self.editSongForm.loadSong(song_id, preview)
+ if self.editSongForm.exec_() == QtGui.QDialog.Accepted:
+ self.autoSelectId = -1
+ self.onSongListLoad()
+ self.remoteSong = song_id
+ self.remoteTriggered = True
+ item = self.buildServiceItem(remote=True)
+ self.remoteSong = -1
+ self.remoteTriggered = None
+ if item:
+ return item
+ return None
def onEditClick(self):
"""
@@ -410,7 +400,7 @@
self.onSongListLoad()
def generateSlideData(self, service_item, item=None, xmlVersion=False,
- remote=False, context=ServiceItemContext.Service):
+ remote=False, context=ServiceItemContext.Service):
log.debug(u'generateSlideData: %s, %s, %s' % (service_item, item, self.remoteSong))
item_id = self._getIdOfItemToGenerate(item, self.remoteSong)
service_item.add_capability(ItemCapabilities.CanEdit)
@@ -426,8 +416,7 @@
verse_list = SongXML().get_verses(song.lyrics)
# no verse list or only 1 space (in error)
verse_tags_translated = False
- if VerseType.from_translated_string(unicode(
- verse_list[0][0][u'type'])) is not None:
+ if VerseType.from_translated_string(unicode(verse_list[0][0][u'type'])) is not None:
verse_tags_translated = True
if not song.verse_order.strip():
for verse in verse_list:
=== modified file 'openlp/plugins/songusage/forms/songusagedeletedialog.py'
--- openlp/plugins/songusage/forms/songusagedeletedialog.py 2013-01-01 16:33:41 +0000
+++ openlp/plugins/songusage/forms/songusagedeletedialog.py 2013-01-30 22:10:34 +0000
@@ -49,8 +49,8 @@
self.deleteCalendar.setVerticalHeaderFormat(QtGui.QCalendarWidget.NoVerticalHeader)
self.deleteCalendar.setObjectName(u'deleteCalendar')
self.verticalLayout.addWidget(self.deleteCalendar)
- self.buttonBox = create_button_box(songUsageDeleteDialog, u'buttonBox', [u'cancel', u'ok'])
- self.verticalLayout.addWidget(self.buttonBox)
+ self.button_box = create_button_box(songUsageDeleteDialog, u'button_box', [u'cancel', u'ok'])
+ self.verticalLayout.addWidget(self.button_box)
self.retranslateUi(songUsageDeleteDialog)
def retranslateUi(self, songUsageDeleteDialog):
=== modified file 'openlp/plugins/songusage/forms/songusagedeleteform.py'
--- openlp/plugins/songusage/forms/songusagedeleteform.py 2013-01-01 16:33:41 +0000
+++ openlp/plugins/songusage/forms/songusagedeleteform.py 2013-01-30 22:10:34 +0000
@@ -44,11 +44,11 @@
self.manager = manager
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
- QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'clicked(QAbstractButton*)'),
+ QtCore.QObject.connect(self.button_box, QtCore.SIGNAL(u'clicked(QAbstractButton*)'),
self.onButtonBoxClicked)
def onButtonBoxClicked(self, button):
- if self.buttonBox.standardButton(button) == QtGui.QDialogButtonBox.Ok:
+ if self.button_box.standardButton(button) == QtGui.QDialogButtonBox.Ok:
ret = QtGui.QMessageBox.question(self,
translate('SongUsagePlugin.SongUsageDeleteForm', 'Delete Selected Song Usage Events?'),
translate('SongUsagePlugin.SongUsageDeleteForm',
=== modified file 'openlp/plugins/songusage/forms/songusagedetaildialog.py'
--- openlp/plugins/songusage/forms/songusagedetaildialog.py 2013-01-01 16:33:41 +0000
+++ openlp/plugins/songusage/forms/songusagedetaildialog.py 2013-01-30 22:10:34 +0000
@@ -74,8 +74,8 @@
self.saveFilePushButton.setObjectName(u'saveFilePushButton')
self.fileHorizontalLayout.addWidget(self.saveFilePushButton)
self.verticalLayout.addWidget(self.fileGroupBox)
- self.buttonBox = create_button_box(songUsageDetailDialog, u'buttonBox', [u'cancel', u'ok'])
- self.verticalLayout.addWidget(self.buttonBox)
+ self.button_box = create_button_box(songUsageDetailDialog, u'button_box', [u'cancel', u'ok'])
+ self.verticalLayout.addWidget(self.button_box)
self.retranslateUi(songUsageDetailDialog)
QtCore.QObject.connect(self.saveFilePushButton, QtCore.SIGNAL(u'clicked()'),
songUsageDetailDialog.defineOutputLocation)
=== modified file 'tests/functional/openlp_core_lib/test_registry.py'
--- tests/functional/openlp_core_lib/test_registry.py 2013-01-24 20:04:18 +0000
+++ tests/functional/openlp_core_lib/test_registry.py 2013-01-30 22:10:34 +0000
@@ -13,26 +13,36 @@
def registry_basic_test(self):
"""
- Test the Service Item basic test
+ Test the registry creation and its usage
"""
# GIVEN: A new registry
registry = Registry.create()
- # WHEN: I add a service it should save it
+ # WHEN: I add a component it should save it
mock_1 = MagicMock()
Registry().register(u'test1', mock_1)
- # THEN: we should be able retrieve the saved object
+ # THEN: we should be able retrieve the saved component
assert Registry().get(u'test1') == mock_1, u'The saved service can be retrieved and matches'
- # WHEN: I add a service for the second time I am mad.
- # THEN I will get an exception
+ # WHEN: I add a component for the second time I am mad.
+ # THEN and I will get an exception
with self.assertRaises(KeyError) as context:
Registry().register(u'test1', mock_1)
- self.assertEqual(context.exception[0], u'Duplicate service exception test1')
+ self.assertEqual(context.exception[0], u'Duplicate service exception test1',
+ u'KeyError exception should have been thrown for duplicate service')
- # WHEN I try to get back a non existent service
+ # WHEN I try to get back a non existent component
# THEN I will get an exception
with self.assertRaises(KeyError) as context:
temp = Registry().get(u'test2')
- self.assertEqual(context.exception[0], u'Service test2 not found in list')
\ No newline at end of file
+ self.assertEqual(context.exception[0], u'Service test2 not found in list',
+ u'KeyError exception should have been thrown for missing service')
+
+ # WHEN I try to replace a component I should be allowed (testing only)
+ Registry().remove(u'test1')
+ # THEN I will get an exception
+ with self.assertRaises(KeyError) as context:
+ temp = Registry().get(u'test1')
+ self.assertEqual(context.exception[0], u'Service test1 not found in list',
+ u'KeyError exception should have been thrown for deleted service')
=== modified file 'tests/functional/openlp_core_lib/test_serviceitem.py'
--- tests/functional/openlp_core_lib/test_serviceitem.py 2013-01-24 20:14:30 +0000
+++ tests/functional/openlp_core_lib/test_serviceitem.py 2013-01-30 22:10:34 +0000
@@ -29,11 +29,10 @@
Set up the Registry
"""
registry = Registry.create()
- mocked_renderer = MagicMock()
- mocked_image_manager = MagicMock()
+ mocked_renderer = MagicMock()
mocked_renderer.format_slide.return_value = [VERSE]
Registry().register(u'renderer', mocked_renderer)
- Registry().register(u'image_manager', mocked_image_manager)
+ Registry().register(u'image_manager', MagicMock())
def serviceitem_basic_test(self):
"""
=== added file 'tests/functional/openlp_core_ui/test_servicenotedialog.py'
--- tests/functional/openlp_core_ui/test_servicenotedialog.py 1970-01-01 00:00:00 +0000
+++ tests/functional/openlp_core_ui/test_servicenotedialog.py 2013-01-30 22:10:34 +0000
@@ -0,0 +1,67 @@
+"""
+ Package to test the openlp.core.ui package.
+"""
+from unittest import TestCase
+
+from mock import patch
+from openlp.core.lib import Registry
+from openlp.core.ui import servicenoteform
+from PyQt4 import QtCore, QtGui, QtTest
+
+class TestStartNoteDialog(TestCase):
+
+ def setUp(self):
+ """
+ Create the UI
+ """
+ registry = Registry.create()
+ self.app = QtGui.QApplication([])
+ self.main_window = QtGui.QMainWindow()
+ Registry().register(u'main_window', self.main_window)
+ self.form = servicenoteform.ServiceNoteForm()
+
+ def tearDown(self):
+ """
+ Delete all the C++ objects at the end so that we don't have a segfault
+ """
+ del self.form
+ del self.main_window
+ del self.app
+
+ def basic_display_test(self):
+ """
+ Test Service Note form functionality
+ """
+ # GIVEN: A dialog with an empty text box
+ self.form.text_edit.setPlainText(u'')
+
+ # WHEN displaying the UI and pressing enter
+ with patch(u'PyQt4.QtGui.QDialog') as mocked_exec:
+ self.form.exec_()
+ okWidget = self.form.button_box.button(self.form.button_box.Save)
+ QtTest.QTest.mouseClick(okWidget, QtCore.Qt.LeftButton)
+
+ # THEN the following input text is returned
+ self.assertEqual(self.form.text_edit.toPlainText(), u'', u'The returned text should be empty')
+
+ # WHEN displaying the UI, having set the text and pressing enter
+ text = u'OpenLP is the best worship software'
+ self.form.text_edit.setPlainText(text)
+ with patch(u'PyQt4.QtGui.QDialog') as mocked_exec:
+ self.form.exec_()
+ okWidget = self.form.button_box.button(self.form.button_box.Save)
+ QtTest.QTest.mouseClick(okWidget, QtCore.Qt.LeftButton)
+
+ # THEN the following text is returned
+ self.assertEqual(self.form.text_edit.toPlainText(), text, u'The text originally entered should still be there')
+
+ # WHEN displaying the UI, having set the text and pressing enter
+ self.form.text_edit.setPlainText(u'')
+ with patch(u'PyQt4.QtGui.QDialog') as mocked_exec:
+ self.form.exec_()
+ self.form.text_edit.setPlainText(text)
+ okWidget = self.form.button_box.button(self.form.button_box.Save)
+ QtTest.QTest.mouseClick(okWidget, QtCore.Qt.LeftButton)
+
+ # THEN the following text is returned
+ self.assertEqual(self.form.text_edit.toPlainText(), text, u'The new text should be returned')
\ No newline at end of file
=== modified file 'tests/functional/openlp_core_ui/test_starttimedialog.py'
--- tests/functional/openlp_core_ui/test_starttimedialog.py 2013-01-24 19:08:47 +0000
+++ tests/functional/openlp_core_ui/test_starttimedialog.py 2013-01-30 22:10:34 +0000
@@ -5,8 +5,9 @@
from unittest import TestCase
from mock import MagicMock, patch
+from openlp.core.lib import Registry
from openlp.core.ui import starttimeform
-from PyQt4 import QtGui, QtTest
+from PyQt4 import QtCore, QtGui, QtTest
class TestStartTimeDialog(TestCase):
@@ -14,52 +15,81 @@
"""
Create the UI
"""
+ registry = Registry.create()
self.app = QtGui.QApplication([])
- self.window = QtGui.QMainWindow()
- self.form = starttimeform.StartTimeForm(self.window)
+ self.main_window = QtGui.QMainWindow()
+ Registry().register(u'main_window', self.main_window)
+ self.form = starttimeform.StartTimeForm()
def tearDown(self):
"""
Delete all the C++ objects at the end so that we don't have a segfault
"""
del self.form
- del self.window
+ del self.main_window
del self.app
def ui_defaults_test(self):
"""
- Test StartTimeDialog defaults
+ Test StartTimeDialog are defaults correct
"""
- self.assertEqual(self.form.hourSpinBox.minimum(), 0)
- self.assertEqual(self.form.hourSpinBox.maximum(), 4)
- self.assertEqual(self.form.minuteSpinBox.minimum(), 0)
- self.assertEqual(self.form.minuteSpinBox.maximum(), 59)
- self.assertEqual(self.form.secondSpinBox.minimum(), 0)
- self.assertEqual(self.form.secondSpinBox.maximum(), 59)
- self.assertEqual(self.form.hourFinishSpinBox.minimum(), 0)
- self.assertEqual(self.form.hourFinishSpinBox.maximum(), 4)
- self.assertEqual(self.form.minuteFinishSpinBox.minimum(), 0)
- self.assertEqual(self.form.minuteFinishSpinBox.maximum(), 59)
- self.assertEqual(self.form.secondFinishSpinBox.minimum(), 0)
- self.assertEqual(self.form.secondFinishSpinBox.maximum(), 59)
+ self.assertEqual(self.form.hourSpinBox.minimum(), 0, u'The minimum hour should stay the same as the dialog')
+ self.assertEqual(self.form.hourSpinBox.maximum(), 4, u'The maximum hour should stay the same as the dialog')
+ self.assertEqual(self.form.minuteSpinBox.minimum(), 0,
+ u'The minimum minute should stay the same as the dialog')
+ self.assertEqual(self.form.minuteSpinBox.maximum(), 59,
+ u'The maximum minute should stay the same as the dialog')
+ self.assertEqual(self.form.secondSpinBox.minimum(), 0,
+ u'The minimum second should stay the same as the dialog')
+ self.assertEqual(self.form.secondSpinBox.maximum(), 59,
+ u'The maximum second should stay the same as the dialog')
+ self.assertEqual(self.form.hourFinishSpinBox.minimum(), 0,
+ u'The minimum finish hour should stay the same as the dialog')
+ self.assertEqual(self.form.hourFinishSpinBox.maximum(), 4,
+ u'The maximum finish hour should stay the same as the dialog')
+ self.assertEqual(self.form.minuteFinishSpinBox.minimum(), 0,
+ u'The minimum finish minute should stay the same as the dialog')
+ self.assertEqual(self.form.minuteFinishSpinBox.maximum(), 59,
+ u'The maximum finish minute should stay the same as the dialog')
+ self.assertEqual(self.form.secondFinishSpinBox.minimum(), 0,
+ u'The minimum finish second should stay the same as the dialog')
+ self.assertEqual(self.form.secondFinishSpinBox.maximum(), 59,
+ u'The maximum finish second should stay the same as the dialog')
def time_display_test(self):
"""
- Test StartTimeDialog display initialisation
+ Test StartTimeDialog display functionality
"""
# GIVEN: A service item with with time
mocked_serviceitem = MagicMock()
mocked_serviceitem.start_time = 61
mocked_serviceitem.end_time = 3701
+ mocked_serviceitem.media_length = 3701
# WHEN displaying the UI and pressing enter
- self.form.item = mocked_serviceitem
- with patch(u'openlp.core.lib.QtGui.QDialog') as MockedQtGuiQDialog:
- MockedQtGuiQDialog.return_value = True
- #does not work yet
- #self.form.exec_()
+ self.form.item = {u'service_item': mocked_serviceitem}
+ with patch(u'PyQt4.QtGui.QDialog') as mocked_exec:
+ self.form.exec_()
+ okWidget = self.form.button_box.button(self.form.button_box.Ok)
+ QtTest.QTest.mouseClick(okWidget, QtCore.Qt.LeftButton)
+
+ # THEN the following input values are returned
+ self.assertEqual(self.form.hourSpinBox.value(), 0)
+ self.assertEqual(self.form.minuteSpinBox.value(), 1)
+ self.assertEqual(self.form.secondSpinBox.value(), 1)
+ self.assertEqual(self.form.item[u'service_item'].start_time, 61, u'The start time should stay the same')
+
+ # WHEN displaying the UI, changing the time to 2min 3secs and pressing enter
+ self.form.item = {u'service_item': mocked_serviceitem}
+ with patch(u'PyQt4.QtGui.QDialog') as mocked_exec:
+ self.form.exec_()
+ self.form.minuteSpinBox.setValue(2)
+ self.form.secondSpinBox.setValue(3)
+ okWidget = self.form.button_box.button(self.form.button_box.Ok)
+ QtTest.QTest.mouseClick(okWidget, QtCore.Qt.LeftButton)
# THEN the following values are returned
self.assertEqual(self.form.hourSpinBox.value(), 0)
- self.assertEqual(self.form.minuteSpinBox.value(), 0)
- self.assertEqual(self.form.secondSpinBox.value(), 0)
\ No newline at end of file
+ self.assertEqual(self.form.minuteSpinBox.value(), 2)
+ self.assertEqual(self.form.secondSpinBox.value(), 3)
+ self.assertEqual(self.form.item[u'service_item'].start_time, 123, u'The start time should have changed')
\ No newline at end of file
Follow ups