27
from PyQt5 import QtCore, QtGui, QtWidgets
27
from PyQt5 import QtGui, QtWidgets
29
29
from openlp.core.common import get_images_filter
30
30
from openlp.core.common.i18n import UiStrings, translate
31
31
from openlp.core.common.path import Path
32
from openlp.core.common.registry import Registry
33
32
from openlp.core.common.settings import Settings
34
33
from openlp.core.display.screens import ScreenList
35
from openlp.core.lib import SettingsTab
34
from openlp.core.lib.settingstab import SettingsTab
36
35
from openlp.core.widgets.buttons import ColorButton
37
36
from openlp.core.widgets.edits import PathEdit
39
39
log = logging.getLogger(__name__)
48
48
Initialise the general settings tab
50
self.logo_file = ':/graphics/openlp-splash-screen.png'
51
50
self.logo_background_color = '#ffffff'
52
51
self.screens = ScreenList()
53
52
self.icon_path = ':/icon/openlp-logo.svg'
54
53
general_translated = translate('OpenLP.GeneralTab', 'General')
55
54
super(GeneralTab, self).__init__(parent, 'Core', general_translated)
59
58
Create the user interface for the general settings tab
61
60
self.setObjectName('GeneralTab')
62
super(GeneralTab, self).setupUi()
61
super(GeneralTab, self).setup_ui()
63
62
self.tab_layout.setStretch(1, 1)
65
self.monitor_group_box = QtWidgets.QGroupBox(self.left_column)
66
self.monitor_group_box.setObjectName('monitor_group_box')
67
self.monitor_layout = QtWidgets.QGridLayout(self.monitor_group_box)
68
self.monitor_layout.setObjectName('monitor_layout')
69
self.monitor_radio_button = QtWidgets.QRadioButton(self.monitor_group_box)
70
self.monitor_radio_button.setObjectName('monitor_radio_button')
71
self.monitor_layout.addWidget(self.monitor_radio_button, 0, 0, 1, 5)
72
self.monitor_combo_box = QtWidgets.QComboBox(self.monitor_group_box)
73
self.monitor_combo_box.setObjectName('monitor_combo_box')
74
self.monitor_layout.addWidget(self.monitor_combo_box, 1, 1, 1, 4)
76
self.override_radio_button = QtWidgets.QRadioButton(self.monitor_group_box)
77
self.override_radio_button.setObjectName('override_radio_button')
78
self.monitor_layout.addWidget(self.override_radio_button, 2, 0, 1, 5)
80
self.custom_x_label = QtWidgets.QLabel(self.monitor_group_box)
81
self.custom_x_label.setObjectName('custom_x_label')
82
self.monitor_layout.addWidget(self.custom_x_label, 3, 1)
83
self.custom_X_value_edit = QtWidgets.QSpinBox(self.monitor_group_box)
84
self.custom_X_value_edit.setObjectName('custom_X_value_edit')
85
self.custom_X_value_edit.setRange(-9999, 9999)
86
self.monitor_layout.addWidget(self.custom_X_value_edit, 4, 1)
87
self.custom_y_label = QtWidgets.QLabel(self.monitor_group_box)
88
self.custom_y_label.setObjectName('custom_y_label')
89
self.monitor_layout.addWidget(self.custom_y_label, 3, 2)
90
self.custom_Y_value_edit = QtWidgets.QSpinBox(self.monitor_group_box)
91
self.custom_Y_value_edit.setObjectName('custom_Y_value_edit')
92
self.custom_Y_value_edit.setRange(-9999, 9999)
93
self.monitor_layout.addWidget(self.custom_Y_value_edit, 4, 2)
94
self.custom_width_label = QtWidgets.QLabel(self.monitor_group_box)
95
self.custom_width_label.setObjectName('custom_width_label')
96
self.monitor_layout.addWidget(self.custom_width_label, 3, 3)
97
self.custom_width_value_edit = QtWidgets.QSpinBox(self.monitor_group_box)
98
self.custom_width_value_edit.setObjectName('custom_width_value_edit')
99
self.custom_width_value_edit.setRange(1, 9999)
100
self.monitor_layout.addWidget(self.custom_width_value_edit, 4, 3)
101
self.custom_height_label = QtWidgets.QLabel(self.monitor_group_box)
102
self.custom_height_label.setObjectName('custom_height_label')
103
self.monitor_layout.addWidget(self.custom_height_label, 3, 4)
104
self.custom_height_value_edit = QtWidgets.QSpinBox(self.monitor_group_box)
105
self.custom_height_value_edit.setObjectName('custom_height_value_edit')
106
self.custom_height_value_edit.setRange(1, 9999)
107
self.monitor_layout.addWidget(self.custom_height_value_edit, 4, 4)
108
self.display_on_monitor_check = QtWidgets.QCheckBox(self.monitor_group_box)
109
self.display_on_monitor_check.setObjectName('monitor_combo_box')
110
self.monitor_layout.addWidget(self.display_on_monitor_check, 5, 0, 1, 5)
111
# Set up the stretchiness of each column, so that the first column
112
# less stretchy (and therefore smaller) than the others
113
self.monitor_layout.setColumnStretch(0, 1)
114
self.monitor_layout.setColumnStretch(1, 3)
115
self.monitor_layout.setColumnStretch(2, 3)
116
self.monitor_layout.setColumnStretch(3, 3)
117
self.monitor_layout.setColumnStretch(4, 3)
118
self.left_layout.addWidget(self.monitor_group_box)
120
64
self.ccli_group_box = QtWidgets.QGroupBox(self.left_column)
121
65
self.ccli_group_box.setObjectName('ccli_group_box')
216
160
self.settings_layout.addRow(self.timeout_label, self.timeout_spin_box)
217
161
self.right_layout.addWidget(self.settings_group_box)
218
162
self.right_layout.addStretch()
220
self.override_radio_button.toggled.connect(self.on_override_radio_button_pressed)
221
self.custom_height_value_edit.valueChanged.connect(self.on_display_changed)
222
self.custom_width_value_edit.valueChanged.connect(self.on_display_changed)
223
self.custom_Y_value_edit.valueChanged.connect(self.on_display_changed)
224
self.custom_X_value_edit.valueChanged.connect(self.on_display_changed)
225
self.monitor_combo_box.currentIndexChanged.connect(self.on_display_changed)
226
# Reload the tab, as the screen resolution/count may have changed.
227
Registry().register_function('config_screen_changed', self.load)
229
164
self.username_label.setVisible(False)
230
165
self.username_edit.setVisible(False)
231
166
self.password_label.setVisible(False)
232
167
self.password_edit.setVisible(False)
234
def retranslateUi(self):
169
def retranslate_ui(self):
236
171
Translate the general settings tab to the currently selected language
238
173
self.tab_title_visible = translate('OpenLP.GeneralTab', 'General')
239
self.monitor_group_box.setTitle(translate('OpenLP.GeneralTab', 'Monitors'))
240
self.monitor_radio_button.setText(translate('OpenLP.GeneralTab', 'Select monitor for output display:'))
241
self.display_on_monitor_check.setText(translate('OpenLP.GeneralTab', 'Display if a single screen'))
242
174
self.startup_group_box.setTitle(translate('OpenLP.GeneralTab', 'Application Startup'))
243
175
self.warning_check_box.setText(translate('OpenLP.GeneralTab', 'Show blank screen warning'))
244
176
self.auto_open_check_box.setText(translate('OpenLP.GeneralTab', 'Automatically open the previous service file'))
263
195
self.number_label.setText(UiStrings().CCLINumberLabel)
264
196
self.username_label.setText(translate('OpenLP.GeneralTab', 'SongSelect username:'))
265
197
self.password_label.setText(translate('OpenLP.GeneralTab', 'SongSelect password:'))
266
# Moved from display tab
267
self.override_radio_button.setText(translate('OpenLP.GeneralTab', 'Override display position:'))
268
self.custom_x_label.setText(translate('OpenLP.GeneralTab', 'X'))
269
self.custom_y_label.setText(translate('OpenLP.GeneralTab', 'Y'))
270
self.custom_height_label.setText(translate('OpenLP.GeneralTab', 'Height'))
271
self.custom_width_label.setText(translate('OpenLP.GeneralTab', 'Width'))
272
198
self.audio_group_box.setTitle(translate('OpenLP.GeneralTab', 'Background Audio'))
273
199
self.start_paused_check_box.setText(translate('OpenLP.GeneralTab', 'Start background audio paused'))
274
200
self.repeat_list_check_box.setText(translate('OpenLP.GeneralTab', 'Repeat track list'))
283
209
settings = Settings()
284
210
settings.beginGroup(self.settings_section)
285
self.monitor_combo_box.clear()
286
self.monitor_combo_box.addItems(self.screens.get_screen_list())
287
monitor_number = settings.value('monitor')
288
self.monitor_combo_box.setCurrentIndex(monitor_number)
289
211
self.number_edit.setText(settings.value('ccli number'))
290
212
self.username_edit.setText(settings.value('songselect username'))
291
213
self.password_edit.setText(settings.value('songselect password'))
292
214
self.save_check_service_check_box.setChecked(settings.value('save prompt'))
293
215
self.auto_unblank_check_box.setChecked(settings.value('auto unblank'))
294
216
self.click_live_slide_to_unblank_check_box.setChecked(settings.value('click live slide to unblank'))
295
self.display_on_monitor_check.setChecked(self.screens.display)
296
217
self.warning_check_box.setChecked(settings.value('blank warning'))
297
218
self.auto_open_check_box.setChecked(settings.value('auto open'))
298
219
self.show_splash_check_box.setChecked(settings.value('show splash'))
303
224
self.check_for_updates_check_box.setChecked(settings.value('update check'))
304
225
self.auto_preview_check_box.setChecked(settings.value('auto preview'))
305
226
self.timeout_spin_box.setValue(settings.value('loop delay'))
306
self.monitor_radio_button.setChecked(not settings.value('override position',))
307
self.override_radio_button.setChecked(settings.value('override position'))
308
self.custom_X_value_edit.setValue(settings.value('x position'))
309
self.custom_Y_value_edit.setValue(settings.value('y position'))
310
self.custom_height_value_edit.setValue(settings.value('height'))
311
self.custom_width_value_edit.setValue(settings.value('width'))
312
227
self.start_paused_check_box.setChecked(settings.value('audio start paused'))
313
228
self.repeat_list_check_box.setChecked(settings.value('audio repeat list'))
314
229
settings.endGroup()
315
self.monitor_combo_box.setDisabled(self.override_radio_button.isChecked())
316
self.custom_X_value_edit.setEnabled(self.override_radio_button.isChecked())
317
self.custom_Y_value_edit.setEnabled(self.override_radio_button.isChecked())
318
self.custom_height_value_edit.setEnabled(self.override_radio_button.isChecked())
319
self.custom_width_value_edit.setEnabled(self.override_radio_button.isChecked())
320
self.display_changed = False
342
249
settings.setValue('ccli number', self.number_edit.displayText())
343
250
settings.setValue('songselect username', self.username_edit.displayText())
344
251
settings.setValue('songselect password', self.password_edit.displayText())
345
settings.setValue('x position', self.custom_X_value_edit.value())
346
settings.setValue('y position', self.custom_Y_value_edit.value())
347
settings.setValue('height', self.custom_height_value_edit.value())
348
settings.setValue('width', self.custom_width_value_edit.value())
349
settings.setValue('override position', self.override_radio_button.isChecked())
350
252
settings.setValue('audio start paused', self.start_paused_check_box.isChecked())
351
253
settings.setValue('audio repeat list', self.repeat_list_check_box.isChecked())
352
254
settings.endGroup()
353
# On save update the screens as well
354
self.post_set_up(True)
356
def post_set_up(self, postUpdate=False):
257
def post_set_up(self):
358
Apply settings after settings tab has loaded and most of the system so must be delayed
259
Apply settings after the tab has loaded
360
261
self.settings_form.register_post_process('slidecontroller_live_spin_delay')
361
# Do not continue on start up.
364
self.screens.set_current_display(self.monitor_combo_box.currentIndex())
365
self.screens.display = self.display_on_monitor_check.isChecked()
366
self.screens.override['size'] = QtCore.QRect(
367
self.custom_X_value_edit.value(),
368
self.custom_Y_value_edit.value(),
369
self.custom_width_value_edit.value(),
370
self.custom_height_value_edit.value())
371
self.screens.override['number'] = self.screens.which_screen(self.screens.override['size'])
372
self.screens.override['primary'] = (self.screens.desktop.primaryScreen() == self.screens.override['number'])
373
if self.override_radio_button.isChecked():
374
self.screens.set_override_display()
376
self.screens.reset_current_display()
377
if self.display_changed:
378
self.settings_form.register_post_process('config_screen_changed')
379
self.display_changed = False
381
def on_override_radio_button_pressed(self, checked):
383
Toggle screen state depending on check box state.
385
:param checked: The state of the check box (boolean).
387
self.monitor_combo_box.setDisabled(checked)
388
self.custom_X_value_edit.setEnabled(checked)
389
self.custom_Y_value_edit.setEnabled(checked)
390
self.custom_height_value_edit.setEnabled(checked)
391
self.custom_width_value_edit.setEnabled(checked)
392
self.display_changed = True
394
def on_display_changed(self):
396
Called when the width, height, x position or y position has changed.
398
self.display_changed = True
400
263
def on_logo_background_color_changed(self, color):