allow plasmoids to change icon
changing icon will change the icon of the default compact representation
This commit is contained in:
parent
135d4039aa
commit
fab4818c92
@ -332,11 +332,12 @@ void Applet::setTitle(const QString &title) const
|
||||
|
||||
QString Applet::icon() const
|
||||
{
|
||||
if (!d->appletDescription.isValid()) {
|
||||
return QString();
|
||||
}
|
||||
return d->icon;
|
||||
}
|
||||
|
||||
return d->appletDescription.icon();
|
||||
void Applet::setIcon(const QString &icon)
|
||||
{
|
||||
d->icon = icon;
|
||||
}
|
||||
|
||||
KPluginInfo Applet::pluginInfo() const
|
||||
|
@ -282,10 +282,16 @@ class PLASMA_EXPORT Applet : public QObject
|
||||
static Applet *loadPlasmoid(const QString &path, uint appletId = 0);
|
||||
|
||||
/**
|
||||
* Returns the icon related to this applet
|
||||
* @returns The icon name related to this applet
|
||||
* By default is the one in the plasmoid desktop file
|
||||
**/
|
||||
QString icon() const;
|
||||
|
||||
/**
|
||||
* Sets an icon name for this applet
|
||||
* @param icon Freedesktop compatible icon name
|
||||
*/
|
||||
void setIcon(const QString &icon);
|
||||
|
||||
|
||||
//ACTIONS
|
||||
|
@ -52,6 +52,7 @@ AppletPrivate::AppletPrivate(KService::Ptr service, const KPluginInfo *info, int
|
||||
q(applet),
|
||||
immutability(Types::Mutable),
|
||||
appletDescription(info ? *info : KPluginInfo(service)),
|
||||
icon(appletDescription.isValid() ? appletDescription.icon() : QString()),
|
||||
mainConfig(0),
|
||||
pendingConstraints(Types::NoConstraint),
|
||||
script(0),
|
||||
|
@ -87,6 +87,7 @@ public:
|
||||
// applet info we keep around in case its needed
|
||||
KPluginInfo appletDescription;
|
||||
QString customTitle;
|
||||
QString icon;
|
||||
|
||||
// bookkeeping
|
||||
KConfigGroup *mainConfig;
|
||||
|
@ -221,21 +221,31 @@ QObject* AppletInterface::configuration() const
|
||||
return m_configuration;
|
||||
}
|
||||
|
||||
uint AppletInterface::id() const
|
||||
{
|
||||
return applet()->id();
|
||||
}
|
||||
|
||||
QString AppletInterface::icon() const
|
||||
{
|
||||
return applet()->icon();
|
||||
}
|
||||
|
||||
void AppletInterface::setIcon(const QString &icon)
|
||||
{
|
||||
if (applet()->icon() == icon) {
|
||||
return;
|
||||
}
|
||||
|
||||
applet()->setIcon(icon);
|
||||
emit iconChanged();
|
||||
}
|
||||
|
||||
QString AppletInterface::title() const
|
||||
{
|
||||
return applet()->title();
|
||||
}
|
||||
|
||||
uint AppletInterface::id() const
|
||||
{
|
||||
return applet()->id();
|
||||
}
|
||||
|
||||
void AppletInterface::setTitle(const QString &title)
|
||||
{
|
||||
if (applet()->title() == title) {
|
||||
|
@ -64,11 +64,10 @@ class AppletInterface : public QQuickItem
|
||||
*/
|
||||
Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
|
||||
|
||||
//TODO: writable icon
|
||||
/**
|
||||
* Icon to represent the plasmoid
|
||||
*/
|
||||
Q_PROPERTY(QString icon READ icon CONSTANT)
|
||||
Q_PROPERTY(QString icon READ icon WRITE setIcon NOTIFY iconChanged)
|
||||
|
||||
/**
|
||||
* Applet id: is unique in the whole Plasma session and will never change across restarts
|
||||
@ -235,6 +234,7 @@ public:
|
||||
|
||||
//PROPERTY ACCESSORS-------------------------------------------------------------------
|
||||
QString icon() const;
|
||||
void setIcon(const QString &icon);
|
||||
|
||||
QString title() const;
|
||||
void setTitle(const QString &title);
|
||||
@ -294,6 +294,7 @@ Q_SIGNALS:
|
||||
void configNeedsSaving();
|
||||
|
||||
//PROPERTY change notifiers--------------
|
||||
void iconChanged();
|
||||
void titleChanged();
|
||||
void formFactorChanged();
|
||||
void locationChanged();
|
||||
|
Loading…
Reference in New Issue
Block a user