ToolbarTools/toolbartools/Config.py

109 lines
2.8 KiB
Python
Raw Normal View History

# Toolbar Tools - Falkon plugin
# 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 Signal, QObject
class Config(QObject):
settingsFileChanged = Signal(str)
spacerCountChanged = Signal(int)
spacerMaxWidthChanged = Signal(int)
separatorCountChanged = Signal(int)
separatorWidthChanged = Signal(int)
def __init__(self, parent=None):
super().__init__(parent)
self._settingsFile = ""
self._spacerCount = 2
self._spacerMaxWidth = 150
self._separatorCount = 2
self._separatorWidth = 5
@property
def settingsFile(self):
return self._settingsFile
@settingsFile.setter
def settingsFile(self, filePath):
if not filePath:
return
if self._settingsFile == filePath:
return
self._settingsFile = filePath
self.settingsFileChanged.emit(filePath)
@property
def spacerCount(self):
return self._spacerCount
@spacerCount.setter
def spacerCount(self, count):
if count < 0:
return
if self._spacerCount == count:
return
self._spacerCount = count
self.spacerCountChanged.emit(count)
@property
def spacerMaxWidth(self):
return self._spacerMaxWidth
@spacerMaxWidth.setter
def spacerMaxWidth(self, maxWidth):
if maxWidth < 0:
return
if self._spacerMaxWidth == maxWidth:
return
self._spacerMaxWidth = maxWidth
self.spacerMaxWidthChanged.emit(maxWidth)
@property
def separatorCount(self):
return self._separatorCount
@separatorCount.setter
def separatorCount(self, count):
if count < 0:
return
if self._separatorCount == count:
return
self._separatorCount = count
self.separatorCountChanged.emit(count)
@property
def separatorWidth(self):
return self._separatorWidth
@separatorWidth.setter
def separatorWidth(self, width):
if width < 0:
return
if self._separatorWidth == width:
return
self._separatorWidth = width
self.spacerMaxWidthChanged.emit(width)