Fix navigation expansion overlay

Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
Loren Eteval
2026-08-13 23:14:44 +08:00
parent 10f57db24e
commit d919a1b486
2 changed files with 30 additions and 3 deletions
+5
View File
@@ -316,6 +316,11 @@ class AppStyleSheet:
background-color: {palette['panel_alt']};
}}
QFrame#NavigationRailPlaceholder {{
border: none;
background-color: {palette['panel_alt']};
}}
QStackedWidget#ApplicationPageStack {{
border: none;
background-color: {palette['window']};
+25 -3
View File
@@ -162,12 +162,21 @@ class NavigationView(Mixins.QTranslatable, Mixins.ThemeAware, QWidget):
self.pageStack = QStackedWidget(parent=self)
self.pageStack.setObjectName('ApplicationPageStack')
# Keep the layout's navigation reservation at the compact rail width.
# The real panel is a sibling overlay, mirroring Fluent NavigationView:
# expanding it changes only the panel geometry, never the page geometry.
self.navigationRail = QFrame(parent=self)
self.navigationRail.setObjectName('NavigationRailPlaceholder')
self.navigationRail.setFixedWidth(self.CollapsedWidth)
self._layout = QHBoxLayout(self)
self._layout.setContentsMargins(0, 0, 0, 0)
self._layout.setSpacing(0)
self._layout.addWidget(self.navigationPanel)
self._layout.addWidget(self.navigationRail)
self._layout.addWidget(self.pageStack, 1)
self.navigationPanel.raise_()
self._widthAnimation = QtCore.QPropertyAnimation(
self,
b'navigationWidth',
@@ -324,9 +333,16 @@ class NavigationView(Mixins.QTranslatable, Mixins.ThemeAware, QWidget):
return self._navigationWidth
def _setNavigationWidth(self, width: int):
"""Apply an animated width to the navigation panel."""
"""Apply an animated overlay width without resizing the page stack."""
self._navigationWidth = int(width)
self.navigationPanel.setFixedWidth(self._navigationWidth)
self.navigationPanel.setGeometry(
0,
0,
self._navigationWidth,
self.height(),
)
self.navigationPanel.raise_()
navigationWidth = QtCore.Property(
int,
@@ -345,6 +361,12 @@ class NavigationView(Mixins.QTranslatable, Mixins.ThemeAware, QWidget):
if not self._expanded:
self._setPageButtonsExpanded(False)
def resizeEvent(self, event):
"""Keep the navigation overlay as tall as the page container."""
super().resizeEvent(event)
self._setNavigationWidth(self._navigationWidth)
@staticmethod
def _refreshWidgetStyle(widget: QWidget):
"""Re-polish a widget after a dynamic property changes."""