diff --git a/src/declarativeimports/core/tooltip.cpp b/src/declarativeimports/core/tooltip.cpp index 88ed6bc82..06a8cc6fd 100644 --- a/src/declarativeimports/core/tooltip.cpp +++ b/src/declarativeimports/core/tooltip.cpp @@ -143,14 +143,15 @@ void ToolTip::showToolTip() //heuristics for knowing the diration Plasma::Types::Direction dir; + QPoint pos = mapToScene(QPoint(0, 0)).toPoint(); + + if (window() && window()->screen()) { + pos = window()->mapToGlobal(pos); + } + QPoint popupPos = dlg->popupPosition(this, dlg->size()); + if (location == Plasma::Types::Floating) { dir = Plasma::Types::Up; - QPoint pos = mapToScene(QPoint(0, 0)).toPoint(); - - if (window() && window()->screen()) { - pos = window()->mapToGlobal(pos); - } - QPoint popupPos = dlg->popupPosition(this, dlg->size()); if (pos.y() + height() <= popupPos.y()) { dir = Plasma::Types::Down; @@ -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 diff --git a/src/declarativeimports/core/tooltipdialog.cpp b/src/declarativeimports/core/tooltipdialog.cpp index 60d9fee3b..6815f77a6 100644 --- a/src/declarativeimports/core/tooltipdialog.cpp +++ b/src/declarativeimports/core/tooltipdialog.cpp @@ -126,18 +126,17 @@ bool ToolTipDialog::event(QEvent *e) void ToolTipDialog::adjustGeometry(const QRect &geom) { - switch (m_direction) { - case Plasma::Types::Right: - setX(x() + (size().width() - geom.size().width())); - break; - case Plasma::Types::Up: - setY(y() + (size().height() - geom.size().height())); - break; - default: - break; - } - if (isVisible()) { + switch (m_direction) { + case Plasma::Types::Left: + setX(x() + (size().width() - geom.size().width())); + break; + case Plasma::Types::Up: + setY(y() + (size().height() - geom.size().height())); + break; + default: + break; + } resize(geom.size()); m_animation->setStartValue(position()); diff --git a/src/plasmaquick/dialog.cpp b/src/plasmaquick/dialog.cpp index b8d0f467b..1d2ba95ad 100644 --- a/src/plasmaquick/dialog.cpp +++ b/src/plasmaquick/dialog.cpp @@ -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()),