This commit is contained in:
Tim Bentley 2010-07-11 06:41:17 +01:00
commit 1a2dfc863d
13 changed files with 219 additions and 28 deletions

View File

@ -521,7 +521,7 @@ class MediaManagerItem(QtGui.QWidget):
if self.serviceItemIconName:
service_item.add_icon(self.serviceItemIconName)
else:
service_item.add_icon(self.parent.icon)
service_item.add_icon(self.parent.icon_path)
if self.generateSlideData(service_item, item):
return service_item
else:

View File

@ -117,8 +117,7 @@ class ServiceItem(object):
service item in the service manager.
``icon``
An instance of QIcon or a string to an icon in the resource or on
disk.
A string to an icon in the resources or on disk.
"""
self.icon = icon
self.iconic_representation = build_icon(icon)

View File

@ -49,6 +49,7 @@ from splashscreen import SplashScreen
from displaytab import DisplayTab
from generaltab import GeneralTab
from themestab import ThemesTab
from advancedtab import AdvancedTab
from aboutform import AboutForm
from pluginform import PluginForm
from settingsform import SettingsForm

View File

@ -0,0 +1,162 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2010 Raoul Snyman #
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin #
# Thompson, Jon Tibble, Carsten Tinggaard #
# --------------------------------------------------------------------------- #
# 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 #
###############################################################################
"""
The :mod:`advancedtab` provides an advanced settings facility.
"""
from PyQt4 import QtCore, QtGui
from openlp.core.lib import SettingsTab, translate
class AdvancedTab(SettingsTab):
"""
The :class:`AdvancedTab` manages the advanced settings tab including the UI
and the loading and saving of the displayed settings.
"""
def __init__(self):
"""
Initialise the settings tab
"""
SettingsTab.__init__(self, u'Advanced')
def setupUi(self):
"""
Configure the UI elements for the tab.
"""
self.setObjectName(u'AdvancedTab')
self.tabTitleVisible = translate('AdvancedTab', 'Advanced')
self.advancedTabLayout = QtGui.QHBoxLayout(self)
self.advancedTabLayout.setSpacing(8)
self.advancedTabLayout.setMargin(8)
self.leftWidget = QtGui.QWidget(self)
self.leftLayout = QtGui.QVBoxLayout(self.leftWidget)
self.leftLayout.setSpacing(8)
self.leftLayout.setMargin(0)
self.recentGroupBox = QtGui.QGroupBox(self.leftWidget)
self.recentGroupBox.setObjectName(u'recentGroupBox')
self.recentGroupBox.setGeometry(QtCore.QRect(0, 0, 220, 57))
self.recentGroupBox.setMaximumSize(QtCore.QSize(220, 57))
self.recentLayout = QtGui.QHBoxLayout(self.recentGroupBox)
self.recentLayout.setSpacing(8)
self.recentLayout.setMargin(6)
self.recentLayout.setObjectName(u'recentLayout')
self.recentLabel = QtGui.QLabel(self.recentGroupBox)
self.recentLabel.setObjectName(u'recentLabel')
self.recentLayout.addWidget(self.recentLabel)
self.recentSpinBox = QtGui.QSpinBox(self.recentGroupBox)
self.recentSpinBox.setMinimum(0)
self.recentSpinBox.setObjectName(u'recentSpinBox')
self.recentLayout.addWidget(self.recentSpinBox)
self.leftLayout.addWidget(self.recentGroupBox)
# self.sharedDirGroupBox = QtGui.QGroupBox(self.leftWidget)
# self.sharedDirGroupBox.setObjectName(u'sharedDirGroupBox')
# self.sharedDirGroupBox.setGeometry(QtCore.QRect(0, 65, 500, 85))
# self.sharedDirGroupBox.setMaximumSize(QtCore.QSize(500, 85))
# self.sharedDirLayout = QtGui.QVBoxLayout(self.sharedDirGroupBox)
# self.sharedDirLayout.setSpacing(8)
# self.sharedDirLayout.setMargin(8)
# self.sharedCheckBox = QtGui.QCheckBox(self.sharedDirGroupBox)
# self.sharedCheckBox.setObjectName(u'sharedCheckBox')
# self.sharedDirLayout.addWidget(self.sharedCheckBox)
# self.sharedSubLayout = QtGui.QHBoxLayout()
# self.sharedSubLayout.setSpacing(8)
# self.sharedSubLayout.setMargin(0)
# self.sharedLabel = QtGui.QLabel(self.sharedDirGroupBox)
# self.sharedLabel.setObjectName(u'sharedLabel')
# self.sharedSubLayout.addWidget(self.sharedLabel)
# self.sharedLineEdit = QtGui.QLineEdit(self.sharedDirGroupBox)
# self.sharedLineEdit.setObjectName(u'sharedLineEdit')
# self.sharedSubLayout.addWidget(self.sharedLineEdit)
# self.sharedPushButton = QtGui.QPushButton(self.sharedDirGroupBox)
# self.sharedPushButton.setObjectName(u'sharedPushButton')
# self.sharedSubLayout.addWidget(self.sharedPushButton)
# self.sharedDirLayout.addLayout(self.sharedSubLayout)
# self.leftLayout.addWidget(self.sharedDirGroupBox)
self.leftSpacer = QtGui.QSpacerItem(20, 40,
QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.leftLayout.addItem(self.leftSpacer)
self.advancedTabLayout.addWidget(self.leftWidget)
# self.rightWidget = QtGui.QWidget(self)
# self.rightLayout = QtGui.QVBoxLayout(self.rightWidget)
# self.rightLayout.setSpacing(8)
# self.rightLayout.setMargin(0)
# self.databaseGroupBox = QtGui.QGroupBox(self.rightWidget)
# self.databaseGroupBox.setObjectName(u'databaseGroupBox')
# self.databaseGroupBox.setEnabled(False)
# self.databaseLayout = QtGui.QVBoxLayout(self.databaseGroupBox)
# self.databaseLayout.setSpacing(8)
# self.databaseLayout.setMargin(8)
# self.rightLayout.addWidget(self.databaseGroupBox)
# self.advancedTabLayout.addWidget(self.rightWidget)
# QtCore.QObject.connect(self.sharedCheckBox,
# QtCore.SIGNAL(u'stateChanged(int)'), self.onSharedCheckBoxChanged)
def retranslateUi(self):
"""
Setup the interface translation strings.
"""
self.recentGroupBox.setTitle(translate('AdvancedTab', 'Recent Files'))
self.recentLabel.setText(
translate('AdvancedTab', 'Number of recent files to list:'))
# self.sharedDirGroupBox.setTitle(
# translate('AdvancedTab', 'Central Data Store'))
# self.sharedCheckBox.setText(
# translate('AdvancedTab', 'Enable a shared data location'))
# self.sharedLabel.setText(translate('AdvancedTab', 'Store location:'))
# self.sharedPushButton.setText(translate('AdvancedTab', 'Browse...'))
# self.databaseGroupBox.setTitle(translate('AdvancedTab', 'Databases'))
def load(self):
"""
Load settings from disk.
"""
settings = QtCore.QSettings()
settings.beginGroup(self.settingsSection)
# The max recent files value does not have an interface and so never
# gets actually stored in the settings therefore the default value of
# 20 will always be used.
self.recentSpinBox.setMaximum(QtCore.QSettings().value(
u'max recent files', QtCore.QVariant(20)).toInt()[0])
self.recentSpinBox.setValue(settings.value(u'recent file count',
QtCore.QVariant(4)).toInt()[0])
settings.endGroup()
def save(self):
"""
Save settings to disk.
"""
settings = QtCore.QSettings()
settings.beginGroup(self.settingsSection)
settings.setValue(u'recent file count',
QtCore.QVariant(self.recentSpinBox.value()))
settings.endGroup()
def onSharedCheckBoxChanged(self, checked):
"""
Enables the widgets to allow a shared data location
"""
self.sharedLabel.setEnabled(checked)
self.sharedTextEdit.setEnabled(checked)
self.sharedPushButton.setEnabled(checked)

View File

@ -44,10 +44,12 @@ class DisplayTab(SettingsTab):
"""
self.tabTitleVisible = translate('DisplayTab', 'Displays')
self.layoutWidget = QtGui.QWidget(self)
self.layoutWidget.setGeometry(QtCore.QRect(0, 40, 241, 79))
self.layoutWidget.setObjectName(u'layoutWidget')
self.verticalLayout = QtGui.QVBoxLayout(self.layoutWidget)
self.verticalLayout.setObjectName(u'verticalLayout')
self.OverrideCheckBox = QtGui.QCheckBox(self.layoutWidget)
self.OverrideCheckBox.setObjectName(u'OverrideCheckBox')
self.verticalLayout.addWidget(self.OverrideCheckBox)
self.CurrentGroupBox = QtGui.QGroupBox(self.layoutWidget)
self.CurrentGroupBox.setObjectName(u'CurrentGroupBox')
self.horizontalLayout = QtGui.QHBoxLayout(self.CurrentGroupBox)
@ -153,9 +155,7 @@ class DisplayTab(SettingsTab):
self.WidthEdit.setObjectName(u'WidthEdit')
self.verticalLayout_5.addWidget(self.WidthEdit)
self.horizontalLayout_2.addLayout(self.verticalLayout_5)
self.OverrideCheckBox = QtGui.QCheckBox(self)
self.OverrideCheckBox.setGeometry(QtCore.QRect(0, 10, 191, 23))
self.OverrideCheckBox.setObjectName(u'OverrideCheckBox')
self.verticalLayout.addWidget(self.CurrentGroupBox_2)
QtCore.QMetaObject.connectSlotsByName(self)
QtCore.QObject.connect(self.OverrideCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'), self.onOverrideCheckBoxChanged)

View File

@ -469,7 +469,8 @@ class Ui_MainWindow(object):
'&Plugin List'))
self.SettingsPluginListItem.setStatusTip(
translate('MainWindow', 'List the Plugins'))
self.SettingsPluginListItem.setShortcut(translate('MainWindow', 'Alt+F7'))
self.SettingsPluginListItem.setShortcut(
translate('MainWindow', 'Alt+F7'))
self.HelpDocumentationItem.setText(
translate('MainWindow', '&User Guide'))
self.HelpAboutItem.setText(translate('MainWindow', '&About'))
@ -897,6 +898,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.ViewLivePanel.setChecked(visible)
def loadSettings(self):
"""
Load the main window settings.
"""
log.debug(u'Loading QSettings')
settings = QtCore.QSettings()
settings.beginGroup(self.generalSettingsSection)
@ -911,6 +915,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
settings.endGroup()
def saveSettings(self):
"""
Save the main window settings.
"""
log.debug(u'Saving QSettings')
settings = QtCore.QSettings()
settings.beginGroup(self.generalSettingsSection)
@ -928,15 +935,19 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
settings.endGroup()
def updateFileMenu(self):
"""
Updates the file menu with the latest list of service files accessed.
"""
recentFileCount = QtCore.QSettings().value(
u'advanced/recent file count', QtCore.QVariant(4)).toInt()[0]
self.FileMenu.clear()
add_actions(self.FileMenu, self.FileMenuActions[:-1])
existingRecentFiles = []
for file in self.recentFiles:
if QtCore.QFile.exists(file):
existingRecentFiles.append(file)
if existingRecentFiles:
existingRecentFiles = [file for file in self.recentFiles
if QtCore.QFile.exists(file)]
recentFilesToDisplay = existingRecentFiles[0:recentFileCount]
if recentFilesToDisplay:
self.FileMenu.addSeparator()
for fileId, filename in enumerate(existingRecentFiles):
for fileId, filename in enumerate(recentFilesToDisplay):
action = QtGui.QAction(u'&%d %s' % (fileId +1,
QtCore.QFileInfo(filename).fileName()), self)
action.setData(QtCore.QVariant(filename))
@ -947,13 +958,22 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.FileMenu.addAction(self.FileMenuActions[-1])
def addRecentFile(self, filename):
recentFileCount = QtCore.QSettings().value(
self.generalSettingsSection + u'/max recent files',
QtCore.QVariant(4)).toInt()[0]
"""
Adds a service to the list of recently used files.
``filename``
The service filename to add
"""
# The maxRecentFiles value does not have an interface and so never gets
# actually stored in the settings therefore the default value of 20
# will always be used.
maxRecentFiles = QtCore.QSettings().value(u'advanced/max recent files',
QtCore.QVariant(20)).toInt()[0]
if filename:
position = self.recentFiles.indexOf(filename)
if position != -1:
self.recentFiles.removeAt(position)
self.recentFiles.insert(0, QtCore.QString(filename))
while self.recentFiles.count() > recentFileCount:
self.recentFiles.removeLast()
while self.recentFiles.count() > maxRecentFiles:
# Don't care what API says takeLast works, removeLast doesn't!
self.recentFiles.takeLast()

