forked from openlp/openlp
Dock Widget Refactoring
bzr-revno: 554
This commit is contained in:
commit
de9e843c04
@ -121,6 +121,7 @@ from serviceitem import ServiceItem
|
||||
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
|
||||
|
53
openlp/core/lib/dockwidget.py
Normal file
53
openlp/core/lib/dockwidget.py
Normal file
@ -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())
|
@ -62,17 +62,17 @@ class SettingsManager(object):
|
||||
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',
|
||||
|
@ -31,20 +31,11 @@ from openlp.core.ui import AboutForm, SettingsForm, AlertForm, \
|
||||
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 @@ class Ui_MainWindow(object):
|
||||
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 @@ class Ui_MainWindow(object):
|
||||
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 @@ class Ui_MainWindow(object):
|
||||
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 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
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 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
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 toggleMediaManager(self, visible):
|
||||
if self.MediaManagerDock.isVisible() != visible:
|
||||
self.MediaManagerDock.setVisible(visible)
|
||||
self.settingsmanager.setUIItemVisibility(
|
||||
self.MediaManagerDock.objectName(), visible)
|
||||
|
||||
def toggleServiceManager(self):
|
||||
serviceBool = self.ServiceManagerDock.isVisible()
|
||||
self.ServiceManagerDock.setVisible(not serviceBool)
|
||||
self.settingsmanager.toggleServiceManager(not serviceBool)
|
||||
def toggleServiceManager(self, visible):
|
||||
if self.ServiceManagerDock.isVisible() != visible:
|
||||
self.ServiceManagerDock.setVisible(visible)
|
||||
self.settingsmanager.setUIItemVisibility(
|
||||
self.ServiceManagerDock.objectName(), visible)
|
||||
|
||||
def toggleThemeManager(self):
|
||||
themeBool = self.ThemeManagerDock.isVisible()
|
||||
self.ThemeManagerDock.setVisible(not themeBool)
|
||||
self.settingsmanager.toggleThemeManager(not themeBool)
|
||||
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()
|
||||
|
Loading…
Reference in New Issue
Block a user