slightly more deterministic tooltip animations
This commit is contained in:
parent
fcbb057dca
commit
65c5c0dfe8
|
@ -169,7 +169,6 @@ void ToolTip::showToolTip()
|
|||
}
|
||||
}
|
||||
|
||||
dlg->setDirection(dir);
|
||||
dlg->setLocation(location);
|
||||
dlg->setMainItem(mainItem());
|
||||
dlg->setVisualParent(this);
|
||||
|
|
|
@ -33,12 +33,10 @@ ToolTipDialog::ToolTipDialog(QQuickItem *parent)
|
|||
m_qmlObject(0),
|
||||
m_animation(0),
|
||||
m_hideTimeout(4000),
|
||||
m_direction(Plasma::Types::Up),
|
||||
m_interactive(false)
|
||||
{
|
||||
setFlags(Qt::ToolTip);
|
||||
setLocation(Plasma::Types::Floating);
|
||||
setDirection(Plasma::Types::Up);
|
||||
|
||||
m_animation = new QPropertyAnimation(this);
|
||||
connect(m_animation, SIGNAL(valueChanged(QVariant)),
|
||||
|
@ -77,16 +75,6 @@ QQuickItem *ToolTipDialog::loadDefaultItem()
|
|||
return qobject_cast<QQuickItem *>(m_qmlObject->rootObject());
|
||||
}
|
||||
|
||||
Plasma::Types::Direction ToolTipDialog::direction() const
|
||||
{
|
||||
return m_direction;
|
||||
}
|
||||
|
||||
void ToolTipDialog::setDirection(Plasma::Types::Direction dir)
|
||||
{
|
||||
m_direction = dir;
|
||||
}
|
||||
|
||||
void ToolTipDialog::showEvent(QShowEvent *event)
|
||||
{
|
||||
m_showTimer->start(m_hideTimeout);
|
||||
|
@ -127,11 +115,11 @@ bool ToolTipDialog::event(QEvent *e)
|
|||
void ToolTipDialog::adjustGeometry(const QRect &geom)
|
||||
{
|
||||
if (isVisible()) {
|
||||
switch (m_direction) {
|
||||
case Plasma::Types::Left:
|
||||
switch (location()) {
|
||||
case Plasma::Types::RightEdge:
|
||||
setX(x() + (size().width() - geom.size().width()));
|
||||
break;
|
||||
case Plasma::Types::Up:
|
||||
case Plasma::Types::BottomEdge:
|
||||
setY(y() + (size().height() - geom.size().height()));
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -79,7 +79,6 @@ private:
|
|||
QTimer *m_showTimer;
|
||||
QPropertyAnimation *m_animation;
|
||||
int m_hideTimeout;
|
||||
Plasma::Types::Direction m_direction;
|
||||
bool m_interactive;
|
||||
};
|
||||
|
||||
|
|
|
@ -239,10 +239,15 @@ void DialogPrivate::updateVisibility(bool visible)
|
|||
void DialogPrivate::updateMinimumWidth()
|
||||
{
|
||||
if (mainItemLayout) {
|
||||
int oldWidth = q->width();
|
||||
q->setMinimumWidth(mainItemLayout.data()->property("minimumWidth").toInt() + frameSvgItem->margins()->left() + frameSvgItem->margins()->right());
|
||||
//Sometimes setMinimumWidth doesn't actually resize: Qt bug?
|
||||
resizeOrigin = DialogPrivate::Window;
|
||||
q->setWidth(qMax(q->width(), q->minimumWidth()));
|
||||
|
||||
if (location == Plasma::Types::RightEdge) {
|
||||
q->setX(q->x() + (oldWidth - q->size().width()));
|
||||
}
|
||||
} else {
|
||||
q->setMinimumWidth(-1);
|
||||
}
|
||||
|
@ -251,10 +256,15 @@ void DialogPrivate::updateMinimumWidth()
|
|||
void DialogPrivate::updateMinimumHeight()
|
||||
{
|
||||
if (mainItemLayout) {
|
||||
int oldHeight = q->height();
|
||||
q->setMinimumHeight(mainItemLayout.data()->property("minimumHeight").toInt() + frameSvgItem->margins()->top() + frameSvgItem->margins()->bottom());
|
||||
//Sometimes setMinimumHeight doesn't actually resize: Qt bug?
|
||||
resizeOrigin = DialogPrivate::Window;
|
||||
q->setHeight(qMax(q->height(), q->minimumHeight()));
|
||||
|
||||
if (location == Plasma::Types::BottomEdge) {
|
||||
q->setY(q->y() + (oldHeight - q->size().height()));
|
||||
}
|
||||
} else {
|
||||
q->setMinimumHeight(-1);
|
||||
}
|
||||
|
@ -548,7 +558,7 @@ void Dialog::setVisualParent(QQuickItem *visualParent)
|
|||
setTransientParent(visualParent->window());
|
||||
}
|
||||
d->resizeOrigin = DialogPrivate::MainItem;
|
||||
d->requestSizeSync();
|
||||
d->requestSizeSync(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user