From 1177cd862a8115ae4a932c6583dcf375f3f0f99d Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Fri, 6 Jan 2017 20:40:21 +0100 Subject: [PATCH] refs #855, re-center load indicator when resizing load overview --- .../components/dbloadoverviewcomponent.cpp | 28 +++++++++++++++++-- .../components/dbloadoverviewcomponent.h | 10 +++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/blackgui/components/dbloadoverviewcomponent.cpp b/src/blackgui/components/dbloadoverviewcomponent.cpp index 76dbb7e13..84b9fb39a 100644 --- a/src/blackgui/components/dbloadoverviewcomponent.cpp +++ b/src/blackgui/components/dbloadoverviewcomponent.cpp @@ -31,7 +31,7 @@ namespace BlackGui Q_ASSERT_X(sGui->getWebDataServices(), Q_FUNC_INFO, "no data services"); ui->setupUi(this); - admitCaches(); // in background + this->admitCaches(); // in background ui->lbl_DatabaseUrl->setTextFormat(Qt::RichText); ui->lbl_DatabaseUrl->setTextInteractionFlags(Qt::TextBrowserInteraction); @@ -92,6 +92,28 @@ namespace BlackGui ui->tb_SharedReloadDistributors->setVisible(visible); } + void CDbLoadOverviewComponent::resizeEvent(QResizeEvent *event) + { + if (this->isShowingLoadIndicator()) + { + // re-center + this->centerLoadIndicator(); + } + QFrame::resizeEvent(event); + } + + bool CDbLoadOverviewComponent::isShowingLoadIndicator() const + { + return m_loadIndicator && this->isVisible() && m_loadIndicator->isAnimated(); + } + + void CDbLoadOverviewComponent::centerLoadIndicator() + { + if (!m_loadIndicator) { return; } + const QPoint middle = this->visibleRegion().boundingRect().center(); + this->m_loadIndicator->centerLoadIndicator(middle); + } + void CDbLoadOverviewComponent::ps_setValues() { if (!sGui) { return; } @@ -172,8 +194,8 @@ namespace BlackGui { this->m_loadIndicator = new CLoadIndicator(64, 64, this); } - const QPoint middle = this->rect().center(); - this->m_loadIndicator->centerLoadIndicator(middle); + + this->centerLoadIndicator(); this->m_loadIndicator->startAnimation(true); } diff --git a/src/blackgui/components/dbloadoverviewcomponent.h b/src/blackgui/components/dbloadoverviewcomponent.h index 11712af64..034478488 100644 --- a/src/blackgui/components/dbloadoverviewcomponent.h +++ b/src/blackgui/components/dbloadoverviewcomponent.h @@ -47,11 +47,21 @@ namespace BlackGui //! Visible shared refresh buttons void setVisibleSharedRefreshButtons(bool visible); + //! Showing load indicator? + bool isShowingLoadIndicator() const; + signals: //! Trigger GUI update //! \private void ps_triggerDigestGuiUpdate(); + protected: + //! \copydoc QWidget::resizeEvent + virtual void resizeEvent(QResizeEvent *event) override; + + //! Center load indicator + void centerLoadIndicator(); + private: QScopedPointer ui; BlackGui::CLoadIndicator *m_loadIndicator = nullptr; //!< load indicator if needed