From 79724872fd8470d31e992521ecbf88e931bc5130 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Fri, 1 Apr 2016 03:54:33 +0300 Subject: [PATCH] In this branch: - Renamed "Default image" and related settings to "Logo" etc. - Moved these settings to General tab from Advanced tab - Re-wired these settings to code functions To do: - Remove these from advanced tab. - Verify tests still work --- openlp/core/common/settings.py | 9 ++- openlp/core/ui/advancedtab.py | 110 ++++++++++++++++----------------- openlp/core/ui/generaltab.py | 76 ++++++++++++++++++++++- openlp/core/ui/maindisplay.py | 6 +- 4 files changed, 139 insertions(+), 62 deletions(-) diff --git a/openlp/core/common/settings.py b/openlp/core/common/settings.py index 1ffda0abd..a241650ea 100644 --- a/openlp/core/common/settings.py +++ b/openlp/core/common/settings.py @@ -109,8 +109,8 @@ class Settings(QtCore.QSettings): 'advanced/alternate rows': not is_win(), 'advanced/current media plugin': -1, 'advanced/data path': '', - 'advanced/default color': '#ffffff', - 'advanced/default image': ':/graphics/openlp-splash-screen.png', + 'advanced/logo background color': '#ffffff', + 'advanced/logo file': ':/graphics/openlp-splash-screen.png', # 7 stands for now, 0 to 6 is Monday to Sunday. 'advanced/default service day': 7, 'advanced/default service enabled': True, @@ -121,7 +121,7 @@ class Settings(QtCore.QSettings): 'advanced/double click live': False, 'advanced/enable exit confirmation': True, 'advanced/expand service item': False, - 'advanced/default show nothing': False, + 'advanced/logo hide on startup': False, 'advanced/hide mouse': True, 'advanced/is portable': False, 'advanced/max recent files': 20, @@ -152,6 +152,9 @@ class Settings(QtCore.QSettings): 'core/save prompt': False, 'core/screen blank': False, 'core/show splash': True, + 'core/logo background color': '#ffffff', + 'core/logo file': ':/graphics/openlp-splash-screen.png', + 'core/logo hide on startup': False, 'core/songselect password': '', 'core/songselect username': '', 'core/update check': True, diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 163c9ccd0..fc65c9dff 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -45,8 +45,8 @@ class AdvancedTab(SettingsTab): """ Initialise the settings tab """ - self.default_image = ':/graphics/openlp-splash-screen.png' - self.default_color = '#ffffff' + self.logo_file = ':/graphics/openlp-splash-screen.png' + self.logo_background_color = '#ffffff' self.data_exists = False self.icon_path = ':/system/system_settings.png' advanced_translated = translate('OpenLP.AdvancedTab', 'Advanced') @@ -173,36 +173,36 @@ class AdvancedTab(SettingsTab): self.data_directory_layout.addRow(self.new_data_directory_has_files_label) self.left_layout.addWidget(self.data_directory_group_box) self.left_layout.addStretch() - # Default Image - self.default_image_group_box = QtWidgets.QGroupBox(self.right_column) - self.default_image_group_box.setObjectName('default_image_group_box') - self.default_image_layout = QtWidgets.QFormLayout(self.default_image_group_box) - self.default_image_layout.setObjectName('default_image_layout') - self.default_color_label = QtWidgets.QLabel(self.default_image_group_box) - self.default_color_label.setObjectName('default_color_label') - self.default_color_button = ColorButton(self.default_image_group_box) - self.default_color_button.setObjectName('default_color_button') - self.default_image_layout.addRow(self.default_color_label, self.default_color_button) - self.default_file_label = QtWidgets.QLabel(self.default_image_group_box) - self.default_file_label.setObjectName('default_file_label') - self.default_file_edit = QtWidgets.QLineEdit(self.default_image_group_box) - self.default_file_edit.setObjectName('default_file_edit') - self.default_browse_button = QtWidgets.QToolButton(self.default_image_group_box) - self.default_browse_button.setObjectName('default_browse_button') - self.default_browse_button.setIcon(build_icon(':/general/general_open.png')) - self.default_revert_button = QtWidgets.QToolButton(self.default_image_group_box) - self.default_revert_button.setObjectName('default_revert_button') - self.default_revert_button.setIcon(build_icon(':/general/general_revert.png')) - self.default_file_layout = QtWidgets.QHBoxLayout() - self.default_file_layout.setObjectName('default_file_layout') - self.default_file_layout.addWidget(self.default_file_edit) - self.default_file_layout.addWidget(self.default_browse_button) - self.default_file_layout.addWidget(self.default_revert_button) - self.default_image_layout.addRow(self.default_file_label, self.default_file_layout) - self.default_show_nothing_check_box = QtWidgets.QCheckBox(self.ui_group_box) - self.default_show_nothing_check_box.setObjectName('default_default_show_nothing_check_box') - self.default_image_layout.addRow(self.default_show_nothing_check_box) - self.right_layout.addWidget(self.default_image_group_box) + # Logo + self.logo_group_box = QtWidgets.QGroupBox(self.right_column) + self.logo_group_box.setObjectName('logo_group_box') + self.logo_layout = QtWidgets.QFormLayout(self.logo_group_box) + self.logo_layout.setObjectName('logo_layout') + self.logo_file_label = QtWidgets.QLabel(self.logo_group_box) + self.logo_file_label.setObjectName('logo_file_label') + self.logo_file_edit = QtWidgets.QLineEdit(self.logo_group_box) + self.logo_file_edit.setObjectName('logo_file_edit') + self.logo_browse_button = QtWidgets.QToolButton(self.logo_group_box) + self.logo_browse_button.setObjectName('logo_browse_button') + self.logo_browse_button.setIcon(build_icon(':/general/general_open.png')) + self.logo_revert_button = QtWidgets.QToolButton(self.logo_group_box) + self.logo_revert_button.setObjectName('logo_revert_button') + self.logo_revert_button.setIcon(build_icon(':/general/general_revert.png')) + self.logo_file_layout = QtWidgets.QHBoxLayout() + self.logo_file_layout.setObjectName('logo_file_layout') + self.logo_file_layout.addWidget(self.logo_file_edit) + self.logo_file_layout.addWidget(self.logo_browse_button) + self.logo_file_layout.addWidget(self.logo_revert_button) + self.logo_layout.addRow(self.logo_file_label, self.logo_file_layout) + self.logo_color_label = QtWidgets.QLabel(self.logo_group_box) + self.logo_color_label.setObjectName('logo_color_label') + self.logo_color_button = ColorButton(self.logo_group_box) + self.logo_color_button.setObjectName('logo_color_button') + self.logo_layout.addRow(self.logo_color_label, self.logo_color_button) + self.logo_hide_on_startup_check_box = QtWidgets.QCheckBox(self.ui_group_box) + self.logo_hide_on_startup_check_box.setObjectName('default_logo_hide_on_startup_check_box') + self.logo_layout.addRow(self.logo_hide_on_startup_check_box) + self.right_layout.addWidget(self.logo_group_box) # Hide mouse self.hide_mouse_group_box = QtWidgets.QGroupBox(self.right_column) self.hide_mouse_group_box.setObjectName('hide_mouse_group_box') @@ -249,9 +249,9 @@ class AdvancedTab(SettingsTab): self.service_name_time.timeChanged.connect(self.update_service_name_example) self.service_name_edit.textChanged.connect(self.update_service_name_example) self.service_name_revert_button.clicked.connect(self.on_service_name_revert_button_clicked) - self.default_color_button.colorChanged.connect(self.on_background_color_changed) - self.default_browse_button.clicked.connect(self.on_default_browse_button_clicked) - self.default_revert_button.clicked.connect(self.on_default_revert_button_clicked) + self.logo_color_button.colorChanged.connect(self.on_background_color_changed) + self.logo_browse_button.clicked.connect(self.on_logo_browse_button_clicked) + self.logo_revert_button.clicked.connect(self.on_logo_revert_button_clicked) self.alternate_rows_check_box.toggled.connect(self.on_alternate_rows_check_box_toggled) self.data_directory_browse_button.clicked.connect(self.on_data_directory_browse_button_clicked) self.data_directory_default_button.clicked.connect(self.on_data_directory_default_button_clicked) @@ -302,12 +302,12 @@ class AdvancedTab(SettingsTab): self.service_name_example_label.setText(translate('OpenLP.AdvancedTab', 'Example:')) self.hide_mouse_group_box.setTitle(translate('OpenLP.AdvancedTab', 'Mouse Cursor')) self.hide_mouse_check_box.setText(translate('OpenLP.AdvancedTab', 'Hide mouse cursor when over display window')) - self.default_image_group_box.setTitle(translate('OpenLP.AdvancedTab', 'Default Image')) - self.default_color_label.setText(translate('OpenLP.AdvancedTab', 'Background color:')) - self.default_file_label.setText(translate('OpenLP.AdvancedTab', 'Image file:')) - self.default_browse_button.setToolTip(translate('OpenLP.AdvancedTab', 'Browse for an image file to display.')) - self.default_revert_button.setToolTip(translate('OpenLP.AdvancedTab', 'Revert to the default OpenLP logo.')) - self.default_show_nothing_check_box.setText(translate('OpenLP.AdvancedTab', 'Don\'t show image or background')) + self.logo_group_box.setTitle(translate('OpenLP.AdvancedTab', 'Logo')) + self.logo_color_label.setText(translate('OpenLP.AdvancedTab', 'Background color:')) + self.logo_file_label.setText(translate('OpenLP.AdvancedTab', 'Logo file:')) + self.logo_browse_button.setToolTip(translate('OpenLP.AdvancedTab', 'Browse for an image file to display.')) + self.logo_revert_button.setToolTip(translate('OpenLP.AdvancedTab', 'Revert to the default OpenLP logo.')) + self.logo_hide_on_startup_check_box.setText(translate('OpenLP.AdvancedTab', 'Don\'t show logo on startup')) self.data_directory_current_label.setText(translate('OpenLP.AdvancedTab', 'Current path:')) self.data_directory_new_label.setText(translate('OpenLP.AdvancedTab', 'Custom path:')) self.data_directory_browse_button.setToolTip(translate('OpenLP.AdvancedTab', @@ -361,9 +361,9 @@ class AdvancedTab(SettingsTab): self.service_name_check_box.setChecked(default_service_enabled) self.service_name_check_box_toggled(default_service_enabled) self.x11_bypass_check_box.setChecked(settings.value('x11 bypass wm')) - self.default_color = settings.value('default color') - self.default_file_edit.setText(settings.value('default image')) - self.default_show_nothing_check_box.setChecked(settings.value('default show nothing')) + self.logo_background_color = settings.value('logo background color') + self.logo_file_edit.setText(settings.value('logo file')) + self.logo_hide_on_startup_check_box.setChecked(settings.value('logo hide on startup')) self.slide_limits = settings.value('slide limits') self.is_search_as_you_type_enabled = settings.value('search as type') self.search_as_type_check_box.setChecked(self.is_search_as_you_type_enabled) @@ -405,7 +405,7 @@ class AdvancedTab(SettingsTab): self.current_data_path = AppLocation.get_data_path() log.warning('User requested data path set to default %s' % self.current_data_path) self.data_directory_label.setText(os.path.abspath(self.current_data_path)) - self.default_color_button.color = self.default_color + self.logo_color_button.color = self.logo_background_color # Don't allow data directory move if running portable. if settings.value('advanced/is portable'): self.data_directory_group_box.hide() @@ -436,9 +436,9 @@ class AdvancedTab(SettingsTab): settings.setValue('enable exit confirmation', self.enable_auto_close_check_box.isChecked()) settings.setValue('hide mouse', self.hide_mouse_check_box.isChecked()) settings.setValue('alternate rows', self.alternate_rows_check_box.isChecked()) - settings.setValue('default color', self.default_color) - settings.setValue('default image', self.default_file_edit.text()) - settings.setValue('default show nothing', self.default_show_nothing_check_box.isChecked()) + settings.setValue('logo background color', self.logo_background_color) + settings.setValue('logo file', self.logo_file_edit.text()) + settings.setValue('logo hide on startup', self.logo_hide_on_startup_check_box.isChecked()) settings.setValue('slide limits', self.slide_limits) if self.x11_bypass_check_box.isChecked() != settings.value('x11 bypass wm'): settings.setValue('x11 bypass wm', self.x11_bypass_check_box.isChecked()) @@ -520,9 +520,9 @@ class AdvancedTab(SettingsTab): """ Select the background colour of the default display screen. """ - self.default_color = color + self.logo_background_color = color - def on_default_browse_button_clicked(self): + def on_logo_browse_button_clicked(self): """ Select an image for the default display screen. """ @@ -531,8 +531,8 @@ class AdvancedTab(SettingsTab): translate('OpenLP.AdvancedTab', 'Open File'), '', file_filters) if filename: - self.default_file_edit.setText(filename) - self.default_file_edit.setFocus() + self.logo_file_edit.setText(filename) + self.logo_file_edit.setFocus() def on_data_directory_browse_button_clicked(self): """ @@ -651,12 +651,12 @@ class AdvancedTab(SettingsTab): self.data_directory_cancel_button.hide() self.new_data_directory_has_files_label.hide() - def on_default_revert_button_clicked(self): + def on_logo_revert_button_clicked(self): """ Revert the default screen back to the default settings. """ - self.default_file_edit.setText(':/graphics/openlp-splash-screen.png') - self.default_file_edit.setFocus() + self.logo_file_edit.setText(':/graphics/openlp-splash-screen.png') + self.logo_file_edit.setFocus() def on_alternate_rows_check_box_toggled(self, checked): """ diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 8ed8b3edf..4c9c24dca 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -27,7 +27,8 @@ import logging from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import Registry, Settings, UiStrings, translate -from openlp.core.lib import SettingsTab, ScreenList +from openlp.core.lib import SettingsTab, ScreenList, ColorButton, build_icon +from openlp.core.utils import get_images_filter log = logging.getLogger(__name__) @@ -40,6 +41,8 @@ class GeneralTab(SettingsTab): """ Initialise the general settings tab """ + self.logo_file = ':/graphics/openlp-splash-screen.png' + self.logo_background_color = '#ffffff' self.screens = ScreenList() self.icon_path = ':/icon/openlp-logo-16x16.png' general_translated = translate('OpenLP.GeneralTab', 'General') @@ -162,6 +165,39 @@ class GeneralTab(SettingsTab): self.check_for_updates_check_box.setVisible(False) self.startup_layout.addWidget(self.check_for_updates_check_box) self.right_layout.addWidget(self.startup_group_box) + # Logo + self.logo_group_box = QtWidgets.QGroupBox(self.right_column) + self.logo_group_box.setObjectName('logo_group_box') + self.logo_layout = QtWidgets.QFormLayout(self.logo_group_box) + self.logo_layout.setObjectName('logo_layout') + self.logo_file_label = QtWidgets.QLabel(self.logo_group_box) + self.logo_file_label.setObjectName('logo_file_label') + self.logo_file_edit = QtWidgets.QLineEdit(self.logo_group_box) + self.logo_file_edit.setObjectName('logo_file_edit') + self.logo_browse_button = QtWidgets.QToolButton(self.logo_group_box) + self.logo_browse_button.setObjectName('logo_browse_button') + self.logo_browse_button.setIcon(build_icon(':/general/general_open.png')) + self.logo_revert_button = QtWidgets.QToolButton(self.logo_group_box) + self.logo_revert_button.setObjectName('logo_revert_button') + self.logo_revert_button.setIcon(build_icon(':/general/general_revert.png')) + self.logo_file_layout = QtWidgets.QHBoxLayout() + self.logo_file_layout.setObjectName('logo_file_layout') + self.logo_file_layout.addWidget(self.logo_file_edit) + self.logo_file_layout.addWidget(self.logo_browse_button) + self.logo_file_layout.addWidget(self.logo_revert_button) + self.logo_layout.addRow(self.logo_file_label, self.logo_file_layout) + self.logo_color_label = QtWidgets.QLabel(self.logo_group_box) + self.logo_color_label.setObjectName('logo_color_label') + self.logo_color_button = ColorButton(self.logo_group_box) + self.logo_color_button.setObjectName('logo_color_button') + self.logo_layout.addRow(self.logo_color_label, self.logo_color_button) + self.logo_hide_on_startup_check_box = QtWidgets.QCheckBox(self.logo_group_box) + self.logo_hide_on_startup_check_box.setObjectName('default_logo_hide_on_startup_check_box') + self.logo_layout.addRow(self.logo_hide_on_startup_check_box) + self.right_layout.addWidget(self.logo_group_box) + self.logo_color_button.colorChanged.connect(self.on_background_color_changed) + self.logo_browse_button.clicked.connect(self.on_logo_browse_button_clicked) + self.logo_revert_button.clicked.connect(self.on_logo_revert_button_clicked) # Application Settings self.settings_group_box = QtWidgets.QGroupBox(self.right_column) self.settings_group_box.setObjectName('settings_group_box') @@ -212,6 +248,12 @@ class GeneralTab(SettingsTab): self.warning_check_box.setText(translate('OpenLP.GeneralTab', 'Show blank screen warning')) self.auto_open_check_box.setText(translate('OpenLP.GeneralTab', 'Automatically open the last service')) self.show_splash_check_box.setText(translate('OpenLP.GeneralTab', 'Show the splash screen')) + self.logo_group_box.setTitle(translate('OpenLP.GeneralTab', 'Logo')) + self.logo_color_label.setText(translate('OpenLP.GeneralTab', 'Background color:')) + self.logo_file_label.setText(translate('OpenLP.GeneralTab', 'Logo file:')) + self.logo_browse_button.setToolTip(translate('OpenLP.GeneralTab', 'Browse for an image file to display.')) + self.logo_revert_button.setToolTip(translate('OpenLP.GeneralTab', 'Revert to the default OpenLP logo.')) + self.logo_hide_on_startup_check_box.setText(translate('OpenLP.GeneralTab', 'Don\'t show logo on startup')) self.check_for_updates_check_box.setText(translate('OpenLP.GeneralTab', 'Check for updates to OpenLP')) self.settings_group_box.setTitle(translate('OpenLP.GeneralTab', 'Application Settings')) self.save_check_service_check_box.setText(translate('OpenLP.GeneralTab', @@ -254,6 +296,10 @@ class GeneralTab(SettingsTab): self.warning_check_box.setChecked(settings.value('blank warning')) self.auto_open_check_box.setChecked(settings.value('auto open')) self.show_splash_check_box.setChecked(settings.value('show splash')) + self.logo_background_color = settings.value('logo background color') + self.logo_file_edit.setText(settings.value('logo file')) + self.logo_hide_on_startup_check_box.setChecked(settings.value('logo hide on startup')) + self.logo_color_button.color = self.logo_background_color self.check_for_updates_check_box.setChecked(settings.value('update check')) self.auto_preview_check_box.setChecked(settings.value('auto preview')) self.timeout_spin_box.setValue(settings.value('loop delay')) @@ -284,6 +330,9 @@ class GeneralTab(SettingsTab): settings.setValue('blank warning', self.warning_check_box.isChecked()) settings.setValue('auto open', self.auto_open_check_box.isChecked()) settings.setValue('show splash', self.show_splash_check_box.isChecked()) + settings.setValue('logo background color', self.logo_background_color) + settings.setValue('logo file', self.logo_file_edit.text()) + settings.setValue('logo hide on startup', self.logo_hide_on_startup_check_box.isChecked()) settings.setValue('update check', self.check_for_updates_check_box.isChecked()) settings.setValue('save prompt', self.save_check_service_check_box.isChecked()) settings.setValue('auto unblank', self.auto_unblank_check_box.isChecked()) @@ -346,3 +395,28 @@ class GeneralTab(SettingsTab): Called when the width, height, x position or y position has changed. """ self.display_changed = True + + def on_logo_browse_button_clicked(self): + """ + Select an image for the default display screen. + """ + file_filters = '%s;;%s (*.*)' % (get_images_filter(), UiStrings().AllFiles) + filename, filter_used = QtWidgets.QFileDialog.getOpenFileName(self, + translate('OpenLP.AdvancedTab', 'Open File'), '', + file_filters) + if filename: + self.logo_file_edit.setText(filename) + self.logo_file_edit.setFocus() + + def on_logo_revert_button_clicked(self): + """ + Revert the default screen back to the default settings. + """ + self.logo_file_edit.setText(':/graphics/openlp-splash-screen.png') + self.logo_file_edit.setFocus() + + def on_background_color_changed(self, color): + """ + Select the background colour of the default display screen. + """ + self.logo_background_color = color \ No newline at end of file diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 0e5215d89..2fce7c96a 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -254,10 +254,10 @@ class MainDisplay(OpenLPMixin, Display, RegistryProperties): if self.is_live: # Build the initial frame. background_color = QtGui.QColor() - background_color.setNamedColor(Settings().value('advanced/default color')) + background_color.setNamedColor(Settings().value('core/logo background color')) if not background_color.isValid(): background_color = QtCore.Qt.white - image_file = Settings().value('advanced/default image') + image_file = Settings().value('core/logo file') splash_image = QtGui.QImage(image_file) self.initial_fame = QtGui.QImage( self.screen['size'].width(), @@ -525,7 +525,7 @@ class MainDisplay(OpenLPMixin, Display, RegistryProperties): self.frame.evaluateJavaScript('show_blank("show");') # Check if setting for hiding default background image and color is enabled. # If so, display should remain hidden, otherwise default logo is shown. (from def setup) - if self.isHidden() and not Settings().value('advanced/default show nothing'): + if self.isHidden() and not Settings().value('core/logo hide on startup'): self.setVisible(True) self.hide_mode = None # Trigger actions when display is active again.