From e00eaba8841d786aaa328cd58eaf94ad328818ea Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 12 Apr 2011 18:45:32 +0100 Subject: [PATCH] Settings Cleanup part1 --- openlp/core/lib/plugin.py | 12 +- openlp/core/lib/pluginmanager.py | 3 +- openlp/core/lib/settingstab.py | 4 +- openlp/core/ui/advancedtab.py | 1 + openlp/core/ui/generaltab.py | 1 + openlp/core/ui/settingsdialog.py | 11 +- openlp/core/ui/settingsform.py | 28 +- openlp/core/ui/themestab.py | 3 +- openlp/plugins/alerts/lib/alertstab.py | 4 +- openlp/plugins/bibles/lib/biblestab.py | 4 +- openlp/plugins/custom/lib/customtab.py | 4 +- openlp/plugins/media/lib/mediatab.py | 4 +- .../presentations/lib/presentationtab.py | 4 +- .../presentations/presentationplugin.py | 3 +- openlp/plugins/remotes/lib/remotetab.py | 4 +- openlp/plugins/songs/lib/songstab.py | 4 +- resources/forms/settings.ui | 595 ++---------------- 17 files changed, 94 insertions(+), 595 deletions(-) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index eda8ecfa1..99247c4b9 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -116,7 +116,7 @@ class Plugin(QtCore.QObject): log.info(u'loaded') def __init__(self, name, pluginHelpers=None, mediaItemClass=None, - settingsTabClass=None, version=None): + settings_tab_class=None, version=None): """ This is the constructor for the plugin object. This provides an easy way for descendent plugins to populate common data. This method *must* @@ -138,7 +138,7 @@ class Plugin(QtCore.QObject): ``mediaItemClass`` The class name of the plugin's media item. - ``settingsTabClass`` + ``settings_tab_class`` The class name of the plugin's settings tab. """ QtCore.QObject.__init__(self) @@ -153,7 +153,7 @@ class Plugin(QtCore.QObject): self.settingsSection = self.name.lower() self.icon = None self.mediaItemClass = mediaItemClass - self.settingsTabClass = settingsTabClass + self.settings_tab_class = settings_tab_class self.weight = 0 self.status = PluginStatus.Inactive # Set up logging @@ -248,9 +248,9 @@ class Plugin(QtCore.QObject): Create a tab for the settings window to display the configurable options for this plugin to the user. """ - if self.settingsTabClass: - return self.settingsTabClass(self.name, - self.getString(StringContent.VisibleName)[u'title']) + if self.settings_tab_class: + return self.settings_tab_class(self.name, + self.getString(StringContent.VisibleName)[u'title'], self.icon_path) return None def addToMenu(self, menubar): diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index 9289084c6..ef8287ba7 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -153,8 +153,7 @@ class PluginManager(object): if plugin.settings_tab: log.debug(u'Inserting settings tab item from %s' % visible_title[u'title']) - settingsform.addTab(visible_title[u'title'], - plugin.settings_tab) + settingsform.insertTab(plugin.settings_tab, plugin.weight) else: log.debug( u'No tab settings in %s' % visible_title[u'title']) diff --git a/openlp/core/lib/settingstab.py b/openlp/core/lib/settingstab.py index 1c2ad5fe4..32d7dc912 100644 --- a/openlp/core/lib/settingstab.py +++ b/openlp/core/lib/settingstab.py @@ -31,7 +31,7 @@ class SettingsTab(QtGui.QWidget): SettingsTab is a helper widget for plugins to define Tabs for the settings dialog. """ - def __init__(self, title, visible_title=None): + def __init__(self, title, visible_title=None, icon_path=None): """ Constructor to create the Settings tab item. @@ -45,6 +45,8 @@ class SettingsTab(QtGui.QWidget): self.tabTitle = title self.tabTitleVisible = visible_title self.settingsSection = self.tabTitle.lower() + if icon_path: + self.icon_path = icon_path self.setupUi() self.retranslateUi() self.initialise() diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 07eff396e..cf4c5b9d5 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -44,6 +44,7 @@ class AdvancedTab(SettingsTab): SettingsTab.__init__(self, u'Advanced') self.default_image = u':/graphics/openlp-splash-screen.png' self.default_color = u'#ffffff' + self.icon_path = u':/icon/openlp-logo-16x16.png' def setupUi(self): """ diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index d249dd4e0..279cd8c26 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -44,6 +44,7 @@ class GeneralTab(SettingsTab): self.monitorNumber = 0 # Set to True to allow PostSetup to work on application start up self.overrideChanged = True + self.icon_path = u':/icon/openlp-logo-16x16.png' SettingsTab.__init__(self, u'General') def preLoad(self): diff --git a/openlp/core/ui/settingsdialog.py b/openlp/core/ui/settingsdialog.py index 70f83f4fa..9359ff54c 100644 --- a/openlp/core/ui/settingsdialog.py +++ b/openlp/core/ui/settingsdialog.py @@ -32,16 +32,19 @@ from openlp.core.lib.ui import create_accept_reject_button_box class Ui_SettingsDialog(object): def setupUi(self, settingsDialog): settingsDialog.setObjectName(u'settingsDialog') - settingsDialog.resize(700, 500) + settingsDialog.resize(800, 500) settingsDialog.setWindowIcon( build_icon(u':/system/system_settings.png')) - self.settingsLayout = QtGui.QVBoxLayout(settingsDialog) + self.settingsLayout = QtGui.QGridLayout(settingsDialog) self.settingsLayout.setObjectName(u'settingsLayout') + self.settingListWidget = QtGui.QListWidget(settingsDialog) + self.settingListWidget.setObjectName(u'settingListWidget') + self.settingsLayout.addWidget(self.settingListWidget, 0, 0, 1, 1) self.settingsTabWidget = QtGui.QTabWidget(settingsDialog) self.settingsTabWidget.setObjectName(u'settingsTabWidget') - self.settingsLayout.addWidget(self.settingsTabWidget) + self.settingsLayout.addWidget(self.settingsTabWidget, 0, 1, 1, 1) self.buttonBox = create_accept_reject_button_box(settingsDialog, True) - self.settingsLayout.addWidget(self.buttonBox) + self.settingsLayout.addWidget(self.buttonBox, 1, 1, 1, 1) self.retranslateUi(settingsDialog) QtCore.QMetaObject.connectSlotsByName(settingsDialog) diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index cf66ad090..c145224be 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -28,9 +28,9 @@ The :mod:`settingsform` provides a user interface for the OpenLP settings """ import logging -from PyQt4 import QtGui +from PyQt4 import QtGui, QtCore -from openlp.core.lib import Receiver +from openlp.core.lib import Receiver, build_icon from openlp.core.ui import AdvancedTab, GeneralTab, ThemesTab from settingsdialog import Ui_SettingsDialog @@ -48,20 +48,20 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): self.setupUi(self) # General tab generalTab = GeneralTab(screens) - self.addTab(u'General', generalTab) + self.insertTab(generalTab, 1) # Themes tab themesTab = ThemesTab(mainWindow) - self.addTab(u'Themes', themesTab) + self.insertTab(themesTab, 2) # Advanced tab advancedTab = AdvancedTab() - self.addTab(u'Advanced', advancedTab) + self.insertTab(advancedTab, 3) + + def exec_(self): + # load all the settings + for tabIndex in range(0, self.settingsTabWidget.count()): + self.settingsTabWidget.widget(tabIndex).load() + return QtGui.QDialog.exec_(self) - def addTab(self, name, tab): - """ - Add a tab to the form - """ - log.info(u'Adding %s tab' % tab.tabTitle) - self.settingsTabWidget.addTab(tab, tab.tabTitleVisible) def insertTab(self, tab, location): """ @@ -71,6 +71,12 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): # 14 : There are 3 tables currently and locations starts at -10 self.settingsTabWidget.insertTab( location + 14, tab, tab.tabTitleVisible) + print tab.tabTitleVisible + item_name = QtGui.QListWidgetItem(tab.tabTitleVisible) + icon = build_icon(tab.icon_path) + pixmap = icon.pixmap(QtCore.QSize(88, 50)) + item_name.setIcon(icon) + self.settingListWidget.insertItem(14 + location, item_name) def removeTab(self, tab): """ diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 1415c6810..5d07d0cf7 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -37,6 +37,7 @@ class ThemesTab(SettingsTab): def __init__(self, parent): self.parent = parent SettingsTab.__init__(self, u'Themes') + self.icon_path = u':/themes/theme_new.png' def setupUi(self): self.setObjectName(u'ThemesTab') @@ -201,4 +202,4 @@ class ThemesTab(SettingsTab): if not preview.isNull(): preview = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) - self.DefaultListView.setPixmap(preview) \ No newline at end of file + self.DefaultListView.setPixmap(preview) diff --git a/openlp/plugins/alerts/lib/alertstab.py b/openlp/plugins/alerts/lib/alertstab.py index 64a9801ca..2e97d27d3 100644 --- a/openlp/plugins/alerts/lib/alertstab.py +++ b/openlp/plugins/alerts/lib/alertstab.py @@ -33,8 +33,8 @@ class AlertsTab(SettingsTab): """ AlertsTab is the alerts settings tab in the settings dialog. """ - def __init__(self, name, visible_title): - SettingsTab.__init__(self, name, visible_title) + def __init__(self, name, visible_title, icon_path): + SettingsTab.__init__(self, name, visible_title, icon_path) def setupUi(self): self.setObjectName(u'AlertsTab') diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 914377e35..c2e05363e 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -40,11 +40,11 @@ class BiblesTab(SettingsTab): """ log.info(u'Bible Tab loaded') - def __init__(self, title, visible_title): + def __init__(self, title, visible_title, icon_path): self.paragraph_style = True self.show_new_chapters = False self.display_style = 0 - SettingsTab.__init__(self, title, visible_title) + SettingsTab.__init__(self, title, visible_title, icon_path) def setupUi(self): self.setObjectName(u'BiblesTab') diff --git a/openlp/plugins/custom/lib/customtab.py b/openlp/plugins/custom/lib/customtab.py index 8ab7ade51..006295410 100644 --- a/openlp/plugins/custom/lib/customtab.py +++ b/openlp/plugins/custom/lib/customtab.py @@ -32,8 +32,8 @@ class CustomTab(SettingsTab): """ CustomTab is the Custom settings tab in the settings dialog. """ - def __init__(self, title, visible_title): - SettingsTab.__init__(self, title, visible_title) + def __init__(self, title, visible_title, icon_path): + SettingsTab.__init__(self, title, visible_title, icon_path) def setupUi(self): self.setObjectName(u'CustomTab') diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index 2679ad64f..72085158c 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -32,8 +32,8 @@ class MediaTab(SettingsTab): """ MediaTab is the Media settings tab in the settings dialog. """ - def __init__(self, title, visible_title): - SettingsTab.__init__(self, title, visible_title) + def __init__(self, title, visible_title, icon_path): + SettingsTab.__init__(self, title, visible_title, icon_path) def setupUi(self): self.setObjectName(u'MediaTab') diff --git a/openlp/plugins/presentations/lib/presentationtab.py b/openlp/plugins/presentations/lib/presentationtab.py index 25ad04f82..c7a143006 100644 --- a/openlp/plugins/presentations/lib/presentationtab.py +++ b/openlp/plugins/presentations/lib/presentationtab.py @@ -33,12 +33,12 @@ class PresentationTab(SettingsTab): """ PresentationsTab is the Presentations settings tab in the settings dialog. """ - def __init__(self, title, visible_title, controllers): + def __init__(self, title, visible_title, controllers, icon_path): """ Constructor """ self.controllers = controllers - SettingsTab.__init__(self, title, visible_title) + SettingsTab.__init__(self, title, visible_title, icon_path) def setupUi(self): """ diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 3575bbacd..1da9fe511 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -62,7 +62,7 @@ class PresentationPlugin(Plugin): """ visible_name = self.getString(StringContent.VisibleName) return PresentationTab(self.name, visible_name[u'title'], - self.controllers) + self.controllers, self.icon_path) def initialise(self): """ @@ -71,7 +71,6 @@ class PresentationPlugin(Plugin): """ log.info(u'Presentations Initialising') Plugin.initialise(self) - self.insertToolboxItem() for controller in self.controllers: if self.controllers[controller].enabled(): try: diff --git a/openlp/plugins/remotes/lib/remotetab.py b/openlp/plugins/remotes/lib/remotetab.py index 6d782b503..97aedc9cd 100644 --- a/openlp/plugins/remotes/lib/remotetab.py +++ b/openlp/plugins/remotes/lib/remotetab.py @@ -32,8 +32,8 @@ class RemoteTab(SettingsTab): """ RemoteTab is the Remotes settings tab in the settings dialog. """ - def __init__(self, title, visible_title): - SettingsTab.__init__(self, title, visible_title) + def __init__(self, title, visible_title, icon_path): + SettingsTab.__init__(self, title, visible_title, icon_path) def setupUi(self): self.setObjectName(u'RemoteTab') diff --git a/openlp/plugins/songs/lib/songstab.py b/openlp/plugins/songs/lib/songstab.py index 14aacefdc..092c6af29 100644 --- a/openlp/plugins/songs/lib/songstab.py +++ b/openlp/plugins/songs/lib/songstab.py @@ -32,8 +32,8 @@ class SongsTab(SettingsTab): """ SongsTab is the Songs settings tab in the settings dialog. """ - def __init__(self, title, visible_title): - SettingsTab.__init__(self, title, visible_title) + def __init__(self, title, visible_title, icon_path): + SettingsTab.__init__(self, title, visible_title, icon_path) def setupUi(self): self.setObjectName(u'SongsTab') diff --git a/resources/forms/settings.ui b/resources/forms/settings.ui index 6ad75e1e5..0c378e125 100644 --- a/resources/forms/settings.ui +++ b/resources/forms/settings.ui @@ -14,565 +14,52 @@ Settings - + :/icon/openlp.org-icon-32.bmp:/icon/openlp.org-icon-32.bmp - - - 8 + + + + 10 + 30 + 681 + 441 + - - 8 - - - - - 2 - - - - General - - - - 8 - - - 8 - - - - - - - - Monitors - - - - 8 - - - 8 - - - - - Select monitor for output display: - - - - - - - - Monitor 1 on X11 Windowing System - - - - - Monitor 2 on X11 Windowing System - - - - - - - - - - - Blank Screen - - - - 8 - - - 8 - - - - - Show warning on startup - - - - - - - - - - Auto Open Last Service - - - - - - Automatically open the last service at startup - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - 8 - - - 0 - - - - - CCLI Details - - - - 8 - - - 8 - - - - - CCLI Number: - - - - - - - - - - SongSelect Username: - - - - - - - - - - SongSelect Password: - - - - - - - QLineEdit::Password - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - + + + + + + + + - - - Themes - - - - 8 - - - 8 - - - - - Global theme - - - - 8 - - - 8 - - - - - - African Sunset - - - - - Snowy Mountains - - - - - Wilderness - - - - - - - - - - - - - - Theme level - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - 8 - - - 8 - - - 8 - - - - - Song level - - - - - - - Use the theme from each song in the database. If a song doesn't have a theme associated with it, then use the service's theme. If the service doesn't have a theme, then use the global theme. - - - true - - - - - - - Service level - - - - - - - Use the theme from the service, overriding any of the individual songs' themes. If the service doesn't have a theme, then use the global theme. - - - true - - - - - - - true - - - Global level - - - - - - - Use the global theme, overriding any themes associated with either the service or the songs. - - - true - - - - - - - + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + - - - Alerts - - - - 8 - - - 8 - - - - - - 8 - - - 0 - - - - - Font - - - - 8 - - - 8 - - - - - Font Name: - - - - - - - - - - - - - Font Color: - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Background Color: - - - - - - - - - - - - - - - - - - 8 - - - 0 - - - - - Display length: - - - - - - - 5 - - - s - - - 180 - - - - - - - Qt::Horizontal - - - - 147 - 20 - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 94 - - - - - - - - - - - - 8 - - - 0 - - - - - - 0 - 0 - - - - Preview - - - - 8 - - - 8 - - - - - - 16777215 - 64 - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - + + +