2019-06-26 09:53:43 +02:00
|
|
|
# ============================================================
|
|
|
|
# Toolbar Tools - plugin for Falkon
|
|
|
|
# Copyright (C) 2019 Juraj Oravec <sgd.orava@gmail.com>
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
# ============================================================
|
|
|
|
|
|
|
|
import os
|
2024-12-07 15:43:56 +01:00
|
|
|
from PySide6 import QtCore, QtWidgets, QtUiTools
|
2019-06-26 09:53:43 +02:00
|
|
|
from toolbartools.i18n import i18n
|
|
|
|
|
|
|
|
|
|
|
|
class SettingsDialog(QtWidgets.QDialog):
|
|
|
|
ui = None
|
|
|
|
config = None
|
|
|
|
|
|
|
|
def __init__(self, config, parent=None):
|
|
|
|
super().__init__(parent)
|
|
|
|
|
|
|
|
self.config = config
|
|
|
|
|
|
|
|
file = QtCore.QFile(os.path.join(os.path.dirname(__file__), "settingsDialog.ui"))
|
|
|
|
file.open(QtCore.QFile.ReadOnly)
|
|
|
|
self.ui = QtUiTools.QUiLoader().load(file, self)
|
|
|
|
file.close()
|
|
|
|
|
|
|
|
layout = QtWidgets.QVBoxLayout(self)
|
|
|
|
layout.addWidget(self.ui)
|
|
|
|
self.setLayout(layout)
|
|
|
|
|
|
|
|
self.translations()
|
|
|
|
self.applyConfig()
|
|
|
|
|
|
|
|
self.ui.buttonBoxConfirm.accepted.connect(self.accept)
|
|
|
|
self.ui.buttonBoxConfirm.rejected.connect(self.reject)
|
|
|
|
|
|
|
|
def applyConfig(self):
|
|
|
|
self.ui.numberOfSpacersSpinBox.setValue(self.config.spacerCount)
|
|
|
|
self.ui.spacerWidthSpinBox.setValue(self.config.spacerMaxWidth)
|
|
|
|
|
|
|
|
self.ui.numberOfSeparatorsSpinBox.setValue(self.config.separatorCount)
|
|
|
|
self.ui.separatorWidthSpinBox.setValue(self.config.separatorWidth)
|
|
|
|
|
|
|
|
def translations(self):
|
|
|
|
self.setWindowTitle(i18n("Toolbar Tools Settings"))
|
|
|
|
|
2019-06-28 11:13:07 +02:00
|
|
|
self.ui.tabWidget.setTabText(0, i18n("Spacer"))
|
2019-06-26 09:53:43 +02:00
|
|
|
self.ui.numberOfSpacersLabel.setText(i18n("Number of spacers:"))
|
|
|
|
self.ui.maximumWidthLabel.setText(i18n("Maximum width:"))
|
|
|
|
|
2019-06-28 11:13:07 +02:00
|
|
|
self.ui.tabWidget.setTabText(1, i18n("Separator"))
|
2019-06-26 09:53:43 +02:00
|
|
|
self.ui.numberOfSeparatorsLabel.setText(i18n("Number of separators"))
|
|
|
|
self.ui.separatorWidthLabel.setText(i18n("Width"))
|
|
|
|
|
|
|
|
def updateConfig(self):
|
|
|
|
self.config.spacerCount = self.ui.numberOfSpacersSpinBox.value()
|
|
|
|
self.config.spacerMaxWidth = self.ui.spacerWidthSpinBox.value()
|
|
|
|
|
|
|
|
self.config.separatorCount = self.ui.numberOfSeparatorsSpinBox.value()
|
|
|
|
self.config.separatorWidth = self.ui.separatorWidthSpinBox.value()
|
|
|
|
|
|
|
|
def accept(self):
|
|
|
|
self.updateConfig()
|
|
|
|
self.config.save()
|
|
|
|
|
|
|
|
super().accept()
|