From 429e5d2cbdcc03376ba3d54b8a70411b18cb4400 Mon Sep 17 00:00:00 2001 From: Zsolt Kovari Date: Fri, 4 Oct 2024 14:36:14 +0200 Subject: [PATCH] Provide centered frame layout for scene reports --- src/main/python/plotlyst/view/reports_view.py | 30 +++++++++++++++---- ui/report/scene_report.ui | 16 ++-------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/main/python/plotlyst/view/reports_view.py b/src/main/python/plotlyst/view/reports_view.py index 01fb390b1..98666edb3 100644 --- a/src/main/python/plotlyst/view/reports_view.py +++ b/src/main/python/plotlyst/view/reports_view.py @@ -22,9 +22,9 @@ from typing import Optional, List from PyQt6.QtGui import QShowEvent -from PyQt6.QtWidgets import QWidget +from PyQt6.QtWidgets import QWidget, QFrame from overrides import overrides -from qthandy import bold, vbox +from qthandy import bold, vbox, hbox from qthandy.filter import OpacityEventFilter from plotlyst.common import PLOTLYST_SECONDARY_COLOR @@ -64,9 +64,17 @@ def __init__(self, novel: Novel, parent=None): vbox(self) - self._scrollarea, self._wdgCenter = scrolled(self) - vbox(self._wdgCenter) - self._wdgCenter.setProperty('relaxed-white-bg', True) + self._scrollarea, self._wdgCenter = scrolled(self, frameless=True) + hbox(self._wdgCenter) + if self._hasFrame(): + self._wdgFrame = QFrame() + self._wdgCenter.layout().addWidget(self._wdgFrame) + self._wdgFrame.setProperty('relaxed-white-bg', True) + self._wdgFrame.setProperty('large-rounded', True) + hbox(self._wdgFrame, 20, 0) + self._wdgFrame.setMaximumWidth(1200) + else: + self._wdgCenter.setProperty('relaxed-white-bg', True) self._dispatcher = event_dispatchers.instance(self._novel) self._dispatcher.register(self, NovelSyncEvent) @@ -75,7 +83,10 @@ def __init__(self, novel: Novel, parent=None): def showEvent(self, event: QShowEvent) -> None: if self._report is None: self._report = self._initReport() - self._wdgCenter.layout().addWidget(self._report) + if self._hasFrame(): + self._wdgFrame.layout().addWidget(self._report) + else: + self._wdgCenter.layout().addWidget(self._report) elif self._refreshNext: self.refresh() self._refreshNext = False @@ -91,6 +102,9 @@ def refresh(self): if self._report: self._report.refresh() + def _hasFrame(self) -> bool: + return False + @abstractmethod def _initReport(self) -> AbstractReport: pass @@ -113,6 +127,10 @@ def __init__(self, novel: Novel, parent=None): self._dispatcher.register(self, SceneChangedEvent, SceneDeletedEvent, CharacterChangedEvent, CharacterDeletedEvent, NovelStoryStructureUpdated) + @overrides + def _hasFrame(self) -> bool: + return True + @overrides def _initReport(self): return SceneReport(self._novel) diff --git a/ui/report/scene_report.ui b/ui/report/scene_report.ui index cb070c144..1f88efa63 100644 --- a/ui/report/scene_report.ui +++ b/ui/report/scene_report.ui @@ -31,19 +31,9 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - + + 30 +