forked from openlp/openlp
Start theme clean up
This commit is contained in:
parent
6877d21a89
commit
257fba8548
@ -43,6 +43,7 @@ from traceback import format_exception
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
|
from openlp.core.common import AppLocation
|
||||||
from openlp.core.lib import Settings, ScreenList, UiStrings, Registry, check_directory_exists
|
from openlp.core.lib import Settings, ScreenList, UiStrings, Registry, check_directory_exists
|
||||||
from openlp.core.resources import qInitResources
|
from openlp.core.resources import qInitResources
|
||||||
from openlp.core.ui.mainwindow import MainWindow
|
from openlp.core.ui.mainwindow import MainWindow
|
||||||
@ -50,7 +51,7 @@ from openlp.core.ui.firsttimelanguageform import FirstTimeLanguageForm
|
|||||||
from openlp.core.ui.firsttimeform import FirstTimeForm
|
from openlp.core.ui.firsttimeform import FirstTimeForm
|
||||||
from openlp.core.ui.exceptionform import ExceptionForm
|
from openlp.core.ui.exceptionform import ExceptionForm
|
||||||
from openlp.core.ui import SplashScreen
|
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']
|
__all__ = ['OpenLP', 'main']
|
||||||
|
@ -27,10 +27,31 @@
|
|||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
"""
|
"""
|
||||||
The :mod:`~openlp.core.theme` module contains all the themeing functions used by
|
The :mod:`common` module contains most of the components and libraries that make
|
||||||
OpenLP when displaying a song or a scripture.
|
OpenLP work.
|
||||||
"""
|
"""
|
||||||
|
import os
|
||||||
|
import logging
|
||||||
|
|
||||||
from openlp.core.theme.theme import Theme
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
__all__ = ['Theme']
|
|
||||||
|
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
|
||||||
|
|
||||||
|
from .applocation import AppLocation
|
@ -27,16 +27,12 @@
|
|||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# 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.
|
The :mod:`openlp.core.common.applocation` module provides an utility for OpenLP receiving the data path etc.
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from openlp.core.lib import Settings
|
|
||||||
from openlp.core.utils import _get_frozen_path
|
|
||||||
|
|
||||||
|
|
||||||
if sys.platform != 'win32' and sys.platform != 'darwin':
|
if sys.platform != 'win32' and sys.platform != 'darwin':
|
||||||
try:
|
try:
|
||||||
from xdg import BaseDirectory
|
from xdg import BaseDirectory
|
||||||
@ -45,7 +41,7 @@ if sys.platform != 'win32' and sys.platform != 'darwin':
|
|||||||
XDG_BASE_AVAILABLE = False
|
XDG_BASE_AVAILABLE = False
|
||||||
|
|
||||||
import openlp
|
import openlp
|
||||||
from openlp.core.lib import check_directory_exists
|
from openlp.core.common import check_directory_exists
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -74,15 +70,15 @@ class AppLocation(object):
|
|||||||
The directory type you want, for instance the data directory. Default *AppLocation.AppDir*
|
The directory type you want, for instance the data directory. Default *AppLocation.AppDir*
|
||||||
"""
|
"""
|
||||||
if dir_type == 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])
|
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:
|
elif dir_type == AppLocation.PluginsDir:
|
||||||
app_path = os.path.abspath(os.path.split(sys.argv[0])[0])
|
app_path = os.path.abspath(os.path.split(sys.argv[0])[0])
|
||||||
return _get_frozen_path(os.path.join(app_path, 'plugins'),
|
return get_frozen_path(os.path.join(app_path, 'plugins'),
|
||||||
os.path.join(os.path.split(openlp.__file__)[0], 'plugins'))
|
os.path.join(os.path.split(openlp.__file__)[0], 'plugins'))
|
||||||
elif dir_type == AppLocation.VersionDir:
|
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])
|
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:
|
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))
|
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')
|
return os.path.join(app_path, 'i18n')
|
||||||
elif dir_type == AppLocation.DataDir and AppLocation.BaseDir:
|
elif dir_type == AppLocation.DataDir and AppLocation.BaseDir:
|
||||||
return os.path.join(AppLocation.BaseDir, 'data')
|
return os.path.join(AppLocation.BaseDir, 'data')
|
||||||
@ -95,6 +91,7 @@ class AppLocation(object):
|
|||||||
Return the path OpenLP stores all its data under.
|
Return the path OpenLP stores all its data under.
|
||||||
"""
|
"""
|
||||||
# Check if we have a different data location.
|
# Check if we have a different data location.
|
||||||
|
from openlp.core.lib import Settings
|
||||||
if Settings().contains('advanced/data path'):
|
if Settings().contains('advanced/data path'):
|
||||||
path = Settings().value('advanced/data path')
|
path = Settings().value('advanced/data path')
|
||||||
else:
|
else:
|
||||||
@ -139,6 +136,15 @@ class AppLocation(object):
|
|||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
|
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_os_dir_path(dir_type):
|
def _get_os_dir_path(dir_type):
|
||||||
"""
|
"""
|
||||||
Return a path based on which OS and environment we are running in.
|
Return a path based on which OS and environment we are running in.
|
@ -41,9 +41,10 @@ from sqlalchemy.pool import NullPool
|
|||||||
from alembic.migration import MigrationContext
|
from alembic.migration import MigrationContext
|
||||||
from alembic.operations import Operations
|
from alembic.operations import Operations
|
||||||
|
|
||||||
|
from openlp.core.common import AppLocation
|
||||||
from openlp.core.lib import translate, Settings
|
from openlp.core.lib import translate, Settings
|
||||||
from openlp.core.lib.ui import critical_error_message_box
|
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__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
49
openlp/core/lib/json/theme.json
Normal file
49
openlp/core/lib/json/theme.json
Normal file
@ -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": ""
|
||||||
|
}
|
@ -35,7 +35,7 @@ import logging
|
|||||||
import imp
|
import imp
|
||||||
|
|
||||||
from openlp.core.lib import Plugin, PluginStatus, Registry
|
from openlp.core.lib import Plugin, PluginStatus, Registry
|
||||||
from openlp.core.utils import AppLocation
|
from openlp.core.common import AppLocation
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -32,11 +32,13 @@ Provide the theme XML and handling functions for OpenLP v2 themes.
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import logging
|
import logging
|
||||||
|
import json
|
||||||
|
|
||||||
from xml.dom.minidom import Document
|
from xml.dom.minidom import Document
|
||||||
from lxml import etree, objectify
|
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__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -202,6 +204,8 @@ class VerticalType(object):
|
|||||||
|
|
||||||
BOOLEAN_LIST = ['bold', 'italics', 'override', 'outline', 'shadow', 'slide_transition']
|
BOOLEAN_LIST = ['bold', 'italics', 'override', 'outline', 'shadow', 'slide_transition']
|
||||||
|
|
||||||
|
BOOLEAN_LIST2 = ['True', 'False']
|
||||||
|
|
||||||
INTEGER_LIST = ['size', 'line_adjustment', 'x', 'height', 'y', 'width', 'shadow_size', 'outline_size',
|
INTEGER_LIST = ['size', 'line_adjustment', 'x', 'height', 'y', 'width', 'shadow_size', 'outline_size',
|
||||||
'horizontal_align', 'vertical_align', 'wrap_style']
|
'horizontal_align', 'vertical_align', 'wrap_style']
|
||||||
|
|
||||||
@ -218,8 +222,12 @@ class ThemeXML(object):
|
|||||||
Initialise the theme object.
|
Initialise the theme object.
|
||||||
"""
|
"""
|
||||||
# Create the minidom document
|
# Create the minidom document
|
||||||
self.theme_xml = Document()
|
json_dir = os.path.join(AppLocation.get_directory(AppLocation.AppDir), 'core', 'lib', 'json')
|
||||||
self.parse_xml(BLANK_THEME_XML)
|
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):
|
def extend_image_filename(self, path):
|
||||||
"""
|
"""
|
||||||
@ -559,6 +567,7 @@ class ThemeXML(object):
|
|||||||
"""
|
"""
|
||||||
Create the attributes with the correct data types and name format
|
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)
|
reject, master, element, value = self._translate_tags(master, element, value)
|
||||||
if reject:
|
if reject:
|
||||||
return
|
return
|
||||||
|
@ -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)
|
|
@ -99,10 +99,11 @@ from .formattingtagcontroller import FormattingTagController
|
|||||||
from .shortcutlistform import ShortcutListForm
|
from .shortcutlistform import ShortcutListForm
|
||||||
from .mediadockmanager import MediaDockManager
|
from .mediadockmanager import MediaDockManager
|
||||||
from .servicemanager import ServiceManager
|
from .servicemanager import ServiceManager
|
||||||
|
from .thememanagerhelper import ThemeManagerHelper
|
||||||
from .thememanager import ThemeManager
|
from .thememanager import ThemeManager
|
||||||
|
|
||||||
__all__ = ['SplashScreen', 'AboutForm', 'SettingsForm', 'MainDisplay', 'SlideController', 'ServiceManager',
|
__all__ = ['SplashScreen', 'AboutForm', 'SettingsForm', 'MainDisplay', 'SlideController', 'ServiceManager',
|
||||||
'ThemeManager', 'MediaDockManager', 'ServiceItemEditForm', 'FirstTimeForm', 'FirstTimeLanguageForm', 'ThemeForm',
|
'ThemeManager', 'MediaDockManager', 'ServiceItemEditForm', 'FirstTimeForm', 'FirstTimeLanguageForm', 'ThemeForm',
|
||||||
'ThemeLayoutForm', 'FileRenameForm', 'StartTimeForm', 'MainDisplay', 'Display', 'ServiceNoteForm',
|
'ThemeLayoutForm', 'FileRenameForm', 'StartTimeForm', 'MainDisplay', 'Display', 'ServiceNoteForm',
|
||||||
'SlideController', 'DisplayController', 'GeneralTab', 'ThemesTab', 'AdvancedTab', 'PluginForm',
|
'SlideController', 'DisplayController', 'GeneralTab', 'ThemesTab', 'AdvancedTab', 'PluginForm',
|
||||||
'FormattingTagForm', 'ShortcutListForm', 'FormattingTagController']
|
'FormattingTagForm', 'ShortcutListForm', 'FormattingTagController', 'ThemeManagerHelper']
|
||||||
|
@ -36,8 +36,9 @@ import sys
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
|
from openlp.core.common.applocation import AppLocation
|
||||||
from openlp.core.lib import SettingsTab, Settings, UiStrings, translate, build_icon
|
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.utils import format_time, get_images_filter
|
||||||
from openlp.core.lib import SlideLimits
|
from openlp.core.lib import SlideLimits
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -41,8 +41,9 @@ from configparser import SafeConfigParser
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
|
from openlp.core.common.applocation import AppLocation
|
||||||
from openlp.core.lib import PluginStatus, Settings, Registry, build_icon, check_directory_exists, translate
|
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.utils import get_web_page
|
||||||
from .firsttimewizard import Ui_FirstTimeWizard, FirstTimePage
|
from .firsttimewizard import Ui_FirstTimeWizard, FirstTimePage
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -46,8 +46,10 @@ from openlp.core.lib import Renderer, OpenLPDockWidget, PluginManager, ImageMana
|
|||||||
from openlp.core.lib.ui import UiStrings, create_action
|
from openlp.core.lib.ui import UiStrings, create_action
|
||||||
from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, ThemeManager, SlideController, PluginForm, \
|
from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, ThemeManager, SlideController, PluginForm, \
|
||||||
MediaDockManager, ShortcutListForm, FormattingTagForm
|
MediaDockManager, ShortcutListForm, FormattingTagForm
|
||||||
|
|
||||||
|
from openlp.core.common.applocation import AppLocation
|
||||||
from openlp.core.ui.media import MediaController
|
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.utils.actions import ActionList, CategoryOrder
|
||||||
from openlp.core.ui.firsttimeform import FirstTimeForm
|
from openlp.core.ui.firsttimeform import FirstTimeForm
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ from openlp.core.lib import OpenLPToolbar, Settings, Registry, UiStrings, transl
|
|||||||
from openlp.core.lib.ui import critical_error_message_box
|
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 import MediaState, MediaInfo, MediaType, get_media_players, set_media_players
|
||||||
from openlp.core.ui.media.mediaplayer import MediaPlayer
|
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
|
from openlp.core.ui import DisplayControllerType
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -38,7 +38,7 @@ from lxml import html
|
|||||||
|
|
||||||
from openlp.core.lib import Settings, UiStrings, Registry, translate, get_text_file_string
|
from openlp.core.lib import Settings, UiStrings, Registry, translate, get_text_file_string
|
||||||
from openlp.core.ui.printservicedialog import Ui_PrintServiceDialog, ZoomSize
|
from openlp.core.ui.printservicedialog import Ui_PrintServiceDialog, ZoomSize
|
||||||
from openlp.core.utils import AppLocation
|
from openlp.core.common import AppLocation
|
||||||
|
|
||||||
DEFAULT_CSS = """/*
|
DEFAULT_CSS = """/*
|
||||||
Edit this file to customize the service order print. Note, that not all CSS
|
Edit this file to customize the service order print. Note, that not all CSS
|
||||||
|
@ -42,13 +42,14 @@ log = logging.getLogger(__name__)
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
|
from openlp.core.common.applocation import AppLocation
|
||||||
from openlp.core.lib import OpenLPToolbar, ServiceItem, ItemCapabilities, Settings, PluginStatus, Registry, \
|
from openlp.core.lib import OpenLPToolbar, ServiceItem, ItemCapabilities, Settings, PluginStatus, Registry, \
|
||||||
UiStrings, build_icon, translate, str_to_bool, check_directory_exists
|
UiStrings, build_icon, translate, str_to_bool, check_directory_exists
|
||||||
from openlp.core.lib.theme import ThemeLevel
|
from openlp.core.lib.theme import ThemeLevel
|
||||||
from openlp.core.lib.ui import critical_error_message_box, create_widget_action, find_and_set_in_combo_box
|
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 import ServiceNoteForm, ServiceItemEditForm, StartTimeForm
|
||||||
from openlp.core.ui.printserviceform import PrintServiceForm
|
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
|
from openlp.core.utils.actions import ActionList, CategoryOrder
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,18 +38,18 @@ import re
|
|||||||
from xml.etree.ElementTree import ElementTree, XML
|
from xml.etree.ElementTree import ElementTree, XML
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
|
from openlp.core.common.applocation import AppLocation
|
||||||
from openlp.core.lib import ImageSource, OpenLPToolbar, Registry, Settings, UiStrings, get_text_file_string, \
|
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
|
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.lib.theme import ThemeXML, BackgroundType
|
||||||
from openlp.core.lib.ui import critical_error_message_box, create_widget_action
|
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, ThemeManagerHelper
|
||||||
from openlp.core.ui import FileRenameForm, ThemeForm
|
from openlp.core.utils import delete_file, get_locale_key, get_filesystem_encoding
|
||||||
from openlp.core.utils import AppLocation, delete_file, get_locale_key, get_filesystem_encoding
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class ThemeManager(QtGui.QWidget):
|
class ThemeManager(QtGui.QWidget, ThemeManagerHelper):
|
||||||
"""
|
"""
|
||||||
Manages the orders of Theme.
|
Manages the orders of Theme.
|
||||||
"""
|
"""
|
||||||
@ -328,8 +328,8 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
try:
|
try:
|
||||||
encoding = get_filesystem_encoding()
|
encoding = get_filesystem_encoding()
|
||||||
shutil.rmtree(os.path.join(self.path, theme).encode(encoding))
|
shutil.rmtree(os.path.join(self.path, theme).encode(encoding))
|
||||||
except OSError as xxx_todo_changeme1:
|
except OSError as os_error:
|
||||||
shutil.Error = xxx_todo_changeme1
|
shutil.Error = os_error
|
||||||
log.exception('Error deleting theme %s', theme)
|
log.exception('Error deleting theme %s', theme)
|
||||||
|
|
||||||
def on_export_theme(self):
|
def on_export_theme(self):
|
||||||
@ -469,7 +469,7 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
log.debug('No theme data - using default theme')
|
log.debug('No theme data - using default theme')
|
||||||
return ThemeXML()
|
return ThemeXML()
|
||||||
else:
|
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):
|
def over_write_message_box(self, theme_name):
|
||||||
"""
|
"""
|
||||||
@ -501,35 +501,30 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
log.exception('Theme contains "%s" XML files' % len(xml_file))
|
log.exception('Theme contains "%s" XML files' % len(xml_file))
|
||||||
raise Exception('validation')
|
raise Exception('validation')
|
||||||
xml_tree = ElementTree(element=XML(theme_zip.read(xml_file[0]))).getroot()
|
xml_tree = ElementTree(element=XML(theme_zip.read(xml_file[0]))).getroot()
|
||||||
v1_background = xml_tree.find('BackgroundType')
|
theme_name = xml_tree.find('name').text.strip()
|
||||||
if v1_background is not None:
|
theme_folder = os.path.join(directory, theme_name)
|
||||||
theme_name, file_xml, out_file, abort_import = \
|
theme_exists = os.path.exists(theme_folder)
|
||||||
self.unzip_version_122(directory, theme_zip, xml_file[0], xml_tree, v1_background, out_file)
|
if theme_exists and not self.over_write_message_box(theme_name):
|
||||||
|
abort_import = True
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
theme_name = xml_tree.find('name').text.strip()
|
abort_import = False
|
||||||
theme_folder = os.path.join(directory, theme_name)
|
for name in theme_zip.namelist():
|
||||||
theme_exists = os.path.exists(theme_folder)
|
name = name.replace('/', os.path.sep)
|
||||||
if theme_exists and not self.over_write_message_box(theme_name):
|
split_name = name.split(os.path.sep)
|
||||||
abort_import = True
|
if split_name[-1] == '' or len(split_name) == 1:
|
||||||
return
|
# 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:
|
else:
|
||||||
abort_import = False
|
out_file = open(full_name, 'wb')
|
||||||
for name in theme_zip.namelist():
|
out_file.write(theme_zip.read(name))
|
||||||
name = name.replace('/', os.path.sep)
|
out_file.close()
|
||||||
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()
|
|
||||||
except (IOError, zipfile.BadZipfile):
|
except (IOError, zipfile.BadZipfile):
|
||||||
log.exception('Importing theme from zip failed %s' % file_name)
|
log.exception('Importing theme from zip failed %s' % file_name)
|
||||||
raise Exception('validation')
|
raise Exception('validation')
|
||||||
@ -548,7 +543,7 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
if not abort_import:
|
if not abort_import:
|
||||||
# As all files are closed, we can create the Theme.
|
# As all files are closed, we can create the Theme.
|
||||||
if file_xml:
|
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)
|
self.generate_and_save_image(directory, theme_name, theme)
|
||||||
# Only show the error message, when IOError was not raised (in
|
# Only show the error message, when IOError was not raised (in
|
||||||
# this case the error message has already been shown).
|
# this case the error message has already been shown).
|
||||||
@ -558,38 +553,6 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
translate('OpenLP.ThemeManager', 'File is not a valid theme.'))
|
translate('OpenLP.ThemeManager', 'File is not a valid theme.'))
|
||||||
log.exception('Theme file does not contain XML data %s' % file_name)
|
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):
|
def check_if_theme_exists(self, theme_name):
|
||||||
"""
|
"""
|
||||||
Check if theme already exists and displays error message
|
Check if theme already exists and displays error message
|
||||||
@ -697,7 +660,7 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
image = os.path.join(self.path, theme + '.png')
|
image = os.path.join(self.path, theme + '.png')
|
||||||
return image
|
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
|
Return a theme object using information parsed from XML
|
||||||
|
|
||||||
@ -741,55 +704,6 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
return True
|
return True
|
||||||
return False
|
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):
|
def _get_renderer(self):
|
||||||
"""
|
"""
|
||||||
Adds the Renderer to the class dynamically
|
Adds the Renderer to the class dynamically
|
||||||
|
38
openlp/core/ui/thememanagerhelper.py
Normal file
38
openlp/core/ui/thememanagerhelper.py
Normal file
@ -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
|
@ -37,10 +37,13 @@ import os
|
|||||||
import re
|
import re
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
import sys
|
import sys
|
||||||
import urllib.request, urllib.error, urllib.parse
|
import urllib.request
|
||||||
|
import urllib.error
|
||||||
|
import urllib.parse
|
||||||
|
|
||||||
from PyQt4 import QtGui, QtCore
|
from PyQt4 import QtGui, QtCore
|
||||||
|
|
||||||
|
from openlp.core.common import AppLocation
|
||||||
from openlp.core.lib import Registry, Settings
|
from openlp.core.lib import Registry, Settings
|
||||||
|
|
||||||
|
|
||||||
@ -81,15 +84,6 @@ class VersionThread(QtCore.QThread):
|
|||||||
Registry().execute('openlp_version_check', '%s' % version)
|
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():
|
def get_application_version():
|
||||||
"""
|
"""
|
||||||
Returns the application version of the running instance of OpenLP::
|
Returns the application version of the running instance of OpenLP::
|
||||||
@ -418,18 +412,17 @@ def get_natural_key(string):
|
|||||||
"""
|
"""
|
||||||
key = DIGITS_OR_NONDIGITS.findall(string)
|
key = DIGITS_OR_NONDIGITS.findall(string)
|
||||||
key = [int(part) if part.isdigit() else get_locale_key(part) for part in key]
|
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.
|
# and int.
|
||||||
if string[0].isdigit():
|
if string[0].isdigit():
|
||||||
return [b''] + key
|
return [b''] + key
|
||||||
return key
|
return key
|
||||||
|
|
||||||
|
|
||||||
from .applocation import AppLocation
|
|
||||||
from .languagemanager import LanguageManager
|
from .languagemanager import LanguageManager
|
||||||
from .actions import ActionList
|
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',
|
'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']
|
'delete_file', 'clean_filename', 'format_time', 'get_locale_key', 'get_natural_key']
|
||||||
|
@ -35,7 +35,7 @@ import sys
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.utils import AppLocation
|
from openlp.core.common import AppLocation
|
||||||
from openlp.core.lib import Settings, translate
|
from openlp.core.lib import Settings, translate
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -34,11 +34,12 @@ import os
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
|
from openlp.core.common.applocation import AppLocation
|
||||||
from openlp.core.lib import Settings, UiStrings, translate
|
from openlp.core.lib import Settings, UiStrings, translate
|
||||||
from openlp.core.lib.db import delete_database
|
from openlp.core.lib.db import delete_database
|
||||||
from openlp.core.lib.ui import critical_error_message_box
|
from openlp.core.lib.ui import critical_error_message_box
|
||||||
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
|
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.manager import BibleFormat
|
||||||
from openlp.plugins.bibles.lib.db import BiblesResourcesDB, clean_filename
|
from openlp.plugins.bibles.lib.db import BiblesResourcesDB, clean_filename
|
||||||
|
|
||||||
|
@ -36,10 +36,11 @@ from tempfile import gettempdir
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
|
from openlp.core.common.applocation import AppLocation
|
||||||
from openlp.core.lib import Registry, Settings, UiStrings, translate, check_directory_exists
|
from openlp.core.lib import Registry, Settings, UiStrings, translate, check_directory_exists
|
||||||
from openlp.core.lib.ui import critical_error_message_box
|
from openlp.core.lib.ui import critical_error_message_box
|
||||||
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
|
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.db import BibleDB, BibleMeta, OldBibleDB, BiblesResourcesDB
|
||||||
from openlp.plugins.bibles.lib.http import BSExtract, BGExtract, CWExtract
|
from openlp.plugins.bibles.lib.http import BSExtract, BGExtract, CWExtract
|
||||||
|
|
||||||
|
@ -38,10 +38,11 @@ from sqlalchemy import Column, ForeignKey, Table, or_, types, func
|
|||||||
from sqlalchemy.orm import class_mapper, mapper, relation
|
from sqlalchemy.orm import class_mapper, mapper, relation
|
||||||
from sqlalchemy.orm.exc import UnmappedClassError
|
from sqlalchemy.orm.exc import UnmappedClassError
|
||||||
|
|
||||||
|
from openlp.core.common.applocation import AppLocation
|
||||||
from openlp.core.lib import Registry, translate
|
from openlp.core.lib import Registry, translate
|
||||||
from openlp.core.lib.db import BaseModel, init_db, Manager
|
from openlp.core.lib.db import BaseModel, init_db, Manager
|
||||||
from openlp.core.lib.ui import critical_error_message_box
|
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
|
from . import upgrade
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -30,8 +30,9 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from openlp.core.common.applocation import AppLocation
|
||||||
from openlp.core.lib import Registry, Settings, translate
|
from openlp.core.lib import Registry, Settings, translate
|
||||||
from openlp.core.utils import AppLocation, delete_file
|
from openlp.core.utils import delete_file
|
||||||
from openlp.plugins.bibles.lib import parse_reference, get_reference_separator, LanguageSelection
|
from openlp.plugins.bibles.lib import parse_reference, get_reference_separator, LanguageSelection
|
||||||
from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta
|
from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta
|
||||||
from .csvbible import CSVBible
|
from .csvbible import CSVBible
|
||||||
|
@ -33,8 +33,8 @@ import chardet
|
|||||||
import codecs
|
import codecs
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
from openlp.core.common import AppLocation
|
||||||
from openlp.core.lib import translate
|
from openlp.core.lib import translate
|
||||||
from openlp.core.utils import AppLocation
|
|
||||||
from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB
|
from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -32,11 +32,12 @@ import os
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
|
from openlp.core.common.applocation import AppLocation
|
||||||
from openlp.core.lib import ItemCapabilities, MediaManagerItem, Registry, ServiceItemContext, Settings, \
|
from openlp.core.lib import ItemCapabilities, MediaManagerItem, Registry, ServiceItemContext, Settings, \
|
||||||
StringContent, TreeWidgetWithDnD, UiStrings, build_icon, check_directory_exists, check_item_selected, \
|
StringContent, TreeWidgetWithDnD, UiStrings, build_icon, check_directory_exists, check_item_selected, \
|
||||||
create_thumb, translate, validate_thumb
|
create_thumb, translate, validate_thumb
|
||||||
from openlp.core.lib.ui import create_widget_action, critical_error_message_box
|
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.forms import AddGroupForm, ChooseGroupForm
|
||||||
from openlp.plugins.images.lib.db import ImageFilenames, ImageGroups
|
from openlp.plugins.images.lib.db import ImageFilenames, ImageGroups
|
||||||
|
|
||||||
|
@ -32,12 +32,13 @@ import os
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
|
from openlp.core.common.applocation import AppLocation
|
||||||
from openlp.core.lib import ItemCapabilities, MediaManagerItem,MediaType, Registry, ServiceItem, ServiceItemContext, \
|
from openlp.core.lib import ItemCapabilities, MediaManagerItem,MediaType, Registry, ServiceItem, ServiceItemContext, \
|
||||||
Settings, UiStrings, build_icon, check_item_selected, check_directory_exists, translate
|
Settings, UiStrings, build_icon, check_item_selected, check_directory_exists, translate
|
||||||
from openlp.core.lib.ui import critical_error_message_box, create_horizontal_adjusting_combo_box
|
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 import DisplayController, Display, DisplayControllerType
|
||||||
from openlp.core.ui.media import get_media_players, set_media_players
|
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__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -33,8 +33,8 @@ import shutil
|
|||||||
|
|
||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
|
from openlp.core.common.applocation import AppLocation
|
||||||
from openlp.core.lib import Registry, Settings, check_directory_exists, create_thumb, validate_thumb
|
from openlp.core.lib import Registry, Settings, check_directory_exists, create_thumb, validate_thumb
|
||||||
from openlp.core.utils import AppLocation
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -35,8 +35,8 @@ import logging
|
|||||||
|
|
||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
|
from openlp.core.common.applocation import AppLocation
|
||||||
from openlp.core.lib import Plugin, StringContent, build_icon, translate
|
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
|
from openlp.plugins.presentations.lib import PresentationController, PresentationMediaItem, PresentationTab
|
||||||
|
|
||||||
|
|
||||||
|
@ -121,12 +121,12 @@ import urllib.request
|
|||||||
import urllib.error
|
import urllib.error
|
||||||
from urllib.parse import urlparse, parse_qs
|
from urllib.parse import urlparse, parse_qs
|
||||||
|
|
||||||
|
|
||||||
from mako.template import Template
|
from mako.template import Template
|
||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
|
from openlp.core.common.applocation import AppLocation
|
||||||
from openlp.core.lib import Registry, Settings, PluginStatus, StringContent, image_to_byte
|
from openlp.core.lib import Registry, Settings, PluginStatus, StringContent, image_to_byte
|
||||||
from openlp.core.utils import AppLocation, translate
|
from openlp.core.utils import translate
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -37,12 +37,11 @@ import ssl
|
|||||||
import socket
|
import socket
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
from urllib.parse import urlparse, parse_qs
|
|
||||||
|
|
||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
|
from openlp.core.common.applocation import AppLocation
|
||||||
from openlp.core.lib import Settings
|
from openlp.core.lib import Settings
|
||||||
from openlp.core.utils import AppLocation
|
|
||||||
|
|
||||||
from openlp.plugins.remotes.lib import HttpRouter
|
from openlp.plugins.remotes.lib import HttpRouter
|
||||||
|
|
||||||
|
@ -31,9 +31,8 @@ import os.path
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui, QtNetwork
|
from PyQt4 import QtCore, QtGui, QtNetwork
|
||||||
|
|
||||||
|
from openlp.core.common.applocation import AppLocation
|
||||||
from openlp.core.lib import Settings, SettingsTab, translate
|
from openlp.core.lib import Settings, SettingsTab, translate
|
||||||
from openlp.core.utils import AppLocation
|
|
||||||
|
|
||||||
|
|
||||||
ZERO_URL = '0.0.0.0'
|
ZERO_URL = '0.0.0.0'
|
||||||
|
|
||||||
|
@ -35,9 +35,9 @@ import os
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
|
from openlp.core.common.applocation import AppLocation
|
||||||
from openlp.core.lib import Registry, translate
|
from openlp.core.lib import Registry, translate
|
||||||
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
|
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 import delete_song
|
||||||
from openlp.plugins.songs.lib.db import Song, MediaFile
|
from openlp.plugins.songs.lib.db import Song, MediaFile
|
||||||
from openlp.plugins.songs.forms.songreviewwidget import SongReviewWidget
|
from openlp.plugins.songs.forms.songreviewwidget import SongReviewWidget
|
||||||
|
@ -38,10 +38,10 @@ import shutil
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
|
from openlp.core.common.applocation import AppLocation
|
||||||
from openlp.core.lib import Registry, PluginStatus, MediaType, UiStrings, translate, create_separated_list, \
|
from openlp.core.lib import Registry, PluginStatus, MediaType, UiStrings, translate, create_separated_list, \
|
||||||
check_directory_exists
|
check_directory_exists
|
||||||
from openlp.core.lib.ui import set_case_insensitive_completer, critical_error_message_box, find_and_set_in_combo_box
|
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 import VerseType, clean_song
|
||||||
from openlp.plugins.songs.lib.db import Book, Song, Author, Topic, MediaFile
|
from openlp.plugins.songs.lib.db import Book, Song, Author, Topic, MediaFile
|
||||||
from openlp.plugins.songs.lib.ui import SongStrings
|
from openlp.plugins.songs.lib.ui import SongStrings
|
||||||
|
@ -36,8 +36,9 @@ import re
|
|||||||
|
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
|
|
||||||
|
from openlp.core.common.applocation import AppLocation
|
||||||
from openlp.core.lib import translate
|
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 openlp.plugins.songs.lib.db import MediaFile, Song
|
||||||
from .db import Author
|
from .db import Author
|
||||||
from .ui import SongStrings
|
from .ui import SongStrings
|
||||||
|
@ -35,10 +35,10 @@ import shutil
|
|||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
from sqlalchemy.sql import or_
|
from sqlalchemy.sql import or_
|
||||||
|
|
||||||
|
from openlp.core.common.applocation import AppLocation
|
||||||
from openlp.core.lib import Registry, MediaManagerItem, ItemCapabilities, PluginStatus, ServiceItemContext, Settings, \
|
from openlp.core.lib import Registry, MediaManagerItem, ItemCapabilities, PluginStatus, ServiceItemContext, Settings, \
|
||||||
UiStrings, translate, check_item_selected, create_separated_list, check_directory_exists
|
UiStrings, translate, check_item_selected, create_separated_list, check_directory_exists
|
||||||
from openlp.core.lib.ui import create_widget_action
|
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.editsongform import EditSongForm
|
||||||
from openlp.plugins.songs.forms.songmaintenanceform import SongMaintenanceForm
|
from openlp.plugins.songs.forms.songmaintenanceform import SongMaintenanceForm
|
||||||
from openlp.plugins.songs.forms.songimportform import SongImportForm
|
from openlp.plugins.songs.forms.songimportform import SongImportForm
|
||||||
|
@ -34,9 +34,9 @@ import os
|
|||||||
|
|
||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
|
from openlp.core.common.applocation import AppLocation
|
||||||
from openlp.core.lib import Registry, translate, check_directory_exists
|
from openlp.core.lib import Registry, translate, check_directory_exists
|
||||||
from openlp.core.ui.wizard import WizardStrings
|
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 import clean_song, VerseType
|
||||||
from openlp.plugins.songs.lib.db import Song, Author, Topic, Book, MediaFile
|
from openlp.plugins.songs.lib.db import Song, Author, Topic, Book, MediaFile
|
||||||
from openlp.plugins.songs.lib.ui import SongStrings
|
from openlp.plugins.songs.lib.ui import SongStrings
|
||||||
|
@ -32,7 +32,7 @@ Functional tests to test the AppLocation class and related methods.
|
|||||||
import copy
|
import copy
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
from openlp.core.utils import AppLocation
|
from openlp.core.common.applocation import AppLocation
|
||||||
from tests.functional import patch
|
from tests.functional import patch
|
||||||
|
|
||||||
FILE_LIST = ['file1', 'file2', 'file3.txt', 'file4.txt', 'file5.mp3', 'file6.mp3']
|
FILE_LIST = ['file1', 'file2', 'file3.txt', 'file4.txt', 'file5.mp3', 'file6.mp3']
|
||||||
|
@ -105,10 +105,10 @@ class TestRemoteTab(TestCase):
|
|||||||
Test the set_urls function with standard defaults
|
Test the set_urls function with standard defaults
|
||||||
"""
|
"""
|
||||||
# GIVEN: A mocked location
|
# GIVEN: A mocked location
|
||||||
with patch('openlp.core.utils.applocation.Settings') as mocked_class, \
|
with patch('openlp.core.common.applocation.Settings') as mocked_class, \
|
||||||
patch('openlp.core.utils.AppLocation.get_directory') as mocked_get_directory, \
|
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.common.applocation.check_directory_exists') as mocked_check_directory_exists, \
|
||||||
patch('openlp.core.utils.applocation.os') as mocked_os:
|
patch('openlp.core.common.applocation.os') as mocked_os:
|
||||||
# GIVEN: A mocked out Settings class and a mocked out AppLocation.get_directory()
|
# GIVEN: A mocked out Settings class and a mocked out AppLocation.get_directory()
|
||||||
mocked_settings = mocked_class.return_value
|
mocked_settings = mocked_class.return_value
|
||||||
mocked_settings.contains.return_value = False
|
mocked_settings.contains.return_value = False
|
||||||
@ -133,10 +133,10 @@ class TestRemoteTab(TestCase):
|
|||||||
Test the set_urls function with certificate available
|
Test the set_urls function with certificate available
|
||||||
"""
|
"""
|
||||||
# GIVEN: A mocked location
|
# GIVEN: A mocked location
|
||||||
with patch('openlp.core.utils.applocation.Settings') as mocked_class, \
|
with patch('openlp.core.common.applocation.Settings') as mocked_class, \
|
||||||
patch('openlp.core.utils.AppLocation.get_directory') as mocked_get_directory, \
|
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.common.applocation.check_directory_exists') as mocked_check_directory_exists, \
|
||||||
patch('openlp.core.utils.applocation.os') as mocked_os:
|
patch('openlp.core.common.applocation.os') as mocked_os:
|
||||||
# GIVEN: A mocked out Settings class and a mocked out AppLocation.get_directory()
|
# GIVEN: A mocked out Settings class and a mocked out AppLocation.get_directory()
|
||||||
mocked_settings = mocked_class.return_value
|
mocked_settings = mocked_class.return_value
|
||||||
mocked_settings.contains.return_value = False
|
mocked_settings.contains.return_value = False
|
||||||
|
Loading…
Reference in New Issue
Block a user