diff --git a/src/declarativeimports/core/tooltipdialog.cpp b/src/declarativeimports/core/tooltipdialog.cpp index 9779dfbe7..04c544614 100644 --- a/src/declarativeimports/core/tooltipdialog.cpp +++ b/src/declarativeimports/core/tooltipdialog.cpp @@ -36,12 +36,8 @@ ToolTipDialog::ToolTipDialog(QQuickItem *parent) m_interactive(false), m_owner(nullptr) { - Qt::WindowFlags flags = Qt::ToolTip; - if (KWindowSystem::isPlatformX11()) { - flags = flags | Qt::BypassWindowManagerHint; - } - setFlags(flags); setLocation(Plasma::Types::Floating); + setType(Dialog::WindowType::Tooltip); m_showTimer = new QTimer(this); m_showTimer->setSingleShot(true); diff --git a/src/plasmaquick/dialog.cpp b/src/plasmaquick/dialog.cpp index 0948807e8..c4c1a9a6f 100644 --- a/src/plasmaquick/dialog.cpp +++ b/src/plasmaquick/dialog.cpp @@ -111,6 +111,11 @@ public: void updateMaximumWidth(); void updateMaximumHeight(); + /** + * Gets the maximum and minimum size hints for the window based on the contents. it doesn't actually resize anything + */ + void getSizeHints(QSize &min, QSize &max) const; + /** * This function is an optimized version of updateMaximumHeight, * updateMaximumWidth,updateMinimumWidth and updateMinimumHeight. @@ -292,6 +297,7 @@ void DialogPrivate::updateVisibility(bool visible) } cachedGeometry = QRect(); } + if (mainItem) { syncToMainItemSize(); } @@ -439,7 +445,7 @@ void DialogPrivate::updateMaximumHeight() hintsCommitTimer.start(); } -void DialogPrivate::updateLayoutParameters() +void DialogPrivate::getSizeHints(QSize &min, QSize &max) const { if (!componentComplete || !mainItem || !q->isVisible() || !mainItemLayout) { return; @@ -447,8 +453,6 @@ void DialogPrivate::updateLayoutParameters() Q_ASSERT(mainItem); Q_ASSERT(mainItemLayout); - mainItem->disconnect(q); - auto margin = frameSvgItem->fixedMargins(); int minimumHeight = mainItemLayout->property("minimumHeight").toInt(); @@ -471,8 +475,25 @@ void DialogPrivate::updateLayoutParameters() maximumHeight = qMin(q->screen()->availableGeometry().height(), maximumHeight); } - const QSize finalSize(qBound(minimumWidth, q->width(), maximumWidth), - qBound(minimumHeight, q->height(), maximumHeight)); + min = QSize(minimumWidth, minimumHeight); + max = QSize(maximumWidth, maximumHeight); +} + +void DialogPrivate::updateLayoutParameters() +{ + if (!componentComplete || !mainItem || !q->isVisible() || !mainItemLayout) { + return; + } + + mainItem->disconnect(q); + auto margin = frameSvgItem->fixedMargins(); + + QSize min; + QSize max(DIALOGSIZE_MAX, DIALOGSIZE_MAX); + getSizeHints(min, max); + + const QSize finalSize(qBound(min.width(), q->width(), max.width()), + qBound(min.height(), q->height(), max.height())); if (visualParent) { //it's important here that we're using re->size() as size, we don't want to do recursive resizeEvents @@ -496,8 +517,8 @@ void DialogPrivate::updateLayoutParameters() //FIXME: this seems to interfere with the geometry change that //sometimes is still going on, causing flicker (this one is two repositions happening in quick succession). //it may have to be delayed further - q->setMinimumSize(QSize(minimumWidth, minimumHeight)); - q->setMaximumSize(QSize(maximumWidth, maximumHeight)); + q->setMinimumSize(min); + q->setMaximumSize(max); QObject::connect(mainItem, SIGNAL(widthChanged()), q, SLOT(slotMainItemSizeChanged())); QObject::connect(mainItem, SIGNAL(heightChanged()), q, SLOT(slotMainItemSizeChanged())); @@ -607,10 +628,16 @@ void DialogPrivate::syncToMainItemSize() syncBorders(q->geometry()); } - const QSize s = QSize(mainItem->width(), mainItem->height()) + + QSize s = QSize(mainItem->width(), mainItem->height()) + QSize(frameSvgItem->fixedMargins()->left() + frameSvgItem->fixedMargins()->right(), frameSvgItem->fixedMargins()->top() + frameSvgItem->fixedMargins()->bottom()); + QSize min; + QSize max(DIALOGSIZE_MAX, DIALOGSIZE_MAX); + getSizeHints(min, max); + s = QSize(qBound(min.width(), s.width(), max.width()), + qBound(min.height(), s.height(), max.height())); + q->contentItem()->setSize(s); frameSvgItem->setSize(s); @@ -621,6 +648,7 @@ void DialogPrivate::syncToMainItemSize() if (geom == q->geometry()) { return; } + q->adjustGeometry(geom); // The borders will instantly be updated but the geometry might take a // while as sub-classes can reimplement adjustGeometry and animate it.