aboutsummaryrefslogtreecommitdiffstats
path: root/sb_builder
diff options
context:
space:
mode:
Diffstat (limited to 'sb_builder')
-rw-r--r--sb_builder/__main__.py1
-rw-r--r--sb_builder/mainwindow.py39
2 files changed, 35 insertions, 5 deletions
diff --git a/sb_builder/__main__.py b/sb_builder/__main__.py
index 7571bd6..239b405 100644
--- a/sb_builder/__main__.py
+++ b/sb_builder/__main__.py
@@ -34,7 +34,6 @@ def main():
app.setDesktopFileName("sb-builder") # Wayland: match sb-builder.desktop
cfg, err = config.load()
w = MainWindow(cfg, Remote(cfg))
- w.resize(1100, 700)
w.show()
if err:
QMessageBox.warning(w, "Config error", f"{err}\nUsing defaults.")
diff --git a/sb_builder/mainwindow.py b/sb_builder/mainwindow.py
index c6ea02e..f63a4ba 100644
--- a/sb_builder/mainwindow.py
+++ b/sb_builder/mainwindow.py
@@ -16,13 +16,14 @@
"""Main window: tabs, status bar, connection polling, VM control, notifications."""
+import os
import time
-from PyQt6.QtCore import QMetaType, QObject, QSize, Qt, QTimer, pyqtSignal, pyqtSlot
+from PyQt6.QtCore import QSettings, QMetaType, QObject, QSize, Qt, QTimer, pyqtSignal, pyqtSlot
from PyQt6.QtDBus import QDBusArgument, QDBusConnection, QDBusInterface, QDBusMessage
from PyQt6.QtGui import QIcon, QKeySequence, QShortcut
-from PyQt6.QtWidgets import (QLabel, QMainWindow, QMessageBox, QPushButton, QStyle, QTabWidget,
- QToolBar, QToolButton)
+from PyQt6.QtWidgets import (QHeaderView, QLabel, QMainWindow, QMessageBox, QPushButton, QSplitter,
+ QStyle, QTabWidget, QToolBar, QToolButton)
from . import VERSION, config
from .dashboard import Dashboard
@@ -79,8 +80,11 @@ class Notifier(QObject):
class MainWindow(QMainWindow):
- def __init__(self, cfg, remote, notifier=None):
+ def __init__(self, cfg, remote, notifier=None, state=None):
super().__init__()
+ # window size, column widths, splitters: kept across runs, apart from config.toml
+ self.state = QSettings(state or os.path.join(os.path.dirname(config.path()), "state.conf"),
+ QSettings.Format.IniFormat)
self.cfg, self.remote = cfg, remote
self.notifier = notifier or Notifier(self)
self.notifier.clicked.connect(self.open_job)
@@ -156,6 +160,8 @@ class MainWindow(QMainWindow):
self.stats_timer = QTimer(self, timeout=self.poll_slow)
self._start_timers()
QTimer.singleShot(0, self.poll_jobs)
+ self.resize(1100, 700)
+ self._restore_view()
# ── polling ─────────────────────────────────────────────────────────────
@@ -400,6 +406,31 @@ class MainWindow(QMainWindow):
if jid:
self.open_jobs().select(jid)
+ # ── view state ──────────────────────────────────────────────────────────
+
+ def _views(self):
+ """(key, widget) of every table header and splitter in the tabs."""
+ # ponytail: keyed by tab class and creation order; a reordered layout
+ # restores the wrong widths once, then saves the right ones
+ for tab in (self.dashboard, self.packages_tab, self.hints_tab, self.results_tab, self.jobs_tab):
+ for kind in (QHeaderView, QSplitter):
+ for n, w in enumerate(tab.findChildren(kind)):
+ yield f"{type(tab).__name__}/{kind.__name__}{n}", w
+
+ def _restore_view(self):
+ if self.state.value("geometry"):
+ self.restoreGeometry(self.state.value("geometry"))
+ for key, w in self._views():
+ if self.state.value(key):
+ w.restoreState(self.state.value(key))
+
+ def closeEvent(self, event):
+ self.state.setValue("geometry", self.saveGeometry())
+ for key, w in self._views():
+ self.state.setValue(key, w.saveState())
+ self.state.sync()
+ super().closeEvent(event)
+
def reload_config(self):
cfg, err = config.load()
if err: