mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-16 09:29:55 +00:00
Fix repaint() when resizing
When resizing windows in tile view the update is a bit wonky when you have a video window on screen. The layout code now repaints the entire homewindow when one of the charts are resized.
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
GcWindowLayout::GcWindowLayout(QWidget *parent, int margin, int hSpacing, int vSpacing)
|
||||
: QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing)
|
||||
: QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing), parent(parent)
|
||||
{
|
||||
setContentsMargins(margin, margin, margin, margin);
|
||||
}
|
||||
@@ -155,6 +155,9 @@ int GcWindowLayout::doLayout(const QRect &rect, bool testOnly) const
|
||||
// Charts already positioned are held here
|
||||
QList <QRect> placed;
|
||||
|
||||
// if not in test mode, set updates enabled before we repaint
|
||||
if (!testOnly) parent->setUpdatesEnabled(false);
|
||||
|
||||
// iterate through each chart, placing it in the
|
||||
// most optimal location top to bottom then
|
||||
// left to right (packed flow)
|
||||
@@ -256,6 +259,10 @@ int GcWindowLayout::doLayout(const QRect &rect, bool testOnly) const
|
||||
|
||||
}
|
||||
|
||||
// if not in test mode, set updates enabled before we repaint
|
||||
if (!testOnly) parent->setUpdatesEnabled(true);
|
||||
parent->repaint();
|
||||
|
||||
// Return the length of the layout
|
||||
int maxy=0;
|
||||
foreach(QRect geom, placed) {
|
||||
@@ -268,13 +275,5 @@ int GcWindowLayout::doLayout(const QRect &rect, bool testOnly) const
|
||||
|
||||
int GcWindowLayout::smartSpacing(QStyle::PixelMetric pm) const
|
||||
{
|
||||
QObject *parent = this->parent();
|
||||
if (!parent) {
|
||||
return -1;
|
||||
} else if (parent->isWidgetType()) {
|
||||
QWidget *pw = static_cast<QWidget *>(parent);
|
||||
return pw->style()->pixelMetric(pm, 0, pw);
|
||||
} else {
|
||||
return static_cast<QLayout *>(parent)->spacing();
|
||||
}
|
||||
return parent->style()->pixelMetric(pm, 0, parent);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user