don't make the tooltip dance

note: this is different from the "dancing dialog" bug.
the tooltip should now appear in the proper position
and behave reasonably good
This commit is contained in:
Marco Martin 2014-04-17 20:05:14 +02:00
parent d488420dcb
commit 13016a42b4
3 changed files with 23 additions and 24 deletions

View File

@ -143,8 +143,6 @@ void ToolTip::showToolTip()
//heuristics for knowing the diration
Plasma::Types::Direction dir;
if (location == Plasma::Types::Floating) {
dir = Plasma::Types::Up;
QPoint pos = mapToScene(QPoint(0, 0)).toPoint();
if (window() && window()->screen()) {
@ -152,6 +150,9 @@ void ToolTip::showToolTip()
}
QPoint popupPos = dlg->popupPosition(this, dlg->size());
if (location == Plasma::Types::Floating) {
dir = Plasma::Types::Up;
if (pos.y() + height() <= popupPos.y()) {
dir = Plasma::Types::Down;
} else if (pos.x() + width() <= popupPos.x()) {
@ -163,6 +164,11 @@ void ToolTip::showToolTip()
}
} else {
dir = Plasma::locationToDirection(location);
if (dir == Plasma::Types::Left && (pos.x() + width() <= popupPos.x())) {
dir = Plasma::Types::Right;
} else if (dir == Plasma::Types::Up && (pos.y() + height() <= popupPos.y())) {
dir = Plasma::Types::Down;
}
}
dlg->setDirection(dir);
@ -170,7 +176,7 @@ void ToolTip::showToolTip()
dlg->setMainItem(mainItem());
dlg->setVisualParent(this);
dlg->setInteractive(m_interactive);
dlg->setVisible(true);
QMetaObject::invokeMethod(dlg, "show", Qt::QueuedConnection);
}
QString ToolTip::mainText() const

View File

@ -126,8 +126,9 @@ bool ToolTipDialog::event(QEvent *e)
void ToolTipDialog::adjustGeometry(const QRect &geom)
{
if (isVisible()) {
switch (m_direction) {
case Plasma::Types::Right:
case Plasma::Types::Left:
setX(x() + (size().width() - geom.size().width()));
break;
case Plasma::Types::Up:
@ -137,8 +138,6 @@ void ToolTipDialog::adjustGeometry(const QRect &geom)
break;
}
if (isVisible()) {
resize(geom.size());
m_animation->setStartValue(position());
m_animation->setEndValue(geom.topLeft());

View File

@ -392,12 +392,6 @@ Dialog::Dialog(QQuickItem *parent)
connect(d->syncTimer, SIGNAL(timeout()),
this, SLOT(syncToMainItemSize()));
connect(this, &QWindow::xChanged, [=]() {
d->requestSyncToMainItemSize(true);
});
connect(this, &QWindow::yChanged, [=]() {
d->requestSyncToMainItemSize(true);
});
connect(this, SIGNAL(visibleChanged(bool)),
this, SLOT(updateInputShape()));
connect(this, SIGNAL(outputOnlyChanged()),