Skip to content

Commit

Permalink
Provide centered frame layout for scene reports
Browse files Browse the repository at this point in the history
  • Loading branch information
zkovari committed Oct 4, 2024
1 parent b3b6800 commit 429e5d2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
30 changes: 24 additions & 6 deletions src/main/python/plotlyst/view/reports_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down
16 changes: 3 additions & 13 deletions ui/report/scene_report.ui
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,9 @@
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<property name="topMargin">
<number>30</number>
</property>
<item>
<widget class="ChartView" name="chartViewActDistribution"/>
</item>
Expand Down

0 comments on commit 429e5d2

Please sign in to comment.