bit better with animations
This commit is contained in:
parent
c53a00ce4b
commit
1f2f706c10
@ -77,8 +77,6 @@ void ToolTip::showToolTip()
|
||||
mainItem()->setVisible(true);
|
||||
}
|
||||
|
||||
dlg->setMainItem(mainItem());
|
||||
|
||||
//heuristics for knowing the diration
|
||||
Plasma::Types::Direction dir = Plasma::Types::Up;
|
||||
QPoint pos = mapToScene(QPoint(0, 0)).toPoint();
|
||||
@ -99,8 +97,9 @@ void ToolTip::showToolTip()
|
||||
}
|
||||
|
||||
dlg->setDirection(dir);
|
||||
dlg->setVisible(true);
|
||||
dlg->setMainItem(mainItem());
|
||||
dlg->setVisualParent(this);
|
||||
dlg->setVisible(true);
|
||||
}
|
||||
|
||||
QString ToolTip::mainText() const
|
||||
|
@ -77,18 +77,59 @@ Plasma::Types::Direction ToolTipDialog::direction() const
|
||||
return m_direction;
|
||||
}
|
||||
|
||||
void ToolTipDialog::setDirection(Plasma::Types::Direction loc)
|
||||
void ToolTipDialog::setDirection(Plasma::Types::Direction dir)
|
||||
{
|
||||
m_direction = loc;
|
||||
m_direction = dir;
|
||||
}
|
||||
|
||||
void ToolTipDialog::showEvent(QShowEvent *event)
|
||||
{
|
||||
m_showTimer->start(m_hideTimeout);
|
||||
m_animation->stop();
|
||||
|
||||
DialogProxy::showEvent(event);
|
||||
}
|
||||
|
||||
void ToolTipDialog::hideEvent(QHideEvent *event)
|
||||
{
|
||||
m_showTimer->stop();
|
||||
m_animation->stop();
|
||||
|
||||
DialogProxy::hideEvent(event);
|
||||
}
|
||||
|
||||
void ToolTipDialog::resizeEvent(QResizeEvent *re)
|
||||
{
|
||||
//TODO: less duplication
|
||||
if (!m_animation) {
|
||||
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_animation->stop();
|
||||
|
||||
switch (m_direction) {
|
||||
case Plasma::Types::Right:
|
||||
setX(x() + (re->oldSize().width() - re->size().width()));
|
||||
break;
|
||||
case Plasma::Types::Up:
|
||||
setY(y() + (re->oldSize().height() - re->size().height()));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (isVisible()) {
|
||||
m_animation->setStartValue(position());
|
||||
m_animation->setEndValue(popupPosition(visualParent(), Qt::AlignCenter));
|
||||
m_animation->start();
|
||||
}
|
||||
DialogProxy::resizeEvent(re);
|
||||
}
|
||||
|
||||
void ToolTipDialog::adjustPosition(const QPoint &point)
|
||||
{
|
||||
if (isVisible()) {
|
||||
@ -101,19 +142,6 @@ void ToolTipDialog::adjustPosition(const QPoint &point)
|
||||
m_animation->setDuration(250);
|
||||
}
|
||||
|
||||
switch (m_direction) {
|
||||
case Plasma::Types::Left:
|
||||
case Plasma::Types::Right:
|
||||
setX(point.x());
|
||||
break;
|
||||
case Plasma::Types::Up:
|
||||
case Plasma::Types::Down:
|
||||
setY(point.y());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
m_animation->setStartValue(position());
|
||||
m_animation->setEndValue(point);
|
||||
m_animation->start();
|
||||
|
@ -62,6 +62,8 @@ public:
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event);
|
||||
void hideEvent(QHideEvent *event);
|
||||
void resizeEvent(QResizeEvent *re);
|
||||
|
||||
private Q_SLOTS:
|
||||
void valueChanged(const QVariant &value);
|
||||
|
Loading…
Reference in New Issue
Block a user