From 1b9d6cbb137a1f2f0c0615caeee38415516634b9 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 6 Sep 2013 18:36:12 +0200 Subject: [PATCH] experiment support for panel auto resize --- .../qml/plasmoid/containmentinterface.cpp | 36 +++++++++++++++++++ .../desktop/contents/views/Panel.qml | 31 ++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.cpp b/src/scriptengines/qml/plasmoid/containmentinterface.cpp index 814cc20ea..df2d02165 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.cpp +++ b/src/scriptengines/qml/plasmoid/containmentinterface.cpp @@ -92,6 +92,42 @@ void ContainmentInterface::init() if (!m_appletInterfaces.isEmpty()) { emit appletsChanged(); } + + if (m_qmlObject->rootObject()->property("minimumWidth").isValid()) { + connect(m_qmlObject->rootObject(), SIGNAL(minimumWidthChanged()), + this, SIGNAL(minimumWidthChanged())); + } + if (m_qmlObject->rootObject()->property("minimumHeight").isValid()) { + connect(m_qmlObject->rootObject(), SIGNAL(minimumHeightChanged()), + this, SIGNAL(minimumHeightChanged())); + } + + if (m_qmlObject->rootObject()->property("maximumWidth").isValid()) { + connect(m_qmlObject->rootObject(), SIGNAL(maximumWidthChanged()), + this, SIGNAL(maximumWidthChanged())); + } + if (m_qmlObject->rootObject()->property("maximumHeight").isValid()) { + connect(m_qmlObject->rootObject(), SIGNAL(maximumHeightChanged()), + this, SIGNAL(maximumHeightChanged())); + } + + if (m_qmlObject->rootObject()->property("implicitWidth").isValid()) { + connect(m_qmlObject->rootObject(), SIGNAL(implicitWidthChanged()), + this, SIGNAL(implicitWidthChanged())); + } + if (m_qmlObject->rootObject()->property("implicitHeight").isValid()) { + connect(m_qmlObject->rootObject(), SIGNAL(implicitHeightChanged()), + this, SIGNAL(implicitHeightChanged())); + } + + emit fillWidthChanged(); + emit fillHeightChanged(); + emit minimumWidthChanged(); + emit minimumHeightChanged(); + emit implicitWidthChanged(); + emit implicitHeightChanged(); + emit maximumWidthChanged(); + emit maximumHeightChanged(); } QList ContainmentInterface::applets() diff --git a/src/shell/qmlpackages/desktop/contents/views/Panel.qml b/src/shell/qmlpackages/desktop/contents/views/Panel.qml index c5da6c950..341f860e5 100644 --- a/src/shell/qmlpackages/desktop/contents/views/Panel.qml +++ b/src/shell/qmlpackages/desktop/contents/views/Panel.qml @@ -80,6 +80,37 @@ PlasmaCore.FrameSvgItem { onLocationChanged: { adjustBorders() } + onMinimumWidthChanged: { + if (containment.formFactor === PlasmaCore.Types.Horizontal) { + panel.width = Math.max(panel.width, containment.minimumWidth); + } + } + onMaximumWidthChanged: { + if (containment.formFactor === PlasmaCore.Types.Horizontal) { + panel.width = Math.min(panel.width, containment.maximumWidth); + } + } + onImplicitWidthChanged: { + if (containment.formFactor === PlasmaCore.Types.Horizontal) { + panel.width = Math.min(containment.maximumWidth, Math.max(containment.implicitWidth, containment.minimumWidth)); + } + } + + onMinimumHeightChanged: { + if (containment.formFactor === PlasmaCore.Types.Vertical) { + panel.width = Math.max(panel.width, containment.minimumHeight); + } + } + onMaximumHeightChanged: { + if (containment.formFactor === PlasmaCore.Types.Vertical) { + panel.width = Math.min(panel.width, containment.maximumHeight); + } + } + onImplicitHeightChanged: { + if (containment.formFactor === PlasmaCore.Types.Vertical) { + panel.width = Math.min(containment.maximumHeight, Math.max(containment.implicitHeight, containment.minimumHeight)); + } + } } Connections {