mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-01 22:55:41 +08:00
refs #477, load indicator appears in wrong place.
A first improvement by re-centering it when view becomes visible.
This commit is contained in:
committed by
Mathew Sutcliffe
parent
6fda875e8f
commit
42304f640b
@@ -103,10 +103,17 @@ namespace BlackGui
|
|||||||
this->paint(p);
|
this->paint(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CLoadIndicator::isParentVisible() const
|
||||||
|
{
|
||||||
|
if (this->parentWidget()) { return parentWidget()->isVisible(); }
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void CLoadIndicator::paint(QPainter &painter) const
|
void CLoadIndicator::paint(QPainter &painter) const
|
||||||
{
|
{
|
||||||
if (!m_displayedWhenStopped && !isAnimated()) { return; }
|
if (!m_displayedWhenStopped && !isAnimated()) { return; }
|
||||||
if (!this->isVisible() || !this->isEnabled()) { return; }
|
if (!this->isVisible() || !this->isEnabled()) { return; }
|
||||||
|
if (!isParentVisible()) { return; }
|
||||||
|
|
||||||
int width = qMin(this->width(), this->height());
|
int width = qMin(this->width(), this->height());
|
||||||
painter.setRenderHint(QPainter::Antialiasing);
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
|
|||||||
@@ -96,6 +96,9 @@ namespace BlackGui
|
|||||||
//! \copydoc QWidget::paintEvent
|
//! \copydoc QWidget::paintEvent
|
||||||
virtual void paintEvent(QPaintEvent *event) override;
|
virtual void paintEvent(QPaintEvent *event) override;
|
||||||
|
|
||||||
|
//! Is parent widget visible
|
||||||
|
bool isParentVisible() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_angle = 0;
|
int m_angle = 0;
|
||||||
int m_timerId = -1;
|
int m_timerId = -1;
|
||||||
|
|||||||
@@ -158,6 +158,16 @@ namespace BlackGui
|
|||||||
// CStyleSheetUtility::useStyleSheetInDerivedWidget(this, QStyle::PE_Widget);
|
// CStyleSheetUtility::useStyleSheetInDerivedWidget(this, QStyle::PE_Widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CViewBaseNonTemplate::showEvent(QShowEvent *event)
|
||||||
|
{
|
||||||
|
if (this->isShowingLoadIndicator())
|
||||||
|
{
|
||||||
|
// re-center
|
||||||
|
this->centerLoadIndicator();
|
||||||
|
}
|
||||||
|
QTableView::showEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
void CViewBaseNonTemplate::allowDragDropValueObjects(bool allowDrag, bool allowDrop)
|
void CViewBaseNonTemplate::allowDragDropValueObjects(bool allowDrag, bool allowDrop)
|
||||||
{
|
{
|
||||||
// see model for implementing logic of drag
|
// see model for implementing logic of drag
|
||||||
@@ -246,17 +256,21 @@ namespace BlackGui
|
|||||||
|
|
||||||
if (!this->m_loadIndicator)
|
if (!this->m_loadIndicator)
|
||||||
{
|
{
|
||||||
this->m_loadIndicator = new CLoadIndicator(64, 64, this->viewport());
|
this->m_loadIndicator = new CLoadIndicator(64, 64, this);
|
||||||
// connect(this->m_loadIndicator, &CLoadIndicator::updatedAnimation, this, &CViewBaseNonTemplate::ps_updatedIndicator);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
QPoint middle = this->geometry().center();
|
this->centerLoadIndicator();
|
||||||
|
this->m_loadIndicator->startAnimation();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CViewBaseNonTemplate::centerLoadIndicator()
|
||||||
|
{
|
||||||
|
if (!m_loadIndicator) { return; }
|
||||||
|
QPoint middle = this->viewport()->geometry().center();
|
||||||
int w = m_loadIndicator->width();
|
int w = m_loadIndicator->width();
|
||||||
int h = m_loadIndicator->height();
|
int h = m_loadIndicator->height();
|
||||||
int x = middle.x() - w / 2;
|
int x = middle.x() - w / 2;
|
||||||
int y = middle.y() - h / 2;
|
int y = middle.y() - h / 2;
|
||||||
this->m_loadIndicator->setGeometry(x, y, w, h);
|
this->m_loadIndicator->setGeometry(x, y, w, h);
|
||||||
this->m_loadIndicator->startAnimation();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CViewBaseNonTemplate::hideLoadIndicator()
|
void CViewBaseNonTemplate::hideLoadIndicator()
|
||||||
@@ -379,7 +393,7 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
return model->sortContainerByColumn(container, sortColumn, sortOrder);
|
return model->sortContainerByColumn(container, sortColumn, sortOrder);
|
||||||
});
|
});
|
||||||
worker->thenWithResult<ContainerType>(this, [this, resize](const ContainerType &sortedContainer)
|
worker->thenWithResult<ContainerType>(this, [this, resize](const ContainerType & sortedContainer)
|
||||||
{
|
{
|
||||||
this->ps_updateContainer(CVariant::from(sortedContainer), false, resize);
|
this->ps_updateContainer(CVariant::from(sortedContainer), false, resize);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -160,6 +160,9 @@ namespace BlackGui
|
|||||||
//! \copydoc QTableView::paintEvent
|
//! \copydoc QTableView::paintEvent
|
||||||
virtual void paintEvent(QPaintEvent *event) override;
|
virtual void paintEvent(QPaintEvent *event) override;
|
||||||
|
|
||||||
|
//! \copydoc QTableView::showEvent
|
||||||
|
virtual void showEvent(QShowEvent *event) override;
|
||||||
|
|
||||||
//! Perform resizing / non slot method for template
|
//! Perform resizing / non slot method for template
|
||||||
virtual void performModeBasedResizeToContent() = 0;
|
virtual void performModeBasedResizeToContent() = 0;
|
||||||
|
|
||||||
@@ -175,6 +178,9 @@ namespace BlackGui
|
|||||||
//! Resize or skip resize?
|
//! Resize or skip resize?
|
||||||
virtual bool isResizeConditionMet(int containerSize = -1) const;
|
virtual bool isResizeConditionMet(int containerSize = -1) const;
|
||||||
|
|
||||||
|
//! Center / re-center load indicator
|
||||||
|
void centerLoadIndicator();
|
||||||
|
|
||||||
//! Init default values
|
//! Init default values
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user