From f299fa37f992be20f01c130bb407b321e0c69d63 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 30 Mar 2021 23:18:15 +0200 Subject: [PATCH] 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 --- desktop-widgets/statswidget.cpp | 13 +++++++++++++ desktop-widgets/statswidget.h | 1 + 2 files changed, 14 insertions(+) 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(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