From 8f0d30c48b28e83c76ee99c78938e13e72ac39f5 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 31 Jul 2010 01:34:37 +0100 Subject: [PATCH] Fix plugin forms --- openlp/core/lib/plugin.py | 1 + openlp/core/ui/mainwindow.py | 1 + openlp/plugins/alerts/alertsplugin.py | 2 +- openlp/plugins/alerts/forms/alertform.py | 5 ++--- .../songusage/forms/songusagedeleteform.py | 2 +- .../songusage/forms/songusagedetailform.py | 15 ++++++++------- openlp/plugins/songusage/songusageplugin.py | 5 +++-- 7 files changed, 17 insertions(+), 14 deletions(-) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 7105cfa82..45fb12ec4 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -133,6 +133,7 @@ class Plugin(QtCore.QObject): self.mediadock = plugin_helpers[u'toolbox'] self.displayManager = plugin_helpers[u'displaymanager'] self.pluginManager = plugin_helpers[u'pluginmanager'] + self.formparent = plugin_helpers[u'formparent'] QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_add_service_item' % self.name), self.processAddServiceEvent) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 4a3d22b29..6f1a1f6c1 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -607,6 +607,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.plugin_helpers[u'toolbox'] = self.mediaDockManager self.plugin_helpers[u'displaymanager'] = self.displayManager self.plugin_helpers[u'pluginmanager'] = self.plugin_manager + self.plugin_helpers[u'formparent'] = self self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers) # hook methods have to happen after find_plugins. Find plugins needs # the controllers hence the hooks have moved from setupUI() to here diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 0e4f868cc..05b973397 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -45,7 +45,7 @@ class AlertsPlugin(Plugin): self.icon = build_icon(u':/plugins/plugin_alerts.png') self.alertsmanager = AlertsManager(self) self.manager = Manager(u'alerts', init_schema) - self.alertForm = AlertForm(self.manager, self) + self.alertForm = AlertForm(self.manager, self.formparent) def getSettingsTab(self): """ diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index ddc7a3743..7e9293845 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -40,9 +40,8 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): Initialise the alert form """ self.manager = manager - self.parent = parent self.item_id = None - QtGui.QDialog.__init__(self, None) + QtGui.QDialog.__init__(self, parent) self.setupUi(self) QtCore.QObject.connect(self.DisplayButton, QtCore.SIGNAL(u'clicked()'), self.onDisplayClicked) @@ -153,6 +152,6 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): def triggerAlert(self, text): if text: text = text.replace(u'<>', unicode(self.ParameterEdit.text())) - self.parent.alertsmanager.displayAlert(text) + self.parent().alertsmanager.displayAlert(text) return True return False diff --git a/openlp/plugins/songusage/forms/songusagedeleteform.py b/openlp/plugins/songusage/forms/songusagedeleteform.py index 637916aff..36eda98b2 100644 --- a/openlp/plugins/songusage/forms/songusagedeleteform.py +++ b/openlp/plugins/songusage/forms/songusagedeleteform.py @@ -34,7 +34,7 @@ class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog): """ Class documentation goes here. """ - def __init__(self, songusagemanager, parent=None): + def __init__(self, songusagemanager, parent): """ Constructor """ diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index 8ff44bfe4..b1668990b 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -42,12 +42,12 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): """ log.info(u'SongUsage Detail Form Loaded') - def __init__(self, parent=None): + def __init__(self, plugin, parent): """ Initialise the form """ - QtGui.QDialog.__init__(self, None) - self.parent = parent + QtGui.QDialog.__init__(self, parent) + self.plugin = plugin self.setupUi(self) def initialise(self): @@ -59,16 +59,16 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): self.fromDate.setSelectedDate(fromDate) self.toDate.setSelectedDate(toDate) self.fileLineEdit.setText( - SettingsManager.get_last_dir(self.parent.settingsSection, 1)) + SettingsManager.get_last_dir(self.plugin.settingsSection, 1)) def defineOutputLocation(self): path = QtGui.QFileDialog.getExistingDirectory(self, translate('SongUsagePlugin.SongUsageDetailForm', 'Output File Location'), - SettingsManager.get_last_dir(self.parent.settingsSection, 1)) + SettingsManager.get_last_dir(self.plugin.settingsSection, 1)) path = unicode(path) 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) def accept(self): @@ -76,7 +76,7 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): filename = u'usage_detail_%s_%s.txt' % ( self.fromDate.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.usagedate >= self.fromDate.selectedDate().toPyDate(), SongUsageItem.usagedate < self.toDate.selectedDate().toPyDate()), @@ -95,3 +95,4 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): finally: if file: file.close() + self.close() diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index 57448b321..0ec82d15f 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -117,8 +117,9 @@ class SongUsagePlugin(Plugin): self.SongUsageStatus.setChecked(self.SongUsageActive) if self.songusagemanager is None: self.songusagemanager = Manager(u'songusage', init_schema) - self.SongUsagedeleteform = SongUsageDeleteForm(self.songusagemanager) - self.SongUsagedetailform = SongUsageDetailForm(self) + self.SongUsagedeleteform = SongUsageDeleteForm(self.songusagemanager, + self.formparent) + self.SongUsagedetailform = SongUsageDetailForm(self, self.formparent) self.SongUsageMenu.menuAction().setVisible(True) def finalise(self):