← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~trb143/openlp/audit into lp:openlp

 

Tim Bentley has proposed merging lp:~trb143/openlp/audit into lp:openlp.

    Requested reviews:
    OpenLP Core (openlp-core)


Following the last merge made some cleanups and simplifications to the process.

The hiding has been stopped for now and I just disable the Media Dock.

-- 
https://code.launchpad.net/~trb143/openlp/audit/+merge/13005
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/plugin.py'
--- openlp/core/lib/plugin.py	2009-10-03 19:02:40 +0000
+++ openlp/core/lib/plugin.py	2009-10-07 16:25:18 +0000
@@ -119,9 +119,6 @@
         self.icon = None
         self.config = PluginConfig(self.name)
         self.weight = 0
-        self.media_id = -1
-        self.settings_id = -1
-        self.media_active = False
         self.status = PluginStatus.Inactive
         # Set up logging
         self.log = logging.getLogger(self.name)
@@ -130,7 +127,7 @@
         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']
+        self.mediadock = plugin_helpers[u'toolbox']
         QtCore.QObject.connect(Receiver.get_receiver(),
             QtCore.SIGNAL(u'%s_add_service_item'% self.name), self.process_add_service_event)
 
@@ -155,8 +152,8 @@
         """
         Sets the status of the plugin
         """
-        self.status = self.config.get_config(\
-            u'%s_status' % self.name, PluginStatus.Inactive)
+        self.status = int(self.config.get_config(\
+            u'%s_status' % self.name, PluginStatus.Inactive))
 
     def toggle_status(self, new_status):
         """
@@ -171,7 +168,7 @@
 
         Returns True or False.
         """
-        return int(self.status ) == int(PluginStatus.Active)
+        return self.status == PluginStatus.Active
 
     def get_media_manager_item(self):
         """
@@ -253,21 +250,12 @@
         """
         Called by the plugin to remove toolbar
         """
-        if self.media_id is not -1:
-            self.mediatoolbox.removeItem(self.media_id)
-        if self.settings_id is not -1:
-            self.settings.removeTab(self.settings_id)
-        self.media_active = False
+        self.mediadock.removeDock(self.name)
+        self.settings.removeTab(self.name)
 
     def insert_toolbox_item(self):
         """
         Called by plugin to replace toolbar
         """
-        if not self.media_active:
-            if self.media_id is not -1:
-                self.mediatoolbox.insertItem(
-                    self.media_id, self.media_item, self.icon, self.media_item.title)
-            if self.settings_id is not -1:
-                self.settings.insertTab(
-                    self.settings_id, self.settings_tab)
-            self.media_active = True
+        self.mediadock.insertDock(self.name)
+        self.settings.insertTab(self.name)

=== modified file 'openlp/core/lib/pluginmanager.py'
--- openlp/core/lib/pluginmanager.py	2009-10-03 19:02:40 +0000
+++ openlp/core/lib/pluginmanager.py	2009-10-07 16:25:18 +0000
@@ -125,7 +125,7 @@
         """
         return cmp(x.weight, y.weight)
 
-    def hook_media_manager(self, mediatoolbox):
+    def hook_media_manager(self, mediadock):
         """
         Loop through all the plugins. If a plugin has a valid media manager
         item, add it to the media manager.
@@ -139,9 +139,8 @@
                 if plugin.media_item is not None:
                     log.debug(u'Inserting media manager item from %s' % \
                         plugin.name)
-                    plugin.media_id = mediatoolbox.addItem(
-                        plugin.media_item, plugin.icon, plugin.media_item.title)
-                    plugin.media_active = True
+                    mediadock.addDock(plugin.name,
+                        plugin.media_item, plugin.icon)
 
     def hook_settings_tabs(self, settingsform=None):
         """
@@ -157,7 +156,7 @@
                 plugin.settings_tab = plugin.get_settings_tab()
                 if plugin.settings_tab is not None:
                     log.debug(u'Inserting settings tab item from %s' % plugin.name)
-                    plugin.settings_id = settingsform.addTab(plugin.settings_tab)
+                    settingsform.addTab(plugin.name, plugin.settings_tab)
                 else:
                     log.debug(u'No tab settings in %s' % plugin.name)
 
