avoid view sync more than every 150 msecs, avoids cpu hogging and displaying garbage

BUG:206946

svn path=/trunk/KDE/kdelibs/; revision=1062972
This commit is contained in:
Marco Martin 2009-12-16 14:19:10 +00:00
parent 4a708b9351
commit 8e967abc2d
2 changed files with 7 additions and 1 deletions

View File

@ -95,6 +95,7 @@ public:
QMap<Dialog::ResizeCorner, QRect> resizeAreas;
int resizeStartCorner;
QTimer *moveTimer;
QTimer *adjustViewTimer;
Plasma::AspectRatioMode aspectRatioMode;
};
@ -280,6 +281,10 @@ Dialog::Dialog(QWidget *parent, Qt::WindowFlags f)
pal.setColor(backgroundRole(), Qt::transparent);
setPalette(pal);
d->adjustViewTimer = new QTimer(this);
d->adjustViewTimer->setSingleShot(true);
connect(d->adjustViewTimer, SIGNAL(timeout()), this, SLOT(adjustView()));
connect(d->background, SIGNAL(repaintNeeded()), this, SLOT(update()));
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(themeChanged()));
@ -527,7 +532,7 @@ bool Dialog::eventFilter(QObject *watched, QEvent *event)
{
if (d->resizeStartCorner == Dialog::NoCorner && watched == d->graphicsWidget &&
(event->type() == QEvent::GraphicsSceneResize || event->type() == QEvent::GraphicsSceneMove)) {
d->adjustView();
d->adjustViewTimer->start(150);
}
return QWidget::eventFilter(watched, event);

View File

@ -167,6 +167,7 @@ class PLASMA_EXPORT Dialog : public QWidget
* React to theme changes
*/
Q_PRIVATE_SLOT(d, void themeChanged())
Q_PRIVATE_SLOT(d, void adjustView())
};
} // Plasma namespace