Refactors, cleanups and fixes

bzr-revno: 980
Fixes: https://launchpad.net/bugs/605655
This commit is contained in:
Jon Tibble 2010-07-31 10:27:12 +01:00
commit 1cbf4333d8
30 changed files with 146 additions and 222 deletions

View File

@ -32,12 +32,12 @@ from optparse import OptionParser
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
log = logging.getLogger()
from openlp.core.lib import Receiver from openlp.core.lib import Receiver
from openlp.core.resources import qInitResources from openlp.core.resources import qInitResources
from openlp.core.ui import MainWindow, SplashScreen, ScreenList from openlp.core.ui import MainWindow, SplashScreen, ScreenList
from openlp.core.utils import AppLocation, LanguageManager from openlp.core.utils import AppLocation, LanguageManager, VersionThread
log = logging.getLogger()
application_stylesheet = u""" application_stylesheet = u"""
QMainWindow::separator QMainWindow::separator
@ -141,7 +141,7 @@ class OpenLP(QtGui.QApplication):
# now kill the splashscreen # now kill the splashscreen
self.splash.finish(self.mainWindow) self.splash.finish(self.mainWindow)
self.mainWindow.repaint() self.mainWindow.repaint()
self.mainWindow.versionThread() VersionThread(self.mainWindow, app_version).start()
return self.exec_() return self.exec_()
def main(): def main():

View File

@ -133,6 +133,7 @@ class Plugin(QtCore.QObject):
self.mediadock = plugin_helpers[u'toolbox'] self.mediadock = plugin_helpers[u'toolbox']
self.displayManager = plugin_helpers[u'displaymanager'] self.displayManager = plugin_helpers[u'displaymanager']
self.pluginManager = plugin_helpers[u'pluginmanager'] self.pluginManager = plugin_helpers[u'pluginmanager']
self.formparent = plugin_helpers[u'formparent']
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'%s_add_service_item' % self.name), QtCore.SIGNAL(u'%s_add_service_item' % self.name),
self.processAddServiceEvent) self.processAddServiceEvent)

View File

@ -77,7 +77,6 @@ class PluginManager(object):
startdepth = len(os.path.abspath(plugin_dir).split(os.sep)) startdepth = len(os.path.abspath(plugin_dir).split(os.sep))
log.debug(u'finding plugins in %s at depth %d', log.debug(u'finding plugins in %s at depth %d',
unicode(plugin_dir), startdepth) unicode(plugin_dir), startdepth)
for root, dirs, files in os.walk(plugin_dir): for root, dirs, files in os.walk(plugin_dir):
for name in files: for name in files:
if name.endswith(u'.py') and not name.startswith(u'__'): if name.endswith(u'.py') and not name.startswith(u'__'):

View File

