[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [plasma-framework/mart/AppletAttached] src/declarativeimports/core: propagate sizehints from mainIte
From: Marco Martin <notmart () gmail ! com>
Date: 2014-01-31 19:03:48
Message-ID: E1W9JNU-0005dB-C3 () scm ! kde ! org
[Download RAW message or body]
Git commit 89cb417e9fb36cde82c52b61731ab7c197bbf8a4 by Marco Martin.
Committed on 31/01/2014 at 18:59.
Pushed by mart into branch 'mart/AppletAttached'.
propagate sizehints from mainItem
M +69 -0 src/declarativeimports/core/dialog.cpp
M +8 -0 src/declarativeimports/core/dialog.h
http://commits.kde.org/plasma-framework/89cb417e9fb36cde82c52b61731ab7c197bbf8a4
diff --git a/src/declarativeimports/core/dialog.cpp \
b/src/declarativeimports/core/dialog.cpp index bb746da..a4f5d23 100644
--- a/src/declarativeimports/core/dialog.cpp
+++ b/src/declarativeimports/core/dialog.cpp
@@ -44,6 +44,10 @@
#include <xcb/shape.h>
#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 a76e016..c03cab0 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 <QObject> m_mainItemLayout;
};
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic