[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,17 +1,26 @@
|
||||
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:
|
||||
super().__init__(parent=parent)
|
||||
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(500, 750)
|
||||
|
||||
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)
|
||||
@ -47,12 +56,18 @@ class HelpDialog(QDialog):
|
||||
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