diff --git a/openlp/core/ui/__init__.py b/openlp/core/ui/__init__.py index 909fc5f3f..be20e4df1 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 mediadockmanager import MediaDockManager from servicemanager import ServiceManager diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index af30313cf..629269a28 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -421,7 +421,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 @@ -432,6 +431,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/plugindialoglistform.py b/openlp/core/ui/plugindialoglistform.py deleted file mode 100644 index 6d9ca526f..000000000 --- a/openlp/core/ui/plugindialoglistform.py +++ /dev/null @@ -1,138 +0,0 @@ -# -*- coding: utf-8 -*- - -# Form implementation generated from reading ui file 'plugindialoglistform.ui' -# -# Created: Thu Aug 13 05:52:06 2009 -# by: PyQt4 UI code generator 4.5.4 -# -# WARNING! All changes made in this file will be lost! - -import logging -from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, PluginStatus, buildIcon - -class PluginCombo(QtGui.QComboBox): - """ - Customised version of QTableWidget which can respond to keyboard - events. - """ - def __init__(self, parent=None, plugin=None): - QtGui.QComboBox.__init__(self, parent) - self.parent = parent - self.plugin = plugin - - def enterEvent(self, event): - self.parent.activePlugin = self.plugin - event.ignore() - -class PluginForm(QtGui.QDialog): - 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') - - def setupUi(self, PluginForm): - PluginForm.setObjectName(u'PluginForm') - PluginForm.resize(400, 568) - icon = buildIcon(u':/icon/openlp-logo-16x16.png') - PluginForm.setWindowIcon(icon) - self.PluginViewList = QtGui.QTableWidget(PluginForm) - self.PluginViewList.setGeometry(QtCore.QRect(20, 10, 371, 261)) - self.PluginViewList.setObjectName(u'PluginViewList') - self.PluginViewList.setShowGrid(False) - self.PluginViewList.setGridStyle(QtCore.Qt.SolidLine) - self.PluginViewList.setSortingEnabled(False) - self.PluginViewList.setColumnCount(3) - item = QtGui.QTableWidgetItem() - self.PluginViewList.setHorizontalHeaderItem(0, item) - item = QtGui.QTableWidgetItem() - self.PluginViewList.setHorizontalHeaderItem(1, item) - item = QtGui.QTableWidgetItem() - self.PluginViewList.setHorizontalHeaderItem(2, item) - self.PluginViewList.horizontalHeader().setVisible(True) - self.PluginViewList.horizontalHeader().setStretchLastSection(True) - self.PluginViewList.verticalHeader().setVisible(False) - self.ButtonBox = QtGui.QDialogButtonBox(PluginForm) - self.ButtonBox.setGeometry(QtCore.QRect(220, 530, 170, 25)) - self.ButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok) - self.ButtonBox.setObjectName(u'ButtonBox') - self.PluginInfoGroupBox = QtGui.QGroupBox(PluginForm) - self.PluginInfoGroupBox.setGeometry(QtCore.QRect(20, 270, 371, 241)) - self.PluginInfoGroupBox.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) - self.PluginInfoGroupBox.setFlat(False) - self.PluginInfoGroupBox.setObjectName("PluginInfoGroupBox") - self.AboutTextLabel = QtGui.QLabel(self.PluginInfoGroupBox) - self.AboutTextLabel.setGeometry(QtCore.QRect(10, 30, 351, 191)) - self.AboutTextLabel.setAlignment(QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) - self.AboutTextLabel.setWordWrap(True) - self.AboutTextLabel.setObjectName("AboutTextLabel") - - self.retranslateUi(PluginForm) - QtCore.QObject.connect(self.ButtonBox, - QtCore.SIGNAL(u'accepted()'), PluginForm.close) - QtCore.QMetaObject.connectSlotsByName(PluginForm) - QtCore.QObject.connect(self.PluginViewList, - QtCore.SIGNAL(u'itemClicked(QTableWidgetItem*)'), self.displayAbout) - - def retranslateUi(self, PluginForm): - PluginForm.setWindowTitle(translate(u'PluginForm', u'Plugin list')) - self.PluginInfoGroupBox.setTitle(translate("PluginForm", "Selected Plugin Information")) - self.PluginViewList.horizontalHeaderItem(0).setText( - translate(u'PluginForm', u'Name')) - self.PluginViewList.horizontalHeaderItem(1).setText( - translate(u'PluginForm', u'Version')) - self.PluginViewList.horizontalHeaderItem(2).setText( - translate(u'PluginForm', u'Status')) - - def load(self): - """ - Load the plugin details into the screen - """ - self.PluginViewList.setRowCount(0) - for plugin in self.parent.plugin_manager.plugins: - row = self.PluginViewList.rowCount() - self.PluginViewList.setRowCount(row + 1) - item1 = QtGui.QTableWidgetItem(plugin.name) - item1.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) - item1.setTextAlignment(QtCore.Qt.AlignVCenter) - item2 = QtGui.QTableWidgetItem(plugin.version) - item2.setTextAlignment(QtCore.Qt.AlignVCenter) - item2.setFlags(QtCore.Qt.ItemIsSelectable) - self.PluginViewList.setItem(row, 0, item1) - self.PluginViewList.setItem(row, 1, item2) - if plugin.can_be_disabled(): - combo = PluginCombo(self, plugin) - self.PluginViewList.setCellWidget(row, 2, combo) - combo.addItem(translate(u'PluginForm', u'Active')) - combo.addItem(translate(u'PluginForm', u'Inactive')) - combo.setCurrentIndex(int(plugin.status)) - QtCore.QObject.connect(combo, - QtCore.SIGNAL(u'currentIndexChanged(int)'), self.statusComboChanged) - else: - item3 = QtGui.QTableWidgetItem( - translate(u'PluginForm', u'Active')) - item3.setTextAlignment(QtCore.Qt.AlignVCenter) - item3.setFlags(QtCore.Qt.ItemIsSelectable) - self.PluginViewList.setItem(row, 2, item3) - self.PluginViewList.setRowHeight(row, 25) - - def displayAbout(self, item): - if item is None: - return False - row = self.PluginViewList.row(item) - text = self.parent.plugin_manager.plugins[row].about() - if text is not None: - self.AboutTextLabel.setText(translate(u'PluginList', text)) - - def statusComboChanged(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/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py new file mode 100644 index 000000000..4e2a93b7e --- /dev/null +++ b/openlp/core/ui/pluginform.py @@ -0,0 +1,118 @@ +# -*- 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) + self.load() + self._clearDetails() + # Right, now let's put some signals and slots together! + QtCore.QObject.connect( + self.PluginListWidget, + QtCore.SIGNAL(u'itemSelectionChanged()'), + 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) + # 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. + plugin.status = int(plugin.status) + # Set the little status text in brackets next to the plugin name. + status_text = 'Inactive' + if plugin.status == PluginStatus.Active: + status_text = 'Active' + elif plugin.status == PluginStatus.Inactive: + status_text = 'Inactive' + elif plugin.status == PluginStatus.Disabled: + status_text = 'Disabled' + item.setText(u'%s (%s)' % (plugin.name, status_text)) + # If the plugin has an icon, set it! + 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): + log.debug('PluginStatus: %s', str(self.activePlugin.status)) + self.VersionNumberLabel.setText(self.activePlugin.version) + self.AboutTextBrowser.setHtml(self.activePlugin.about()) + 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().split(u' ')[0] + 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): + self.activePlugin.toggle_status(status) + if status == PluginStatus.Active: + self.activePlugin.initialise() + else: + self.activePlugin.finalise() + status_text = 'Inactive' + if self.activePlugin.status == PluginStatus.Active: + status_text = 'Active' + elif self.activePlugin.status == PluginStatus.Inactive: + status_text = 'Inactive' + elif self.activePlugin.status == PluginStatus.Disabled: + status_text = 'Disabled' + self.PluginListWidget.currentItem().setText( + u'%s (%s)' % (self.activePlugin.name, status_text)) + 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()