~tomasgroth/openlp/portable-path

« back to all changes in this revision

Viewing changes to openlp/core/ui/generaltab.py

  • Committer: Tomas Groth
  • Date: 2019-04-30 19:02:42 UTC
  • mfrom: (2829.2.32 openlp)
  • Revision ID: tomasgroth@yahoo.dk-20190430190242-6zwjk8724tyux70m
trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
###############################################################################
5
5
# OpenLP - Open Source Lyrics Projection                                      #
6
6
# --------------------------------------------------------------------------- #
7
 
# Copyright (c) 2008-2018 OpenLP Developers                                   #
 
7
# Copyright (c) 2008-2019 OpenLP Developers                                   #
8
8
# --------------------------------------------------------------------------- #
9
9
# This program is free software; you can redistribute it and/or modify it     #
10
10
# under the terms of the GNU General Public License as published by the Free  #
24
24
"""
25
25
import logging
26
26
 
27
 
from PyQt5 import QtCore, QtGui, QtWidgets
 
27
from PyQt5 import QtGui, QtWidgets
28
28
 
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
38
37
 
 
38
 
39
39
log = logging.getLogger(__name__)
40
40
 
41
41
 
47
47
        """
48
48
        Initialise the general settings tab
49
49
        """
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)
56
55
 
57
 
    def setupUi(self):
 
56
    def setup_ui(self):
58
57
        """
59
58
        Create the user interface for the general settings tab
60
59
        """
61
60
        self.setObjectName('GeneralTab')
62
 
        super(GeneralTab, self).setupUi()
 
61
        super(GeneralTab, self).setup_ui()
63
62
        self.tab_layout.setStretch(1, 1)
64
 
        # Monitors
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)
75
 
        # Display Position
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)
79
 
        # Custom position
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)
119
63
        # CCLI Details
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()
219
 
        # Signals and slots
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)
228
163
        # Remove for now
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)
233
168
 
234
 
    def retranslateUi(self):
 
169
    def retranslate_ui(self):
235
170
        """
236
171
        Translate the general settings tab to the currently selected language
237
172
        """
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'))
282
208
        """
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
321
230
 
322
231
    def save(self):
323
232
        """
325
234
        """
326
235
        settings = Settings()
327
236
        settings.beginGroup(self.settings_section)
328
 
        settings.setValue('monitor', self.monitor_combo_box.currentIndex())
329
 
        settings.setValue('display on monitor', self.display_on_monitor_check.isChecked())
330
237
        settings.setValue('blank warning', self.warning_check_box.isChecked())
331
238
        settings.setValue('auto open', self.auto_open_check_box.isChecked())
332
239
        settings.setValue('show splash', self.show_splash_check_box.isChecked())
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)
 
255
        self.post_set_up()
355
256
 
356
 
    def post_set_up(self, postUpdate=False):
 
257
    def post_set_up(self):
357
258
        """
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
359
260
        """
360
261
        self.settings_form.register_post_process('slidecontroller_live_spin_delay')
361
 
        # Do not continue on start up.
362
 
        if not postUpdate:
363
 
            return
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()
375
 
        else:
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
380
 
 
381
 
    def on_override_radio_button_pressed(self, checked):
382
 
        """
383
 
        Toggle screen state depending on check box state.
384
 
 
385
 
        :param checked: The state of the check box (boolean).
386
 
        """
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
393
 
 
394
 
    def on_display_changed(self):
395
 
        """
396
 
        Called when the width, height, x position or y position has changed.
397
 
        """
398
 
        self.display_changed = True
399
262
 
400
263
    def on_logo_background_color_changed(self, color):
401
264
        """