1
# -*- coding: utf-8 -*-
2
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
4
###############################################################################
5
# OpenLP - Open Source Lyrics Projection #
6
# --------------------------------------------------------------------------- #
7
# Copyright (c) 2008-2012 Raoul Snyman #
8
# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan #
9
# Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, #
10
# Armin Kƶhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias #
11
# PƵldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
12
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund #
13
# --------------------------------------------------------------------------- #
14
# This program is free software; you can redistribute it and/or modify it #
15
# under the terms of the GNU General Public License as published by the Free #
16
# Software Foundation; version 2 of the License. #
18
# This program is distributed in the hope that it will be useful, but WITHOUT #
19
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
20
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
23
# You should have received a copy of the GNU General Public License along #
24
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
25
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
26
###############################################################################
29
from PyQt4 import QtCore, QtGui
31
from openlp.core.lib import SettingsTab, Receiver, translate
32
from openlp.core.lib.ui import UiStrings
33
from openlp.core.ui import ScreenList
35
log = logging.getLogger(__name__)
37
class GeneralTab(SettingsTab):
39
GeneralTab is the general settings tab in the settings dialog.
41
def __init__(self, parent):
43
Initialise the general settings tab
45
self.screens = ScreenList.get_instance()
46
self.icon_path = u':/icon/openlp-logo-16x16.png'
47
generalTranslated = translate('OpenLP.GeneralTab', 'General')
48
SettingsTab.__init__(self, parent, u'General', generalTranslated)
52
Create the user interface for the general settings tab
54
self.setObjectName(u'GeneralTab')
55
SettingsTab.setupUi(self)
56
self.tabLayout.setStretch(1, 1)
58
self.monitorGroupBox = QtGui.QGroupBox(self.leftColumn)
59
self.monitorGroupBox.setObjectName(u'monitorGroupBox')
60
self.monitorLayout = QtGui.QGridLayout(self.monitorGroupBox)
61
self.monitorLayout.setObjectName(u'monitorLayout')
62
self.monitorRadioButton = QtGui.QRadioButton(self.monitorGroupBox)
63
self.monitorRadioButton.setObjectName(u'monitorRadioButton')
64
self.monitorLayout.addWidget(self.monitorRadioButton, 0, 0, 1, 5)
65
self.monitorComboBox = QtGui.QComboBox(self.monitorGroupBox)
66
self.monitorComboBox.setObjectName(u'monitorComboBox')
67
self.monitorLayout.addWidget(self.monitorComboBox, 1, 1, 1, 4)
68
self.displayOnMonitorCheck = QtGui.QCheckBox(self.monitorGroupBox)
69
self.displayOnMonitorCheck.setObjectName(u'monitorComboBox')
70
self.monitorLayout.addWidget(self.displayOnMonitorCheck, 2, 1, 1, 4)
72
self.overrideRadioButton = QtGui.QRadioButton(self.monitorGroupBox)
73
self.overrideRadioButton.setObjectName(u'overrideRadioButton')
74
self.monitorLayout.addWidget(self.overrideRadioButton, 3, 0, 1, 5)
76
self.customXLabel = QtGui.QLabel(self.monitorGroupBox)
77
self.customXLabel.setObjectName(u'customXLabel')
78
self.monitorLayout.addWidget(self.customXLabel, 4, 1)
79
self.customXValueEdit = QtGui.QSpinBox(self.monitorGroupBox)
80
self.customXValueEdit.setObjectName(u'customXValueEdit')
81
self.customXValueEdit.setRange(-9999, 9999)
82
self.monitorLayout.addWidget(self.customXValueEdit, 5, 1)
83
self.customYLabel = QtGui.QLabel(self.monitorGroupBox)
84
self.customYLabel.setObjectName(u'customYLabel')
85
self.monitorLayout.addWidget(self.customYLabel, 4, 2)
86
self.customYValueEdit = QtGui.QSpinBox(self.monitorGroupBox)
87
self.customYValueEdit.setObjectName(u'customYValueEdit')
88
self.customYValueEdit.setRange(-9999, 9999)
89
self.monitorLayout.addWidget(self.customYValueEdit, 5, 2)
90
self.customWidthLabel = QtGui.QLabel(self.monitorGroupBox)
91
self.customWidthLabel.setObjectName(u'customWidthLabel')
92
self.monitorLayout.addWidget(self.customWidthLabel, 4, 3)
93
self.customWidthValueEdit = QtGui.QSpinBox(self.monitorGroupBox)
94
self.customWidthValueEdit.setObjectName(u'customWidthValueEdit')
95
self.customWidthValueEdit.setMaximum(9999)
96
self.monitorLayout.addWidget(self.customWidthValueEdit, 5, 3)
97
self.customHeightLabel = QtGui.QLabel(self.monitorGroupBox)
98
self.customHeightLabel.setObjectName(u'customHeightLabel')
99
self.monitorLayout.addWidget(self.customHeightLabel, 4, 4)
100
self.customHeightValueEdit = QtGui.QSpinBox(self.monitorGroupBox)
101
self.customHeightValueEdit.setObjectName(u'customHeightValueEdit')
102
self.customHeightValueEdit.setMaximum(9999)
103
self.monitorLayout.addWidget(self.customHeightValueEdit, 5, 4)
104
# Set up the stretchiness of each column, so that the first column
105
# less stretchy (and therefore smaller) than the others
106
self.monitorLayout.setColumnStretch(0, 1)
107
self.monitorLayout.setColumnStretch(1, 3)
108
self.monitorLayout.setColumnStretch(2, 3)
109
self.monitorLayout.setColumnStretch(3, 3)
110
self.monitorLayout.setColumnStretch(4, 3)
111
self.leftLayout.addWidget(self.monitorGroupBox)
113
self.ccliGroupBox = QtGui.QGroupBox(self.leftColumn)
114
self.ccliGroupBox.setObjectName(u'ccliGroupBox')
115
self.ccliLayout = QtGui.QFormLayout(self.ccliGroupBox)
116
self.ccliLayout.setObjectName(u'ccliLayout')
117
self.numberLabel = QtGui.QLabel(self.ccliGroupBox)
118
self.numberLabel.setObjectName(u'numberLabel')
119
self.numberEdit = QtGui.QLineEdit(self.ccliGroupBox)
120
self.numberEdit.setValidator(QtGui.QIntValidator())
121
self.numberEdit.setObjectName(u'numberEdit')
122
self.ccliLayout.addRow(self.numberLabel, self.numberEdit)
123
self.usernameLabel = QtGui.QLabel(self.ccliGroupBox)
124
self.usernameLabel.setObjectName(u'usernameLabel')
125
self.usernameEdit = QtGui.QLineEdit(self.ccliGroupBox)
126
self.usernameEdit.setObjectName(u'usernameEdit')
127
self.ccliLayout.addRow(self.usernameLabel, self.usernameEdit)
128
self.passwordLabel = QtGui.QLabel(self.ccliGroupBox)
129
self.passwordLabel.setObjectName(u'passwordLabel')
130
self.passwordEdit = QtGui.QLineEdit(self.ccliGroupBox)
131
self.passwordEdit.setEchoMode(QtGui.QLineEdit.Password)
132
self.passwordEdit.setObjectName(u'passwordEdit')
133
self.ccliLayout.addRow(self.passwordLabel, self.passwordEdit)
134
self.leftLayout.addWidget(self.ccliGroupBox)
136
self.audioGroupBox = QtGui.QGroupBox(self.leftColumn)
137
self.audioGroupBox.setObjectName(u'audioGroupBox')
138
self.audioLayout = QtGui.QVBoxLayout(self.audioGroupBox)
139
self.audioLayout.setObjectName(u'audioLayout')
140
self.startPausedCheckBox = QtGui.QCheckBox(self.audioGroupBox)
141
self.startPausedCheckBox.setObjectName(u'startPausedCheckBox')
142
self.audioLayout.addWidget(self.startPausedCheckBox)
143
self.repeatListCheckBox = QtGui.QCheckBox(self.audioGroupBox)
144
self.repeatListCheckBox.setObjectName(u'repeatListCheckBox')
145
self.audioLayout.addWidget(self.repeatListCheckBox)
146
self.leftLayout.addWidget(self.audioGroupBox)
147
self.leftLayout.addStretch()
148
# Application Startup
149
self.startupGroupBox = QtGui.QGroupBox(self.rightColumn)
150
self.startupGroupBox.setObjectName(u'startupGroupBox')
151
self.startupLayout = QtGui.QVBoxLayout(self.startupGroupBox)
152
self.startupLayout.setObjectName(u'startupLayout')
153
self.warningCheckBox = QtGui.QCheckBox(self.startupGroupBox)
154
self.warningCheckBox.setObjectName(u'warningCheckBox')
155
self.startupLayout.addWidget(self.warningCheckBox)
156
self.autoOpenCheckBox = QtGui.QCheckBox(self.startupGroupBox)
157
self.autoOpenCheckBox.setObjectName(u'autoOpenCheckBox')
158
self.startupLayout.addWidget(self.autoOpenCheckBox)
159
self.showSplashCheckBox = QtGui.QCheckBox(self.startupGroupBox)
160
self.showSplashCheckBox.setObjectName(u'showSplashCheckBox')
161
self.startupLayout.addWidget(self.showSplashCheckBox)
162
self.checkForUpdatesCheckBox = QtGui.QCheckBox(self.startupGroupBox)
163
self.checkForUpdatesCheckBox.setObjectName(u'checkForUpdatesCheckBox')
164
self.startupLayout.addWidget(self.checkForUpdatesCheckBox)
165
self.rightLayout.addWidget(self.startupGroupBox)
166
# Application Settings
167
self.settingsGroupBox = QtGui.QGroupBox(self.rightColumn)
168
self.settingsGroupBox.setObjectName(u'settingsGroupBox')
169
self.settingsLayout = QtGui.QFormLayout(self.settingsGroupBox)
170
self.settingsLayout.setObjectName(u'settingsLayout')
171
self.saveCheckServiceCheckBox = QtGui.QCheckBox(self.settingsGroupBox)
172
self.saveCheckServiceCheckBox.setObjectName(u'saveCheckServiceCheckBox')
173
self.settingsLayout.addRow(self.saveCheckServiceCheckBox)
174
self.autoUnblankCheckBox = QtGui.QCheckBox(self.settingsGroupBox)
175
self.autoUnblankCheckBox.setObjectName(u'autoUnblankCheckBox')
176
self.settingsLayout.addRow(self.autoUnblankCheckBox)
177
self.autoPreviewCheckBox = QtGui.QCheckBox(self.settingsGroupBox)
178
self.autoPreviewCheckBox.setObjectName(u'autoPreviewCheckBox')
179
self.settingsLayout.addRow(self.autoPreviewCheckBox)
180
# Moved here from image tab
181
self.timeoutLabel = QtGui.QLabel(self.settingsGroupBox)
182
self.timeoutLabel.setObjectName(u'timeoutLabel')
183
self.timeoutSpinBox = QtGui.QSpinBox(self.settingsGroupBox)
184
self.timeoutSpinBox.setObjectName(u'timeoutSpinBox')
185
self.timeoutSpinBox.setRange(1, 180)
186
self.settingsLayout.addRow(self.timeoutLabel, self.timeoutSpinBox)
187
self.rightLayout.addWidget(self.settingsGroupBox)
188
self.rightLayout.addStretch()
190
QtCore.QObject.connect(self.overrideRadioButton,
191
QtCore.SIGNAL(u'toggled(bool)'), self.onOverrideRadioButtonPressed)
192
QtCore.QObject.connect(self.customHeightValueEdit,
193
QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayChanged)
194
QtCore.QObject.connect(self.customWidthValueEdit,
195
QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayChanged)
196
QtCore.QObject.connect(self.customYValueEdit,
197
QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayChanged)
198
QtCore.QObject.connect(self.customXValueEdit,
199
QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayChanged)
200
QtCore.QObject.connect(self.monitorComboBox,
201
QtCore.SIGNAL(u'currentIndexChanged(int)'), self.onDisplayChanged)
202
# Reload the tab, as the screen resolution/count may have changed.
203
QtCore.QObject.connect(Receiver.get_receiver(),
204
QtCore.SIGNAL(u'config_screen_changed'), self.load)
206
self.usernameLabel.setVisible(False)
207
self.usernameEdit.setVisible(False)
208
self.passwordLabel.setVisible(False)
209
self.passwordEdit.setVisible(False)
211
def retranslateUi(self):
213
Translate the general settings tab to the currently selected language
215
self.tabTitleVisible = translate('OpenLP.GeneralTab', 'General')
216
self.monitorGroupBox.setTitle(translate('OpenLP.GeneralTab',
218
self.monitorRadioButton.setText(translate('OpenLP.GeneralTab',
219
'Select monitor for output display:'))
220
self.displayOnMonitorCheck.setText(
221
translate('OpenLP.GeneralTab', 'Display if a single screen'))
222
self.startupGroupBox.setTitle(
223
translate('OpenLP.GeneralTab', 'Application Startup'))
224
self.warningCheckBox.setText(
225
translate('OpenLP.GeneralTab', 'Show blank screen warning'))
226
self.autoOpenCheckBox.setText(translate('OpenLP.GeneralTab',
227
'Automatically open the last service'))
228
self.showSplashCheckBox.setText(
229
translate('OpenLP.GeneralTab', 'Show the splash screen'))
230
self.checkForUpdatesCheckBox.setText(
231
translate('OpenLP.GeneralTab', 'Check for updates to OpenLP'))
232
self.settingsGroupBox.setTitle(
233
translate('OpenLP.GeneralTab', 'Application Settings'))
234
self.saveCheckServiceCheckBox.setText(translate('OpenLP.GeneralTab',
235
'Prompt to save before starting a new service'))
236
self.autoUnblankCheckBox.setText(translate('OpenLP.GeneralTab',
237
'Unblank display when adding new live item'))
238
self.autoPreviewCheckBox.setText(translate('OpenLP.GeneralTab',
239
'Automatically preview next item in service'))
240
self.timeoutLabel.setText(translate('OpenLP.GeneralTab',
241
'Timed slide interval:'))
242
self.timeoutSpinBox.setSuffix(translate('OpenLP.GeneralTab', ' sec'))
243
self.ccliGroupBox.setTitle(
244
translate('OpenLP.GeneralTab', 'CCLI Details'))
245
self.numberLabel.setText(UiStrings().CCLINumberLabel)
246
self.usernameLabel.setText(
247
translate('OpenLP.GeneralTab', 'SongSelect username:'))
248
self.passwordLabel.setText(
249
translate('OpenLP.GeneralTab', 'SongSelect password:'))
250
# Moved from display tab
251
self.overrideRadioButton.setText(translate('OpenLP.GeneralTab',
252
'Override display position:'))
253
self.customXLabel.setText(translate('OpenLP.GeneralTab', 'X'))
254
self.customYLabel.setText(translate('OpenLP.GeneralTab', 'Y'))
255
self.customHeightLabel.setText(translate('OpenLP.GeneralTab', 'Height'))
256
self.customWidthLabel.setText(translate('OpenLP.GeneralTab', 'Width'))
257
self.audioGroupBox.setTitle(
258
translate('OpenLP.GeneralTab', 'Background Audio'))
259
self.startPausedCheckBox.setText(
260
translate('OpenLP.GeneralTab', 'Start background audio paused'))
261
self.repeatListCheckBox.setText(
262
translate('OpenLP.GeneralTab', 'Repeat track list'))
266
Load the settings to populate the form
268
settings = QtCore.QSettings()
269
settings.beginGroup(self.settingsSection)
270
self.monitorComboBox.clear()
271
self.monitorComboBox.addItems(self.screens.get_screen_list())
272
monitorNumber = settings.value(u'monitor',
273
QtCore.QVariant(self.screens.display_count - 1)).toInt()[0]
274
self.monitorComboBox.setCurrentIndex(monitorNumber)
275
self.numberEdit.setText(unicode(settings.value(
276
u'ccli number', QtCore.QVariant(u'')).toString()))
277
self.usernameEdit.setText(unicode(settings.value(
278
u'songselect username', QtCore.QVariant(u'')).toString()))
279
self.passwordEdit.setText(unicode(settings.value(
280
u'songselect password', QtCore.QVariant(u'')).toString()))
281
self.saveCheckServiceCheckBox.setChecked(settings.value(u'save prompt',
282
QtCore.QVariant(False)).toBool())
283
self.autoUnblankCheckBox.setChecked(settings.value(u'auto unblank',
284
QtCore.QVariant(False)).toBool())
285
self.displayOnMonitorCheck.setChecked(self.screens.display)
286
self.warningCheckBox.setChecked(settings.value(u'blank warning',
287
QtCore.QVariant(False)).toBool())
288
self.autoOpenCheckBox.setChecked(settings.value(u'auto open',
289
QtCore.QVariant(False)).toBool())
290
self.showSplashCheckBox.setChecked(settings.value(u'show splash',
291
QtCore.QVariant(True)).toBool())
292
self.checkForUpdatesCheckBox.setChecked(settings.value(u'update check',
293
QtCore.QVariant(True)).toBool())
294
self.autoPreviewCheckBox.setChecked(settings.value(u'auto preview',
295
QtCore.QVariant(False)).toBool())
296
self.timeoutSpinBox.setValue(settings.value(u'loop delay',
297
QtCore.QVariant(5)).toInt()[0])
298
self.monitorRadioButton.setChecked(
299
not settings.value(u'override position',
300
QtCore.QVariant(False)).toBool())
301
self.overrideRadioButton.setChecked(settings.value(u'override position',
302
QtCore.QVariant(False)).toBool())
303
self.customXValueEdit.setValue(settings.value(u'x position',
304
QtCore.QVariant(self.screens.current[u'size'].x())).toInt()[0])
305
self.customYValueEdit.setValue(settings.value(u'y position',
306
QtCore.QVariant(self.screens.current[u'size'].y())).toInt()[0])
307
self.customHeightValueEdit.setValue(settings.value(u'height',
308
QtCore.QVariant(self.screens.current[u'size'].height())).toInt()[0])
309
self.customWidthValueEdit.setValue(settings.value(u'width',
310
QtCore.QVariant(self.screens.current[u'size'].width())).toInt()[0])
311
self.startPausedCheckBox.setChecked(settings.value(
312
u'audio start paused', QtCore.QVariant(True)).toBool())
313
self.repeatListCheckBox.setChecked(settings.value(
314
u'audio repeat list', QtCore.QVariant(False)).toBool())
316
self.monitorComboBox.setDisabled(self.overrideRadioButton.isChecked())
317
self.displayOnMonitorCheck.setDisabled(
318
self.overrideRadioButton.isChecked())
319
self.customXValueEdit.setEnabled(self.overrideRadioButton.isChecked())
320
self.customYValueEdit.setEnabled(self.overrideRadioButton.isChecked())
321
self.customHeightValueEdit.setEnabled(
322
self.overrideRadioButton.isChecked())
323
self.customWidthValueEdit.setEnabled(
324
self.overrideRadioButton.isChecked())
325
self.display_changed = False
326
settings.beginGroup(self.settingsSection)
330
Save the settings from the form
332
settings = QtCore.QSettings()
333
settings.beginGroup(self.settingsSection)
334
settings.setValue(u'monitor',
335
QtCore.QVariant(self.monitorComboBox.currentIndex()))
336
settings.setValue(u'display on monitor',
337
QtCore.QVariant(self.displayOnMonitorCheck.isChecked()))
338
settings.setValue(u'blank warning',
339
QtCore.QVariant(self.warningCheckBox.isChecked()))
340
settings.setValue(u'auto open',
341
QtCore.QVariant(self.autoOpenCheckBox.isChecked()))
342
settings.setValue(u'show splash',
343
QtCore.QVariant(self.showSplashCheckBox.isChecked()))
344
settings.setValue(u'update check',
345
QtCore.QVariant(self.checkForUpdatesCheckBox.isChecked()))
346
settings.setValue(u'save prompt',
347
QtCore.QVariant(self.saveCheckServiceCheckBox.isChecked()))
348
settings.setValue(u'auto unblank',
349
QtCore.QVariant(self.autoUnblankCheckBox.isChecked()))
350
settings.setValue(u'auto preview',
351
QtCore.QVariant(self.autoPreviewCheckBox.isChecked()))
352
settings.setValue(u'loop delay',
353
QtCore.QVariant(self.timeoutSpinBox.value()))
354
settings.setValue(u'ccli number',
355
QtCore.QVariant(self.numberEdit.displayText()))
356
settings.setValue(u'songselect username',
357
QtCore.QVariant(self.usernameEdit.displayText()))
358
settings.setValue(u'songselect password',
359
QtCore.QVariant(self.passwordEdit.displayText()))
360
settings.setValue(u'x position',
361
QtCore.QVariant(self.customXValueEdit.value()))
362
settings.setValue(u'y position',
363
QtCore.QVariant(self.customYValueEdit.value()))
364
settings.setValue(u'height',
365
QtCore.QVariant(self.customHeightValueEdit.value()))
366
settings.setValue(u'width',
367
QtCore.QVariant(self.customWidthValueEdit.value()))
368
settings.setValue(u'override position',
369
QtCore.QVariant(self.overrideRadioButton.isChecked()))
370
settings.setValue(u'audio start paused',
371
QtCore.QVariant(self.startPausedCheckBox.isChecked()))
372
settings.setValue(u'audio repeat list',
373
QtCore.QVariant(self.repeatListCheckBox.isChecked()))
375
# On save update the screens as well
378
def postSetUp(self, postUpdate=False):
380
Apply settings after settings tab has loaded and most of the
381
system so must be delayed
383
Receiver.send_message(u'slidecontroller_live_spin_delay',
384
self.timeoutSpinBox.value())
385
# Do not continue on start up.
388
self.screens.set_current_display(self.monitorComboBox.currentIndex())
389
self.screens.display = self.displayOnMonitorCheck.isChecked()
390
self.screens.override[u'size'] = QtCore.QRect(
391
self.customXValueEdit.value(),
392
self.customYValueEdit.value(),
393
self.customWidthValueEdit.value(),
394
self.customHeightValueEdit.value())
395
if self.overrideRadioButton.isChecked():
396
self.screens.set_override_display()
398
self.screens.reset_current_display()
399
if self.display_changed:
400
Receiver.send_message(u'config_screen_changed')
401
self.display_changed = False
403
def onOverrideRadioButtonPressed(self, checked):
405
Toggle screen state depending on check box state.
408
The state of the check box (boolean).
410
self.monitorComboBox.setDisabled(checked)
411
self.displayOnMonitorCheck.setDisabled(checked)
412
self.customXValueEdit.setEnabled(checked)
413
self.customYValueEdit.setEnabled(checked)
414
self.customHeightValueEdit.setEnabled(checked)
415
self.customWidthValueEdit.setEnabled(checked)
416
self.display_changed = True
418
def onDisplayChanged(self):
420
Called when the width, height, x position or y position has changed.
422
self.display_changed = True