diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 656a77847..82c331a26 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -31,7 +31,6 @@ The :mod:`lib` module contains most of the components and libraries that make OpenLP work. """ import logging -import datetime import os from PyQt4 import QtCore, QtGui, Qt @@ -91,92 +90,6 @@ class ServiceItemAction(object): Next = 3 -class Settings(QtCore.QSettings): - """ - Class to wrap QSettings. - - * Exposes all the methods of QSettings. - * Adds functionality for OpenLP Portable. If the ``defaultFormat`` is set to - ``IniFormat``, and the path to the Ini file is set using ``setFilename``, - then the Settings constructor (without any arguments) will create a Settings - object for accessing settings stored in that Ini file. - """ - __filePath__ = u'' - __defaultValues__ = { - u'displayTags/html_tags': u'', - u'players/background color': u'#000000', - u'servicemanager/service theme': u'', -} - - @staticmethod - def appendDefaultValues(defaultValues): - Settings.__defaultValues__ = dict(defaultValues.items() + Settings.__defaultValues__.items()) - - @staticmethod - def setFilename(iniFile): - """ - Sets the complete path to an Ini file to be used by Settings objects. - - Does not affect existing Settings objects. - """ - Settings.__filePath__ = iniFile - - def __init__(self, *args): - if not args and Settings.__filePath__ and \ - Settings.defaultFormat() == Settings.IniFormat: - QtCore.QSettings.__init__(self, Settings.__filePath__, Settings.IniFormat) - else: - QtCore.QSettings.__init__(self, *args) - - def value(self, key, defaultValue): - """ - Returns the value for the given ``key``. The returned ``value`` is - of the same type as the ``defaultValue``. - - ``key`` - The key to return the value from. - - ``defaultValue`` - The value to be returned if the given ``key`` is not present in the - config. Note, the ``defaultValue``'s type defines the type the - returned is converted to. In other words, if the ``defaultValue`` is - a boolean, then the returned value will be converted to a boolean. - - **Note**, this method only converts a few types and might need to be - extended if a certain type is missing! - """ - # Check for none as u'' is passed as default and is valid! This is - # needed because the settings export does not know the default values, - # thus just passes None. - if defaultValue is None and not super(Settings, self).contains(key): - return None - setting = super(Settings, self).value(key, defaultValue) - # On OS X (and probably on other platforms too) empty value from QSettings - # is represented as type PyQt4.QtCore.QPyNullVariant. This type has to be - # converted to proper 'None' Python type. - if isinstance(setting, QtCore.QPyNullVariant) and setting.isNull(): - setting = None - # Handle 'None' type (empty value) properly. - if setting is None: - # An empty string saved to the settings results in a None type being - # returned. Convert it to empty unicode string. - if isinstance(defaultValue, unicode): - return u'' - # An empty list saved to the settings results in a None type being - # returned. - else: - return [] - # Convert the setting to the correct type. - if isinstance(defaultValue, bool): - if isinstance(setting, bool): - return setting - # Sometimes setting is string instead of a boolean. - return setting == u'true' - if isinstance(defaultValue, int): - return int(setting) - return setting - - def translate(context, text, comment=None, encoding=QtCore.QCoreApplication.CodecForTr, n=-1, translate=QtCore.QCoreApplication.translate): @@ -469,6 +382,7 @@ def create_separated_list(stringlist): u'Locale list separator: start') % (stringlist[0], merged) +from settings import Settings from eventreceiver import Receiver from listwidgetwithdnd import ListWidgetWithDnD from formattingtags import FormattingTags diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 3960db0a1..f391991d8 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -79,68 +79,6 @@ PROGRESSBAR_STYLE = """ height: 10px; } """ -__defaultValues__ = { - u'advanced/x11 bypass wm': True, - u'advanced/default service enabled': True, - u'advanced/enable exit confirmation': True, - u'advanced/save current plugin': False, - u'advanced/single click preview': False, - u'advanced/default service day': 7, - u'advanced/max recent files': 20, - u'advanced/is portable': False, - u'advanced/hide mouse': True, - u'advanced/current media plugin': -1, - u'advanced/double click live': False, - u'advanced/default service hour': 11, - u'advanced/default color': u'#ffffff', - u'advanced/default image': u':/graphics/openlp-splash-screen.png', - u'advanced/expand service item': False, - u'advanced/recent file count': 4, - # TODO: Check if translate works here. - u'advanced/default service name': translate('OpenLP.AdvancedTab', 'Service %Y-%m-%d %H-%M', - 'This may not contain any of the following characters: /\\?*|<>\[\]":+\nSee http://docs.python.org/library/' - 'datetime.html#strftime-strptime-behavior for more information.'), - u'advanced/default service minute': 0, - u'advanced/slide limits': SlideLimits.End, - u'general/ccli number': u'', - u'general/y position': 0, - u'general/has run wizard': False, - u'general/update check': True, - u'general/language': u'[en]', - u'general/songselect password': u'', - u'general/recent files': [], - u'general/save prompt': False, - u'general/auto preview': False, - u'general/override position': False, - u'general/view mode': u'default', - u'general/auto open': False, - u'general/enable slide loop': True, - u'general/show splash': True, - u'general/screen blank': False, - u'general/x position': 0, - u'general/loop delay': 5, - u'general/height': 1024, - u'general/monitor': 0, - u'general/songselect username': u'', - u'general/audio repeat list': False, - u'general/auto unblank': False, - u'general/display on monitor': True, - u'general/width': 1280, - u'general/audio start paused': True, - u'general/last version test': datetime.datetime.now().date(), - u'general/blank warning': False, - u'themes/theme level': 3, - u'themes/global theme': u'', - u'user interface/main window position': QtCore.QPoint(), - u'user interface/preview panel': True, - u'user interface/live panel': True, - u'user interface/main window geometry': QtCore.QByteArray(), - u'user interface/preview splitter geometry': QtCore.QByteArray(), - u'user interface/lock panel': False, - u'user interface/mainwindow splitter geometry': QtCore.QByteArray(), - u'user interface/live splitter geometry': QtCore.QByteArray(), - u'user interface/main window state': QtCore.QByteArray() -} class Ui_MainWindow(object):