diff --git a/src/scriptengines/qml/plasmoid/appletinterface.cpp b/src/scriptengines/qml/plasmoid/appletinterface.cpp index 8304347ad..70faad94a 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.cpp +++ b/src/scriptengines/qml/plasmoid/appletinterface.cpp @@ -80,6 +80,10 @@ AppletInterface::AppletInterface(DeclarativeAppletScript *script, QQuickItem *pa m_creationTimer = new QTimer(this); m_creationTimer->setSingleShot(true); connect(m_creationTimer, &QTimer::timeout, this, &AppletInterface::init); + + m_collapseTimer = new QTimer(this); + m_collapseTimer->setSingleShot(true); + connect(m_collapseTimer, &QTimer::timeout, this, &AppletInterface::compactRepresentationCheck); } AppletInterface::~AppletInterface() @@ -569,7 +573,11 @@ void AppletInterface::geometryChanged(const QRectF &newGeometry, const QRectF &o Q_UNUSED(oldGeometry) QQuickItem::geometryChanged(newGeometry, oldGeometry); + m_collapseTimer->start(100); +} +void AppletInterface::compactRepresentationCheck() +{ if (!m_qmlObject->rootObject() || qobject_cast(this)) { return; } @@ -584,7 +592,7 @@ void AppletInterface::geometryChanged(const QRectF &newGeometry, const QRectF &o } //TODO: completely arbitrary for now - if (newGeometry.width() < minHint.width() || newGeometry.height() < minHint.height()) { + if (width() < minHint.width() || height() < minHint.height()) { m_expanded = false; //we are already an icon: nothing to do diff --git a/src/scriptengines/qml/plasmoid/appletinterface.h b/src/scriptengines/qml/plasmoid/appletinterface.h index 8de54ad4c..4461c9f10 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.h +++ b/src/scriptengines/qml/plasmoid/appletinterface.h @@ -180,12 +180,17 @@ Q_SIGNALS: void implicitHeightChanged(); protected: - virtual void init(); void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); void itemChange(ItemChange change, const ItemChangeData &value); DeclarativeAppletScript *m_appletScriptEngine; +protected Q_SLOTS: + virtual void init(); + +private Q_SLOTS: + void compactRepresentationCheck(); + private: //Helper for minimumWidth etc. qreal readGraphicsObjectSizeHint(const char *hint) const; @@ -203,6 +208,7 @@ private: QWeakPointer m_compactUiObject; QTimer *m_creationTimer; + QTimer *m_collapseTimer; Plasma::Types::BackgroundHints m_backgroundHints; bool m_busy : 1;