Reworked the plugin list dialog.

This commit is contained in:
Raoul Snyman 2009-10-06 23:07:12 +02:00
parent 9a8c045f2b
commit 317fc7875c
6 changed files with 335 additions and 119 deletions

View File

@ -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):
"""

View File

@ -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

View File

@ -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()'),

View File

@ -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'))

View File

@ -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()

View File

@ -1,139 +1,142 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PluginViewDialog</class>
<widget class="QWidget" name="PluginViewDialog">
<widget class="QDialog" name="PluginViewDialog">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>568</height>
<width>554</width>
<height>344</height>
</rect>
</property>
<property name="windowTitle">
<string>Plugin list</string>
</property>
<widget class="QTableWidget" name="PluginViewList">
<property name="geometry">
<rect>
<x>20</x>
<y>10</y>
<width>371</width>
<height>261</height>
</rect>
<layout class="QVBoxLayout" name="PluginLayout">
<property name="spacing">
<number>8</number>
</property>
<property name="showGrid">
<bool>false</bool>
<property name="margin">
<number>8</number>
</property>
<property name="gridStyle">
<enum>Qt::SolidLine</enum>
</property>
<property name="rowCount">
<number>1</number>
</property>
<attribute name="horizontalHeaderVisible">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderCascadingSectionResizes">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderCascadingSectionResizes">
<bool>false</bool>
</attribute>
<row/>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Version</string>
</property>
</column>
<column>
<property name="text">
<string>Status</string>
</property>
</column>
<item row="0" column="0">
<property name="text">
<string>qqq</string>
</property>
<item>
<layout class="QHBoxLayout" name="ListLayout">
<property name="spacing">
<number>8</number>
</property>
<item>
<widget class="QListWidget" name="PluginListWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>192</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="PluginInfoGroupBox">
<property name="title">
<string>Plugin Details</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="flat">
<bool>false</bool>
</property>
<layout class="QFormLayout" name="PluginInfoLayout">
<property name="horizontalSpacing">
<number>8</number>
</property>
<property name="verticalSpacing">
<number>8</number>
</property>
<property name="margin">
<number>8</number>
</property>
<item row="1" column="0">
<widget class="QLabel" name="VersionLabel">
<property name="text">
<string>Version:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="VersionNumberLabel">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="AboutLabel">
<property name="text">
<string>About:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="StatusLabel">
<property name="text">
<string>Status:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBox">
<item>
<property name="text">
<string>Disabled</string>
</property>
</item>
<item>
<property name="text">
<string>Inactive</string>
</property>
</item>
<item>
<property name="text">
<string>Active</string>
</property>
</item>
</widget>
</item>
<item row="2" column="1">
<widget class="QTextBrowser" name="AboutTextBrowser">
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<property name="text">
<string>aaa</string>
</property>
<item>
<widget class="QDialogButtonBox" name="PluginListButtonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="2">
<property name="text">
<string>ccc</string>
</property>
</item>
</widget>
<widget class="QDialogButtonBox" name="ButtonBox">
<property name="geometry">
<rect>
<x>220</x>
<y>530</y>
<width>170</width>
<height>25</height>
</rect>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QGroupBox" name="PluginInfoGroupBox">
<property name="geometry">
<rect>
<x>20</x>
<y>270</y>
<width>371</width>
<height>241</height>
</rect>
</property>
<property name="title">
<string>GroupBox</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="flat">
<bool>false</bool>
</property>
<widget class="QLabel" name="AboutTextLabel">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>351</width>
<height>191</height>
</rect>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</widget>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>ButtonBox</sender>
<sender>PluginListButtonBox</sender>
<signal>accepted()</signal>
<receiver>PluginViewDialog</receiver>
<slot>close()</slot>