OSDN Git Service

plasma: do not adjust Plasma::ScrollWidget on timer
authorIvailo Monev <xakepa10@gmail.com>
Thu, 14 Sep 2023 12:04:06 +0000 (15:04 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Thu, 14 Sep 2023 12:04:06 +0000 (15:04 +0300)
while the compression of the scrollbars adjustment has its gain the visual
glitches that resizing on timer causes are not worth it

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
plasma/widgets/scrollwidget.cpp
plasma/widgets/scrollwidget.h

index 0bc9535..2155b4f 100644 (file)
@@ -119,10 +119,6 @@ public:
         borderSvg = new Plasma::Svg(q);
         borderSvg->setImagePath("widgets/scrollwidget");
 
-        adjustScrollbarsTimer = new QTimer(q);
-        adjustScrollbarsTimer->setSingleShot(true);
-        QObject::connect(adjustScrollbarsTimer, SIGNAL(timeout()), q, SLOT(adjustScrollbars()));
-
         wheelTimer =  new QTimer(q);
         wheelTimer->setSingleShot(true);
 
@@ -1035,7 +1031,6 @@ public:
     QString styleSheet;
     QWeakPointer<QGraphicsWidget> widgetToBeVisible;
     QRectF rectToBeVisible;
-    QTimer *adjustScrollbarsTimer;
     QTimer *wheelTimer;
 
     QPointF pressPos;
@@ -1115,7 +1110,7 @@ void ScrollWidget::setWidget(QGraphicsWidget *widget)
         widget->setParentItem(d->scrollingWidget);
         widget->setPos(d->minXExtent(), d->minYExtent());
         widget->installEventFilter(this);
-        d->adjustScrollbarsTimer->start(200);
+        d->adjustScrollbars();
     }
 }
 
@@ -1290,7 +1285,7 @@ void ScrollWidget::resizeEvent(QGraphicsSceneResizeEvent *event)
         return;
     }
 
-    d->adjustScrollbarsTimer->start(200);
+    d->adjustScrollbars();
 
     //if topBorder exists bottomBorder too
     if (d->topBorder) {
@@ -1375,7 +1370,7 @@ bool ScrollWidget::eventFilter(QObject *watched, QEvent *event)
         emit viewportGeometryChanged(viewportGeometry());
     } else if (watched == d->widget.data() && event->type() == QEvent::GraphicsSceneResize) {
         d->stopAnimations();
-        d->adjustScrollbarsTimer->start(200);
+        d->adjustScrollbars();
         updateGeometry();
 
         QPointF newPos = d->widget.data()->pos();
index a4def8d..e557613 100644 (file)
@@ -56,7 +56,6 @@ class PLASMA_EXPORT ScrollWidget : public QGraphicsWidget
     Q_PROPERTY(bool overShoot READ hasOverShoot WRITE setOverShoot)
 
 public:
-
     /**
      * Constructs a new ScrollWidget
      *
@@ -173,7 +172,6 @@ public:
      */
     QRectF viewportGeometry() const;
 
-
     /**
      * @return the size of the internal widget
      * @since 4.4
@@ -230,7 +228,7 @@ Q_SIGNALS:
      * @since 4.4
      */
     void scrollStateChanged(QAbstractAnimation::State newState,
-            QAbstractAnimation::State oldState);
+                            QAbstractAnimation::State oldState);
 
     /**
      * The viewport geomety changed, for instance due a widget resize
@@ -258,7 +256,6 @@ private:
     Q_PRIVATE_SLOT(d, void horizontalScroll(int value))
     Q_PRIVATE_SLOT(d, void makeRectVisible())
     Q_PRIVATE_SLOT(d, void makeItemVisible())
-    Q_PRIVATE_SLOT(d, void adjustScrollbars())
     Q_PRIVATE_SLOT(d, void fixupX())
     Q_PRIVATE_SLOT(d, void fixupY())
     Q_PRIVATE_SLOT(d, void setScrollX())