Unloader/unloader/Config.py
Juraj Oravec b87c793229
Add Config class
Signed-off-by: Juraj Oravec <sgd.orava@gmail.com>
2019-06-29 00:44:53 +02:00

89 lines
2.6 KiB
Python

# 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/>.
from PySide2.QtCore import QObject, Signal
class Config(QObject):
updateIntervalChanged = Signal(int)
closeThresholdChanged = Signal(int)
thresholdChanged = Signal(int)
settingsFileChanged = Signal(str)
def __init__(self, updateInterval=None, closeThreshold=None, threshold=None, settingsFile=None):
super().__init__()
self._updateInterval = updateInterval
self._closeThreshold = closeThreshold
self._threshold = threshold
self._settingsFile = settingsFile
@property
def updateInterval(self):
return self._updateInterval
@updateInterval.setter
def updateInterval(self, updateInterval):
if updateInterval < 1:
return
if self._updateInterval == updateInterval:
return
self._updateInterval = updateInterval
self.updateIntervalChanged.emit(updateInterval)
@property
def closeThreshold(self):
return self._closeThreshold
@closeThreshold.setter
def closeThreshold(self, closeThreshold):
if closeThreshold < 0:
return
if self._closeThreshold == closeThreshold:
return
self._closeThreshold = closeThreshold
self.closeThresholdChanged.emit(closeThreshold)
@property
def threshold(self):
return self._threshold
@threshold.setter
def threshold(self, threshold):
if threshold < 1:
return
if self._threshold == threshold:
return
self._threshold = threshold
self.thresholdChanged.emit(threshold)
@property
def settingsFile(self):
return self._settingsFile
@settingsFile.setter
def settingsFile(self, settingsFile):
if not settingsFile:
return
if self._settingsFile == settingsFile:
return
self._settingsFile = settingsFile
self.settingsFileChanged.emit(settingsFile)