diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2021-03-30 23:18:15 +0200 |
---|---|---|
committer | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2021-03-31 13:41:39 +0200 |
commit | f299fa37f992be20f01c130bb407b321e0c69d63 (patch) | |
tree | dcfaf64893ee3f1884778266d4dbd0f4669beec2 | |
parent | 01fb69e198b3dfdccd3a0de5a3f12973d7811dc0 (diff) | |
download | subsurface-f299fa37f992be20f01c130bb407b321e0c69d63.tar.gz |
stats: fix visibility check of the statistics tab on desktop
Apparently, the visibility flag of the view is not inherited
from the statistics widget. Therefore, the statistics is
redrawn on every action even if not visible.
Set the visibility explicitly in the show- and hide-events.
This is crazy.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r-- | desktop-widgets/statswidget.cpp | 13 | ||||
-rw-r--r-- | desktop-widgets/statswidget.h | 1 |
2 files changed, 14 insertions, 0 deletions
diff --git a/desktop-widgets/statswidget.cpp b/desktop-widgets/statswidget.cpp index 465d5d496..6b936915f 100644 --- a/desktop-widgets/statswidget.cpp +++ b/desktop-widgets/statswidget.cpp @@ -93,6 +93,8 @@ StatsWidget::StatsWidget(QWidget *parent) : QWidget(parent) view = qobject_cast<StatsView *>(root); if (!view) qWarning("Oops. The root of the StatsView is not a StatsView."); + if (view) + view->setVisible(isVisible()); // Synchronize visibility of widget and QtQuick-view. } // Initialize QComboBox with list of variables @@ -209,6 +211,17 @@ void StatsWidget::showEvent(QShowEvent *e) unrestrict(); updateUi(); QWidget::showEvent(e); + // Apparently, we have to manage the visibility of the view ourselves. That's mad. + if (view) + view->setVisible(true); +} + +void StatsWidget::hideEvent(QHideEvent *e) +{ + QWidget::hideEvent(e); + // Apparently, we have to manage the visibility of the view ourselves. That's mad. + if (view) + view->setVisible(false); } void StatsWidget::restrict() diff --git a/desktop-widgets/statswidget.h b/desktop-widgets/statswidget.h index 4ae86a015..c3397d613 100644 --- a/desktop-widgets/statswidget.h +++ b/desktop-widgets/statswidget.h @@ -37,6 +37,7 @@ private: ChartListModel charts; void showEvent(QShowEvent *) override; + void hideEvent(QHideEvent *) override; }; #endif // STATSWIDGET_H |