From ea6957700591cc3f0c97ebec3179801594c39665 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 19 Aug 2013 17:44:40 +0200 Subject: [PATCH] export fillWidth/fillHeight properties with those should hopefully be possible to have widgets behaving like the taskbar --- .../qml/plasmoid/appletinterface.cpp | 58 +++++++++++++++++++ .../qml/plasmoid/appletinterface.h | 15 +++-- 2 files changed, 69 insertions(+), 4 deletions(-) diff --git a/src/scriptengines/qml/plasmoid/appletinterface.cpp b/src/scriptengines/qml/plasmoid/appletinterface.cpp index b0e489bf0..8248564fc 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.cpp +++ b/src/scriptengines/qml/plasmoid/appletinterface.cpp @@ -473,6 +473,50 @@ int AppletInterface::apiVersion() const return offers.first()->property("X-KDE-PluginInfo-Version", QVariant::Int).toInt(); } +bool AppletInterface::fillWidth() const +{ + if (!m_qmlObject->rootObject()) { + return false; + } + + + QVariant prop; + + if (m_compactUiObject) { + prop = m_compactUiObject.data()->property("fillWidth"); + } else { + prop = m_qmlObject->rootObject()->property("fillWidth"); + } + + if (prop.isValid() && prop.canConvert()) { + return prop.toBool(); + } else { + return false; + } +} + +bool AppletInterface::fillHeight() const +{ + if (!m_qmlObject->rootObject()) { + return false; + } + + + QVariant prop; + + if (m_compactUiObject) { + prop = m_compactUiObject.data()->property("fillHeight"); + } else { + prop = m_qmlObject->rootObject()->property("fillHeight"); + } + + if (prop.isValid() && prop.canConvert()) { + return prop.toBool(); + } else { + return false; + } +} + //private api, just an helper qreal AppletInterface::readGraphicsObjectSizeHint(const char *hint) const { @@ -670,6 +714,13 @@ void AppletInterface::compactRepresentationCheck() connect(m_compactUiObject.data(), SIGNAL(implicitHeightChanged()), this, SIGNAL(implicitHeightChanged())); } + + emit minimumWidthChanged(); + emit minimumHeightChanged(); + emit implicitWidthChanged(); + emit implicitHeightChanged(); + emit maximumWidthChanged(); + emit maximumHeightChanged(); //failed to create UI, don't do anything, return in expanded status } else { m_expanded = true; @@ -715,6 +766,13 @@ void AppletInterface::compactRepresentationCheck() this, SIGNAL(implicitHeightChanged())); } + emit minimumWidthChanged(); + emit minimumHeightChanged(); + emit implicitWidthChanged(); + emit implicitHeightChanged(); + emit maximumWidthChanged(); + emit maximumHeightChanged(); + m_qmlObject->rootObject()->setProperty("parent", QVariant::fromValue(this)); m_compactUiObject.data()->deleteLater(); diff --git a/src/scriptengines/qml/plasmoid/appletinterface.h b/src/scriptengines/qml/plasmoid/appletinterface.h index 147b7f727..626e80e3d 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.h +++ b/src/scriptengines/qml/plasmoid/appletinterface.h @@ -73,8 +73,11 @@ class AppletInterface : public QQuickItem Q_PROPERTY(qreal minimumHeight READ minimumHeight NOTIFY minimumHeightChanged) Q_PROPERTY(qreal maximumWidth READ maximumWidth NOTIFY maximumWidthChanged) Q_PROPERTY(qreal maximumHeight READ maximumHeight NOTIFY maximumHeightChanged) - Q_PROPERTY(qreal implicitWidth READ implicitWidth NOTIFY implicitWidthChanged) - Q_PROPERTY(qreal implicitHeight READ implicitHeight NOTIFY implicitHeightChanged) + //implicitWidth/height is already there + //Q_PROPERTY(qreal implicitWidth READ implicitWidth NOTIFY implicitWidthChanged) + //Q_PROPERTY(qreal implicitHeight READ implicitHeight NOTIFY implicitHeightChanged) + Q_PROPERTY(bool fillWidth READ fillWidth NOTIFY fillWidthChanged) + Q_PROPERTY(bool fillHeight READ fillHeight NOTIFY fillHeightChanged) public: AppletInterface(DeclarativeAppletScript *script, QQuickItem *parent = 0); @@ -150,6 +153,8 @@ public: bool userConfiguring() const; int apiVersion() const; + bool fillWidth() const; + bool fillHeight() const; qreal minimumWidth() const; qreal minimumHeight() const; qreal maximumWidth() const; @@ -176,8 +181,10 @@ Q_SIGNALS: void minimumHeightChanged(); void maximumWidthChanged(); void maximumHeightChanged(); - void implicitWidthChanged(); - void implicitHeightChanged(); + //void implicitWidthChanged(); + //void implicitHeightChanged(); + void fillWidthChanged(); + void fillHeightChanged(); protected: void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);