2010-10-03 07:42:02 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2019-04-13 13:00:22 +00:00
|
|
|
##########################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# ---------------------------------------------------------------------- #
|
2022-02-01 10:10:57 +00:00
|
|
|
# Copyright (c) 2008-2022 OpenLP Developers #
|
2019-04-13 13:00:22 +00:00
|
|
|
# ---------------------------------------------------------------------- #
|
|
|
|
# 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, either version 3 of the License, or #
|
|
|
|
# (at your option) any later version. #
|
|
|
|
# #
|
|
|
|
# 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, see <https://www.gnu.org/licenses/>. #
|
|
|
|
##########################################################################
|
2013-02-01 21:34:23 +00:00
|
|
|
"""
|
|
|
|
The Theme wizard
|
|
|
|
"""
|
2010-10-03 07:42:02 +00:00
|
|
|
import logging
|
|
|
|
|
2015-11-07 00:49:40 +00:00
|
|
|
from PyQt5 import QtCore, QtGui, QtWidgets
|
2010-10-03 07:42:02 +00:00
|
|
|
|
2019-12-11 19:31:48 +00:00
|
|
|
from openlp.core.common import is_not_image_file
|
2020-02-04 20:35:35 +00:00
|
|
|
from openlp.core.common.enum import ServiceItemType
|
2017-10-07 07:05:07 +00:00
|
|
|
from openlp.core.common.i18n import UiStrings, translate
|
2017-10-23 22:09:57 +00:00
|
|
|
from openlp.core.common.mixins import RegistryProperties
|
|
|
|
from openlp.core.common.registry import Registry
|
2019-12-11 19:31:48 +00:00
|
|
|
from openlp.core.lib.theme import BackgroundType
|
2013-01-11 00:19:11 +00:00
|
|
|
from openlp.core.lib.ui import critical_error_message_box
|
2018-10-02 04:39:42 +00:00
|
|
|
from openlp.core.ui.themelayoutform import ThemeLayoutForm
|
|
|
|
from openlp.core.ui.themewizard import Ui_ThemeWizard
|
|
|
|
|
2010-10-03 07:42:02 +00:00
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
2013-02-01 21:34:23 +00:00
|
|
|
|
2015-11-07 00:49:40 +00:00
|
|
|
class ThemeForm(QtWidgets.QWizard, Ui_ThemeWizard, RegistryProperties):
|
2010-10-03 07:42:02 +00:00
|
|
|
"""
|
2011-01-02 22:24:14 +00:00
|
|
|
This is the Theme Import Wizard, which allows easy creation and editing of
|
|
|
|
OpenLP themes.
|
2010-10-03 07:42:02 +00:00
|
|
|
"""
|
2013-08-31 18:17:38 +00:00
|
|
|
log.info('ThemeWizardForm loaded')
|
2010-10-03 07:42:02 +00:00
|
|
|
|
|
|
|
def __init__(self, parent):
|
|
|
|
"""
|
|
|
|
Instantiate the wizard, and run any extra setup we need to.
|
|
|
|
|
2014-03-17 19:05:55 +00:00
|
|
|
:param parent: The QWidget-derived parent of the wizard.
|
2010-10-03 07:42:02 +00:00
|
|
|
"""
|
2021-08-25 21:14:19 +00:00
|
|
|
super(ThemeForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint |
|
|
|
|
QtCore.Qt.WindowCloseButtonHint)
|
2015-01-08 22:05:32 +00:00
|
|
|
self._setup()
|
|
|
|
|
|
|
|
def _setup(self):
|
|
|
|
"""
|
|
|
|
Set up the class. This method is mocked out by the tests.
|
|
|
|
"""
|
2018-09-12 05:43:27 +00:00
|
|
|
self.setup_ui(self)
|
2019-12-11 19:31:48 +00:00
|
|
|
self.can_update_theme = True
|
2017-09-26 16:39:13 +00:00
|
|
|
self.temp_background_filename = None
|
2013-12-26 17:36:00 +00:00
|
|
|
self.theme_layout_form = ThemeLayoutForm(self)
|
|
|
|
self.customButtonClicked.connect(self.on_custom_1_button_clicked)
|
|
|
|
self.currentIdChanged.connect(self.on_current_id_changed)
|
|
|
|
Registry().register_function('theme_line_count', self.update_lines_text)
|
2019-12-11 19:31:48 +00:00
|
|
|
self.main_area_page.font_name_changed.connect(self.calculate_lines)
|
|
|
|
self.main_area_page.font_size_changed.connect(self.calculate_lines)
|
|
|
|
self.main_area_page.line_spacing_changed.connect(self.calculate_lines)
|
|
|
|
self.main_area_page.is_outline_enabled_changed.connect(self.on_outline_toggled)
|
|
|
|
self.main_area_page.outline_size_changed.connect(self.calculate_lines)
|
|
|
|
self.main_area_page.is_shadow_enabled_changed.connect(self.on_shadow_toggled)
|
|
|
|
self.main_area_page.shadow_size_changed.connect(self.calculate_lines)
|
|
|
|
self.footer_area_page.font_name_changed.connect(self.update_theme)
|
|
|
|
self.footer_area_page.font_size_changed.connect(self.update_theme)
|
2021-08-25 21:14:19 +00:00
|
|
|
self.setOption(QtWidgets.QWizard.HaveHelpButton, True)
|
|
|
|
self.helpRequested.connect(self.provide_help)
|
|
|
|
|
|
|
|
def provide_help(self):
|
|
|
|
"""
|
|
|
|
Provide help within the wizard by opening the appropriate page of the openlp manual in the user's browser
|
|
|
|
"""
|
|
|
|
QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://manual.openlp.org/themes.html"))
|
2010-11-08 06:11:04 +00:00
|
|
|
|
2014-04-02 07:04:12 +00:00
|
|
|
def set_defaults(self):
|
2010-11-05 19:20:41 +00:00
|
|
|
"""
|
|
|
|
Set up display at start of theme edit.
|
|
|
|
"""
|
|
|
|
self.restart()
|
2013-12-26 17:36:00 +00:00
|
|
|
self.set_background_page_values()
|
|
|
|
self.set_main_area_page_values()
|
|
|
|
self.set_footer_area_page_values()
|
|
|
|
self.set_alignment_page_values()
|
|
|
|
self.set_position_page_values()
|
|
|
|
self.set_preview_page_values()
|
2010-11-05 19:20:41 +00:00
|
|
|
|
2019-11-22 16:40:10 +00:00
|
|
|
def calculate_lines(self, *args):
|
2010-11-23 20:48:55 +00:00
|
|
|
"""
|
|
|
|
Calculate the number of lines on a page by rendering text
|
|
|
|
"""
|
|
|
|
# Do not trigger on start up
|
2018-08-31 05:49:26 +00:00
|
|
|
if self.currentPage() != self.welcome_page:
|
2013-12-26 17:36:00 +00:00
|
|
|
self.update_theme()
|
2013-02-01 21:48:06 +00:00
|
|
|
self.theme_manager.generate_image(self.theme, True)
|
2010-11-23 20:48:55 +00:00
|
|
|
|
2013-12-26 17:36:00 +00:00
|
|
|
def update_lines_text(self, lines):
|
2010-11-23 20:48:55 +00:00
|
|
|
"""
|
|
|
|
Updates the lines on a page on the wizard
|
2016-02-27 14:03:52 +00:00
|
|
|
:param lines: then number of lines to be displayed
|
2010-11-23 20:48:55 +00:00
|
|
|
"""
|
2013-12-26 17:36:00 +00:00
|
|
|
self.main_line_count_label.setText(
|
2012-12-29 15:25:29 +00:00
|
|
|
translate('OpenLP.ThemeForm', '(approximately %d lines per slide)') % int(lines))
|
2010-11-23 20:48:55 +00:00
|
|
|
|
2010-12-28 21:24:21 +00:00
|
|
|
def resizeEvent(self, event=None):
|
|
|
|
"""
|
|
|
|
Rescale the theme preview thumbnail on resize events.
|
|
|
|
"""
|
|
|
|
if not event:
|
|
|
|
event = QtGui.QResizeEvent(self.size(), self.size())
|
2015-11-07 00:49:40 +00:00
|
|
|
QtWidgets.QWizard.resizeEvent(self, event)
|
2019-05-28 20:37:50 +00:00
|
|
|
try:
|
|
|
|
self.display_aspect_ratio = self.renderer.width() / self.renderer.height()
|
|
|
|
except ZeroDivisionError:
|
|
|
|
self.display_aspect_ratio = 1
|
2019-06-06 20:10:39 +00:00
|
|
|
# Make sure we don't resize before the widgets are actually created
|
|
|
|
if hasattr(self, 'preview_area_layout'):
|
|
|
|
self.preview_area_layout.set_aspect_ratio(self.display_aspect_ratio)
|
2020-09-20 17:35:49 +00:00
|
|
|
self.application.process_events()
|
2019-06-06 20:10:39 +00:00
|
|
|
self.preview_box.set_scale(float(self.preview_box.width()) / self.renderer.width())
|
2010-12-28 21:24:21 +00:00
|
|
|
|
2012-09-17 21:30:10 +00:00
|
|
|
def validateCurrentPage(self):
|
2013-02-01 21:34:23 +00:00
|
|
|
"""
|
|
|
|
Validate the current page
|
|
|
|
"""
|
2020-02-04 20:35:35 +00:00
|
|
|
if self.page(self.currentId()) == self.background_page:
|
|
|
|
background_image = BackgroundType.to_string(BackgroundType.Image)
|
|
|
|
background_video = BackgroundType.to_string(BackgroundType.Video)
|
|
|
|
background_stream = BackgroundType.to_string(BackgroundType.Stream)
|
|
|
|
if self.background_page.background_type == background_image and \
|
|
|
|
is_not_image_file(self.background_page.image_path):
|
|
|
|
QtWidgets.QMessageBox.critical(self, translate('OpenLP.ThemeWizard', 'Background Image Empty'),
|
|
|
|
translate('OpenLP.ThemeWizard', 'You have not selected a '
|
|
|
|
'background image. Please select one before continuing.'))
|
|
|
|
return False
|
|
|
|
elif self.background_page.background_type == background_video and \
|
|
|
|
not self.background_page.video_path:
|
|
|
|
QtWidgets.QMessageBox.critical(self, translate('OpenLP.ThemeWizard', 'Background Video Empty'),
|
|
|
|
translate('OpenLP.ThemeWizard', 'You have not selected a '
|
|
|
|
'background video. Please select one before continuing.'))
|
|
|
|
return False
|
|
|
|
elif self.background_page.background_type == background_stream and \
|
|
|
|
not self.background_page.stream_mrl.strip():
|
|
|
|
QtWidgets.QMessageBox.critical(self, translate('OpenLP.ThemeWizard', 'Background Stream Empty'),
|
|
|
|
translate('OpenLP.ThemeWizard', 'You have not selected a '
|
|
|
|
'background stream. Please select one before continuing.'))
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
return True
|
|
|
|
return True
|
2012-09-17 21:30:10 +00:00
|
|
|
|
2013-12-26 17:36:00 +00:00
|
|
|
def on_current_id_changed(self, page_id):
|
2010-12-27 21:53:02 +00:00
|
|
|
"""
|
2012-07-06 06:25:21 +00:00
|
|
|
Detects Page changes and updates as appropriate.
|
2016-02-27 14:03:52 +00:00
|
|
|
:param page_id: current page number
|
2010-12-27 21:53:02 +00:00
|
|
|
"""
|
2013-12-26 17:36:00 +00:00
|
|
|
enabled = self.page(page_id) == self.area_position_page
|
2015-11-07 00:49:40 +00:00
|
|
|
self.setOption(QtWidgets.QWizard.HaveCustomButton1, enabled)
|
2013-12-26 17:36:00 +00:00
|
|
|
if self.page(page_id) == self.preview_page:
|
|
|
|
self.update_theme()
|
2010-12-28 21:24:21 +00:00
|
|
|
self.resizeEvent()
|
2020-09-20 17:35:49 +00:00
|
|
|
self.preview_box.clear_slides()
|
2019-06-06 20:10:39 +00:00
|
|
|
self.preview_box.show()
|
|
|
|
self.preview_box.generate_preview(self.theme, False, False)
|
2010-12-27 21:53:02 +00:00
|
|
|
|
2013-12-26 17:36:00 +00:00
|
|
|
def on_custom_1_button_clicked(self, number):
|
2011-10-02 16:38:05 +00:00
|
|
|
"""
|
2011-10-03 16:53:54 +00:00
|
|
|
Generate layout preview and display the form.
|
2011-10-02 16:38:05 +00:00
|
|
|
"""
|
2013-12-26 17:36:00 +00:00
|
|
|
self.update_theme()
|
2018-10-13 20:55:36 +00:00
|
|
|
width = self.renderer.width()
|
|
|
|
height = self.renderer.height()
|
2011-09-27 19:37:34 +00:00
|
|
|
pixmap = QtGui.QPixmap(width, height)
|
|
|
|
pixmap.fill(QtCore.Qt.white)
|
|
|
|
paint = QtGui.QPainter(pixmap)
|
2011-09-28 20:43:30 +00:00
|
|
|
paint.setPen(QtGui.QPen(QtCore.Qt.blue, 2))
|
2022-01-21 21:32:09 +00:00
|
|
|
main_rect = QtCore.QRect(int(self.theme.font_main_x), int(self.theme.font_main_y),
|
|
|
|
int(self.theme.font_main_width - 1), int(self.theme.font_main_height - 1))
|
2018-10-13 20:55:36 +00:00
|
|
|
paint.drawRect(main_rect)
|
2011-09-28 20:43:30 +00:00
|
|
|
paint.setPen(QtGui.QPen(QtCore.Qt.red, 2))
|
2022-01-21 21:32:09 +00:00
|
|
|
footer_rect = QtCore.QRect(int(self.theme.font_footer_x), int(self.theme.font_footer_y),
|
|
|
|
int(self.theme.font_footer_width - 1), int(self.theme.font_footer_height - 1))
|
2018-10-13 20:55:36 +00:00
|
|
|
paint.drawRect(footer_rect)
|
2011-09-27 19:37:34 +00:00
|
|
|
paint.end()
|
2015-11-07 00:49:40 +00:00
|
|
|
self.theme_layout_form.exec(pixmap)
|
2011-10-02 07:52:28 +00:00
|
|
|
|
2019-11-22 16:40:10 +00:00
|
|
|
def on_outline_toggled(self, is_enabled):
|
2010-10-16 07:21:24 +00:00
|
|
|
"""
|
2010-10-16 13:54:57 +00:00
|
|
|
Change state as Outline check box changed
|
2010-10-16 07:21:24 +00:00
|
|
|
"""
|
2019-12-11 19:31:48 +00:00
|
|
|
if self.can_update_theme:
|
2019-11-22 16:40:10 +00:00
|
|
|
self.theme.font_main_outline = is_enabled
|
2013-12-26 17:36:00 +00:00
|
|
|
self.calculate_lines()
|
2010-10-11 16:14:36 +00:00
|
|
|
|
2019-11-22 16:40:10 +00:00
|
|
|
def on_shadow_toggled(self, is_enabled):
|
2010-10-16 07:21:24 +00:00
|
|
|
"""
|
|
|
|
Change state as Shadow check box changed
|
|
|
|
"""
|
2019-12-11 19:31:48 +00:00
|
|
|
if self.can_update_theme:
|
2019-11-22 16:40:10 +00:00
|
|
|
self.theme.font_main_shadow = is_enabled
|
2013-12-26 17:36:00 +00:00
|
|
|
self.calculate_lines()
|
2010-10-03 07:42:02 +00:00
|
|
|
|
2015-11-07 00:49:40 +00:00
|
|
|
def exec(self, edit=False):
|
2010-10-03 07:42:02 +00:00
|
|
|
"""
|
|
|
|
Run the wizard.
|
|
|
|
"""
|
2016-05-20 16:22:06 +00:00
|
|
|
log.debug('Editing theme {name}'.format(name=self.theme.theme_name))
|
2019-10-23 22:54:29 +00:00
|
|
|
self.temp_background_filename = self.theme.background_source
|
2019-12-11 19:31:48 +00:00
|
|
|
self.can_update_theme = False
|
2014-04-02 07:04:12 +00:00
|
|
|
self.set_defaults()
|
2019-12-11 19:31:48 +00:00
|
|
|
self.can_update_theme = True
|
2013-12-26 17:36:00 +00:00
|
|
|
self.theme_name_label.setVisible(not edit)
|
|
|
|
self.theme_name_edit.setVisible(not edit)
|
2011-01-09 18:51:06 +00:00
|
|
|
self.edit_mode = edit
|
2010-12-05 18:02:36 +00:00
|
|
|
if edit:
|
2016-05-20 16:22:06 +00:00
|
|
|
self.setWindowTitle(translate('OpenLP.ThemeWizard', 'Edit Theme - {name}'
|
|
|
|
).format(name=self.theme.theme_name))
|
2010-12-05 18:02:36 +00:00
|
|
|
self.next()
|
2010-12-28 11:18:56 +00:00
|
|
|
else:
|
2011-04-15 21:43:59 +00:00
|
|
|
self.setWindowTitle(UiStrings().NewTheme)
|
2015-11-07 00:49:40 +00:00
|
|
|
return QtWidgets.QWizard.exec(self)
|
2010-10-03 07:42:02 +00:00
|
|
|
|
2013-03-07 12:59:35 +00:00
|
|
|
def initializePage(self, page_id):
|
2010-11-08 06:11:04 +00:00
|
|
|
"""
|
|
|
|
Set up the pages for Initial run through dialog
|
|
|
|
"""
|
2016-05-20 16:22:06 +00:00
|
|
|
log.debug('initializePage {page}'.format(page=page_id))
|
2013-12-26 17:36:00 +00:00
|
|
|
wizard_page = self.page(page_id)
|
|
|
|
if wizard_page == self.background_page:
|
|
|
|
self.set_background_page_values()
|
|
|
|
elif wizard_page == self.main_area_page:
|
|
|
|
self.set_main_area_page_values()
|
|
|
|
elif wizard_page == self.footer_area_page:
|
|
|
|
self.set_footer_area_page_values()
|
|
|
|
elif wizard_page == self.alignment_page:
|
|
|
|
self.set_alignment_page_values()
|
|
|
|
elif wizard_page == self.area_position_page:
|
|
|
|
self.set_position_page_values()
|
|
|
|
|
|
|
|
def set_background_page_values(self):
|
2010-10-16 07:21:24 +00:00
|
|
|
"""
|
2010-12-28 11:18:56 +00:00
|
|
|
Handle the display and state of the Background page.
|
2010-10-16 07:21:24 +00:00
|
|
|
"""
|
2019-12-11 19:31:48 +00:00
|
|
|
self.background_page.background_type = self.theme.background_type
|
2013-12-26 17:36:00 +00:00
|
|
|
if self.theme.background_type == BackgroundType.to_string(BackgroundType.Solid):
|
2019-12-11 19:31:48 +00:00
|
|
|
self.background_page.color = self.theme.background_color
|
2012-12-29 15:25:29 +00:00
|
|
|
elif self.theme.background_type == BackgroundType.to_string(BackgroundType.Gradient):
|
2019-12-11 19:31:48 +00:00
|
|
|
self.background_page.gradient_start = self.theme.background_start_color
|
|
|
|
self.background_page.gradient_end = self.theme.background_end_color
|
|
|
|
self.background_page.gradient_type = self.theme.background_direction
|
2012-12-29 15:25:29 +00:00
|
|
|
elif self.theme.background_type == BackgroundType.to_string(BackgroundType.Image):
|
2019-12-11 19:31:48 +00:00
|
|
|
self.background_page.image_color = self.theme.background_border_color
|
|
|
|
if self.theme.background_source and self.theme.background_source.exists():
|
|
|
|
self.background_page.image_path = self.theme.background_source
|
|
|
|
else:
|
|
|
|
self.background_page.image_path = self.theme.background_filename
|
2016-04-30 15:40:23 +00:00
|
|
|
elif self.theme.background_type == BackgroundType.to_string(BackgroundType.Video):
|
2019-12-11 19:31:48 +00:00
|
|
|
self.background_page.video_color = self.theme.background_border_color
|
|
|
|
if self.theme.background_source and self.theme.background_source.exists():
|
|
|
|
self.background_page.video_path = self.theme.background_source
|
|
|
|
else:
|
|
|
|
self.background_page.video_path = self.theme.background_filename
|
2020-02-04 20:35:35 +00:00
|
|
|
elif self.theme.background_type == BackgroundType.to_string(BackgroundType.Stream):
|
|
|
|
self.background_page.stream_color = self.theme.background_border_color
|
|
|
|
self.background_page.stream_mrl = self.theme.background_source
|
2010-10-03 07:42:02 +00:00
|
|
|
|
2013-12-26 17:36:00 +00:00
|
|
|
def set_main_area_page_values(self):
|
2010-10-16 07:21:24 +00:00
|
|
|
"""
|
2010-12-28 11:18:56 +00:00
|
|
|
Handle the display and state of the Main Area page.
|
2010-10-16 07:21:24 +00:00
|
|
|
"""
|
2019-12-11 19:31:48 +00:00
|
|
|
self.main_area_page.font_name = self.theme.font_main_name
|
|
|
|
self.main_area_page.font_color = self.theme.font_main_color
|
|
|
|
self.main_area_page.font_size = self.theme.font_main_size
|
|
|
|
self.main_area_page.line_spacing = self.theme.font_main_line_adjustment
|
|
|
|
self.main_area_page.is_outline_enabled = self.theme.font_main_outline
|
|
|
|
self.main_area_page.outline_color = self.theme.font_main_outline_color
|
|
|
|
self.main_area_page.outline_size = self.theme.font_main_outline_size
|
|
|
|
self.main_area_page.is_shadow_enabled = self.theme.font_main_shadow
|
|
|
|
self.main_area_page.shadow_color = self.theme.font_main_shadow_color
|
|
|
|
self.main_area_page.shadow_size = self.theme.font_main_shadow_size
|
|
|
|
self.main_area_page.is_bold = self.theme.font_main_bold
|
|
|
|
self.main_area_page.is_italic = self.theme.font_main_italics
|
2013-12-26 17:36:00 +00:00
|
|
|
|
|
|
|
def set_footer_area_page_values(self):
|
2010-10-16 07:21:24 +00:00
|
|
|
"""
|
2010-12-28 11:18:56 +00:00
|
|
|
Handle the display and state of the Footer Area page.
|
2010-10-16 07:21:24 +00:00
|
|
|
"""
|
2019-12-11 19:31:48 +00:00
|
|
|
self.footer_area_page.font_name = self.theme.font_footer_name
|
|
|
|
self.footer_area_page.font_color = self.theme.font_footer_color
|
2020-04-09 21:55:27 +00:00
|
|
|
self.footer_area_page.is_bold = self.theme.font_footer_bold
|
|
|
|
self.footer_area_page.is_italic = self.theme.font_footer_italics
|
|
|
|
self.footer_area_page.font_size = self.theme.font_footer_size
|
2010-10-11 16:14:36 +00:00
|
|
|
|
2013-12-26 17:36:00 +00:00
|
|
|
def set_position_page_values(self):
|
2010-10-16 13:54:57 +00:00
|
|
|
"""
|
2013-12-26 17:36:00 +00:00
|
|
|
Handle the display and state of the _position page.
|
2010-10-16 13:54:57 +00:00
|
|
|
"""
|
2010-11-16 17:33:41 +00:00
|
|
|
# Main Area
|
2019-12-11 19:31:48 +00:00
|
|
|
self.area_position_page.use_main_default_location = not self.theme.font_main_override
|
2021-11-28 14:13:28 +00:00
|
|
|
self.area_position_page.main_x = int(self.theme.font_main_x)
|
|
|
|
self.area_position_page.main_y = int(self.theme.font_main_y)
|
|
|
|
self.area_position_page.main_height = int(self.theme.font_main_height)
|
|
|
|
self.area_position_page.main_width = int(self.theme.font_main_width)
|
2010-11-16 17:33:41 +00:00
|
|
|
# Footer
|
2019-12-11 19:31:48 +00:00
|
|
|
self.area_position_page.use_footer_default_location = not self.theme.font_footer_override
|
2021-11-28 14:13:28 +00:00
|
|
|
self.area_position_page.footer_x = int(self.theme.font_footer_x)
|
|
|
|
self.area_position_page.footer_y = int(self.theme.font_footer_y)
|
|
|
|
self.area_position_page.footer_height = int(self.theme.font_footer_height)
|
|
|
|
self.area_position_page.footer_width = int(self.theme.font_footer_width)
|
2010-10-09 10:59:49 +00:00
|
|
|
|
2013-12-26 17:36:00 +00:00
|
|
|
def set_alignment_page_values(self):
|
2010-11-08 06:11:04 +00:00
|
|
|
"""
|
2010-12-28 11:18:56 +00:00
|
|
|
Handle the display and state of the Alignments page.
|
2010-11-08 06:11:04 +00:00
|
|
|
"""
|
2019-12-11 19:31:48 +00:00
|
|
|
self.alignment_page.horizontal_align = self.theme.display_horizontal_align
|
|
|
|
self.alignment_page.vertical_align = self.theme.display_vertical_align
|
|
|
|
self.alignment_page.is_transition_enabled = self.theme.display_slide_transition
|
|
|
|
self.alignment_page.transition_type = self.theme.display_slide_transition_type
|
|
|
|
self.alignment_page.transition_speed = self.theme.display_slide_transition_speed
|
2019-12-14 11:44:42 +00:00
|
|
|
self.alignment_page.transition_direction = self.theme.display_slide_transition_direction
|
|
|
|
self.alignment_page.is_transition_reverse_enabled = self.theme.display_slide_transition_reverse
|
2010-10-17 18:58:42 +00:00
|
|
|
|
2013-12-26 17:36:00 +00:00
|
|
|
def set_preview_page_values(self):
|
2010-12-28 11:18:56 +00:00
|
|
|
"""
|
|
|
|
Handle the display and state of the Preview page.
|
|
|
|
"""
|
2019-12-11 19:31:48 +00:00
|
|
|
self.theme_name_edit.setText(self.theme.theme_name)
|
2020-02-04 20:35:35 +00:00
|
|
|
self.preview_box.set_theme(self.theme, service_item_type=ServiceItemType.Text)
|
2010-10-13 19:40:01 +00:00
|
|
|
|
2013-12-26 17:36:00 +00:00
|
|
|
def update_theme(self):
|
2010-10-16 07:21:24 +00:00
|
|
|
"""
|
|
|
|
Update the theme object from the UI for fields not already updated
|
|
|
|
when the are changed.
|
|
|
|
"""
|
2019-12-11 19:31:48 +00:00
|
|
|
if not self.can_update_theme:
|
2010-12-03 20:22:59 +00:00
|
|
|
return
|
2013-12-26 17:36:00 +00:00
|
|
|
log.debug('update_theme')
|
2019-12-11 19:31:48 +00:00
|
|
|
# background page
|
|
|
|
self.theme.background_type = self.background_page.background_type
|
|
|
|
if self.theme.background_type == BackgroundType.to_string(BackgroundType.Solid):
|
|
|
|
self.theme.background_color = self.background_page.color
|
|
|
|
elif self.theme.background_type == BackgroundType.to_string(BackgroundType.Gradient):
|
|
|
|
self.theme.background_direction = self.background_page.gradient_type
|
|
|
|
self.theme.background_start_color = self.background_page.gradient_start
|
|
|
|
self.theme.background_end_color = self.background_page.gradient_end
|
|
|
|
elif self.theme.background_type == BackgroundType.to_string(BackgroundType.Image):
|
|
|
|
self.theme.background_border_color = self.background_page.image_color
|
|
|
|
self.theme.background_source = self.background_page.image_path
|
|
|
|
self.theme.background_filename = self.background_page.image_path
|
|
|
|
elif self.theme.background_type == BackgroundType.to_string(BackgroundType.Video):
|
|
|
|
self.theme.background_border_color = self.background_page.video_color
|
|
|
|
self.theme.background_source = self.background_page.video_path
|
|
|
|
self.theme.background_filename = self.background_page.video_path
|
2020-02-04 20:35:35 +00:00
|
|
|
elif self.theme.background_type == BackgroundType.to_string(BackgroundType.Stream):
|
|
|
|
self.theme.background_border_color = self.background_page.stream_color
|
|
|
|
self.theme.background_source = self.background_page.stream_mrl
|
|
|
|
self.theme.background_filename = self.background_page.stream_mrl
|
2010-10-13 19:40:01 +00:00
|
|
|
# main page
|
2019-12-11 19:31:48 +00:00
|
|
|
self.theme.font_main_name = self.main_area_page.font_name
|
2020-04-09 21:55:27 +00:00
|
|
|
self.theme.font_main_color = self.main_area_page.font_color
|
2019-12-11 19:31:48 +00:00
|
|
|
self.theme.font_main_size = self.main_area_page.font_size
|
|
|
|
self.theme.font_main_line_adjustment = self.main_area_page.line_spacing
|
2022-01-21 21:32:09 +00:00
|
|
|
self.theme.font_main_outline = self.main_area_page.is_outline_enabled
|
|
|
|
self.theme.font_main_outline_color = self.main_area_page.outline_color
|
2019-12-11 19:31:48 +00:00
|
|
|
self.theme.font_main_outline_size = self.main_area_page.outline_size
|
2022-01-21 21:32:09 +00:00
|
|
|
self.theme.font_main_shadow = self.main_area_page.is_shadow_enabled
|
2019-12-11 19:31:48 +00:00
|
|
|
self.theme.font_main_shadow_size = self.main_area_page.shadow_size
|
2022-01-21 21:32:09 +00:00
|
|
|
self.main_area_page.shadow_color = self.theme.font_main_shadow_color
|
2019-12-11 19:31:48 +00:00
|
|
|
self.theme.font_main_bold = self.main_area_page.is_bold
|
|
|
|
self.theme.font_main_italics = self.main_area_page.is_italic
|
2010-10-13 19:40:01 +00:00
|
|
|
# footer page
|
2019-12-11 19:31:48 +00:00
|
|
|
self.theme.font_footer_name = self.footer_area_page.font_name
|
2020-04-09 21:55:27 +00:00
|
|
|
self.theme.font_footer_color = self.footer_area_page.font_color
|
2019-12-11 19:31:48 +00:00
|
|
|
self.theme.font_footer_size = self.footer_area_page.font_size
|
2020-04-09 21:55:27 +00:00
|
|
|
self.theme.font_footer_bold = self.footer_area_page.is_bold
|
|
|
|
self.theme.font_footer_italics = self.footer_area_page.is_italic
|
2019-10-26 10:00:07 +00:00
|
|
|
# position page (main)
|
2019-12-11 19:31:48 +00:00
|
|
|
self.theme.font_main_override = not self.area_position_page.use_main_default_location
|
2019-10-26 10:00:07 +00:00
|
|
|
if self.theme.font_main_override:
|
2019-12-11 19:31:48 +00:00
|
|
|
self.theme.font_main_x = self.area_position_page.main_x
|
|
|
|
self.theme.font_main_y = self.area_position_page.main_y
|
|
|
|
self.theme.font_main_height = self.area_position_page.main_height
|
|
|
|
self.theme.font_main_width = self.area_position_page.main_width
|
2019-10-26 10:00:07 +00:00
|
|
|
else:
|
|
|
|
self.theme.set_default_header()
|
|
|
|
# position page (footer)
|
2019-12-11 19:31:48 +00:00
|
|
|
self.theme.font_footer_override = not self.area_position_page.use_footer_default_location
|
2019-10-26 10:00:07 +00:00
|
|
|
if self.theme.font_footer_override:
|
2019-12-11 19:31:48 +00:00
|
|
|
self.theme.font_footer_x = self.area_position_page.footer_x
|
|
|
|
self.theme.font_footer_y = self.area_position_page.footer_y
|
|
|
|
self.theme.font_footer_height = self.area_position_page.footer_height
|
|
|
|
self.theme.font_footer_width = self.area_position_page.footer_width
|
2019-10-26 10:00:07 +00:00
|
|
|
else:
|
|
|
|
self.theme.set_default_footer()
|
2019-12-11 19:31:48 +00:00
|
|
|
# alignment page
|
|
|
|
self.theme.display_horizontal_align = self.alignment_page.horizontal_align
|
|
|
|
self.theme.display_vertical_align = self.alignment_page.vertical_align
|
|
|
|
self.theme.display_slide_transition = self.alignment_page.is_transition_enabled
|
|
|
|
self.theme.display_slide_transition_type = self.alignment_page.transition_type
|
|
|
|
self.theme.display_slide_transition_speed = self.alignment_page.transition_speed
|
2019-12-14 11:44:42 +00:00
|
|
|
self.theme.display_slide_transition_direction = self.alignment_page.transition_direction
|
|
|
|
self.theme.display_slide_transition_reverse = self.alignment_page.is_transition_reverse_enabled
|
2010-10-09 11:20:47 +00:00
|
|
|
|
2010-11-05 19:20:41 +00:00
|
|
|
def accept(self):
|
|
|
|
"""
|
2012-04-02 00:19:16 +00:00
|
|
|
Lets save the theme as Finish has been triggered
|
2010-11-05 19:20:41 +00:00
|
|
|
"""
|
2010-11-08 06:11:04 +00:00
|
|
|
# Save the theme name
|
2019-12-11 19:31:48 +00:00
|
|
|
self.theme.theme_name = self.theme_name_edit.text()
|
2010-11-18 17:40:20 +00:00
|
|
|
if not self.theme.theme_name:
|
2011-02-02 23:12:31 +00:00
|
|
|
critical_error_message_box(
|
2012-09-17 21:30:10 +00:00
|
|
|
translate('OpenLP.ThemeWizard', 'Theme Name Missing'),
|
2012-12-29 15:25:29 +00:00
|
|
|
translate('OpenLP.ThemeWizard', 'There is no name for this theme. Please enter one.'))
|
2010-11-05 19:20:41 +00:00
|
|
|
return
|
2013-08-31 18:17:38 +00:00
|
|
|
if self.theme.theme_name == '-1' or self.theme.theme_name == 'None':
|
2011-02-02 23:12:31 +00:00
|
|
|
critical_error_message_box(
|
2012-09-17 21:30:10 +00:00
|
|
|
translate('OpenLP.ThemeWizard', 'Theme Name Invalid'),
|
2012-12-29 15:25:29 +00:00
|
|
|
translate('OpenLP.ThemeWizard', 'Invalid theme name. Please enter one.'))
|
2010-11-21 20:45:22 +00:00
|
|
|
return
|
2017-09-26 16:39:13 +00:00
|
|
|
destination_path = None
|
2016-04-30 15:40:23 +00:00
|
|
|
if self.theme.background_type == BackgroundType.to_string(BackgroundType.Image) or \
|
2019-12-11 19:31:48 +00:00
|
|
|
self.theme.background_type == BackgroundType.to_string(BackgroundType.Video):
|
2017-09-26 16:39:13 +00:00
|
|
|
file_name = self.theme.background_filename.name
|
|
|
|
destination_path = self.path / self.theme.theme_name / file_name
|
2020-02-04 20:35:35 +00:00
|
|
|
if self.theme.background_type == BackgroundType.to_string(BackgroundType.Stream):
|
|
|
|
destination_path = self.theme.background_source
|
2013-02-01 21:48:06 +00:00
|
|
|
if not self.edit_mode and not self.theme_manager.check_if_theme_exists(self.theme.theme_name):
|
2011-01-09 19:15:40 +00:00
|
|
|
return
|
2019-10-23 22:54:29 +00:00
|
|
|
# Set the theme background to the cache location
|
|
|
|
self.theme.background_filename = destination_path
|
2020-05-25 05:01:12 +00:00
|
|
|
self.theme_manager.save_theme(self.theme)
|
|
|
|
self.theme_manager.save_preview(self.theme.theme_name, self.preview_box.save_screenshot())
|
2015-11-07 00:49:40 +00:00
|
|
|
return QtWidgets.QDialog.accept(self)
|