Settings Cleanup part1

This commit is contained in:
Tim Bentley 2011-04-12 18:45:32 +01:00
parent d99a78837c
commit e00eaba884
17 changed files with 94 additions and 595 deletions

View File

@ -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):

View File

@ -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'])

View File

@ -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()

View File

@ -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):
"""

View File

@ -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):

View File

@ -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)

View File

@ -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):
"""

View File

@ -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')

View File

@ -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')

View File

@ -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')

View File

@ -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')

View File

@ -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')

View File

@ -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):
"""

View File

@ -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:

View File

@ -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')

View File

@ -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')

View File

@ -14,565 +14,52 @@
<string>Settings</string>
</property>
<property name="windowIcon">
<iconset resource="../images/openlp-2.qrc">
<iconset>
<normaloff>:/icon/openlp.org-icon-32.bmp</normaloff>:/icon/openlp.org-icon-32.bmp</iconset>
</property>
<layout class="QVBoxLayout" name="SettingsLayout">
<property name="spacing">
<number>8</number>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>681</width>
<height>441</height>
</rect>
</property>
<property name="margin">
<number>8</number>
</property>
<item>
<widget class="QTabWidget" name="SettingsTabWidget">
<property name="currentIndex">
<number>2</number>
</property>
<widget class="QWidget" name="GeneralTab">
<attribute name="title">
<string>General</string>
</attribute>
<layout class="QHBoxLayout" name="GeneralLayout">
<property name="spacing">
<number>8</number>
</property>
<property name="margin">
<number>8</number>
</property>
<item>
<widget class="QWidget" name="GeneralLeftWidget" native="true">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="MonitorGroupBox">
<property name="title">
<string>Monitors</string>
</property>
<layout class="QVBoxLayout" name="MonitorLayout">
<property name="spacing">
<number>8</number>
</property>
<property name="margin">
<number>8</number>
</property>
<item>
<widget class="QLabel" name="MonitorLabel">
<property name="text">
<string>Select monitor for output display:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="MonitorComboBox">
<item>
<property name="text">
<string>Monitor 1 on X11 Windowing System</string>
</property>
</item>
<item>
<property name="text">
<string>Monitor 2 on X11 Windowing System</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="BlankScreenGroupBox">
<property name="title">
<string>Blank Screen</string>
</property>
<layout class="QVBoxLayout" name="BlankScreenLayout">
<property name="spacing">
<number>8</number>
</property>
<property name="margin">
<number>8</number>
</property>
<item>
<widget class="QCheckBox" name="WarningCheckBox">
<property name="text">
<string>Show warning on startup</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="AutoOpenGroupBox">
<property name="title">
<string>Auto Open Last Service</string>
</property>
<layout class="QVBoxLayout" name="AutoOpenLayout">
<item>
<widget class="QCheckBox" name="AutoOpenCheckBox">
<property name="text">
<string>Automatically open the last service at startup</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="GeneralLeftSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="GeneralRightWidget" native="true">
<layout class="QVBoxLayout" name="GeneralRightLayout">
<property name="spacing">
<number>8</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="CCLIGroupBox">
<property name="title">
<string>CCLI Details</string>
</property>
<layout class="QGridLayout" name="CCLILayout">
<property name="margin">
<number>8</number>
</property>
<property name="spacing">
<number>8</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="NumberLabel">
<property name="text">
<string>CCLI Number:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="NumberEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="UsernameLabel">
<property name="text">
<string>SongSelect Username:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="UsernameEdit"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="PasswordLabel">
<property name="text">
<string>SongSelect Password:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="PasswordEdit">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="GeneralRightSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QListWidget" name="settingListWidget"/>
</item>
<item row="0" column="1">
<widget class="QStackedWidget" name="tagStackedWidget">
<widget class="QWidget" name="page"/>
<widget class="QWidget" name="page_2"/>
</widget>
<widget class="QWidget" name="ThemesTab">
<attribute name="title">
<string>Themes</string>
</attribute>
<layout class="QHBoxLayout" name="ThemesTabLayout">
<property name="spacing">
<number>8</number>
</property>
<property name="margin">
<number>8</number>
</property>
<item>
<widget class="QGroupBox" name="GlobalGroupBox">
<property name="title">
<string>Global theme</string>
</property>
<layout class="QVBoxLayout" name="GlobalGroupBoxLayout">
<property name="spacing">
<number>8</number>
</property>
<property name="margin">
<number>8</number>
</property>
<item>
<widget class="QComboBox" name="DefaultComboBox">
<item>
<property name="text">
<string>African Sunset</string>
</property>
</item>
<item>
<property name="text">
<string>Snowy Mountains</string>
</property>
</item>
<item>
<property name="text">
<string>Wilderness</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QListView" name="DefaultListView"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="LevelGroupBox">
<property name="title">
<string>Theme level</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="labelAlignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="formAlignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="horizontalSpacing">
<number>8</number>
</property>
<property name="verticalSpacing">
<number>8</number>
</property>
<property name="margin">
<number>8</number>
</property>
<item row="0" column="0">
<widget class="QRadioButton" name="SongLevelRadioButton">
<property name="text">
<string>Song level</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="SongLevelLabel">
<property name="text">
<string>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.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="ServiceLevelRadioButton">
<property name="text">
<string>Service level</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="ServiceLevelLabel">
<property name="text">
<string>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.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="GlobalLevelRadioButton">
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Global level</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="GlobalLevelLabel">
<property name="text">
<string>Use the global theme, overriding any themes associated with either the service or the songs.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item row="1" column="1">
<widget class="QDialogButtonBox" name="ButtonsBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QWidget" name="AlertsTab">
<attribute name="title">
<string>Alerts</string>
</attribute>
<layout class="QHBoxLayout" name="AlertsLayout">
<property name="spacing">
<number>8</number>
</property>
<property name="margin">
<number>8</number>
</property>
<item>
<widget class="QWidget" name="AlertLeftColumn" native="true">
<layout class="QVBoxLayout" name="SlideLeftLayout">
<property name="spacing">
<number>8</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="FontGroupBox">
<property name="title">
<string>Font</string>
</property>
<layout class="QVBoxLayout" name="FontLayout">
<property name="spacing">
<number>8</number>
</property>
<property name="margin">
<number>8</number>
</property>
<item>
<widget class="QLabel" name="FontLabel">
<property name="text">
<string>Font Name:</string>
</property>
</widget>
</item>
<item>
<widget class="QFontComboBox" name="FontComboBox"/>
</item>
<item>
<widget class="QWidget" name="ColorWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="FontColorLabel">
<property name="text">
<string>Font Color:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="FontColourButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="ColorSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="BackgroundColorLabel">
<property name="text">
<string>Background Color:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="BackgroundColourButton">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="LengthWidget" native="true">
<layout class="QHBoxLayout" name="LengthLayout">
<property name="spacing">
<number>8</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="LengthLabel">
<property name="text">
<string>Display length:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="LengthSpinBox">
<property name="value">
<number>5</number>
</property>
<property name="suffix">
<string>s</string>
</property>
<property name="maximum">
<number>180</number>
</property>
</widget>
</item>
<item>
<spacer name="LengthSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>147</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="SlideLeftSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>94</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="SlideRightColumn" native="true">
<layout class="QVBoxLayout" name="SlideRightLayout">
<property name="spacing">
<number>8</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="PreviewGroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Preview</string>
</property>
<layout class="QVBoxLayout" name="PreviewLayout">
<property name="spacing">
<number>8</number>
</property>
<property name="margin">
<number>8</number>
</property>
<item>
<widget class="QGraphicsView" name="FontPreview">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>64</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="SlideRightSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="ButtonsBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<resources>
<include location="../images/openlp-2.qrc"/>