Falkon Develop
Cross-platform Qt-based web browser
mcl_settings.py
Go to the documentation of this file.
1# ============================================================
2# MiddleClickLoader - plugin for Falkon
3# Copyright (C) 2018 Juraj Oravec <sgd.orava@gmail.com>
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17# ============================================================
18
19import os
20from PySide6 import QtCore, QtWidgets, QtUiTools
21from middleclickloader.i18n import i18n
22from middleclickloader.mcl_loadmode import MCL_LoadMode
23
24
25class MCL_Settings(QtWidgets.QDialog):
26 settingsFile = ""
27 ui = None
28
29 def __init__(self, settingsFile, parent=None):
30 super().__init__(parent)
31
32 self.settingsFilesettingsFile = settingsFile
33
34 file = QtCore.QFile(os.path.join(os.path.dirname(__file__), "mcl_settings.ui"))
35 file.open(QtCore.QFile.ReadOnly)
36 self.ui = QtUiTools.QUiLoader().load(file, self)
37 file.close()
38
39 layout = QtWidgets.QVBoxLayout(self)
40 layout.addWidget(self.ui)
41 self.setLayout(layout)
42
43 self.setWindowTitle(i18n("MiddleClickLoader Setting"))
44 self.ui.label_header.setText("<h2>{}</h2>".format(i18n("MiddleClickLoader")))
45 self.ui.label_loadMode.setText(i18n("Open url in:"))
46 self.ui.onlyValidUrl.setText(i18n("Use only valid url"))
47
48 self.ui.loadMode.addItem(i18n("New Tab"), MCL_LoadMode.NEW_TAB)
49 self.ui.loadMode.addItem(i18n("Current Tab"), MCL_LoadMode.CURRENT_TAB)
50 self.ui.loadMode.addItem(i18n("New Window"), MCL_LoadMode.NEW_WINDOW)
51
52 settings = QtCore.QSettings(self.settingsFilesettingsFile, QtCore.QSettings.IniFormat)
53 settings.beginGroup("MiddleClickLoader")
54 self.ui.loadMode.setCurrentIndex(int(settings.value("LoadMode", MCL_LoadMode.NEW_TAB)))
55 self.ui.onlyValidUrl.setChecked(bool(settings.value("OnlyValidUrl", True)))
56 settings.endGroup()
57
58 self.ui.buttonBox.accepted.connect(self.accept)
59 self.ui.buttonBox.rejected.connect(self.reject)
60
61 def accept(self):
62 settings = QtCore.QSettings(self.settingsFilesettingsFile, QtCore.QSettings.IniFormat)
63 settings.beginGroup("MiddleClickLoader")
64 settings.setValue("LoadMode", self.ui.loadMode.currentIndex())
65 settings.setValue("OnlyValidUrl", self.ui.onlyValidUrl.isChecked())
66 settings.endGroup()
67
68 super().accept()
69 self.close()
def __init__(self, settingsFile, parent=None)
Definition: mcl_settings.py:29
Definition: i18n.py:1