@@ -202,11 +201,12 @@
         Loop through all the plugins and give them an opportunity to
         initialise themselves.
         """
-        log.info(u'initialising plugins')
         for plugin in self.plugins:
+            log.info(u'initialising plugins %s in a %s state'
+                % (plugin.name, plugin.is_active()))
             if plugin.is_active():
                 plugin.initialise()
-            if plugin.media_item is not None and not plugin.is_active():
+            if not plugin.is_active():
                 plugin.remove_toolbox_item()
 
     def finalise_plugins(self):

=== modified file 'openlp/core/ui/__init__.py'
--- openlp/core/ui/__init__.py	2009-09-25 00:43:42 +0000
+++ openlp/core/ui/__init__.py	2009-10-07 16:25:18 +0000
@@ -34,10 +34,11 @@
 from alertform import AlertForm
 from plugindialoglistform import PluginForm
 from settingsform import SettingsForm
+from mediadockmanager import MediaDockManager
 from servicemanager import ServiceManager
 from thememanager import ThemeManager
 from mainwindow import MainWindow
 
 __all__ = ['SplashScreen', 'AboutForm', 'SettingsForm', 'MainWindow',
     'MainDisplay', 'SlideController', 'ServiceManager', 'ThemeManager',
-    'AmendThemeForm']
+    'AmendThemeForm', 'MediaDockManager']

=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py	2009-10-03 18:39:44 +0000
+++ openlp/core/ui/mainwindow.py	2009-10-07 16:25:18 +0000
@@ -29,9 +29,10 @@
 
 from openlp.core.ui import AboutForm, SettingsForm, AlertForm, \
     ServiceManager, ThemeManager, MainDisplay, SlideController, \
-    PluginForm
+    PluginForm, MediaDockManager
 from openlp.core.lib import translate, RenderManager, PluginConfig, \
-    OpenLPDockWidget, SettingsManager, PluginManager, Receiver, buildIcon
+    OpenLPDockWidget, SettingsManager, PluginManager, Receiver, \
+    buildIcon
 
 
 class Ui_MainWindow(object):
@@ -489,6 +490,8 @@
         #ThemeManager needs to call RenderManager
         self.RenderManager = RenderManager(self.ThemeManagerContents,
             self.screenList, self.getMonitorNumber())
+        #Define the media Dock Manager
+        self.mediaDockManager = MediaDockManager(self.MediaToolBox)
         log.info(u'Load Plugins')
         #make the controllers available to the plugins
         self.plugin_helpers[u'preview'] = self.PreviewController
@@ -496,7 +499,7 @@
         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_helpers[u'toolbox'] = self.mediaDockManager
         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
@@ -505,7 +508,7 @@
         self.plugin_manager.hook_settings_tabs(self.settingsForm)
         # Find and insert media manager items
         log.info(u'hook media')
-        self.plugin_manager.hook_media_manager(self.MediaToolBox)
+        self.plugin_manager.hook_media_manager(self.mediaDockManager)
         # Call the hook method to pull in import menus.
         log.info(u'hook menus')
         self.plugin_manager.hook_import_menu(self.FileImportMenu)

=== added file 'openlp/core/ui/mediadockmanager.py'
--- openlp/core/ui/mediadockmanager.py	1970-01-01 00:00:00 +0000
+++ openlp/core/ui/mediadockmanager.py	2009-10-07 16:25:18 +0000
@@ -0,0 +1,54 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expanddock textwidth=80 dockstop=4 softdockstop=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 MERCHANdockILITY 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
+
+log = logging.getLogger(u'MediaDockManager')
+
+class MediaDockManager(object):
+
+    def __init__(self, mediaDock):
+        self.mediaDock = mediaDock
+        self.docks = {}
+
+    def addDock(self, name,  media_item, icon):
+        log.info(u'Adding %s dock' % name)
+        id = self.mediaDock.addItem(
+                        media_item, icon, media_item.title)
+        self.docks[name] = (\
+            {u'data':media_item, u'icon':icon, u'id': id, u'active':True})
+
+    def insertDock(self, name):
+        log.debug(u'Inserting %s dock' % name)
+        for tab_index in range(0, self.mediaDock.count()):
+            #print self.mediaDock.widget(tab_index).ConfigSection,  name
+            if self.mediaDock.widget(tab_index).ConfigSection == name.lower():
+                self.mediaDock.setItemEnabled(tab_index, True)
+
+    def removeDock(self, name):
+        log.debug(u'remove %s dock' % name)
+        for tab_index in range(0, self.mediaDock.count()):
+            #print self.mediaDock.widget(tab_index).ConfigSection, name
+            if self.mediaDock.widget(tab_index).ConfigSection == name.lower():
+                self.mediaDock.setItemEnabled(tab_index, False)

=== modified file 'openlp/core/ui/settingsform.py'
--- openlp/core/ui/settingsform.py	2009-10-03 19:02:40 +0000
+++ openlp/core/ui/settingsform.py	2009-10-07 16:25:18 +0000
@@ -35,29 +35,44 @@
 
     def __init__(self, screen_list, mainWindow, parent=None):
         QtGui.QDialog.__init__(self, None)
+        self.tabs = {}
         self.setupUi(self)
         # General tab
         self.GeneralTab = GeneralTab(screen_list)
-        self.addTab(self.GeneralTab)
+        self.addTab(u'General', self.GeneralTab)
         # Themes tab
         self.ThemesTab = ThemesTab(mainWindow)
-        self.addTab(self.ThemesTab)
+        self.addTab(u'Themes', self.ThemesTab)
         # Alert tab
         self.AlertsTab = AlertsTab()
-        self.addTab(self.AlertsTab)
+        self.addTab(u'Alerts', self.AlertsTab)
 
-    def addTab(self, tab):
+    def addTab(self, name,  tab):
         log.info(u'Adding %s tab' % tab.title())
-        return self.SettingsTabWidget.addTab(tab, tab.title())
-
-    def insertTab(self, id, tab):
-        log.debug(u'Inserting %s tab' % tab.title())
-        self.SettingsTabWidget.insertTab(id, tab, tab.title())
-
-    def removeTab(self, id):
-        log.debug(u'remove %s no tab' % unicode(id))
-        self.SettingsTabWidget.removeTab(id)
-
+        id = self.SettingsTabWidget.addTab(tab, tab.title())
+        self.tabs[name] = ({u'data': tab, u'id': id, u'active':True})
+
+    def insertTab(self, name):
+        log.debug(u'Inserting %s tab' % name)
+        for tab_index in range(0, self.SettingsTabWidget.count()):
+            #print self.SettingsTabWidget.widget(tab_index).title()
+            if self.SettingsTabWidget.widget(tab_index).title() == name:
+                #print "Insert match"
+                #print self.SettingsTabWidget.widget(tab_index).isVisible()
+                self.SettingsTabWidget.setTabEnabled(tab_index, True)
+                #print self.SettingsTabWidget.widget(tab_index).isVisible()
+
+
+    def removeTab(self, name):
+        log.debug(u'remove %s tab' % name)
+        #print ">>>>>>>>>>> remove settings"
+        for tab_index in range(0, self.SettingsTabWidget.count()):
+            #print self.SettingsTabWidget.widget(tab_index).title(), name
+            if self.SettingsTabWidget.widget(tab_index).title() == name:
+                #print "remove match"
+                #print self.SettingsTabWidget.widget(tab_index).isVisible()
+                self.SettingsTabWidget.setTabEnabled(tab_index, False)
+                #print self.SettingsTabWidget.widget(tab_index).isVisible()
 
     def accept(self):
         for tab_index in range(0, self.SettingsTabWidget.count()):

=== modified file 'openlp/plugins/images/lib/imagetab.py'
--- openlp/plugins/images/lib/imagetab.py	2009-09-25 00:43:42 +0000
+++ openlp/plugins/images/lib/imagetab.py	2009-10-07 16:25:18 +0000
@@ -31,7 +31,7 @@
     ImageTab is the Image settings tab in the settings dialog.
     """
     def __init__(self):
