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