[help] store size settings, flake8
This commit is contained in:
parent
464e5421ae
commit
43d7b9a620
@ -14,7 +14,6 @@ except ImportError:
|
||||
pass
|
||||
|
||||
def main():
|
||||
print("executing main.main")
|
||||
app = QApplication(sys.argv)
|
||||
app.setApplicationName(cnst.application_name)
|
||||
app.setApplicationVersion(str(cnst.application_version))
|
||||
@ -33,7 +32,6 @@ def main():
|
||||
window.show()
|
||||
|
||||
code = app.exec_()
|
||||
print("Application exit!")
|
||||
pos = window.pos()
|
||||
settings.setValue("app/width", window.width())
|
||||
settings.setValue("app/height", window.height())
|
||||
|
@ -1,30 +1,39 @@
|
||||
from PyQt5.QtGui import QIcon
|
||||
from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QFrame, QHBoxLayout, QPushButton, QSizePolicy, QTextBrowser, QVBoxLayout, QWidget
|
||||
from PyQt5.QtCore import QUrl
|
||||
from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QFrame, QHBoxLayout
|
||||
from PyQt5.QtWidgets import QPushButton, QSizePolicy, QTextBrowser, QVBoxLayout, QWidget
|
||||
from PyQt5.QtCore import QSettings, QUrl
|
||||
|
||||
import blipblop.constants as cnst
|
||||
|
||||
|
||||
class HelpDialog(QDialog):
|
||||
|
||||
def __init__(self, parent = None) -> None:
|
||||
|
||||
def __init__(self, parent=None) -> None:
|
||||
super().__init__(parent=parent)
|
||||
|
||||
self.setModal(True)
|
||||
self.setMinimumSize(500, 750)
|
||||
self._settings = QSettings()
|
||||
width = int(self._settings.value("help/width", 640))
|
||||
height = int(self._settings.value("help/height", 480))
|
||||
x = int(self._settings.value("help/pos_x", 100))
|
||||
y = int(self._settings.value("help/pos_y", 100))
|
||||
|
||||
self.setModal(True)
|
||||
self.setMinimumSize(640, 480)
|
||||
self.resize(width, height)
|
||||
self.move(x, y)
|
||||
self.finished.connect(self.on_finished)
|
||||
self.help = HelpBrowser()
|
||||
|
||||
self.help._edit.historyChanged.connect(self._on_history_changed)
|
||||
|
||||
|
||||
self.back_btn = QPushButton(QIcon(":/icons/docs_back"), "back")
|
||||
self.back_btn.setEnabled(False)
|
||||
self.back_btn.clicked.connect(self.help._edit.backward)
|
||||
self.home_btn = QPushButton(QIcon(":/icons/docs_home"),"home")
|
||||
self.home_btn = QPushButton(QIcon(":/icons/docs_home"), "home")
|
||||
self.home_btn.clicked.connect(self.help._edit.home)
|
||||
self.fwd_btn = QPushButton(QIcon(":/icons/docs_fwd"),"forward")
|
||||
self.fwd_btn = QPushButton(QIcon(":/icons/docs_fwd"), "forward")
|
||||
self.fwd_btn.setEnabled(False)
|
||||
self.fwd_btn.clicked.connect(self.help._edit.forward)
|
||||
|
||||
|
||||
empty = QWidget()
|
||||
empty.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
|
||||
|
||||
@ -32,8 +41,8 @@ class HelpDialog(QDialog):
|
||||
hbox.addWidget(self.back_btn)
|
||||
hbox.addWidget(self.home_btn)
|
||||
hbox.addWidget(self.fwd_btn)
|
||||
hbox.addWidget(empty)
|
||||
|
||||
hbox.addWidget(empty)
|
||||
|
||||
bbox = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok)
|
||||
bbox.accepted.connect(self.accept)
|
||||
layout = QVBoxLayout()
|
||||
@ -42,17 +51,23 @@ class HelpDialog(QDialog):
|
||||
layout.addWidget(self.help)
|
||||
layout.addWidget(bbox)
|
||||
self.setLayout(layout)
|
||||
|
||||
|
||||
def _on_history_changed(self):
|
||||
self.back_btn.setEnabled(self.help._edit.isBackwardAvailable())
|
||||
self.fwd_btn.setEnabled(self.help._edit.isForwardAvailable())
|
||||
|
||||
def on_finished(self):
|
||||
self._settings.setValue("help/width", self.width())
|
||||
self._settings.setValue("help/height", self.height())
|
||||
self._settings.setValue("help/pos_x", self.x())
|
||||
self._settings.setValue("help/pos_y", self.y())
|
||||
|
||||
|
||||
class HelpBrowser(QWidget):
|
||||
|
||||
def __init__(self, parent=None) -> None:
|
||||
super().__init__(parent=parent)
|
||||
self.setLayout(QVBoxLayout())
|
||||
# FIXME https://stackoverflow.com/a/43217828 about loading from resource files
|
||||
doc_url = QUrl.fromLocalFile(cnst.DOCS_ROOT_FILE)
|
||||
self._edit = QTextBrowser()
|
||||
self._edit.setOpenLinks(True)
|
||||
|
Loading…
Reference in New Issue
Block a user