Falkon Develop
Cross-platform Qt-based web browser
settingsdialog.py
Go to the documentation of this file.
1# ============================================================
2# RunAction plugin for Falkon
3# Copyright (C) 2018 David Rosca <nowrep@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# ============================================================
18import os
19from PySide6 import QtCore, QtWidgets, QtUiTools
20from runaction.i18n import i18n
21
22
23class SettingsDialog(QtWidgets.QDialog):
24 def __init__(self, manager, parent=None):
25 super().__init__(parent)
26
27 self.manager = manager
28
29 file = QtCore.QFile(os.path.join(os.path.dirname(__file__), "settings.ui"))
30 file.open(QtCore.QFile.ReadOnly)
31 self.ui = QtUiTools.QUiLoader().load(file, self)
32 file.close()
33
34 layout = QtWidgets.QVBoxLayout(self)
35 layout.addWidget(self.ui)
36
37 self.setMinimumSize(400, 250)
38 self.setWindowTitle(i18n("Run Action Settings"))
39 self.ui.label.setText(i18n("Available actions"))
40
41 for action in self.manager.actions:
42 item = QtWidgets.QListWidgetItem(self.ui.listWidget)
43 item.setText(action.title)
44 item.setIcon(action.icon)
45 item.setData(QtCore.Qt.UserRole, action.id)
46 item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable)
47 item.setCheckState(QtCore.Qt.Unchecked if action.id in self.manager.disabledActions else QtCore.Qt.Checked)
48 self.ui.listWidget.addItem(item)
49
50 self.ui.buttonBox.accepted.connect(self.accept)
51 self.ui.buttonBox.rejected.connect(self.reject)
52
53 def accept(self):
54 disabled = []
55 for i in range(self.ui.listWidget.count()):
56 item = self.ui.listWidget.item(i)
57 if item.checkState() == QtCore.Qt.Unchecked:
58 disabled.append(item.data(QtCore.Qt.UserRole))
59 self.manager.disabledActions = disabled
60 super().accept()
def __init__(self, manager, parent=None)
Definition: i18n.py:1