From 8e967abc2d1471db1ba35ebcb68f3f5526bb33dd Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 16 Dec 2009 14:19:10 +0000 Subject: [PATCH] avoid view sync more than every 150 msecs, avoids cpu hogging and displaying garbage BUG:206946 svn path=/trunk/KDE/kdelibs/; revision=1062972 --- dialog.cpp | 7 ++++++- dialog.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/dialog.cpp b/dialog.cpp index 70facb8b7..2b148994a 100644 --- a/dialog.cpp +++ b/dialog.cpp @@ -95,6 +95,7 @@ public: QMap 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); diff --git a/dialog.h b/dialog.h index 3a83b097c..76e11cd43 100644 --- a/dialog.h +++ b/dialog.h @@ -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