[app] store window settings and restore upon startup
This commit is contained in:
parent
6008cc03d6
commit
6a73f38fba
@ -3,7 +3,7 @@ import sys
|
||||
import pathlib
|
||||
import ctypes
|
||||
|
||||
from PyQt6.QtCore import QProcess, QSize, QThreadPool, Qt
|
||||
from PyQt6.QtCore import QProcess, QSize, QThreadPool, Qt, QSettings
|
||||
from PyQt6.QtWidgets import (
|
||||
QApplication,
|
||||
QGridLayout,
|
||||
@ -19,6 +19,7 @@ from IPython import embed
|
||||
import numpy as np
|
||||
|
||||
from pyrelacs.util.logging import config_logging
|
||||
import pyrelacs.info as info
|
||||
|
||||
log = config_logging()
|
||||
|
||||
@ -139,10 +140,33 @@ class PyRelacs(QMainWindow):
|
||||
|
||||
def main():
|
||||
app = QApplication(sys.argv)
|
||||
app.setApplicationName(info.NAME)
|
||||
app.setApplicationVersion(str(info.VERSION))
|
||||
app.setOrganizationDomain(info.ORGANIZATION)
|
||||
|
||||
# read window settings
|
||||
settings = QSettings(info.ORGANIZATION, info.NAME)
|
||||
width = int(settings.value("app/width", 1024))
|
||||
height = int(settings.value("app/height", 768))
|
||||
x = int(settings.value("app/pos_x", 100))
|
||||
y = int(settings.value("app/pos_y", 100))
|
||||
|
||||
window = PyRelacs()
|
||||
window.setMinimumWidth(200)
|
||||
window.setMinimumHeight(200)
|
||||
window.resize(width, height)
|
||||
window.move(x, y)
|
||||
window.show()
|
||||
app.exec()
|
||||
|
||||
# store window position and size
|
||||
pos = window.pos()
|
||||
settings.setValue("app/width", window.width())
|
||||
settings.setValue("app/height", window.height())
|
||||
settings.setValue("app/pos_x", pos.x())
|
||||
settings.setValue("app/pos_y", pos.y())
|
||||
sys.exit(exit_code)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in New Issue
Block a user