Add zoom to default zoom level on unknown hosts

Signed-off-by: Juraj Oravec <sgd.orava@gmail.com>
This commit is contained in:
Juraj Oravec 2019-05-15 21:30:22 +02:00
parent 256de794a3
commit ae01a4de54
No known key found for this signature in database
GPG Key ID: 63ACB65056BC8D07
3 changed files with 16 additions and 2 deletions

View File

@ -32,7 +32,8 @@ class AutoZoomer(QtCore.QObject):
self.config = { self.config = {
"settingsFile": os.path.join(settingsPath, "autoZoomer", "settings.ini"), "settingsFile": os.path.join(settingsPath, "autoZoomer", "settings.ini"),
"active": True "active": True,
"defaultZoom": True
} }
self.data = {} self.data = {}
self.remove = [] self.remove = []
@ -50,6 +51,7 @@ class AutoZoomer(QtCore.QObject):
settings.beginGroup("AutoZoomer") settings.beginGroup("AutoZoomer")
self.config["active"] = str2bool(settings.value("active", True)) self.config["active"] = str2bool(settings.value("active", True))
self.config["defaultZoom"] = str2bool(settings.value("defaultZoom", True))
settings.endGroup() settings.endGroup()
for group in settings.childGroups(): for group in settings.childGroups():
@ -68,6 +70,7 @@ class AutoZoomer(QtCore.QObject):
settings.beginGroup("AutoZoomer") settings.beginGroup("AutoZoomer")
settings.setValue("active", self.config["active"]) settings.setValue("active", self.config["active"])
settings.setValue("defaultZoom", self.config["defaultZoom"])
settings.endGroup() settings.endGroup()
for host in self.remove: for host in self.remove:
@ -92,6 +95,8 @@ class AutoZoomer(QtCore.QObject):
if host in self.data.keys(): if host in self.data.keys():
if self.data[host]["active"]: if self.data[host]["active"]:
view.setZoomLevel(self.data[host]["zoom"]) view.setZoomLevel(self.data[host]["zoom"])
elif self.config["defaultZoom"]:
view.setZoomLevel(Falkon.Settings.staticSettings().defaultZoomLevel)
def addItem(self, host, zoom=6, active=True): def addItem(self, host, zoom=6, active=True):
if not host: if not host:

View File

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>379</width> <width>390</width>
<height>334</height> <height>334</height>
</rect> </rect>
</property> </property>
@ -102,6 +102,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="checkBoxDefaultZoom">
<property name="text">
<string>On unknown host zoom to default zoom level</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QDialogButtonBox" name="buttonBoxConfirm"> <widget class="QDialogButtonBox" name="buttonBoxConfirm">
<property name="tabletTracking"> <property name="tabletTracking">

View File

@ -46,6 +46,7 @@ class SettingsDialog(QtWidgets.QDialog):
self.setLayout(layout) self.setLayout(layout)
self.ui.checkBoxEnableAutoZoomer.setChecked(self.config["active"]) self.ui.checkBoxEnableAutoZoomer.setChecked(self.config["active"])
self.ui.checkBoxDefaultZoom.setChecked(self.config["defaultZoom"])
for key, value in self.data.items(): for key, value in self.data.items():
widget = ListItem() widget = ListItem()
@ -89,6 +90,7 @@ class SettingsDialog(QtWidgets.QDialog):
def updateData(self): def updateData(self):
self.config["active"] = self.ui.checkBoxEnableAutoZoomer.isChecked() self.config["active"] = self.ui.checkBoxEnableAutoZoomer.isChecked()
self.config["defaultZoom"] = self.ui.checkBoxDefaultZoom.isChecked()
self.data.clear() self.data.clear()