animate that mofo tip!
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=878938
This commit is contained in:
parent
c40e327130
commit
7d5c604245
@ -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 @@ class ToolTipPrivate
|
||||
imageLabel(0),
|
||||
preview(0),
|
||||
source(0),
|
||||
timeline(0),
|
||||
autohide(true)
|
||||
{ }
|
||||
|
||||
@ -53,6 +56,9 @@ class ToolTipPrivate
|
||||
WindowPreview *preview;
|
||||
FrameSvg *background;
|
||||
QPointer<QObject> source;
|
||||
QTimeLine *timeline;
|
||||
QPoint to;
|
||||
QPoint from;
|
||||
bool autohide;
|
||||
};
|
||||
|
||||
@ -117,6 +123,13 @@ void ToolTip::setContent(const ToolTipContent &data)
|
||||
|
||||
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 @@ void ToolTip::prepareShowing(bool cueUpdate)
|
||||
|
||||
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);
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
|
||||
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 @@ protected:
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateTheme();
|
||||
void animateMove(qreal);
|
||||
|
||||
private:
|
||||
ToolTipPrivate * const d;
|
||||
|
@ -308,7 +308,7 @@ void ToolTipManagerPrivate::showToolTip()
|
||||
//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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user