AutoZoomer/autoZoomer/listItem.py

62 lines
2.0 KiB
Python
Raw Permalink Normal View History

# ============================================================
# Auto Zoomer - 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/>.
# ============================================================
import Falkon
import os
from PySide2 import QtCore, QtWidgets, QtUiTools
class ListItem(QtWidgets.QWidget):
ui = None
def __init__(self, parent=None):
super().__init__(parent)
file = QtCore.QFile(os.path.join(os.path.dirname(__file__), "listItem.ui"))
file.open(QtCore.QFile.ReadOnly)
self.ui = QtUiTools.QUiLoader().load(file, self)
file.close()
layout = QtWidgets.QVBoxLayout(self)
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()
def host(self):
return self.ui.labelHost.text()
def zoom(self):
return self.ui.comboBoxZoomLevel.currentIndex()
def setActive(self, active):
active = bool(active)
self.ui.checkBoxActive.setChecked(active)
def setHost(self, host):
host = str(host)
self.ui.labelHost.setText(host)
def setZoom(self, zoom):
zoom = int(zoom)
self.ui.comboBoxZoomLevel.setCurrentIndex(zoom)