[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/workspace/libs/plasma
From:       Aaron J. Seigo <aseigo () kde ! org>
Date:       2008-11-02 7:25:57
Message-ID: 1225610757.940314.32354.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 878938 by aseigo:

animate that mofo tip!


 M  +52 -0     private/tooltip.cpp  
 M  +2 -1      private/tooltip_p.h  
 M  +1 -1      tooltipmanager.cpp  


--- trunk/KDE/kdebase/workspace/libs/plasma/private/tooltip.cpp #878937:878938
@@ -27,9 +27,11 @@
 #include <QMouseEvent>
 #include <QPainter>
 #include <QPalette>
+#include <QTimeLine>
 
 #include <KDebug>
 #include <KGlobal>
+#include <KGlobalSettings>
 
 #include <plasma/plasma.h>
 #include <plasma/theme.h>
@@ -45,6 +47,7 @@
           imageLabel(0),
           preview(0),
           source(0),
+          timeline(0),
           autohide(true)
     { }
 
@@ -53,6 +56,9 @@
     WindowPreview *preview;
     FrameSvg *background;
     QPointer<QObject> source;
+    QTimeLine *timeline;
+    QPoint to;
+    QPoint from;
     bool autohide;
 };
 
@@ -117,6 +123,13 @@
 
     if (isVisible()) {
         d->preview->setInfo();
+
+        QSize hint = sizeHint();
+        QSize current = size();
+
+        if (hint != current) {
+            move(x(), y() + (current.height() - hint.height()));
+        }
         resize(sizeHint());
     }
 }
@@ -136,9 +149,48 @@
 
     layout()->activate();
     d->preview->setInfo();
+
+    QSize hint = sizeHint();
+    QSize current = size();
+
+    if (hint != current) {
+        move(x(), y() + (current.height() - hint.height()));
+    }
     resize(sizeHint());
 }
 
+void ToolTip::moveTo(const QPoint &to)
+{
+    if (!isVisible() ||
+        !(KGlobalSettings::graphicEffectsLevel() & \
KGlobalSettings::SimpleAnimationEffects)) { +        move(to);
+        return;
+    }
+
+    d->from = pos();
+    d->to = to;
+
+    if (!d->timeline) {
+        d->timeline = new QTimeLine(250, this);
+        d->timeline->setFrameRange(0, 10);
+        connect(d->timeline, SIGNAL(valueChanged(qreal)), this, \
SLOT(animateMove(qreal))); +    }
+
+    d->timeline->stop();
+    d->timeline->start();
+}
+
+void ToolTip::animateMove(qreal progress)
+{
+    if (qFuzzyCompare(progress, 1.0)) {
+        move(d->to);
+        return;
+    }
+
+    move(d->from.x() + ((d->to.x() - d->from.x()) * progress),
+         d->from.y() + ((d->to.y() - d->from.y()) * progress));
+}
+
 void ToolTip::resizeEvent(QResizeEvent *e)
 {
     QWidget::resizeEvent(e);
--- trunk/KDE/kdebase/workspace/libs/plasma/private/tooltip_p.h #878937:878938
@@ -39,7 +39,7 @@
 
     void setContent(const ToolTipContent &data);
     void prepareShowing(bool cueUpdate);
-    void setActivated(bool value);
+    void moveTo(const QPoint &to);
     bool autohide() const;
 
 protected:
@@ -52,6 +52,7 @@
 
 private Q_SLOTS:
     void updateTheme();
+    void animateMove(qreal);
 
 private:
     ToolTipPrivate * const d;
--- trunk/KDE/kdebase/workspace/libs/plasma/tooltipmanager.cpp #878937:878938
@@ -308,7 +308,7 @@
     //kDebug() << "about to show" << justCreated;
     tipWidget->setContent(tooltip);
     tipWidget->prepareShowing(!justCreated);
-    tipWidget->move(ToolTipManager::self()->m_corona->popupPosition(currentWidget, \
tipWidget->size())); +    \
tipWidget->moveTo(ToolTipManager::self()->m_corona->popupPosition(currentWidget, \
tipWidget->size()));  tipWidget->show();
     isShown = true;  //ToolTip is visible
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic