forked from openlp/openlp
Remove events and move to Registry
This commit is contained in:
parent
7303395cb7
commit
27cd63ebcd
|
@ -109,10 +109,6 @@ class OpenLP(QtGui.QApplication):
|
||||||
if 'OpenLP' in args:
|
if 'OpenLP' in args:
|
||||||
args.remove('OpenLP')
|
args.remove('OpenLP')
|
||||||
self.args.extend(args)
|
self.args.extend(args)
|
||||||
# provide a listener for widgets to reqest a screen update.
|
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_process_events'), self.processEvents)
|
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'cursor_busy'), self.setBusyCursor)
|
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'cursor_normal'), self.setNormalCursor)
|
|
||||||
# Decide how many screens we have and their size
|
# Decide how many screens we have and their size
|
||||||
screens = ScreenList.create(self.desktop())
|
screens = ScreenList.create(self.desktop())
|
||||||
# First time checks in settings
|
# First time checks in settings
|
||||||
|
@ -182,21 +178,28 @@ class OpenLP(QtGui.QApplication):
|
||||||
if not hasattr(self, u'exceptionForm'):
|
if not hasattr(self, u'exceptionForm'):
|
||||||
self.exceptionForm = ExceptionForm(self.mainWindow)
|
self.exceptionForm = ExceptionForm(self.mainWindow)
|
||||||
self.exceptionForm.exceptionTextEdit.setPlainText(''.join(format_exception(exctype, value, traceback)))
|
self.exceptionForm.exceptionTextEdit.setPlainText(''.join(format_exception(exctype, value, traceback)))
|
||||||
self.setNormalCursor()
|
self.set_normal_cursor()
|
||||||
self.exceptionForm.exec_()
|
self.exceptionForm.exec_()
|
||||||
|
|
||||||
def setBusyCursor(self):
|
def process_events(self):
|
||||||
|
"""
|
||||||
|
Wrapper to make ProcessEvents visible and named correctly
|
||||||
|
"""
|
||||||
|
self.processEvents()
|
||||||
|
|
||||||
|
def set_busy_cursor(self):
|
||||||
"""
|
"""
|
||||||
Sets the Busy Cursor for the Application
|
Sets the Busy Cursor for the Application
|
||||||
"""
|
"""
|
||||||
self.setOverrideCursor(QtCore.Qt.BusyCursor)
|
self.setOverrideCursor(QtCore.Qt.BusyCursor)
|
||||||
self.processEvents()
|
self.processEvents()
|
||||||
|
|
||||||
def setNormalCursor(self):
|
def set_normal_cursor(self):
|
||||||
"""
|
"""
|
||||||
Sets the Normal Cursor for the Application
|
Sets the Normal Cursor for the Application
|
||||||
"""
|
"""
|
||||||
self.restoreOverrideCursor()
|
self.restoreOverrideCursor()
|
||||||
|
self.processEvents()
|
||||||
|
|
||||||
def event(self, event):
|
def event(self, event):
|
||||||
"""
|
"""
|
||||||
|
@ -288,6 +291,7 @@ def main(args=None):
|
||||||
app.setApplicationName(u'OpenLP')
|
app.setApplicationName(u'OpenLP')
|
||||||
set_up_logging(AppLocation.get_directory(AppLocation.CacheDir))
|
set_up_logging(AppLocation.get_directory(AppLocation.CacheDir))
|
||||||
registry = Registry.create()
|
registry = Registry.create()
|
||||||
|
Registry().register(u'openlp_core', app)
|
||||||
app.setApplicationVersion(get_application_version()[u'version'])
|
app.setApplicationVersion(get_application_version()[u'version'])
|
||||||
# Instance check
|
# Instance check
|
||||||
if not options.testing:
|
if not options.testing:
|
||||||
|
|
|
@ -55,15 +55,6 @@ class EventReceiver(QtCore.QObject):
|
||||||
``openlp_information_message``
|
``openlp_information_message``
|
||||||
Displays a standalone Information Message.
|
Displays a standalone Information Message.
|
||||||
|
|
||||||
``cursor_busy``
|
|
||||||
Makes the cursor got to a busy form.
|
|
||||||
|
|
||||||
``cursor_normal``
|
|
||||||
Resets the cursor to default.
|
|
||||||
|
|
||||||
``openlp_process_events``
|
|
||||||
Requests the Application to flush the events queue.
|
|
||||||
|
|
||||||
``openlp_version_check``
|
``openlp_version_check``
|
||||||
Version has changed so pop up window.
|
Version has changed so pop up window.
|
||||||
|
|
||||||
|
@ -120,29 +111,6 @@ class EventReceiver(QtCore.QObject):
|
||||||
``slidecontroller_live_stop_loop``
|
``slidecontroller_live_stop_loop``
|
||||||
Stop the loop on the main display.
|
Stop the loop on the main display.
|
||||||
|
|
||||||
|
|
||||||
**Servicemanager related signals**
|
|
||||||
|
|
||||||
``servicemanager_new_service``
|
|
||||||
A new service is being loaded or created.
|
|
||||||
|
|
||||||
``servicemanager_previous_item``
|
|
||||||
Display the previous item in the service.
|
|
||||||
|
|
||||||
``servicemanager_preview_live``
|
|
||||||
Requests a Preview item from the Service Manager to update live and add
|
|
||||||
a new item to the preview panel.
|
|
||||||
|
|
||||||
``servicemanager_next_item``
|
|
||||||
Display the next item in the service.
|
|
||||||
|
|
||||||
``servicemanager_set_item``
|
|
||||||
Go live on a specific item, by index.
|
|
||||||
|
|
||||||
``service_item_update``
|
|
||||||
Passes back to the service manager the service item after it has been
|
|
||||||
processed by the plugin.
|
|
||||||
|
|
||||||
**Display signals**
|
**Display signals**
|
||||||
|
|
||||||
``update_display_css``
|
``update_display_css``
|
||||||
|
|
|
@ -332,9 +332,9 @@ class MediaManagerItem(QtGui.QWidget):
|
||||||
Settings().value(self.settingsSection + u'/last directory'), self.onNewFileMasks)
|
Settings().value(self.settingsSection + u'/last directory'), self.onNewFileMasks)
|
||||||
log.info(u'New files(s) %s', files)
|
log.info(u'New files(s) %s', files)
|
||||||
if files:
|
if files:
|
||||||
Receiver.send_message(u'cursor_busy')
|
self.openlp_core.set_busy_cursor()
|
||||||
self.validateAndLoad(files)
|
self.validateAndLoad(files)
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_normal_cursor()
|
||||||
|
|
||||||
def loadFile(self, files):
|
def loadFile(self, files):
|
||||||
"""
|
"""
|
||||||
|
@ -698,3 +698,13 @@ class MediaManagerItem(QtGui.QWidget):
|
||||||
|
|
||||||
theme_manager = property(_get_theme_manager)
|
theme_manager = property(_get_theme_manager)
|
||||||
|
|
||||||
|
def _get_openlp_core(self):
|
||||||
|
"""
|
||||||
|
Adds the openlp to the class dynamically
|
||||||
|
"""
|
||||||
|
if not hasattr(self, u'_openlp_core'):
|
||||||
|
self._openlp_core = Registry().get(u'openlp_core')
|
||||||
|
return self._openlp_core
|
||||||
|
|
||||||
|
openlp_core = property(_get_openlp_core)
|
||||||
|
|
||||||
|
|
|
@ -409,6 +409,12 @@ class Plugin(QtCore.QObject):
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def new_service_created(self):
|
||||||
|
"""
|
||||||
|
The plugin's needs to handle a new song creation
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
def _get_main_window(self):
|
def _get_main_window(self):
|
||||||
"""
|
"""
|
||||||
Adds the main window to the class dynamically
|
Adds the main window to the class dynamically
|
||||||
|
@ -419,3 +425,14 @@ class Plugin(QtCore.QObject):
|
||||||
|
|
||||||
main_window = property(_get_main_window)
|
main_window = property(_get_main_window)
|
||||||
|
|
||||||
|
def _get_openlp_core(self):
|
||||||
|
"""
|
||||||
|
Adds the openlp to the class dynamically
|
||||||
|
"""
|
||||||
|
if not hasattr(self, u'_openlp_core'):
|
||||||
|
self._openlp_core = Registry().get(u'openlp_core')
|
||||||
|
return self._openlp_core
|
||||||
|
|
||||||
|
openlp_core = property(_get_openlp_core)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -211,3 +211,13 @@ class PluginManager(object):
|
||||||
if plugin.name == name:
|
if plugin.name == name:
|
||||||
return plugin
|
return plugin
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def new_service_created(self):
|
||||||
|
"""
|
||||||
|
Loop through all the plugins and give them an opportunity to handle a new service
|
||||||
|
"""
|
||||||
|
log.info(u'plugins - new service created')
|
||||||
|
for plugin in self.plugins:
|
||||||
|
if plugin.isActive():
|
||||||
|
plugin.new_service_created()
|
||||||
|
|
||||||
|
|
|
@ -146,13 +146,13 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
||||||
# Download the theme screenshots.
|
# Download the theme screenshots.
|
||||||
self.themeScreenshotThread = ThemeScreenshotThread(self)
|
self.themeScreenshotThread = ThemeScreenshotThread(self)
|
||||||
self.themeScreenshotThread.start()
|
self.themeScreenshotThread.start()
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_normal_cursor()
|
||||||
|
|
||||||
def nextId(self):
|
def nextId(self):
|
||||||
"""
|
"""
|
||||||
Determine the next page in the Wizard to go to.
|
Determine the next page in the Wizard to go to.
|
||||||
"""
|
"""
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
if self.currentId() == FirstTimePage.Plugins:
|
if self.currentId() == FirstTimePage.Plugins:
|
||||||
if not self.webAccess:
|
if not self.webAccess:
|
||||||
return FirstTimePage.NoInternet
|
return FirstTimePage.NoInternet
|
||||||
|
@ -163,14 +163,13 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
||||||
elif self.currentId() == FirstTimePage.NoInternet:
|
elif self.currentId() == FirstTimePage.NoInternet:
|
||||||
return FirstTimePage.Progress
|
return FirstTimePage.Progress
|
||||||
elif self.currentId() == FirstTimePage.Themes:
|
elif self.currentId() == FirstTimePage.Themes:
|
||||||
Receiver.send_message(u'cursor_busy')
|
self.openlp_core.set_busy_cursor()
|
||||||
Receiver.send_message(u'openlp_process_events')
|
|
||||||
while not self.themeScreenshotThread.isFinished():
|
while not self.themeScreenshotThread.isFinished():
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
# Build the screenshot icons, as this can not be done in the thread.
|
# Build the screenshot icons, as this can not be done in the thread.
|
||||||
self._buildThemeScreenshots()
|
self._buildThemeScreenshots()
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_normal_cursor()
|
||||||
return FirstTimePage.Defaults
|
return FirstTimePage.Defaults
|
||||||
else:
|
else:
|
||||||
return self.currentId() + 1
|
return self.currentId() + 1
|
||||||
|
@ -181,7 +180,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
||||||
"""
|
"""
|
||||||
# Keep track of the page we are at. Triggering "Cancel" causes pageId
|
# Keep track of the page we are at. Triggering "Cancel" causes pageId
|
||||||
# to be a -1.
|
# to be a -1.
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
if pageId != -1:
|
if pageId != -1:
|
||||||
self.lastId = pageId
|
self.lastId = pageId
|
||||||
if pageId == FirstTimePage.Plugins:
|
if pageId == FirstTimePage.Plugins:
|
||||||
|
@ -213,16 +212,15 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
||||||
if self.hasRunWizard:
|
if self.hasRunWizard:
|
||||||
self.cancelButton.setVisible(False)
|
self.cancelButton.setVisible(False)
|
||||||
elif pageId == FirstTimePage.Progress:
|
elif pageId == FirstTimePage.Progress:
|
||||||
Receiver.send_message(u'cursor_busy')
|
self.openlp_core.set_busy_cursor()
|
||||||
self.repaint()
|
self.repaint()
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
# Try to give the wizard a chance to redraw itself
|
# Try to give the wizard a chance to redraw itself
|
||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
self._preWizard()
|
self._preWizard()
|
||||||
self._performWizard()
|
self._performWizard()
|
||||||
self._postWizard()
|
self._postWizard()
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_normal_cursor()
|
||||||
Receiver.send_message(u'openlp_process_events')
|
|
||||||
|
|
||||||
def updateScreenListCombo(self):
|
def updateScreenListCombo(self):
|
||||||
"""
|
"""
|
||||||
|
@ -244,16 +242,15 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
||||||
self.downloadCancelled = True
|
self.downloadCancelled = True
|
||||||
while self.themeScreenshotThread.isRunning():
|
while self.themeScreenshotThread.isRunning():
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_normal_cursor()
|
||||||
|
|
||||||
def onNoInternetFinishButtonClicked(self):
|
def onNoInternetFinishButtonClicked(self):
|
||||||
"""
|
"""
|
||||||
Process the triggering of the "Finish" button on the No Internet page.
|
Process the triggering of the "Finish" button on the No Internet page.
|
||||||
"""
|
"""
|
||||||
Receiver.send_message(u'cursor_busy')
|
self.openlp_core.set_busy_cursor()
|
||||||
self._performWizard()
|
self._performWizard()
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_normal_cursor()
|
||||||
Receiver.send_message(u'openlp_process_events')
|
|
||||||
Settings().setValue(u'general/has run wizard', True)
|
Settings().setValue(u'general/has run wizard', True)
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
|
@ -320,7 +317,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
||||||
self.progressLabel.setText(status_text)
|
self.progressLabel.setText(status_text)
|
||||||
if increment > 0:
|
if increment > 0:
|
||||||
self.progressBar.setValue(self.progressBar.value() + increment)
|
self.progressBar.setValue(self.progressBar.value() + increment)
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
|
|
||||||
def _preWizard(self):
|
def _preWizard(self):
|
||||||
"""
|
"""
|
||||||
|
@ -328,10 +325,10 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
||||||
"""
|
"""
|
||||||
self.max_progress = 0
|
self.max_progress = 0
|
||||||
self.finishButton.setVisible(False)
|
self.finishButton.setVisible(False)
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
# Loop through the songs list and increase for each selected item
|
# Loop through the songs list and increase for each selected item
|
||||||
for i in xrange(self.songsListWidget.count()):
|
for i in xrange(self.songsListWidget.count()):
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
item = self.songsListWidget.item(i)
|
item = self.songsListWidget.item(i)
|
||||||
if item.checkState() == QtCore.Qt.Checked:
|
if item.checkState() == QtCore.Qt.Checked:
|
||||||
filename = item.data(QtCore.Qt.UserRole)
|
filename = item.data(QtCore.Qt.UserRole)
|
||||||
|
@ -340,7 +337,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
||||||
# Loop through the Bibles list and increase for each selected item
|
# Loop through the Bibles list and increase for each selected item
|
||||||
iterator = QtGui.QTreeWidgetItemIterator(self.biblesTreeWidget)
|
iterator = QtGui.QTreeWidgetItemIterator(self.biblesTreeWidget)
|
||||||
while iterator.value():
|
while iterator.value():
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
item = iterator.value()
|
item = iterator.value()
|
||||||
if item.parent() and item.checkState(0) == QtCore.Qt.Checked:
|
if item.parent() and item.checkState(0) == QtCore.Qt.Checked:
|
||||||
filename = item.data(0, QtCore.Qt.UserRole)
|
filename = item.data(0, QtCore.Qt.UserRole)
|
||||||
|
@ -349,7 +346,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
||||||
iterator += 1
|
iterator += 1
|
||||||
# Loop through the themes list and increase for each selected item
|
# Loop through the themes list and increase for each selected item
|
||||||
for i in xrange(self.themesListWidget.count()):
|
for i in xrange(self.themesListWidget.count()):
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
item = self.themesListWidget.item(i)
|
item = self.themesListWidget.item(i)
|
||||||
if item.checkState() == QtCore.Qt.Checked:
|
if item.checkState() == QtCore.Qt.Checked:
|
||||||
filename = item.data(QtCore.Qt.UserRole)
|
filename = item.data(QtCore.Qt.UserRole)
|
||||||
|
@ -369,7 +366,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
||||||
self.progressPage.setTitle(translate('OpenLP.FirstTimeWizard', 'Setting Up'))
|
self.progressPage.setTitle(translate('OpenLP.FirstTimeWizard', 'Setting Up'))
|
||||||
self.progressPage.setSubTitle(u'Setup complete.')
|
self.progressPage.setSubTitle(u'Setup complete.')
|
||||||
self.repaint()
|
self.repaint()
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
# Try to give the wizard a chance to repaint itself
|
# Try to give the wizard a chance to repaint itself
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
@ -396,7 +393,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
||||||
self.finishButton.setEnabled(True)
|
self.finishButton.setEnabled(True)
|
||||||
self.cancelButton.setVisible(False)
|
self.cancelButton.setVisible(False)
|
||||||
self.nextButton.setVisible(False)
|
self.nextButton.setVisible(False)
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
|
|
||||||
def _performWizard(self):
|
def _performWizard(self):
|
||||||
"""
|
"""
|
||||||
|
@ -471,3 +468,13 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
||||||
return self._theme_manager
|
return self._theme_manager
|
||||||
|
|
||||||
theme_manager = property(_get_theme_manager)
|
theme_manager = property(_get_theme_manager)
|
||||||
|
|
||||||
|
def _get_openlp_core(self):
|
||||||
|
"""
|
||||||
|
Adds the openlp to the class dynamically
|
||||||
|
"""
|
||||||
|
if not hasattr(self, u'_openlp_core'):
|
||||||
|
self._openlp_core = Registry().get(u'openlp_core')
|
||||||
|
return self._openlp_core
|
||||||
|
|
||||||
|
openlp_core = property(_get_openlp_core)
|
||||||
|
|
|
@ -229,7 +229,7 @@ class MainDisplay(Display):
|
||||||
log.debug(u'text to display')
|
log.debug(u'text to display')
|
||||||
# Wait for the webview to update before displaying text.
|
# Wait for the webview to update before displaying text.
|
||||||
while not self.webLoaded:
|
while not self.webLoaded:
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
self.setGeometry(self.screen[u'size'])
|
self.setGeometry(self.screen[u'size'])
|
||||||
if animate:
|
if animate:
|
||||||
self.frame.evaluateJavaScript(u'show_text("%s")' % slide.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"'))
|
self.frame.evaluateJavaScript(u'show_text("%s")' % slide.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"'))
|
||||||
|
@ -333,18 +333,18 @@ class MainDisplay(Display):
|
||||||
Generates a preview of the image displayed.
|
Generates a preview of the image displayed.
|
||||||
"""
|
"""
|
||||||
log.debug(u'preview for %s', self.isLive)
|
log.debug(u'preview for %s', self.isLive)
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
# We must have a service item to preview.
|
# We must have a service item to preview.
|
||||||
if self.isLive and hasattr(self, u'serviceItem'):
|
if self.isLive and hasattr(self, u'serviceItem'):
|
||||||
# Wait for the fade to finish before geting the preview.
|
# Wait for the fade to finish before geting the preview.
|
||||||
# Important otherwise preview will have incorrect text if at all!
|
# Important otherwise preview will have incorrect text if at all!
|
||||||
if self.serviceItem.themedata and self.serviceItem.themedata.display_slide_transition:
|
if self.serviceItem.themedata and self.serviceItem.themedata.display_slide_transition:
|
||||||
while self.frame.evaluateJavaScript(u'show_text_complete()') == u'false':
|
while self.frame.evaluateJavaScript(u'show_text_complete()') == u'false':
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
# Wait for the webview to update before getting the preview.
|
# Wait for the webview to update before getting the preview.
|
||||||
# Important otherwise first preview will miss the background !
|
# Important otherwise first preview will miss the background !
|
||||||
while not self.webLoaded:
|
while not self.webLoaded:
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
# if was hidden keep it hidden
|
# if was hidden keep it hidden
|
||||||
if self.isLive:
|
if self.isLive:
|
||||||
if self.hideMode:
|
if self.hideMode:
|
||||||
|
@ -486,6 +486,16 @@ class MainDisplay(Display):
|
||||||
return self._image_manager
|
return self._image_manager
|
||||||
|
|
||||||
image_manager = property(_get_image_manager)
|
image_manager = property(_get_image_manager)
|
||||||
|
|
||||||
|
def _get_openlp_core(self):
|
||||||
|
"""
|
||||||
|
Adds the openlp to the class dynamically
|
||||||
|
"""
|
||||||
|
if not hasattr(self, u'_openlp_core'):
|
||||||
|
self._openlp_core = Registry().get(u'openlp_core')
|
||||||
|
return self._openlp_core
|
||||||
|
|
||||||
|
openlp_core = property(_get_openlp_core)
|
||||||
|
|
||||||
|
|
||||||
class AudioPlayer(QtCore.QObject):
|
class AudioPlayer(QtCore.QObject):
|
||||||
|
|
|
@ -531,7 +531,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'cleanup'), self.clean_up)
|
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'cleanup'), self.clean_up)
|
||||||
# Media Manager
|
# Media Manager
|
||||||
QtCore.QObject.connect(self.mediaToolBox, QtCore.SIGNAL(u'currentChanged(int)'), self.onMediaToolBoxChanged)
|
QtCore.QObject.connect(self.mediaToolBox, QtCore.SIGNAL(u'currentChanged(int)'), self.onMediaToolBoxChanged)
|
||||||
Receiver.send_message(u'cursor_busy')
|
self.openlp_core.set_busy_cursor()
|
||||||
# Simple message boxes
|
# Simple message boxes
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_error_message'), self.onErrorMessage)
|
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_error_message'), self.onErrorMessage)
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_warning_message'), self.onWarningMessage)
|
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_warning_message'), self.onWarningMessage)
|
||||||
|
@ -580,7 +580,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||||
# Hide/show the theme combobox on the service manager
|
# Hide/show the theme combobox on the service manager
|
||||||
self.serviceManagerContents.theme_change()
|
self.serviceManagerContents.theme_change()
|
||||||
# Reset the cursor
|
# Reset the cursor
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_busy_cursor()
|
||||||
|
|
||||||
def setAutoLanguage(self, value):
|
def setAutoLanguage(self, value):
|
||||||
self.languageGroup.setDisabled(value)
|
self.languageGroup.setDisabled(value)
|
||||||
|
@ -635,20 +635,20 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||||
"""
|
"""
|
||||||
Give all the plugins a chance to perform some tasks at startup
|
Give all the plugins a chance to perform some tasks at startup
|
||||||
"""
|
"""
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
for plugin in self.pluginManager.plugins:
|
for plugin in self.pluginManager.plugins:
|
||||||
if plugin.isActive():
|
if plugin.isActive():
|
||||||
plugin.appStartup()
|
plugin.appStartup()
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
|
|
||||||
def firstTime(self):
|
def firstTime(self):
|
||||||
# Import themes if first time
|
# Import themes if first time
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
for plugin in self.pluginManager.plugins:
|
for plugin in self.pluginManager.plugins:
|
||||||
if hasattr(plugin, u'firstTime'):
|
if hasattr(plugin, u'firstTime'):
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
plugin.firstTime()
|
plugin.firstTime()
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
temp_dir = os.path.join(unicode(gettempdir()), u'openlp')
|
temp_dir = os.path.join(unicode(gettempdir()), u'openlp')
|
||||||
shutil.rmtree(temp_dir, True)
|
shutil.rmtree(temp_dir, True)
|
||||||
|
|
||||||
|
@ -669,7 +669,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||||
QtGui.QMessageBox.No)
|
QtGui.QMessageBox.No)
|
||||||
if answer == QtGui.QMessageBox.No:
|
if answer == QtGui.QMessageBox.No:
|
||||||
return
|
return
|
||||||
Receiver.send_message(u'cursor_busy')
|
self.openlp_core.set_busy_cursor()
|
||||||
screens = ScreenList()
|
screens = ScreenList()
|
||||||
firstTime = FirstTimeForm(screens, self)
|
firstTime = FirstTimeForm(screens, self)
|
||||||
firstTime.exec_()
|
firstTime.exec_()
|
||||||
|
@ -979,14 +979,14 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||||
renderer.
|
renderer.
|
||||||
"""
|
"""
|
||||||
log.debug(u'screenChanged')
|
log.debug(u'screenChanged')
|
||||||
Receiver.send_message(u'cursor_busy')
|
self.openlp_core.set_busy_cursor()
|
||||||
self.imageManager.updateDisplay()
|
self.imageManager.updateDisplay()
|
||||||
self.renderer.update_display()
|
self.renderer.update_display()
|
||||||
self.previewController.screenSizeChanged()
|
self.previewController.screenSizeChanged()
|
||||||
self.liveController.screenSizeChanged()
|
self.liveController.screenSizeChanged()
|
||||||
self.setFocus()
|
self.setFocus()
|
||||||
self.activateWindow()
|
self.activateWindow()
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_busy_cursor()
|
||||||
|
|
||||||
def closeEvent(self, event):
|
def closeEvent(self, event):
|
||||||
"""
|
"""
|
||||||
|
@ -1270,14 +1270,14 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||||
self.loadProgressBar.show()
|
self.loadProgressBar.show()
|
||||||
self.loadProgressBar.setMaximum(size)
|
self.loadProgressBar.setMaximum(size)
|
||||||
self.loadProgressBar.setValue(0)
|
self.loadProgressBar.setValue(0)
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
|
|
||||||
def incrementProgressBar(self):
|
def incrementProgressBar(self):
|
||||||
"""
|
"""
|
||||||
Increase the Progress Bar value by 1
|
Increase the Progress Bar value by 1
|
||||||
"""
|
"""
|
||||||
self.loadProgressBar.setValue(self.loadProgressBar.value() + 1)
|
self.loadProgressBar.setValue(self.loadProgressBar.value() + 1)
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
|
|
||||||
def finishedProgressBar(self):
|
def finishedProgressBar(self):
|
||||||
"""
|
"""
|
||||||
|
@ -1292,7 +1292,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||||
if event.timerId() == self.timer_id:
|
if event.timerId() == self.timer_id:
|
||||||
self.timer_id = 0
|
self.timer_id = 0
|
||||||
self.loadProgressBar.hide()
|
self.loadProgressBar.hide()
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
|
|
||||||
def setNewDataPath(self, new_data_path):
|
def setNewDataPath(self, new_data_path):
|
||||||
self.newDataPath = new_data_path
|
self.newDataPath = new_data_path
|
||||||
|
@ -1307,20 +1307,19 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||||
if self.copyData:
|
if self.copyData:
|
||||||
log.info(u'Copying data to new path')
|
log.info(u'Copying data to new path')
|
||||||
try:
|
try:
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.set_busy_cursor()
|
||||||
Receiver.send_message(u'cursor_busy')
|
|
||||||
self.showStatusMessage(
|
self.showStatusMessage(
|
||||||
translate('OpenLP.MainWindow', 'Copying OpenLP data to new data directory location - %s '
|
translate('OpenLP.MainWindow', 'Copying OpenLP data to new data directory location - %s '
|
||||||
'- Please wait for copy to finish').replace('%s', self.newDataPath))
|
'- Please wait for copy to finish').replace('%s', self.newDataPath))
|
||||||
dir_util.copy_tree(old_data_path, self.newDataPath)
|
dir_util.copy_tree(old_data_path, self.newDataPath)
|
||||||
log.info(u'Copy sucessful')
|
log.info(u'Copy sucessful')
|
||||||
except (IOError, os.error, DistutilsFileError), why:
|
except (IOError, os.error, DistutilsFileError), why:
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_normal_cursor()
|
||||||
log.exception(u'Data copy failed %s' % unicode(why))
|
log.exception(u'Data copy failed %s' % unicode(why))
|
||||||
QtGui.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'New Data Directory Error'),
|
QtGui.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'New Data Directory Error'),
|
||||||
translate('OpenLP.MainWindow',
|
translate('OpenLP.MainWindow',
|
||||||
'OpenLP Data directory copy failed\n\n%s').replace('%s', unicode(why)),
|
'OpenLP Data directory copy failed\n\n%s').replace('%s', unicode(why)),
|
||||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
|
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
log.info(u'No data copy requested')
|
log.info(u'No data copy requested')
|
||||||
|
@ -1331,3 +1330,12 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||||
if self.newDataPath == AppLocation.get_directory(AppLocation.DataDir):
|
if self.newDataPath == AppLocation.get_directory(AppLocation.DataDir):
|
||||||
settings.remove(u'advanced/data path')
|
settings.remove(u'advanced/data path')
|
||||||
|
|
||||||
|
def _get_openlp_core(self):
|
||||||
|
"""
|
||||||
|
Adds the openlp to the class dynamically
|
||||||
|
"""
|
||||||
|
if not hasattr(self, u'_openlp_core'):
|
||||||
|
self._openlp_core = Registry().get(u'openlp_core')
|
||||||
|
return self._openlp_core
|
||||||
|
|
||||||
|
openlp_core = property(_get_openlp_core)
|
|
@ -27,6 +27,7 @@
|
||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
from openlp.core.lib import Registry
|
||||||
from openlp.core.ui.media import MediaState
|
from openlp.core.ui.media import MediaState
|
||||||
|
|
||||||
class MediaPlayer(object):
|
class MediaPlayer(object):
|
||||||
|
@ -143,3 +144,13 @@ class MediaPlayer(object):
|
||||||
Returns Information about the player
|
Returns Information about the player
|
||||||
"""
|
"""
|
||||||
return u''
|
return u''
|
||||||
|
|
||||||
|
def _get_openlp_core(self):
|
||||||
|
"""
|
||||||
|
Adds the openlp to the class dynamically
|
||||||
|
"""
|
||||||
|
if not hasattr(self, u'_openlp_core'):
|
||||||
|
self._openlp_core = Registry().get(u'openlp_core')
|
||||||
|
return self._openlp_core
|
||||||
|
|
||||||
|
openlp_core = property(_get_openlp_core)
|
|
@ -34,7 +34,7 @@ from datetime import datetime
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
from PyQt4.phonon import Phonon
|
from PyQt4.phonon import Phonon
|
||||||
|
|
||||||
from openlp.core.lib import Receiver, translate, Settings
|
from openlp.core.lib import translate, Settings
|
||||||
|
|
||||||
from openlp.core.ui.media import MediaState
|
from openlp.core.ui.media import MediaState
|
||||||
from openlp.core.ui.media.mediaplayer import MediaPlayer
|
from openlp.core.ui.media.mediaplayer import MediaPlayer
|
||||||
|
@ -150,7 +150,7 @@ class PhononPlayer(MediaPlayer):
|
||||||
current_state = display.mediaObject.state()
|
current_state = display.mediaObject.state()
|
||||||
if current_state == Phonon.ErrorState:
|
if current_state == Phonon.ErrorState:
|
||||||
return False
|
return False
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
if (datetime.now() - start).seconds > 5:
|
if (datetime.now() - start).seconds > 5:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -35,7 +35,7 @@ import sys
|
||||||
|
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
|
|
||||||
from openlp.core.lib import Receiver, translate, Settings
|
from openlp.core.lib import translate, Settings
|
||||||
from openlp.core.ui.media import MediaState
|
from openlp.core.ui.media import MediaState
|
||||||
from openlp.core.ui.media.mediaplayer import MediaPlayer
|
from openlp.core.ui.media.mediaplayer import MediaPlayer
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ class VlcPlayer(MediaPlayer):
|
||||||
while not mediaState == display.vlcMedia.get_state():
|
while not mediaState == display.vlcMedia.get_state():
|
||||||
if display.vlcMedia.get_state() == vlc.State.Error:
|
if display.vlcMedia.get_state() == vlc.State.Error:
|
||||||
return False
|
return False
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
if (datetime.now() - start).seconds > 60:
|
if (datetime.now() - start).seconds > 60:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -31,7 +31,7 @@ import logging
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import PluginStatus, Receiver, translate
|
from openlp.core.lib import PluginStatus, Registry, translate
|
||||||
from plugindialog import Ui_PluginViewDialog
|
from plugindialog import Ui_PluginViewDialog
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -62,7 +62,7 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
|
||||||
self._clearDetails()
|
self._clearDetails()
|
||||||
self.programaticChange = True
|
self.programaticChange = True
|
||||||
pluginListWidth = 0
|
pluginListWidth = 0
|
||||||
for plugin in self.parent().pluginManager.plugins:
|
for plugin in self.plugin_manager.plugins:
|
||||||
item = QtGui.QListWidgetItem(self.pluginListWidget)
|
item = QtGui.QListWidgetItem(self.pluginListWidget)
|
||||||
# We do this just to make 100% sure the status is an integer as
|
# We do this just to make 100% sure the status is an integer as
|
||||||
# sometimes when it's loaded from the config, it isn't cast to int.
|
# sometimes when it's loaded from the config, it isn't cast to int.
|
||||||
|
@ -106,10 +106,9 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
|
||||||
if self.pluginListWidget.currentItem() is None:
|
if self.pluginListWidget.currentItem() is None:
|
||||||
self._clearDetails()
|
self._clearDetails()
|
||||||
return
|
return
|
||||||
plugin_name_singular = \
|
plugin_name_singular = self.pluginListWidget.currentItem().text().split(u'(')[0][:-1]
|
||||||
self.pluginListWidget.currentItem().text().split(u'(')[0][:-1]
|
|
||||||
self.activePlugin = None
|
self.activePlugin = None
|
||||||
for plugin in self.parent().pluginManager.plugins:
|
for plugin in self.plugin_manager.plugins:
|
||||||
if plugin.status != PluginStatus.Disabled:
|
if plugin.status != PluginStatus.Disabled:
|
||||||
if plugin.nameStrings[u'singular'] == plugin_name_singular:
|
if plugin.nameStrings[u'singular'] == plugin_name_singular:
|
||||||
self.activePlugin = plugin
|
self.activePlugin = plugin
|
||||||
|
@ -123,9 +122,9 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
|
||||||
if self.programaticChange or status == PluginStatus.Disabled:
|
if self.programaticChange or status == PluginStatus.Disabled:
|
||||||
return
|
return
|
||||||
if status == PluginStatus.Inactive:
|
if status == PluginStatus.Inactive:
|
||||||
Receiver.send_message(u'cursor_busy')
|
self.openlp_core.set_busy_cursor()
|
||||||
self.activePlugin.toggleStatus(PluginStatus.Active)
|
self.activePlugin.toggleStatus(PluginStatus.Active)
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_normal_cursor()
|
||||||
self.activePlugin.appStartup()
|
self.activePlugin.appStartup()
|
||||||
else:
|
else:
|
||||||
self.activePlugin.toggleStatus(PluginStatus.Inactive)
|
self.activePlugin.toggleStatus(PluginStatus.Inactive)
|
||||||
|
@ -138,3 +137,23 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
|
||||||
status_text = translate('OpenLP.PluginForm', '%s (Disabled)')
|
status_text = translate('OpenLP.PluginForm', '%s (Disabled)')
|
||||||
self.pluginListWidget.currentItem().setText(
|
self.pluginListWidget.currentItem().setText(
|
||||||
status_text % self.activePlugin.nameStrings[u'singular'])
|
status_text % self.activePlugin.nameStrings[u'singular'])
|
||||||
|
|
||||||
|
def _get_plugin_manager(self):
|
||||||
|
"""
|
||||||
|
Adds the plugin manager to the class dynamically
|
||||||
|
"""
|
||||||
|
if not hasattr(self, u'_plugin_manager'):
|
||||||
|
self._plugin_manager = Registry().get(u'plugin_manager')
|
||||||
|
return self._plugin_manager
|
||||||
|
|
||||||
|
plugin_manager = property(_get_plugin_manager)
|
||||||
|
|
||||||
|
def _get_openlp_core(self):
|
||||||
|
"""
|
||||||
|
Adds the openlp to the class dynamically
|
||||||
|
"""
|
||||||
|
if not hasattr(self, u'_openlp_core'):
|
||||||
|
self._openlp_core = Registry().get(u'openlp_core')
|
||||||
|
return self._openlp_core
|
||||||
|
|
||||||
|
openlp_core = property(_get_openlp_core)
|
||||||
|
|
|
@ -203,18 +203,10 @@ class ServiceManagerDialog(object):
|
||||||
QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL(u'itemExpanded(QTreeWidgetItem*)'),
|
QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL(u'itemExpanded(QTreeWidgetItem*)'),
|
||||||
self.expanded)
|
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'theme_update_list'), self.update_theme_list)
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_preview_live'),
|
|
||||||
self.preview_live)
|
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_next_item'), self.next_item)
|
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_previous_item'),
|
|
||||||
self.previous_item)
|
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_set_item'), self.on_set_item)
|
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.config_updated)
|
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.config_updated)
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'),
|
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'),
|
||||||
self.regenerate_service_Items)
|
self.regenerate_service_Items)
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_global'), self.theme_change)
|
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_global'), self.theme_change)
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'service_item_update'),
|
|
||||||
self.service_item_update)
|
|
||||||
# Last little bits of setting up
|
# Last little bits of setting up
|
||||||
self.service_theme = Settings().value(self.main_window.serviceManagerSettingsSection + u'/service theme')
|
self.service_theme = Settings().value(self.main_window.serviceManagerSettingsSection + u'/service theme')
|
||||||
self.servicePath = AppLocation.get_section_data_path(u'servicemanager')
|
self.servicePath = AppLocation.get_section_data_path(u'servicemanager')
|
||||||
|
@ -448,7 +440,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||||
self.service_id += 1
|
self.service_id += 1
|
||||||
self.set_modified(False)
|
self.set_modified(False)
|
||||||
Settings().setValue(u'servicemanager/last file', u'')
|
Settings().setValue(u'servicemanager/last file', u'')
|
||||||
Receiver.send_message(u'servicemanager_new_service')
|
self.plugin_manager.new_service_created()
|
||||||
|
|
||||||
def save_file(self):
|
def save_file(self):
|
||||||
"""
|
"""
|
||||||
|
@ -476,7 +468,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||||
missing_list = []
|
missing_list = []
|
||||||
audio_files = []
|
audio_files = []
|
||||||
total_size = 0
|
total_size = 0
|
||||||
Receiver.send_message(u'cursor_busy')
|
self.openlp_core.set_busy_cursor()
|
||||||
# Number of items + 1 to zip it
|
# Number of items + 1 to zip it
|
||||||
self.main_window.displayProgressBar(len(self.service_items) + 1)
|
self.main_window.displayProgressBar(len(self.service_items) + 1)
|
||||||
# Get list of missing files, and list of files to write
|
# Get list of missing files, and list of files to write
|
||||||
|
@ -492,7 +484,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||||
else:
|
else:
|
||||||
write_list.append(path_from)
|
write_list.append(path_from)
|
||||||
if missing_list:
|
if missing_list:
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_normal_cursor()
|
||||||
title = translate('OpenLP.ServiceManager', 'Service File(s) Missing')
|
title = translate('OpenLP.ServiceManager', 'Service File(s) Missing')
|
||||||
message = translate('OpenLP.ServiceManager',
|
message = translate('OpenLP.ServiceManager',
|
||||||
'The following file(s) in the service are missing:\n\t%s\n\n'
|
'The following file(s) in the service are missing:\n\t%s\n\n'
|
||||||
|
@ -502,7 +494,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||||
if answer == QtGui.QMessageBox.Cancel:
|
if answer == QtGui.QMessageBox.Cancel:
|
||||||
self.main_window.finishedProgressBar()
|
self.main_window.finishedProgressBar()
|
||||||
return False
|
return False
|
||||||
Receiver.send_message(u'cursor_busy')
|
self.openlp_core.set_busy_cursor()
|
||||||
# Check if item contains a missing file.
|
# Check if item contains a missing file.
|
||||||
for item in list(self.service_items):
|
for item in list(self.service_items):
|
||||||
self.main_window.incrementProgressBar()
|
self.main_window.incrementProgressBar()
|
||||||
|
@ -563,7 +555,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||||
if zip_file:
|
if zip_file:
|
||||||
zip_file.close()
|
zip_file.close()
|
||||||
self.main_window.finishedProgressBar()
|
self.main_window.finishedProgressBar()
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_normal_cursor()
|
||||||
if success:
|
if success:
|
||||||
try:
|
try:
|
||||||
shutil.copy(temp_file_name, path_file_name)
|
shutil.copy(temp_file_name, path_file_name)
|
||||||
|
@ -592,7 +584,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||||
log.debug(u'ServiceManager.save_file - %s', path_file_name)
|
log.debug(u'ServiceManager.save_file - %s', path_file_name)
|
||||||
Settings().setValue(self.main_window.serviceManagerSettingsSection + u'/last directory', path)
|
Settings().setValue(self.main_window.serviceManagerSettingsSection + u'/last directory', path)
|
||||||
service = []
|
service = []
|
||||||
Receiver.send_message(u'cursor_busy')
|
self.openlp_core.set_busy_cursor()
|
||||||
# Number of items + 1 to zip it
|
# Number of items + 1 to zip it
|
||||||
self.main_window.displayProgressBar(len(self.service_items) + 1)
|
self.main_window.displayProgressBar(len(self.service_items) + 1)
|
||||||
for item in self.service_items:
|
for item in self.service_items:
|
||||||
|
@ -621,7 +613,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||||
if zip_file:
|
if zip_file:
|
||||||
zip_file.close()
|
zip_file.close()
|
||||||
self.main_window.finishedProgressBar()
|
self.main_window.finishedProgressBar()
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_normal_cursor()
|
||||||
if success:
|
if success:
|
||||||
try:
|
try:
|
||||||
shutil.copy(temp_file_name, path_file_name)
|
shutil.copy(temp_file_name, path_file_name)
|
||||||
|
@ -718,7 +710,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||||
if osfile.endswith(u'osd'):
|
if osfile.endswith(u'osd'):
|
||||||
p_file = os.path.join(self.servicePath, osfile)
|
p_file = os.path.join(self.servicePath, osfile)
|
||||||
if 'p_file' in locals():
|
if 'p_file' in locals():
|
||||||
Receiver.send_message(u'cursor_busy')
|
self.openlp_core.set_busy_cursor()
|
||||||
file_to = open(p_file, u'r')
|
file_to = open(p_file, u'r')
|
||||||
items = cPickle.load(file_to)
|
items = cPickle.load(file_to)
|
||||||
file_to.close()
|
file_to.close()
|
||||||
|
@ -763,6 +755,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||||
QtGui.QMessageBox.information(self, translate('OpenLP.ServiceManager', 'Corrupt File'),
|
QtGui.QMessageBox.information(self, translate('OpenLP.ServiceManager', 'Corrupt File'),
|
||||||
translate('OpenLP.ServiceManager',
|
translate('OpenLP.ServiceManager',
|
||||||
'This file is either corrupt or it is not an OpenLP 2 service file.'))
|
'This file is either corrupt or it is not an OpenLP 2 service file.'))
|
||||||
|
self.openlp_core.set_normal_cursor()
|
||||||
return
|
return
|
||||||
finally:
|
finally:
|
||||||
if file_to:
|
if file_to:
|
||||||
|
@ -770,7 +763,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||||
if zip_file:
|
if zip_file:
|
||||||
zip_file.close()
|
zip_file.close()
|
||||||
self.main_window.finishedProgressBar()
|
self.main_window.finishedProgressBar()
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_normal_cursor()
|
||||||
self.repaint_service_list(-1, -1)
|
self.repaint_service_list(-1, -1)
|
||||||
|
|
||||||
def load_Last_file(self):
|
def load_Last_file(self):
|
||||||
|
@ -944,12 +937,20 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||||
self.add_service_item(self.serviceItemEditForm.get_service_item(),
|
self.add_service_item(self.serviceItemEditForm.get_service_item(),
|
||||||
replace=True, expand=self.service_items[item][u'expanded'])
|
replace=True, expand=self.service_items[item][u'expanded'])
|
||||||
|
|
||||||
def preview_live(self, message):
|
def preview_live(self, unique_identifier, row):
|
||||||
"""
|
"""
|
||||||
Called by the SlideController to request a preview item be made live
|
Called by the SlideController to request a preview item be made live
|
||||||
and allows the next preview to be updated if relevant.
|
and allows the next preview to be updated if relevant
|
||||||
|
|
||||||
|
|
||||||
|
``unique_identifier``
|
||||||
|
Reference to the service_item
|
||||||
|
|
||||||
|
|
||||||
|
``row``
|
||||||
|
individual row number
|
||||||
|
|
||||||
"""
|
"""
|
||||||
unique_identifier, row = message.split(u':')
|
|
||||||
for sitem in self.service_items:
|
for sitem in self.service_items:
|
||||||
if sitem[u'service_item'].unique_identifier == unique_identifier:
|
if sitem[u'service_item'].unique_identifier == unique_identifier:
|
||||||
item = self.service_manager_list.topLevelItem(sitem[u'order'] - 1)
|
item = self.service_manager_list.topLevelItem(sitem[u'order'] - 1)
|
||||||
|
@ -975,9 +976,13 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||||
lookFor = 1
|
lookFor = 1
|
||||||
serviceIterator += 1
|
serviceIterator += 1
|
||||||
|
|
||||||
def previous_item(self, message):
|
def previous_item(self, last_slide=False):
|
||||||
"""
|
"""
|
||||||
Called by the SlideController to select the previous service item.
|
Called by the SlideController to select the previous service item.
|
||||||
|
|
||||||
|
``last_slide``
|
||||||
|
Is this the last slide in the service_item
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if not self.service_manager_list.selectedItems():
|
if not self.service_manager_list.selectedItems():
|
||||||
return
|
return
|
||||||
|
@ -987,7 +992,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||||
serviceIterator = QtGui.QTreeWidgetItemIterator(self.service_manager_list)
|
serviceIterator = QtGui.QTreeWidgetItemIterator(self.service_manager_list)
|
||||||
while serviceIterator.value():
|
while serviceIterator.value():
|
||||||
if serviceIterator.value() == selected:
|
if serviceIterator.value() == selected:
|
||||||
if message == u'last slide' and prevItemLastSlide:
|
if last_slide and prevItemLastSlide:
|
||||||
pos = prevItem.data(0, QtCore.Qt.UserRole)
|
pos = prevItem.data(0, QtCore.Qt.UserRole)
|
||||||
check_expanded = self.service_items[pos - 1][u'expanded']
|
check_expanded = self.service_items[pos - 1][u'expanded']
|
||||||
self.service_manager_list.setCurrentItem(prevItemLastSlide)
|
self.service_manager_list.setCurrentItem(prevItemLastSlide)
|
||||||
|
@ -1246,7 +1251,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||||
Rebuild the service list as things have changed and a
|
Rebuild the service list as things have changed and a
|
||||||
repaint is the easiest way to do this.
|
repaint is the easiest way to do this.
|
||||||
"""
|
"""
|
||||||
Receiver.send_message(u'cursor_busy')
|
self.openlp_core.set_busy_cursor()
|
||||||
log.debug(u'regenerate_service_Items')
|
log.debug(u'regenerate_service_Items')
|
||||||
# force reset of renderer as theme data has changed
|
# force reset of renderer as theme data has changed
|
||||||
self.service_has_all_original_files = True
|
self.service_has_all_original_files = True
|
||||||
|
@ -1278,14 +1283,14 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||||
self.set_modified()
|
self.set_modified()
|
||||||
# Repaint it once only at the end
|
# Repaint it once only at the end
|
||||||
self.repaint_service_list(-1, -1)
|
self.repaint_service_list(-1, -1)
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_normal_cursor()
|
||||||
|
|
||||||
def service_item_update(self, message):
|
def service_item_update(self, edit_id, unique_identifier, temporary=False):
|
||||||
"""
|
"""
|
||||||
Triggered from plugins to update service items.
|
Triggered from plugins to update service items.
|
||||||
Save the values as they will be used as part of the service load
|
Save the values as they will be used as part of the service load
|
||||||
"""
|
"""
|
||||||
edit_id, self.load_item_unique_identifier, temporary = message.split(u':')
|
self.load_item_unique_identifier = unique_identifier
|
||||||
self.load_item_edit_id = int(edit_id)
|
self.load_item_edit_id = int(edit_id)
|
||||||
self.load_item_temporary = str_to_bool(temporary)
|
self.load_item_temporary = str_to_bool(temporary)
|
||||||
|
|
||||||
|
@ -1353,7 +1358,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||||
"""
|
"""
|
||||||
Send the current item to the Preview slide controller
|
Send the current item to the Preview slide controller
|
||||||
"""
|
"""
|
||||||
Receiver.send_message(u'cursor_busy')
|
self.openlp_core.set_busy_cursor()
|
||||||
item, child = self.find_service_item()
|
item, child = self.find_service_item()
|
||||||
if self.service_items[item][u'service_item'].is_valid:
|
if self.service_items[item][u'service_item'].is_valid:
|
||||||
self.preview_controller.addServiceManagerItem(self.service_items[item][u'service_item'], child)
|
self.preview_controller.addServiceManagerItem(self.service_items[item][u'service_item'], child)
|
||||||
|
@ -1361,7 +1366,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||||
critical_error_message_box(translate('OpenLP.ServiceManager', 'Missing Display Handler'),
|
critical_error_message_box(translate('OpenLP.ServiceManager', 'Missing Display Handler'),
|
||||||
translate('OpenLP.ServiceManager',
|
translate('OpenLP.ServiceManager',
|
||||||
'Your item cannot be displayed as there is no handler to display it'))
|
'Your item cannot be displayed as there is no handler to display it'))
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_normal_cursor()
|
||||||
|
|
||||||
def get_service_item(self):
|
def get_service_item(self):
|
||||||
"""
|
"""
|
||||||
|
@ -1394,7 +1399,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||||
return
|
return
|
||||||
if row != -1:
|
if row != -1:
|
||||||
child = row
|
child = row
|
||||||
Receiver.send_message(u'cursor_busy')
|
self.openlp_core.set_busy_cursor()
|
||||||
if self.service_items[item][u'service_item'].is_valid:
|
if self.service_items[item][u'service_item'].is_valid:
|
||||||
self.live_controller.addServiceManagerItem(self.service_items[item][u'service_item'], child)
|
self.live_controller.addServiceManagerItem(self.service_items[item][u'service_item'], child)
|
||||||
if Settings().value(self.main_window.generalSettingsSection + u'/auto preview'):
|
if Settings().value(self.main_window.generalSettingsSection + u'/auto preview'):
|
||||||
|
@ -1409,7 +1414,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||||
critical_error_message_box(translate('OpenLP.ServiceManager', 'Missing Display Handler'),
|
critical_error_message_box(translate('OpenLP.ServiceManager', 'Missing Display Handler'),
|
||||||
translate('OpenLP.ServiceManager',
|
translate('OpenLP.ServiceManager',
|
||||||
'Your item cannot be displayed as the plugin required to display it is missing or inactive'))
|
'Your item cannot be displayed as the plugin required to display it is missing or inactive'))
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_normal_cursor()
|
||||||
|
|
||||||
def remote_edit(self):
|
def remote_edit(self):
|
||||||
"""
|
"""
|
||||||
|
@ -1621,4 +1626,14 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||||
self._main_window = Registry().get(u'main_window')
|
self._main_window = Registry().get(u'main_window')
|
||||||
return self._main_window
|
return self._main_window
|
||||||
|
|
||||||
main_window = property(_get_main_window)
|
main_window = property(_get_main_window)
|
||||||
|
|
||||||
|
def _get_openlp_core(self):
|
||||||
|
"""
|
||||||
|
Adds the openlp to the class dynamically
|
||||||
|
"""
|
||||||
|
if not hasattr(self, u'_openlp_core'):
|
||||||
|
self._openlp_core = Registry().get(u'openlp_core')
|
||||||
|
return self._openlp_core
|
||||||
|
|
||||||
|
openlp_core = property(_get_openlp_core)
|
||||||
|
|
|
@ -510,12 +510,12 @@ class SlideController(DisplayController):
|
||||||
self.keypress_loop = True
|
self.keypress_loop = True
|
||||||
keypressCommand = self.keypress_queue.popleft()
|
keypressCommand = self.keypress_queue.popleft()
|
||||||
if keypressCommand == ServiceItemAction.Previous:
|
if keypressCommand == ServiceItemAction.Previous:
|
||||||
Receiver.send_message('servicemanager_previous_item')
|
self.service_manager.previous_item()
|
||||||
elif keypressCommand == ServiceItemAction.PreviousLastSlide:
|
elif keypressCommand == ServiceItemAction.PreviousLastSlide:
|
||||||
# Go to the last slide of the previous item
|
# Go to the last slide of the previous item
|
||||||
Receiver.send_message('servicemanager_previous_item', u'last slide')
|
self.service_manager.previous_item(last_slide=True)
|
||||||
else:
|
else:
|
||||||
Receiver.send_message('servicemanager_next_item')
|
self.service_manager.next_item()
|
||||||
self.keypress_loop = False
|
self.keypress_loop = False
|
||||||
|
|
||||||
def screenSizeChanged(self):
|
def screenSizeChanged(self):
|
||||||
|
@ -1248,8 +1248,7 @@ class SlideController(DisplayController):
|
||||||
row = self.previewListWidget.currentRow()
|
row = self.previewListWidget.currentRow()
|
||||||
if -1 < row < self.previewListWidget.rowCount():
|
if -1 < row < self.previewListWidget.rowCount():
|
||||||
if self.serviceItem.from_service:
|
if self.serviceItem.from_service:
|
||||||
Receiver.send_message('servicemanager_preview_live', u'%s:%s' %
|
self.service_manager.preview_live(self.serviceItem.unique_identifier, row)
|
||||||
(self.serviceItem.unique_identifier, row))
|
|
||||||
else:
|
else:
|
||||||
self.live_controller.addServiceManagerItem(self.serviceItem, row)
|
self.live_controller.addServiceManagerItem(self.serviceItem, row)
|
||||||
|
|
||||||
|
|
|
@ -147,13 +147,13 @@ class ThemeManager(QtGui.QWidget):
|
||||||
"""
|
"""
|
||||||
Import new themes downloaded by the first time wizard
|
Import new themes downloaded by the first time wizard
|
||||||
"""
|
"""
|
||||||
Receiver.send_message(u'cursor_busy')
|
self.openlp_core.set_busy_cursor()
|
||||||
files = SettingsManager.get_files(self.settingsSection, u'.otz')
|
files = SettingsManager.get_files(self.settingsSection, u'.otz')
|
||||||
for file_name in files:
|
for file_name in files:
|
||||||
file_name = os.path.join(self.path, file_name)
|
file_name = os.path.join(self.path, file_name)
|
||||||
self.unzip_theme(file_name, self.path)
|
self.unzip_theme(file_name, self.path)
|
||||||
delete_file(file)
|
delete_file(file)
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_normal_cursor()
|
||||||
|
|
||||||
def config_updated(self):
|
def config_updated(self):
|
||||||
"""
|
"""
|
||||||
|
@ -361,7 +361,7 @@ class ThemeManager(QtGui.QWidget):
|
||||||
path = QtGui.QFileDialog.getExistingDirectory(self,
|
path = QtGui.QFileDialog.getExistingDirectory(self,
|
||||||
translate('OpenLP.ThemeManager', 'Save Theme - (%s)') % theme,
|
translate('OpenLP.ThemeManager', 'Save Theme - (%s)') % theme,
|
||||||
Settings().value(self.settingsSection + u'/last directory export'))
|
Settings().value(self.settingsSection + u'/last directory export'))
|
||||||
Receiver.send_message(u'cursor_busy')
|
self.openlp_core.set_busy_cursor()
|
||||||
if path:
|
if path:
|
||||||
Settings().setValue(self.settingsSection + u'/last directory export', path)
|
Settings().setValue(self.settingsSection + u'/last directory export', path)
|
||||||
theme_path = os.path.join(path, theme + u'.otz')
|
theme_path = os.path.join(path, theme + u'.otz')
|
||||||
|
@ -383,7 +383,7 @@ class ThemeManager(QtGui.QWidget):
|
||||||
finally:
|
finally:
|
||||||
if zip_file:
|
if zip_file:
|
||||||
zip_file.close()
|
zip_file.close()
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_normal_cursor()
|
||||||
|
|
||||||
def on_import_theme(self):
|
def on_import_theme(self):
|
||||||
"""
|
"""
|
||||||
|
@ -398,12 +398,12 @@ class ThemeManager(QtGui.QWidget):
|
||||||
log.info(u'New Themes %s', unicode(files))
|
log.info(u'New Themes %s', unicode(files))
|
||||||
if not files:
|
if not files:
|
||||||
return
|
return
|
||||||
Receiver.send_message(u'cursor_busy')
|
self.openlp_core.set_busy_cursor()
|
||||||
for file_name in files:
|
for file_name in files:
|
||||||
Settings().setValue(self.settingsSection + u'/last directory import', unicode(file_name))
|
Settings().setValue(self.settingsSection + u'/last directory import', unicode(file_name))
|
||||||
self.unzip_theme(file_name, self.path)
|
self.unzip_theme(file_name, self.path)
|
||||||
self.load_themes()
|
self.load_themes()
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_normal_cursor()
|
||||||
|
|
||||||
def load_themes(self, first_time=False):
|
def load_themes(self, first_time=False):
|
||||||
"""
|
"""
|
||||||
|
@ -841,3 +841,13 @@ class ThemeManager(QtGui.QWidget):
|
||||||
return self._main_window
|
return self._main_window
|
||||||
|
|
||||||
main_window = property(_get_main_window)
|
main_window = property(_get_main_window)
|
||||||
|
|
||||||
|
def _get_openlp_core(self):
|
||||||
|
"""
|
||||||
|
Adds the openlp to the class dynamically
|
||||||
|
"""
|
||||||
|
if not hasattr(self, u'_openlp_core'):
|
||||||
|
self._openlp_core = Registry().get(u'openlp_core')
|
||||||
|
return self._openlp_core
|
||||||
|
|
||||||
|
openlp_core = property(_get_openlp_core)
|
|
@ -34,7 +34,7 @@ import os
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import build_icon, Receiver, Settings, translate, UiStrings
|
from openlp.core.lib import build_icon, Receiver, Registry, Settings, translate, UiStrings
|
||||||
from openlp.core.lib.ui import add_welcome_page
|
from openlp.core.lib.ui import add_welcome_page
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -215,7 +215,7 @@ class OpenLPWizard(QtGui.QWizard):
|
||||||
self.progressLabel.setText(status_text)
|
self.progressLabel.setText(status_text)
|
||||||
if increment > 0:
|
if increment > 0:
|
||||||
self.progressBar.setValue(self.progressBar.value() + increment)
|
self.progressBar.setValue(self.progressBar.value() + increment)
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
|
|
||||||
def preWizard(self):
|
def preWizard(self):
|
||||||
"""
|
"""
|
||||||
|
@ -233,7 +233,7 @@ class OpenLPWizard(QtGui.QWizard):
|
||||||
self.progressBar.setValue(self.progressBar.maximum())
|
self.progressBar.setValue(self.progressBar.maximum())
|
||||||
self.finishButton.setVisible(True)
|
self.finishButton.setVisible(True)
|
||||||
self.cancelButton.setVisible(False)
|
self.cancelButton.setVisible(False)
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
|
|
||||||
def getFileName(self, title, editbox, setting_name, filters=u''):
|
def getFileName(self, title, editbox, setting_name, filters=u''):
|
||||||
"""
|
"""
|
||||||
|
@ -282,3 +282,13 @@ class OpenLPWizard(QtGui.QWizard):
|
||||||
if folder:
|
if folder:
|
||||||
editbox.setText(folder)
|
editbox.setText(folder)
|
||||||
Settings().setValue(self.plugin.settingsSection + u'/' + setting_name, folder)
|
Settings().setValue(self.plugin.settingsSection + u'/' + setting_name, folder)
|
||||||
|
|
||||||
|
def _get_openlp_core(self):
|
||||||
|
"""
|
||||||
|
Adds the openlp to the class dynamically
|
||||||
|
"""
|
||||||
|
if not hasattr(self, u'_openlp_core'):
|
||||||
|
self._openlp_core = Registry().get(u'openlp_core')
|
||||||
|
return self._openlp_core
|
||||||
|
|
||||||
|
openlp_core = property(_get_openlp_core)
|
|
@ -39,7 +39,7 @@ from subprocess import Popen, PIPE
|
||||||
import sys
|
import sys
|
||||||
import urllib2
|
import urllib2
|
||||||
|
|
||||||
from openlp.core.lib import Settings
|
from openlp.core.lib import Registry, Settings
|
||||||
|
|
||||||
from PyQt4 import QtGui, QtCore
|
from PyQt4 import QtGui, QtCore
|
||||||
|
|
||||||
|
@ -425,7 +425,7 @@ def get_web_page(url, header=None, update_openlp=False):
|
||||||
if not page:
|
if not page:
|
||||||
return None
|
return None
|
||||||
if update_openlp:
|
if update_openlp:
|
||||||
Receiver.send_message(u'openlp_process_events')
|
Registry().get(u'openlp_core').process_events()
|
||||||
log.debug(page)
|
log.debug(page)
|
||||||
return page
|
return page
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ import os
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import Receiver, translate, Settings, UiStrings
|
from openlp.core.lib import translate, Settings, UiStrings
|
||||||
from openlp.core.lib.db import delete_database
|
from openlp.core.lib.db import delete_database
|
||||||
from openlp.core.lib.ui import critical_error_message_box
|
from openlp.core.lib.ui import critical_error_message_box
|
||||||
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
|
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
|
||||||
|
@ -578,7 +578,7 @@ class BibleImportForm(OpenLPWizard):
|
||||||
self.progressLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Registering Bible...'))
|
self.progressLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Registering Bible...'))
|
||||||
else:
|
else:
|
||||||
self.progressLabel.setText(WizardStrings.StartingImport)
|
self.progressLabel.setText(WizardStrings.StartingImport)
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
|
|
||||||
def performWizard(self):
|
def performWizard(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -335,7 +335,7 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||||
"""
|
"""
|
||||||
OpenLPWizard.preWizard(self)
|
OpenLPWizard.preWizard(self)
|
||||||
self.progressLabel.setText(translate('BiblesPlugin.UpgradeWizardForm', 'Starting upgrade...'))
|
self.progressLabel.setText(translate('BiblesPlugin.UpgradeWizardForm', 'Starting upgrade...'))
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
|
|
||||||
def performWizard(self):
|
def performWizard(self):
|
||||||
"""
|
"""
|
||||||
|
@ -465,7 +465,7 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||||
self.newbibles[number].create_verse(db_book.id,
|
self.newbibles[number].create_verse(db_book.id,
|
||||||
int(verse[u'chapter']),
|
int(verse[u'chapter']),
|
||||||
int(verse[u'verse']), unicode(verse[u'text']))
|
int(verse[u'verse']), unicode(verse[u'text']))
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
self.newbibles[number].session.commit()
|
self.newbibles[number].session.commit()
|
||||||
else:
|
else:
|
||||||
language_id = self.newbibles[number].get_object(BibleMeta, u'language_id')
|
language_id = self.newbibles[number].get_object(BibleMeta, u'language_id')
|
||||||
|
@ -511,7 +511,7 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||||
self.newbibles[number].create_verse(db_book.id,
|
self.newbibles[number].create_verse(db_book.id,
|
||||||
int(verse[u'chapter']),
|
int(verse[u'chapter']),
|
||||||
int(verse[u'verse']), unicode(verse[u'text']))
|
int(verse[u'verse']), unicode(verse[u'text']))
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
self.newbibles[number].session.commit()
|
self.newbibles[number].session.commit()
|
||||||
if not self.success.get(number, True):
|
if not self.success.get(number, True):
|
||||||
self.incrementProgressBar(translate('BiblesPlugin.UpgradeWizardForm',
|
self.incrementProgressBar(translate('BiblesPlugin.UpgradeWizardForm',
|
||||||
|
|
|
@ -32,7 +32,7 @@ import re
|
||||||
|
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
|
|
||||||
from openlp.core.lib import Receiver, translate, UiStrings
|
from openlp.core.lib import Registry, translate, UiStrings
|
||||||
from openlp.core.lib.ui import critical_error_message_box
|
from openlp.core.lib.ui import critical_error_message_box
|
||||||
from editbibledialog import Ui_EditBibleDialog
|
from editbibledialog import Ui_EditBibleDialog
|
||||||
from openlp.plugins.bibles.lib import BibleStrings
|
from openlp.plugins.bibles.lib import BibleStrings
|
||||||
|
@ -122,8 +122,7 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
|
||||||
if book.name != custom_names[abbr]:
|
if book.name != custom_names[abbr]:
|
||||||
if not self.validateBook(custom_names[abbr], abbr):
|
if not self.validateBook(custom_names[abbr], abbr):
|
||||||
return
|
return
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.set_busy_cursor()
|
||||||
Receiver.send_message(u'cursor_busy')
|
|
||||||
self.manager.save_meta_data(self.bible, version, copyright, permissions, book_name_language)
|
self.manager.save_meta_data(self.bible, version, copyright, permissions, book_name_language)
|
||||||
if not self.webbible:
|
if not self.webbible:
|
||||||
for abbr, book in self.books.iteritems():
|
for abbr, book in self.books.iteritems():
|
||||||
|
@ -132,7 +131,7 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
|
||||||
book.name = custom_names[abbr]
|
book.name = custom_names[abbr]
|
||||||
self.manager.update_book(self.bible, book)
|
self.manager.update_book(self.bible, book)
|
||||||
self.bible = None
|
self.bible = None
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_normal_cursor()
|
||||||
QtGui.QDialog.accept(self)
|
QtGui.QDialog.accept(self)
|
||||||
|
|
||||||
def validateMeta(self, name, copyright):
|
def validateMeta(self, name, copyright):
|
||||||
|
@ -189,3 +188,13 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
|
||||||
% new_book_name)
|
% new_book_name)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def _get_openlp_core(self):
|
||||||
|
"""
|
||||||
|
Adds the openlp to the class dynamically
|
||||||
|
"""
|
||||||
|
if not hasattr(self, u'_openlp_core'):
|
||||||
|
self._openlp_core = Registry().get(u'openlp_core')
|
||||||
|
return self._openlp_core
|
||||||
|
|
||||||
|
openlp_core = property(_get_openlp_core)
|
||||||
|
|
|
@ -118,7 +118,7 @@ class CSVBible(BibleDB):
|
||||||
book_details = BiblesResourcesDB.get_book_by_id(book_ref_id)
|
book_details = BiblesResourcesDB.get_book_by_id(book_ref_id)
|
||||||
self.create_book(unicode(line[2], details['encoding']), book_ref_id, book_details[u'testament_id'])
|
self.create_book(unicode(line[2], details['encoding']), book_ref_id, book_details[u'testament_id'])
|
||||||
book_list[int(line[0])] = unicode(line[2], details['encoding'])
|
book_list[int(line[0])] = unicode(line[2], details['encoding'])
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
except (IOError, IndexError):
|
except (IOError, IndexError):
|
||||||
log.exception(u'Loading books from file failed')
|
log.exception(u'Loading books from file failed')
|
||||||
success = False
|
success = False
|
||||||
|
@ -157,7 +157,7 @@ class CSVBible(BibleDB):
|
||||||
verse_text = unicode(line[3], u'cp1252')
|
verse_text = unicode(line[3], u'cp1252')
|
||||||
self.create_verse(book.id, line[1], line[2], verse_text)
|
self.create_verse(book.id, line[1], line[2], verse_text)
|
||||||
self.wizard.incrementProgressBar(translate('BiblesPlugin.CSVBible', 'Importing verses... done.'))
|
self.wizard.incrementProgressBar(translate('BiblesPlugin.CSVBible', 'Importing verses... done.'))
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
self.session.commit()
|
self.session.commit()
|
||||||
except IOError:
|
except IOError:
|
||||||
log.exception(u'Loading verses from file failed')
|
log.exception(u'Loading verses from file failed')
|
||||||
|
|
|
@ -38,7 +38,7 @@ from sqlalchemy import Column, ForeignKey, or_, Table, types, func
|
||||||
from sqlalchemy.orm import class_mapper, mapper, relation
|
from sqlalchemy.orm import class_mapper, mapper, relation
|
||||||
from sqlalchemy.orm.exc import UnmappedClassError
|
from sqlalchemy.orm.exc import UnmappedClassError
|
||||||
|
|
||||||
from openlp.core.lib import Receiver, translate
|
from openlp.core.lib import Receiver, Registry, translate
|
||||||
from openlp.core.lib.db import BaseModel, init_db, Manager
|
from openlp.core.lib.db import BaseModel, init_db, Manager
|
||||||
from openlp.core.lib.ui import critical_error_message_box
|
from openlp.core.lib.ui import critical_error_message_box
|
||||||
from openlp.core.utils import AppLocation, clean_filename
|
from openlp.core.utils import AppLocation, clean_filename
|
||||||
|
@ -549,6 +549,16 @@ class BibleDB(QtCore.QObject, Manager):
|
||||||
verses = self.session.query(Verse).all()
|
verses = self.session.query(Verse).all()
|
||||||
log.debug(verses)
|
log.debug(verses)
|
||||||
|
|
||||||
|
def _get_openlp_core(self):
|
||||||
|
"""
|
||||||
|
Adds the openlp to the class dynamically
|
||||||
|
"""
|
||||||
|
if not hasattr(self, u'_openlp_core'):
|
||||||
|
self._openlp_core = Registry().get(u'openlp_core')
|
||||||
|
return self._openlp_core
|
||||||
|
|
||||||
|
openlp_core = property(_get_openlp_core)
|
||||||
|
|
||||||
|
|
||||||
class BiblesResourcesDB(QtCore.QObject, Manager):
|
class BiblesResourcesDB(QtCore.QObject, Manager):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -38,7 +38,7 @@ from HTMLParser import HTMLParseError
|
||||||
|
|
||||||
from BeautifulSoup import BeautifulSoup, NavigableString, Tag
|
from BeautifulSoup import BeautifulSoup, NavigableString, Tag
|
||||||
|
|
||||||
from openlp.core.lib import Receiver, translate
|
from openlp.core.lib import Receiver, Registry,translate
|
||||||
from openlp.core.lib.ui import critical_error_message_box
|
from openlp.core.lib.ui import critical_error_message_box
|
||||||
from openlp.core.utils import get_web_page
|
from openlp.core.utils import get_web_page
|
||||||
from openlp.plugins.bibles.lib import SearchResults
|
from openlp.plugins.bibles.lib import SearchResults
|
||||||
|
@ -164,7 +164,7 @@ class BGExtract(object):
|
||||||
if len(verse_parts) > 1:
|
if len(verse_parts) > 1:
|
||||||
verse = int(verse_parts[0])
|
verse = int(verse_parts[0])
|
||||||
except TypeError:
|
except TypeError:
|
||||||
log.warn(u'Illegal verse number: %s', unicode(raw_verse_num))
|
log.warn(u'Illegal verse number: %s', unicode(verse))
|
||||||
verses.append((verse, text))
|
verses.append((verse, text))
|
||||||
verse_list = {}
|
verse_list = {}
|
||||||
for verse, text in verses[::-1]:
|
for verse, text in verses[::-1]:
|
||||||
|
@ -235,9 +235,10 @@ class BGExtract(object):
|
||||||
soup = get_soup_for_bible_ref(
|
soup = get_soup_for_bible_ref(
|
||||||
u'http://www.biblegateway.com/passage/?%s' % url_params,
|
u'http://www.biblegateway.com/passage/?%s' % url_params,
|
||||||
pre_parse_regex=r'<meta name.*?/>', pre_parse_substitute='', cleaner=cleaner)
|
pre_parse_regex=r'<meta name.*?/>', pre_parse_substitute='', cleaner=cleaner)
|
||||||
|
self.openlp_core.process_events()
|
||||||
if not soup:
|
if not soup:
|
||||||
return None
|
return None
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
div = soup.find('div', 'result-text-style-normal')
|
div = soup.find('div', 'result-text-style-normal')
|
||||||
self._clean_soup(div)
|
self._clean_soup(div)
|
||||||
span_list = div.findAll('span', 'text')
|
span_list = div.findAll('span', 'text')
|
||||||
|
@ -281,7 +282,7 @@ class BGExtract(object):
|
||||||
if not soup:
|
if not soup:
|
||||||
send_error_message(u'parse')
|
send_error_message(u'parse')
|
||||||
return None
|
return None
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
content = soup.find(u'table', u'infotable')
|
content = soup.find(u'table', u'infotable')
|
||||||
if content:
|
if content:
|
||||||
content = content.findAll(u'tr')
|
content = content.findAll(u'tr')
|
||||||
|
@ -329,7 +330,7 @@ class BSExtract(object):
|
||||||
soup = get_soup_for_bible_ref(chapter_url, header)
|
soup = get_soup_for_bible_ref(chapter_url, header)
|
||||||
if not soup:
|
if not soup:
|
||||||
return None
|
return None
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
content = soup.find(u'div', u'content')
|
content = soup.find(u'div', u'content')
|
||||||
if not content:
|
if not content:
|
||||||
log.error(u'No verses found in the Bibleserver response.')
|
log.error(u'No verses found in the Bibleserver response.')
|
||||||
|
@ -339,7 +340,7 @@ class BSExtract(object):
|
||||||
verse_number = re.compile(r'v(\d{1,2})(\d{3})(\d{3}) verse.*')
|
verse_number = re.compile(r'v(\d{1,2})(\d{3})(\d{3}) verse.*')
|
||||||
verses = {}
|
verses = {}
|
||||||
for verse in content:
|
for verse in content:
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
versenumber = int(verse_number.sub(r'\3', verse[u'class']))
|
versenumber = int(verse_number.sub(r'\3', verse[u'class']))
|
||||||
verses[versenumber] = verse.contents[1].rstrip(u'\n')
|
verses[versenumber] = verse.contents[1].rstrip(u'\n')
|
||||||
return SearchResults(book_name, chapter, verses)
|
return SearchResults(book_name, chapter, verses)
|
||||||
|
@ -402,7 +403,7 @@ class CWExtract(object):
|
||||||
soup = get_soup_for_bible_ref(chapter_url)
|
soup = get_soup_for_bible_ref(chapter_url)
|
||||||
if not soup:
|
if not soup:
|
||||||
return None
|
return None
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
html_verses = soup.findAll(u'span', u'versetext')
|
html_verses = soup.findAll(u'span', u'versetext')
|
||||||
if not html_verses:
|
if not html_verses:
|
||||||
log.error(u'No verses found in the CrossWalk response.')
|
log.error(u'No verses found in the CrossWalk response.')
|
||||||
|
@ -412,27 +413,25 @@ class CWExtract(object):
|
||||||
reduce_spaces = re.compile(r'[ ]{2,}')
|
reduce_spaces = re.compile(r'[ ]{2,}')
|
||||||
fix_punctuation = re.compile(r'[ ]+([.,;])')
|
fix_punctuation = re.compile(r'[ ]+([.,;])')
|
||||||
for verse in html_verses:
|
for verse in html_verses:
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
verse_number = int(verse.contents[0].contents[0])
|
verse_number = int(verse.contents[0].contents[0])
|
||||||
verse_text = u''
|
verse_text = u''
|
||||||
for part in verse.contents:
|
for part in verse.contents:
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
if isinstance(part, NavigableString):
|
if isinstance(part, NavigableString):
|
||||||
verse_text = verse_text + part
|
verse_text = verse_text + part
|
||||||
elif part and part.attrMap and \
|
elif part and part.attrMap and \
|
||||||
(part.attrMap[u'class'] == u'WordsOfChrist' or \
|
(part.attrMap[u'class'] == u'WordsOfChrist' or part.attrMap[u'class'] == u'strongs'):
|
||||||
part.attrMap[u'class'] == u'strongs'):
|
|
||||||
for subpart in part.contents:
|
for subpart in part.contents:
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
if isinstance(subpart, NavigableString):
|
if isinstance(subpart, NavigableString):
|
||||||
verse_text = verse_text + subpart
|
verse_text = verse_text + subpart
|
||||||
elif subpart and subpart.attrMap and \
|
elif subpart and subpart.attrMap and subpart.attrMap[u'class'] == u'strongs':
|
||||||
subpart.attrMap[u'class'] == u'strongs':
|
|
||||||
for subsub in subpart.contents:
|
for subsub in subpart.contents:
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
if isinstance(subsub, NavigableString):
|
if isinstance(subsub, NavigableString):
|
||||||
verse_text = verse_text + subsub
|
verse_text = verse_text + subsub
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
# Fix up leading and trailing spaces, multiple spaces, and spaces
|
# Fix up leading and trailing spaces, multiple spaces, and spaces
|
||||||
# between text and , and .
|
# between text and , and .
|
||||||
verse_text = verse_text.strip(u'\n\r\t ')
|
verse_text = verse_text.strip(u'\n\r\t ')
|
||||||
|
@ -598,7 +597,7 @@ class HTTPBible(BibleDB):
|
||||||
return []
|
return []
|
||||||
book = db_book.name
|
book = db_book.name
|
||||||
if BibleDB.get_verse_count(self, book_id, reference[1]) == 0:
|
if BibleDB.get_verse_count(self, book_id, reference[1]) == 0:
|
||||||
Receiver.send_message(u'cursor_busy')
|
self.openlp_core.set_busy_cursor()
|
||||||
search_results = self.get_chapter(book, reference[1])
|
search_results = self.get_chapter(book, reference[1])
|
||||||
if search_results and search_results.has_verselist():
|
if search_results and search_results.has_verselist():
|
||||||
## We have found a book of the bible lets check to see
|
## We have found a book of the bible lets check to see
|
||||||
|
@ -606,14 +605,14 @@ class HTTPBible(BibleDB):
|
||||||
## we get a correct book. For example it is possible
|
## we get a correct book. For example it is possible
|
||||||
## to request ac and get Acts back.
|
## to request ac and get Acts back.
|
||||||
book_name = search_results.book
|
book_name = search_results.book
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
# Check to see if book/chapter exists.
|
# Check to see if book/chapter exists.
|
||||||
db_book = self.get_book(book_name)
|
db_book = self.get_book(book_name)
|
||||||
self.create_chapter(db_book.id, search_results.chapter,
|
self.create_chapter(db_book.id, search_results.chapter,
|
||||||
search_results.verselist)
|
search_results.verselist)
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_normal_cursor()
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
return BibleDB.get_verses(self, reference_list, show_error)
|
return BibleDB.get_verses(self, reference_list, show_error)
|
||||||
|
|
||||||
def get_chapter(self, book, chapter):
|
def get_chapter(self, book, chapter):
|
||||||
|
@ -660,6 +659,16 @@ class HTTPBible(BibleDB):
|
||||||
log.debug(u'HTTPBible.get_verse_count("%s", %s)', book_id, chapter)
|
log.debug(u'HTTPBible.get_verse_count("%s", %s)', book_id, chapter)
|
||||||
return BiblesResourcesDB.get_verse_count(book_id, chapter)
|
return BiblesResourcesDB.get_verse_count(book_id, chapter)
|
||||||
|
|
||||||
|
def _get_openlp_core(self):
|
||||||
|
"""
|
||||||
|
Adds the openlp to the class dynamically
|
||||||
|
"""
|
||||||
|
if not hasattr(self, u'_openlp_core'):
|
||||||
|
self._openlp_core = Registry().get(u'openlp_core')
|
||||||
|
return self._openlp_core
|
||||||
|
|
||||||
|
openlp_core = property(_get_openlp_core)
|
||||||
|
|
||||||
def get_soup_for_bible_ref(reference_url, header=None, pre_parse_regex=None,
|
def get_soup_for_bible_ref(reference_url, header=None, pre_parse_regex=None,
|
||||||
pre_parse_substitute=None, cleaner=None):
|
pre_parse_substitute=None, cleaner=None):
|
||||||
"""
|
"""
|
||||||
|
@ -698,10 +707,10 @@ def get_soup_for_bible_ref(reference_url, header=None, pre_parse_regex=None,
|
||||||
soup = BeautifulSoup(page_source)
|
soup = BeautifulSoup(page_source)
|
||||||
except HTMLParseError:
|
except HTMLParseError:
|
||||||
log.exception(u'BeautifulSoup could not parse the bible page.')
|
log.exception(u'BeautifulSoup could not parse the bible page.')
|
||||||
|
Registry().get(u'openlp_core').process_events()
|
||||||
if not soup:
|
if not soup:
|
||||||
send_error_message(u'parse')
|
send_error_message(u'parse')
|
||||||
return None
|
return None
|
||||||
Receiver.send_message(u'openlp_process_events')
|
|
||||||
return soup
|
return soup
|
||||||
|
|
||||||
def send_error_message(error_type):
|
def send_error_message(error_type):
|
||||||
|
|
|
@ -614,7 +614,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||||
"""
|
"""
|
||||||
log.debug(u'Advanced Search Button clicked')
|
log.debug(u'Advanced Search Button clicked')
|
||||||
self.advancedSearchButton.setEnabled(False)
|
self.advancedSearchButton.setEnabled(False)
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
bible = self.advancedVersionComboBox.currentText()
|
bible = self.advancedVersionComboBox.currentText()
|
||||||
second_bible = self.advancedSecondComboBox.currentText()
|
second_bible = self.advancedSecondComboBox.currentText()
|
||||||
book = self.advancedBookComboBox.currentText()
|
book = self.advancedBookComboBox.currentText()
|
||||||
|
@ -628,7 +628,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||||
verse_range = chapter_from + verse_separator + verse_from + range_separator + chapter_to + \
|
verse_range = chapter_from + verse_separator + verse_from + range_separator + chapter_to + \
|
||||||
verse_separator + verse_to
|
verse_separator + verse_to
|
||||||
versetext = u'%s %s' % (book, verse_range)
|
versetext = u'%s %s' % (book, verse_range)
|
||||||
Receiver.send_message(u'cursor_busy')
|
self.openlp_core.set_busy_cursor()
|
||||||
self.search_results = self.plugin.manager.get_verses(bible, versetext, book_ref_id)
|
self.search_results = self.plugin.manager.get_verses(bible, versetext, book_ref_id)
|
||||||
if second_bible:
|
if second_bible:
|
||||||
self.second_search_results = self.plugin.manager.get_verses(second_bible, versetext, book_ref_id)
|
self.second_search_results = self.plugin.manager.get_verses(second_bible, versetext, book_ref_id)
|
||||||
|
@ -640,8 +640,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||||
self.displayResults(bible, second_bible)
|
self.displayResults(bible, second_bible)
|
||||||
self.advancedSearchButton.setEnabled(True)
|
self.advancedSearchButton.setEnabled(True)
|
||||||
self.checkSearchResult()
|
self.checkSearchResult()
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_normal_cursor()
|
||||||
Receiver.send_message(u'openlp_process_events')
|
|
||||||
|
|
||||||
def onQuickSearchButton(self):
|
def onQuickSearchButton(self):
|
||||||
"""
|
"""
|
||||||
|
@ -650,7 +649,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||||
"""
|
"""
|
||||||
log.debug(u'Quick Search Button clicked')
|
log.debug(u'Quick Search Button clicked')
|
||||||
self.quickSearchButton.setEnabled(False)
|
self.quickSearchButton.setEnabled(False)
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
bible = self.quickVersionComboBox.currentText()
|
bible = self.quickVersionComboBox.currentText()
|
||||||
second_bible = self.quickSecondComboBox.currentText()
|
second_bible = self.quickSecondComboBox.currentText()
|
||||||
text = self.quickSearchEdit.text()
|
text = self.quickSearchEdit.text()
|
||||||
|
@ -662,7 +661,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||||
self.search_results[0].book.book_reference_id)
|
self.search_results[0].book.book_reference_id)
|
||||||
else:
|
else:
|
||||||
# We are doing a 'Text Search'.
|
# We are doing a 'Text Search'.
|
||||||
Receiver.send_message(u'cursor_busy')
|
self.openlp_core.set_busy_cursor()
|
||||||
bibles = self.plugin.manager.get_bibles()
|
bibles = self.plugin.manager.get_bibles()
|
||||||
self.search_results = self.plugin.manager.verse_search(bible, second_bible, text)
|
self.search_results = self.plugin.manager.verse_search(bible, second_bible, text)
|
||||||
if second_bible and self.search_results:
|
if second_bible and self.search_results:
|
||||||
|
@ -697,8 +696,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||||
self.displayResults(bible, second_bible)
|
self.displayResults(bible, second_bible)
|
||||||
self.quickSearchButton.setEnabled(True)
|
self.quickSearchButton.setEnabled(True)
|
||||||
self.checkSearchResult()
|
self.checkSearchResult()
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_normal_cursor()
|
||||||
Receiver.send_message(u'openlp_process_events')
|
|
||||||
|
|
||||||
def displayResults(self, bible, second_bible=u''):
|
def displayResults(self, bible, second_bible=u''):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -108,7 +108,7 @@ class OpenLP1Bible(BibleDB):
|
||||||
verse_number = int(verse[1])
|
verse_number = int(verse[1])
|
||||||
text = unicode(verse[2], u'cp1252')
|
text = unicode(verse[2], u'cp1252')
|
||||||
self.create_verse(db_book.id, chapter, verse_number, text)
|
self.create_verse(db_book.id, chapter, verse_number, text)
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
self.session.commit()
|
self.session.commit()
|
||||||
connection.close()
|
connection.close()
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
import logging
|
import logging
|
||||||
from lxml import etree, objectify
|
from lxml import etree, objectify
|
||||||
|
|
||||||
from openlp.core.lib import Receiver, translate
|
from openlp.core.lib import translate
|
||||||
from openlp.core.lib.ui import critical_error_message_box
|
from openlp.core.lib.ui import critical_error_message_box
|
||||||
from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB
|
from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ class OpenSongBible(BibleDB):
|
||||||
self.wizard.incrementProgressBar(translate('BiblesPlugin.Opensong', 'Importing %s %s...',
|
self.wizard.incrementProgressBar(translate('BiblesPlugin.Opensong', 'Importing %s %s...',
|
||||||
'Importing <book name> <chapter>...')) % (db_book.name, chapter_number)
|
'Importing <book name> <chapter>...')) % (db_book.name, chapter_number)
|
||||||
self.session.commit()
|
self.session.commit()
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
except etree.XMLSyntaxError as inst:
|
except etree.XMLSyntaxError as inst:
|
||||||
critical_error_message_box(message=translate('BiblesPlugin.OpenSongImport',
|
critical_error_message_box(message=translate('BiblesPlugin.OpenSongImport',
|
||||||
'Incorrect Bible file type supplied. OpenSong Bibles may be '
|
'Incorrect Bible file type supplied. OpenSong Bibles may be '
|
||||||
|
|
|
@ -33,7 +33,7 @@ import chardet
|
||||||
import codecs
|
import codecs
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from openlp.core.lib import Receiver, translate
|
from openlp.core.lib import translate
|
||||||
from openlp.core.utils import AppLocation
|
from openlp.core.utils import AppLocation
|
||||||
from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB
|
from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ class OSISBible(BibleDB):
|
||||||
.replace(u'</div>', u'').replace(u'</w>', u'')
|
.replace(u'</div>', u'').replace(u'</w>', u'')
|
||||||
verse_text = self.spaces_regex.sub(u' ', verse_text)
|
verse_text = self.spaces_regex.sub(u' ', verse_text)
|
||||||
self.create_verse(db_book.id, chapter, verse, verse_text)
|
self.create_verse(db_book.id, chapter, verse, verse_text)
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
self.session.commit()
|
self.session.commit()
|
||||||
if match_count == 0:
|
if match_count == 0:
|
||||||
success = False
|
success = False
|
||||||
|
|
|
@ -250,7 +250,7 @@ class CustomMediaItem(MediaManagerItem):
|
||||||
and_(CustomSlide.title == item.title, CustomSlide.theme_name == item.theme,
|
and_(CustomSlide.title == item.title, CustomSlide.theme_name == item.theme,
|
||||||
CustomSlide.credits == item.raw_footer[0][len(item.title) + 1:]))
|
CustomSlide.credits == item.raw_footer[0][len(item.title) + 1:]))
|
||||||
if custom:
|
if custom:
|
||||||
Receiver.send_message(u'service_item_update', u'%s:%s:%s' % (custom.id, item.unique_identifier, False))
|
self.service_manager.service_item_update(custom.id, item.unique_identifier)
|
||||||
else:
|
else:
|
||||||
if self.add_custom_from_service:
|
if self.add_custom_from_service:
|
||||||
self.create_from_service_item(item)
|
self.create_from_service_item(item)
|
||||||
|
|
|
@ -99,7 +99,7 @@ class ImageMediaItem(MediaManagerItem):
|
||||||
if check_item_selected(self.listView, translate('ImagePlugin.MediaItem','You must select an image to delete.')):
|
if check_item_selected(self.listView, translate('ImagePlugin.MediaItem','You must select an image to delete.')):
|
||||||
row_list = [item.row() for item in self.listView.selectedIndexes()]
|
row_list = [item.row() for item in self.listView.selectedIndexes()]
|
||||||
row_list.sort(reverse=True)
|
row_list.sort(reverse=True)
|
||||||
Receiver.send_message(u'cursor_busy')
|
self.openlp_core.set_busy_cursor()
|
||||||
self.main_window.displayProgressBar(len(row_list))
|
self.main_window.displayProgressBar(len(row_list))
|
||||||
for row in row_list:
|
for row in row_list:
|
||||||
text = self.listView.item(row)
|
text = self.listView.item(row)
|
||||||
|
@ -109,12 +109,12 @@ class ImageMediaItem(MediaManagerItem):
|
||||||
self.main_window.incrementProgressBar()
|
self.main_window.incrementProgressBar()
|
||||||
SettingsManager.setValue(self.settingsSection + u'/images files', self.getFileList())
|
SettingsManager.setValue(self.settingsSection + u'/images files', self.getFileList())
|
||||||
self.main_window.finishedProgressBar()
|
self.main_window.finishedProgressBar()
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_normal_cursor()
|
||||||
self.listView.blockSignals(False)
|
self.listView.blockSignals(False)
|
||||||
|
|
||||||
def loadList(self, images, initialLoad=False):
|
def loadList(self, images, initialLoad=False):
|
||||||
|
self.openlp_core.set_busy_cursor()
|
||||||
if not initialLoad:
|
if not initialLoad:
|
||||||
Receiver.send_message(u'cursor_busy')
|
|
||||||
self.main_window.displayProgressBar(len(images))
|
self.main_window.displayProgressBar(len(images))
|
||||||
# Sort the images by its filename considering language specific
|
# Sort the images by its filename considering language specific
|
||||||
# characters.
|
# characters.
|
||||||
|
@ -138,7 +138,7 @@ class ImageMediaItem(MediaManagerItem):
|
||||||
self.main_window.incrementProgressBar()
|
self.main_window.incrementProgressBar()
|
||||||
if not initialLoad:
|
if not initialLoad:
|
||||||
self.main_window.finishedProgressBar()
|
self.main_window.finishedProgressBar()
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_busy_cursor()
|
||||||
|
|
||||||
def generateSlideData(self, service_item, item=None, xmlVersion=False,
|
def generateSlideData(self, service_item, item=None, xmlVersion=False,
|
||||||
remote=False, context=ServiceItemContext.Service):
|
remote=False, context=ServiceItemContext.Service):
|
||||||
|
|
|
@ -150,9 +150,8 @@ class PresentationMediaItem(MediaManagerItem):
|
||||||
"""
|
"""
|
||||||
currlist = self.getFileList()
|
currlist = self.getFileList()
|
||||||
titles = [os.path.split(file)[1] for file in currlist]
|
titles = [os.path.split(file)[1] for file in currlist]
|
||||||
Receiver.send_message(u'cursor_busy')
|
self.openlp_core.set_busy_cursor()
|
||||||
if not initialLoad:
|
if not initialLoad:
|
||||||
Receiver.send_message(u'cursor_busy')
|
|
||||||
self.main_window.displayProgressBar(len(files))
|
self.main_window.displayProgressBar(len(files))
|
||||||
# Sort the presentations by its filename considering language specific characters.
|
# Sort the presentations by its filename considering language specific characters.
|
||||||
files.sort(cmp=locale_compare,
|
files.sort(cmp=locale_compare,
|
||||||
|
@ -206,10 +205,9 @@ class PresentationMediaItem(MediaManagerItem):
|
||||||
item_name.setIcon(icon)
|
item_name.setIcon(icon)
|
||||||
item_name.setToolTip(file)
|
item_name.setToolTip(file)
|
||||||
self.listView.addItem(item_name)
|
self.listView.addItem(item_name)
|
||||||
Receiver.send_message(u'cursor_normal')
|
|
||||||
if not initialLoad:
|
if not initialLoad:
|
||||||
self.main_window.finishedProgressBar()
|
self.main_window.finishedProgressBar()
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_busy_cursor()
|
||||||
|
|
||||||
def onDeleteClick(self):
|
def onDeleteClick(self):
|
||||||
"""
|
"""
|
||||||
|
@ -219,7 +217,7 @@ class PresentationMediaItem(MediaManagerItem):
|
||||||
items = self.listView.selectedIndexes()
|
items = self.listView.selectedIndexes()
|
||||||
row_list = [item.row() for item in items]
|
row_list = [item.row() for item in items]
|
||||||
row_list.sort(reverse=True)
|
row_list.sort(reverse=True)
|
||||||
Receiver.send_message(u'cursor_busy')
|
self.openlp_core.set_busy_cursor()
|
||||||
self.main_window.displayProgressBar(len(row_list))
|
self.main_window.displayProgressBar(len(row_list))
|
||||||
for item in items:
|
for item in items:
|
||||||
filepath = unicode(item.data(QtCore.Qt.UserRole))
|
filepath = unicode(item.data(QtCore.Qt.UserRole))
|
||||||
|
@ -229,7 +227,7 @@ class PresentationMediaItem(MediaManagerItem):
|
||||||
doc.close_presentation()
|
doc.close_presentation()
|
||||||
self.main_window.incrementProgressBar()
|
self.main_window.incrementProgressBar()
|
||||||
self.main_window.finishedProgressBar()
|
self.main_window.finishedProgressBar()
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_busy_cursor()
|
||||||
for row in row_list:
|
for row in row_list:
|
||||||
self.listView.takeItem(row)
|
self.listView.takeItem(row)
|
||||||
Settings().setValue(self.settingsSection + u'/presentations files', self.getFileList())
|
Settings().setValue(self.settingsSection + u'/presentations files', self.getFileList())
|
||||||
|
|
|
@ -226,7 +226,7 @@ class SongExportForm(OpenLPWizard):
|
||||||
self.directoryLineEdit.clear()
|
self.directoryLineEdit.clear()
|
||||||
self.searchLineEdit.clear()
|
self.searchLineEdit.clear()
|
||||||
# Load the list of songs.
|
# Load the list of songs.
|
||||||
Receiver.send_message(u'cursor_busy')
|
self.openlp_core.set_busy_cursor()
|
||||||
songs = self.plugin.manager.get_all_objects(Song)
|
songs = self.plugin.manager.get_all_objects(Song)
|
||||||
songs.sort(cmp=natcmp, key=lambda song: song.sort_key)
|
songs.sort(cmp=natcmp, key=lambda song: song.sort_key)
|
||||||
for song in songs:
|
for song in songs:
|
||||||
|
@ -240,7 +240,7 @@ class SongExportForm(OpenLPWizard):
|
||||||
item.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled)
|
item.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled)
|
||||||
item.setCheckState(QtCore.Qt.Unchecked)
|
item.setCheckState(QtCore.Qt.Unchecked)
|
||||||
self.availableListWidget.addItem(item)
|
self.availableListWidget.addItem(item)
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_normal_cursor()
|
||||||
|
|
||||||
def preWizard(self):
|
def preWizard(self):
|
||||||
"""
|
"""
|
||||||
|
@ -248,7 +248,7 @@ class SongExportForm(OpenLPWizard):
|
||||||
"""
|
"""
|
||||||
OpenLPWizard.preWizard(self)
|
OpenLPWizard.preWizard(self)
|
||||||
self.progressLabel.setText(translate('SongsPlugin.ExportWizardForm', 'Starting export...'))
|
self.progressLabel.setText(translate('SongsPlugin.ExportWizardForm', 'Starting export...'))
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
|
|
||||||
def performWizard(self):
|
def performWizard(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -35,7 +35,7 @@ import os
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import Receiver, Settings, SettingsManager, translate, UiStrings
|
from openlp.core.lib import Settings, SettingsManager, translate, UiStrings
|
||||||
from openlp.core.lib.ui import critical_error_message_box
|
from openlp.core.lib.ui import critical_error_message_box
|
||||||
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
|
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
|
||||||
from openlp.plugins.songs.lib.importer import SongFormat, SongFormatSelect
|
from openlp.plugins.songs.lib.importer import SongFormat, SongFormatSelect
|
||||||
|
@ -328,7 +328,7 @@ class SongImportForm(OpenLPWizard):
|
||||||
"""
|
"""
|
||||||
OpenLPWizard.preWizard(self)
|
OpenLPWizard.preWizard(self)
|
||||||
self.progressLabel.setText(WizardStrings.StartingImport)
|
self.progressLabel.setText(WizardStrings.StartingImport)
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
|
|
||||||
def performWizard(self):
|
def performWizard(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -346,12 +346,12 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
||||||
"""
|
"""
|
||||||
Utility method to merge two objects to leave one in the database.
|
Utility method to merge two objects to leave one in the database.
|
||||||
"""
|
"""
|
||||||
Receiver.send_message(u'cursor_busy')
|
self.openlp_core.set_busy_cursor()
|
||||||
merge(dbObject)
|
merge(dbObject)
|
||||||
reset()
|
reset()
|
||||||
if not self.fromSongEdit:
|
if not self.fromSongEdit:
|
||||||
Receiver.send_message(u'songs_load_list')
|
Receiver.send_message(u'songs_load_list')
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_normal_cursor()
|
||||||
|
|
||||||
def mergeAuthors(self, oldAuthor):
|
def mergeAuthors(self, oldAuthor):
|
||||||
"""
|
"""
|
||||||
|
@ -481,3 +481,12 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
||||||
deleteButton.setEnabled(True)
|
deleteButton.setEnabled(True)
|
||||||
editButton.setEnabled(True)
|
editButton.setEnabled(True)
|
||||||
|
|
||||||
|
def _get_openlp_core(self):
|
||||||
|
"""
|
||||||
|
Adds the openlp to the class dynamically
|
||||||
|
"""
|
||||||
|
if not hasattr(self, u'_openlp_core'):
|
||||||
|
self._openlp_core = Registry().get(u'openlp_core')
|
||||||
|
return self._openlp_core
|
||||||
|
|
||||||
|
openlp_core = property(_get_openlp_core)
|
|
@ -361,7 +361,7 @@ class SongMediaItem(MediaManagerItem):
|
||||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
|
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
|
||||||
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No:
|
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No:
|
||||||
return
|
return
|
||||||
Receiver.send_message(u'cursor_busy')
|
self.openlp_core.set_busy_cursor()
|
||||||
self.main_window.displayProgressBar(len(items))
|
self.main_window.displayProgressBar(len(items))
|
||||||
for item in items:
|
for item in items:
|
||||||
item_id = item.data(QtCore.Qt.UserRole)
|
item_id = item.data(QtCore.Qt.UserRole)
|
||||||
|
@ -380,7 +380,7 @@ class SongMediaItem(MediaManagerItem):
|
||||||
self.plugin.manager.delete_object(Song, item_id)
|
self.plugin.manager.delete_object(Song, item_id)
|
||||||
self.main_window.incrementProgressBar()
|
self.main_window.incrementProgressBar()
|
||||||
self.main_window.finishedProgressBar()
|
self.main_window.finishedProgressBar()
|
||||||
Receiver.send_message(u'cursor_normal')
|
self.openlp_core.set_normal_cursor()
|
||||||
self.onSearchTextButtonClicked()
|
self.onSearchTextButtonClicked()
|
||||||
|
|
||||||
def onCloneClick(self):
|
def onCloneClick(self):
|
||||||
|
@ -526,7 +526,7 @@ class SongMediaItem(MediaManagerItem):
|
||||||
temporary = True
|
temporary = True
|
||||||
# Update service with correct song id.
|
# Update service with correct song id.
|
||||||
if editId:
|
if editId:
|
||||||
Receiver.send_message(u'service_item_update%s:%s:%s' % (editId, item.unique_identifier, temporary))
|
self.service_manager.service_item_update(editId, item.unique_identifier, temporary)
|
||||||
|
|
||||||
def search(self, string, showError):
|
def search(self, string, showError):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -35,7 +35,7 @@ import os
|
||||||
|
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
from openlp.core.lib import check_directory_exists, Receiver, translate
|
from openlp.core.lib import Registry, check_directory_exists, translate
|
||||||
from openlp.core.utils import clean_filename
|
from openlp.core.utils import clean_filename
|
||||||
from openlp.plugins.songs.lib import OpenLyrics
|
from openlp.plugins.songs.lib import OpenLyrics
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ class OpenLyricsExport(object):
|
||||||
openLyrics = OpenLyrics(self.manager)
|
openLyrics = OpenLyrics(self.manager)
|
||||||
self.parent.progressBar.setMaximum(len(self.songs))
|
self.parent.progressBar.setMaximum(len(self.songs))
|
||||||
for song in self.songs:
|
for song in self.songs:
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
if self.parent.stop_export_flag:
|
if self.parent.stop_export_flag:
|
||||||
return False
|
return False
|
||||||
self.parent.incrementProgressBar(translate('SongsPlugin.OpenLyricsExport', 'Exporting "%s"...') %
|
self.parent.incrementProgressBar(translate('SongsPlugin.OpenLyricsExport', 'Exporting "%s"...') %
|
||||||
|
@ -80,3 +80,13 @@ class OpenLyricsExport(object):
|
||||||
tree.write(open(os.path.join(self.save_path, filename), u'w'),
|
tree.write(open(os.path.join(self.save_path, filename), u'w'),
|
||||||
encoding=u'utf-8', xml_declaration=True, pretty_print=True)
|
encoding=u'utf-8', xml_declaration=True, pretty_print=True)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def _get_openlp_core(self):
|
||||||
|
"""
|
||||||
|
Adds the openlp to the class dynamically
|
||||||
|
"""
|
||||||
|
if not hasattr(self, u'_openlp_core'):
|
||||||
|
self._openlp_core = Registry().get(u'openlp_core')
|
||||||
|
return self._openlp_core
|
||||||
|
|
||||||
|
openlp_core = property(_get_openlp_core)
|
||||||
|
|
|
@ -38,7 +38,7 @@ import sqlite3
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import Plugin, StringContent, build_icon, translate, Receiver, UiStrings
|
from openlp.core.lib import Plugin, StringContent, build_icon, translate, UiStrings
|
||||||
from openlp.core.lib.db import Manager
|
from openlp.core.lib.db import Manager
|
||||||
from openlp.core.lib.ui import create_action
|
from openlp.core.lib.ui import create_action
|
||||||
from openlp.core.utils import get_filesystem_encoding
|
from openlp.core.utils import get_filesystem_encoding
|
||||||
|
@ -96,9 +96,6 @@ class SongsPlugin(Plugin):
|
||||||
action_list.add_action(self.songImportItem, UiStrings().Import)
|
action_list.add_action(self.songImportItem, UiStrings().Import)
|
||||||
action_list.add_action(self.songExportItem, UiStrings().Export)
|
action_list.add_action(self.songExportItem, UiStrings().Export)
|
||||||
action_list.add_action(self.toolsReindexItem, UiStrings().Tools)
|
action_list.add_action(self.toolsReindexItem, UiStrings().Tools)
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_new_service'),
|
|
||||||
self.clearTemporarySongs)
|
|
||||||
|
|
||||||
|
|
||||||
def addImportMenuItem(self, import_menu):
|
def addImportMenuItem(self, import_menu):
|
||||||
"""
|
"""
|
||||||
|
@ -244,9 +241,9 @@ class SongsPlugin(Plugin):
|
||||||
If the first time wizard has run, this function is run to import all the
|
If the first time wizard has run, this function is run to import all the
|
||||||
new songs into the database.
|
new songs into the database.
|
||||||
"""
|
"""
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
self.onToolsReindexItemTriggered()
|
self.onToolsReindexItemTriggered()
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
db_dir = unicode(os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp'))
|
db_dir = unicode(os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp'))
|
||||||
if not os.path.exists(db_dir):
|
if not os.path.exists(db_dir):
|
||||||
return
|
return
|
||||||
|
@ -254,12 +251,12 @@ class SongsPlugin(Plugin):
|
||||||
song_count = 0
|
song_count = 0
|
||||||
for sfile in os.listdir(db_dir):
|
for sfile in os.listdir(db_dir):
|
||||||
if sfile.startswith(u'songs_') and sfile.endswith(u'.sqlite'):
|
if sfile.startswith(u'songs_') and sfile.endswith(u'.sqlite'):
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
song_dbs.append(os.path.join(db_dir, sfile))
|
song_dbs.append(os.path.join(db_dir, sfile))
|
||||||
song_count += self._countSongs(os.path.join(db_dir, sfile))
|
song_count += self._countSongs(os.path.join(db_dir, sfile))
|
||||||
if not song_dbs:
|
if not song_dbs:
|
||||||
return
|
return
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
progress = QtGui.QProgressDialog(self.main_window)
|
progress = QtGui.QProgressDialog(self.main_window)
|
||||||
progress.setWindowModality(QtCore.Qt.WindowModal)
|
progress.setWindowModality(QtCore.Qt.WindowModal)
|
||||||
progress.setWindowTitle(translate('OpenLP.Ui', 'Importing Songs'))
|
progress.setWindowTitle(translate('OpenLP.Ui', 'Importing Songs'))
|
||||||
|
@ -268,11 +265,11 @@ class SongsPlugin(Plugin):
|
||||||
progress.setRange(0, song_count)
|
progress.setRange(0, song_count)
|
||||||
progress.setMinimumDuration(0)
|
progress.setMinimumDuration(0)
|
||||||
progress.forceShow()
|
progress.forceShow()
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
for db in song_dbs:
|
for db in song_dbs:
|
||||||
importer = OpenLPSongImport(self.manager, filename=db)
|
importer = OpenLPSongImport(self.manager, filename=db)
|
||||||
importer.doImport(progress)
|
importer.doImport(progress)
|
||||||
Receiver.send_message(u'openlp_process_events')
|
self.openlp_core.process_events()
|
||||||
progress.setValue(song_count)
|
progress.setValue(song_count)
|
||||||
self.mediaItem.onSearchTextButtonClicked()
|
self.mediaItem.onSearchTextButtonClicked()
|
||||||
|
|
||||||
|
@ -281,7 +278,7 @@ class SongsPlugin(Plugin):
|
||||||
Time to tidy up on exit
|
Time to tidy up on exit
|
||||||
"""
|
"""
|
||||||
log.info(u'Songs Finalising')
|
log.info(u'Songs Finalising')
|
||||||
self.clearTemporarySongs()
|
self.new_service_created()
|
||||||
# Clean up files and connections
|
# Clean up files and connections
|
||||||
self.manager.finalise()
|
self.manager.finalise()
|
||||||
self.songImportItem.setVisible(False)
|
self.songImportItem.setVisible(False)
|
||||||
|
@ -293,13 +290,18 @@ class SongsPlugin(Plugin):
|
||||||
action_list.remove_action(self.toolsReindexItem, UiStrings().Tools)
|
action_list.remove_action(self.toolsReindexItem, UiStrings().Tools)
|
||||||
Plugin.finalise(self)
|
Plugin.finalise(self)
|
||||||
|
|
||||||
def clearTemporarySongs(self):
|
def new_service_created(self):
|
||||||
# Remove temporary songs
|
"""
|
||||||
|
Remove temporary songs from the database
|
||||||
|
"""
|
||||||
songs = self.manager.get_all_objects(Song, Song.temporary == True)
|
songs = self.manager.get_all_objects(Song, Song.temporary == True)
|
||||||
for song in songs:
|
for song in songs:
|
||||||
self.manager.delete_object(Song, song.id)
|
self.manager.delete_object(Song, song.id)
|
||||||
|
|
||||||
def _countSongs(self, db_file):
|
def _countSongs(self, db_file):
|
||||||
|
"""
|
||||||
|
Provide a count of the songs in the database
|
||||||
|
"""
|
||||||
connection = sqlite3.connect(db_file)
|
connection = sqlite3.connect(db_file)
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
cursor.execute(u'SELECT COUNT(id) AS song_count FROM songs')
|
cursor.execute(u'SELECT COUNT(id) AS song_count FROM songs')
|
||||||
|
|
Loading…
Reference in New Issue