openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #22037
[Merge] lp:~trb143/openlp/theme-cleanup into lp:openlp
Tim Bentley has proposed merging lp:~trb143/openlp/theme-cleanup into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~trb143/openlp/theme-cleanup/+merge/190840
Start to clean up the theme code and move common code from utils and lib to common.
Add a helper
replace the xml default code to json load and simplify it.
remove to v1 theme import code. We will not support v1 to v2.2 direct
move applocation to a common package to allow it to be used in lib.
This is part of a series of theme cleanups which will have more tests written as code is developed
Proposing to get a view on direction.
--
https://code.launchpad.net/~trb143/openlp/theme-cleanup/+merge/190840
Your team OpenLP Core is requested to review the proposed merge of lp:~trb143/openlp/theme-cleanup into lp:openlp.
=== modified file 'openlp/core/__init__.py'
--- openlp/core/__init__.py 2013-08-31 18:17:38 +0000
+++ openlp/core/__init__.py 2013-10-13 20:38:16 +0000
@@ -43,14 +43,15 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import Settings, ScreenList, UiStrings, Registry, check_directory_exists
+from openlp.core.common import AppLocation, Settings, UiStrings, check_directory_exists
+from openlp.core.lib import ScreenList, Registry
from openlp.core.resources import qInitResources
from openlp.core.ui.mainwindow import MainWindow
from openlp.core.ui.firsttimelanguageform import FirstTimeLanguageForm
from openlp.core.ui.firsttimeform import FirstTimeForm
from openlp.core.ui.exceptionform import ExceptionForm
from openlp.core.ui import SplashScreen
-from openlp.core.utils import AppLocation, LanguageManager, VersionThread, get_application_version
+from openlp.core.utils import LanguageManager, VersionThread, get_application_version
__all__ = ['OpenLP', 'main']
=== added directory 'openlp/core/common'
=== added file 'openlp/core/common/__init__.py'
--- openlp/core/common/__init__.py 1970-01-01 00:00:00 +0000
+++ openlp/core/common/__init__.py 2013-10-13 20:38:16 +0000
@@ -0,0 +1,109 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2013 Raoul Snyman #
+# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan #
+# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
+# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
+# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
+# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
+# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
+# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
+# --------------------------------------------------------------------------- #
+# 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:`common` module contains most of the components and libraries that make
+OpenLP work.
+"""
+import os
+import logging
+import sys
+
+from PyQt4 import QtCore
+
+log = logging.getLogger(__name__)
+
+
+def check_directory_exists(directory, do_not_log=False):
+ """
+ Check a theme directory exists and if not create it
+
+ ``directory``
+ The directory to make sure exists
+
+ ``do_not_log``
+ To not log anything. This is need for the start up, when the log isn't ready.
+ """
+ if not do_not_log:
+ log.debug('check_directory_exists %s' % directory)
+ try:
+ if not os.path.exists(directory):
+ os.makedirs(directory)
+ except IOError:
+ pass
+
+
+def get_frozen_path(frozen_option, non_frozen_option):
+ """
+ Return a path based on the system status.
+ """
+ if hasattr(sys, 'frozen') and sys.frozen == 1:
+ return frozen_option
+ return non_frozen_option
+
+
+class ThemeLevel(object):
+ """
+ Provides an enumeration for the level a theme applies to
+ """
+ Global = 1
+ Service = 2
+ Song = 3
+
+
+def translate(context, text, comment=None, encoding=QtCore.QCoreApplication.CodecForTr, n=-1,
+ qt_translate=QtCore.QCoreApplication.translate):
+ """
+ A special shortcut method to wrap around the Qt4 translation functions. This abstracts the translation procedure so
+ that we can change it if at a later date if necessary, without having to redo the whole of OpenLP.
+
+ ``context``
+ The translation context, used to give each string a context or a namespace.
+
+ ``text``
+ The text to put into the translation tables for translation.
+
+ ``comment``
+ An identifying string for when the same text is used in different roles within the same context.
+ """
+ return qt_translate(context, text, comment, encoding, n)
+
+
+class SlideLimits(object):
+ """
+ Provides an enumeration for behaviour of OpenLP at the end limits of each service item when pressing the up/down
+ arrow keys
+ """
+ End = 1
+ Wrap = 2
+ Next = 3
+
+from .uistrings import UiStrings
+from .settings import Settings
+from .applocation import AppLocation
+
=== added file 'openlp/core/common/applocation.py'
--- openlp/core/common/applocation.py 1970-01-01 00:00:00 +0000
+++ openlp/core/common/applocation.py 2013-10-13 20:38:16 +0000
@@ -0,0 +1,172 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2013 Raoul Snyman #
+# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan #
+# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
+# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
+# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
+# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
+# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
+# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
+# --------------------------------------------------------------------------- #
+# 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:`openlp.core.common.applocation` module provides an utility for OpenLP receiving the data path etc.
+"""
+import logging
+import os
+import sys
+
+from openlp.core.common import Settings
+
+
+if sys.platform != 'win32' and sys.platform != 'darwin':
+ try:
+ from xdg import BaseDirectory
+ XDG_BASE_AVAILABLE = True
+ except ImportError:
+ XDG_BASE_AVAILABLE = False
+
+import openlp
+from openlp.core.common import check_directory_exists, get_frozen_path
+
+
+log = logging.getLogger(__name__)
+
+
+class AppLocation(object):
+ """
+ The :class:`AppLocation` class is a static class which retrieves a directory based on the directory type.
+ """
+ AppDir = 1
+ DataDir = 2
+ PluginsDir = 3
+ VersionDir = 4
+ CacheDir = 5
+ LanguageDir = 6
+
+ # Base path where data/config/cache dir is located
+ BaseDir = None
+
+ @staticmethod
+ def get_directory(dir_type=AppDir):
+ """
+ Return the appropriate directory according to the directory type.
+
+ ``dir_type``
+ The directory type you want, for instance the data directory. Default *AppLocation.AppDir*
+ """
+ if dir_type == AppLocation.AppDir:
+ return get_frozen_path(os.path.abspath(os.path.split(sys.argv[0])[0]), os.path.split(openlp.__file__)[0])
+ elif dir_type == AppLocation.PluginsDir:
+ app_path = os.path.abspath(os.path.split(sys.argv[0])[0])
+ return get_frozen_path(os.path.join(app_path, 'plugins'),
+ os.path.join(os.path.split(openlp.__file__)[0], 'plugins'))
+ elif dir_type == AppLocation.VersionDir:
+ return get_frozen_path(os.path.abspath(os.path.split(sys.argv[0])[0]), os.path.split(openlp.__file__)[0])
+ elif dir_type == AppLocation.LanguageDir:
+ app_path = get_frozen_path(os.path.abspath(os.path.split(sys.argv[0])[0]), _get_os_dir_path(dir_type))
+ return os.path.join(app_path, 'i18n')
+ elif dir_type == AppLocation.DataDir and AppLocation.BaseDir:
+ return os.path.join(AppLocation.BaseDir, 'data')
+ else:
+ return _get_os_dir_path(dir_type)
+
+ @staticmethod
+ def get_data_path():
+ """
+ Return the path OpenLP stores all its data under.
+ """
+ # Check if we have a different data location.
+ if Settings().contains('advanced/data path'):
+ path = Settings().value('advanced/data path')
+ else:
+ path = AppLocation.get_directory(AppLocation.DataDir)
+ check_directory_exists(path)
+ return os.path.normpath(path)
+
+ @staticmethod
+ def get_files(section=None, extension=None):
+ """
+ Get a list of files from the data files path.
+
+ ``section``
+ Defaults to *None*. The section of code getting the files - used to load from a section's data subdirectory.
+
+ ``extension``
+ Defaults to *None*. The extension to search for. For example::
+
+ u'.png'
+ """
+ path = AppLocation.get_data_path()
+ if section:
+ path = os.path.join(path, section)
+ try:
+ files = os.listdir(path)
+ except OSError:
+ return []
+ if extension:
+ return [filename for filename in files if extension == os.path.splitext(filename)[1]]
+ else:
+ # no filtering required
+ return files
+
+ @staticmethod
+ def get_section_data_path(section):
+ """
+ Return the path a particular module stores its data under.
+ """
+ data_path = AppLocation.get_data_path()
+ path = os.path.join(data_path, section)
+ check_directory_exists(path)
+ return path
+
+
+def _get_os_dir_path(dir_type):
+ """
+ Return a path based on which OS and environment we are running in.
+ """
+ if sys.platform == 'win32':
+ if dir_type == AppLocation.DataDir:
+ return os.path.join(str(os.getenv('APPDATA')), 'openlp', 'data')
+ elif dir_type == AppLocation.LanguageDir:
+ return os.path.split(openlp.__file__)[0]
+ return os.path.join(str(os.getenv('APPDATA')), 'openlp')
+ elif sys.platform == 'darwin':
+ if dir_type == AppLocation.DataDir:
+ return os.path.join(str(os.getenv('HOME')),
+ 'Library', 'Application Support', 'openlp', 'Data')
+ elif dir_type == AppLocation.LanguageDir:
+ return os.path.split(openlp.__file__)[0]
+ return os.path.join(str(os.getenv('HOME')), 'Library', 'Application Support', 'openlp')
+ else:
+ if dir_type == AppLocation.LanguageDir:
+ for prefix in ['/usr/local', '/usr']:
+ directory = os.path.join(prefix, 'share', 'openlp')
+ if os.path.exists(directory):
+ return directory
+ return os.path.join('/usr', 'share', 'openlp')
+ if XDG_BASE_AVAILABLE:
+ if dir_type == AppLocation.DataDir:
+ return os.path.join(str(BaseDirectory.xdg_data_home), 'openlp')
+ elif dir_type == AppLocation.CacheDir:
+ return os.path.join(str(BaseDirectory.xdg_cache_home), 'openlp')
+ if dir_type == AppLocation.DataDir:
+ return os.path.join(str(os.getenv('HOME')), '.openlp', 'data')
+ return os.path.join(str(os.getenv('HOME')), '.openlp')
=== renamed file 'openlp/core/lib/uistrings.py' => 'openlp/core/common/uistrings.py'
--- openlp/core/lib/uistrings.py 2013-04-15 21:31:04 +0000
+++ openlp/core/common/uistrings.py 2013-10-13 20:38:16 +0000
@@ -31,7 +31,7 @@
"""
import logging
-from openlp.core.lib import translate
+from openlp.core.common import translate
log = logging.getLogger(__name__)
=== modified file 'openlp/core/lib/__init__.py'
--- openlp/core/lib/__init__.py 2013-08-31 18:17:38 +0000
+++ openlp/core/lib/__init__.py 2013-10-13 20:38:16 +0000
@@ -37,6 +37,8 @@
from PyQt4 import QtCore, QtGui, Qt
+from openlp.core.common import translate
+
log = logging.getLogger(__name__)
@@ -72,16 +74,6 @@
Video = 2
-class SlideLimits(object):
- """
- Provides an enumeration for behaviour of OpenLP at the end limits of each service item when pressing the up/down
- arrow keys
- """
- End = 1
- Wrap = 2
- Next = 3
-
-
class ServiceItemAction(object):
"""
Provides an enumeration for the required action moving between service items by left/right arrow keys
@@ -91,24 +83,6 @@
Next = 3
-def translate(context, text, comment=None, encoding=QtCore.QCoreApplication.CodecForTr, n=-1,
- qt_translate=QtCore.QCoreApplication.translate):
- """
- A special shortcut method to wrap around the Qt4 translation functions. This abstracts the translation procedure so
- that we can change it if at a later date if necessary, without having to redo the whole of OpenLP.
-
- ``context``
- The translation context, used to give each string a context or a namespace.
-
- ``text``
- The text to put into the translation tables for translation.
-
- ``comment``
- An identifying string for when the same text is used in different roles within the same context.
- """
- return qt_translate(context, text, comment, encoding, n)
-
-
def get_text_file_string(text_file):
"""
Open a file and return its content as unicode string. If the supplied file name is not a file then the function
@@ -327,57 +301,36 @@
return text
-def check_directory_exists(directory, do_not_log=False):
- """
- Check a theme directory exists and if not create it
-
- ``directory``
- The directory to make sure exists
-
- ``do_not_log``
- To not log anything. This is need for the start up, when the log isn't ready.
- """
- if not do_not_log:
- log.debug('check_directory_exists %s' % directory)
- try:
- if not os.path.exists(directory):
- os.makedirs(directory)
- except IOError:
- pass
-
-
-def create_separated_list(stringlist):
+def create_separated_list(string_list):
"""
Returns a string that represents a join of a list of strings with a localized separator. This function corresponds
to QLocale::createSeparatedList which was introduced in Qt 4.8 and implements the algorithm from
http://www.unicode.org/reports/tr35/#ListPatterns
- ``stringlist``
+ ``string_list``
List of unicode strings
"""
if LooseVersion(Qt.PYQT_VERSION_STR) >= LooseVersion('4.9') and \
LooseVersion(Qt.qVersion()) >= LooseVersion('4.8'):
- return QtCore.QLocale().createSeparatedList(stringlist)
- if not stringlist:
+ return QtCore.QLocale().createSeparatedList(string_list)
+ if not string_list:
return ''
- elif len(stringlist) == 1:
- return stringlist[0]
- elif len(stringlist) == 2:
+ elif len(string_list) == 1:
+ return string_list[0]
+ elif len(string_list) == 2:
return translate('OpenLP.core.lib', '%s and %s',
- 'Locale list separator: 2 items') % (stringlist[0], stringlist[1])
+ 'Locale list separator: 2 items') % (string_list[0], string_list[1])
else:
merged = translate('OpenLP.core.lib', '%s, and %s',
- 'Locale list separator: end') % (stringlist[-2], stringlist[-1])
- for index in reversed(list(range(1, len(stringlist) - 2))):
+ 'Locale list separator: end') % (string_list[-2], string_list[-1])
+ for index in reversed(list(range(1, len(string_list) - 2))):
merged = translate('OpenLP.core.lib', '%s, %s',
- 'Locale list separator: middle') % (stringlist[index], merged)
- return translate('OpenLP.core.lib', '%s, %s', 'Locale list separator: start') % (stringlist[0], merged)
+ 'Locale list separator: middle') % (string_list[index], merged)
+ return translate('OpenLP.core.lib', '%s, %s', 'Locale list separator: start') % (string_list[0], merged)
from .registry import Registry
-from .uistrings import UiStrings
from .screen import ScreenList
-from .settings import Settings
from .listwidgetwithdnd import ListWidgetWithDnD
from .treewidgetwithdnd import TreeWidgetWithDnD
from .formattingtags import FormattingTags
=== modified file 'openlp/core/lib/db.py'
--- openlp/core/lib/db.py 2013-08-31 18:17:38 +0000
+++ openlp/core/lib/db.py 2013-10-13 20:38:16 +0000
@@ -41,9 +41,10 @@
from alembic.migration import MigrationContext
from alembic.operations import Operations
-from openlp.core.lib import translate, Settings
+from openlp.core.common import AppLocation, Settings
+from openlp.core.lib import translate
from openlp.core.lib.ui import critical_error_message_box
-from openlp.core.utils import AppLocation, delete_file
+from openlp.core.utils import delete_file
log = logging.getLogger(__name__)
=== modified file 'openlp/core/lib/formattingtags.py'
--- openlp/core/lib/formattingtags.py 2013-09-11 19:00:30 +0000
+++ openlp/core/lib/formattingtags.py 2013-10-13 20:38:16 +0000
@@ -31,7 +31,8 @@
"""
import json
-from openlp.core.lib import Settings, translate
+from openlp.core.common import Settings
+from openlp.core.lib import translate
class FormattingTags(object):
=== added directory 'openlp/core/lib/json'
=== added file 'openlp/core/lib/json/theme.json'
--- openlp/core/lib/json/theme.json 1970-01-01 00:00:00 +0000
+++ openlp/core/lib/json/theme.json 2013-10-13 20:38:16 +0000
@@ -0,0 +1,49 @@
+{
+ "background_border_color": "#000000",
+ "background_color": "#000000",
+ "background_direction": "vertical",
+ "background_end_color": "#000000",
+ "background_filename": "",
+ "background_start_color": "#000000",
+ "background_type": "solid",
+ "display_horizontal_align": 0,
+ "display_slide_transition": false,
+ "display_vertical_align": 0,
+ "font_footer_bold": false,
+ "font_footer_color": "#FFFFFF",
+ "font_footer_height": 78,
+ "font_footer_italics": false,
+ "font_footer_line_adjustment": 0,
+ "font_footer_location": "",
+ "font_footer_name": "Arial",
+ "font_footer_outline": false,
+ "font_footer_outline_color": "#000000",
+ "font_footer_outline_size": 2,
+ "font_footer_override": false,
+ "font_footer_shadow": true,
+ "font_footer_shadow_color": "#000000",
+ "font_footer_shadow_size": 5,
+ "font_footer_size": 12,
+ "font_footer_width": 1004,
+ "font_footer_x": 10,
+ "font_footer_y": 690,
+ "font_main_bold": false,
+ "font_main_color": "#FFFFFF",
+ "font_main_height": 690,
+ "font_main_italics": false,
+ "font_main_line_adjustment": 0,
+ "font_main_location": "",
+ "font_main_name": "Arial",
+ "font_main_outline": false,
+ "font_main_outline_color": "#000000",
+ "font_main_outline_size": 2,
+ "font_main_override": false,
+ "font_main_shadow": true,
+ "font_main_shadow_color": "#000000",
+ "font_main_shadow_size": 5,
+ "font_main_size": 40,
+ "font_main_width": 1004,
+ "font_main_x": 10,
+ "font_main_y": 10,
+ "theme_name": ""
+}
=== modified file 'openlp/core/lib/mediamanageritem.py'
--- openlp/core/lib/mediamanageritem.py 2013-10-02 21:07:20 +0000
+++ openlp/core/lib/mediamanageritem.py 2013-10-13 20:38:16 +0000
@@ -35,8 +35,9 @@
from PyQt4 import QtCore, QtGui
+from openlp.core.common import Settings, UiStrings, translate
from openlp.core.lib import OpenLPToolbar, ServiceItem, StringContent, ListWidgetWithDnD, \
- ServiceItemContext, Settings, Registry, UiStrings, translate
+ ServiceItemContext, Registry
from openlp.core.lib.searchedit import SearchEdit
from openlp.core.lib.ui import create_widget_action, critical_error_message_box
=== modified file 'openlp/core/lib/plugin.py'
--- openlp/core/lib/plugin.py 2013-08-31 18:17:38 +0000
+++ openlp/core/lib/plugin.py 2013-10-13 20:38:16 +0000
@@ -34,7 +34,8 @@
from PyQt4 import QtCore
-from openlp.core.lib import Settings, Registry, UiStrings
+from openlp.core.common import Settings, UiStrings
+from openlp.core.lib import Registry
from openlp.core.utils import get_application_version
log = logging.getLogger(__name__)
=== modified file 'openlp/core/lib/pluginmanager.py'
--- openlp/core/lib/pluginmanager.py 2013-08-31 18:17:38 +0000
+++ openlp/core/lib/pluginmanager.py 2013-10-13 20:38:16 +0000
@@ -35,7 +35,7 @@
import imp
from openlp.core.lib import Plugin, PluginStatus, Registry
-from openlp.core.utils import AppLocation
+from openlp.core.common import AppLocation
log = logging.getLogger(__name__)
=== modified file 'openlp/core/lib/renderer.py'
--- openlp/core/lib/renderer.py 2013-08-31 18:17:38 +0000
+++ openlp/core/lib/renderer.py 2013-10-13 20:38:16 +0000
@@ -31,9 +31,10 @@
from PyQt4 import QtGui, QtCore, QtWebKit
-from openlp.core.lib import Settings, FormattingTags, ImageSource, ItemCapabilities, Registry, ScreenList, \
+from openlp.core.common import Settings
+from openlp.core.lib import FormattingTags, ImageSource, ItemCapabilities, Registry, ScreenList, \
ServiceItem, expand_tags, build_lyrics_format_css, build_lyrics_outline_css
-from openlp.core.lib.theme import ThemeLevel
+from openlp.core.common import ThemeLevel
from openlp.core.ui import MainDisplay
log = logging.getLogger(__name__)
=== modified file 'openlp/core/lib/screen.py'
--- openlp/core/lib/screen.py 2013-08-31 18:17:38 +0000
+++ openlp/core/lib/screen.py 2013-10-13 20:38:16 +0000
@@ -36,7 +36,8 @@
from PyQt4 import QtCore
-from openlp.core.lib import Registry, translate
+from openlp.core.common import Settings, translate
+from openlp.core.lib import Registry
log = logging.getLogger(__name__)
@@ -244,7 +245,6 @@
"""
Loads the screen size and the monitor number from the settings.
"""
- from openlp.core.lib import Settings
# Add the screen settings to the settings dict. This has to be done here due to cyclic dependency.
# Do not do this anywhere else.
screen_settings = {
=== modified file 'openlp/core/lib/serviceitem.py'
--- openlp/core/lib/serviceitem.py 2013-08-31 18:17:38 +0000
+++ openlp/core/lib/serviceitem.py 2013-10-13 20:38:16 +0000
@@ -39,7 +39,8 @@
from PyQt4 import QtGui
-from openlp.core.lib import ImageSource, Settings, Registry, build_icon, clean_tags, expand_tags, translate
+from openlp.core.common import Settings
+from openlp.core.lib import ImageSource, Registry, build_icon, clean_tags, expand_tags, translate
log = logging.getLogger(__name__)
=== removed file 'openlp/core/lib/settings.py'
--- openlp/core/lib/settings.py 2013-08-31 18:17:38 +0000
+++ openlp/core/lib/settings.py 1970-01-01 00:00:00 +0000
@@ -1,499 +0,0 @@
-# -*- coding: utf-8 -*-
-# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
-
-###############################################################################
-# OpenLP - Open Source Lyrics Projection #
-# --------------------------------------------------------------------------- #
-# Copyright (c) 2008-2013 Raoul Snyman #
-# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan #
-# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
-# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
-# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
-# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
-# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
-# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
-# --------------------------------------------------------------------------- #
-# 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 #
-###############################################################################
-"""
-This class contains the core default settings.
-"""
-import datetime
-import logging
-import os
-import sys
-
-from PyQt4 import QtCore, QtGui
-
-from openlp.core.lib import SlideLimits, UiStrings
-from openlp.core.lib.theme import ThemeLevel
-
-
-log = logging.getLogger(__name__)
-
-
-# Fix for bug #1014422.
-X11_BYPASS_DEFAULT = True
-if sys.platform.startswith('linux'):
- # Default to False on Gnome.
- X11_BYPASS_DEFAULT = bool(not os.environ.get('GNOME_DESKTOP_SESSION_ID'))
- # Default to False on Xfce.
- if os.environ.get('DESKTOP_SESSION') == 'xfce':
- X11_BYPASS_DEFAULT = False
-
-
-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 ``set_filename``,
- then the Settings constructor (without any arguments) will create a Settings
- object for accessing settings stored in that Ini file.
-
- ``__default_settings__``
- This dict contains all core settings with their default values.
-
- ``__obsolete_settings__``
- Each entry is structured in the following way::
-
- (u'general/enable slide loop', u'advanced/slide limits',
- [(SlideLimits.Wrap, True), (SlideLimits.End, False)])
-
- The first entry is the *old key*; it will be removed.
-
- The second entry is the *new key*; we will add it to the config. If this is just an empty string, we just remove
- the old key.
-
- The last entry is a list containing two-pair tuples. If the list is empty, no conversion is made. Otherwise each
- pair describes how to convert the old setting's value::
-
- (SlideLimits.Wrap, True)
-
- This means, that if the value of ``general/enable slide loop`` is equal (``==``) ``True`` then we set
- ``advanced/slide limits`` to ``SlideLimits.Wrap``. **NOTE**, this means that the rules have to cover all cases!
- So, if the type of the old value is bool, then there must be two rules.
- """
- __default_settings__ = {
- 'advanced/add page break': False,
- 'advanced/alternate rows': not sys.platform.startswith('win'),
- 'advanced/current media plugin': -1,
- 'advanced/data path': '',
- 'advanced/default color': '#ffffff',
- 'advanced/default image': ':/graphics/openlp-splash-screen.png',
- # 7 stands for now, 0 to 6 is Monday to Sunday.
- 'advanced/default service day': 7,
- 'advanced/default service enabled': True,
- 'advanced/default service hour': 11,
- 'advanced/default service minute': 0,
- 'advanced/default service name': UiStrings().DefaultServiceName,
- 'advanced/display size': 0,
- 'advanced/double click live': False,
- 'advanced/enable exit confirmation': True,
- 'advanced/expand service item': False,
- 'advanced/hide mouse': True,
- 'advanced/is portable': False,
- 'advanced/max recent files': 20,
- 'advanced/print file meta data': False,
- 'advanced/print notes': False,
- 'advanced/print slide text': False,
- 'advanced/recent file count': 4,
- 'advanced/save current plugin': False,
- 'advanced/slide limits': SlideLimits.End,
- 'advanced/single click preview': False,
- 'advanced/x11 bypass wm': X11_BYPASS_DEFAULT,
- 'crashreport/last directory': '',
- 'formattingTags/html_tags': '',
- 'core/audio repeat list': False,
- 'core/auto open': False,
- 'core/auto preview': False,
- 'core/audio start paused': True,
- 'core/auto unblank': False,
- 'core/blank warning': False,
- 'core/ccli number': '',
- 'core/has run wizard': False,
- 'core/language': '[en]',
- 'core/last version test': '',
- 'core/loop delay': 5,
- 'core/recent files': [],
- 'core/save prompt': False,
- 'core/screen blank': False,
- 'core/show splash': True,
- 'core/songselect password': '',
- 'core/songselect username': '',
- 'core/update check': True,
- 'core/view mode': 'default',
- # The other display settings (display position and dimensions) are defined in the ScreenList class due to a
- # circular dependency.
- 'core/display on monitor': True,
- 'core/override position': False,
- 'images/background color': '#000000',
- 'media/players': 'webkit',
- 'media/override player': QtCore.Qt.Unchecked,
- 'players/background color': '#000000',
- 'servicemanager/last directory': '',
- 'servicemanager/last file': '',
- 'servicemanager/service theme': '',
- 'SettingsImport/file_date_created': datetime.datetime.now().strftime("%Y-%m-%d %H:%M"),
- 'SettingsImport/Make_Changes': 'At_Own_RISK',
- 'SettingsImport/type': 'OpenLP_settings_export',
- 'SettingsImport/version': '',
- 'shortcuts/aboutItem': [QtGui.QKeySequence('Ctrl+F1')],
- 'shortcuts/addToService': [],
- 'shortcuts/audioPauseItem': [],
- 'shortcuts/displayTagItem': [],
- 'shortcuts/blankScreen': [QtGui.QKeySequence(QtCore.Qt.Key_Period)],
- 'shortcuts/collapse': [QtGui.QKeySequence(QtCore.Qt.Key_Minus)],
- 'shortcuts/desktopScreen': [QtGui.QKeySequence('D')],
- 'shortcuts/delete': [],
- 'shortcuts/down': [QtGui.QKeySequence(QtCore.Qt.Key_Down)],
- 'shortcuts/editSong': [],
- 'shortcuts/escapeItem': [QtGui.QKeySequence(QtCore.Qt.Key_Escape)],
- 'shortcuts/expand': [QtGui.QKeySequence(QtCore.Qt.Key_Plus)],
- 'shortcuts/exportThemeItem': [],
- 'shortcuts/fileNewItem': [QtGui.QKeySequence('Ctrl+N')],
- 'shortcuts/fileSaveAsItem': [QtGui.QKeySequence('Ctrl+Shift+S')],
- 'shortcuts/fileExitItem': [QtGui.QKeySequence('Alt+F4')],
- 'shortcuts/fileSaveItem': [QtGui.QKeySequence('Ctrl+S')],
- 'shortcuts/fileOpenItem': [QtGui.QKeySequence('Ctrl+O')],
- 'shortcuts/goLive': [],
- 'shortcuts/importThemeItem': [],
- 'shortcuts/importBibleItem': [],
- 'shortcuts/listViewBiblesDeleteItem': [QtGui.QKeySequence(QtCore.Qt.Key_Delete)],
- 'shortcuts/listViewBiblesPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Enter),
- QtGui.QKeySequence(QtCore.Qt.Key_Return)],
- 'shortcuts/listViewBiblesLiveItem': [QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Enter),
- QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Return)],
- 'shortcuts/listViewBiblesServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus),
- QtGui.QKeySequence(QtCore.Qt.Key_Equal)],
- 'shortcuts/listViewCustomDeleteItem': [QtGui.QKeySequence(QtCore.Qt.Key_Delete)],
- 'shortcuts/listViewCustomPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Enter),
- QtGui.QKeySequence(QtCore.Qt.Key_Return)],
- 'shortcuts/listViewCustomLiveItem': [QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Enter),
- QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Return)],
- 'shortcuts/listViewCustomServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus),
- QtGui.QKeySequence(QtCore.Qt.Key_Equal)],
- 'shortcuts/listViewImagesDeleteItem': [QtGui.QKeySequence(QtCore.Qt.Key_Delete)],
- 'shortcuts/listViewImagesPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Enter),
- QtGui.QKeySequence(QtCore.Qt.Key_Return)],
- 'shortcuts/listViewImagesLiveItem': [QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Enter),
- QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Return)],
- 'shortcuts/listViewImagesServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus),
- QtGui.QKeySequence(QtCore.Qt.Key_Equal)],
- 'shortcuts/listViewMediaDeleteItem': [QtGui.QKeySequence(QtCore.Qt.Key_Delete)],
- 'shortcuts/listViewMediaPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Enter),
- QtGui.QKeySequence(QtCore.Qt.Key_Return)],
- 'shortcuts/listViewMediaLiveItem': [QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Enter),
- QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Return)],
- 'shortcuts/listViewMediaServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus),
- QtGui.QKeySequence(QtCore.Qt.Key_Equal)],
- 'shortcuts/listViewPresentationsDeleteItem': [QtGui.QKeySequence(QtCore.Qt.Key_Delete)],
- 'shortcuts/listViewPresentationsPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Enter),
- QtGui.QKeySequence(QtCore.Qt.Key_Return)],
- 'shortcuts/listViewPresentationsLiveItem': [QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Enter),
- QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Return)],
- 'shortcuts/listViewPresentationsServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus),
- QtGui.QKeySequence(QtCore.Qt.Key_Equal)],
- 'shortcuts/listViewSongsDeleteItem': [QtGui.QKeySequence(QtCore.Qt.Key_Delete)],
- 'shortcuts/listViewSongsPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Enter),
- QtGui.QKeySequence(QtCore.Qt.Key_Return)],
- 'shortcuts/listViewSongsLiveItem': [QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Enter),
- QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Return)],
- 'shortcuts/listViewSongsServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus),
- QtGui.QKeySequence(QtCore.Qt.Key_Equal)],
- 'shortcuts/lockPanel': [],
- 'shortcuts/modeDefaultItem': [],
- 'shortcuts/modeLiveItem': [],
- 'shortcuts/make_live': [QtGui.QKeySequence(QtCore.Qt.Key_Enter), QtGui.QKeySequence(QtCore.Qt.Key_Return)],
- 'shortcuts/moveUp': [QtGui.QKeySequence(QtCore.Qt.Key_PageUp)],
- 'shortcuts/moveTop': [QtGui.QKeySequence(QtCore.Qt.Key_Home)],
- 'shortcuts/modeSetupItem': [],
- 'shortcuts/moveBottom': [QtGui.QKeySequence(QtCore.Qt.Key_End)],
- 'shortcuts/moveDown': [QtGui.QKeySequence(QtCore.Qt.Key_PageDown)],
- 'shortcuts/nextTrackItem': [],
- 'shortcuts/nextItem_live': [QtGui.QKeySequence(QtCore.Qt.Key_Down),
- QtGui.QKeySequence(QtCore.Qt.Key_PageDown)],
- 'shortcuts/nextItem_preview': [],
- 'shortcuts/nextService': [QtGui.QKeySequence(QtCore.Qt.Key_Right)],
- 'shortcuts/newService': [],
- 'shortcuts/offlineHelpItem': [],
- 'shortcuts/onlineHelpItem': [QtGui.QKeySequence('Alt+F1')],
- 'shortcuts/openService': [],
- 'shortcuts/saveService': [],
- 'shortcuts/previousItem_live': [QtGui.QKeySequence(QtCore.Qt.Key_Up),
- QtGui.QKeySequence(QtCore.Qt.Key_PageUp)],
- 'shortcuts/playbackPause': [],
- 'shortcuts/playbackPlay': [],
- 'shortcuts/playbackStop': [],
- 'shortcuts/playSlidesLoop': [],
- 'shortcuts/playSlidesOnce': [],
- 'shortcuts/previousService': [QtGui.QKeySequence(QtCore.Qt.Key_Left)],
- 'shortcuts/previousItem_preview': [],
- 'shortcuts/printServiceItem': [QtGui.QKeySequence('Ctrl+P')],
- 'shortcuts/songExportItem': [],
- 'shortcuts/songUsageStatus': [QtGui.QKeySequence(QtCore.Qt.Key_F4)],
- 'shortcuts/searchShortcut': [QtGui.QKeySequence('Ctrl+F')],
- 'shortcuts/settingsShortcutsItem': [],
- 'shortcuts/settingsImportItem': [],
- 'shortcuts/settingsPluginListItem': [QtGui.QKeySequence('Alt+F7')],
- 'shortcuts/songUsageDelete': [],
- 'shortcuts/settingsConfigureItem': [],
- 'shortcuts/shortcutAction_B': [QtGui.QKeySequence('B')],
- 'shortcuts/shortcutAction_C': [QtGui.QKeySequence('C')],
- 'shortcuts/shortcutAction_E': [QtGui.QKeySequence('E')],
- 'shortcuts/shortcutAction_I': [QtGui.QKeySequence('I')],
- 'shortcuts/shortcutAction_O': [QtGui.QKeySequence('O')],
- 'shortcuts/shortcutAction_P': [QtGui.QKeySequence('P')],
- 'shortcuts/shortcutAction_V': [QtGui.QKeySequence('V')],
- 'shortcuts/shortcutAction_0': [QtGui.QKeySequence('0')],
- 'shortcuts/shortcutAction_1': [QtGui.QKeySequence('1')],
- 'shortcuts/shortcutAction_2': [QtGui.QKeySequence('2')],
- 'shortcuts/shortcutAction_3': [QtGui.QKeySequence('3')],
- 'shortcuts/shortcutAction_4': [QtGui.QKeySequence('4')],
- 'shortcuts/shortcutAction_5': [QtGui.QKeySequence('5')],
- 'shortcuts/shortcutAction_6': [QtGui.QKeySequence('6')],
- 'shortcuts/shortcutAction_7': [QtGui.QKeySequence('7')],
- 'shortcuts/shortcutAction_8': [QtGui.QKeySequence('8')],
- 'shortcuts/shortcutAction_9': [QtGui.QKeySequence('9')],
- 'shortcuts/settingsExportItem': [],
- 'shortcuts/songUsageReport': [],
- 'shortcuts/songImportItem': [],
- 'shortcuts/themeScreen': [QtGui.QKeySequence('T')],
- 'shortcuts/toolsReindexItem': [],
- 'shortcuts/toolsFindDuplicates': [],
- 'shortcuts/toolsAlertItem': [QtGui.QKeySequence('F7')],
- 'shortcuts/toolsFirstTimeWizard': [],
- 'shortcuts/toolsOpenDataFolder': [],
- 'shortcuts/toolsAddToolItem': [],
- 'shortcuts/updateThemeImages': [],
- 'shortcuts/up': [QtGui.QKeySequence(QtCore.Qt.Key_Up)],
- 'shortcuts/viewThemeManagerItem': [QtGui.QKeySequence('F10')],
- 'shortcuts/viewMediaManagerItem': [QtGui.QKeySequence('F8')],
- 'shortcuts/viewPreviewPanel': [QtGui.QKeySequence('F11')],
- 'shortcuts/viewLivePanel': [QtGui.QKeySequence('F12')],
- 'shortcuts/viewServiceManagerItem': [QtGui.QKeySequence('F9')],
- 'shortcuts/webSiteItem': [],
- 'themes/global theme': '',
- 'themes/last directory': '',
- 'themes/last directory export': '',
- 'themes/last directory import': '',
- 'themes/theme level': ThemeLevel.Song,
- 'user interface/live panel': True,
- 'user interface/live splitter geometry': QtCore.QByteArray(),
- 'user interface/lock panel': False,
- 'user interface/main window geometry': QtCore.QByteArray(),
- 'user interface/main window position': QtCore.QPoint(0, 0),
- 'user interface/main window splitter geometry': QtCore.QByteArray(),
- 'user interface/main window state': QtCore.QByteArray(),
- 'user interface/preview panel': True,
- 'user interface/preview splitter geometry': QtCore.QByteArray()
- }
- __file_path__ = ''
- __obsolete_settings__ = [
- # Changed during 1.9.x development.
- ('bibles/bookname language', 'bibles/book name language', []),
- ('general/enable slide loop', 'advanced/slide limits', [(SlideLimits.Wrap, True), (SlideLimits.End, False)]),
- ('songs/ccli number', 'core/ccli number', []),
- ('media/use phonon', '', []),
- # Changed during 2.1.x development.
- ('advanced/stylesheet fix', '', []),
- ('bibles/last directory 1', 'bibles/last directory import', []),
- ('media/background color', 'players/background color', []),
- ('themes/last directory', 'themes/last directory import', []),
- ('themes/last directory 1', 'themes/last directory export', []),
- ('songs/last directory 1', 'songs/last directory import', []),
- ('songusage/last directory 1', 'songusage/last directory export', []),
- ('user interface/mainwindow splitter geometry', 'user interface/main window splitter geometry', []),
- ('shortcuts/makeLive', 'shortcuts/make_live', []),
- ('general/audio repeat list', 'core/audio repeat list', []),
- ('general/auto open', 'core/auto open', []),
- ('general/auto preview', 'core/auto preview', []),
- ('general/audio start paused', 'core/audio start paused', []),
- ('general/auto unblank', 'core/auto unblank', []),
- ('general/blank warning', 'core/blank warning', []),
- ('general/ccli number', 'core/ccli number', []),
- ('general/has run wizard', 'core/has run wizard', []),
- ('general/language', 'core/language', []),
- ('general/last version test', 'core/last version test', []),
- ('general/loop delay', 'core/loop delay', []),
- ('general/recent files', 'core/recent files', []),
- ('general/save prompt', 'core/save prompt', []),
- ('general/screen blank', 'core/screen blank', []),
- ('general/show splash', 'core/show splash', []),
- ('general/songselect password', 'core/songselect password', []),
- ('general/songselect username', 'core/songselect username', []),
- ('general/update check', 'core/update check', []),
- ('general/view mode', 'core/view mode', []),
- ('general/display on monitor', 'core/display on monitor', []),
- ('general/override position', 'core/override position', []),
- ('general/x position', 'core/x position', []),
- ('general/y position', 'core/y position', []),
- ('general/monitor', 'core/monitor', []),
- ('general/height', 'core/height', []),
- ('general/monitor', 'core/monitor', []),
- ('general/width', 'core/width', [])
- ]
-
- @staticmethod
- def extend_default_settings(default_values):
- """
- Static method to merge the given ``default_values`` with the ``Settings.__default_settings__``.
-
- ``default_values``
- A dict with setting keys and their default values.
- """
- Settings.__default_settings__ = dict(list(default_values.items()) + list(Settings.__default_settings__.items()))
-
- @staticmethod
- def set_filename(ini_file):
- """
- Sets the complete path to an Ini file to be used by Settings objects.
-
- Does not affect existing Settings objects.
- """
- Settings.__file_path__ = ini_file
-
- @staticmethod
- def set_up_default_values():
- """
- This static method is called on start up. It is used to perform any operation on the __default_settings__ dict.
- """
- # Make sure the string is translated (when building the dict the string is not translated because the translate
- # function was not set up as this stage).
- Settings.__default_settings__['advanced/default service name'] = UiStrings().DefaultServiceName
-
- def __init__(self, *args):
- """
- Constructor which checks if this should be a native settings object, or an INI file.
- """
- if not args and Settings.__file_path__ and Settings.defaultFormat() == Settings.IniFormat:
- QtCore.QSettings.__init__(self, Settings.__file_path__, Settings.IniFormat)
- else:
- QtCore.QSettings.__init__(self, *args)
-
- def get_default_value(self, key):
- """
- Get the default value of the given key
- """
- if self.group():
- key = self.group() + '/' + key
- return Settings.__default_settings__[key]
-
- def remove_obsolete_settings(self):
- """
- This method is only called to clean up the config. It removes old settings and it renames settings. See
- ``__obsolete_settings__`` for more details.
- """
- for old_key, new_key, rules in Settings.__obsolete_settings__:
- # Once removed we don't have to do this again.
- if self.contains(old_key):
- if new_key:
- # Get the value of the old_key.
- old_value = super(Settings, self).value(old_key)
- # When we want to convert the value, we have to figure out the default value (because we cannot get
- # the default value from the central settings dict.
- if rules:
- default_value = rules[0][1]
- old_value = self._convert_value(old_value, default_value)
- # Iterate over our rules and check what the old_value should be "converted" to.
- for new, old in rules:
- # If the value matches with the condition (rule), then use the provided value. This is used to
- # convert values. E. g. an old value 1 results in True, and 0 in False.
- if old == old_value:
- old_value = new
- break
- self.setValue(new_key, old_value)
- self.remove(old_key)
-
- def value(self, key):
- """
- Returns the value for the given ``key``. The returned ``value`` is of the same type as the default value in the
- *Settings.__default_settings__* dict.
-
- ``key``
- The key to return the value from.
- """
- # if group() is not empty the group has not been specified together with the key.
- if self.group():
- default_value = Settings.__default_settings__[self.group() + '/' + key]
- else:
- default_value = Settings.__default_settings__[key]
- setting = super(Settings, self).value(key, default_value)
- return self._convert_value(setting, default_value)
-
- def _convert_value(self, setting, default_value):
- """
- This converts the given ``setting`` to the type of the given ``default_value``.
-
- ``setting``
- The setting to convert. This could be ``true`` for example.Settings()
-
- ``default_value``
- Indication the type the setting should be converted to. For example ``True`` (type is boolean), meaning that
- we convert the string ``true`` to a python boolean.
-
- **Note**, this method only converts a few types and might need to be extended if a certain type is missing!
- """
- # 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(default_value, str):
- return ''
- # 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(default_value, bool):
- if isinstance(setting, bool):
- return setting
- # Sometimes setting is string instead of a boolean.
- return setting == 'true'
- if isinstance(default_value, int):
- return int(setting)
- return setting
-
- def get_files_from_config(self, plugin):
- """
- This removes the settings needed for old way we saved files (e. g. the image paths for the image plugin). A list
- of file paths are returned.
-
- **Note**: Only a list of paths is returned; this does not convert anything!
-
- ``plugin``
- The Plugin object.The caller has to convert/save the list himself; o
- """
- files_list = []
- # We need QSettings instead of Settings here to bypass our central settings dict.
- # Do NOT do this anywhere else!
- settings = QtCore.QSettings(self.fileName(), Settings.IniFormat)
- settings.beginGroup(plugin.settings_section)
- if settings.contains('%s count' % plugin.name):
- # Get the count.
- list_count = int(settings.value('%s count' % plugin.name, 0))
- if list_count:
- for counter in range(list_count):
- # The keys were named e. g.: "image 0"
- item = settings.value('%s %d' % (plugin.name, counter), '')
- if item:
- files_list.append(item)
- settings.remove('%s %d' % (plugin.name, counter))
- settings.remove('%s count' % plugin.name)
- settings.endGroup()
- return files_list
=== modified file 'openlp/core/lib/theme.py'
--- openlp/core/lib/theme.py 2013-08-31 18:17:38 +0000
+++ openlp/core/lib/theme.py 2013-10-13 20:38:16 +0000
@@ -32,69 +32,16 @@
import os
import re
import logging
+import json
from xml.dom.minidom import Document
from lxml import etree, objectify
+from openlp.core.common import AppLocation
-from openlp.core.lib import str_to_bool, ScreenList
+from openlp.core.lib import str_to_bool, ScreenList, get_text_file_string
log = logging.getLogger(__name__)
-BLANK_THEME_XML = \
-'''<?xml version="1.0" encoding="utf-8"?>
- <theme version="1.0">
- <name> </name>
- <background type="image">
- <filename></filename>
- <borderColor>#000000</borderColor>
- </background>
- <background type="gradient">
- <startColor>#000000</startColor>
- <endColor>#000000</endColor>
- <direction>vertical</direction>
- </background>
- <background type="solid">
- <color>#000000</color>
- </background>
- <font type="main">
- <name>Arial</name>
- <color>#FFFFFF</color>
- <size>40</size>
- <bold>False</bold>
- <italics>False</italics>
- <line_adjustment>0</line_adjustment>
- <shadow shadowColor="#000000" shadowSize="5">True</shadow>
- <outline outlineColor="#000000" outlineSize="2">False</outline>
- <location override="False" x="10" y="10" width="1004" height="690"/>
- </font>
- <font type="footer">
- <name>Arial</name>
- <color>#FFFFFF</color>
- <size>12</size>
- <bold>False</bold>
- <italics>False</italics>
- <line_adjustment>0</line_adjustment>
- <shadow shadowColor="#000000" shadowSize="5">True</shadow>
- <outline outlineColor="#000000" outlineSize="2">False</outline>
- <location override="False" x="10" y="690" width="1004" height="78"/>
- </font>
- <display>
- <horizontalAlign>0</horizontalAlign>
- <verticalAlign>0</verticalAlign>
- <slideTransition>False</slideTransition>
- </display>
- </theme>
-'''
-
-
-class ThemeLevel(object):
- """
- Provides an enumeration for the level a theme applies to
- """
- Global = 1
- Service = 2
- Song = 3
-
class BackgroundType(object):
"""
@@ -217,9 +164,13 @@
"""
Initialise the theme object.
"""
- # Create the minidom document
- self.theme_xml = Document()
- self.parse_xml(BLANK_THEME_XML)
+ # basic theme object with defaults
+ json_dir = os.path.join(AppLocation.get_directory(AppLocation.AppDir), 'core', 'lib', 'json')
+ json_file = os.path.join(json_dir, 'theme.json')
+ jsn = get_text_file_string(json_file)
+ jsn = json.loads(jsn)
+ for key, value in jsn.items():
+ setattr(self, key, value)
def extend_image_filename(self, path):
"""
@@ -559,6 +510,7 @@
"""
Create the attributes with the correct data types and name format
"""
+ #print(master, element, value)
reject, master, element, value = self._translate_tags(master, element, value)
if reject:
return
=== modified file 'openlp/core/lib/ui.py'
--- openlp/core/lib/ui.py 2013-08-31 18:17:38 +0000
+++ openlp/core/lib/ui.py 2013-10-13 20:38:16 +0000
@@ -33,7 +33,8 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import Registry, UiStrings, build_icon, translate
+from openlp.core.common import UiStrings, translate
+from openlp.core.lib import Registry, build_icon
from openlp.core.utils.actions import ActionList
=== removed directory 'openlp/core/theme'
=== removed file 'openlp/core/theme/__init__.py'
--- openlp/core/theme/__init__.py 2013-02-01 19:58:18 +0000
+++ openlp/core/theme/__init__.py 1970-01-01 00:00:00 +0000
@@ -1,36 +0,0 @@
-# -*- coding: utf-8 -*-
-# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
-
-###############################################################################
-# OpenLP - Open Source Lyrics Projection #
-# --------------------------------------------------------------------------- #
-# Copyright (c) 2008-2013 Raoul Snyman #
-# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan #
-# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
-# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
-# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
-# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
-# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
-# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
-# --------------------------------------------------------------------------- #
-# 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:`~openlp.core.theme` module contains all the themeing functions used by
-OpenLP when displaying a song or a scripture.
-"""
-
-from openlp.core.theme.theme import Theme
-
-__all__ = ['Theme']
=== removed file 'openlp/core/theme/theme.py'
--- openlp/core/theme/theme.py 2013-08-31 18:17:38 +0000
+++ openlp/core/theme/theme.py 1970-01-01 00:00:00 +0000
@@ -1,252 +0,0 @@
-# -*- coding: utf-8 -*-
-# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
-
-###############################################################################
-# OpenLP - Open Source Lyrics Projection #
-# --------------------------------------------------------------------------- #
-# Copyright (c) 2008-2013 Raoul Snyman #
-# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan #
-# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
-# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
-# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
-# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
-# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
-# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
-# --------------------------------------------------------------------------- #
-# 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 #
-###############################################################################
-"""
-OpenLP version 1 theme handling
-
-Provides reference data, a default v1 XML theme and class wrapper for
-processing version 1 themes in OpenLP version 2.
-"""
-
-from xml.etree.ElementTree import ElementTree, XML
-from PyQt4 import QtGui
-
-DELPHI_COLORS = {
- 'clAqua': 0x00FFFF,
- 'clBlack': 0x000000,
- 'clBlue': 0x0000FF,
- 'clFuchsia': 0xFF00FF,
- 'clGray': 0x808080,
- 'clGreen': 0x008000,
- 'clLime': 0x00FF00,
- 'clMaroon': 0x800000,
- 'clNavy': 0x000080,
- 'clOlive': 0x808000,
- 'clPurple': 0x800080,
- 'clRed': 0xFF0000,
- 'clSilver': 0xC0C0C0,
- 'clTeal': 0x008080,
- 'clWhite': 0xFFFFFF,
- 'clYellow': 0xFFFF00
-}
-
-BLANK_STYLE_XML = \
-'''<?xml version="1.0" encoding="iso-8859-1"?>
-<Theme>
- <Name>BlankStyle</Name>
- <BackgroundMode>1</BackgroundMode>
- <BackgroundType>0</BackgroundType>
- <BackgroundParameter1>$000000</BackgroundParameter1>
- <BackgroundParameter2/>
- <BackgroundParameter3/>
- <FontName>Arial</FontName>
- <FontColor>clWhite</FontColor>
- <FontProportion>30</FontProportion>
- <FontUnits>pixels</FontUnits>
- <Shadow>0</Shadow>
- <Outline>0</Outline>
- <HorizontalAlign>0</HorizontalAlign>
- <VerticalAlign>0</VerticalAlign>
- <WrapStyle>0</WrapStyle>
-</Theme>
-'''
-
-
-class Theme(object):
- """
- Provide a class wrapper storing data from an XML theme
-
- ``name``
- Theme name
-
- ``BackgroundMode``
- The behaviour of the background. Valid modes are:
-
- * ``0`` - Transparent
- * ``1`` - Opaque
-
- ``BackgroundType``
- The content of the background. Valid types are:
-
- * ``0`` - solid color
- * ``1`` - gradient color
- * ``2`` - image
-
- ``BackgroundParameter1``
- Extra information about the background. The contents of this attribute
- depend on the BackgroundType:
-
- * ``image`` - image filename
- * ``gradient`` - start color
- * ``solid`` - color
-
- ``BackgroundParameter2``
- Extra information about the background. The contents of this attribute
- depend on the BackgroundType:
-
- * ``image`` - border color
- * ``gradient`` - end color
- * ``solid`` - N/A
-
- ``BackgroundParameter3``
- Extra information about the background. The contents of this attribute
- depend on the BackgroundType:
-
- * ``image`` - N/A
- * ``gradient`` - The direction of the gradient. Valid entries are:
-
- * ``0`` - vertical
- * ``1`` - horizontal
-
- * ``solid`` - N/A
-
- ``FontName``
- Name of the font to use for the main font.
-
- ``FontColor``
- The color for the main font
-
- ``FontProportion``
- The size of the main font
-
- ``FontUnits``
- The units for FontProportion, either <pixels> or <points>
-
- ``Shadow``
- The shadow type to apply to the main font.
-
- * ``0`` - no shadow
- * non-zero - use shadow
-
- ``ShadowColor``
- Color for the shadow
-
- ``Outline``
- The outline to apply to the main font
-
- * ``0`` - no outline
- * non-zero - use outline
-
- ``OutlineColor``
- Color for the outline (or None if Outline is 0)
-
- ``HorizontalAlign``
- The horizontal alignment to apply to text. Valid alignments are:
-
- * ``0`` - left align
- * ``1`` - right align
- * ``2`` - centre align
-
- ``VerticalAlign``
- The vertical alignment to apply to the text. Valid alignments are:
-
- * ``0`` - top align
- * ``1`` - bottom align
- * ``2`` - centre align
-
- ``WrapStyle``
- The wrap style to apply to the text. Valid styles are:
-
- * ``0`` - normal
- * ``1`` - lyrics
- """
-
- def __init__(self, xml):
- """
- Initialise a theme with data from xml
-
- ``xml``
- The data to initialise the theme with
- """
- # init to defaults
- self._set_from_xml(BLANK_STYLE_XML)
- self._set_from_xml(xml)
-
- def _get_as_string(self):
- """
- Return single line string representation of a theme
- """
- theme_strings = []
- keys = dir(self)
- keys.sort()
- for key in keys:
- if key[0:1] != '_':
- theme_strings.append('_%s_' % (getattr(self, key)))
- return ''.join(theme_strings)
-
- def _set_from_xml(self, xml):
- """
- Set theme class attributes with data from XML
-
- ``xml``
- The data to apply to the theme
- """
- root = ElementTree(element=XML(xml.encode('ascii', 'xmlcharrefreplace')))
- xml_iter = root.getiterator()
- for element in xml_iter:
- delphi_color_change = False
- if element.tag != 'Theme':
- element_text = element.text
- val = 0
- if element_text is None:
- val = element_text
- # strings need special handling to sort the colours out
- if isinstance(element_text, str):
- if element_text[0] == '$':
- # might be a hex number
- try:
- val = int(element_text[1:], 16)
- except ValueError:
- # nope
- pass
- elif element_text in DELPHI_COLORS:
- val = DELPHI_COLORS[element_text]
- delphi_color_change = True
- else:
- try:
- val = int(element_text)
- except ValueError:
- val = element_text
- if (element.tag.find('Color') > 0 or (element.tag.find('BackgroundParameter') == 0 and
- isinstance(val, int))):
- # convert to a wx.Colour
- if not delphi_color_change:
- val = QtGui.QColor(val & 0xFF, (val >> 8) & 0xFF, (val >> 16) & 0xFF)
- else:
- val = QtGui.QColor((val >> 16) & 0xFF, (val >> 8) & 0xFF, val & 0xFF)
- setattr(self, element.tag, val)
-
- def __str__(self):
- """
- Provide Python string representation for the class (multiline output)
- """
- theme_strings = []
- for key in dir(self):
- if key[0:1] != '_':
- theme_strings.append('%30s : %s' % (key, getattr(self, key)))
- return '\n'.join(theme_strings)
=== modified file 'openlp/core/ui/__init__.py'
--- openlp/core/ui/__init__.py 2013-09-01 06:31:09 +0000
+++ openlp/core/ui/__init__.py 2013-10-13 20:38:16 +0000
@@ -99,10 +99,11 @@
from .shortcutlistform import ShortcutListForm
from .mediadockmanager import MediaDockManager
from .servicemanager import ServiceManager
+from .thememanagerhelper import ThemeManagerHelper
from .thememanager import ThemeManager
__all__ = ['SplashScreen', 'AboutForm', 'SettingsForm', 'MainDisplay', 'SlideController', 'ServiceManager',
'ThemeManager', 'MediaDockManager', 'ServiceItemEditForm', 'FirstTimeForm', 'FirstTimeLanguageForm', 'ThemeForm',
'ThemeLayoutForm', 'FileRenameForm', 'StartTimeForm', 'MainDisplay', 'Display', 'ServiceNoteForm',
'SlideController', 'DisplayController', 'GeneralTab', 'ThemesTab', 'AdvancedTab', 'PluginForm',
- 'FormattingTagForm', 'ShortcutListForm', 'FormattingTagController']
+ 'FormattingTagForm', 'ShortcutListForm', 'FormattingTagController', 'ThemeManagerHelper']
=== modified file 'openlp/core/ui/aboutdialog.py'
--- openlp/core/ui/aboutdialog.py 2013-08-31 18:17:38 +0000
+++ openlp/core/ui/aboutdialog.py 2013-10-13 20:38:16 +0000
@@ -29,7 +29,8 @@
from PyQt4 import QtGui
-from openlp.core.lib import UiStrings, build_icon, translate
+from openlp.core.common import UiStrings, translate
+from openlp.core.lib import build_icon
from openlp.core.lib.ui import create_button, create_button_box
=== modified file 'openlp/core/ui/advancedtab.py'
--- openlp/core/ui/advancedtab.py 2013-08-31 18:17:38 +0000
+++ openlp/core/ui/advancedtab.py 2013-10-13 20:38:16 +0000
@@ -36,9 +36,9 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import SettingsTab, Settings, UiStrings, translate, build_icon
-from openlp.core.utils import AppLocation, format_time, get_images_filter
-from openlp.core.lib import SlideLimits
+from openlp.core.common import AppLocation, Settings, SlideLimits, UiStrings, translate
+from openlp.core.lib import SettingsTab, build_icon
+from openlp.core.utils import format_time, get_images_filter
log = logging.getLogger(__name__)
=== modified file 'openlp/core/ui/exceptionform.py'
--- openlp/core/ui/exceptionform.py 2013-09-14 19:16:14 +0000
+++ openlp/core/ui/exceptionform.py 2013-10-13 20:38:16 +0000
@@ -85,7 +85,7 @@
except ImportError:
VLC_VERSION = '-'
-from openlp.core.lib import UiStrings, Settings, translate
+from openlp.core.common import Settings, UiStrings, translate
from openlp.core.utils import get_application_version
from .exceptiondialog import Ui_ExceptionDialog
=== modified file 'openlp/core/ui/firsttimeform.py'
--- openlp/core/ui/firsttimeform.py 2013-08-31 18:17:38 +0000
+++ openlp/core/ui/firsttimeform.py 2013-10-13 20:38:16 +0000
@@ -41,8 +41,9 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import PluginStatus, Settings, Registry, build_icon, check_directory_exists, translate
-from openlp.core.utils import AppLocation, get_web_page
+from openlp.core.common import AppLocation, Settings, check_directory_exists
+from openlp.core.lib import PluginStatus, Registry, build_icon, translate
+from openlp.core.utils import get_web_page
from .firsttimewizard import Ui_FirstTimeWizard, FirstTimePage
log = logging.getLogger(__name__)
=== modified file 'openlp/core/ui/formattingtagdialog.py'
--- openlp/core/ui/formattingtagdialog.py 2013-09-15 06:37:43 +0000
+++ openlp/core/ui/formattingtagdialog.py 2013-10-13 20:38:16 +0000
@@ -31,7 +31,8 @@
"""
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import UiStrings, translate, build_icon
+from openlp.core.common import UiStrings, translate
+from openlp.core.lib import build_icon
from openlp.core.lib.ui import create_button_box
=== modified file 'openlp/core/ui/generaltab.py'
--- openlp/core/ui/generaltab.py 2013-08-31 18:17:38 +0000
+++ openlp/core/ui/generaltab.py 2013-10-13 20:38:16 +0000
@@ -33,7 +33,8 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import Registry, Settings, SettingsTab, ScreenList, UiStrings, translate
+from openlp.core.common import Settings, UiStrings, translate
+from openlp.core.lib import Registry, SettingsTab, ScreenList
log = logging.getLogger(__name__)
=== modified file 'openlp/core/ui/maindisplay.py'
--- openlp/core/ui/maindisplay.py 2013-08-31 18:17:38 +0000
+++ openlp/core/ui/maindisplay.py 2013-10-13 20:38:16 +0000
@@ -44,7 +44,8 @@
from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL
from PyQt4.phonon import Phonon
-from openlp.core.lib import ServiceItem, Settings, ImageSource, Registry, build_html, expand_tags, \
+from openlp.core.common import Settings
+from openlp.core.lib import ServiceItem, ImageSource, Registry, build_html, expand_tags, \
image_to_byte, translate
from openlp.core.lib.theme import BackgroundType
=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py 2013-08-31 18:17:38 +0000
+++ openlp/core/ui/mainwindow.py 2013-10-13 20:38:16 +0000
@@ -42,12 +42,14 @@
from PyQt4 import QtCore, QtGui
from openlp.core.lib import Renderer, OpenLPDockWidget, PluginManager, ImageManager, PluginStatus, Registry, \
- Settings, ScreenList, build_icon, check_directory_exists, translate
+ ScreenList, build_icon, translate
from openlp.core.lib.ui import UiStrings, create_action
from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, ThemeManager, SlideController, PluginForm, \
MediaDockManager, ShortcutListForm, FormattingTagForm
+
+from openlp.core.common import AppLocation, Settings, check_directory_exists
from openlp.core.ui.media import MediaController
-from openlp.core.utils import AppLocation, LanguageManager, add_actions, get_application_version
+from openlp.core.utils import LanguageManager, add_actions, get_application_version
from openlp.core.utils.actions import ActionList, CategoryOrder
from openlp.core.ui.firsttimeform import FirstTimeForm
=== modified file 'openlp/core/ui/media/__init__.py'
--- openlp/core/ui/media/__init__.py 2013-08-31 18:17:38 +0000
+++ openlp/core/ui/media/__init__.py 2013-10-13 20:38:16 +0000
@@ -31,7 +31,7 @@
"""
import logging
-from openlp.core.lib import Settings
+from openlp.core.common import Settings
from PyQt4 import QtCore
=== modified file 'openlp/core/ui/media/mediacontroller.py'
--- openlp/core/ui/media/mediacontroller.py 2013-08-31 18:17:38 +0000
+++ openlp/core/ui/media/mediacontroller.py 2013-10-13 20:38:16 +0000
@@ -35,11 +35,12 @@
import datetime
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import OpenLPToolbar, Settings, Registry, UiStrings, translate
+from openlp.core.common import Settings, UiStrings, translate
+from openlp.core.lib import OpenLPToolbar, Registry
from openlp.core.lib.ui import critical_error_message_box
from openlp.core.ui.media import MediaState, MediaInfo, MediaType, get_media_players, set_media_players
from openlp.core.ui.media.mediaplayer import MediaPlayer
-from openlp.core.utils import AppLocation
+from openlp.core.common import AppLocation
from openlp.core.ui import DisplayControllerType
log = logging.getLogger(__name__)
=== modified file 'openlp/core/ui/media/phononplayer.py'
--- openlp/core/ui/media/phononplayer.py 2013-08-31 18:17:38 +0000
+++ openlp/core/ui/media/phononplayer.py 2013-10-13 20:38:16 +0000
@@ -36,7 +36,8 @@
from PyQt4 import QtGui
from PyQt4.phonon import Phonon
-from openlp.core.lib import Settings, translate
+from openlp.core.common import Settings
+from openlp.core.lib import translate
from openlp.core.ui.media import MediaState
from openlp.core.ui.media.mediaplayer import MediaPlayer
=== modified file 'openlp/core/ui/media/playertab.py'
--- openlp/core/ui/media/playertab.py 2013-08-31 18:17:38 +0000
+++ openlp/core/ui/media/playertab.py 2013-10-13 20:38:16 +0000
@@ -31,7 +31,8 @@
"""
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import Registry, SettingsTab, Settings, UiStrings, translate
+from openlp.core.common import Settings, UiStrings, translate
+from openlp.core.lib import Registry, SettingsTab
from openlp.core.lib.ui import create_button
from openlp.core.ui.media import get_media_players, set_media_players
=== modified file 'openlp/core/ui/media/vlcplayer.py'
--- openlp/core/ui/media/vlcplayer.py 2013-08-31 18:17:38 +0000
+++ openlp/core/ui/media/vlcplayer.py 2013-10-13 20:38:16 +0000
@@ -37,7 +37,8 @@
from PyQt4 import QtGui
-from openlp.core.lib import Settings, translate
+from openlp.core.common import Settings
+from openlp.core.lib import translate
from openlp.core.ui.media import MediaState
from openlp.core.ui.media.mediaplayer import MediaPlayer
=== modified file 'openlp/core/ui/media/webkitplayer.py'
--- openlp/core/ui/media/webkitplayer.py 2013-08-31 18:17:38 +0000
+++ openlp/core/ui/media/webkitplayer.py 2013-10-13 20:38:16 +0000
@@ -33,7 +33,8 @@
import logging
-from openlp.core.lib import Settings, translate
+from openlp.core.common import Settings
+from openlp.core.lib import translate
from openlp.core.ui.media import MediaState
from openlp.core.ui.media.mediaplayer import MediaPlayer
=== modified file 'openlp/core/ui/plugindialog.py'
--- openlp/core/ui/plugindialog.py 2013-08-31 18:17:38 +0000
+++ openlp/core/ui/plugindialog.py 2013-10-13 20:38:16 +0000
@@ -31,7 +31,7 @@
#"""
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import UiStrings, translate
+from openlp.core.common import UiStrings, translate
from openlp.core.lib.ui import create_button_box
=== modified file 'openlp/core/ui/printservicedialog.py'
--- openlp/core/ui/printservicedialog.py 2013-08-31 18:17:38 +0000
+++ openlp/core/ui/printservicedialog.py 2013-10-13 20:38:16 +0000
@@ -31,7 +31,8 @@
"""
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import SpellTextEdit, UiStrings, build_icon, translate
+from openlp.core.common import UiStrings, translate
+from openlp.core.lib import SpellTextEdit, build_icon
class ZoomSize(object):
=== modified file 'openlp/core/ui/printserviceform.py'
--- openlp/core/ui/printserviceform.py 2013-08-31 18:17:38 +0000
+++ openlp/core/ui/printserviceform.py 2013-10-13 20:38:16 +0000
@@ -36,9 +36,10 @@
from PyQt4 import QtCore, QtGui
from lxml import html
-from openlp.core.lib import Settings, UiStrings, Registry, translate, get_text_file_string
+from openlp.core.common import Settings, UiStrings, translate
+from openlp.core.lib import Registry, get_text_file_string
from openlp.core.ui.printservicedialog import Ui_PrintServiceDialog, ZoomSize
-from openlp.core.utils import AppLocation
+from openlp.core.common import AppLocation
DEFAULT_CSS = """/*
Edit this file to customize the service order print. Note, that not all CSS
=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py 2013-09-07 07:52:52 +0000
+++ openlp/core/ui/servicemanager.py 2013-10-13 20:38:16 +0000
@@ -42,13 +42,14 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import OpenLPToolbar, ServiceItem, ItemCapabilities, Settings, PluginStatus, Registry, \
- UiStrings, build_icon, translate, str_to_bool, check_directory_exists
-from openlp.core.lib.theme import ThemeLevel
+from openlp.core.common import AppLocation, Settings, check_directory_exists, UiStrings, translate
+from openlp.core.lib import OpenLPToolbar, ServiceItem, ItemCapabilities, PluginStatus, Registry, \
+ build_icon
+from openlp.core.common import ThemeLevel
from openlp.core.lib.ui import critical_error_message_box, create_widget_action, find_and_set_in_combo_box
from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm
from openlp.core.ui.printserviceform import PrintServiceForm
-from openlp.core.utils import AppLocation, delete_file, split_filename, format_time
+from openlp.core.utils import delete_file, split_filename, format_time
from openlp.core.utils.actions import ActionList, CategoryOrder
=== modified file 'openlp/core/ui/shortcutlistform.py'
--- openlp/core/ui/shortcutlistform.py 2013-08-31 18:17:38 +0000
+++ openlp/core/ui/shortcutlistform.py 2013-10-13 20:38:16 +0000
@@ -33,8 +33,8 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import Registry, Settings
-from openlp.core.utils import translate
+from openlp.core.lib import Registry
+from openlp.core.common import Settings, translate
from openlp.core.utils.actions import ActionList
from .shortcutlistdialog import Ui_ShortcutListDialog
=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py 2013-08-31 18:17:38 +0000
+++ openlp/core/ui/slidecontroller.py 2013-10-13 20:38:16 +0000
@@ -37,8 +37,9 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import OpenLPToolbar, ItemCapabilities, ServiceItem, ImageSource, SlideLimits, \
- ServiceItemAction, Settings, Registry, UiStrings, ScreenList, build_icon, build_html, translate
+from openlp.core.common import Settings, SlideLimits, UiStrings, translate
+from openlp.core.lib import OpenLPToolbar, ItemCapabilities, ServiceItem, ImageSource, \
+ ServiceItemAction, Registry, ScreenList, build_icon, build_html
from openlp.core.ui import HideMode, MainDisplay, Display, DisplayControllerType
from openlp.core.lib.ui import create_action
from openlp.core.utils.actions import ActionList, CategoryOrder
=== modified file 'openlp/core/ui/starttimedialog.py'
--- openlp/core/ui/starttimedialog.py 2013-08-31 18:17:38 +0000
+++ openlp/core/ui/starttimedialog.py 2013-10-13 20:38:16 +0000
@@ -31,7 +31,7 @@
"""
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import UiStrings, translate
+from openlp.core.common import UiStrings, translate
from openlp.core.lib.ui import create_button_box
=== modified file 'openlp/core/ui/starttimeform.py'
--- openlp/core/ui/starttimeform.py 2013-09-09 21:10:40 +0000
+++ openlp/core/ui/starttimeform.py 2013-10-13 20:38:16 +0000
@@ -33,7 +33,8 @@
from .starttimedialog import Ui_StartTimeDialog
-from openlp.core.lib import UiStrings, Registry, translate
+from openlp.core.common import UiStrings, translate
+from openlp.core.lib import Registry
from openlp.core.lib.ui import critical_error_message_box
=== modified file 'openlp/core/ui/themeform.py'
--- openlp/core/ui/themeform.py 2013-08-31 18:17:38 +0000
+++ openlp/core/ui/themeform.py 2013-10-13 20:38:16 +0000
@@ -34,7 +34,8 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import UiStrings, Registry, translate
+from openlp.core.common import UiStrings, translate
+from openlp.core.lib import Registry
from openlp.core.lib.theme import BackgroundType, BackgroundGradientType
from openlp.core.lib.ui import critical_error_message_box
from openlp.core.ui import ThemeLayoutForm
=== modified file 'openlp/core/ui/thememanager.py'
--- openlp/core/ui/thememanager.py 2013-08-31 18:17:38 +0000
+++ openlp/core/ui/thememanager.py 2013-10-13 20:38:16 +0000
@@ -38,18 +38,18 @@
from xml.etree.ElementTree import ElementTree, XML
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import ImageSource, OpenLPToolbar, Registry, Settings, UiStrings, get_text_file_string, \
- build_icon, translate, check_item_selected, check_directory_exists, create_thumb, validate_thumb
-from openlp.core.lib.theme import ThemeXML, BackgroundType, VerticalType, BackgroundGradientType
+from openlp.core.common import AppLocation, Settings, check_directory_exists, UiStrings, translate
+from openlp.core.lib import ImageSource, OpenLPToolbar, Registry, get_text_file_string, \
+ build_icon, check_item_selected, create_thumb, validate_thumb
+from openlp.core.lib.theme import ThemeXML, BackgroundType
from openlp.core.lib.ui import critical_error_message_box, create_widget_action
-from openlp.core.theme import Theme
-from openlp.core.ui import FileRenameForm, ThemeForm
-from openlp.core.utils import AppLocation, delete_file, get_locale_key, get_filesystem_encoding
+from openlp.core.ui import FileRenameForm, ThemeForm, ThemeManagerHelper
+from openlp.core.utils import delete_file, get_locale_key, get_filesystem_encoding
log = logging.getLogger(__name__)
-class ThemeManager(QtGui.QWidget):
+class ThemeManager(QtGui.QWidget, ThemeManagerHelper):
"""
Manages the orders of Theme.
"""
@@ -328,8 +328,8 @@
try:
encoding = get_filesystem_encoding()
shutil.rmtree(os.path.join(self.path, theme).encode(encoding))
- except OSError as xxx_todo_changeme1:
- shutil.Error = xxx_todo_changeme1
+ except OSError as os_error:
+ shutil.Error = os_error
log.exception('Error deleting theme %s', theme)
def on_export_theme(self):
@@ -469,7 +469,7 @@
log.debug('No theme data - using default theme')
return ThemeXML()
else:
- return self._create_theme_fom_Xml(xml, self.path)
+ return self._create_theme_from_Xml(xml, self.path)
def over_write_message_box(self, theme_name):
"""
@@ -501,35 +501,30 @@
log.exception('Theme contains "%s" XML files' % len(xml_file))
raise Exception('validation')
xml_tree = ElementTree(element=XML(theme_zip.read(xml_file[0]))).getroot()
- v1_background = xml_tree.find('BackgroundType')
- if v1_background is not None:
- theme_name, file_xml, out_file, abort_import = \
- self.unzip_version_122(directory, theme_zip, xml_file[0], xml_tree, v1_background, out_file)
+ theme_name = xml_tree.find('name').text.strip()
+ theme_folder = os.path.join(directory, theme_name)
+ theme_exists = os.path.exists(theme_folder)
+ if theme_exists and not self.over_write_message_box(theme_name):
+ abort_import = True
+ return
else:
- theme_name = xml_tree.find('name').text.strip()
- theme_folder = os.path.join(directory, theme_name)
- theme_exists = os.path.exists(theme_folder)
- if theme_exists and not self.over_write_message_box(theme_name):
- abort_import = True
- return
+ abort_import = False
+ for name in theme_zip.namelist():
+ name = name.replace('/', os.path.sep)
+ split_name = name.split(os.path.sep)
+ if split_name[-1] == '' or len(split_name) == 1:
+ # is directory or preview file
+ continue
+ full_name = os.path.join(directory, name)
+ check_directory_exists(os.path.dirname(full_name))
+ if os.path.splitext(name)[1].lower() == '.xml':
+ file_xml = str(theme_zip.read(name), 'utf-8')
+ out_file = open(full_name, 'w')
+ out_file.write(file_xml)
else:
- abort_import = False
- for name in theme_zip.namelist():
- name = name.replace('/', os.path.sep)
- split_name = name.split(os.path.sep)
- if split_name[-1] == '' or len(split_name) == 1:
- # is directory or preview file
- continue
- full_name = os.path.join(directory, name)
- check_directory_exists(os.path.dirname(full_name))
- if os.path.splitext(name)[1].lower() == '.xml':
- file_xml = str(theme_zip.read(name), 'utf-8')
- out_file = open(full_name, 'w')
- out_file.write(file_xml)
- else:
- out_file = open(full_name, 'wb')
- out_file.write(theme_zip.read(name))
- out_file.close()
+ out_file = open(full_name, 'wb')
+ out_file.write(theme_zip.read(name))
+ out_file.close()
except (IOError, zipfile.BadZipfile):
log.exception('Importing theme from zip failed %s' % file_name)
raise Exception('validation')
@@ -548,7 +543,7 @@
if not abort_import:
# As all files are closed, we can create the Theme.
if file_xml:
- theme = self._create_theme_fom_Xml(file_xml, self.path)
+ theme = self._create_theme_from_Xml(file_xml, self.path)
self.generate_and_save_image(directory, theme_name, theme)
# Only show the error message, when IOError was not raised (in
# this case the error message has already been shown).
@@ -558,38 +553,6 @@
translate('OpenLP.ThemeManager', 'File is not a valid theme.'))
log.exception('Theme file does not contain XML data %s' % file_name)
- def unzip_version_122(self, dir_name, zip_file, xml_file, xml_tree, background, out_file):
- """
- Unzip openlp.org 1.2x theme file and upgrade the theme xml. When calling
- this method, please keep in mind, that some parameters are redundant.
- """
- theme_name = xml_tree.find('Name').text.strip()
- theme_name = self.bad_v1_name_chars.sub('', theme_name)
- theme_folder = os.path.join(dir_name, theme_name)
- theme_exists = os.path.exists(theme_folder)
- if theme_exists and not self.over_write_message_box(theme_name):
- return '', '', '', True
- themedir = os.path.join(dir_name, theme_name)
- check_directory_exists(themedir)
- file_xml = str(zip_file.read(xml_file), 'utf-8')
- file_xml = self._migrate_version_122(file_xml)
- out_file = open(os.path.join(themedir, theme_name + '.xml'), 'w')
- out_file.write(file_xml.encode('utf-8'))
- out_file.close()
- if background.text.strip() == '2':
- image_name = xml_tree.find('BackgroundParameter1').text.strip()
- # image file has same extension and is in subfolder
- image_file = [name for name in zip_file.namelist() if os.path.splitext(name)[1].lower()
- == os.path.splitext(image_name)[1].lower() and name.find(r'/')]
- if len(image_file) >= 1:
- out_file = open(os.path.join(themedir, image_name), 'wb')
- out_file.write(zip_file.read(image_file[0]))
- out_file.close()
- else:
- log.exception('Theme file does not contain image file "%s"' % image_name.decode('utf-8', 'replace'))
- raise Exception('validation')
- return theme_name, file_xml, out_file, False
-
def check_if_theme_exists(self, theme_name):
"""
Check if theme already exists and displays error message
@@ -697,7 +660,7 @@
image = os.path.join(self.path, theme + '.png')
return image
- def _create_theme_fom_Xml(self, theme_xml, path):
+ def _create_theme_from_Xml(self, theme_xml, path):
"""
Return a theme object using information parsed from XML
@@ -741,55 +704,6 @@
return True
return False
- def _migrate_version_122(self, xml_data):
- """
- Convert the xml data from version 1 format to the current format.
-
- New fields are loaded with defaults to provide a complete, working
- theme containing all compatible customisations from the old theme.
-
- ``xml_data``
- Version 1 theme to convert
- """
- theme = Theme(xml_data)
- new_theme = ThemeXML()
- new_theme.theme_name = self.bad_v1_name_chars.sub('', theme.Name)
- if theme.BackgroundType == BackgroundType.Solid:
- new_theme.background_type = BackgroundType.to_string(BackgroundType.Solid)
- new_theme.background_color = str(theme.BackgroundParameter1.name())
- elif theme.BackgroundType == BackgroundType.Horizontal:
- new_theme.background_type = BackgroundType.to_string(BackgroundType.Gradient)
- new_theme.background_direction = BackgroundGradientType.to_string(BackgroundGradientType.Horizontal)
- if theme.BackgroundParameter3.name() == 1:
- new_theme.background_direction = BackgroundGradientType.to_string(BackgroundGradientType.Horizontal)
- new_theme.background_start_color = str(theme.BackgroundParameter1.name())
- new_theme.background_end_color = str(theme.BackgroundParameter2.name())
- elif theme.BackgroundType == BackgroundType.Image:
- new_theme.background_type = BackgroundType.to_string(BackgroundType.Image)
- new_theme.background_filename = str(theme.BackgroundParameter1)
- elif theme.BackgroundType == BackgroundType.Transparent:
- new_theme.background_type = BackgroundType.to_string(BackgroundType.Transparent)
- new_theme.font_main_name = theme.FontName
- new_theme.font_main_color = str(theme.FontColor.name())
- new_theme.font_main_size = theme.FontProportion * 3
- new_theme.font_footer_name = theme.FontName
- new_theme.font_footer_color = str(theme.FontColor.name())
- new_theme.font_main_shadow = False
- if theme.Shadow == 1:
- new_theme.font_main_shadow = True
- new_theme.font_main_shadow_color = str(theme.ShadowColor.name())
- if theme.Outline == 1:
- new_theme.font_main_outline = True
- new_theme.font_main_outline_color = str(theme.OutlineColor.name())
- vAlignCorrection = VerticalType.Top
- if theme.VerticalAlign == 2:
- vAlignCorrection = VerticalType.Middle
- elif theme.VerticalAlign == 1:
- vAlignCorrection = VerticalType.Bottom
- new_theme.display_horizontal_align = theme.HorizontalAlign
- new_theme.display_vertical_align = vAlignCorrection
- return new_theme.extract_xml()
-
def _get_renderer(self):
"""
Adds the Renderer to the class dynamically
=== added file 'openlp/core/ui/thememanagerhelper.py'
--- openlp/core/ui/thememanagerhelper.py 1970-01-01 00:00:00 +0000
+++ openlp/core/ui/thememanagerhelper.py 2013-10-13 20:38:16 +0000
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2013 Raoul Snyman #
+# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan #
+# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
+# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
+# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
+# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
+# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
+# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
+# --------------------------------------------------------------------------- #
+# 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 Theme Controller helps manages adding, deleteing and modifying of themes.
+"""
+
+
+class ThemeManagerHelper(object):
+ """
+ Manages the non ui theme functions.
+ """
+ pass
\ No newline at end of file
=== modified file 'openlp/core/ui/themestab.py'
--- openlp/core/ui/themestab.py 2013-08-31 18:17:38 +0000
+++ openlp/core/ui/themestab.py 2013-10-13 20:38:16 +0000
@@ -33,8 +33,8 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import Registry, Settings, SettingsTab, UiStrings, translate
-from openlp.core.lib.theme import ThemeLevel
+from openlp.core.common import Settings, ThemeLevel, UiStrings, translate
+from openlp.core.lib import Registry, SettingsTab
from openlp.core.lib.ui import find_and_set_in_combo_box
=== modified file 'openlp/core/ui/themewizard.py'
--- openlp/core/ui/themewizard.py 2013-08-31 18:17:38 +0000
+++ openlp/core/ui/themewizard.py 2013-10-13 20:38:16 +0000
@@ -31,7 +31,8 @@
"""
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import UiStrings, build_icon, translate
+from openlp.core.common import UiStrings, translate
+from openlp.core.lib import build_icon
from openlp.core.lib.theme import HorizontalType, BackgroundType, BackgroundGradientType
from openlp.core.lib.ui import add_welcome_page, create_valign_selection_widgets
=== modified file 'openlp/core/ui/wizard.py'
--- openlp/core/ui/wizard.py 2013-08-31 18:17:38 +0000
+++ openlp/core/ui/wizard.py 2013-10-13 20:38:16 +0000
@@ -32,9 +32,10 @@
import logging
import os
-from PyQt4 import QtCore, QtGui
+from PyQt4 import QtGui
-from openlp.core.lib import Registry, Settings, UiStrings, build_icon, translate
+from openlp.core.common import Settings, UiStrings, translate
+from openlp.core.lib import Registry, build_icon
from openlp.core.lib.ui import add_welcome_page
log = logging.getLogger(__name__)
=== modified file 'openlp/core/utils/__init__.py'
--- openlp/core/utils/__init__.py 2013-09-09 21:10:40 +0000
+++ openlp/core/utils/__init__.py 2013-10-13 20:38:16 +0000
@@ -37,11 +37,14 @@
import re
from subprocess import Popen, PIPE
import sys
-import urllib.request, urllib.error, urllib.parse
+import urllib.request
+import urllib.error
+import urllib.parse
from PyQt4 import QtGui, QtCore
-from openlp.core.lib import Registry, Settings
+from openlp.core.common import AppLocation, Settings
+from openlp.core.lib import Registry
if sys.platform != 'win32' and sys.platform != 'darwin':
@@ -81,15 +84,6 @@
Registry().execute('openlp_version_check', '%s' % version)
-def _get_frozen_path(frozen_option, non_frozen_option):
- """
- Return a path based on the system status.
- """
- if hasattr(sys, 'frozen') and sys.frozen == 1:
- return frozen_option
- return non_frozen_option
-
-
def get_application_version():
"""
Returns the application version of the running instance of OpenLP::
@@ -418,18 +412,17 @@
"""
key = DIGITS_OR_NONDIGITS.findall(string)
key = [int(part) if part.isdigit() else get_locale_key(part) for part in key]
- # Python 3 does not support comparision of different types anymore. So make sure, that we do not compare str
+ # Python 3 does not support comparison of different types anymore. So make sure, that we do not compare str
# and int.
if string[0].isdigit():
return [b''] + key
return key
-from .applocation import AppLocation
from .languagemanager import LanguageManager
from .actions import ActionList
-__all__ = ['AppLocation', 'ActionList', 'LanguageManager', 'get_application_version', 'check_latest_version',
+__all__ = ['ActionList', 'LanguageManager', 'get_application_version', 'check_latest_version',
'add_actions', 'get_filesystem_encoding', 'get_web_page', 'get_uno_command', 'get_uno_instance',
'delete_file', 'clean_filename', 'format_time', 'get_locale_key', 'get_natural_key']
=== modified file 'openlp/core/utils/actions.py'
--- openlp/core/utils/actions.py 2013-08-31 18:17:38 +0000
+++ openlp/core/utils/actions.py 2013-10-13 20:38:16 +0000
@@ -34,7 +34,7 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import Settings
+from openlp.core.common import Settings
log = logging.getLogger(__name__)
=== removed file 'openlp/core/utils/applocation.py'
--- openlp/core/utils/applocation.py 2013-08-31 18:17:38 +0000
+++ openlp/core/utils/applocation.py 1970-01-01 00:00:00 +0000
@@ -1,174 +0,0 @@
-# -*- coding: utf-8 -*-
-# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
-
-###############################################################################
-# OpenLP - Open Source Lyrics Projection #
-# --------------------------------------------------------------------------- #
-# Copyright (c) 2008-2013 Raoul Snyman #
-# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan #
-# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
-# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
-# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
-# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
-# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
-# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
-# --------------------------------------------------------------------------- #
-# 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:`openlp.core.utils.applocation` module provides an utility for OpenLP receiving the data path etc.
-"""
-import logging
-import os
-import sys
-
-from openlp.core.lib import Settings
-from openlp.core.utils import _get_frozen_path
-
-
-if sys.platform != 'win32' and sys.platform != 'darwin':
- try:
- from xdg import BaseDirectory
- XDG_BASE_AVAILABLE = True
- except ImportError:
- XDG_BASE_AVAILABLE = False
-
-import openlp
-from openlp.core.lib import check_directory_exists
-
-
-log = logging.getLogger(__name__)
-
-
-class AppLocation(object):
- """
- The :class:`AppLocation` class is a static class which retrieves a directory based on the directory type.
- """
- AppDir = 1
- DataDir = 2
- PluginsDir = 3
- VersionDir = 4
- CacheDir = 5
- LanguageDir = 6
-
- # Base path where data/config/cache dir is located
- BaseDir = None
-
- @staticmethod
- def get_directory(dir_type=AppDir):
- """
- Return the appropriate directory according to the directory type.
-
- ``dir_type``
- The directory type you want, for instance the data directory. Default *AppLocation.AppDir*
- """
- if dir_type == AppLocation.AppDir:
- return _get_frozen_path(os.path.abspath(os.path.split(sys.argv[0])[0]), os.path.split(openlp.__file__)[0])
- elif dir_type == AppLocation.PluginsDir:
- app_path = os.path.abspath(os.path.split(sys.argv[0])[0])
- return _get_frozen_path(os.path.join(app_path, 'plugins'),
- os.path.join(os.path.split(openlp.__file__)[0], 'plugins'))
- elif dir_type == AppLocation.VersionDir:
- return _get_frozen_path(os.path.abspath(os.path.split(sys.argv[0])[0]), os.path.split(openlp.__file__)[0])
- elif dir_type == AppLocation.LanguageDir:
- app_path = _get_frozen_path(os.path.abspath(os.path.split(sys.argv[0])[0]), _get_os_dir_path(dir_type))
- return os.path.join(app_path, 'i18n')
- elif dir_type == AppLocation.DataDir and AppLocation.BaseDir:
- return os.path.join(AppLocation.BaseDir, 'data')
- else:
- return _get_os_dir_path(dir_type)
-
- @staticmethod
- def get_data_path():
- """
- Return the path OpenLP stores all its data under.
- """
- # Check if we have a different data location.
- if Settings().contains('advanced/data path'):
- path = Settings().value('advanced/data path')
- else:
- path = AppLocation.get_directory(AppLocation.DataDir)
- check_directory_exists(path)
- return os.path.normpath(path)
-
- @staticmethod
- def get_files(section=None, extension=None):
- """
- Get a list of files from the data files path.
-
- ``section``
- Defaults to *None*. The section of code getting the files - used to load from a section's data subdirectory.
-
- ``extension``
- Defaults to *None*. The extension to search for. For example::
-
- u'.png'
- """
- path = AppLocation.get_data_path()
- if section:
- path = os.path.join(path, section)
- try:
- files = os.listdir(path)
- except OSError:
- return []
- if extension:
- return [filename for filename in files if extension == os.path.splitext(filename)[1]]
- else:
- # no filtering required
- return files
-
- @staticmethod
- def get_section_data_path(section):
- """
- Return the path a particular module stores its data under.
- """
- data_path = AppLocation.get_data_path()
- path = os.path.join(data_path, section)
- check_directory_exists(path)
- return path
-
-
-def _get_os_dir_path(dir_type):
- """
- Return a path based on which OS and environment we are running in.
- """
- if sys.platform == 'win32':
- if dir_type == AppLocation.DataDir:
- return os.path.join(str(os.getenv('APPDATA')), 'openlp', 'data')
- elif dir_type == AppLocation.LanguageDir:
- return os.path.split(openlp.__file__)[0]
- return os.path.join(str(os.getenv('APPDATA')), 'openlp')
- elif sys.platform == 'darwin':
- if dir_type == AppLocation.DataDir:
- return os.path.join(str(os.getenv('HOME')),
- 'Library', 'Application Support', 'openlp', 'Data')
- elif dir_type == AppLocation.LanguageDir:
- return os.path.split(openlp.__file__)[0]
- return os.path.join(str(os.getenv('HOME')), 'Library', 'Application Support', 'openlp')
- else:
- if dir_type == AppLocation.LanguageDir:
- for prefix in ['/usr/local', '/usr']:
- directory = os.path.join(prefix, 'share', 'openlp')
- if os.path.exists(directory):
- return directory
- return os.path.join('/usr', 'share', 'openlp')
- if XDG_BASE_AVAILABLE:
- if dir_type == AppLocation.DataDir:
- return os.path.join(str(BaseDirectory.xdg_data_home), 'openlp')
- elif dir_type == AppLocation.CacheDir:
- return os.path.join(str(BaseDirectory.xdg_cache_home), 'openlp')
- if dir_type == AppLocation.DataDir:
- return os.path.join(str(os.getenv('HOME')), '.openlp', 'data')
- return os.path.join(str(os.getenv('HOME')), '.openlp')
-
=== modified file 'openlp/core/utils/languagemanager.py'
--- openlp/core/utils/languagemanager.py 2013-08-31 18:17:38 +0000
+++ openlp/core/utils/languagemanager.py 2013-10-13 20:38:16 +0000
@@ -35,8 +35,8 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.utils import AppLocation
-from openlp.core.lib import Settings, translate
+from openlp.core.common import AppLocation, Settings
+from openlp.core.lib import translate
log = logging.getLogger(__name__)
=== modified file 'openlp/plugins/alerts/alertsplugin.py'
--- openlp/plugins/alerts/alertsplugin.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/alerts/alertsplugin.py 2013-10-13 20:38:16 +0000
@@ -31,7 +31,8 @@
from PyQt4 import QtGui
-from openlp.core.lib import Plugin, Settings, StringContent, build_icon, translate
+from openlp.core.common import Settings
+from openlp.core.lib import Plugin, StringContent, build_icon, translate
from openlp.core.lib.db import Manager
from openlp.core.lib.ui import create_action, UiStrings
from openlp.core.lib.theme import VerticalType
=== modified file 'openlp/plugins/alerts/lib/alertstab.py'
--- openlp/plugins/alerts/lib/alertstab.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/alerts/lib/alertstab.py 2013-10-13 20:38:16 +0000
@@ -29,7 +29,8 @@
from PyQt4 import QtGui
-from openlp.core.lib import SettingsTab, Settings, UiStrings, translate
+from openlp.core.common import Settings, UiStrings, translate
+from openlp.core.lib import SettingsTab
from openlp.core.lib.ui import create_valign_selection_widgets
=== modified file 'openlp/plugins/bibles/forms/bibleimportform.py'
--- openlp/plugins/bibles/forms/bibleimportform.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/bibles/forms/bibleimportform.py 2013-10-13 20:38:16 +0000
@@ -32,13 +32,13 @@
import logging
import os
-from PyQt4 import QtCore, QtGui
+from PyQt4 import QtGui
-from openlp.core.lib import Settings, UiStrings, translate
+from openlp.core.common import AppLocation, Settings, UiStrings, translate
from openlp.core.lib.db import delete_database
from openlp.core.lib.ui import critical_error_message_box
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
-from openlp.core.utils import AppLocation, get_locale_key
+from openlp.core.utils import get_locale_key
from openlp.plugins.bibles.lib.manager import BibleFormat
from openlp.plugins.bibles.lib.db import BiblesResourcesDB, clean_filename
=== modified file 'openlp/plugins/bibles/forms/bibleupgradeform.py'
--- openlp/plugins/bibles/forms/bibleupgradeform.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/bibles/forms/bibleupgradeform.py 2013-10-13 20:38:16 +0000
@@ -36,10 +36,11 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import Registry, Settings, UiStrings, translate, check_directory_exists
+from openlp.core.common import AppLocation, UiStrings, Settings, check_directory_exists, translate
+from openlp.core.lib import Registry
from openlp.core.lib.ui import critical_error_message_box
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
-from openlp.core.utils import AppLocation, delete_file
+from openlp.core.utils import delete_file
from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta, OldBibleDB, BiblesResourcesDB
from openlp.plugins.bibles.lib.http import BSExtract, BGExtract, CWExtract
=== modified file 'openlp/plugins/bibles/forms/booknamedialog.py'
--- openlp/plugins/bibles/forms/booknamedialog.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/bibles/forms/booknamedialog.py 2013-10-13 20:38:16 +0000
@@ -29,7 +29,7 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import translate
+from openlp.core.common import translate
from openlp.core.lib.ui import create_button_box
class Ui_BookNameDialog(object):
=== modified file 'openlp/plugins/bibles/forms/booknameform.py'
--- openlp/plugins/bibles/forms/booknameform.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/bibles/forms/booknameform.py 2013-10-13 20:38:16 +0000
@@ -36,7 +36,7 @@
from PyQt4.QtGui import QDialog
from PyQt4 import QtCore
-from openlp.core.lib import translate
+from openlp.core.common import translate
from openlp.core.lib.ui import critical_error_message_box
from openlp.plugins.bibles.forms.booknamedialog import Ui_BookNameDialog
from openlp.plugins.bibles.lib import BibleStrings
=== modified file 'openlp/plugins/bibles/forms/editbibledialog.py'
--- openlp/plugins/bibles/forms/editbibledialog.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/bibles/forms/editbibledialog.py 2013-10-13 20:38:16 +0000
@@ -29,7 +29,8 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import build_icon, translate
+from openlp.core.common import translate
+from openlp.core.lib import build_icon
from openlp.core.lib.ui import create_button_box
from openlp.plugins.bibles.lib import LanguageSelection, BibleStrings
from openlp.plugins.bibles.lib.db import BiblesResourcesDB
=== modified file 'openlp/plugins/bibles/forms/editbibleform.py'
--- openlp/plugins/bibles/forms/editbibleform.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/bibles/forms/editbibleform.py 2013-10-13 20:38:16 +0000
@@ -33,7 +33,8 @@
from PyQt4 import QtGui
-from openlp.core.lib import Registry, UiStrings, translate
+from openlp.core.common import UiStrings, translate
+from openlp.core.lib import Registry
from openlp.core.lib.ui import critical_error_message_box
from .editbibledialog import Ui_EditBibleDialog
from openlp.plugins.bibles.lib import BibleStrings
=== modified file 'openlp/plugins/bibles/forms/languagedialog.py'
--- openlp/plugins/bibles/forms/languagedialog.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/bibles/forms/languagedialog.py 2013-10-13 20:38:16 +0000
@@ -29,7 +29,7 @@
from PyQt4 import QtGui
-from openlp.core.lib import translate
+from openlp.core.common import translate
from openlp.core.lib.ui import create_button_box
class Ui_LanguageDialog(object):
=== modified file 'openlp/plugins/bibles/forms/languageform.py'
--- openlp/plugins/bibles/forms/languageform.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/bibles/forms/languageform.py 2013-10-13 20:38:16 +0000
@@ -34,7 +34,7 @@
from PyQt4.QtGui import QDialog
-from openlp.core.lib import translate
+from openlp.core.common import translate
from openlp.core.lib.ui import critical_error_message_box
from openlp.plugins.bibles.forms.languagedialog import \
Ui_LanguageDialog
=== modified file 'openlp/plugins/bibles/lib/__init__.py'
--- openlp/plugins/bibles/lib/__init__.py 2013-08-31 19:59:13 +0000
+++ openlp/plugins/bibles/lib/__init__.py 2013-10-13 20:38:16 +0000
@@ -33,7 +33,8 @@
import logging
import re
-from openlp.core.lib import Settings, translate
+from openlp.core.common import Settings
+from openlp.core.lib import translate
log = logging.getLogger(__name__)
=== modified file 'openlp/plugins/bibles/lib/biblestab.py'
--- openlp/plugins/bibles/lib/biblestab.py 2013-09-16 16:30:59 +0000
+++ openlp/plugins/bibles/lib/biblestab.py 2013-10-13 20:38:16 +0000
@@ -31,7 +31,8 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import Registry, SettingsTab, Settings, UiStrings, translate
+from openlp.core.common import Settings, UiStrings, translate
+from openlp.core.lib import Registry, SettingsTab
from openlp.core.lib.ui import find_and_set_in_combo_box
from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, update_reference_separators, \
get_reference_separator, LanguageSelection
=== modified file 'openlp/plugins/bibles/lib/db.py'
--- openlp/plugins/bibles/lib/db.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/bibles/lib/db.py 2013-10-13 20:38:16 +0000
@@ -38,10 +38,11 @@
from sqlalchemy.orm import class_mapper, mapper, relation
from sqlalchemy.orm.exc import UnmappedClassError
+from openlp.core.common import AppLocation
from openlp.core.lib import Registry, translate
from openlp.core.lib.db import BaseModel, init_db, Manager
from openlp.core.lib.ui import critical_error_message_box
-from openlp.core.utils import AppLocation, clean_filename
+from openlp.core.utils import clean_filename
from . import upgrade
log = logging.getLogger(__name__)
=== modified file 'openlp/plugins/bibles/lib/manager.py'
--- openlp/plugins/bibles/lib/manager.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/bibles/lib/manager.py 2013-10-13 20:38:16 +0000
@@ -30,8 +30,9 @@
import logging
import os
-from openlp.core.lib import Registry, Settings, translate
-from openlp.core.utils import AppLocation, delete_file
+from openlp.core.common import AppLocation, Settings
+from openlp.core.lib import Registry, translate
+from openlp.core.utils import delete_file
from openlp.plugins.bibles.lib import parse_reference, get_reference_separator, LanguageSelection
from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta
from .csvbible import CSVBible
=== modified file 'openlp/plugins/bibles/lib/mediaitem.py'
--- openlp/plugins/bibles/lib/mediaitem.py 2013-10-02 21:07:20 +0000
+++ openlp/plugins/bibles/lib/mediaitem.py 2013-10-13 20:38:16 +0000
@@ -31,8 +31,9 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import Registry, MediaManagerItem, ItemCapabilities, ServiceItemContext, Settings, UiStrings, \
- create_separated_list, translate
+from openlp.core.common import Settings, UiStrings, translate
+from openlp.core.lib import Registry, MediaManagerItem, ItemCapabilities, ServiceItemContext, \
+ create_separated_list
from openlp.core.lib.searchedit import SearchEdit
from openlp.core.lib.ui import set_case_insensitive_completer, create_horizontal_adjusting_combo_box, \
critical_error_message_box, find_and_set_in_combo_box, build_icon
=== modified file 'openlp/plugins/bibles/lib/osis.py'
--- openlp/plugins/bibles/lib/osis.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/bibles/lib/osis.py 2013-10-13 20:38:16 +0000
@@ -33,8 +33,8 @@
import codecs
import re
+from openlp.core.common import AppLocation
from openlp.core.lib import translate
-from openlp.core.utils import AppLocation
from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB
log = logging.getLogger(__name__)
=== modified file 'openlp/plugins/custom/forms/editcustomdialog.py'
--- openlp/plugins/custom/forms/editcustomdialog.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/custom/forms/editcustomdialog.py 2013-10-13 20:38:16 +0000
@@ -29,7 +29,8 @@
from PyQt4 import QtGui
-from openlp.core.lib import UiStrings, build_icon, translate
+from openlp.core.common import UiStrings, translate
+from openlp.core.lib import build_icon
from openlp.core.lib.ui import create_button_box, create_button
=== modified file 'openlp/plugins/custom/forms/editcustomslidedialog.py'
--- openlp/plugins/custom/forms/editcustomslidedialog.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/custom/forms/editcustomslidedialog.py 2013-10-13 20:38:16 +0000
@@ -29,7 +29,8 @@
from PyQt4 import QtGui
-from openlp.core.lib import SpellTextEdit, UiStrings, translate
+from openlp.core.common import UiStrings, translate
+from openlp.core.lib import SpellTextEdit
from openlp.core.lib.ui import create_button, create_button_box
class Ui_CustomSlideEditDialog(object):
=== modified file 'openlp/plugins/custom/forms/editcustomslideform.py'
--- openlp/plugins/custom/forms/editcustomslideform.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/custom/forms/editcustomslideform.py 2013-10-13 20:38:16 +0000
@@ -30,7 +30,7 @@
import logging
-from PyQt4 import QtCore, QtGui
+from PyQt4 import QtGui
from .editcustomslidedialog import Ui_CustomSlideEditDialog
=== modified file 'openlp/plugins/custom/lib/customtab.py'
--- openlp/plugins/custom/lib/customtab.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/custom/lib/customtab.py 2013-10-13 20:38:16 +0000
@@ -33,7 +33,8 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import SettingsTab, Settings, translate
+from openlp.core.common import Settings, translate
+from openlp.core.lib import SettingsTab
class CustomTab(SettingsTab):
=== modified file 'openlp/plugins/custom/lib/mediaitem.py'
--- openlp/plugins/custom/lib/mediaitem.py 2013-10-02 21:07:20 +0000
+++ openlp/plugins/custom/lib/mediaitem.py 2013-10-13 20:38:16 +0000
@@ -32,8 +32,9 @@
from PyQt4 import QtCore, QtGui
from sqlalchemy.sql import or_, func, and_
-from openlp.core.lib import Registry, MediaManagerItem, ItemCapabilities, ServiceItemContext, Settings, PluginStatus,\
- UiStrings, check_item_selected, translate
+from openlp.core.common import Settings, UiStrings, translate
+from openlp.core.lib import Registry, MediaManagerItem, ItemCapabilities, ServiceItemContext, PluginStatus,\
+ check_item_selected
from openlp.plugins.custom.forms.editcustomform import EditCustomForm
from openlp.plugins.custom.lib import CustomXMLParser, CustomXMLBuilder
from openlp.plugins.custom.lib.db import CustomSlide
=== modified file 'openlp/plugins/images/imageplugin.py'
--- openlp/plugins/images/imageplugin.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/images/imageplugin.py 2013-10-13 20:38:16 +0000
@@ -31,10 +31,11 @@
import logging
-from openlp.core.lib import Plugin, StringContent, Registry, ImageSource, Settings, build_icon, translate
+from openlp.core.common import Settings
+from openlp.core.lib import Plugin, StringContent, Registry, ImageSource, build_icon, translate
from openlp.core.lib.db import Manager
from openlp.plugins.images.lib import ImageMediaItem, ImageTab
-from openlp.plugins.images.lib.db import init_schema, ImageFilenames
+from openlp.plugins.images.lib.db import init_schema
log = logging.getLogger(__name__)
=== modified file 'openlp/plugins/images/lib/imagetab.py'
--- openlp/plugins/images/lib/imagetab.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/images/lib/imagetab.py 2013-10-13 20:38:16 +0000
@@ -29,7 +29,8 @@
from PyQt4 import QtGui
-from openlp.core.lib import Registry, SettingsTab, Settings, UiStrings, translate
+from openlp.core.common import Settings, UiStrings, translate
+from openlp.core.lib import SettingsTab
class ImageTab(SettingsTab):
=== modified file 'openlp/plugins/images/lib/mediaitem.py'
--- openlp/plugins/images/lib/mediaitem.py 2013-10-02 21:07:20 +0000
+++ openlp/plugins/images/lib/mediaitem.py 2013-10-13 20:38:16 +0000
@@ -32,11 +32,12 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import ItemCapabilities, MediaManagerItem, Registry, ServiceItemContext, Settings, \
- StringContent, TreeWidgetWithDnD, UiStrings, build_icon, check_directory_exists, check_item_selected, \
- create_thumb, translate, validate_thumb
+from openlp.core.common import AppLocation, Settings, UiStrings, check_directory_exists, translate
+from openlp.core.lib import ItemCapabilities, MediaManagerItem, Registry, ServiceItemContext, \
+ StringContent, TreeWidgetWithDnD, build_icon, check_item_selected, create_thumb, \
+ validate_thumb
from openlp.core.lib.ui import create_widget_action, critical_error_message_box
-from openlp.core.utils import AppLocation, delete_file, get_locale_key, get_images_filter
+from openlp.core.utils import delete_file, get_locale_key, get_images_filter
from openlp.plugins.images.forms import AddGroupForm, ChooseGroupForm
from openlp.plugins.images.lib.db import ImageFilenames, ImageGroups
=== modified file 'openlp/plugins/media/lib/mediaitem.py'
--- openlp/plugins/media/lib/mediaitem.py 2013-10-02 21:07:20 +0000
+++ openlp/plugins/media/lib/mediaitem.py 2013-10-13 20:38:16 +0000
@@ -32,12 +32,13 @@
from PyQt4 import QtCore, QtGui
+from openlp.core.common import AppLocation, Settings, check_directory_exists, UiStrings, translate
from openlp.core.lib import ItemCapabilities, MediaManagerItem,MediaType, Registry, ServiceItem, ServiceItemContext, \
- Settings, UiStrings, build_icon, check_item_selected, check_directory_exists, translate
+ build_icon, check_item_selected
from openlp.core.lib.ui import critical_error_message_box, create_horizontal_adjusting_combo_box
from openlp.core.ui import DisplayController, Display, DisplayControllerType
from openlp.core.ui.media import get_media_players, set_media_players
-from openlp.core.utils import AppLocation, get_locale_key
+from openlp.core.utils import get_locale_key
log = logging.getLogger(__name__)
=== modified file 'openlp/plugins/media/lib/mediatab.py'
--- openlp/plugins/media/lib/mediatab.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/media/lib/mediatab.py 2013-10-13 20:38:16 +0000
@@ -29,7 +29,8 @@
from PyQt4 import QtGui
-from openlp.core.lib import Settings, SettingsTab, UiStrings, translate
+from openlp.core.common import Settings, UiStrings, translate
+from openlp.core.lib import SettingsTab
class MediaQ_check_box(QtGui.QCheckBox):
=== modified file 'openlp/plugins/media/mediaplugin.py'
--- openlp/plugins/media/mediaplugin.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/media/mediaplugin.py 2013-10-13 20:38:16 +0000
@@ -31,7 +31,7 @@
from PyQt4 import QtCore
-from openlp.core.lib import Plugin, Registry, StringContent, Settings, build_icon, translate
+from openlp.core.lib import Plugin, Registry, StringContent, build_icon, translate
from openlp.plugins.media.lib import MediaMediaItem, MediaTab
=== modified file 'openlp/plugins/presentations/lib/mediaitem.py'
--- openlp/plugins/presentations/lib/mediaitem.py 2013-10-02 21:07:20 +0000
+++ openlp/plugins/presentations/lib/mediaitem.py 2013-10-13 20:38:16 +0000
@@ -32,8 +32,9 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import MediaManagerItem, Registry, ItemCapabilities, ServiceItemContext, Settings, UiStrings, \
- build_icon, check_item_selected, create_thumb, translate, validate_thumb
+from openlp.core.common import Settings, UiStrings, translate
+from openlp.core.lib import MediaManagerItem, Registry, ItemCapabilities, ServiceItemContext, \
+ build_icon, check_item_selected, create_thumb, validate_thumb
from openlp.core.lib.ui import critical_error_message_box, create_horizontal_adjusting_combo_box
from openlp.core.utils import get_locale_key
from openlp.plugins.presentations.lib import MessageListener
=== modified file 'openlp/plugins/presentations/lib/presentationcontroller.py'
--- openlp/plugins/presentations/lib/presentationcontroller.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/presentations/lib/presentationcontroller.py 2013-10-13 20:38:16 +0000
@@ -33,8 +33,8 @@
from PyQt4 import QtCore
-from openlp.core.lib import Registry, Settings, check_directory_exists, create_thumb, validate_thumb
-from openlp.core.utils import AppLocation
+from openlp.core.common import AppLocation, Settings, check_directory_exists
+from openlp.core.lib import Registry, create_thumb, validate_thumb
log = logging.getLogger(__name__)
=== modified file 'openlp/plugins/presentations/lib/presentationtab.py'
--- openlp/plugins/presentations/lib/presentationtab.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/presentations/lib/presentationtab.py 2013-10-13 20:38:16 +0000
@@ -29,7 +29,8 @@
from PyQt4 import QtGui
-from openlp.core.lib import Settings, SettingsTab, UiStrings, translate
+from openlp.core.common import Settings, UiStrings, translate
+from openlp.core.lib import SettingsTab
class PresentationTab(SettingsTab):
=== modified file 'openlp/plugins/presentations/presentationplugin.py'
--- openlp/plugins/presentations/presentationplugin.py 2013-10-02 21:07:20 +0000
+++ openlp/plugins/presentations/presentationplugin.py 2013-10-13 20:38:16 +0000
@@ -35,8 +35,8 @@
from PyQt4 import QtCore
+from openlp.core.common import AppLocation
from openlp.core.lib import Plugin, StringContent, build_icon, translate
-from openlp.core.utils import AppLocation
from openlp.plugins.presentations.lib import PresentationController, PresentationMediaItem, PresentationTab
=== modified file 'openlp/plugins/remotes/lib/httprouter.py'
--- openlp/plugins/remotes/lib/httprouter.py 2013-09-28 05:10:44 +0000
+++ openlp/plugins/remotes/lib/httprouter.py 2013-10-13 20:38:16 +0000
@@ -121,12 +121,11 @@
import urllib.error
from urllib.parse import urlparse, parse_qs
-
from mako.template import Template
from PyQt4 import QtCore
-from openlp.core.lib import Registry, Settings, PluginStatus, StringContent, image_to_byte
-from openlp.core.utils import AppLocation, translate
+from openlp.core.common import AppLocation, Settings, translate
+from openlp.core.lib import Registry, PluginStatus, StringContent, image_to_byte
log = logging.getLogger(__name__)
=== modified file 'openlp/plugins/remotes/lib/httpserver.py'
--- openlp/plugins/remotes/lib/httpserver.py 2013-09-14 21:00:58 +0000
+++ openlp/plugins/remotes/lib/httpserver.py 2013-10-13 20:38:16 +0000
@@ -37,12 +37,10 @@
import socket
import os
import logging
-from urllib.parse import urlparse, parse_qs
from PyQt4 import QtCore
-from openlp.core.lib import Settings
-from openlp.core.utils import AppLocation
+from openlp.core.common import AppLocation, Settings
from openlp.plugins.remotes.lib import HttpRouter
=== modified file 'openlp/plugins/remotes/lib/remotetab.py'
--- openlp/plugins/remotes/lib/remotetab.py 2013-09-28 20:43:00 +0000
+++ openlp/plugins/remotes/lib/remotetab.py 2013-10-13 20:38:16 +0000
@@ -31,9 +31,8 @@
from PyQt4 import QtCore, QtGui, QtNetwork
-from openlp.core.lib import Settings, SettingsTab, translate
-from openlp.core.utils import AppLocation
-
+from openlp.core.common import AppLocation, Settings, translate
+from openlp.core.lib import SettingsTab
ZERO_URL = '0.0.0.0'
=== modified file 'openlp/plugins/songs/forms/duplicatesongremovalform.py'
--- openlp/plugins/songs/forms/duplicatesongremovalform.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/songs/forms/duplicatesongremovalform.py 2013-10-13 20:38:16 +0000
@@ -37,7 +37,6 @@
from openlp.core.lib import Registry, translate
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
-from openlp.core.utils import AppLocation
from openlp.plugins.songs.lib import delete_song
from openlp.plugins.songs.lib.db import Song, MediaFile
from openlp.plugins.songs.forms.songreviewwidget import SongReviewWidget
@@ -45,6 +44,7 @@
log = logging.getLogger(__name__)
+
class DuplicateSongRemovalForm(OpenLPWizard):
"""
This is the Duplicate Song Removal Wizard. It provides functionality to
=== modified file 'openlp/plugins/songs/forms/editsongdialog.py'
--- openlp/plugins/songs/forms/editsongdialog.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/songs/forms/editsongdialog.py 2013-10-13 20:38:16 +0000
@@ -29,7 +29,8 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import UiStrings, build_icon, translate
+from openlp.core.common import UiStrings, translate
+from openlp.core.lib import build_icon
from openlp.core.lib.ui import create_button_box, create_button
from openlp.plugins.songs.lib.ui import SongStrings
=== modified file 'openlp/plugins/songs/forms/editsongform.py'
--- openlp/plugins/songs/forms/editsongform.py 2013-09-01 20:43:22 +0000
+++ openlp/plugins/songs/forms/editsongform.py 2013-10-13 20:38:16 +0000
@@ -38,10 +38,9 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import Registry, PluginStatus, MediaType, UiStrings, translate, create_separated_list, \
- check_directory_exists
+from openlp.core.common import AppLocation, UiStrings, check_directory_exists, translate
+from openlp.core.lib import Registry, PluginStatus, MediaType, create_separated_list
from openlp.core.lib.ui import set_case_insensitive_completer, critical_error_message_box, find_and_set_in_combo_box
-from openlp.core.utils import AppLocation
from openlp.plugins.songs.lib import VerseType, clean_song
from openlp.plugins.songs.lib.db import Book, Song, Author, Topic, MediaFile
from openlp.plugins.songs.lib.ui import SongStrings
=== modified file 'openlp/plugins/songs/forms/songexportform.py'
--- openlp/plugins/songs/forms/songexportform.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/songs/forms/songexportform.py 2013-10-13 20:38:16 +0000
@@ -34,7 +34,8 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import Registry, UiStrings, create_separated_list, build_icon, translate
+from openlp.core.common import UiStrings, translate
+from openlp.core.lib import Registry, create_separated_list, build_icon
from openlp.core.lib.ui import critical_error_message_box
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
from openlp.plugins.songs.lib.db import Song
=== modified file 'openlp/plugins/songs/forms/songimportform.py'
--- openlp/plugins/songs/forms/songimportform.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/songs/forms/songimportform.py 2013-10-13 20:38:16 +0000
@@ -35,7 +35,9 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import Registry, Settings, UiStrings, translate
+from openlp.core.common import UiStrings, translate
+from openlp.core.common import Settings
+from openlp.core.lib import Registry
from openlp.core.lib.ui import critical_error_message_box
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
from openlp.plugins.songs.lib.importer import SongFormat, SongFormatSelect
=== modified file 'openlp/plugins/songs/forms/songmaintenancedialog.py'
--- openlp/plugins/songs/forms/songmaintenancedialog.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/songs/forms/songmaintenancedialog.py 2013-10-13 20:38:16 +0000
@@ -29,7 +29,8 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import UiStrings, build_icon
+from openlp.core.common import UiStrings
+from openlp.core.lib import build_icon
from openlp.core.lib.ui import create_button_box
from openlp.plugins.songs.lib.ui import SongStrings
=== modified file 'openlp/plugins/songs/forms/songmaintenanceform.py'
--- openlp/plugins/songs/forms/songmaintenanceform.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/songs/forms/songmaintenanceform.py 2013-10-13 20:38:16 +0000
@@ -32,7 +32,8 @@
from PyQt4 import QtGui, QtCore
from sqlalchemy.sql import and_
-from openlp.core.lib import Registry, UiStrings, translate
+from openlp.core.common import UiStrings, translate
+from openlp.core.lib import Registry
from openlp.core.lib.ui import critical_error_message_box
from openlp.plugins.songs.forms.authorsform import AuthorsForm
from openlp.plugins.songs.forms.topicsform import TopicsForm
=== modified file 'openlp/plugins/songs/lib/__init__.py'
--- openlp/plugins/songs/lib/__init__.py 2013-10-05 05:30:00 +0000
+++ openlp/plugins/songs/lib/__init__.py 2013-10-13 20:38:16 +0000
@@ -36,8 +36,9 @@
from PyQt4 import QtGui
+from openlp.core.common import AppLocation
from openlp.core.lib import translate
-from openlp.core.utils import AppLocation, CONTROL_CHARS
+from openlp.core.utils import CONTROL_CHARS
from openlp.plugins.songs.lib.db import MediaFile, Song
from .db import Author
from .ui import SongStrings
=== modified file 'openlp/plugins/songs/lib/importer.py'
--- openlp/plugins/songs/lib/importer.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/songs/lib/importer.py 2013-10-13 20:38:16 +0000
@@ -32,7 +32,7 @@
import os
import logging
-from openlp.core.lib import translate, UiStrings
+from openlp.core.common import translate, UiStrings
from openlp.core.ui.wizard import WizardStrings
from .opensongimport import OpenSongImport
from .easyslidesimport import EasySlidesImport
=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py 2013-10-02 21:07:20 +0000
+++ openlp/plugins/songs/lib/mediaitem.py 2013-10-13 20:38:16 +0000
@@ -35,10 +35,10 @@
from PyQt4 import QtCore, QtGui
from sqlalchemy.sql import or_
-from openlp.core.lib import Registry, MediaManagerItem, ItemCapabilities, PluginStatus, ServiceItemContext, Settings, \
- UiStrings, translate, check_item_selected, create_separated_list, check_directory_exists
+from openlp.core.common import AppLocation, Settings, check_directory_exists, UiStrings, translate
+from openlp.core.lib import Registry, MediaManagerItem, ItemCapabilities, PluginStatus, ServiceItemContext, \
+ check_item_selected, create_separated_list
from openlp.core.lib.ui import create_widget_action
-from openlp.core.utils import AppLocation
from openlp.plugins.songs.forms.editsongform import EditSongForm
from openlp.plugins.songs.forms.songmaintenanceform import SongMaintenanceForm
from openlp.plugins.songs.forms.songimportform import SongImportForm
=== modified file 'openlp/plugins/songs/lib/olpimport.py'
--- openlp/plugins/songs/lib/olpimport.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/songs/lib/olpimport.py 2013-10-13 20:38:16 +0000
@@ -36,7 +36,7 @@
from sqlalchemy.orm import class_mapper, mapper, relation, scoped_session, sessionmaker
from sqlalchemy.orm.exc import UnmappedClassError
-from openlp.core.lib import translate
+from openlp.core.common import translate
from openlp.core.lib.db import BaseModel
from openlp.core.ui.wizard import WizardStrings
from openlp.plugins.songs.lib import clean_song
=== modified file 'openlp/plugins/songs/lib/oooimport.py'
--- openlp/plugins/songs/lib/oooimport.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/songs/lib/oooimport.py 2013-10-13 20:38:16 +0000
@@ -51,6 +51,7 @@
PAGE_AFTER = 5
PAGE_BOTH = 6
+
class OooImport(SongImport):
"""
Import songs from Impress/Powerpoint docs using Impress
=== modified file 'openlp/plugins/songs/lib/openlyricsexport.py'
--- openlp/plugins/songs/lib/openlyricsexport.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/songs/lib/openlyricsexport.py 2013-10-13 20:38:16 +0000
@@ -35,7 +35,8 @@
from lxml import etree
-from openlp.core.lib import Registry, check_directory_exists, translate
+from openlp.core.common import check_directory_exists, translate
+from openlp.core.lib import Registry
from openlp.core.utils import clean_filename
from openlp.plugins.songs.lib.xml import OpenLyrics
=== modified file 'openlp/plugins/songs/lib/opensongimport.py'
--- openlp/plugins/songs/lib/opensongimport.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/songs/lib/opensongimport.py 2013-10-13 20:38:16 +0000
@@ -33,13 +33,14 @@
from lxml import objectify
from lxml.etree import Error, LxmlError
-from openlp.core.lib import translate
+from openlp.core.common import translate
from openlp.plugins.songs.lib import VerseType
from openlp.plugins.songs.lib.songimport import SongImport
from openlp.plugins.songs.lib.ui import SongStrings
log = logging.getLogger(__name__)
+
class OpenSongImport(SongImport):
"""
Import songs exported from OpenSong
=== modified file 'openlp/plugins/songs/lib/powersongimport.py'
--- openlp/plugins/songs/lib/powersongimport.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/songs/lib/powersongimport.py 2013-10-13 20:38:16 +0000
@@ -34,7 +34,7 @@
import fnmatch
import os
-from openlp.core.lib import translate
+from openlp.core.common import translate
from openlp.plugins.songs.lib.songimport import SongImport
log = logging.getLogger(__name__)
=== modified file 'openlp/plugins/songs/lib/songimport.py'
--- openlp/plugins/songs/lib/songimport.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/songs/lib/songimport.py 2013-10-13 20:38:16 +0000
@@ -34,9 +34,9 @@
from PyQt4 import QtCore
-from openlp.core.lib import Registry, translate, check_directory_exists
+from openlp.core.common import AppLocation, check_directory_exists, translate
+from openlp.core.lib import Registry
from openlp.core.ui.wizard import WizardStrings
-from openlp.core.utils import AppLocation
from openlp.plugins.songs.lib import clean_song, VerseType
from openlp.plugins.songs.lib.db import Song, Author, Topic, Book, MediaFile
from openlp.plugins.songs.lib.ui import SongStrings
=== modified file 'openlp/plugins/songs/lib/songproimport.py'
--- openlp/plugins/songs/lib/songproimport.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/songs/lib/songproimport.py 2013-10-13 20:38:16 +0000
@@ -35,6 +35,7 @@
from openlp.plugins.songs.lib import strip_rtf
from openlp.plugins.songs.lib.songimport import SongImport
+
class SongProImport(SongImport):
"""
The :class:`SongProImport` class provides the ability to import song files
=== modified file 'openlp/plugins/songs/lib/songshowplusimport.py'
--- openlp/plugins/songs/lib/songshowplusimport.py 2013-09-14 22:22:05 +0000
+++ openlp/plugins/songs/lib/songshowplusimport.py 2013-10-13 20:38:16 +0000
@@ -27,8 +27,8 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
-The :mod:`songshowplusimport` module provides the functionality for importing
-SongShow Plus songs into the OpenLP database.
+The :mod:`songshowplusimport` module provides the functionality for importing SongShow Plus songs into the OpenLP
+database.
"""
import chardet
import os
@@ -56,6 +56,7 @@
log = logging.getLogger(__name__)
+
class SongShowPlusImport(SongImport):
"""
The :class:`SongShowPlusImport` class provides the ability to import song files from SongShow Plus.
=== modified file 'openlp/plugins/songs/lib/songstab.py'
--- openlp/plugins/songs/lib/songstab.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/songs/lib/songstab.py 2013-10-13 20:38:16 +0000
@@ -29,7 +29,8 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import Settings, SettingsTab, translate
+from openlp.core.common import Settings, translate
+from openlp.core.lib import SettingsTab
class SongsTab(SettingsTab):
=== modified file 'openlp/plugins/songs/lib/ui.py'
--- openlp/plugins/songs/lib/ui.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/songs/lib/ui.py 2013-10-13 20:38:16 +0000
@@ -32,6 +32,7 @@
"""
from openlp.core.lib import translate
+
class SongStrings(object):
"""
Provide standard strings for use throughout the songs plugin.
=== modified file 'openlp/plugins/songs/lib/worshipcenterproimport.py'
--- openlp/plugins/songs/lib/worshipcenterproimport.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/songs/lib/worshipcenterproimport.py 2013-10-13 20:38:16 +0000
@@ -34,7 +34,7 @@
import pyodbc
-from openlp.core.lib import translate
+from openlp.core.common import translate
from openlp.plugins.songs.lib.songimport import SongImport
log = logging.getLogger(__name__)
=== modified file 'openlp/plugins/songs/lib/wowimport.py'
--- openlp/plugins/songs/lib/wowimport.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/songs/lib/wowimport.py 2013-10-13 20:38:16 +0000
@@ -33,7 +33,7 @@
import os
import logging
-from openlp.core.lib import translate
+from openlp.core.common import translate
from openlp.plugins.songs.lib.songimport import SongImport
BLOCK_TYPES = ('V', 'C', 'B')
=== modified file 'openlp/plugins/songs/lib/xml.py'
--- openlp/plugins/songs/lib/xml.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/songs/lib/xml.py 2013-10-13 20:38:16 +0000
@@ -68,7 +68,8 @@
from lxml import etree, objectify
-from openlp.core.lib import FormattingTags, translate
+from openlp.core.common import translate
+from openlp.core.lib import FormattingTags
from openlp.plugins.songs.lib import VerseType, clean_song
from openlp.plugins.songs.lib.db import Author, Book, Song, Topic
from openlp.core.utils import get_application_version
=== modified file 'openlp/plugins/songs/lib/zionworximport.py'
--- openlp/plugins/songs/lib/zionworximport.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/songs/lib/zionworximport.py 2013-10-13 20:38:16 +0000
@@ -33,7 +33,7 @@
import csv
import logging
-from openlp.core.lib import translate
+from openlp.core.common import translate
from openlp.plugins.songs.lib.songimport import SongImport
log = logging.getLogger(__name__)
=== modified file 'openlp/plugins/songs/songsplugin.py'
--- openlp/plugins/songs/songsplugin.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/songs/songsplugin.py 2013-10-13 20:38:16 +0000
@@ -38,7 +38,8 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import Plugin, StringContent, UiStrings, build_icon, translate
+from openlp.core.common import UiStrings, translate
+from openlp.core.lib import Plugin, StringContent, build_icon
from openlp.core.lib.db import Manager
from openlp.core.lib.ui import create_action
from openlp.core.utils.actions import ActionList
=== modified file 'openlp/plugins/songusage/forms/songusagedeletedialog.py'
--- openlp/plugins/songusage/forms/songusagedeletedialog.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/songusage/forms/songusagedeletedialog.py 2013-10-13 20:38:16 +0000
@@ -29,7 +29,7 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import translate
+from openlp.core.common import translate
from openlp.core.lib.ui import create_button_box
=== modified file 'openlp/plugins/songusage/forms/songusagedeleteform.py'
--- openlp/plugins/songusage/forms/songusagedeleteform.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/songusage/forms/songusagedeleteform.py 2013-10-13 20:38:16 +0000
@@ -27,9 +27,10 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
-from PyQt4 import QtCore, QtGui
+from PyQt4 import QtGui
-from openlp.core.lib import Registry, translate
+from openlp.core.common import translate
+from openlp.core.lib import Registry
from openlp.plugins.songusage.lib.db import SongUsageItem
from .songusagedeletedialog import Ui_SongUsageDeleteDialog
=== modified file 'openlp/plugins/songusage/forms/songusagedetaildialog.py'
--- openlp/plugins/songusage/forms/songusagedetaildialog.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/songusage/forms/songusagedetaildialog.py 2013-10-13 20:38:16 +0000
@@ -29,7 +29,8 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import build_icon, translate
+from openlp.core.common import translate
+from openlp.core.lib import build_icon
from openlp.core.lib.ui import create_button_box
=== modified file 'openlp/plugins/songusage/forms/songusagedetailform.py'
--- openlp/plugins/songusage/forms/songusagedetailform.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/songusage/forms/songusagedetailform.py 2013-10-13 20:38:16 +0000
@@ -33,7 +33,8 @@
from PyQt4 import QtGui
from sqlalchemy.sql import and_
-from openlp.core.lib import Registry, Settings, translate, check_directory_exists
+from openlp.core.common import Settings, check_directory_exists, translate
+from openlp.core.lib import Registry
from openlp.plugins.songusage.lib.db import SongUsageItem
from .songusagedetaildialog import Ui_SongUsageDetailDialog
=== modified file 'openlp/plugins/songusage/songusageplugin.py'
--- openlp/plugins/songusage/songusageplugin.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/songusage/songusageplugin.py 2013-10-13 20:38:16 +0000
@@ -32,7 +32,8 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import Plugin, Registry, Settings, StringContent, build_icon, translate
+from openlp.core.common import Settings, translate
+from openlp.core.lib import Plugin, Registry, StringContent, build_icon
from openlp.core.lib.db import Manager
from openlp.core.lib.ui import create_action
from openlp.core.utils.actions import ActionList
=== added directory 'tests/functional/openlp_core_common'
=== added file 'tests/functional/openlp_core_common/__init__.py'
--- tests/functional/openlp_core_common/__init__.py 1970-01-01 00:00:00 +0000
+++ tests/functional/openlp_core_common/__init__.py 2013-10-13 20:38:16 +0000
@@ -0,0 +1,1 @@
+__author__ = 'tim'
=== renamed file 'tests/functional/openlp_core_utils/test_applocation.py' => 'tests/functional/openlp_core_common/test_applocation.py'
--- tests/functional/openlp_core_utils/test_applocation.py 2013-09-19 21:02:28 +0000
+++ tests/functional/openlp_core_common/test_applocation.py 2013-10-13 20:38:16 +0000
@@ -32,7 +32,7 @@
import copy
from unittest import TestCase
-from openlp.core.utils import AppLocation
+from openlp.core.common import AppLocation, get_frozen_path
from tests.functional import patch
FILE_LIST = ['file1', 'file2', 'file3.txt', 'file4.txt', 'file5.mp3', 'file6.mp3']
@@ -46,10 +46,10 @@
"""
Test the AppLocation.get_data_path() method
"""
- with patch('openlp.core.utils.applocation.Settings') as mocked_class, \
- patch('openlp.core.utils.AppLocation.get_directory') as mocked_get_directory, \
- patch('openlp.core.utils.applocation.check_directory_exists') as mocked_check_directory_exists, \
- patch('openlp.core.utils.applocation.os') as mocked_os:
+ with patch('openlp.core.common.Settings') as mocked_class, \
+ patch('openlp.core.common.AppLocation.get_directory') as mocked_get_directory, \
+ patch('openlp.core.common.applocation.check_directory_exists') as mocked_check_directory_exists, \
+ patch('openlp.core.common.applocation.os') as mocked_os:
# GIVEN: A mocked out Settings class and a mocked out AppLocation.get_directory()
mocked_settings = mocked_class.return_value
mocked_settings.contains.return_value = False
@@ -59,6 +59,7 @@
# WHEN: we call AppLocation.get_data_path()
data_path = AppLocation.get_data_path()
+ print(data_path)
# THEN: check that all the correct methods were called, and the result is correct
mocked_settings.contains.assert_called_with('advanced/data path')
@@ -70,8 +71,8 @@
"""
Test the AppLocation.get_data_path() method when a custom location is set in the settings
"""
- with patch('openlp.core.utils.applocation.Settings') as mocked_class,\
- patch('openlp.core.utils.applocation.os') as mocked_os:
+ with patch('openlp.core.common.Settings') as mocked_class,\
+ patch('openlp.core.common.applocation.os') as mocked_os:
# GIVEN: A mocked out Settings class which returns a custom data location
mocked_settings = mocked_class.return_value
mocked_settings.contains.return_value = True
@@ -90,8 +91,8 @@
"""
Test the AppLocation.get_files() method with no parameters passed.
"""
- with patch('openlp.core.utils.AppLocation.get_data_path') as mocked_get_data_path, \
- patch('openlp.core.utils.applocation.os.listdir') as mocked_listdir:
+ with patch('openlp.core.common.AppLocation.get_data_path') as mocked_get_data_path, \
+ patch('openlp.core.common.applocation.os.listdir') as mocked_listdir:
# GIVEN: Our mocked modules/methods.
mocked_get_data_path.return_value = 'test/dir'
mocked_listdir.return_value = copy.deepcopy(FILE_LIST)
@@ -106,8 +107,8 @@
"""
Test the AppLocation.get_files() method with all parameters passed.
"""
- with patch('openlp.core.utils.AppLocation.get_data_path') as mocked_get_data_path, \
- patch('openlp.core.utils.applocation.os.listdir') as mocked_listdir:
+ with patch('openlp.core.common.AppLocation.get_data_path') as mocked_get_data_path, \
+ patch('openlp.core.common.applocation.os.listdir') as mocked_listdir:
# GIVEN: Our mocked modules/methods.
mocked_get_data_path.return_value = 'test/dir'
mocked_listdir.return_value = copy.deepcopy(FILE_LIST)
@@ -125,8 +126,8 @@
"""
Test the AppLocation.get_section_data_path() method
"""
- with patch('openlp.core.utils.AppLocation.get_data_path') as mocked_get_data_path, \
- patch('openlp.core.utils.applocation.check_directory_exists') as mocked_check_directory_exists:
+ with patch('openlp.core.common.AppLocation.get_data_path') as mocked_get_data_path, \
+ patch('openlp.core.common.applocation.check_directory_exists') as mocked_check_directory_exists:
# GIVEN: A mocked out AppLocation.get_data_path()
mocked_get_data_path.return_value = 'test/dir'
mocked_check_directory_exists.return_value = True
@@ -143,7 +144,7 @@
Test the AppLocation.get_directory() method for AppLocation.AppDir
"""
# GIVEN: A mocked out _get_frozen_path function
- with patch('openlp.core.utils.applocation._get_frozen_path') as mocked_get_frozen_path:
+ with patch('openlp.core.common.applocation.get_frozen_path') as mocked_get_frozen_path:
mocked_get_frozen_path.return_value = 'app/dir'
# WHEN: We call AppLocation.get_directory
@@ -157,10 +158,10 @@
Test the AppLocation.get_directory() method for AppLocation.PluginsDir
"""
# GIVEN: _get_frozen_path, abspath, split and sys are mocked out
- with patch('openlp.core.utils.applocation._get_frozen_path') as mocked_get_frozen_path, \
- patch('openlp.core.utils.applocation.os.path.abspath') as mocked_abspath, \
- patch('openlp.core.utils.applocation.os.path.split') as mocked_split, \
- patch('openlp.core.utils.applocation.sys') as mocked_sys:
+ with patch('openlp.core.common.applocation.get_frozen_path') as mocked_get_frozen_path, \
+ patch('openlp.core.common.applocation.os.path.abspath') as mocked_abspath, \
+ patch('openlp.core.common.applocation.os.path.split') as mocked_split, \
+ patch('openlp.core.common.applocation.sys') as mocked_sys:
mocked_abspath.return_value = 'plugins/dir'
mocked_split.return_value = ['openlp']
mocked_get_frozen_path.return_value = 'plugins/dir'
@@ -172,3 +173,31 @@
# THEN: The correct directory should be returned
self.assertEqual('plugins/dir', directory, 'Directory should be "plugins/dir"')
+
+ def get_frozen_path_in_unfrozen_app_test(self):
+ """
+ Test the _get_frozen_path() function when the application is not frozen (compiled by PyInstaller)
+ """
+ with patch('openlp.core.utils.sys') as mocked_sys:
+ # GIVEN: The sys module "without" a "frozen" attribute
+ mocked_sys.frozen = None
+
+ # WHEN: We call _get_frozen_path() with two parameters
+ frozen_path = get_frozen_path('frozen', 'not frozen')
+
+ # THEN: The non-frozen parameter is returned
+ self.assertEqual('not frozen', frozen_path, '_get_frozen_path should return "not frozen"')
+
+ def get_frozen_path_in_frozen_app_test(self):
+ """
+ Test the get_frozen_path() function when the application is frozen (compiled by PyInstaller)
+ """
+ with patch('openlp.core.common.sys') as mocked_sys:
+ # GIVEN: The sys module *with* a "frozen" attribute
+ mocked_sys.frozen = 1
+
+ # WHEN: We call _get_frozen_path() with two parameters
+ frozen_path = get_frozen_path('frozen', 'not frozen')
+
+ # THEN: The frozen parameter is returned
+ self.assertEqual('frozen', frozen_path, 'Should return "frozen"')
\ No newline at end of file
=== renamed file 'tests/functional/openlp_core_lib/test_settings.py' => 'tests/functional/openlp_core_common/test_settings.py'
--- tests/functional/openlp_core_lib/test_settings.py 2013-09-22 21:11:03 +0000
+++ tests/functional/openlp_core_common/test_settings.py 2013-10-13 20:38:16 +0000
@@ -35,7 +35,7 @@
from PyQt4 import QtGui
-from openlp.core.lib import Settings
+from openlp.core.common import Settings
class TestSettings(TestCase):
=== renamed file 'tests/functional/openlp_core_lib/test_uistrings.py' => 'tests/functional/openlp_core_common/test_uistrings.py'
--- tests/functional/openlp_core_lib/test_uistrings.py 2013-09-22 21:11:03 +0000
+++ tests/functional/openlp_core_common/test_uistrings.py 2013-10-13 20:38:16 +0000
@@ -31,7 +31,7 @@
"""
from unittest import TestCase
-from openlp.core.lib import UiStrings
+from openlp.core.common import UiStrings
class TestUiStrings(TestCase):
=== modified file 'tests/functional/openlp_core_lib/test_formattingtags.py'
--- tests/functional/openlp_core_lib/test_formattingtags.py 2013-09-19 21:02:28 +0000
+++ tests/functional/openlp_core_lib/test_formattingtags.py 2013-10-13 20:38:16 +0000
@@ -59,7 +59,7 @@
Test the FormattingTags class' get_html_tags static method.
"""
with patch('openlp.core.lib.translate') as mocked_translate, \
- patch('openlp.core.lib.settings') as mocked_settings, \
+ patch('openlp.core.common.settings') as mocked_settings, \
patch('openlp.core.lib.formattingtags.json') as mocked_json:
# GIVEN: Our mocked modules and functions.
mocked_translate.side_effect = lambda module, string_to_translate, comment: string_to_translate
@@ -80,7 +80,7 @@
FormattingTags class - test the get_html_tags(), add_html_tags() and remove_html_tag() methods.
"""
with patch('openlp.core.lib.translate') as mocked_translate, \
- patch('openlp.core.lib.settings') as mocked_settings, \
+ patch('openlp.core.common.settings') as mocked_settings, \
patch('openlp.core.lib.formattingtags.json') as mocked_json:
# GIVEN: Our mocked modules and functions.
mocked_translate.side_effect = lambda module, string_to_translate: string_to_translate
=== modified file 'tests/functional/openlp_core_lib/test_lib.py'
--- tests/functional/openlp_core_lib/test_lib.py 2013-10-02 21:37:00 +0000
+++ tests/functional/openlp_core_lib/test_lib.py 2013-10-13 20:38:16 +0000
@@ -36,7 +36,8 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import str_to_bool, create_thumb, translate, check_directory_exists, get_text_file_string, \
+from openlp.core.common import check_directory_exists, translate
+from openlp.core.lib import str_to_bool, create_thumb, get_text_file_string, \
build_icon, image_to_byte, check_item_selected, validate_thumb, create_separated_list, clean_tags, expand_tags
from tests.functional import MagicMock, patch
=== modified file 'tests/functional/openlp_core_lib/test_pluginmanager.py'
--- tests/functional/openlp_core_lib/test_pluginmanager.py 2013-10-03 19:56:12 +0000
+++ tests/functional/openlp_core_lib/test_pluginmanager.py 2013-10-13 20:38:16 +0000
@@ -31,8 +31,9 @@
"""
from unittest import TestCase
+from openlp.core.common import Settings
from openlp.core.lib.pluginmanager import PluginManager
-from openlp.core.lib import Settings, Registry, PluginStatus
+from openlp.core.lib import Registry, PluginStatus
from tests.functional import MagicMock
=== added file 'tests/functional/openlp_core_lib/test_theme.py'
--- tests/functional/openlp_core_lib/test_theme.py 1970-01-01 00:00:00 +0000
+++ tests/functional/openlp_core_lib/test_theme.py 2013-10-13 20:38:16 +0000
@@ -0,0 +1,65 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2013 Raoul Snyman #
+# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan #
+# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
+# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
+# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
+# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
+# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
+# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
+# --------------------------------------------------------------------------- #
+# 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 #
+###############################################################################
+"""
+Package to test the openlp.core.lib.theme package.
+"""
+from tests.functional import MagicMock, patch
+from unittest import TestCase
+
+from openlp.core.lib.theme import ThemeXML
+
+
+class TestTheme(TestCase):
+ """
+ Test the functions in the Theme module
+ """
+ def setUp(self):
+ """
+ Create the UI
+ """
+ pass
+
+ def tearDown(self):
+ """
+ Delete all the C++ objects at the end so that we don't have a segfault
+ """
+ pass
+
+ def test_new_theme(self):
+ """
+ Test the theme creation - basic test
+ """
+ # GIVEN: A new theme
+
+ # WHEN: A theme is created
+ default_theme = ThemeXML()
+
+ # THEN: We should get some default behaviours
+ self.assertTrue(default_theme.background_border_color == '#000000', 'The theme should have a black border')
+ self.assertTrue(default_theme.background_type == 'solid', 'There theme should have a solid backgrounds')
\ No newline at end of file
=== modified file 'tests/functional/openlp_core_utils/test_actions.py'
--- tests/functional/openlp_core_utils/test_actions.py 2013-09-19 21:02:28 +0000
+++ tests/functional/openlp_core_utils/test_actions.py 2013-10-13 20:38:16 +0000
@@ -35,7 +35,7 @@
from PyQt4 import QtGui, QtCore
-from openlp.core.lib import Settings
+from openlp.core.common import Settings
from openlp.core.utils import ActionList
=== modified file 'tests/functional/openlp_core_utils/test_utils.py'
--- tests/functional/openlp_core_utils/test_utils.py 2013-10-05 18:06:23 +0000
+++ tests/functional/openlp_core_utils/test_utils.py 2013-10-13 20:38:16 +0000
@@ -31,7 +31,7 @@
"""
from unittest import TestCase
-from openlp.core.utils import clean_filename, get_filesystem_encoding, _get_frozen_path, get_locale_key, \
+from openlp.core.utils import clean_filename, get_filesystem_encoding, get_locale_key, \
get_natural_key, split_filename
from tests.functional import patch
@@ -75,34 +75,6 @@
mocked_getdefaultencoding.assert_called_with()
self.assertEqual('utf-8', result, 'The result should be "utf-8"')
- def get_frozen_path_in_unfrozen_app_test(self):
- """
- Test the _get_frozen_path() function when the application is not frozen (compiled by PyInstaller)
- """
- with patch('openlp.core.utils.sys') as mocked_sys:
- # GIVEN: The sys module "without" a "frozen" attribute
- mocked_sys.frozen = None
-
- # WHEN: We call _get_frozen_path() with two parameters
- frozen_path = _get_frozen_path('frozen', 'not frozen')
-
- # THEN: The non-frozen parameter is returned
- self.assertEqual('not frozen', frozen_path, '_get_frozen_path should return "not frozen"')
-
- def get_frozen_path_in_frozen_app_test(self):
- """
- Test the _get_frozen_path() function when the application is frozen (compiled by PyInstaller)
- """
- with patch('openlp.core.utils.sys') as mocked_sys:
- # GIVEN: The sys module *with* a "frozen" attribute
- mocked_sys.frozen = 1
-
- # WHEN: We call _get_frozen_path() with two parameters
- frozen_path = _get_frozen_path('frozen', 'not frozen')
-
- # THEN: The frozen parameter is returned
- self.assertEqual('frozen', frozen_path, 'Should return "frozen"')
-
def split_filename_with_file_path_test(self):
"""
Test the split_filename() function with a path to a file
=== modified file 'tests/functional/openlp_plugins/remotes/test_remotetab.py'
--- tests/functional/openlp_plugins/remotes/test_remotetab.py 2013-09-19 21:02:28 +0000
+++ tests/functional/openlp_plugins/remotes/test_remotetab.py 2013-10-13 20:38:16 +0000
@@ -36,7 +36,7 @@
from PyQt4 import QtGui
-from openlp.core.lib import Settings
+from openlp.core.common import Settings
from openlp.plugins.remotes.lib.remotetab import RemoteTab
from tests.functional import patch
@@ -105,10 +105,10 @@
Test the set_urls function with standard defaults
"""
# GIVEN: A mocked location
- with patch('openlp.core.utils.applocation.Settings') as mocked_class, \
+ with patch('openlp.core.common.Settings') as mocked_class, \
patch('openlp.core.utils.AppLocation.get_directory') as mocked_get_directory, \
- patch('openlp.core.utils.applocation.check_directory_exists') as mocked_check_directory_exists, \
- patch('openlp.core.utils.applocation.os') as mocked_os:
+ patch('openlp.core.common.check_directory_exists') as mocked_check_directory_exists, \
+ patch('openlp.core.common.applocation.os') as mocked_os:
# GIVEN: A mocked out Settings class and a mocked out AppLocation.get_directory()
mocked_settings = mocked_class.return_value
mocked_settings.contains.return_value = False
@@ -133,10 +133,10 @@
Test the set_urls function with certificate available
"""
# GIVEN: A mocked location
- with patch('openlp.core.utils.applocation.Settings') as mocked_class, \
+ with patch('openlp.core.common.Settings') as mocked_class, \
patch('openlp.core.utils.AppLocation.get_directory') as mocked_get_directory, \
- patch('openlp.core.utils.applocation.check_directory_exists') as mocked_check_directory_exists, \
- patch('openlp.core.utils.applocation.os') as mocked_os:
+ patch('openlp.core.common.check_directory_exists') as mocked_check_directory_exists, \
+ patch('openlp.core.common.applocation.os') as mocked_os:
# GIVEN: A mocked out Settings class and a mocked out AppLocation.get_directory()
mocked_settings = mocked_class.return_value
mocked_settings.contains.return_value = False
=== modified file 'tests/functional/openlp_plugins/remotes/test_router.py'
--- tests/functional/openlp_plugins/remotes/test_router.py 2013-09-29 21:25:42 +0000
+++ tests/functional/openlp_plugins/remotes/test_router.py 2013-10-13 20:38:16 +0000
@@ -35,7 +35,7 @@
from PyQt4 import QtGui
-from openlp.core.lib import Settings
+from openlp.core.common import Settings
from openlp.plugins.remotes.lib.httpserver import HttpRouter
from tests.functional import MagicMock
=== modified file 'tests/functional/openlp_plugins/songs/test_mediaitem.py'
--- tests/functional/openlp_plugins/songs/test_mediaitem.py 2013-10-02 21:07:20 +0000
+++ tests/functional/openlp_plugins/songs/test_mediaitem.py 2013-10-13 20:38:16 +0000
@@ -7,7 +7,8 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import Registry, ServiceItem, Settings
+from openlp.core.common import Settings
+from openlp.core.lib import Registry, ServiceItem
from openlp.plugins.songs.lib.mediaitem import SongMediaItem
from tests.functional import patch, MagicMock
=== modified file 'tests/interfaces/openlp_core_lib/test_pluginmanager.py'
--- tests/interfaces/openlp_core_lib/test_pluginmanager.py 2013-10-04 21:45:38 +0000
+++ tests/interfaces/openlp_core_lib/test_pluginmanager.py 2013-10-13 20:38:16 +0000
@@ -9,9 +9,14 @@
from PyQt4 import QtGui
+from openlp.core.common import Settings
from openlp.core.lib.pluginmanager import PluginManager
+<<<<<<< TREE
from openlp.core.lib import Registry, Settings
from tests.interfaces import MagicMock
+=======
+from openlp.core.lib import Registry
+>>>>>>> MERGE-SOURCE
class TestPluginManager(TestCase):