~samothjtm/openlp/bug-1695587

« back to all changes in this revision

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

  • Committer: Tim Bentley
  • Author(s): Phill
  • Date: 2017-05-23 04:58:49 UTC
  • mfrom: (2732.3.9 path_edit_widget)
  • Revision ID: tim.bentley@gmail.com-20170523045849-lyg1q3adv3acbnez
Add a custom widget for editing and selecting paths. Implemented in OpenLP, with the exception of the import wizards, as I have other plans for refactoring these!

lp:~phill-ridout/openlp/path_edit (revision 2737)
[SUCCESS] https://ci.openlp.io/job/Branch-01-Pull/2009/
[SUCCESS] https://ci.openlp.io/job/Branch-02-Functional-Tests/1919/
[SUCCESS] https://ci.openlp.io/job/Branch-03-Interface-Tests/1855/
[SUCCESS] https://ci.openlp.io/job/Branch-04a-Code_Analysis/1235/
[SUCCESS] https://ci.openl...

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
from PyQt5 import QtCore, QtGui, QtWidgets
28
28
 
29
29
from openlp.core.common import Registry, Settings, UiStrings, translate, get_images_filter
30
 
from openlp.core.lib import SettingsTab, ScreenList, build_icon
31
 
from openlp.core.ui.lib.colorbutton import ColorButton
 
30
from openlp.core.lib import SettingsTab, ScreenList
 
31
from openlp.core.ui.lib import ColorButton, PathEdit
32
32
 
33
33
log = logging.getLogger(__name__)
34
34
 
172
172
        self.logo_layout.setObjectName('logo_layout')
173
173
        self.logo_file_label = QtWidgets.QLabel(self.logo_group_box)
174
174
        self.logo_file_label.setObjectName('logo_file_label')
175
 
        self.logo_file_edit = QtWidgets.QLineEdit(self.logo_group_box)
176
 
        self.logo_file_edit.setObjectName('logo_file_edit')
177
 
        self.logo_browse_button = QtWidgets.QToolButton(self.logo_group_box)
178
 
        self.logo_browse_button.setObjectName('logo_browse_button')
179
 
        self.logo_browse_button.setIcon(build_icon(':/general/general_open.png'))
180
 
        self.logo_revert_button = QtWidgets.QToolButton(self.logo_group_box)
181
 
        self.logo_revert_button.setObjectName('logo_revert_button')
182
 
        self.logo_revert_button.setIcon(build_icon(':/general/general_revert.png'))
183
 
        self.logo_file_layout = QtWidgets.QHBoxLayout()
184
 
        self.logo_file_layout.setObjectName('logo_file_layout')
185
 
        self.logo_file_layout.addWidget(self.logo_file_edit)
186
 
        self.logo_file_layout.addWidget(self.logo_browse_button)
187
 
        self.logo_file_layout.addWidget(self.logo_revert_button)
188
 
        self.logo_layout.addRow(self.logo_file_label, self.logo_file_layout)
 
175
        self.logo_file_path_edit = PathEdit(self.logo_group_box, default_path=':/graphics/openlp-splash-screen.png')
 
176
        self.logo_layout.addRow(self.logo_file_label, self.logo_file_path_edit)
189
177
        self.logo_color_label = QtWidgets.QLabel(self.logo_group_box)
190
178
        self.logo_color_label.setObjectName('logo_color_label')
191
179
        self.logo_color_button = ColorButton(self.logo_group_box)
196
184
        self.logo_layout.addRow(self.logo_hide_on_startup_check_box)
197
185
        self.right_layout.addWidget(self.logo_group_box)
198
186
        self.logo_color_button.colorChanged.connect(self.on_logo_background_color_changed)
199
 
        self.logo_browse_button.clicked.connect(self.on_logo_browse_button_clicked)
200
 
        self.logo_revert_button.clicked.connect(self.on_logo_revert_button_clicked)
201
187
        # Application Settings
202
188
        self.settings_group_box = QtWidgets.QGroupBox(self.right_column)
203
189
        self.settings_group_box.setObjectName('settings_group_box')
