forked from openlp/openlp
Media Itmes now hide them selves correctly
This commit is contained in:
parent
c4f8fc86cd
commit
39a9f8efac
@ -119,6 +119,8 @@ class Plugin(object):
|
||||
self.icon = None
|
||||
self.config = PluginConfig(self.name)
|
||||
self.weight = 0
|
||||
self.media_id = -1
|
||||
self.media_active = False
|
||||
self.status = PluginStatus.Inactive
|
||||
# Set up logging
|
||||
self.log = logging.getLogger(self.name)
|
||||
@ -127,6 +129,7 @@ class Plugin(object):
|
||||
self.render_manager = plugin_helpers[u'render']
|
||||
self.service_manager = plugin_helpers[u'service']
|
||||
self.settings = plugin_helpers[u'settings']
|
||||
self.mediatoolbox = plugin_helpers[u'toolbox']
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'%s_add_service_item'% self.name), self.process_add_service_event)
|
||||
|
||||
@ -236,8 +239,8 @@ class Plugin(object):
|
||||
"""
|
||||
Called by the plugin Manager to initialise anything it needs.
|
||||
"""
|
||||
log.info(u'base class called')
|
||||
pass
|
||||
if self.media_item is not None:
|
||||
self.media_item.initialise()
|
||||
|
||||
def finalise(self):
|
||||
"""
|
||||
@ -245,3 +248,20 @@ class Plugin(object):
|
||||
"""
|
||||
pass
|
||||
|
||||
def remove_toolbox_item(self):
|
||||
"""
|
||||
Called by the plugin to remove toolbar
|
||||
"""
|
||||
if self.media_id is not -1:
|
||||
self.mediatoolbox.removeItem(self.media_id)
|
||||
self.media_active = False
|
||||
|
||||
def insert_toolbox_item(self):
|
||||
"""
|
||||
Called by plugin to replace toolbar
|
||||
"""
|
||||
if self.media_id is not -1:
|
||||
if not self.media_active:
|
||||
self.mediatoolbox.insertItem(
|
||||
self.media_id, self.media_item, self.icon, self.media_item.title)
|
||||
self.media_active = True
|
||||
|
@ -139,10 +139,9 @@ class PluginManager(object):
|
||||
if plugin.media_item is not None:
|
||||
log.debug(u'Inserting media manager item from %s' % \
|
||||
plugin.name)
|
||||
mediatoolbox.addItem(plugin.media_item, plugin.icon,
|
||||
plugin.media_item.title)
|
||||
if plugin.status == PluginStatus.Inactive:
|
||||
plugin.media_item.hide()
|
||||
plugin.media_id = mediatoolbox.addItem(
|
||||
plugin.media_item, plugin.icon, plugin.media_item.title)
|
||||
plugin.media_active = True
|
||||
|
||||
def hook_settings_tabs(self, settingsform=None):
|
||||
"""
|
||||
@ -205,10 +204,11 @@ class PluginManager(object):
|
||||
"""
|
||||
log.info(u'initialising plugins')
|
||||
for plugin in self.plugins:
|
||||
print plugin.name , plugin.media_item
|
||||
if plugin.is_active():
|
||||
plugin.initialise()
|
||||
if plugin.media_item is not None:
|
||||
plugin.media_item.initialise()
|
||||
if plugin.media_item is not None and not plugin.is_active():
|
||||
plugin.remove_toolbox_item()
|
||||
|
||||
def finalise_plugins(self):
|
||||
"""
|
||||
|
@ -109,19 +109,12 @@ class Ui_MainWindow(object):
|
||||
self.MediaManagerDock.setObjectName(u'MediaManagerDock')
|
||||
self.MediaManagerDock.setMinimumWidth(
|
||||
self.settingsmanager.mainwindow_left)
|
||||
|
||||
# self.MediaManagerDock.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Ignored,
|
||||
# QtGui.QSizePolicy.Maximum))
|
||||
# geometry = self.MediaManagerDock.geometry()
|
||||
# geometry.setWidth(self.settingsmanager.mainwindow_left)
|
||||
# self.MediaManagerDock.setGeometry(geometry)
|
||||
# self.MediaManagerDock.setMinimumWidth(10)
|
||||
|
||||
self.MediaManagerContents = QtGui.QWidget()
|
||||
self.MediaManagerContents.setObjectName(u'MediaManagerContents')
|
||||
self.MediaManagerLayout = QtGui.QHBoxLayout(self.MediaManagerContents)
|
||||
self.MediaManagerLayout.setContentsMargins(0, 2, 0, 0)
|
||||
self.MediaManagerLayout.setObjectName(u'MediaManagerLayout')
|
||||
# Create the media toolbox
|
||||
self.MediaToolBox = QtGui.QToolBox(self.MediaManagerContents)
|
||||
self.MediaToolBox.setObjectName(u'MediaToolBox')
|
||||
self.MediaManagerLayout.addWidget(self.MediaToolBox)
|
||||
@ -503,6 +496,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
self.plugin_helpers[u'render'] = self.RenderManager
|
||||
self.plugin_helpers[u'service'] = self.ServiceManagerContents
|
||||
self.plugin_helpers[u'settings'] = self.settingsForm
|
||||
self.plugin_helpers[u'toolbox'] = self.MediaToolBox
|
||||
self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers)
|
||||
# hook methods have to happen after find_plugins. Find plugins needs
|
||||
# the controllers hence the hooks have moved from setupUI() to here
|
||||
@ -528,6 +522,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
log.info(u'Load data from Settings')
|
||||
self.settingsForm.postSetUp()
|
||||
|
||||
|
||||
def getMonitorNumber(self):
|
||||
"""
|
||||
Set up the default behaviour of the monitor configuration in
|
||||
|
@ -113,14 +113,13 @@ class PluginForm(QtGui.QDialog):
|
||||
combo.setCurrentIndex(int(plugin.status))
|
||||
QtCore.QObject.connect(combo,
|
||||
QtCore.SIGNAL(u'currentIndexChanged(int)'), self.statusComboChanged)
|
||||
self.PluginViewList.setRowHeight(row, 25)
|
||||
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, 15)
|
||||
self.PluginViewList.setRowHeight(row, 25)
|
||||
|
||||
def displayAbout(self, item):
|
||||
if item is None:
|
||||
|
@ -121,6 +121,7 @@ class AuditPlugin(Plugin):
|
||||
|
||||
def initialise(self):
|
||||
log.info(u'audit Initialising')
|
||||
Plugin.initialise(self)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'audit_live'), self.onReceiveAudit)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
|
@ -44,9 +44,12 @@ class ImagePlugin(Plugin):
|
||||
|
||||
def initialise(self):
|
||||
log.info(u'Plugin Initialising')
|
||||
Plugin.initialise(self)
|
||||
self.insert_toolbox_item()
|
||||
|
||||
def finalise(self):
|
||||
log.info(u'Plugin Finalise')
|
||||
self.remove_toolbox_item()
|
||||
|
||||
def get_settings_tab(self):
|
||||
self.ImageTab = ImageTab()
|
||||
|
@ -66,6 +66,7 @@ class ImageMediaItem(MediaManagerItem):
|
||||
|
||||
def initialise(self):
|
||||
log.debug(u'initialise')
|
||||
self.ListView.clear()
|
||||
self.ListView.setSelectionMode(
|
||||
QtGui.QAbstractItemView.ExtendedSelection)
|
||||
self.ListView.setIconSize(QtCore.QSize(88,50))
|
||||
|
@ -145,6 +145,7 @@ class SongsPlugin(Plugin):
|
||||
QtCore.SIGNAL(u'triggered()'), self.onExportOpenSongItemClicked)
|
||||
|
||||
def initialise(self):
|
||||
Plugin.initialise(self)
|
||||
self.media_item.displayResultsSong(self.songmanager.get_songs())
|
||||
|
||||
def onImportOpenlp1ItemClick(self):
|
||||
|
Loading…
Reference in New Issue
Block a user