diff --git a/src/plasma/applet.cpp b/src/plasma/applet.cpp index 2da99243a..473e7a626 100644 --- a/src/plasma/applet.cpp +++ b/src/plasma/applet.cpp @@ -360,6 +360,21 @@ void Applet::setIcon(const QString &icon) emit iconChanged(icon); } +bool Applet::isBusy() const +{ + return d->busy; +} + +void Applet::setBusy(bool busy) +{ + if (busy == d->busy) { + return; + } + + d->busy = busy; + emit busyChanged(busy); +} + KPluginInfo Applet::pluginInfo() const { return d->appletDescription; diff --git a/src/plasma/applet.h b/src/plasma/applet.h index c3ab03049..449f761d3 100644 --- a/src/plasma/applet.h +++ b/src/plasma/applet.h @@ -73,6 +73,7 @@ class PLASMA_EXPORT Applet : public QObject Q_PROPERTY(Plasma::Types::Location location READ location NOTIFY locationChanged) Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL) Q_PROPERTY(QString icon READ icon WRITE setIcon NOTIFY iconChanged FINAL) + Q_PROPERTY(bool busy READ isBusy WRITE setBusy NOTIFY busyChanged FINAL) public: //CONSTRUCTORS @@ -323,6 +324,23 @@ public: */ void setIcon(const QString &icon); + /** + * @returns true if the applet should show a busy status, for instance doing + * some network operation + * @since 5.21 + */ + bool isBusy() const; + + /** + * Sets the Applet to have a busy status hint, for instance the applet doing + * some network operation. + * The graphical representation of the busy status depends completely from + * the visualization. + * @param busy true if the applet is busy + * @since 5.21 + */ + void setBusy(bool busy); + //ACTIONS /** * Returns a list of context-related QAction instances. @@ -431,6 +449,12 @@ Q_SIGNALS: */ void iconChanged(const QString &icon); + /** + * Emitted when the busy status has changed + * @since 5.21 + */ + void busyChanged(bool busy); + //CONFIGURATION /** * Emitted when an applet has changed values in its configuration diff --git a/src/plasma/private/applet_p.cpp b/src/plasma/private/applet_p.cpp index 14b1debaa..67b423ce6 100644 --- a/src/plasma/private/applet_p.cpp +++ b/src/plasma/private/applet_p.cpp @@ -74,7 +74,8 @@ AppletPrivate::AppletPrivate(KService::Ptr service, const KPluginInfo *info, int needsConfig(false), started(false), globalShortcutEnabled(false), - userConfiguring(false) + userConfiguring(false), + busy(false) { if (appletId == 0) { appletId = ++s_maxAppletId; diff --git a/src/plasma/private/applet_p.h b/src/plasma/private/applet_p.h index 312d302bc..157fb1fee 100644 --- a/src/plasma/private/applet_p.h +++ b/src/plasma/private/applet_p.h @@ -119,6 +119,7 @@ public: bool started : 1; bool globalShortcutEnabled : 1; bool userConfiguring : 1; + bool busy : 1; }; } // Plasma namespace diff --git a/src/scriptengines/qml/plasmoid/appletinterface.cpp b/src/scriptengines/qml/plasmoid/appletinterface.cpp index 941303ee5..876af2ced 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.cpp +++ b/src/scriptengines/qml/plasmoid/appletinterface.cpp @@ -56,7 +56,6 @@ AppletInterface::AppletInterface(DeclarativeAppletScript *script, const QVariant m_toolTipItem(0), m_args(args), m_backgroundHints(Plasma::Types::StandardBackground), - m_busy(false), m_hideOnDeactivate(true), m_oldKeyboardShortcut(0), m_dummyNativeInterface(0), @@ -86,6 +85,9 @@ AppletInterface::AppletInterface(DeclarativeAppletScript *script, const QVariant connect(applet(), &Plasma::Applet::iconChanged, this, &AppletInterface::iconChanged); + connect(applet(), &Plasma::Applet::busyChanged, + this, &AppletInterface::busyChanged); + connect(applet(), &Plasma::Applet::activated, this, &AppletInterface::activated); @@ -125,7 +127,6 @@ AppletInterface::AppletInterface(Plasma::Applet *a, const QVariantList &args, QQ m_toolTipTextFormat(0), m_args(args), m_backgroundHints(Plasma::Types::StandardBackground), - m_busy(false), m_hideOnDeactivate(true), m_oldKeyboardShortcut(0), m_dummyNativeInterface(0), @@ -151,6 +152,15 @@ AppletInterface::AppletInterface(Plasma::Applet *a, const QVariantList &args, QQ connect(applet(), &Plasma::Applet::destroyedChanged, this, &AppletInterface::destroyedChanged); + connect(applet(), &Plasma::Applet::titleChanged, + this, &AppletInterface::titleChanged); + + connect(applet(), &Plasma::Applet::iconChanged, + this, &AppletInterface::iconChanged); + + connect(applet(), &Plasma::Applet::busyChanged, + this, &AppletInterface::busyChanged); + connect(appletScript(), &DeclarativeAppletScript::formFactorChanged, this, &AppletInterface::formFactorChanged); connect(appletScript(), &DeclarativeAppletScript::locationChanged, @@ -385,17 +395,12 @@ void AppletInterface::setToolTipItem(QQuickItem *toolTipItem) bool AppletInterface::isBusy() const { - return m_busy; + return applet()->isBusy(); } void AppletInterface::setBusy(bool busy) { - if (m_busy == busy) { - return; - } - - m_busy = busy; - emit busyChanged(); + applet()->setBusy(busy); } Plasma::Types::BackgroundHints AppletInterface::backgroundHints() const diff --git a/src/scriptengines/qml/plasmoid/appletinterface.h b/src/scriptengines/qml/plasmoid/appletinterface.h index 4a186ff49..6cf71aa9d 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.h +++ b/src/scriptengines/qml/plasmoid/appletinterface.h @@ -428,7 +428,6 @@ private: QPointer m_toolTipItem; QVariantList m_args; Plasma::Types::BackgroundHints m_backgroundHints; - bool m_busy : 1; bool m_hideOnDeactivate : 1; //this is used to build an emacs style shortcut int m_oldKeyboardShortcut;