View File

@ -29,7 +29,7 @@ import logging
from PyQt4 import QtGui
from openlp.core.ui import GeneralTab, ThemesTab, DisplayTab
from openlp.core.ui import AdvancedTab, GeneralTab, ThemesTab, DisplayTab
from settingsdialog import Ui_SettingsDialog
log = logging.getLogger(__name__)
@ -53,6 +53,9 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
# Display tab
self.DisplayTab = DisplayTab(screens)
self.addTab(u'Display', self.DisplayTab)
# Advanced tab
self.advancedTab = AdvancedTab()
self.addTab(u'Advanced', self.advancedTab)
def addTab(self, name, tab):
"""
@ -66,9 +69,9 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
Add a tab to the form at a specific location
"""
log.debug(u'Inserting %s tab' % tab.tabTitle)
#13 : There are 3 tables currently and locations starts at -10
# 14 : There are 3 tables currently and locations starts at -10
self.SettingsTabWidget.insertTab(
location + 13, tab, tab.tabTitleVisible)
location + 14, tab, tab.tabTitleVisible)
def removeTab(self, name):
"""

View File

@ -38,7 +38,8 @@ class BiblePlugin(Plugin):
def __init__(self, plugin_helpers):
Plugin.__init__(self, u'Bibles', u'1.9.2', plugin_helpers)
self.weight = -9
self.icon = build_icon(u':/plugins/plugin_bibles.png')
self.icon_path = u':/plugins/plugin_bibles.png'
self.icon = build_icon(self.icon_path)
#Register the bible Manager
self.status = PluginStatus.Active
self.manager = None

View File

@ -50,7 +50,8 @@ class CustomPlugin(Plugin):
self.weight = -5
self.custommanager = Manager(u'custom', init_schema)
self.edit_custom_form = EditCustomForm(self.custommanager)
self.icon = build_icon(u':/plugins/plugin_custom.png')
self.icon_path = u':/plugins/plugin_custom.png'
self.icon = build_icon(self.icon_path)
self.status = PluginStatus.Active
def getSettingsTab(self):

View File

@ -36,7 +36,8 @@ class ImagePlugin(Plugin):
def __init__(self, plugin_helpers):
Plugin.__init__(self, u'Images', u'1.9.2', plugin_helpers)
self.weight = -7
self.icon = build_icon(u':/plugins/plugin_images.png')
self.icon_path = u':/plugins/plugin_images.png'
self.icon = build_icon(self.icon_path)
self.status = PluginStatus.Active
def getSettingsTab(self):

View File

@ -38,7 +38,8 @@ class MediaPlugin(Plugin):
def __init__(self, plugin_helpers):
Plugin.__init__(self, u'Media', u'1.9.2', plugin_helpers)
self.weight = -6
self.icon = build_icon(u':/plugins/plugin_media.png')
self.icon_path = u':/plugins/plugin_media.png'
self.icon = build_icon(self.icon_path)
# passed with drag and drop messages
self.dnd_id = u'Media'
self.status = PluginStatus.Active

View File

@ -40,7 +40,8 @@ class PresentationPlugin(Plugin):
self.controllers = {}
Plugin.__init__(self, u'Presentations', u'1.9.2', plugin_helpers)
self.weight = -8
self.icon = build_icon(u':/plugins/plugin_presentations.png')
self.icon_path = u':/plugins/plugin_presentations.png'
self.icon = build_icon(self.icon_path)
self.status = PluginStatus.Active
def getSettingsTab(self):

View File

@ -58,7 +58,8 @@ class SongsPlugin(Plugin):
Plugin.__init__(self, u'Songs', u'1.9.2', plugin_helpers)
self.weight = -10
self.manager = Manager(u'songs', init_schema)
self.icon = build_icon(u':/plugins/plugin_songs.png')
self.icon_path = u':/plugins/plugin_songs.png'
self.icon = build_icon(self.icon_path)
self.status = PluginStatus.Active
def getSettingsTab(self):