From b402591cdfb8db4278410a3d1ba9e5bdc1f94939 Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 2 Nov 2026 13:18:21 +0100 Subject: [PATCH] fix: adaptive empty state, escaped button ampersand, no tenant preselection for APs - Empty states hide icon and text when space is short instead of being squeezed; title and button always stay readable - "Standorte & Mandanten" button no longer shows a mnemonic underscore - The tenant on the access point page is always chosen deliberately Co-Authored-By: Claude Opus 5.5 --- netbox_sync/ui/pages/access_points.py | 5 +++-- netbox_sync/ui/widgets.py | 26 ++++++++++++++++---------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/netbox_sync/ui/pages/access_points.py b/netbox_sync/ui/pages/access_points.py index 17eb7c3..464a4ac 100644 --- a/netbox_sync/ui/pages/access_points.py +++ b/netbox_sync/ui/pages/access_points.py @@ -144,7 +144,7 @@ class AccessPointsPage(Page): self.body.addWidget(source) result = Card("Abgleich") - self.sites_button = result.add_action(button("Standorte & Mandanten …", "globe", on_click=self.map_sites)) + self.sites_button = result.add_action(button("Standorte && Mandanten …", "globe", on_click=self.map_sites)) self.refresh_button = result.add_action(button("Neu abgleichen", "refresh", on_click=self.compare)) filters = QHBoxLayout() self.search = SearchField("Name, S/N, MAC, IP, Standort …") @@ -269,7 +269,8 @@ class AccessPointsPage(Page): def done(result): self.tenants, roles = result settings = self._settings() - self.tenant.set_items(self.tenants, settings.get("tenant_id")) + # The tenant is always chosen deliberately – never preselected. + self.tenant.set_items(self.tenants) role_id = settings.get("role_id") or next( (role_id for name, role_id in roles if name.casefold() in ROLE_HINTS or "access point" in name.casefold()), None) diff --git a/netbox_sync/ui/widgets.py b/netbox_sync/ui/widgets.py index 5dd47a4..2ea67fe 100644 --- a/netbox_sync/ui/widgets.py +++ b/netbox_sync/ui/widgets.py @@ -257,20 +257,26 @@ class EmptyState(QWidget): layout.addStretch(2) layout.setContentsMargins(24, 16, 24, 16) - def minimumSizeHint(self): - # Word-wrapped labels report almost no minimum height, so a small card - # would squeeze icon, title and text on top of each other. - width = max(self.width(), 320) - 48 - height = 32 + 56 + self.title_label.heightForWidth(width) + self.text_label.heightForWidth(min(width, 520)) - height += 2 * 10 + def _heights(self, width): + width = max(width, 320) - 48 + core = 32 + self.title_label.heightForWidth(width) + 10 if self.action is not None: - height += 16 + self.action.sizeHint().height() - return QSize(260, height) + core += 16 + self.action.sizeHint().height() + return core, self.text_label.heightForWidth(min(width, 520)) + 10, 56 + 10 + + def minimumSizeHint(self): + # Title and button always fit; icon and text are dropped when space is short. + core, _text, _icon = self._heights(self.width()) + return QSize(260, core) def resizeEvent(self, event): super().resizeEvent(event) - if event.size().width() != event.oldSize().width(): - self.updateGeometry() + # Word-wrapped labels report almost no minimum height, so a small card + # would squeeze icon, title, text and button on top of each other. + core, text, icon_height = self._heights(event.size().width()) + available = event.size().height() + self.text_label.setVisible(available >= core + text) + self.icon_label.setVisible(available >= core + text + icon_height) def set_text(self, title=None, text=None): if title is not None: