openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #00371
[Merge] lp:~meths/openlp/trivialfixes into lp:openlp
Jon Tibble has proposed merging lp:~meths/openlp/trivialfixes into lp:openlp.
Requested reviews:
openlp.org Core (openlp-core)
Refactor the dock widget saving
- Fixes issue when using close button on widget the visibility wasn't saved
--
https://code.launchpad.net/~meths/openlp/trivialfixes/+merge/12114
Your team openlp.org Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/__init__.py'
--- openlp/core/lib/__init__.py 2009-09-18 17:37:11 +0000
+++ openlp/core/lib/__init__.py 2009-09-19 11:25:01 +0000
@@ -121,6 +121,7 @@
from serviceitem import ServiceType
from serviceitem import ServiceItem
from toolbar import OpenLPToolbar
+from dockwidget import OpenLPDockWidget
from songxmlhandler import SongXMLBuilder, SongXMLParser
from themexmlhandler import ThemeXML
from renderer import Renderer
=== added file 'openlp/core/lib/dockwidget.py'
--- openlp/core/lib/dockwidget.py 1970-01-01 00:00:00 +0000
+++ openlp/core/lib/dockwidget.py 2009-09-19 11:25:01 +0000
@@ -0,0 +1,53 @@
+# -*- 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 types
+import logging
+
+from PyQt4 import QtCore, QtGui
+
+class OpenLPDockWidget(QtGui.QDockWidget):
+ """
+ Custom DockWidget class to handle events
+ """
+ def __init__(self, parent=None, name=None):
+ """
+ Initialise the DockWidget
+ """
+ QtGui.QDockWidget.__init__(self, parent)
+ self.parent = parent
+ if name is not None:
+ self.setObjectName(name)
+ self.log = logging.getLogger(u'OpenLPDockWidget')
+ self.log.debug(u'Init done')
+
+ def closeEvent(self, event):
+ self.parent.settingsmanager.setUIItemVisibility(
+ self.objectName(), False)
+ event.accept()
+
+ def resizeEvent(self, event):
+ if self.objectName() == u'MediaManagerDock':
+ if event.size().width() != event.oldSize().width():
+ self.parent.settingsmanager.setDockbarLeft(event.size().width())
=== modified file 'openlp/core/lib/settingsmanager.py'
--- openlp/core/lib/settingsmanager.py 2009-09-14 22:10:08 +0000
+++ openlp/core/lib/settingsmanager.py 2009-09-19 11:25:01 +0000
@@ -62,17 +62,17 @@
self.showPreviewPanel = str_to_bool(ConfigHelper.get_config(
u'user interface', u'display previewpanel', True))
- def toggleMediaManager(self, isVisible):
- ConfigHelper.set_config(u'user interface', u'display mediamanager',
- isVisible)
-
- def toggleServiceManager(self, isVisible):
- ConfigHelper.set_config(u'user interface', u'display servicemanager',
- isVisible)
-
- def toggleThemeManager(self, isVisible):
- ConfigHelper.set_config(u'user interface', u'display thememanager',
- isVisible)
+ def setUIItemVisibility(self, item=u'', isVisible=True):
+ if item != u'':
+ if item == u'ThemeManagerDock':
+ ConfigHelper.set_config('user interface',
+ u'display thememanager', isVisible)
+ elif item == u'ServiceManagerDock':
+ ConfigHelper.set_config('user interface',
+ u'display servicemanager', isVisible)
+ elif item == u'MediaManagerDock':
+ ConfigHelper.set_config('user interface',
+ u'display mediamanager', isVisible)
def togglePreviewPanel(self, isVisible):
ConfigHelper.set_config(u'user interface', u'display previewpanel',
=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py 2009-09-18 18:20:58 +0000
+++ openlp/core/ui/mainwindow.py 2009-09-19 11:25:01 +0000
@@ -31,20 +31,11 @@
ServiceManager, ThemeManager, MainDisplay, SlideController, \
PluginForm
from openlp.core.lib import translate, Plugin, MediaManagerItem, \
- SettingsTab, RenderManager, PluginConfig, str_to_bool, \
+ SettingsTab, RenderManager, PluginConfig, str_to_bool, OpenLPDockWidget, \
SettingsManager, PluginManager, Receiver
from openlp.core.utils import ConfigHelper
-class mediaDock(QtGui.QDockWidget):
- def __init__(self, parent=None, name=None):
- QtGui.QDockWidget.__init__(self, parent)
- self.parent = parent
-
- def resizeEvent(self, resizeEvent):
- if resizeEvent.size().width() != resizeEvent.oldSize().width():
- self.parent.settingsmanager.setDockbarLeft(resizeEvent.size().width())
-
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
"""
@@ -116,7 +107,7 @@
self.DefaultThemeLabel.setObjectName(u'DefaultThemeLabel')
self.StatusBar.addPermanentWidget(self.DefaultThemeLabel)
# Create the MediaManager
- self.MediaManagerDock = mediaDock(MainWindow)
+ self.MediaManagerDock = OpenLPDockWidget(MainWindow)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(u':/system/system_mediamanager.png'),
QtGui.QIcon.Normal, QtGui.QIcon.Off)
@@ -146,7 +137,7 @@
QtCore.Qt.DockWidgetArea(1), self.MediaManagerDock)
self.MediaManagerDock.setVisible(self.settingsmanager.showMediaManager)
# Create the service manager
- self.ServiceManagerDock = QtGui.QDockWidget(MainWindow)
+ self.ServiceManagerDock = OpenLPDockWidget(MainWindow)
ServiceManagerIcon = QtGui.QIcon()
ServiceManagerIcon.addPixmap(
QtGui.QPixmap(u':/system/system_servicemanager.png'),
@@ -164,7 +155,7 @@
self.ServiceManagerDock.setVisible(
self.settingsmanager.showServiceManager)
# Create the theme manager
- self.ThemeManagerDock = QtGui.QDockWidget(MainWindow)
+ self.ThemeManagerDock = OpenLPDockWidget(MainWindow)
ThemeManagerIcon = QtGui.QIcon()
ThemeManagerIcon.addPixmap(
QtGui.QPixmap(u':/system/system_thememanager.png'),
@@ -520,13 +511,17 @@
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'update_global_theme'), self.defaultThemeChanged)
QtCore.QObject.connect(self.FileNewItem,
- QtCore.SIGNAL(u'triggered()'), self.ServiceManagerContents.onNewService)
+ QtCore.SIGNAL(u'triggered()'),
+ self.ServiceManagerContents.onNewService)
QtCore.QObject.connect(self.FileOpenItem,
- QtCore.SIGNAL(u'triggered()'), self.ServiceManagerContents.onLoadService)
+ QtCore.SIGNAL(u'triggered()'),
+ self.ServiceManagerContents.onLoadService)
QtCore.QObject.connect(self.FileSaveItem,
- QtCore.SIGNAL(u'triggered()'), self.ServiceManagerContents.onQuickSaveService)
+ QtCore.SIGNAL(u'triggered()'),
+ self.ServiceManagerContents.onQuickSaveService)
QtCore.QObject.connect(self.FileSaveAsItem,
- QtCore.SIGNAL(u'triggered()'), self.ServiceManagerContents.onSaveService)
+ QtCore.SIGNAL(u'triggered()'),
+ self.ServiceManagerContents.onSaveService)
#warning cyclic dependency
#RenderManager needs to call ThemeManager and
#ThemeManager needs to call RenderManager
@@ -673,20 +668,23 @@
def defaultThemeChanged(self, theme):
self.DefaultThemeLabel.setText(self.defaultThemeText + theme)
- def toggleMediaManager(self):
- mediaBool = self.MediaManagerDock.isVisible()
- self.MediaManagerDock.setVisible(not mediaBool)
- self.settingsmanager.toggleMediaManager(not mediaBool)
-
- def toggleServiceManager(self):
- serviceBool = self.ServiceManagerDock.isVisible()
- self.ServiceManagerDock.setVisible(not serviceBool)
- self.settingsmanager.toggleServiceManager(not serviceBool)
-
- def toggleThemeManager(self):
- themeBool = self.ThemeManagerDock.isVisible()
- self.ThemeManagerDock.setVisible(not themeBool)
- self.settingsmanager.toggleThemeManager(not themeBool)
+ def toggleMediaManager(self, visible):
+ if self.MediaManagerDock.isVisible() != visible:
+ self.MediaManagerDock.setVisible(visible)
+ self.settingsmanager.setUIItemVisibility(
+ self.MediaManagerDock.objectName(), visible)
+
+ def toggleServiceManager(self, visible):
+ if self.ServiceManagerDock.isVisible() != visible:
+ self.ServiceManagerDock.setVisible(visible)
+ self.settingsmanager.setUIItemVisibility(
+ self.ServiceManagerDock.objectName(), visible)
+
+ def toggleThemeManager(self, visible):
+ if self.ThemeManagerDock.isVisible() != visible:
+ self.ThemeManagerDock.setVisible(visible)
+ self.settingsmanager.setUIItemVisibility(
+ self.ThemeManagerDock.objectName(), visible)
def togglePreviewPanel(self):
previewBool = self.PreviewController.Panel.isVisible()
Follow ups