[IconItem] Add selected property
This commit is contained in:
parent
d6656a545a
commit
9c8cf7078e
@ -252,6 +252,7 @@ IconItem::IconItem(QQuickItem *parent)
|
||||
m_iconItemSource(new NullSource(this)),
|
||||
m_status(Plasma::Svg::Normal),
|
||||
m_active(false),
|
||||
m_selected(false),
|
||||
m_animated(true),
|
||||
m_usesPlasmaTheme(true),
|
||||
m_roundToIconSize(true),
|
||||
@ -448,6 +449,26 @@ void IconItem::setActive(bool active)
|
||||
emit activeChanged();
|
||||
}
|
||||
|
||||
bool IconItem::isSelected() const
|
||||
{
|
||||
return m_selected;
|
||||
}
|
||||
|
||||
void IconItem::setSelected(bool selected)
|
||||
{
|
||||
if (m_selected == selected) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_selected = selected;
|
||||
|
||||
if (isComponentComplete()) {
|
||||
m_allowNextAnimation = true;
|
||||
schedulePixmapUpdate();
|
||||
}
|
||||
emit selectedChanged();
|
||||
}
|
||||
|
||||
bool IconItem::isAnimated() const
|
||||
{
|
||||
return m_animated;
|
||||
@ -726,6 +747,8 @@ void IconItem::loadPixmap()
|
||||
result = KIconLoader::global()->iconEffect()->apply(result, KIconLoader::Desktop, KIconLoader::DisabledState);
|
||||
} else if (m_active) {
|
||||
result = KIconLoader::global()->iconEffect()->apply(result, KIconLoader::Desktop, KIconLoader::ActiveState);
|
||||
} else if (m_selected) {
|
||||
result = KIconLoader::global()->iconEffect()->apply(result, KIconLoader::Desktop, KIconLoader::SelectedState);
|
||||
}
|
||||
|
||||
const QSize oldPaintedSize = paintedSize();
|
||||
|
@ -61,6 +61,12 @@ class IconItem : public QQuickItem
|
||||
*/
|
||||
Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
|
||||
|
||||
/**
|
||||
* Apply a visual indication that this icon is selected.
|
||||
* @since 5.77
|
||||
*/
|
||||
Q_PROPERTY(bool selected READ isSelected WRITE setSelected NOTIFY selectedChanged)
|
||||
|
||||
/**
|
||||
* Sets the image in a selected status.
|
||||
* Svgs can be colored with system color themes, if the status is selected,
|
||||
@ -124,6 +130,9 @@ public:
|
||||
bool isActive() const;
|
||||
void setActive(bool active);
|
||||
|
||||
bool isSelected() const;
|
||||
void setSelected(bool selected);
|
||||
|
||||
bool isAnimated() const;
|
||||
void setAnimated(bool animated);
|
||||
|
||||
@ -156,6 +165,7 @@ public:
|
||||
Q_SIGNALS:
|
||||
void overlaysChanged();
|
||||
void activeChanged();
|
||||
void selectedChanged();
|
||||
void sourceChanged();
|
||||
void animatedChanged();
|
||||
void usesPlasmaThemeChanged();
|
||||
@ -187,6 +197,7 @@ private:
|
||||
Plasma::Svg::Status m_status;
|
||||
|
||||
bool m_active;
|
||||
bool m_selected;
|
||||
bool m_animated;
|
||||
bool m_usesPlasmaTheme;
|
||||
bool m_roundToIconSize;
|
||||
|
Loading…
Reference in New Issue
Block a user