2019-05-28 21:34:52 +02:00
|
|
|
# ============================================================
|
|
|
|
# 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 Falkon
|
|
|
|
import os
|
|
|
|
from PySide2 import QtCore, QtGui, QtWidgets, QtUiTools
|
|
|
|
from unloader.i18n import i18n
|
|
|
|
|
|
|
|
|
|
|
|
class SettingsDialog(QtWidgets.QDialog):
|
|
|
|
ui = None
|
|
|
|
config = None
|
|
|
|
|
|
|
|
def __init__(self, config, remove, 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()
|
|
|
|
|
2019-06-29 00:45:16 +02:00
|
|
|
self.ui.updateIntervalSpinBox.setValue(self.config.updateInterval)
|
|
|
|
self.ui.discardInactiveTabAfterSpinBox.setValue(self.config.threshold)
|
|
|
|
self.ui.closeTabForSpinBox.setValue(self.config.closeThreshold)
|
2019-05-28 21:34:52 +02:00
|
|
|
|
|
|
|
self.ui.buttonBoxConfirm.accepted.connect(self.accept)
|
|
|
|
self.ui.buttonBoxConfirm.rejected.connect(self.reject)
|
|
|
|
|
|
|
|
def translations(self):
|
|
|
|
self.setWindowTitle(i18n("Unloader Settings"))
|
|
|
|
self.ui.updateIntervalLabel.setText(i18n("Update interval (in seconds):"))
|
|
|
|
self.ui.discardInactiveTabAfterLabel.setText(
|
|
|
|
i18n("Discard inactive tab after (in seconds):")
|
|
|
|
)
|
2019-06-14 10:37:02 +02:00
|
|
|
self.ui.closeTabWhenUnloadedForLabel.setText(
|
|
|
|
i18n("Close tab when unloaded for:")
|
|
|
|
)
|
2019-05-28 21:34:52 +02:00
|
|
|
|
|
|
|
def updateData(self):
|
2019-06-29 00:45:16 +02:00
|
|
|
self.config.updateInterval = self.ui.updateIntervalSpinBox.value()
|
|
|
|
self.config.threshold = self.ui.discardInactiveTabAfterSpinBox.value()
|
|
|
|
self.config.closeThreshold = self.ui.closeTabForSpinBox.value()
|
2019-05-28 21:34:52 +02:00
|
|
|
|
|
|
|
def accept(self):
|
|
|
|
self.updateData()
|
|
|
|
|
|
|
|
super().accept()
|