diff --git a/CHANGELOG.md b/CHANGELOG.md index 44bb672..b73b86c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## v0.6.2.3_beta — 2026-11-26 + +- Show the installed version at the upper right of the hover monitor above its controls. +- Restore the last size and position of the main monitor and its reusable dialogs. Keep restored windows within the current work area where their content fits. + ## v0.6.2.2_beta — 2026-11-26 - Promote Adaptive Resource Monitor to Beta after verifying the production self-update, restoration of local and remote monitoring, and signed same-number Beta discovery. diff --git a/IMPLEMENTATION_REPORT.md b/IMPLEMENTATION_REPORT.md index b0587fc..64c543a 100644 --- a/IMPLEMENTATION_REPORT.md +++ b/IMPLEMENTATION_REPORT.md @@ -1,5 +1,26 @@ # Adaptive Resource Monitor implementation report +## v0.6.2.3_beta — Hover monitor version and window placement + +Production v0.6.2.2_beta was built from `5e8ea74be3fd94156bdc7a0810cfcc8eaac739f0`. +The earlier hover label and expanded-window geometry corrections were +committed afterward in `d40be62478eb45f572a1555ce22491e4a2cc5eb8`. The +published Beta and its installed executable therefore lacked both changes. + +This Bug-Fix increments only the last numerical counter. The hover monitor +reads VERSION.md through the shared version module and renders it above the +selectors and Pin and Details controls. A shared geometry handler preserves +the existing main-window state file and remembers Settings, Remote Targets, +Remote Machine and Application Details placement. The About layout remains +the same as the previous release. + +The 34 regressions passed. Native Windows checks exercised individual and +All Systems, pinned and unpinned, and a popup anchored to a separate machine +icon. Both themes were checked at effective 100% and 150% scaling using +Qt's per-process scale factor on private Windows desktops. A native geometry +check confirmed exact positioning on reopening and recovery of an off-screen +About window on the current display. + ## v0.6.2.2_beta — Beta promotion Alpha production acceptance and the signed same-number compatibility diff --git a/VERSION.md b/VERSION.md index d45e7a3..367c72e 100644 --- a/VERSION.md +++ b/VERSION.md @@ -1 +1 @@ -v0.6.2.2_beta +v0.6.2.3_beta diff --git a/arm/about.py b/arm/about.py index 671cab6..d54bcd5 100644 --- a/arm/about.py +++ b/arm/about.py @@ -21,6 +21,7 @@ from .branding import ( ) from .version import NAME, VERSION from .update_ui import UpdatePanel +from .window_geometry import WindowGeometry LOG = logging.getLogger(__name__) DOCS = { @@ -232,4 +233,5 @@ class AboutPage(QWidget): buttons.rejected.connect(dialog.reject) layout.addWidget(buttons) dialog.resize(620, dialog.sizeHint().height()) + dialog.window_geometry = WindowGeometry(dialog, self.data_root / "application-details-window.bin") dialog.exec() diff --git a/arm/application.py b/arm/application.py index 45dbd96..71b3616 100644 --- a/arm/application.py +++ b/arm/application.py @@ -11,7 +11,7 @@ from time import time import winreg import psutil -from PySide6.QtCore import QByteArray, QEvent, QLockFile, QObject, QRect, QSignalBlocker, Qt, QTimer, QUrl, Signal +from PySide6.QtCore import QLockFile, QObject, QRect, QSignalBlocker, Qt, QTimer, QUrl, Signal from PySide6.QtGui import QDesktopServices from PySide6.QtWidgets import QApplication, QDialog, QMessageBox, QSystemTrayIcon @@ -27,9 +27,9 @@ from .model import ALL, LOCAL, TOTAL, Connection from .providers.ssh import update_host_key from .tray import HoverMonitor from .tray_menu import TrayMenu -from .update_client import write_atomic from .version import NAME, VERSION from .views import METRIC_NAMES, Monitor +from .window_geometry import WindowGeometry, fit_work_area LOG = logging.getLogger(__name__) RUN_KEY = r"Software\Microsoft\Windows\CurrentVersion\Run" @@ -92,19 +92,7 @@ class Application(QObject): self.expanded = Monitor(self.dashboard, True, self.request_archive, self.open_expanded, self.set_pin, self.about_page) self.expanded.setWindowIcon(self.brand_icon) - self.window_geometry_file = self.root / "monitor-window.bin" - self.saved_window_geometry = None - try: - geometry = self.window_geometry_file.read_bytes() - if self.expanded.restoreGeometry(QByteArray(geometry)): - self.saved_window_geometry = geometry - except FileNotFoundError: - pass - except OSError as exc: - LOG.warning("Could not read monitor window geometry: %s", exc) - self.window_geometry_timer = QTimer(self, singleShot=True, interval=350) - self.window_geometry_timer.timeout.connect(self.save_window_geometry) - self.expanded.installEventFilter(self) + self.window_geometry = WindowGeometry(self.expanded, self.root / "monitor-window.bin") self.popup = Monitor(self.dashboard, False, self.request_archive, self.open_expanded, self.set_pin) for view in (self.popup, self.expanded): view.add_update_banner(self.open_update) @@ -130,34 +118,13 @@ class Application(QObject): self.change_brand_theme() self.configure() - def eventFilter(self, watched, event): - if watched is self.expanded: - if event.type() == QEvent.Type.Hide: - self.window_geometry_timer.stop() - self.save_window_geometry() - elif self.expanded.isVisible() and event.type() in (QEvent.Type.Move, QEvent.Type.Resize, - QEvent.Type.WindowStateChange): - self.window_geometry_timer.start() - return super().eventFilter(watched, event) - - def save_window_geometry(self): - if self.expanded.isMinimized(): - return - if self.expanded.isVisible(): - self.expanded.fit_work_area() - geometry = bytes(self.expanded.saveGeometry()) - if geometry != self.saved_window_geometry: - try: - write_atomic(self.window_geometry_file, geometry) - self.saved_window_geometry = geometry - except OSError as exc: - LOG.warning("Could not save monitor window geometry: %s", exc) - def change_brand_theme(self, scheme=None): scheme = scheme or self.qt.styleHints().colorScheme() self.brand_colors = DARK if scheme == Qt.ColorScheme.Dark else LIGHT self.about_page.theme(self.brand_colors) self.expanded.brand_tabs(self.brand_colors) + self.popup.header.setStyleSheet(f"color: {self.brand_colors.text}") + self.popup.version_label.setStyleSheet(f"color: {self.brand_colors.muted}") for view in (self.popup, self.expanded): view.update_banner.theme(self.brand_colors) for menu in self.menus.values(): @@ -604,7 +571,6 @@ class Application(QObject): updates_stopped = self.about_page.updates.stop() for timer in (self.tray_timer, self.hover_timer, self.view_timer): timer.stop() - self.window_geometry_timer.stop() for icon in self.icons.values(): icon.hide() self.popup.hide() @@ -646,13 +612,13 @@ def main(): state = presentation(transaction) if transaction else {} if state.get("expanded", not controller.settings.minimized): controller.open_expanded() - if not controller.saved_window_geometry and (geometry := state.get("geometry")): + if not controller.window_geometry.saved and (geometry := state.get("geometry")): rect = QRect(*geometry) if any(screen.availableGeometry().intersects(rect) for screen in app.screens()): controller.expanded.setGeometry(rect) if state.get("about"): controller.expanded.tabs.setCurrentWidget(controller.about_page) - controller.expanded.fit_work_area() + fit_work_area(controller.expanded) if transaction: controller.about_page.updates.follow_restart(transaction) signal_ready(root) diff --git a/arm/dialogs.py b/arm/dialogs.py index 5f785fc..4dcf50e 100644 --- a/arm/dialogs.py +++ b/arm/dialogs.py @@ -13,6 +13,7 @@ from PySide6.QtWidgets import ( from .config import TRAY_MODES from .model import DISK_MODES, LOCAL, NETWORK, RANGES, RESOURCES, Connection from .views import fill, interval_choices, machine_choices, plain +from .window_geometry import WindowGeometry def checkbox(value): @@ -122,6 +123,7 @@ class SettingsDialog(QDialog): self.timer.timeout.connect(self.update_diagnostics) self.timer.start() self.update_diagnostics() + self.window_geometry = WindowGeometry(self, app.root / "settings-window.bin") def section(self, title): page = QWidget() @@ -331,6 +333,7 @@ class TargetDialog(QDialog): self.os.currentIndexChanged.connect(update) self.auth.currentIndexChanged.connect(update) update() + self.window_geometry = WindowGeometry(self, app.root / "remote-machine-window.bin") def save(self): host, name, user = (field.text().strip() for field in (self.host, self.name, self.username)) @@ -398,6 +401,7 @@ class ConnectionsDialog(QDialog): app.collectors.changed.connect(self.sync) app.collectors.test_finished.connect(self.test_finished) self.sync() + self.window_geometry = WindowGeometry(self, app.root / "remote-targets-window.bin") def selected(self): row = self.table.currentRow() diff --git a/arm/views.py b/arm/views.py index b13c07c..9e09649 100644 --- a/arm/views.py +++ b/arm/views.py @@ -1,7 +1,7 @@ from time import time, strftime, localtime from PySide6.QtCore import QSize, Qt, QSignalBlocker, QTimer -from PySide6.QtGui import QColor, QGuiApplication, QPalette +from PySide6.QtGui import QColor, QPalette from PySide6.QtWidgets import ( QAbstractItemView, QComboBox, QFrame, QGridLayout, QHeaderView, QHBoxLayout, QLabel, QPushButton, QScrollArea, QSizePolicy, QTableWidget, QTableWidgetItem, QTabWidget, QVBoxLayout, QWidget, @@ -10,6 +10,7 @@ from PySide6.QtWidgets import ( from .graphs import Plot, resource_series, selected_resource from .model import ALL, LOCAL, NETWORK, TOTAL, Connection, INTERVALS, RANGES, RESOURCES, format_value from .version import VERSION +from .window_geometry import fit_work_area METRIC_NAMES = { "cpu.util": "CPU utilization", "cpu.frequency": "Frequency", "cpu.temperature": "CPU temperature", @@ -234,16 +235,16 @@ class Monitor(QWidget): layout = QVBoxLayout(self.resource_page if expanded else self) layout.setContentsMargins(8, 7, 8, 7) layout.setSpacing(4) - layout.addLayout(top) - if expanded: - layout.addWidget(self.header) - else: - status = QHBoxLayout() - status.addWidget(self.header, 1) + if not expanded: version = QLabel(VERSION, textFormat=Qt.TextFormat.PlainText) version.setAccessibleName(f"Installed version {VERSION}") - status.addWidget(version, 0, Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter) - layout.addLayout(status) + font = version.font() + font.setPointSize(8) + version.setFont(font) + layout.addWidget(version, alignment=Qt.AlignmentFlag.AlignRight) + self.version_label = version + layout.addLayout(top) + layout.addWidget(self.header) self.single = QWidget() single_layout = QVBoxLayout(self.single) single_layout.setContentsMargins(0, 0, 0, 0) @@ -286,27 +287,10 @@ class Monitor(QWidget): self.ensurePolished() self.layout().activate() self.show() - self.fit_work_area() + fit_work_area(self) self.raise_() self.activateWindow() - def fit_work_area(self): - if self.isMinimized() or self.isMaximized() or self.isFullScreen(): - return - frame = self.frameGeometry() - screen = QGuiApplication.screenAt(frame.center()) or self.screen() - if screen is None: - return - area = screen.availableGeometry() - if frame.width() > area.width() or frame.height() > area.height(): - self.resize(self.width() - max(0, frame.width() - area.width()), - self.height() - max(0, frame.height() - area.height())) - frame = self.frameGeometry() - x = max(area.left(), min(frame.left(), area.right() - frame.width() + 1)) - y = max(area.top(), min(frame.top(), area.bottom() - frame.height() + 1)) - if (x, y) != (frame.left(), frame.top()): - self.move(x, y) - def brand_tabs(self, colors): self.tabs.setStyleSheet(f""" QTabWidget#armMainTabs::pane {{ border: 1px solid {colors.border}; }} @@ -334,18 +318,19 @@ class Monitor(QWidget): def popup_size(self): cfg = self.dashboard.settings - banner = self.update_banner.sizeHint().height() + self.layout().spacing() if ( + extra = self.version_label.sizeHint().height() + self.layout().spacing() + extra += self.update_banner.sizeHint().height() + self.layout().spacing() if ( hasattr(self, "update_banner") and not self.update_banner.isHidden()) else 0 if self.selected_machine != ALL: - return QSize(cfg.popup_width, cfg.popup_height + banner) + return QSize(cfg.popup_width, cfg.popup_height + extra) # Cap in HoverMonitor against the work area. The scroll area keeps # six columns together even on a narrow monitor. rows_height = sum(max(138, section.sizeHint().height()) for section in self.sections.values()) - return QSize(max(cfg.popup_width, 875), max(cfg.popup_height, rows_height + 72) + banner) + return QSize(max(cfg.popup_width, 875), max(cfg.popup_height, rows_height + 72) + extra) def add_update_banner(self, open_update): self.update_banner = UpdateBanner(open_update) - self.layout().insertWidget(0 if self.expanded else 2, self.update_banner) + self.layout().insertWidget(0 if self.expanded else self.layout().indexOf(self.header) + 1, self.update_banner) def sync_devices(self): if not self.expanded: diff --git a/arm/window_geometry.py b/arm/window_geometry.py new file mode 100644 index 0000000..b9b4cba --- /dev/null +++ b/arm/window_geometry.py @@ -0,0 +1,69 @@ +"""Keep user-facing windows within the work area and remember their placement.""" +import logging + +from PySide6.QtCore import QByteArray, QEvent, QObject, QTimer +from PySide6.QtGui import QGuiApplication + +from .update_client import write_atomic + +LOG = logging.getLogger(__name__) + + +def fit_work_area(window): + if window.isMinimized() or window.isMaximized() or window.isFullScreen(): + return + frame = window.frameGeometry() + screen = QGuiApplication.screenAt(frame.center()) or window.screen() + if screen is None: + return + area = screen.availableGeometry() + if frame.width() > area.width() or frame.height() > area.height(): + window.resize(window.width() - max(0, frame.width() - area.width()), + window.height() - max(0, frame.height() - area.height())) + frame = window.frameGeometry() + x = max(area.left(), min(frame.left(), area.right() - frame.width() + 1)) + y = max(area.top(), min(frame.top(), area.bottom() - frame.height() + 1)) + if (x, y) != (frame.left(), frame.top()): + window.move(x, y) + + +class WindowGeometry(QObject): + def __init__(self, window, path): + super().__init__(window) + self.window, self.path = window, path + self.saved = None + try: + geometry = path.read_bytes() + if window.restoreGeometry(QByteArray(geometry)): + self.saved = geometry + except FileNotFoundError: + pass + except OSError as exc: + LOG.warning("Could not read %s: %s", path.name, exc) + self.timer = QTimer(self, singleShot=True, interval=350) + self.timer.timeout.connect(self.save) + window.installEventFilter(self) + + def eventFilter(self, watched, event): + if event.type() == QEvent.Type.Show: + fit_work_area(watched) + if event.type() == QEvent.Type.Hide: + self.timer.stop() + self.save() + elif watched.isVisible() and event.type() in (QEvent.Type.Show, QEvent.Type.Move, QEvent.Type.Resize, + QEvent.Type.WindowStateChange): + self.timer.start() + return super().eventFilter(watched, event) + + def save(self): + if self.window.isMinimized(): + return + if self.window.isVisible(): + fit_work_area(self.window) + geometry = bytes(self.window.saveGeometry()) + if geometry != self.saved: + try: + write_atomic(self.path, geometry) + self.saved = geometry + except OSError as exc: + LOG.warning("Could not save %s: %s", self.path.name, exc) diff --git a/tests/windows_gui.py b/tests/windows_gui.py index 0c816c0..1759a22 100644 --- a/tests/windows_gui.py +++ b/tests/windows_gui.py @@ -511,6 +511,46 @@ def verify_update_notices(session, wait_for, results, captures): results["verified_shared_update_notices"] = "Verified, ready, rejected, deferred and duplicate notification states" +def verify_hover_version(session, remote, results, captures): + from arm.model import ALL, LOCAL + from arm.version import VERSION + + original = session.settings + hover = session.popup + scale = round(hover.devicePixelRatioF() * 100) + modes = ( + ("individual-unpinned", LOCAL, LOCAL, False), + ("individual-pinned", remote, remote, True), + ("all-systems-unpinned", ALL, LOCAL, False), + ("all-systems-pinned", ALL, remote, True), + ) + try: + for theme in ("Light", "Dark"): + session.apply(replace(original, theme=theme)) + for name, selection, anchor, pinned in modes: + session.hover.pin(False) + session.select_machine(selection, anchor) + session.hover.pin(pinned, anchor) + session.qt.processEvents() + label = hover.version_label + rect = label.geometry() + assert hover.isVisible() and hover.pinned == pinned + assert hover.selected_machine == selection and session.hover.anchor == anchor + assert label.isVisible() and label.text() == VERSION + assert rect.bottom() < hover.machine.geometry().top() + assert rect.right() == hover.width() - hover.layout().contentsMargins().right() - 1 + assert label.fontMetrics().horizontalAdvance(VERSION) <= rect.width() + assert hover.rect().contains(rect) + if captures and theme == ("Light" if scale > 100 else "Dark"): + capture_native_window(int(hover.winId()), captures / f"hover-{name}-{scale}.png") + finally: + session.hover.pin(False) + hover.hide() + session.apply(original) + results["hover_version"] = {"version": VERSION, "scale_percent": scale, + "themes": ["Light", "Dark"], "views": [row[0] for row in modes]} + + def evaluate_app(work, results, short=False, captures=None): import psutil from PySide6.QtCore import QEventLoop, QTimer @@ -730,6 +770,7 @@ def evaluate_app(work, results, short=False, captures=None): session.popup.hide() session.apply(replace(session.settings, separate_tray_icons=True, persistent=True)) assert set(session.icons) == {LOCAL, *(target.identifier for target in targets)} + verify_hover_version(session, primary, results, captures) with patch("arm.application.tray_icon", wraps=tray_icon) as draw: session.render() assert {call.args[1] for call in draw.call_args_list} == {LOCAL, primary, other}