forked from openlp/openlp
Minor tweeks
This commit is contained in:
parent
a775f0ddb8
commit
fc5c6561e7
@ -506,7 +506,7 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ThemeManage
|
|||||||
|
|
||||||
def get_theme_data(self, theme_name):
|
def get_theme_data(self, theme_name):
|
||||||
"""
|
"""
|
||||||
Returns a theme object from an XML file
|
Returns a theme object from an XML or JSON file
|
||||||
|
|
||||||
:param theme_name: Name of the theme to load from file
|
:param theme_name: Name of the theme to load from file
|
||||||
:return: The theme object.
|
:return: The theme object.
|
||||||
@ -556,11 +556,13 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ThemeManage
|
|||||||
out_file = None
|
out_file = None
|
||||||
file_xml = None
|
file_xml = None
|
||||||
abort_import = True
|
abort_import = True
|
||||||
|
json_theme = False
|
||||||
|
theme_name = ""
|
||||||
try:
|
try:
|
||||||
theme_zip = zipfile.ZipFile(file_name)
|
theme_zip = zipfile.ZipFile(file_name)
|
||||||
json_theme = False
|
|
||||||
json_file = [name for name in theme_zip.namelist() if os.path.splitext(name)[1].lower() == '.json']
|
json_file = [name for name in theme_zip.namelist() if os.path.splitext(name)[1].lower() == '.json']
|
||||||
if len(json_file) != 1:
|
if len(json_file) != 1:
|
||||||
|
# TODO: remove XML handling at some point but would need a auto conversion to run first.
|
||||||
xml_file = [name for name in theme_zip.namelist() if os.path.splitext(name)[1].lower() == '.xml']
|
xml_file = [name for name in theme_zip.namelist() if os.path.splitext(name)[1].lower() == '.xml']
|
||||||
if len(xml_file) != 1:
|
if len(xml_file) != 1:
|
||||||
self.log_error('Theme contains "{val:d}" theme files'.format(val=len(xml_file)))
|
self.log_error('Theme contains "{val:d}" theme files'.format(val=len(xml_file)))
|
||||||
@ -572,9 +574,9 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ThemeManage
|
|||||||
raise ValidationError
|
raise ValidationError
|
||||||
theme_name = xml_tree.find('name').text.strip()
|
theme_name = xml_tree.find('name').text.strip()
|
||||||
else:
|
else:
|
||||||
theme = Theme()
|
new_theme = Theme()
|
||||||
theme.load_theme(theme_zip.read(json_file[0]).decode("utf-8"))
|
new_theme.load_theme(theme_zip.read(json_file[0]).decode("utf-8"))
|
||||||
theme_name = theme.theme_name
|
theme_name = new_theme.theme_name
|
||||||
json_theme = True
|
json_theme = True
|
||||||
theme_folder = os.path.join(directory, theme_name)
|
theme_folder = os.path.join(directory, theme_name)
|
||||||
theme_exists = os.path.exists(theme_folder)
|
theme_exists = os.path.exists(theme_folder)
|
||||||
|
Loading…
Reference in New Issue
Block a user