Release hover version and window placement fixes
This commit is contained in:
47
arm/views.py
47
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:
|
||||
|
||||
Reference in New Issue
Block a user