Plugin List Combo boxhandling finished

This commit is contained in:
Tim Bentley 2009-10-03 08:25:41 +01:00
parent 0408a0a320
commit 37a9b5fb4e
4 changed files with 36 additions and 28 deletions

View File

@ -11,6 +11,20 @@ import logging
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate, PluginStatus, buildIcon 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): class PluginForm(QtGui.QDialog):
global log global log
log = logging.getLogger(u'PluginForm') log = logging.getLogger(u'PluginForm')
@ -18,6 +32,7 @@ class PluginForm(QtGui.QDialog):
def __init__(self, parent=None): def __init__(self, parent=None):
QtGui.QDialog.__init__(self, parent) QtGui.QDialog.__init__(self, parent)
self.parent = parent self.parent = parent
self.activePlugin = None
self.setupUi(self) self.setupUi(self)
log.debug(u'Defined') log.debug(u'Defined')
@ -57,7 +72,6 @@ class PluginForm(QtGui.QDialog):
self.AboutTextLabel.setWordWrap(True) self.AboutTextLabel.setWordWrap(True)
self.AboutTextLabel.setObjectName("AboutTextLabel") self.AboutTextLabel.setObjectName("AboutTextLabel")
self.retranslateUi(PluginForm) self.retranslateUi(PluginForm)
QtCore.QObject.connect(self.ButtonBox, QtCore.QObject.connect(self.ButtonBox,
QtCore.SIGNAL(u'accepted()'), PluginForm.close) QtCore.SIGNAL(u'accepted()'), PluginForm.close)
@ -92,13 +106,13 @@ class PluginForm(QtGui.QDialog):
self.PluginViewList.setItem(row, 0, item1) self.PluginViewList.setItem(row, 0, item1)
self.PluginViewList.setItem(row, 1, item2) self.PluginViewList.setItem(row, 1, item2)
if plugin.can_be_disabled(): if plugin.can_be_disabled():
combo = QtGui.QComboBox() combo = PluginCombo(self, plugin)
self.PluginViewList.setCellWidget(row, 2, combo) self.PluginViewList.setCellWidget(row, 2, combo)
combo.addItem(translate(u'PluginForm', u'Active')) combo.addItem(translate(u'PluginForm', u'Active'))
combo.addItem(translate(u'PluginForm', u'Inactive')) combo.addItem(translate(u'PluginForm', u'Inactive'))
QtCore.QObject.connect(combo,
QtCore.SIGNAL(u'activated(int)'), self.statusComboChanged)
combo.setCurrentIndex(int(plugin.status)) combo.setCurrentIndex(int(plugin.status))
QtCore.QObject.connect(combo,
QtCore.SIGNAL(u'currentIndexChanged(int)'), self.statusComboChanged)
self.PluginViewList.setRowHeight(row, 25) self.PluginViewList.setRowHeight(row, 25)
else: else:
item3 = QtGui.QTableWidgetItem( item3 = QtGui.QTableWidgetItem(
@ -117,10 +131,9 @@ class PluginForm(QtGui.QDialog):
self.AboutTextLabel.setText(translate(u'PluginList', text)) self.AboutTextLabel.setText(translate(u'PluginList', text))
def statusComboChanged(self, status): def statusComboChanged(self, status):
row = self.PluginViewList.currentRow() log.debug(u'Combo status changed %s for plugin %s' %(status, self.activePlugin.name))
log.debug(u'Combo status changed %s for row %s' %(status, row)) self.activePlugin.toggle_status(status)
self.parent.plugin_manager.plugins[row].toggle_status(status)
if status == PluginStatus.Active: if status == PluginStatus.Active:
self.parent.plugin_manager.plugins[row].initialise() self.activePlugin.initialise()
else: else:
self.parent.plugin_manager.plugins[row].finalise() self.activePlugin.finalise()

View File

@ -43,7 +43,7 @@ class AuditPlugin(Plugin):
self.weight = -4 self.weight = -4
# Create the plugin icon # Create the plugin icon
self.icon = buildIcon(u':/media/media_image.png') self.icon = buildIcon(u':/media/media_image.png')
self.auditfile = None self.auditmanager = None
def can_be_disabled(self): def can_be_disabled(self):
return True return True
@ -115,9 +115,9 @@ class AuditPlugin(Plugin):
QtCore.QObject.connect(self.AuditReport, QtCore.QObject.connect(self.AuditReport,
QtCore.SIGNAL(u'triggered()'), self.onAuditReport) QtCore.SIGNAL(u'triggered()'), self.onAuditReport)
def get_settings_tab(self): # def get_settings_tab(self):
self.AuditTab = AuditTab() # self.AuditTab = AuditTab()
return self.AuditTab # return self.AuditTab
def initialise(self): def initialise(self):
log.info(u'Plugin Initialising') log.info(u'Plugin Initialising')
@ -128,9 +128,15 @@ class AuditPlugin(Plugin):
self.auditActive = str_to_bool( self.auditActive = str_to_bool(
self.config.get_config(u'audit active', False)) self.config.get_config(u'audit active', False))
self.AuditStatus.setChecked(self.auditActive) self.AuditStatus.setChecked(self.auditActive)
if self.auditmanager is None:
self.auditmanager = AuditManager(self.config) self.auditmanager = AuditManager(self.config)
self.auditdeleteform = AuditDeleteForm(self.auditmanager) self.auditdeleteform = AuditDeleteForm(self.auditmanager)
self.auditdetailform = AuditDetailForm(self.auditmanager) self.auditdetailform = AuditDetailForm(self.auditmanager)
self.AuditMenu.setVisible(True)
def finalise(self):
log.info(u'Plugin Finalise')
self.AuditMenu.setVisible(True)
def toggleAuditState(self): def toggleAuditState(self):
self.auditActive = not self.auditActive self.auditActive = not self.auditActive

View File

@ -44,30 +44,17 @@ class RemoteTab(SettingsTab):
self.RemotePortSpinBox.setObjectName(u'RemotePortSpinBox') self.RemotePortSpinBox.setObjectName(u'RemotePortSpinBox')
self.RemotePortSpinBox.setMaximum(32767) self.RemotePortSpinBox.setMaximum(32767)
self.RemoteModeLayout.addWidget(self.RemotePortSpinBox) self.RemoteModeLayout.addWidget(self.RemotePortSpinBox)
self.RemoteActive = QtGui.QCheckBox(self.RemoteModeGroupBox)
self.RemoteActive.setObjectName(u'RemotePortSpinBox')
self.RemoteModeLayout.addWidget(self.RemoteActive)
self.WarningLabel = QtGui.QLabel(self.RemoteModeGroupBox)
self.WarningLabel.setObjectName(u'WarningLabel')
self.RemoteModeLayout.addWidget(self.WarningLabel)
self.RemoteLayout.setWidget( self.RemoteLayout.setWidget(
0, QtGui.QFormLayout.LabelRole, self.RemoteModeGroupBox) 0, QtGui.QFormLayout.LabelRole, self.RemoteModeGroupBox)
def retranslateUi(self): def retranslateUi(self):
self.RemoteModeGroupBox.setTitle( self.RemoteModeGroupBox.setTitle(
translate(u'RemoteTab', u'Remotes Receiver Port')) translate(u'RemoteTab', u'Remotes Receiver Port'))
self.RemoteActive.setText(translate(u'RemoteTab', 'Remote available:'))
self.WarningLabel.setText(translate(u'RemoteTab',
u'A restart is needed for this change to become effective'))
def load(self): def load(self):
self.RemotePortSpinBox.setValue( self.RemotePortSpinBox.setValue(
int(self.config.get_config(u'remote port', 4316))) int(self.config.get_config(u'remote port', 4316)))
self.RemoteActive.setChecked(
int(self.config.get_config(u'startup', 0)))
def save(self): def save(self):
self.config.set_config( self.config.set_config(
u'remote port', unicode(self.RemotePortSpinBox.value())) u'remote port', unicode(self.RemotePortSpinBox.value()))
self.config.set_config(
u'startup', unicode(self.RemoteActive.checkState()))

View File

@ -34,6 +34,7 @@ class RemotesPlugin(Plugin):
# Call the parent constructor # Call the parent constructor
Plugin.__init__(self, u'Remotes', u'1.9.0', plugin_helpers) Plugin.__init__(self, u'Remotes', u'1.9.0', plugin_helpers)
self.weight = -1 self.weight = -1
self.server = None
def can_be_disabled(self): def can_be_disabled(self):
return True return True
@ -47,6 +48,7 @@ class RemotesPlugin(Plugin):
def finalise(self): def finalise(self):
log.debug(u'finalise') log.debug(u'finalise')
if self.server is not None:
self.server.close() self.server.close()
def about(self): def about(self):