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/>.
# ============================================================
import Falkon
import os
from PySide2 import QtCore, QtWidgets, QtUiTools
@ -35,6 +36,9 @@ class ListItem(QtWidgets.QWidget):
layout.addWidget(self.ui)
self.setLayout(layout)
for level in Falkon.WebView.zoomLevels():
self.ui.comboBoxZoomLevel.addItem(str(level) + '%')
def active(self):
return self.ui.checkBoxActive.isChecked()
@ -42,7 +46,7 @@ class ListItem(QtWidgets.QWidget):
return self.ui.labelHost.text()
def zoom(self):
return self.ui.spinBoxZoomLevel.value()
return self.ui.comboBoxZoomLevel.currentIndex()
def setActive(self, active):
active = bool(active)
@ -54,4 +58,4 @@ class ListItem(QtWidgets.QWidget):
def setZoom(self, zoom):
zoom = int(zoom)
self.ui.spinBoxZoomLevel.setValue(zoom)
self.ui.comboBoxZoomLevel.setCurrentIndex(zoom)

View File

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

View File

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

View File

@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ============================================================
import Falkon
import os
from PySide2 import QtCore, QtWidgets, QtUiTools
from autoZoomer.listItem import ListItem
@ -46,6 +47,10 @@ class SettingsDialog(QtWidgets.QDialog):
layout.addWidget(self.ui)
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.ui.checkBoxEnableAutoZoomer.setChecked(self.config["active"])
@ -122,7 +127,7 @@ class SettingsDialog(QtWidgets.QDialog):
def handleItemAdd(self):
host = self.ui.lineEditNew.text()
zoom = self.ui.spinBoxNew.value()
zoom = self.ui.comboBoxNew.currentIndex()
if not host:
return