forked from openlp/openlp
Start of Active / Inactive work
This commit is contained in:
parent
e25c9937c7
commit
0408a0a320
@ -31,8 +31,9 @@ class PluginStatus(object):
|
||||
"""
|
||||
Defines the status of the plugin
|
||||
"""
|
||||
Active = 1
|
||||
Inactive = 2
|
||||
Active = 0
|
||||
Inactive = 1
|
||||
Disabled = 2
|
||||
|
||||
class Plugin(object):
|
||||
"""
|
||||
@ -85,17 +86,6 @@ class Plugin(object):
|
||||
``about()``
|
||||
Used in the plugin manager, when a person clicks on the 'About' button.
|
||||
|
||||
``save(data)``
|
||||
A method to convert the plugin's data to a string to be stored in the
|
||||
Service file.
|
||||
|
||||
``load(string)``
|
||||
A method to convert the string from a Service file into the plugin's
|
||||
own data format.
|
||||
|
||||
``render(theme, screen_number)``
|
||||
A method used to render something to the screen, given the current theme
|
||||
and screen number.
|
||||
"""
|
||||
global log
|
||||
log = logging.getLogger(u'Plugin')
|
||||
@ -157,6 +147,20 @@ class Plugin(object):
|
||||
"""
|
||||
return False
|
||||
|
||||
def set_status(self):
|
||||
"""
|
||||
Sets the status of the plugin
|
||||
"""
|
||||
self.status = self.config.get_config(\
|
||||
u'%s_status' % self.name, PluginStatus.Inactive)
|
||||
|
||||
def toggle_status(self, new_status):
|
||||
"""
|
||||
Changes the status of the plugin and remembers it
|
||||
"""
|
||||
self.status = new_status
|
||||
self.config.set_config(u'%s_status' % self.name, self.status)
|
||||
|
||||
def get_media_manager_item(self):
|
||||
"""
|
||||
Construct a MediaManagerItem object with all the buttons and things
|
||||
|
@ -105,7 +105,12 @@ class PluginManager(object):
|
||||
for plugin in plugins_list:
|
||||
if plugin.check_pre_conditions():
|
||||
log.debug(u'Plugin %s active', unicode(plugin.name))
|
||||
if plugin.can_be_disabled():
|
||||
plugin.set_status()
|
||||
else:
|
||||
plugin.status = PluginStatus.Active
|
||||
else:
|
||||
plugin.status = PluginStatus.Disabled
|
||||
self.plugins.append(plugin)
|
||||
|
||||
def order_by_weight(self, x, y):
|
||||
@ -129,13 +134,14 @@ class PluginManager(object):
|
||||
The Media Manager itself.
|
||||
"""
|
||||
for plugin in self.plugins:
|
||||
if plugin.status == PluginStatus.Active:
|
||||
media_manager_item = plugin.get_media_manager_item()
|
||||
if media_manager_item is not None:
|
||||
log.debug(u'Inserting media manager item from %s' % \
|
||||
plugin.name)
|
||||
mediatoolbox.addItem(media_manager_item, plugin.icon,
|
||||
media_manager_item.title)
|
||||
if plugin.status == PluginStatus.Inactive:
|
||||
media_manager_item.hide()
|
||||
|
||||
def hook_settings_tabs(self, settingsform=None):
|
||||
"""
|
||||
@ -163,8 +169,9 @@ class PluginManager(object):
|
||||
The Import menu.
|
||||
"""
|
||||
for plugin in self.plugins:
|
||||
if plugin.status == PluginStatus.Active:
|
||||
plugin.add_import_menu_item(import_menu)
|
||||
if plugin.status == PluginStatus.Inactive:
|
||||
import_menu.hide()
|
||||
|
||||
def hook_export_menu(self, export_menu):
|
||||
"""
|
||||
@ -175,8 +182,9 @@ class PluginManager(object):
|
||||
The Export menu.
|
||||
"""
|
||||
for plugin in self.plugins:
|
||||
if plugin.status == PluginStatus.Active:
|
||||
plugin.add_export_menu_item(export_menu)
|
||||
if plugin.status == PluginStatus.Inactive:
|
||||
export_menu.hide()
|
||||
|
||||
def hook_tools_menu(self, tools_menu):
|
||||
"""
|
||||
@ -187,8 +195,9 @@ class PluginManager(object):
|
||||
The Tools menu.
|
||||
"""
|
||||
for plugin in self.plugins:
|
||||
if plugin.status == PluginStatus.Active:
|
||||
plugin.add_tools_menu_item(tools_menu)
|
||||
if plugin.status == PluginStatus.Inactive:
|
||||
tools_menu.hide()
|
||||
|
||||
def initialise_plugins(self):
|
||||
"""
|
||||
|
@ -96,7 +96,9 @@ class PluginForm(QtGui.QDialog):
|
||||
self.PluginViewList.setCellWidget(row, 2, combo)
|
||||
combo.addItem(translate(u'PluginForm', u'Active'))
|
||||
combo.addItem(translate(u'PluginForm', u'Inactive'))
|
||||
# if plugin.status == PluginStatus.Active:
|
||||
QtCore.QObject.connect(combo,
|
||||
QtCore.SIGNAL(u'activated(int)'), self.statusComboChanged)
|
||||
combo.setCurrentIndex(int(plugin.status))
|
||||
self.PluginViewList.setRowHeight(row, 25)
|
||||
else:
|
||||
item3 = QtGui.QTableWidgetItem(
|
||||
@ -114,3 +116,11 @@ class PluginForm(QtGui.QDialog):
|
||||
if text is not None:
|
||||
self.AboutTextLabel.setText(translate(u'PluginList', text))
|
||||
|
||||
def statusComboChanged(self, status):
|
||||
row = self.PluginViewList.currentRow()
|
||||
log.debug(u'Combo status changed %s for row %s' %(status, row))
|
||||
self.parent.plugin_manager.plugins[row].toggle_status(status)
|
||||
if status == PluginStatus.Active:
|
||||
self.parent.plugin_manager.plugins[row].initialise()
|
||||
else:
|
||||
self.parent.plugin_manager.plugins[row].finalise()
|
||||
|
@ -45,16 +45,8 @@ class AuditPlugin(Plugin):
|
||||
self.icon = buildIcon(u':/media/media_image.png')
|
||||
self.auditfile = None
|
||||
|
||||
def check_pre_conditions(self):
|
||||
"""
|
||||
Check to see if auditing is required
|
||||
"""
|
||||
log.debug(u'check_pre_conditions')
|
||||
#Lets see if audit is required
|
||||
if int(self.config.get_config(u'startup', 0)) == QtCore.Qt.Checked:
|
||||
def can_be_disabled(self):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def add_tools_menu_item(self, tools_menu):
|
||||
"""
|
||||
|
@ -71,4 +71,3 @@ class RemoteTab(SettingsTab):
|
||||
u'remote port', unicode(self.RemotePortSpinBox.value()))
|
||||
self.config.set_config(
|
||||
u'startup', unicode(self.RemoteActive.checkState()))
|
||||
|
||||
|
@ -38,25 +38,16 @@ class RemotesPlugin(Plugin):
|
||||
def can_be_disabled(self):
|
||||
return True
|
||||
|
||||
def check_pre_conditions(self):
|
||||
"""
|
||||
Check to see if remotes is required
|
||||
"""
|
||||
log.debug(u'check_pre_conditions')
|
||||
#Lets see if Remote is required
|
||||
if int(self.config.get_config(u'startup', 0)) == QtCore.Qt.Checked:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def initialise(self):
|
||||
log.debug(u'initialise')
|
||||
self.server = QtNetwork.QUdpSocket()
|
||||
self.server.bind(int(self.config.get_config(u'remote port', 4316)))
|
||||
QtCore.QObject.connect(self.server,
|
||||
QtCore.SIGNAL(u'readyRead()'), self.readData)
|
||||
|
||||
def finalise(self):
|
||||
pass
|
||||
log.debug(u'finalise')
|
||||
self.server.close()
|
||||
|
||||
def about(self):
|
||||
return u'<b>Remote Plugin</b> <br>This plugin provides the ability to send messages to a running version of openlp on a different computer.<br> The Primary use for this would be to send alerts from a creche'
|
||||
@ -78,11 +69,7 @@ class RemotesPlugin(Plugin):
|
||||
log.info(u'Sending event %s ', datagram)
|
||||
pos = datagram.find(u':')
|
||||
event = unicode(datagram[:pos].lower())
|
||||
|
||||
if event == u'alert':
|
||||
Receiver().send_message(u'alert_text', unicode(datagram[pos + 1:]))
|
||||
if event == u'next_slide':
|
||||
Receiver().send_message(u'live_slide_next')
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user