Use comboBox for zoom level selection

Signed-off-by: Juraj Oravec <sgd.orava@gmail.com>
This commit is contained in:
Juraj Oravec 2019-05-16 13:07:52 +02:00
parent 846da6c17f
commit fe02f16a92
No known key found for this signature in database
GPG Key ID: 63ACB65056BC8D07
4 changed files with 44 additions and 21 deletions

View File

@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# ============================================================ # ============================================================
import Falkon
import os import os
from PySide2 import QtCore, QtWidgets, QtUiTools from PySide2 import QtCore, QtWidgets, QtUiTools
@ -35,6 +36,9 @@ class ListItem(QtWidgets.QWidget):
layout.addWidget(self.ui) layout.addWidget(self.ui)
self.setLayout(layout) self.setLayout(layout)
for level in Falkon.WebView.zoomLevels():
self.ui.comboBoxZoomLevel.addItem(str(level) + '%')
def active(self): def active(self):
return self.ui.checkBoxActive.isChecked() return self.ui.checkBoxActive.isChecked()
@ -42,7 +46,7 @@ class ListItem(QtWidgets.QWidget):
return self.ui.labelHost.text() return self.ui.labelHost.text()
def zoom(self): def zoom(self):
return self.ui.spinBoxZoomLevel.value() return self.ui.comboBoxZoomLevel.currentIndex()
def setActive(self, active): def setActive(self, active):
active = bool(active) active = bool(active)
@ -54,4 +58,4 @@ class ListItem(QtWidgets.QWidget):
def setZoom(self, zoom): def setZoom(self, zoom):
zoom = int(zoom) zoom = int(zoom)
self.ui.spinBoxZoomLevel.setValue(zoom) self.ui.comboBoxZoomLevel.setCurrentIndex(zoom)

View File

@ -6,10 +6,16 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>354</width> <width>387</width>
<height>30</height> <height>28</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
@ -24,7 +30,7 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1,0"> <layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0">
<item> <item>
<widget class="QCheckBox" name="checkBoxActive"> <widget class="QCheckBox" name="checkBoxActive">
<property name="text"> <property name="text">
@ -40,11 +46,20 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QSpinBox" name="spinBoxZoomLevel"> <spacer name="horizontalSpacer">
<property name="maximum"> <property name="orientation">
<number>18</number> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> <property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="comboBoxZoomLevel"/>
</item> </item>
</layout> </layout>
</item> </item>

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>390</width> <width>520</width>
<height>334</height> <height>358</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -30,21 +30,20 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QSpinBox" name="spinBoxNew"> <widget class="QComboBox" name="comboBoxNew"/>
<property name="maximum">
<number>18</number>
</property>
<property name="value">
<number>6</number>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0">
<item> <item>
<widget class="QListWidget" name="listWidget"> <widget class="QListWidget" name="listWidget">
<property name="minimumSize">
<size>
<width>400</width>
<height>200</height>
</size>
</property>
<property name="sizeAdjustPolicy"> <property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustIgnored</enum> <enum>QAbstractScrollArea::AdjustIgnored</enum>
</property> </property>

View File

@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# ============================================================ # ============================================================
import Falkon
import os import os
from PySide2 import QtCore, QtWidgets, QtUiTools from PySide2 import QtCore, QtWidgets, QtUiTools
from autoZoomer.listItem import ListItem from autoZoomer.listItem import ListItem
@ -46,6 +47,10 @@ class SettingsDialog(QtWidgets.QDialog):
layout.addWidget(self.ui) layout.addWidget(self.ui)
self.setLayout(layout) self.setLayout(layout)
for level in Falkon.WebView.zoomLevels():
self.ui.comboBoxNew.addItem(str(level) + '%')
self.ui.comboBoxNew.setCurrentIndex(Falkon.WebView.zoomLevels().index(100))
self.translations() self.translations()
self.ui.checkBoxEnableAutoZoomer.setChecked(self.config["active"]) self.ui.checkBoxEnableAutoZoomer.setChecked(self.config["active"])
@ -122,7 +127,7 @@ class SettingsDialog(QtWidgets.QDialog):
def handleItemAdd(self): def handleItemAdd(self):
host = self.ui.lineEditNew.text() host = self.ui.lineEditNew.text()
zoom = self.ui.spinBoxNew.value() zoom = self.ui.comboBoxNew.currentIndex()
if not host: if not host:
return return