IconItem: Add animated property

Add property animated, that allows to disable cross-fade animation when
changing icon (enabled by default).

REVIEW: 126637
This commit is contained in:
David Rosca 2016-01-06 20:21:15 +01:00
parent 6353e0e7bf
commit e4ea8d55b7
2 changed files with 23 additions and 1 deletions

View File

@ -42,6 +42,7 @@ IconItem::IconItem(QQuickItem *parent)
m_svgIcon(0), m_svgIcon(0),
m_smooth(false), m_smooth(false),
m_active(false), m_active(false),
m_animated(true),
m_textureChanged(false), m_textureChanged(false),
m_sizeChanged(false), m_sizeChanged(false),
m_svgFromIconLoader(false), m_svgFromIconLoader(false),
@ -241,6 +242,21 @@ bool IconItem::smooth() const
return m_smooth; return m_smooth;
} }
bool IconItem::isAnimated() const
{
return m_animated;
}
void IconItem::setAnimated(bool animated)
{
if (m_animated == animated) {
return;
}
m_animated = animated;
emit animatedChanged();
}
bool IconItem::isValid() const bool IconItem::isValid() const
{ {
return !m_icon.isNull() || m_svgIcon || !m_pixmapIcon.isNull() || !m_imageIcon.isNull(); return !m_icon.isNull() || m_svgIcon || !m_pixmapIcon.isNull() || !m_imageIcon.isNull();
@ -397,7 +413,7 @@ void IconItem::loadPixmap()
m_textureChanged = true; m_textureChanged = true;
//don't animate initial setting //don't animate initial setting
if (!m_oldIconPixmap.isNull() && !m_sizeChanged) { if (m_animated && !m_oldIconPixmap.isNull() && !m_sizeChanged) {
m_animation->setStartValue((qreal)0); m_animation->setStartValue((qreal)0);
m_animation->setEndValue((qreal)1); m_animation->setEndValue((qreal)1);
m_animation->start(); m_animation->start();

View File

@ -43,6 +43,7 @@ class IconItem : public QQuickItem
Q_PROPERTY(Plasma::Theme::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY colorGroupChanged) Q_PROPERTY(Plasma::Theme::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY colorGroupChanged)
Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged) Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged)
Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged) Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
Q_PROPERTY(bool animated READ isAnimated WRITE setAnimated NOTIFY animatedChanged)
Q_PROPERTY(bool valid READ isValid NOTIFY validChanged) Q_PROPERTY(bool valid READ isValid NOTIFY validChanged)
Q_PROPERTY(int paintedWidth READ paintedWidth NOTIFY paintedSizeChanged) Q_PROPERTY(int paintedWidth READ paintedWidth NOTIFY paintedSizeChanged)
Q_PROPERTY(int paintedHeight READ paintedHeight NOTIFY paintedSizeChanged) Q_PROPERTY(int paintedHeight READ paintedHeight NOTIFY paintedSizeChanged)
@ -64,6 +65,9 @@ public:
void setSmooth(const bool smooth); void setSmooth(const bool smooth);
bool smooth() const; bool smooth() const;
bool isAnimated() const;
void setAnimated(bool animated);
bool isValid() const; bool isValid() const;
int paintedWidth() const; int paintedWidth() const;
@ -81,6 +85,7 @@ Q_SIGNALS:
void activeChanged(); void activeChanged();
void sourceChanged(); void sourceChanged();
void smoothChanged(); void smoothChanged();
void animatedChanged();
void validChanged(); void validChanged();
void colorGroupChanged(); void colorGroupChanged();
void paintedSizeChanged(); void paintedSizeChanged();
@ -105,6 +110,7 @@ private:
bool m_smooth; bool m_smooth;
bool m_active; bool m_active;
bool m_animated;
bool m_textureChanged; bool m_textureChanged;
bool m_sizeChanged; bool m_sizeChanged;