254
240
        self.logo_group_box.setTitle(translate('OpenLP.GeneralTab', 'Logo'))
255
241
        self.logo_color_label.setText(UiStrings().BackgroundColorColon)
256
242
        self.logo_file_label.setText(translate('OpenLP.GeneralTab', 'Logo file:'))
257
 
        self.logo_browse_button.setToolTip(translate('OpenLP.GeneralTab', 'Browse for an image file to display.'))
258
 
        self.logo_revert_button.setToolTip(translate('OpenLP.GeneralTab', 'Revert to the default OpenLP logo.'))
259
243
        self.logo_hide_on_startup_check_box.setText(translate('OpenLP.GeneralTab', 'Don\'t show logo on startup'))
260
244
        self.check_for_updates_check_box.setText(translate('OpenLP.GeneralTab', 'Check for updates to OpenLP'))
261
245
        self.settings_group_box.setTitle(translate('OpenLP.GeneralTab', 'Application Settings'))
282
266
        self.audio_group_box.setTitle(translate('OpenLP.GeneralTab', 'Background Audio'))
283
267
        self.start_paused_check_box.setText(translate('OpenLP.GeneralTab', 'Start background audio paused'))
284
268
        self.repeat_list_check_box.setText(translate('OpenLP.GeneralTab', 'Repeat track list'))
 
269
        self.logo_file_path_edit.dialog_caption = dialog_caption = translate('OpenLP.AdvancedTab', 'Select Logo File')
 
270
        self.logo_file_path_edit.filters = '{text};;{names} (*)'.format(
 
271
            text=get_images_filter(), names=UiStrings().AllFiles)
285
272
 
286
273
    def load(self):
287
274
        """
304
291
        self.auto_open_check_box.setChecked(settings.value('auto open'))
305
292
        self.show_splash_check_box.setChecked(settings.value('show splash'))
306
293
        self.logo_background_color = settings.value('logo background color')
307
 
        self.logo_file_edit.setText(settings.value('logo file'))
 
294
        self.logo_file_path_edit.path = settings.value('logo file')
308
295
        self.logo_hide_on_startup_check_box.setChecked(settings.value('logo hide on startup'))
309
296
        self.logo_color_button.color = self.logo_background_color
310
297
        self.check_for_updates_check_box.setChecked(settings.value('update check'))
338
325
        settings.setValue('auto open', self.auto_open_check_box.isChecked())
339
326
        settings.setValue('show splash', self.show_splash_check_box.isChecked())
340
327
        settings.setValue('logo background color', self.logo_background_color)
341
 
        settings.setValue('logo file', self.logo_file_edit.text())
 
328
        settings.setValue('logo file', self.logo_file_path_edit.path)
342
329
        settings.setValue('logo hide on startup', self.logo_hide_on_startup_check_box.isChecked())
343
330
        settings.setValue('update check', self.check_for_updates_check_box.isChecked())
344
331
        settings.setValue('save prompt', self.save_check_service_check_box.isChecked())
404
391
        """
405
392
        self.display_changed = True
406
393
 
407
 
    def on_logo_browse_button_clicked(self):
408
 
        """
409
 
        Select the logo file
410
 
        """
411
 
        file_filters = '{text};;{names} (*.*)'.format(text=get_images_filter(), names=UiStrings().AllFiles)
412
 
        filename, filter_used = QtWidgets.QFileDialog.getOpenFileName(self,
413
 
                                                                      translate('OpenLP.AdvancedTab', 'Open File'), '',
414
 
                                                                      file_filters)
415
 
        if filename:
416
 
            self.logo_file_edit.setText(filename)
417
 
        self.logo_file_edit.setFocus()
418
 
 
419
 
    def on_logo_revert_button_clicked(self):
420
 
        """
421
 
        Revert the logo file back to the default setting.
422
 
        """
423
 
        self.logo_file_edit.setText(':/graphics/openlp-splash-screen.png')
424
 
        self.logo_file_edit.setFocus()
425
 
 
426
394
    def on_logo_background_color_changed(self, color):
427
395
        """
428
396
        Select the background color for logo.