tabCounter/tabcounter/settingsDialog.py

64 lines
2.2 KiB
Python
Raw Normal View History

# ============================================================
# Unloader - 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
from PySide2 import QtCore, QtWidgets, QtUiTools
from tabcounter.i18n import i18n
from tabcounter.constants import DISPLAY_TYPE
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__), "settings.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.ui.displayTypeComboBox.setCurrentIndex(self.config.displayType - 1)
self.ui.enableTooltipCheckBox.setChecked(self.config.enableTooltip)
self.ui.buttonBoxConfirm.accepted.connect(self.accept)
self.ui.buttonBoxConfirm.rejected.connect(self.reject)
def translations(self):
self.setWindowTitle(i18n("Tab Counter Settings"))
self.ui.displayTypeLabel.setText(i18n("Show count of tabs:"))
self.ui.enableTooltipLabel.setText(i18n("Enable tooltip"))
def updateData(self):
self.config.displayType = self.ui.displayTypeComboBox.currentIndex() + 1
self.config.enableTooltip = self.ui.enableTooltipCheckBox.isChecked()
def accept(self):
self.updateData()
super().accept()