openlp/openlp/core/ui/generaltab.py

249 lines
14 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
2019-04-13 13:00:22 +00:00
##########################################################################
# OpenLP - Open Source Lyrics Projection #
# ---------------------------------------------------------------------- #
# Copyright (c) 2008-2019 OpenLP Developers #
# ---------------------------------------------------------------------- #
# 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 20:36:27 +00:00
"""
The general tab of the configuration dialog.
"""
2010-12-08 19:00:24 +00:00
import logging
from pathlib import Path
from PyQt5 import QtGui, QtWidgets
2017-10-07 07:05:07 +00:00
from openlp.core.common import get_images_filter
from openlp.core.common.i18n import UiStrings, translate
from openlp.core.common.settings import Settings
2017-10-10 07:08:44 +00:00
from openlp.core.display.screens import ScreenList
from openlp.core.lib.settingstab import SettingsTab
2017-10-23 22:09:57 +00:00
from openlp.core.widgets.buttons import ColorButton
from openlp.core.widgets.edits import PathEdit
2018-10-02 04:39:42 +00:00
2010-12-08 19:00:24 +00:00
log = logging.getLogger(__name__)
2013-02-01 20:36:27 +00:00
class GeneralTab(SettingsTab):
"""
GeneralTab is the general settings tab in the settings dialog.
"""
def __init__(self, parent):
2010-07-01 15:46:51 +00:00
"""
Initialise the general settings tab
"""
self.logo_background_color = '#ffffff'
self.screens = ScreenList()
2016-10-27 17:45:50 +00:00
self.icon_path = ':/icon/openlp-logo.svg'
2013-03-16 16:59:10 +00:00
general_translated = translate('OpenLP.GeneralTab', 'General')
2013-08-31 18:17:38 +00:00
super(GeneralTab, self).__init__(parent, 'Core', general_translated)
def setup_ui(self):
2010-07-01 15:46:51 +00:00
"""
Create the user interface for the general settings tab
"""
2013-08-31 18:17:38 +00:00
self.setObjectName('GeneralTab')
super(GeneralTab, self).setup_ui()
2013-03-16 20:52:59 +00:00
self.tab_layout.setStretch(1, 1)
# CCLI Details
2015-11-07 00:49:40 +00:00
self.ccli_group_box = QtWidgets.QGroupBox(self.left_column)
2013-08-31 18:17:38 +00:00
self.ccli_group_box.setObjectName('ccli_group_box')
2015-11-07 00:49:40 +00:00
self.ccli_layout = QtWidgets.QFormLayout(self.ccli_group_box)
2013-08-31 18:17:38 +00:00
self.ccli_layout.setObjectName('ccli_layout')
2015-11-07 00:49:40 +00:00
self.number_label = QtWidgets.QLabel(self.ccli_group_box)
2013-08-31 18:17:38 +00:00
self.number_label.setObjectName('number_label')
2015-11-07 00:49:40 +00:00
self.number_edit = QtWidgets.QLineEdit(self.ccli_group_box)
2013-03-16 16:59:10 +00:00
self.number_edit.setValidator(QtGui.QIntValidator())
2013-08-31 18:17:38 +00:00
self.number_edit.setObjectName('number_edit')
2013-03-16 16:59:10 +00:00
self.ccli_layout.addRow(self.number_label, self.number_edit)
2015-11-07 00:49:40 +00:00
self.username_label = QtWidgets.QLabel(self.ccli_group_box)
2013-08-31 18:17:38 +00:00
self.username_label.setObjectName('username_label')
2015-11-07 00:49:40 +00:00
self.username_edit = QtWidgets.QLineEdit(self.ccli_group_box)
2013-08-31 18:17:38 +00:00
self.username_edit.setObjectName('username_edit')
2013-03-16 16:59:10 +00:00
self.ccli_layout.addRow(self.username_label, self.username_edit)
2015-11-07 00:49:40 +00:00
self.password_label = QtWidgets.QLabel(self.ccli_group_box)
2013-08-31 18:17:38 +00:00
self.password_label.setObjectName('password_label')
2015-11-07 00:49:40 +00:00
self.password_edit = QtWidgets.QLineEdit(self.ccli_group_box)
self.password_edit.setEchoMode(QtWidgets.QLineEdit.Password)
2013-08-31 18:17:38 +00:00
self.password_edit.setObjectName('password_edit')
2013-03-16 16:59:10 +00:00
self.ccli_layout.addRow(self.password_label, self.password_edit)
self.left_layout.addWidget(self.ccli_group_box)
self.left_layout.addStretch()
# Application Startup
2015-11-07 00:49:40 +00:00
self.startup_group_box = QtWidgets.QGroupBox(self.right_column)
2013-08-31 18:17:38 +00:00
self.startup_group_box.setObjectName('startup_group_box')
2015-11-07 00:49:40 +00:00
self.startup_layout = QtWidgets.QVBoxLayout(self.startup_group_box)
2013-08-31 18:17:38 +00:00
self.startup_layout.setObjectName('startup_layout')
2015-11-07 00:49:40 +00:00
self.warning_check_box = QtWidgets.QCheckBox(self.startup_group_box)
2013-08-31 18:17:38 +00:00
self.warning_check_box.setObjectName('warning_check_box')
2013-03-16 16:59:10 +00:00
self.startup_layout.addWidget(self.warning_check_box)
2015-11-07 00:49:40 +00:00
self.auto_open_check_box = QtWidgets.QCheckBox(self.startup_group_box)
2013-08-31 18:17:38 +00:00
self.auto_open_check_box.setObjectName('auto_open_check_box')
2013-03-16 16:59:10 +00:00
self.startup_layout.addWidget(self.auto_open_check_box)
2015-11-07 00:49:40 +00:00
self.show_splash_check_box = QtWidgets.QCheckBox(self.startup_group_box)
2013-08-31 18:17:38 +00:00
self.show_splash_check_box.setObjectName('show_splash_check_box')
2013-03-16 16:59:10 +00:00
self.startup_layout.addWidget(self.show_splash_check_box)
2015-11-07 00:49:40 +00:00
self.check_for_updates_check_box = QtWidgets.QCheckBox(self.startup_group_box)
2013-08-31 18:17:38 +00:00
self.check_for_updates_check_box.setObjectName('check_for_updates_check_box')
2013-03-16 16:59:10 +00:00
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_path_edit = PathEdit(self.logo_group_box,
default_path=Path(':/graphics/openlp-splash-screen.png'))
self.logo_layout.addRow(self.logo_file_label, self.logo_file_path_edit)
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('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_logo_background_color_changed)
# Application Settings
2015-11-07 00:49:40 +00:00
self.settings_group_box = QtWidgets.QGroupBox(self.right_column)
2013-08-31 18:17:38 +00:00
self.settings_group_box.setObjectName('settings_group_box')
2015-11-07 00:49:40 +00:00
self.settings_layout = QtWidgets.QFormLayout(self.settings_group_box)
2013-08-31 18:17:38 +00:00
self.settings_layout.setObjectName('settings_layout')
2015-11-07 00:49:40 +00:00
self.save_check_service_check_box = QtWidgets.QCheckBox(self.settings_group_box)
2013-08-31 18:17:38 +00:00
self.save_check_service_check_box.setObjectName('save_check_service_check_box')
2013-03-16 16:59:10 +00:00
self.settings_layout.addRow(self.save_check_service_check_box)
2015-11-07 00:49:40 +00:00
self.auto_unblank_check_box = QtWidgets.QCheckBox(self.settings_group_box)
2013-08-31 18:17:38 +00:00
self.auto_unblank_check_box.setObjectName('auto_unblank_check_box')
2013-03-16 16:59:10 +00:00
self.settings_layout.addRow(self.auto_unblank_check_box)
self.click_live_slide_to_unblank_check_box = QtWidgets.QCheckBox(self.settings_group_box)
self.click_live_slide_to_unblank_check_box.setObjectName('click_live_slide_to_unblank')
self.settings_layout.addRow(self.click_live_slide_to_unblank_check_box)
2015-11-07 00:49:40 +00:00
self.auto_preview_check_box = QtWidgets.QCheckBox(self.settings_group_box)
2013-08-31 18:17:38 +00:00
self.auto_preview_check_box.setObjectName('auto_preview_check_box')
2013-03-16 16:59:10 +00:00
self.settings_layout.addRow(self.auto_preview_check_box)
# Moved here from image tab
2015-11-07 00:49:40 +00:00
self.timeout_label = QtWidgets.QLabel(self.settings_group_box)
2013-08-31 18:17:38 +00:00
self.timeout_label.setObjectName('timeout_label')
2015-11-07 00:49:40 +00:00
self.timeout_spin_box = QtWidgets.QSpinBox(self.settings_group_box)
2013-08-31 18:17:38 +00:00
self.timeout_spin_box.setObjectName('timeout_spin_box')
2013-03-16 16:59:10 +00:00
self.timeout_spin_box.setRange(1, 180)
self.settings_layout.addRow(self.timeout_label, self.timeout_spin_box)
self.right_layout.addWidget(self.settings_group_box)
self.right_layout.addStretch()
2011-03-15 20:53:36 +00:00
# Remove for now
2013-03-16 16:59:10 +00:00
self.username_label.setVisible(False)
self.username_edit.setVisible(False)
self.password_label.setVisible(False)
self.password_edit.setVisible(False)
2011-03-15 20:53:36 +00:00
def retranslate_ui(self):
2010-07-01 15:46:51 +00:00
"""
Translate the general settings tab to the currently selected language
"""
2013-03-16 16:59:10 +00:00
self.tab_title_visible = translate('OpenLP.GeneralTab', 'General')
self.startup_group_box.setTitle(translate('OpenLP.GeneralTab', 'Application Startup'))
self.warning_check_box.setText(translate('OpenLP.GeneralTab', 'Show blank screen warning'))
2016-05-10 01:11:49 +00:00
self.auto_open_check_box.setText(translate('OpenLP.GeneralTab', 'Automatically open the previous service file'))
2013-03-16 16:59:10 +00:00
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(UiStrings().BackgroundColorColon)
self.logo_file_label.setText(translate('OpenLP.GeneralTab', 'Logo file:'))
self.logo_hide_on_startup_check_box.setText(translate('OpenLP.GeneralTab', 'Don\'t show logo on startup'))
2013-03-16 16:59:10 +00:00
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',
2013-12-24 15:55:01 +00:00
'Prompt to save before starting a new service'))
self.click_live_slide_to_unblank_check_box.setText(translate('OpenLP.GeneralTab',
'Unblank display when changing slide in Live'))
self.auto_unblank_check_box.setText(translate('OpenLP.GeneralTab', 'Unblank display when sending '
'items to Live'))
2014-03-20 19:10:31 +00:00
self.auto_preview_check_box.setText(translate('OpenLP.GeneralTab',
'Automatically preview the next item in service'))
2013-03-16 16:59:10 +00:00
self.timeout_label.setText(translate('OpenLP.GeneralTab', 'Timed slide interval:'))
self.timeout_spin_box.setSuffix(translate('OpenLP.GeneralTab', ' sec'))
self.ccli_group_box.setTitle(translate('OpenLP.GeneralTab', 'CCLI Details'))
2013-03-16 20:52:59 +00:00
self.number_label.setText(UiStrings().CCLINumberLabel)
2013-03-16 16:59:10 +00:00
self.username_label.setText(translate('OpenLP.GeneralTab', 'SongSelect username:'))
self.password_label.setText(translate('OpenLP.GeneralTab', 'SongSelect password:'))
2019-05-03 17:25:27 +00:00
self.logo_file_path_edit.dialog_caption = translate('OpenLP.AdvancedTab', 'Select Logo File')
self.logo_file_path_edit.dialog_caption = translate('OpenLP.AdvancedTab', 'Select Logo File')
2017-05-22 19:56:54 +00:00
self.logo_file_path_edit.filters = '{text};;{names} (*)'.format(
text=get_images_filter(), names=UiStrings().AllFiles)
def load(self):
2010-07-01 15:46:51 +00:00
"""
Load the settings to populate the form
"""
2012-05-17 15:13:09 +00:00
settings = Settings()
2013-03-16 20:52:59 +00:00
settings.beginGroup(self.settings_section)
2013-08-31 18:17:38 +00:00
self.number_edit.setText(settings.value('ccli number'))
self.username_edit.setText(settings.value('songselect username'))
self.password_edit.setText(settings.value('songselect password'))
self.save_check_service_check_box.setChecked(settings.value('save prompt'))
self.auto_unblank_check_box.setChecked(settings.value('auto unblank'))
self.click_live_slide_to_unblank_check_box.setChecked(settings.value('click live slide to unblank'))
2013-08-31 18:17:38 +00:00
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_path_edit.path = 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
2013-08-31 18:17:38 +00:00
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'))
2010-07-01 15:46:51 +00:00
settings.endGroup()
def save(self):
2010-07-01 15:46:51 +00:00
"""
Save the settings from the form
"""
2012-05-17 15:13:09 +00:00
settings = Settings()
2013-03-16 20:52:59 +00:00
settings.beginGroup(self.settings_section)
2013-08-31 18:17:38 +00:00
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_path_edit.path)
settings.setValue('logo hide on startup', self.logo_hide_on_startup_check_box.isChecked())
2013-08-31 18:17:38 +00:00
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())
settings.setValue('click live slide to unblank', self.click_live_slide_to_unblank_check_box.isChecked())
2013-08-31 18:17:38 +00:00
settings.setValue('auto preview', self.auto_preview_check_box.isChecked())
settings.setValue('loop delay', self.timeout_spin_box.value())
settings.setValue('ccli number', self.number_edit.displayText())
settings.setValue('songselect username', self.username_edit.displayText())
settings.setValue('songselect password', self.password_edit.displayText())
settings.endGroup()
self.post_set_up()
def post_set_up(self):
2010-07-24 19:27:25 +00:00
"""
Apply settings after the tab has loaded
2010-07-24 19:27:25 +00:00
"""
2013-08-31 18:17:38 +00:00
self.settings_form.register_post_process('slidecontroller_live_spin_delay')
def on_logo_background_color_changed(self, color):
"""
Select the background color for logo.
"""
self.logo_background_color = color