add icon/titleChanged
make it possible to set icon and title from the Applet subclass, making appletInterface (so plasmoid obj) notice about the change and relay the notify signal
This commit is contained in:
parent
d405378219
commit
6973dac801
@ -335,9 +335,14 @@ QString Applet::title() const
|
||||
return i18n("Unknown");
|
||||
}
|
||||
|
||||
void Applet::setTitle(const QString &title) const
|
||||
void Applet::setTitle(const QString &title)
|
||||
{
|
||||
if (title == d->customTitle) {
|
||||
return;
|
||||
}
|
||||
|
||||
d->customTitle = title;
|
||||
emit titleChanged(title);
|
||||
}
|
||||
|
||||
QString Applet::icon() const
|
||||
@ -347,7 +352,12 @@ QString Applet::icon() const
|
||||
|
||||
void Applet::setIcon(const QString &icon)
|
||||
{
|
||||
if (icon == d->icon) {
|
||||
return;
|
||||
}
|
||||
|
||||
d->icon = icon;
|
||||
emit iconChanged(icon);
|
||||
}
|
||||
|
||||
KPluginInfo Applet::pluginInfo() const
|
||||
|
@ -71,8 +71,8 @@ class PLASMA_EXPORT Applet : public QObject
|
||||
Q_PROPERTY(Plasma::Types::ImmutabilityType immutability READ immutability WRITE setImmutability NOTIFY immutabilityChanged)
|
||||
Q_PROPERTY(Plasma::Types::FormFactor formFactor READ formFactor NOTIFY formFactorChanged)
|
||||
Q_PROPERTY(Plasma::Types::Location location READ location NOTIFY locationChanged)
|
||||
Q_PROPERTY(QString title READ title WRITE setTitle FINAL)
|
||||
Q_PROPERTY(QString icon READ icon WRITE setIcon FINAL)
|
||||
Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL)
|
||||
Q_PROPERTY(QString icon READ icon WRITE setIcon NOTIFY iconChanged FINAL)
|
||||
|
||||
public:
|
||||
//CONSTRUCTORS
|
||||
@ -290,7 +290,7 @@ public:
|
||||
* @since 5.0
|
||||
* @param title the user-visible title for the applet.
|
||||
*/
|
||||
void setTitle(const QString &title) const;
|
||||
void setTitle(const QString &title);
|
||||
|
||||
/**
|
||||
* Attempts to load an applet from a package
|
||||
@ -419,6 +419,18 @@ Q_SIGNALS:
|
||||
*/
|
||||
void destroyedChanged(bool destroyed);
|
||||
|
||||
/**
|
||||
* Emitted when the title has changed
|
||||
* @since 5.20
|
||||
*/
|
||||
void titleChanged(const QString &title);
|
||||
|
||||
/**
|
||||
* Emitted when the icon name for the applet has changed
|
||||
* @since 5.20
|
||||
*/
|
||||
void iconChanged(const QString &icon);
|
||||
|
||||
//CONFIGURATION
|
||||
/**
|
||||
* Emitted when an applet has changed values in its configuration
|
||||
|
@ -80,6 +80,12 @@ AppletInterface::AppletInterface(DeclarativeAppletScript *script, const QVariant
|
||||
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::activated,
|
||||
this, &AppletInterface::activated);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user