-        SettingsTab.__init__(self, translate(u'ImageTab', u'Image'), u'Image')
+        SettingsTab.__init__(self, translate(u'ImageTab', u'Images'), u'Image')
 
     def setupUi(self):
         self.setObjectName(u'ImageTab')

=== modified file 'openlp/plugins/media/lib/mediaitem.py'
--- openlp/plugins/media/lib/mediaitem.py	2009-09-26 09:11:39 +0000
+++ openlp/plugins/media/lib/mediaitem.py	2009-10-07 16:25:18 +0000
@@ -46,9 +46,10 @@
         self.TranslationContext = u'MediaPlugin'
         self.IconPath = u'images/image'
         self.PluginTextShort = u'Media'
-        self.ConfigSection = u'images'
+        self.ConfigSection = u'media'
         self.OnNewPrompt = u'Select Media(s)'
-        self.OnNewFileMasks = u'Videos (*.avi *.mpeg *.mpg *.mp4);;Audio (*.ogg *.mp3 *.wma);;All files (*)'
+        self.OnNewFileMasks = \
+            u'Videos (*.avi *.mpeg *.mpg *.mp4);;Audio (*.ogg *.mp3 *.wma);;All files (*)'
         # this next is a class, not an instance of a class - it will
         # be instanced by the base MediaManagerItem
         self.ListViewWithDnD_class = MediaListView

=== modified file 'openlp/plugins/remotes/remoteplugin.py'
--- openlp/plugins/remotes/remoteplugin.py	2009-10-03 07:25:41 +0000
+++ openlp/plugins/remotes/remoteplugin.py	2009-10-07 16:25:18 +0000
@@ -41,6 +41,8 @@
 
     def initialise(self):
         log.debug(u'initialise')
+        Plugin.initialise(self)
+        self.insert_toolbox_item()
         self.server = QtNetwork.QUdpSocket()
         self.server.bind(int(self.config.get_config(u'remote port', 4316)))
         QtCore.QObject.connect(self.server,
@@ -48,6 +50,7 @@
 
     def finalise(self):
         log.debug(u'finalise')
+        self.remove_toolbox_item()
         if self.server is not None:
             self.server.close()
 


Follow ups