From 317fc7875cf72d068db60db6ba7afe03b68002fc Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Tue, 6 Oct 2009 23:07:12 +0200 Subject: [PATCH] Reworked the plugin list dialog. --- openlp/core/lib/plugin.py | 2 +- openlp/core/ui/__init__.py | 2 +- openlp/core/ui/mainwindow.py | 2 +- openlp/core/ui/plugindialog.py | 117 ++++++++++++ openlp/core/ui/pluginform.py | 96 ++++++++++ resources/forms/plugindialoglistform.ui | 235 ++++++++++++------------ 6 files changed, 335 insertions(+), 119 deletions(-) create mode 100644 openlp/core/ui/plugindialog.py create mode 100644 openlp/core/ui/pluginform.py diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 0e82aa8b5..fbde53ce2 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -171,7 +171,7 @@ class Plugin(object): Returns True or False. """ - return int(self.status ) == int(PluginStatus.Active) + return int(self.status) == PluginStatus.Active def get_media_manager_item(self): """ diff --git a/openlp/core/ui/__init__.py b/openlp/core/ui/__init__.py index 7ffb77463..870286295 100644 --- a/openlp/core/ui/__init__.py +++ b/openlp/core/ui/__init__.py @@ -32,7 +32,7 @@ from generaltab import GeneralTab from themestab import ThemesTab from about import AboutForm from alertform import AlertForm -from plugindialoglistform import PluginForm +from pluginform import PluginForm from settingsform import SettingsForm from servicemanager import ServiceManager from thememanager import ThemeManager diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index d06a78a53..fefc03adc 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -420,7 +420,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.mainDisplay = MainDisplay(self, screens) self.generalConfig = PluginConfig(u'General') self.alertForm = AlertForm(self) - self.pluginForm = PluginForm(self) self.aboutForm = AboutForm(self) self.settingsForm = SettingsForm(self.screenList, self) # Set up the path with plugins @@ -431,6 +430,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.plugin_helpers = {} # Set up the interface self.setupUi(self) + self.pluginForm = PluginForm(self) # Set up signals and slots QtCore.QObject.connect(self.ImportThemeItem, QtCore.SIGNAL(u'triggered()'), diff --git a/openlp/core/ui/plugindialog.py b/openlp/core/ui/plugindialog.py new file mode 100644 index 000000000..ba7491912 --- /dev/null +++ b/openlp/core/ui/plugindialog.py @@ -0,0 +1,117 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2009 Raoul Snyman # +# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten # +# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### + +from PyQt4 import QtCore, QtGui +from openlp.core.lib import translate + +class Ui_PluginViewDialog(object): + def setupUi(self, PluginViewDialog): + PluginViewDialog.setObjectName(u'PluginViewDialog') + PluginViewDialog.setWindowModality(QtCore.Qt.ApplicationModal) + PluginViewDialog.resize(554, 344) + self.PluginLayout = QtGui.QVBoxLayout(PluginViewDialog) + self.PluginLayout.setSpacing(8) + self.PluginLayout.setMargin(8) + self.PluginLayout.setObjectName(u'PluginLayout') + self.ListLayout = QtGui.QHBoxLayout() + self.ListLayout.setSpacing(8) + self.ListLayout.setObjectName(u'ListLayout') + self.PluginListWidget = QtGui.QListWidget(PluginViewDialog) + sizePolicy = QtGui.QSizePolicy( + QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth( + self.PluginListWidget.sizePolicy().hasHeightForWidth()) + self.PluginListWidget.setSizePolicy(sizePolicy) + self.PluginListWidget.setMaximumSize(QtCore.QSize(192, 16777215)) + self.PluginListWidget.setObjectName(u'PluginListWidget') + self.ListLayout.addWidget(self.PluginListWidget) + self.PluginInfoGroupBox = QtGui.QGroupBox(PluginViewDialog) + self.PluginInfoGroupBox.setAlignment( + QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) + self.PluginInfoGroupBox.setFlat(False) + self.PluginInfoGroupBox.setObjectName(u'PluginInfoGroupBox') + self.PluginInfoLayout = QtGui.QFormLayout(self.PluginInfoGroupBox) + self.PluginInfoLayout.setMargin(8) + self.PluginInfoLayout.setSpacing(8) + self.PluginInfoLayout.setObjectName(u'PluginInfoLayout') + self.VersionLabel = QtGui.QLabel(self.PluginInfoGroupBox) + self.VersionLabel.setObjectName(u'VersionLabel') + self.PluginInfoLayout.setWidget( + 1, QtGui.QFormLayout.LabelRole, self.VersionLabel) + self.VersionNumberLabel = QtGui.QLabel(self.PluginInfoGroupBox) + self.VersionNumberLabel.setObjectName(u'VersionNumberLabel') + self.PluginInfoLayout.setWidget( + 1, QtGui.QFormLayout.FieldRole, self.VersionNumberLabel) + self.AboutLabel = QtGui.QLabel(self.PluginInfoGroupBox) + self.AboutLabel.setObjectName(u'AboutLabel') + self.PluginInfoLayout.setWidget( + 2, QtGui.QFormLayout.LabelRole, self.AboutLabel) + self.StatusLabel = QtGui.QLabel(self.PluginInfoGroupBox) + self.StatusLabel.setObjectName(u'StatusLabel') + self.PluginInfoLayout.setWidget( + 0, QtGui.QFormLayout.LabelRole, self.StatusLabel) + self.StatusComboBox = QtGui.QComboBox(self.PluginInfoGroupBox) + self.StatusComboBox.setObjectName(u'StatusComboBox') + self.StatusComboBox.addItem(QtCore.QString()) + self.StatusComboBox.addItem(QtCore.QString()) + self.PluginInfoLayout.setWidget( + 0, QtGui.QFormLayout.FieldRole, self.StatusComboBox) + self.AboutTextBrowser = QtGui.QTextBrowser(self.PluginInfoGroupBox) + self.AboutTextBrowser.setTextInteractionFlags( + QtCore.Qt.LinksAccessibleByMouse) + self.AboutTextBrowser.setObjectName(u'AboutTextBrowser') + self.PluginInfoLayout.setWidget( + 2, QtGui.QFormLayout.FieldRole, self.AboutTextBrowser) + self.ListLayout.addWidget(self.PluginInfoGroupBox) + self.PluginLayout.addLayout(self.ListLayout) + self.PluginListButtonBox = QtGui.QDialogButtonBox(PluginViewDialog) + self.PluginListButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok) + self.PluginListButtonBox.setObjectName(u'PluginListButtonBox') + self.PluginLayout.addWidget(self.PluginListButtonBox) + + self.retranslateUi(PluginViewDialog) + QtCore.QObject.connect( + self.PluginListButtonBox, + QtCore.SIGNAL(u'accepted()'), + PluginViewDialog.close) + QtCore.QMetaObject.connectSlotsByName(PluginViewDialog) + + def retranslateUi(self, PluginViewDialog): + PluginViewDialog.setWindowTitle( + translate(u'PluginViewDialog', u'Plugin List')) + self.PluginInfoGroupBox.setTitle( + translate(u'PluginViewDialog', u'Plugin Details')) + self.VersionLabel.setText( + translate(u'PluginViewDialog', u'Version:')) + self.VersionNumberLabel.setText( + translate(u'PluginViewDialog', u'TextLabel')) + self.AboutLabel.setText(translate(u'PluginViewDialog', u'About:')) + self.StatusLabel.setText(translate(u'PluginViewDialog', u'Status:')) + self.StatusComboBox.setItemText( + 0, translate(u'PluginViewDialog', u'Active')) + self.StatusComboBox.setItemText( + 1, translate(u'PluginViewDialog', u'Inactive')) + diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py new file mode 100644 index 000000000..4ef941862 --- /dev/null +++ b/openlp/core/ui/pluginform.py @@ -0,0 +1,96 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2009 Raoul Snyman # +# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten # +# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### + +import logging + +from PyQt4 import QtCore, QtGui + +from openlp.core.lib.plugin import PluginStatus +from plugindialog import Ui_PluginViewDialog + +class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): + global log + log = logging.getLogger(u'PluginForm') + + def __init__(self, parent=None): + QtGui.QDialog.__init__(self, parent) + self.parent = parent + self.activePlugin = None + self.setupUi(self) + log.debug(u'Defined') + self.load() + self._clearDetails() + # Right, now let's put some signals and slots together! + QtCore.QObject.connect(self.PluginListWidget, QtCore.SIGNAL(u'currentItemChanged(QListWidgetItem *, QListWidgetItem *)'), self.onPluginListWidgetSelectionChanged) + QtCore.QObject.connect(self.StatusComboBox, QtCore.SIGNAL(u'currentIndexChanged(int)'), self.onStatusComboBoxChanged) + + def load(self): + """ + Load the plugin details into the screen + """ + self.PluginListWidget.clear() + for plugin in self.parent.plugin_manager.plugins: + item = QtGui.QListWidgetItem(self.PluginListWidget) + item.setText(plugin.name) + if plugin.icon is not None: + item.setIcon(plugin.icon) + self.PluginListWidget.addItem(item) + + def _clearDetails(self): + self.StatusComboBox.setCurrentIndex(-1) + self.VersionNumberLabel.setText(u'') + self.AboutTextBrowser.setHtml(u'') + + def _setDetails(self): + self.VersionNumberLabel.setText(self.activePlugin.version) + self.AboutTextBrowser.setHtml(self.activePlugin.about()) + #if not self.activePlugin.can_be_disabled(): + # self.StatusComboBox.setCurrentIndex(0) + # self.StatusComboBox.setEnabled(False) + #else: + #self.StatusComboBox.setEnabled(False) + self.StatusComboBox.setCurrentIndex(int(self.activePlugin.status)) + + def onPluginListWidgetSelectionChanged(self): + if self.PluginListWidget.currentItem() is None: + self._clearDetails() + return + plugin_name = self.PluginListWidget.currentItem().text() + self.activePlugin = None + for plugin in self.parent.plugin_manager.plugins: + if plugin.name == plugin_name: + self.activePlugin = plugin + break + if self.activePlugin is not None: + self._setDetails() + else: + self._clearDetails() + + def onStatusComboBoxChanged(self, status): + log.debug(u'Combo status changed %s for plugin %s' %(status, self.activePlugin.name)) + self.activePlugin.toggle_status(status) + if status == PluginStatus.Active: + self.activePlugin.initialise() + else: + self.activePlugin.finalise() diff --git a/resources/forms/plugindialoglistform.ui b/resources/forms/plugindialoglistform.ui index d8b18e2e4..b95d81f42 100644 --- a/resources/forms/plugindialoglistform.ui +++ b/resources/forms/plugindialoglistform.ui @@ -1,139 +1,142 @@ PluginViewDialog - + + + Qt::ApplicationModal + 0 0 - 400 - 568 + 554 + 344 Plugin list - - - - 20 - 10 - 371 - 261 - + + + 8 - - false + + 8 - - Qt::SolidLine - - - 1 - - - true - - - false - - - true - - - true - - - false - - - true - - - false - - - - - Name - - - - - Version - - - - - Status - - - - - qqq - + + + + 8 + + + + + + 0 + 0 + + + + + 192 + 16777215 + + + + + + + + Plugin Details + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + false + + + + 8 + + + 8 + + + 8 + + + + + Version: + + + + + + + TextLabel + + + + + + + About: + + + + + + + Status: + + + + + + + + Disabled + + + + + Inactive + + + + + Active + + + + + + + + Qt::LinksAccessibleByMouse + + + + + + + - - - aaa - + + + + QDialogButtonBox::Ok + + - - - ccc - - - - - - - 220 - 530 - 170 - 25 - - - - QDialogButtonBox::Ok - - - - - - 20 - 270 - 371 - 241 - - - - GroupBox - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - 10 - 30 - 351 - 191 - - - - TextLabel - - - + - ButtonBox + PluginListButtonBox accepted() PluginViewDialog close()