diff --git a/src/declarativeimports/core/dialog.cpp b/src/declarativeimports/core/dialog.cpp index bb746da63..a4f5d23d0 100644 --- a/src/declarativeimports/core/dialog.cpp +++ b/src/declarativeimports/core/dialog.cpp @@ -44,6 +44,10 @@ #include #endif +//Unfortunately QWINDOWSIZE_MAX is not exported +#define DIALOGSIZE_MAX ((1<<24)-1) + + DialogProxy::DialogProxy(QQuickItem *parent) : QQuickWindow(parent ? parent->window() : 0), m_location(Plasma::Types::BottomEdge), @@ -111,6 +115,35 @@ void DialogProxy::setMainItem(QQuickItem *mainItem) m_syncTimer->stop(); syncToMainItemSize(); } + + //Extract the representation's Layout, if any + QObject *layout = 0; + + //Search a child that has the needed Layout properties + //HACK: here we are not type safe, but is the only way to access to a pointer of Layout + foreach (QObject *child, mainItem->children()) { + //find for the needed property of Layout: minimum/maximum/preferred sizes and fillWidth/fillHeight + if (child->property("minimumWidth").isValid() && child->property("minimumHeight").isValid() && + child->property("preferredWidth").isValid() && child->property("preferredHeight").isValid() && + child->property("maximumWidth").isValid() && child->property("maximumHeight").isValid() && + child->property("fillWidth").isValid() && child->property("fillHeight").isValid() + ) { + layout = child; + } + } + m_mainItemLayout = layout; + + if (layout) { + connect(layout, SIGNAL(minimumWidthChanged()), this, SLOT(updateMinimumWidth())); + connect(layout, SIGNAL(minimumHeightChanged()), this, SLOT(updateMinimumHeight())); + connect(layout, SIGNAL(maximumWidthChanged()), this, SLOT(updatemaximumWidth())); + connect(layout, SIGNAL(maximumHeightChanged()), this, SLOT(updatemaximumHeight())); + + updateMinimumWidth(); + updateMinimumHeight(); + updateMaximumWidth(); + updateMaximumHeight(); + } } //if this is called in Component.onCompleted we have to wait a loop the item is added to a scene @@ -559,5 +592,41 @@ void DialogProxy::updateInputShape() #endif } +void DialogProxy::updateMinimumWidth() +{ + if (m_mainItemLayout) { + setMinimumWidth(m_mainItemLayout.data()->property("minimumWidth").toInt()); + } else { + setMinimumWidth(-1); + } +} + +void DialogProxy::updateMinimumHeight() +{ + if (m_mainItemLayout) { + setMinimumHeight(m_mainItemLayout.data()->property("minimumHeight").toInt()); + } else { + setMinimumHeight(-1); + } +} + +void DialogProxy::updateMaximumWidth() +{ + if (m_mainItemLayout) { + setMaximumWidth(m_mainItemLayout.data()->property("maximumWidth").toInt()); + } else { + setMaximumWidth(DIALOGSIZE_MAX); + } +} + +void DialogProxy::updateMaximumHeight() +{ + if (m_mainItemLayout) { + setMaximumHeight(m_mainItemLayout.data()->property("maximumWidth").toInt()); + } else { + setMaximumHeight(DIALOGSIZE_MAX); + } +} + #include "dialog.moc" diff --git a/src/declarativeimports/core/dialog.h b/src/declarativeimports/core/dialog.h index a76e01635..c03cab0ab 100644 --- a/src/declarativeimports/core/dialog.h +++ b/src/declarativeimports/core/dialog.h @@ -171,12 +171,20 @@ private Q_SLOTS: void updateVisibility(bool visible); + void updateMinimumWidth(); + void updateMinimumHeight(); + void updateMaximumWidth(); + void updateMaximumHeight(); + private: QRect m_cachedGeometry; WindowType m_type; bool m_hideOnWindowDeactivate; bool m_outputOnly; Plasma::Theme m_theme; + + //Attached Layout property of mainItem, if any + QWeakPointer m_mainItemLayout; }; #endif