drop animations from tooltips
tooltips are now animated by a KWin effect, don't try to animate own X11 positions, that's quite dangerous Change-Id: I08ef2bc23ec1ef7cb7c432ba1bf6d9c5b0a0ab01
This commit is contained in:
parent
3224f87c15
commit
ce9751cb35
@ -155,8 +155,6 @@ void ToolTip::showToolTip()
|
|||||||
|
|
||||||
dlg->setOwner(this);
|
dlg->setOwner(this);
|
||||||
|
|
||||||
//if the dialog is not currently visible, disable the animated repositioning
|
|
||||||
dlg->setAnimationsEnabled(dlg->isVisible());
|
|
||||||
dlg->show();
|
dlg->show();
|
||||||
dlg->setLocation(location);
|
dlg->setLocation(location);
|
||||||
dlg->setMainItem(mainItem());
|
dlg->setMainItem(mainItem());
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
#include <QQmlEngine>
|
#include <QQmlEngine>
|
||||||
#include <QQuickItem>
|
#include <QQuickItem>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QPropertyAnimation>
|
|
||||||
|
|
||||||
#include <kdeclarative/qmlobjectsharedengine.h>
|
#include <kdeclarative/qmlobjectsharedengine.h>
|
||||||
|
|
||||||
@ -34,10 +33,8 @@
|
|||||||
ToolTipDialog::ToolTipDialog(QQuickItem *parent)
|
ToolTipDialog::ToolTipDialog(QQuickItem *parent)
|
||||||
: Dialog(parent),
|
: Dialog(parent),
|
||||||
m_qmlObject(0),
|
m_qmlObject(0),
|
||||||
m_animation(0),
|
|
||||||
m_hideTimeout(4000),
|
m_hideTimeout(4000),
|
||||||
m_interactive(false),
|
m_interactive(false),
|
||||||
m_animationsEnabled(true),
|
|
||||||
m_owner(Q_NULLPTR)
|
m_owner(Q_NULLPTR)
|
||||||
{
|
{
|
||||||
Qt::WindowFlags flags = Qt::ToolTip;
|
Qt::WindowFlags flags = Qt::ToolTip;
|
||||||
@ -49,13 +46,6 @@ ToolTipDialog::ToolTipDialog(QQuickItem *parent)
|
|||||||
setFlags(flags);
|
setFlags(flags);
|
||||||
setLocation(Plasma::Types::Floating);
|
setLocation(Plasma::Types::Floating);
|
||||||
|
|
||||||
m_animation = new QPropertyAnimation(this);
|
|
||||||
connect(m_animation, SIGNAL(valueChanged(QVariant)),
|
|
||||||
this, SLOT(valueChanged(QVariant)));
|
|
||||||
m_animation->setTargetObject(this);
|
|
||||||
m_animation->setEasingCurve(QEasingCurve::InOutQuad);
|
|
||||||
m_animation->setDuration(250);
|
|
||||||
|
|
||||||
m_showTimer = new QTimer(this);
|
m_showTimer = new QTimer(this);
|
||||||
m_showTimer->setSingleShot(true);
|
m_showTimer->setSingleShot(true);
|
||||||
connect(m_showTimer, &QTimer::timeout, [ = ]() {
|
connect(m_showTimer, &QTimer::timeout, [ = ]() {
|
||||||
@ -89,7 +79,6 @@ QQuickItem *ToolTipDialog::loadDefaultItem()
|
|||||||
void ToolTipDialog::showEvent(QShowEvent *event)
|
void ToolTipDialog::showEvent(QShowEvent *event)
|
||||||
{
|
{
|
||||||
m_showTimer->start(m_hideTimeout);
|
m_showTimer->start(m_hideTimeout);
|
||||||
m_animation->stop();
|
|
||||||
|
|
||||||
Dialog::showEvent(event);
|
Dialog::showEvent(event);
|
||||||
}
|
}
|
||||||
@ -97,7 +86,6 @@ void ToolTipDialog::showEvent(QShowEvent *event)
|
|||||||
void ToolTipDialog::hideEvent(QHideEvent *event)
|
void ToolTipDialog::hideEvent(QHideEvent *event)
|
||||||
{
|
{
|
||||||
m_showTimer->stop();
|
m_showTimer->stop();
|
||||||
m_animation->stop();
|
|
||||||
|
|
||||||
Dialog::hideEvent(event);
|
Dialog::hideEvent(event);
|
||||||
}
|
}
|
||||||
@ -128,43 +116,6 @@ bool ToolTipDialog::event(QEvent *e)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolTipDialog::adjustGeometry(const QRect &geom)
|
|
||||||
{
|
|
||||||
if (m_animationsEnabled) {
|
|
||||||
QRect startGeom(geometry());
|
|
||||||
|
|
||||||
switch (location()) {
|
|
||||||
case Plasma::Types::RightEdge:
|
|
||||||
startGeom.moveLeft(geom.left());
|
|
||||||
break;
|
|
||||||
case Plasma::Types::BottomEdge:
|
|
||||||
startGeom.moveTop(geom.top());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
startGeom.setSize(geom.size());
|
|
||||||
setGeometry(startGeom);
|
|
||||||
|
|
||||||
m_animation->setStartValue(startGeom.topLeft());
|
|
||||||
m_animation->setEndValue(geom.topLeft());
|
|
||||||
m_animation->start();
|
|
||||||
} else {
|
|
||||||
setGeometry(geom);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ToolTipDialog::animationsEnabled() const
|
|
||||||
{
|
|
||||||
return m_animationsEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ToolTipDialog::setAnimationsEnabled(bool enabled)
|
|
||||||
{
|
|
||||||
m_animationsEnabled = enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
QObject *ToolTipDialog::owner() const
|
QObject *ToolTipDialog::owner() const
|
||||||
{
|
{
|
||||||
return m_owner;
|
return m_owner;
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
|
|
||||||
class QQuickItem;
|
class QQuickItem;
|
||||||
class QGraphicsWidget;
|
class QGraphicsWidget;
|
||||||
class QPropertyAnimation;
|
|
||||||
|
|
||||||
namespace KDeclarative
|
namespace KDeclarative
|
||||||
{
|
{
|
||||||
@ -52,20 +51,12 @@ public:
|
|||||||
Plasma::Types::Direction direction() const;
|
Plasma::Types::Direction direction() const;
|
||||||
void setDirection(Plasma::Types::Direction loc);
|
void setDirection(Plasma::Types::Direction loc);
|
||||||
|
|
||||||
/**
|
|
||||||
* animate the position change if visible
|
|
||||||
*/
|
|
||||||
void adjustGeometry(const QRect &geom) Q_DECL_OVERRIDE;
|
|
||||||
|
|
||||||
void dismiss();
|
void dismiss();
|
||||||
void keepalive();
|
void keepalive();
|
||||||
|
|
||||||
bool interactive();
|
bool interactive();
|
||||||
void setInteractive(bool interactive);
|
void setInteractive(bool interactive);
|
||||||
|
|
||||||
bool animationsEnabled() const;
|
|
||||||
void setAnimationsEnabled(bool enabled);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basically the last one who has shown the dialog
|
* Basically the last one who has shown the dialog
|
||||||
*/
|
*/
|
||||||
@ -84,10 +75,8 @@ private Q_SLOTS:
|
|||||||
private:
|
private:
|
||||||
KDeclarative::QmlObject *m_qmlObject;
|
KDeclarative::QmlObject *m_qmlObject;
|
||||||
QTimer *m_showTimer;
|
QTimer *m_showTimer;
|
||||||
QPropertyAnimation *m_animation;
|
|
||||||
int m_hideTimeout;
|
int m_hideTimeout;
|
||||||
bool m_interactive;
|
bool m_interactive;
|
||||||
bool m_animationsEnabled;
|
|
||||||
QObject *m_owner;
|
QObject *m_owner;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user