~tomasgroth/openlp/portable-path

« back to all changes in this revision

Viewing changes to openlp/core/widgets/wizard.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  #
27
27
from PyQt5 import QtCore, QtGui, QtWidgets
28
28
 
29
29
from openlp.core.common import is_macosx
30
 
from openlp.core.common.i18n import UiStrings, translate
31
 
from openlp.core.ui.icons import UiIcons
 
30
from openlp.core.common.i18n import translate
32
31
from openlp.core.common.mixins import RegistryProperties
33
32
from openlp.core.common.registry import Registry
34
 
from openlp.core.common.settings import Settings
35
 
from openlp.core.lib import build_icon
36
33
from openlp.core.lib.ui import add_welcome_page
37
 
from openlp.core.widgets.dialogs import FileDialog
 
34
from openlp.core.ui.icons import UiIcons
 
35
 
38
36
 
39
37
log = logging.getLogger(__name__)
40
38
 
110
108
        self.delete_icon = UiIcons().delete
111
109
        self.finish_button = self.button(QtWidgets.QWizard.FinishButton)
112
110
        self.cancel_button = self.button(QtWidgets.QWizard.CancelButton)
113
 
        self.setupUi(image)
 
111
        self.setup_ui(image)
114
112
        self.register_fields()
115
113
        self.custom_init()
116
114
        self.custom_signals()
119
117
            self.error_copy_to_button.clicked.connect(self.on_error_copy_to_button_clicked)
120
118
            self.error_save_to_button.clicked.connect(self.on_error_save_to_button_clicked)
121
119
 
122
 
    def setupUi(self, image):
 
120
    def setup_ui(self, image):
123
121
        """
124
122
        Set up the wizard UI.
125
123
        :param image: path to start up image
136
134
        self.add_custom_pages()
137
135
        if self.with_progress_page:
138
136
            self.add_progress_page()
139
 
        self.retranslateUi()
 
137
        self.retranslate_ui()
140
138
 
141
139
    def register_fields(self):
142
140
        """
280
278
        self.finish_button.setVisible(True)
281
279
        self.cancel_button.setVisible(False)
282
280
        self.application.process_events()
283
 
 
284
 
    def get_file_name(self, title, editbox, setting_name, filters=''):
285
 
        """
286
 
        Opens a FileDialog and saves the filename to the given editbox.
287
 
 
288
 
        :param str title: The title of the dialog.
289
 
        :param QtWidgets.QLineEdit editbox:  An QLineEdit.
290
 
        :param str setting_name: The place where to save the last opened directory.
291
 
        :param str filters: The file extension filters. It should contain the file description
292
 
            as well as the file extension. For example::
293
 
 
294
 
                'OpenLP 2 Databases (*.sqlite)'
295
 
        :rtype: None
296
 
        """
297
 
        if filters:
298
 
            filters += ';;'
299
 
        filters += '%s (*)' % UiStrings().AllFiles
300
 
        file_path, filter_used = FileDialog.getOpenFileName(
301
 
            self, title, Settings().value(self.plugin.settings_section + '/' + setting_name), filters)
302
 
        if file_path:
303
 
            editbox.setText(str(file_path))
304
 
            Settings().setValue(self.plugin.settings_section + '/' + setting_name, file_path.parent)
305
 
 
306
 
    def get_folder(self, title, editbox, setting_name):
307
 
        """
308
 
        Opens a FileDialog and saves the selected folder to the given editbox.
309
 
 
310
 
        :param str title: The title of the dialog.
311
 
        :param QtWidgets.QLineEdit editbox: An QLineEditbox.
312
 
        :param str setting_name: The place where to save the last opened directory.
313
 
        :rtype: None
314
 
        """
315
 
        folder_path = FileDialog.getExistingDirectory(
316
 
            self, title, Settings().value(self.plugin.settings_section + '/' + setting_name),
317
 
            FileDialog.ShowDirsOnly)
318
 
        if folder_path:
319
 
            editbox.setText(str(folder_path))
320
 
            Settings().setValue(self.plugin.settings_section + '/' + setting_name, folder_path)