@ -25,8 +25,6 @@
############################################################################### ###############################################################################
import logging import logging
import time
import re
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
@ -34,8 +32,7 @@ from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \
ThemeManager, SlideController, PluginForm, MediaDockManager, DisplayManager ThemeManager, SlideController, PluginForm, MediaDockManager, DisplayManager
from openlp.core.lib import RenderManager, build_icon, OpenLPDockWidget, \ from openlp.core.lib import RenderManager, build_icon, OpenLPDockWidget, \
SettingsManager, PluginManager, Receiver, translate SettingsManager, PluginManager, Receiver, translate
from openlp.core.utils import check_latest_version, AppLocation, add_actions, \ from openlp.core.utils import AppLocation, add_actions, LanguageManager
LanguageManager
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -58,49 +55,6 @@ MEDIA_MANAGER_STYLE = """
font-weight: bold; font-weight: bold;
} }
""" """
class VersionThread(QtCore.QThread):
"""
A special Qt thread class to fetch the version of OpenLP from the website.
This is threaded so that it doesn't affect the loading time of OpenLP.
"""
def __init__(self, parent, app_version):
QtCore.QThread.__init__(self, parent)
self.parent = parent
self.app_version = app_version
self.version_splitter = re.compile(
r'([0-9]+).([0-9]+).([0-9]+)(?:-bzr([0-9]+))?')
def run(self):
"""
Run the thread.
"""
time.sleep(1)
Receiver.send_message(u'maindisplay_blank_check')
version = check_latest_version(self.app_version)
remote_version = {}
local_version = {}
match = self.version_splitter.match(version)
if match:
remote_version[u'major'] = int(match.group(1))
remote_version[u'minor'] = int(match.group(2))
remote_version[u'release'] = int(match.group(3))
if len(match.groups()) > 3 and match.group(4):
remote_version[u'revision'] = int(match.group(4))
match = self.version_splitter.match(self.app_version[u'full'])
if match:
local_version[u'major'] = int(match.group(1))
local_version[u'minor'] = int(match.group(2))
local_version[u'release'] = int(match.group(3))
if len(match.groups()) > 3 and match.group(4):
local_version[u'revision'] = int(match.group(4))
if remote_version[u'major'] > local_version[u'major'] or \
remote_version[u'minor'] > local_version[u'minor'] or \
remote_version[u'release'] > local_version[u'release']:
Receiver.send_message(u'openlp_version_check', u'%s' % version)
elif remote_version.get(u'revision') and \
local_version.get(u'revision') and \
remote_version[u'revision'] > local_version[u'revision']:
Receiver.send_message(u'openlp_version_check', u'%s' % version)
class Ui_MainWindow(object): class Ui_MainWindow(object):
def setupUi(self, MainWindow): def setupUi(self, MainWindow):
@ -578,20 +532,15 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
QtCore.SIGNAL(u'triggered()'), QtCore.SIGNAL(u'triggered()'),
self.ThemeManagerContents.onExportTheme) self.ThemeManagerContents.onExportTheme)
QtCore.QObject.connect(self.ViewMediaManagerItem, QtCore.QObject.connect(self.ViewMediaManagerItem,
QtCore.SIGNAL(u'triggered(bool)'), QtCore.SIGNAL(u'triggered(bool)'), self.toggleMediaManager)
self.toggleMediaManager)
QtCore.QObject.connect(self.ViewServiceManagerItem, QtCore.QObject.connect(self.ViewServiceManagerItem,
QtCore.SIGNAL(u'triggered(bool)'), QtCore.SIGNAL(u'triggered(bool)'), self.toggleServiceManager)
self.toggleServiceManager)
QtCore.QObject.connect(self.ViewThemeManagerItem, QtCore.QObject.connect(self.ViewThemeManagerItem,
QtCore.SIGNAL(u'triggered(bool)'), QtCore.SIGNAL(u'triggered(bool)'), self.toggleThemeManager)
self.toggleThemeManager)
QtCore.QObject.connect(self.ViewPreviewPanel, QtCore.QObject.connect(self.ViewPreviewPanel,
QtCore.SIGNAL(u'toggled(bool)'), QtCore.SIGNAL(u'toggled(bool)'), self.setPreviewPanelVisibility)
self.setPreviewPanelVisibility)
QtCore.QObject.connect(self.ViewLivePanel, QtCore.QObject.connect(self.ViewLivePanel,
QtCore.SIGNAL(u'toggled(bool)'), QtCore.SIGNAL(u'toggled(bool)'), self.setLivePanelVisibility)
self.setLivePanelVisibility)
QtCore.QObject.connect(self.MediaManagerDock, QtCore.QObject.connect(self.MediaManagerDock,
QtCore.SIGNAL(u'visibilityChanged(bool)'), QtCore.SIGNAL(u'visibilityChanged(bool)'),
self.ViewMediaManagerItem.setChecked) self.ViewMediaManagerItem.setChecked)
@ -609,8 +558,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
QtCore.SIGNAL(u'triggered()'), self.onPluginItemClicked) QtCore.SIGNAL(u'triggered()'), self.onPluginItemClicked)
QtCore.QObject.connect(self.SettingsConfigureItem, QtCore.QObject.connect(self.SettingsConfigureItem,
QtCore.SIGNAL(u'triggered()'), self.onOptionsSettingsItemClicked) QtCore.SIGNAL(u'triggered()'), self.onOptionsSettingsItemClicked)
QtCore.QObject.connect(self.FileNewItem, QtCore.QObject.connect(self.FileNewItem, QtCore.SIGNAL(u'triggered()'),
QtCore.SIGNAL(u'triggered()'),
self.ServiceManagerContents.onNewService) self.ServiceManagerContents.onNewService)
QtCore.QObject.connect(self.FileOpenItem, QtCore.QObject.connect(self.FileOpenItem,
QtCore.SIGNAL(u'triggered()'), QtCore.SIGNAL(u'triggered()'),
@ -623,22 +571,18 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.ServiceManagerContents.onSaveService) self.ServiceManagerContents.onSaveService)
#i18n set signals for languages #i18n set signals for languages
QtCore.QObject.connect(self.AutoLanguageItem, QtCore.QObject.connect(self.AutoLanguageItem,
QtCore.SIGNAL(u'toggled(bool)'), QtCore.SIGNAL(u'toggled(bool)'), self.setAutoLanguage)
self.setAutoLanguage)
self.LanguageGroup.triggered.connect(LanguageManager.set_language) self.LanguageGroup.triggered.connect(LanguageManager.set_language)
QtCore.QObject.connect(self.ModeDefaultItem, QtCore.QObject.connect(self.ModeDefaultItem,
QtCore.SIGNAL(u'triggered()'), QtCore.SIGNAL(u'triggered()'), self.setViewMode)
self.onModeDefaultItemClicked)
QtCore.QObject.connect(self.ModeSetupItem, QtCore.QObject.connect(self.ModeSetupItem,
QtCore.SIGNAL(u'triggered()'), QtCore.SIGNAL(u'triggered()'), self.onModeSetupItemClicked)
self.onModeSetupItemClicked)
QtCore.QObject.connect(self.ModeLiveItem, QtCore.QObject.connect(self.ModeLiveItem,
QtCore.SIGNAL(u'triggered()'), QtCore.SIGNAL(u'triggered()'), self.onModeLiveItemClicked)
self.onModeLiveItemClicked)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'theme_update_global'), self.defaultThemeChanged) QtCore.SIGNAL(u'theme_update_global'), self.defaultThemeChanged)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'openlp_version_check'), self.versionCheck) QtCore.SIGNAL(u'openlp_version_check'), self.versionNotice)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'maindisplay_blank_check'), self.blankCheck) QtCore.SIGNAL(u'maindisplay_blank_check'), self.blankCheck)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
@ -663,6 +607,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.plugin_helpers[u'toolbox'] = self.mediaDockManager self.plugin_helpers[u'toolbox'] = self.mediaDockManager
self.plugin_helpers[u'displaymanager'] = self.displayManager self.plugin_helpers[u'displaymanager'] = self.displayManager
self.plugin_helpers[u'pluginmanager'] = self.plugin_manager self.plugin_helpers[u'pluginmanager'] = self.plugin_manager
self.plugin_helpers[u'formparent'] = self
self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers) self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers)
# hook methods have to happen after find_plugins. Find plugins needs # hook methods have to happen after find_plugins. Find plugins needs
# the controllers hence the hooks have moved from setupUI() to here # the controllers hence the hooks have moved from setupUI() to here
@ -699,12 +644,11 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
LanguageManager.AutoLanguage = value LanguageManager.AutoLanguage = value
LanguageManager.set_language(self.LanguageGroup.checkedAction()) LanguageManager.set_language(self.LanguageGroup.checkedAction())
def versionCheck(self, version): def versionNotice(self, version):
""" """
Checks the version of the Application called from openlp.pyw Notifies the user that a newer version of OpenLP is available.
Triggered by delay thread. Triggered by delay thread.
""" """
app_version = self.applicationVersion[u'full']
version_text = unicode(translate('OpenLP.MainWindow', version_text = unicode(translate('OpenLP.MainWindow',
'Version %s of OpenLP is now available for download (you are ' 'Version %s of OpenLP is now available for download (you are '
'currently running version %s). \n\nYou can download the latest ' 'currently running version %s). \n\nYou can download the latest '
@ -712,16 +656,13 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
'<a href="http://openlp.org/">http://openlp.org/</a>.')) '<a href="http://openlp.org/">http://openlp.org/</a>.'))
QtGui.QMessageBox.question(self, QtGui.QMessageBox.question(self,
translate('OpenLP.MainWindow', 'OpenLP Version Updated'), translate('OpenLP.MainWindow', 'OpenLP Version Updated'),
version_text % (version, app_version), version_text % (version, self.applicationVersion[u'full']))
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok),
QtGui.QMessageBox.Ok)
def show(self): def show(self):
""" """
Show the main form, as well as the display form Show the main form, as well as the display form
""" """
QtGui.QWidget.show(self) QtGui.QWidget.show(self)
#screen_number = self.getMonitorNumber()
self.displayManager.setup() self.displayManager.setup()
if self.displayManager.mainDisplay.isVisible(): if self.displayManager.mainDisplay.isVisible():
self.displayManager.mainDisplay.setFocus() self.displayManager.mainDisplay.setFocus()
@ -749,13 +690,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
'The Main Display has been blanked out')) 'The Main Display has been blanked out'))
settings.endGroup() settings.endGroup()
def versionThread(self):
"""
Start an initial setup thread to delay notifications
"""
vT = VersionThread(self, self.applicationVersion)
vT.start()
def onHelpWebSiteClicked(self): def onHelpWebSiteClicked(self):
""" """
Load the OpenLP website Load the OpenLP website
@ -783,35 +717,28 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
""" """
self.settingsForm.exec_() self.settingsForm.exec_()
def onModeDefaultItemClicked(self):
"""
Put OpenLP into "Default" view mode.
"""
self.MediaManagerDock.setVisible(True)
self.ServiceManagerDock.setVisible(True)
self.ThemeManagerDock.setVisible(True)
self.setPreviewPanelVisibility(True)
self.setLivePanelVisibility(True)
def onModeSetupItemClicked(self): def onModeSetupItemClicked(self):
""" """
Put OpenLP into "Setup" view mode. Put OpenLP into "Setup" view mode.
""" """
self.MediaManagerDock.setVisible(True) self.setViewMode(True, True, False, True, False)
self.ServiceManagerDock.setVisible(True)
self.ThemeManagerDock.setVisible(False)
self.setPreviewPanelVisibility(True)
self.setLivePanelVisibility(False)
def onModeLiveItemClicked(self): def onModeLiveItemClicked(self):
""" """
Put OpenLP into "Live" view mode. Put OpenLP into "Live" view mode.
""" """
self.MediaManagerDock.setVisible(False) self.setViewMode(False, True, False, False, True)
self.ServiceManagerDock.setVisible(True)
self.ThemeManagerDock.setVisible(False) def setViewMode(self, media=True, service=True, theme=True, preview=True,
self.setPreviewPanelVisibility(False) live=True):
self.setLivePanelVisibility(True) """
Set OpenLP to a different view mode.
"""
self.MediaManagerDock.setVisible(media)
self.ServiceManagerDock.setVisible(service)
self.ThemeManagerDock.setVisible(theme)
self.setPreviewPanelVisibility(preview)
self.setLivePanelVisibility(live)
def screenChanged(self): def screenChanged(self):
""" """

View File

@ -498,8 +498,7 @@ class ServiceManager(QtGui.QWidget):
'Your service is unsaved, do you want to save ' 'Your service is unsaved, do you want to save '
'those changes before creating a new one?'), 'those changes before creating a new one?'),
QtGui.QMessageBox.StandardButtons( QtGui.QMessageBox.StandardButtons(
QtGui.QMessageBox.Cancel | QtGui.QMessageBox.Cancel | QtGui.QMessageBox.Save),
QtGui.QMessageBox.Save),
QtGui.QMessageBox.Save) QtGui.QMessageBox.Save)
if ret == QtGui.QMessageBox.Save: if ret == QtGui.QMessageBox.Save:
self.onSaveService() self.onSaveService()
@ -656,8 +655,7 @@ class ServiceManager(QtGui.QWidget):
'Your current service is unsaved, do you want to ' 'Your current service is unsaved, do you want to '
'save the changes before opening a new one?'), 'save the changes before opening a new one?'),
QtGui.QMessageBox.StandardButtons( QtGui.QMessageBox.StandardButtons(
QtGui.QMessageBox.Discard | QtGui.QMessageBox.Discard | QtGui.QMessageBox.Save),
QtGui.QMessageBox.Save),
QtGui.QMessageBox.Save) QtGui.QMessageBox.Save)
if ret == QtGui.QMessageBox.Save: if ret == QtGui.QMessageBox.Save:
self.onSaveService() self.onSaveService()
@ -802,7 +800,6 @@ class ServiceManager(QtGui.QWidget):
``item`` ``item``
Service Item to be added Service Item to be added
""" """
sitem = self.findServiceItem()[0] sitem = self.findServiceItem()[0]
item.render() item.render()
@ -847,10 +844,7 @@ class ServiceManager(QtGui.QWidget):
QtGui.QMessageBox.critical(self, QtGui.QMessageBox.critical(self,
translate('OpenLP.ServiceManager', 'Missing Display Handler'), translate('OpenLP.ServiceManager', 'Missing Display Handler'),
translate('OpenLP.ServiceManager', 'Your item cannot be ' translate('OpenLP.ServiceManager', 'Your item cannot be '
'displayed as there is no handler to display it'), 'displayed as there is no handler to display it'))
QtGui.QMessageBox.StandardButtons(
QtGui.QMessageBox.Ok),
QtGui.QMessageBox.Ok)
def getServiceItem(self): def getServiceItem(self):
""" """
@ -883,10 +877,7 @@ class ServiceManager(QtGui.QWidget):
QtGui.QMessageBox.critical(self, QtGui.QMessageBox.critical(self,
translate('OpenLP.ServiceManager', 'Missing Display Handler'), translate('OpenLP.ServiceManager', 'Missing Display Handler'),
translate('OpenLP.ServiceManager', 'Your item cannot be ' translate('OpenLP.ServiceManager', 'Your item cannot be '
'displayed as there is no handler to display it'), 'displayed as there is no handler to display it'))
QtGui.QMessageBox.StandardButtons(
QtGui.QMessageBox.Ok),
QtGui.QMessageBox.Ok)
def remoteEdit(self): def remoteEdit(self):
""" """

View File

@ -235,8 +235,7 @@ class ThemeManager(QtGui.QWidget):
QtGui.QMessageBox.critical(self, QtGui.QMessageBox.critical(self,
translate('OpenLP.ThemeManager', 'Error'), translate('OpenLP.ThemeManager', 'Error'),
translate('OpenLP.ThemeManager', translate('OpenLP.ThemeManager',
'You are unable to delete the default theme.'), 'You are unable to delete the default theme.'))
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
else: else:
for plugin in self.parent.plugin_manager.plugins: for plugin in self.parent.plugin_manager.plugins:
if plugin.usesTheme(theme): if plugin.usesTheme(theme):

View File

@ -27,20 +27,66 @@
The :mod:`utils` module provides the utility libraries for OpenLP The :mod:`utils` module provides the utility libraries for OpenLP
""" """
import os
import sys
import logging import logging
import os
import re
import sys
import time
import urllib2 import urllib2
from datetime import datetime from datetime import datetime
from PyQt4 import QtGui, QtCore from PyQt4 import QtGui, QtCore
import openlp import openlp
from openlp.core.lib import translate from openlp.core.lib import Receiver, translate
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
images_filter = None images_filter = None
class VersionThread(QtCore.QThread):
"""
A special Qt thread class to fetch the version of OpenLP from the website.
This is threaded so that it doesn't affect the loading time of OpenLP.
"""
def __init__(self, parent, app_version):
QtCore.QThread.__init__(self, parent)
self.app_version = app_version
self.version_splitter = re.compile(
r'([0-9]+).([0-9]+).([0-9]+)(?:-bzr([0-9]+))?')
def run(self):
"""
Run the thread.
"""
time.sleep(1)
Receiver.send_message(u'maindisplay_blank_check')
version = check_latest_version(self.app_version)
remote_version = {}
local_version = {}
match = self.version_splitter.match(version)
if match:
remote_version[u'major'] = int(match.group(1))
remote_version[u'minor'] = int(match.group(2))
remote_version[u'release'] = int(match.group(3))
if len(match.groups()) > 3 and match.group(4):
remote_version[u'revision'] = int(match.group(4))
match = self.version_splitter.match(self.app_version[u'full'])
if match:
local_version[u'major'] = int(match.group(1))
local_version[u'minor'] = int(match.group(2))
local_version[u'release'] = int(match.group(3))
if len(match.groups()) > 3 and match.group(4):
local_version[u'revision'] = int(match.group(4))
if remote_version[u'major'] > local_version[u'major'] or \
remote_version[u'minor'] > local_version[u'minor'] or \
remote_version[u'release'] > local_version[u'release']:
Receiver.send_message(u'openlp_version_check', u'%s' % version)
elif remote_version.get(u'revision') and \
local_version.get(u'revision') and \
remote_version[u'revision'] > local_version[u'revision']:
Receiver.send_message(u'openlp_version_check', u'%s' % version)
class AppLocation(object): class AppLocation(object):
""" """
The :class:`AppLocation` class is a static class which retrieves a The :class:`AppLocation` class is a static class which retrieves a

View File

@ -28,7 +28,7 @@ import logging
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import Plugin, build_icon, PluginStatus, translate from openlp.core.lib import Plugin, build_icon, translate
from openlp.core.lib.db import Manager from openlp.core.lib.db import Manager
from openlp.plugins.alerts.lib import AlertsManager, AlertsTab from openlp.plugins.alerts.lib import AlertsManager, AlertsTab
from openlp.plugins.alerts.lib.db import init_schema from openlp.plugins.alerts.lib.db import init_schema
@ -45,8 +45,7 @@ class AlertsPlugin(Plugin):
self.icon = build_icon(u':/plugins/plugin_alerts.png') self.icon = build_icon(u':/plugins/plugin_alerts.png')
self.alertsmanager = AlertsManager(self) self.alertsmanager = AlertsManager(self)
self.manager = Manager(u'alerts', init_schema) self.manager = Manager(u'alerts', init_schema)
self.alertForm = AlertForm(self.manager, self) self.alertForm = AlertForm(self)
self.status = PluginStatus.Active
def getSettingsTab(self): def getSettingsTab(self):
""" """

View File

@ -35,14 +35,14 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
""" """
Provide UI for the alert system Provide UI for the alert system
""" """
def __init__(self, manager, parent): def __init__(self, plugin):
""" """
Initialise the alert form Initialise the alert form
""" """
self.manager = manager self.manager = plugin.manager
self.parent = parent self.parent = plugin
self.item_id = None self.item_id = None
QtGui.QDialog.__init__(self, None) QtGui.QDialog.__init__(self, plugin.formparent)
self.setupUi(self) self.setupUi(self)
QtCore.QObject.connect(self.DisplayButton, QtCore.SIGNAL(u'clicked()'), QtCore.QObject.connect(self.DisplayButton, QtCore.SIGNAL(u'clicked()'),
self.onDisplayClicked) self.onDisplayClicked)

View File

@ -28,7 +28,7 @@ import logging
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import Plugin, build_icon, PluginStatus, translate from openlp.core.lib import Plugin, build_icon, translate
from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -41,8 +41,6 @@ class BiblePlugin(Plugin):
self.weight = -9 self.weight = -9
self.icon_path = u':/plugins/plugin_bibles.png' self.icon_path = u':/plugins/plugin_bibles.png'
self.icon = build_icon(self.icon_path) self.icon = build_icon(self.icon_path)
# Register the bible Manager.
self.status = PluginStatus.Active
self.manager = None self.manager = None
def initialise(self): def initialise(self):

View File

@ -129,8 +129,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
'Invalid Bible Location'), 'Invalid Bible Location'),
translate('BiblesPlugin.ImportWizardForm', translate('BiblesPlugin.ImportWizardForm',
'You need to specify a file to import your ' 'You need to specify a file to import your '
'Bible from.'), 'Bible from.'))
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
self.OSISLocationEdit.setFocus() self.OSISLocationEdit.setFocus()
return False return False
elif self.field(u'source_format').toInt()[0] == BibleFormat.CSV: elif self.field(u'source_format').toInt()[0] == BibleFormat.CSV:
@ -140,8 +139,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
'Invalid Books File'), 'Invalid Books File'),
translate('BiblesPlugin.ImportWizardForm', translate('BiblesPlugin.ImportWizardForm',
'You need to specify a file with books of ' 'You need to specify a file with books of '
'the Bible to use in the import.'), 'the Bible to use in the import.'))
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
self.BooksLocationEdit.setFocus() self.BooksLocationEdit.setFocus()
return False return False
elif self.field(u'csv_versefile').toString() == u'': elif self.field(u'csv_versefile').toString() == u'':
@ -150,8 +148,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
'Invalid Verse File'), 'Invalid Verse File'),
translate('BiblesPlugin.ImportWizardForm', translate('BiblesPlugin.ImportWizardForm',
'You need to specify a file of Bible ' 'You need to specify a file of Bible '
'verses to import.'), 'verses to import.'))
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
self.CsvVerseLocationEdit.setFocus() self.CsvVerseLocationEdit.setFocus()
return False return False
elif self.field(u'source_format').toInt()[0] == \ elif self.field(u'source_format').toInt()[0] == \
@ -162,8 +159,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
'Invalid OpenSong Bible'), 'Invalid OpenSong Bible'),
translate('BiblesPlugin.ImportWizardForm', translate('BiblesPlugin.ImportWizardForm',
'You need to specify an OpenSong Bible ' 'You need to specify an OpenSong Bible '
'file to import.'), 'file to import.'))
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
self.OpenSongFileEdit.setFocus() self.OpenSongFileEdit.setFocus()
return False return False
return True return True
@ -178,8 +174,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
'Empty Version Name'), 'Empty Version Name'),
translate('BiblesPlugin.ImportWizardForm', translate('BiblesPlugin.ImportWizardForm',
'You need to specify a version name for your ' 'You need to specify a version name for your '
'Bible.'), 'Bible.'))
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
self.VersionNameEdit.setFocus() self.VersionNameEdit.setFocus()
return False return False
elif license_copyright == u'': elif license_copyright == u'':
@ -189,8 +184,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
translate('BiblesPlugin.ImportWizardForm', translate('BiblesPlugin.ImportWizardForm',
'You need to set a copyright for your Bible! ' 'You need to set a copyright for your Bible! '
'Bibles in the Public Domain need to be marked as ' 'Bibles in the Public Domain need to be marked as '
'such.'), 'such.'))
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
self.CopyrightEdit.setFocus() self.CopyrightEdit.setFocus()
return False return False
elif self.manager.exists(license_version): elif self.manager.exists(license_version):
@ -199,8 +193,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
'Bible Exists'), 'Bible Exists'),
translate('BiblesPlugin.ImportWizardForm', translate('BiblesPlugin.ImportWizardForm',
'This Bible already exists! Please import ' 'This Bible already exists! Please import '
'a different Bible or first delete the existing one.'), 'a different Bible or first delete the existing one.'))
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
self.VersionNameEdit.setFocus() self.VersionNameEdit.setFocus()
return False return False
return True return True

View File

@ -387,10 +387,7 @@ class BibleMediaItem(MediaManagerItem):
QtGui.QMessageBox.critical(self, QtGui.QMessageBox.critical(self,
translate('BiblesPlugin.MediaItem', 'No Book Found'), translate('BiblesPlugin.MediaItem', 'No Book Found'),
translate('BiblesPlugin.MediaItem', translate('BiblesPlugin.MediaItem',
'No matching book could be found in this Bible.'), 'No matching book could be found in this Bible.'))
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok),
QtGui.QMessageBox.Ok
)
def onAdvancedVersionComboBox(self): def onAdvancedVersionComboBox(self):
self.initialiseBible( self.initialiseBible(

View File

@ -28,7 +28,7 @@ import logging
from forms import EditCustomForm from forms import EditCustomForm
from openlp.core.lib import Plugin, build_icon, PluginStatus, translate from openlp.core.lib import Plugin, build_icon, translate
from openlp.core.lib.db import Manager from openlp.core.lib.db import Manager
from openlp.plugins.custom.lib import CustomMediaItem, CustomTab from openlp.plugins.custom.lib import CustomMediaItem, CustomTab
from openlp.plugins.custom.lib.db import CustomSlide, init_schema from openlp.plugins.custom.lib.db import CustomSlide, init_schema
@ -53,7 +53,6 @@ class CustomPlugin(Plugin):
self.edit_custom_form = EditCustomForm(self.custommanager) self.edit_custom_form = EditCustomForm(self.custommanager)
self.icon_path = u':/plugins/plugin_custom.png' self.icon_path = u':/plugins/plugin_custom.png'
self.icon = build_icon(self.icon_path) self.icon = build_icon(self.icon_path)
self.status = PluginStatus.Active
def getSettingsTab(self): def getSettingsTab(self):
return CustomTab(self.name) return CustomTab(self.name)

View File

@ -151,8 +151,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
valid, message = self._validate() valid, message = self._validate()
if not valid: if not valid:
QtGui.QMessageBox.critical(self, QtGui.QMessageBox.critical(self,
translate('CustomPlugin.EditCustomForm', 'Error'), message, translate('CustomPlugin.EditCustomForm', 'Error'), message)
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
return False return False
sxml = CustomXMLBuilder() sxml = CustomXMLBuilder()
sxml.new_document() sxml.new_document()

View File

@ -26,7 +26,7 @@
import logging import logging
from openlp.core.lib import Plugin, build_icon, PluginStatus, translate from openlp.core.lib import Plugin, build_icon, translate
from openlp.plugins.images.lib import ImageMediaItem from openlp.plugins.images.lib import ImageMediaItem
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -39,7 +39,6 @@ class ImagePlugin(Plugin):
self.weight = -7 self.weight = -7
self.icon_path = u':/plugins/plugin_images.png' self.icon_path = u':/plugins/plugin_images.png'
self.icon = build_icon(self.icon_path) self.icon = build_icon(self.icon_path)
self.status = PluginStatus.Active
def getMediaManagerItem(self): def getMediaManagerItem(self):
# Create the MediaManagerItem object # Create the MediaManagerItem object

View File

@ -28,7 +28,7 @@ import logging
from PyQt4.phonon import Phonon from PyQt4.phonon import Phonon
from openlp.core.lib import Plugin, build_icon, PluginStatus, translate from openlp.core.lib import Plugin, build_icon, translate
from openlp.plugins.media.lib import MediaMediaItem from openlp.plugins.media.lib import MediaMediaItem
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -43,7 +43,6 @@ class MediaPlugin(Plugin):
self.icon = build_icon(self.icon_path) self.icon = build_icon(self.icon_path)
# passed with drag and drop messages # passed with drag and drop messages
self.dnd_id = u'Media' self.dnd_id = u'Media'
self.status = PluginStatus.Active
self.audio_list = u'' self.audio_list = u''
self.video_list = u'' self.video_list = u''
for mimetype in Phonon.BackendCapabilities.availableMimeTypes(): for mimetype in Phonon.BackendCapabilities.availableMimeTypes():

View File

@ -69,8 +69,8 @@ class ImpressController(PresentationController):
""" """
log.debug(u'Initialising') log.debug(u'Initialising')
PresentationController.__init__(self, plugin, u'Impress') PresentationController.__init__(self, plugin, u'Impress')
self.supports = [u'.odp'] self.supports = [u'odp']
self.alsosupports = [u'.ppt', u'.pps', u'.pptx', u'.ppsx'] self.alsosupports = [u'ppt', u'pps', u'pptx', u'ppsx']
self.process = None self.process = None
self.desktop = None self.desktop = None
self.manager = None self.manager = None

View File

@ -79,7 +79,6 @@ class PresentationMediaItem(MediaManagerItem):
'Select Presentation(s)') 'Select Presentation(s)')
self.Automatic = translate('PresentationPlugin.MediaItem', self.Automatic = translate('PresentationPlugin.MediaItem',
'Automatic') 'Automatic')
self.buildFileMaskString()
def buildFileMaskString(self): def buildFileMaskString(self):
""" """
@ -92,7 +91,7 @@ class PresentationMediaItem(MediaManagerItem):
self.controllers[controller].alsosupports self.controllers[controller].alsosupports
for type in types: for type in types:
if fileType.find(type) == -1: if fileType.find(type) == -1:
fileType += u'*%s ' % type fileType += u'*.%s ' % type
self.parent.serviceManager.supportedSuffixes(type) self.parent.serviceManager.supportedSuffixes(type)
self.OnNewFileMasks = translate('PresentationPlugin.MediaItem', self.OnNewFileMasks = translate('PresentationPlugin.MediaItem',
'Presentations (%s)' % fileType) 'Presentations (%s)' % fileType)
@ -189,8 +188,7 @@ class PresentationMediaItem(MediaManagerItem):
translate('PresentationPlugin.MediaItem', translate('PresentationPlugin.MediaItem',
'File Exists'), 'File Exists'),
translate('PresentationPlugin.MediaItem', translate('PresentationPlugin.MediaItem',
'A presentation with that filename already exists.'), 'A presentation with that filename already exists.'))
QtGui.QMessageBox.Ok)
continue continue
controller_name = self.findControllerByType(filename) controller_name = self.findControllerByType(filename)
if controller_name: if controller_name:
@ -214,8 +212,7 @@ class PresentationMediaItem(MediaManagerItem):
self, translate('PresentationPlugin.MediaItem', self, translate('PresentationPlugin.MediaItem',
'Unsupported File'), 'Unsupported File'),
translate('PresentationPlugin.MediaItem', translate('PresentationPlugin.MediaItem',
'This type of presentation is not supported'), 'This type of presentation is not supported'))
QtGui.QMessageBox.Ok)
continue continue
item_name = QtGui.QListWidgetItem(filename) item_name = QtGui.QListWidgetItem(filename)
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file)) item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
@ -288,7 +285,7 @@ class PresentationMediaItem(MediaManagerItem):
"supports" the extension. If none found, then look for a controller "supports" the extension. If none found, then look for a controller
which "alsosupports" it instead. which "alsosupports" it instead.
""" """
filetype = os.path.splitext(filename)[1] filetype = filename.split(u'.')[1]
if not filetype: if not filetype:
return None return None
for controller in self.controllers: for controller in self.controllers:

View File

@ -54,7 +54,7 @@ class PowerpointController(PresentationController):
""" """
log.debug(u'Initialising') log.debug(u'Initialising')
PresentationController.__init__(self, plugin, u'Powerpoint') PresentationController.__init__(self, plugin, u'Powerpoint')
self.supports = [u'.ppt', u'.pps', u'.pptx', u'.ppsx'] self.supports = [u'ppt', u'pps', u'pptx', u'ppsx']
self.process = None self.process = None
def check_available(self): def check_available(self):

View File

@ -50,7 +50,7 @@ class PptviewController(PresentationController):
log.debug(u'Initialising') log.debug(u'Initialising')
self.process = None self.process = None
PresentationController.__init__(self, plugin, u'Powerpoint Viewer') PresentationController.__init__(self, plugin, u'Powerpoint Viewer')
self.supports = [u'.ppt', u'.pps', u'.pptx', u'.ppsx'] self.supports = [u'ppt', u'pps', u'pptx', u'ppsx']
def check_available(self): def check_available(self):
""" """

View File

@ -30,7 +30,7 @@ presentations from a variety of document formats.
import os import os
import logging import logging
from openlp.core.lib import Plugin, build_icon, PluginStatus, translate from openlp.core.lib import Plugin, build_icon, translate
from openlp.core.utils import AppLocation from openlp.core.utils import AppLocation
from openlp.plugins.presentations.lib import PresentationController, \ from openlp.plugins.presentations.lib import PresentationController, \
PresentationMediaItem, PresentationTab PresentationMediaItem, PresentationTab
@ -55,7 +55,6 @@ class PresentationPlugin(Plugin):
self.weight = -8 self.weight = -8
self.icon_path = u':/plugins/plugin_presentations.png' self.icon_path = u':/plugins/plugin_presentations.png'
self.icon = build_icon(self.icon_path) self.icon = build_icon(self.icon_path)
self.status = PluginStatus.Active
def getSettingsTab(self): def getSettingsTab(self):
""" """
@ -74,6 +73,7 @@ class PresentationPlugin(Plugin):
for controller in self.controllers: for controller in self.controllers:
if self.controllers[controller].enabled(): if self.controllers[controller].enabled():
self.controllers[controller].start_process() self.controllers[controller].start_process()
self.mediaItem.buildFileMaskString()
def finalise(self): def finalise(self):
""" """

View File

@ -82,16 +82,14 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
QtGui.QMessageBox.critical( QtGui.QMessageBox.critical(
self, translate('SongsPlugin.AuthorsForm', 'Error'), self, translate('SongsPlugin.AuthorsForm', 'Error'),
translate('SongsPlugin.AuthorsForm', translate('SongsPlugin.AuthorsForm',
'You need to type in the first name of the author.'), 'You need to type in the first name of the author.'))
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
self.FirstNameEdit.setFocus() self.FirstNameEdit.setFocus()
return False return False
elif not self.LastNameEdit.text(): elif not self.LastNameEdit.text():
QtGui.QMessageBox.critical( QtGui.QMessageBox.critical(
self, translate('SongsPlugin.AuthorsForm', 'Error'), self, translate('SongsPlugin.AuthorsForm', 'Error'),
translate('SongsPlugin.AuthorsForm', translate('SongsPlugin.AuthorsForm',
'You need to type in the last name of the author.'), 'You need to type in the last name of the author.'))
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
self.LastNameEdit.setFocus() self.LastNameEdit.setFocus()
return False return False
elif not self.DisplayEdit.text(): elif not self.DisplayEdit.text():

View File

@ -331,8 +331,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
translate('SongsPlugin.EditSongForm', 'You have not selected ' translate('SongsPlugin.EditSongForm', 'You have not selected '
'a valid author. Either select an author from the list, ' 'a valid author. Either select an author from the list, '
'or type in a new author and click the "Add Author to ' 'or type in a new author and click the "Add Author to '
'Song" button to add the new author.'), 'Song" button to add the new author.'))
QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
def onAuthorsListViewPressed(self): def onAuthorsListViewPressed(self):
if self.AuthorsListView.count() > 1: if self.AuthorsListView.count() > 1:
@ -389,8 +388,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
translate('SongsPlugin.EditSongForm', 'You have not selected ' translate('SongsPlugin.EditSongForm', 'You have not selected '
'a valid topic. Either select a topic from the list, or ' 'a valid topic. Either select a topic from the list, or '
'type in a new topic and click the "Add Topic to Song" ' 'type in a new topic and click the "Add Topic to Song" '
'button to add the new topic.'), 'button to add the new topic.'))
QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
def onTopicListViewPressed(self): def onTopicListViewPressed(self):
self.TopicRemoveButton.setEnabled(True) self.TopicRemoveButton.setEnabled(True)

View File

@ -52,8 +52,7 @@ class SongBookForm(QtGui.QDialog, Ui_SongBookDialog):
QtGui.QMessageBox.critical( QtGui.QMessageBox.critical(
self, translate('SongsPlugin.SongBookForm', 'Error'), self, translate('SongsPlugin.SongBookForm', 'Error'),
translate('SongsPlugin.SongBookForm', translate('SongsPlugin.SongBookForm',
'You need to type in a name for the book.'), 'You need to type in a name for the book.'))
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
self.NameEdit.setFocus() self.NameEdit.setFocus()
return False return False
else: else:

View File

@ -109,8 +109,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard):
'No OpenLyrics Files Selected'), 'No OpenLyrics Files Selected'),
translate('SongsPlugin.ImportWizardForm', translate('SongsPlugin.ImportWizardForm',
'You need to add at least one OpenLyrics ' 'You need to add at least one OpenLyrics '
'song file to import from.'), 'song file to import from.'))
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
self.OpenLyricsAddButton.setFocus() self.OpenLyricsAddButton.setFocus()
return False return False
elif source_format == SongFormat.OpenSong: elif source_format == SongFormat.OpenSong:
@ -120,8 +119,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard):
'No OpenSong Files Selected'), 'No OpenSong Files Selected'),
translate('SongsPlugin.ImportWizardForm', translate('SongsPlugin.ImportWizardForm',
'You need to add at least one OpenSong ' 'You need to add at least one OpenSong '
'song file to import from.'), 'song file to import from.'))
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
self.OpenSongAddButton.setFocus() self.OpenSongAddButton.setFocus()
return False return False
elif source_format == SongFormat.CCLI: elif source_format == SongFormat.CCLI:
@ -131,8 +129,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard):
'No CCLI Files Selected'), 'No CCLI Files Selected'),
translate('SongsPlugin.ImportWizardForm', translate('SongsPlugin.ImportWizardForm',
'You need to add at least one CCLI file ' 'You need to add at least one CCLI file '
'to import from.'), 'to import from.'))
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
self.CCLIAddButton.setFocus() self.CCLIAddButton.setFocus()
return False return False
elif source_format == SongFormat.CSV: elif source_format == SongFormat.CSV:
@ -141,8 +138,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard):
translate('SongsPlugin.ImportWizardForm', translate('SongsPlugin.ImportWizardForm',
'No CSV File Selected'), 'No CSV File Selected'),
translate('SongsPlugin.ImportWizardForm', translate('SongsPlugin.ImportWizardForm',
'You need to specify a CSV file to import from.'), 'You need to specify a CSV file to import from.'))
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
self.CSVFilenameEdit.setFocus() self.CSVFilenameEdit.setFocus()
return False return False
return True return True

View File

@ -51,8 +51,7 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
QtGui.QMessageBox.critical( QtGui.QMessageBox.critical(
self, translate('SongsPlugin.TopicsForm', 'Error'), self, translate('SongsPlugin.TopicsForm', 'Error'),
translate('SongsPlugin.TopicsForm', translate('SongsPlugin.TopicsForm',
'You need to type in a topic name!'), 'You need to type in a topic name!'))
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
self.NameEdit.setFocus() self.NameEdit.setFocus()
return False return False
else: else:

View File

@ -28,8 +28,7 @@ import logging
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import Plugin, build_icon, PluginStatus, Receiver, \ from openlp.core.lib import Plugin, build_icon, Receiver, translate
translate
from openlp.core.lib.db import Manager from openlp.core.lib.db import Manager
from openlp.plugins.songs.lib import OpenLPSongImport, SongMediaItem, SongsTab from openlp.plugins.songs.lib import OpenLPSongImport, SongMediaItem, SongsTab
from openlp.plugins.songs.lib.db import init_schema, Song from openlp.plugins.songs.lib.db import init_schema, Song
@ -63,7 +62,6 @@ class SongsPlugin(Plugin):
self.manager = Manager(u'songs', init_schema) self.manager = Manager(u'songs', init_schema)
self.icon_path = u':/plugins/plugin_songs.png' self.icon_path = u':/plugins/plugin_songs.png'
self.icon = build_icon(self.icon_path) self.icon = build_icon(self.icon_path)
self.status = PluginStatus.Active
def getSettingsTab(self): def getSettingsTab(self):
return SongsTab(self.name) return SongsTab(self.name)
@ -200,15 +198,11 @@ class SongsPlugin(Plugin):
except: except:
log.exception('Could not import SoF file') log.exception('Could not import SoF file')
QtGui.QMessageBox.critical(None, QtGui.QMessageBox.critical(None,
translate('SongsPlugin', translate('SongsPlugin', 'Import Error'),
'Import Error'), translate('SongsPlugin', 'Error importing Songs of '
translate('SongsPlugin',
'Error importing Songs of '
'Fellowship file.\nOpenOffice.org must be installed' 'Fellowship file.\nOpenOffice.org must be installed'
' and you must be using an unedited copy of the RTF' ' and you must be using an unedited copy of the RTF'
' included with the Songs of Fellowship Music Editions'), ' included with the Songs of Fellowship Music Editions'))
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok),
QtGui.QMessageBox.Ok)
Receiver.send_message(u'songs_load_list') Receiver.send_message(u'songs_load_list')
def onImportOpenSongItemClick(self): def onImportOpenSongItemClick(self):
@ -223,12 +217,8 @@ class SongsPlugin(Plugin):
except: except:
log.exception('Could not import OpenSong file') log.exception('Could not import OpenSong file')
QtGui.QMessageBox.critical(None, QtGui.QMessageBox.critical(None,
translate('SongsPlugin', translate('SongsPlugin', 'Import Error'),
'Import Error'), translate('SongsPlugin', 'Error importing OpenSong file'))
translate('SongsPlugin',
'Error importing OpenSong file'),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok),
QtGui.QMessageBox.Ok)
Receiver.send_message(u'songs_load_list') Receiver.send_message(u'songs_load_list')
def onImportOpenLPSongItemClick(self): def onImportOpenLPSongItemClick(self):
@ -252,8 +242,7 @@ class SongsPlugin(Plugin):
def onImportOooItemClick(self): def onImportOooItemClick(self):
filenames = QtGui.QFileDialog.getOpenFileNames( filenames = QtGui.QFileDialog.getOpenFileNames(
None, translate('SongsPlugin', None, translate('SongsPlugin', 'Open documents or presentations'),
'Open documents or presentations'),
'', u'All Files(*.*)') '', u'All Files(*.*)')
oooimport = OooImport(self.manager) oooimport = OooImport(self.manager)
oooimport.import_docs(filenames) oooimport.import_docs(filenames)

View File

@ -34,7 +34,7 @@ class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog):
""" """
Class documentation goes here. Class documentation goes here.
""" """
def __init__(self, songusagemanager, parent=None): def __init__(self, songusagemanager, parent):
""" """
Constructor Constructor
""" """

View File

@ -42,12 +42,12 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog):
""" """
log.info(u'SongUsage Detail Form Loaded') log.info(u'SongUsage Detail Form Loaded')
def __init__(self, parent=None): def __init__(self, plugin, parent):
""" """
Initialise the form Initialise the form
""" """
QtGui.QDialog.__init__(self, None) QtGui.QDialog.__init__(self, parent)
self.parent = parent self.plugin = plugin
self.setupUi(self) self.setupUi(self)
def initialise(self): def initialise(self):
@ -59,16 +59,16 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog):
self.fromDate.setSelectedDate(fromDate) self.fromDate.setSelectedDate(fromDate)
self.toDate.setSelectedDate(toDate) self.toDate.setSelectedDate(toDate)
self.fileLineEdit.setText( self.fileLineEdit.setText(
SettingsManager.get_last_dir(self.parent.settingsSection, 1)) SettingsManager.get_last_dir(self.plugin.settingsSection, 1))
def defineOutputLocation(self): def defineOutputLocation(self):
path = QtGui.QFileDialog.getExistingDirectory(self, path = QtGui.QFileDialog.getExistingDirectory(self,
translate('SongUsagePlugin.SongUsageDetailForm', translate('SongUsagePlugin.SongUsageDetailForm',
'Output File Location'), 'Output File Location'),
SettingsManager.get_last_dir(self.parent.settingsSection, 1)) SettingsManager.get_last_dir(self.plugin.settingsSection, 1))
path = unicode(path) path = unicode(path)
if path != u'': if path != u'':
SettingsManager.set_last_dir(self.parent.settingsSection, path, 1) SettingsManager.set_last_dir(self.plugin.settingsSection, path, 1)
self.fileLineEdit.setText(path) self.fileLineEdit.setText(path)
def accept(self): def accept(self):
@ -76,7 +76,7 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog):
filename = u'usage_detail_%s_%s.txt' % ( filename = u'usage_detail_%s_%s.txt' % (
self.fromDate.selectedDate().toString(u'ddMMyyyy'), self.fromDate.selectedDate().toString(u'ddMMyyyy'),
self.toDate.selectedDate().toString(u'ddMMyyyy')) self.toDate.selectedDate().toString(u'ddMMyyyy'))
usage = self.parent.songusagemanager.get_all_objects( usage = self.plugin.songusagemanager.get_all_objects(
SongUsageItem, and_( SongUsageItem, and_(
SongUsageItem.usagedate >= self.fromDate.selectedDate().toPyDate(), SongUsageItem.usagedate >= self.fromDate.selectedDate().toPyDate(),
SongUsageItem.usagedate < self.toDate.selectedDate().toPyDate()), SongUsageItem.usagedate < self.toDate.selectedDate().toPyDate()),
@ -95,3 +95,4 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog):
finally: finally:
if file: if file:
file.close() file.close()
self.close()

View File

@ -117,8 +117,9 @@ class SongUsagePlugin(Plugin):
self.SongUsageStatus.setChecked(self.SongUsageActive) self.SongUsageStatus.setChecked(self.SongUsageActive)
if self.songusagemanager is None: if self.songusagemanager is None:
self.songusagemanager = Manager(u'songusage', init_schema) self.songusagemanager = Manager(u'songusage', init_schema)
self.SongUsagedeleteform = SongUsageDeleteForm(self.songusagemanager) self.SongUsagedeleteform = SongUsageDeleteForm(self.songusagemanager,
self.SongUsagedetailform = SongUsageDetailForm(self) self.formparent)
self.SongUsagedetailform = SongUsageDetailForm(self, self.formparent)
self.SongUsageMenu.menuAction().setVisible(True) self.SongUsageMenu.menuAction().setVisible(True)
def finalise(self): def finalise(self):