if the user did set an implicit size, keep it
Summary: if the user code did something like IconItem { implicitWidth: 32 implicitHeight: 32 } then never automatically update implicitWidth or height. this favors compatibility and fixes the desktop toolbox appearance Test Plan: textbox works, other icon items in plasmashell seems properly sized. applet alternatives fix is still needed Reviewers: #plasma, hein Reviewed By: #plasma, hein Subscribers: hein, davidedmundson, plasma-devel, #frameworks Tags: #plasma, #frameworks Differential Revision: https://phabricator.kde.org/D5243
This commit is contained in:
parent
03427e4323
commit
fb8ed07651
@ -49,6 +49,8 @@ IconItem::IconItem(QQuickItem *parent)
|
||||
m_sizeChanged(false),
|
||||
m_allowNextAnimation(false),
|
||||
m_blockNextAnimation(false),
|
||||
m_implicitHeightSetByUser(false),
|
||||
m_implicitWidthSetByUser(false),
|
||||
m_colorGroup(Plasma::Theme::NormalColorGroup),
|
||||
m_animValue(0)
|
||||
{
|
||||
@ -75,6 +77,9 @@ IconItem::IconItem(QQuickItem *parent)
|
||||
connect(this, SIGNAL(overlaysChanged()),
|
||||
this, SLOT(schedulePixmapUpdate()));
|
||||
|
||||
connect(this, &IconItem::implicitWidthChanged, this, &IconItem::implicitWidthChanged2);
|
||||
connect(this, &IconItem::implicitHeightChanged, this, &IconItem::implicitHeightChanged2);
|
||||
|
||||
updateImplicitSize();
|
||||
}
|
||||
|
||||
@ -88,7 +93,13 @@ void IconItem::updateImplicitSize()
|
||||
const QSize &s = m_imageIcon.size();
|
||||
|
||||
if (s.isValid()) {
|
||||
setImplicitSize(s.width(), s.height());
|
||||
if (!m_implicitWidthSetByUser && !m_implicitHeightSetByUser) {
|
||||
setImplicitSize(s.width(), s.height());
|
||||
} else if (!m_implicitWidthSetByUser) {
|
||||
setImplicitWidth(s.width());
|
||||
} else if (!m_implicitHeightSetByUser) {
|
||||
setImplicitHeight(s.height());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@ -105,7 +116,13 @@ void IconItem::updateImplicitSize()
|
||||
s = m_svgIcon->size();
|
||||
}
|
||||
if (s.isValid()) {
|
||||
setImplicitSize(s.width(), s.height());
|
||||
if (!m_implicitWidthSetByUser && !m_implicitHeightSetByUser) {
|
||||
setImplicitSize(s.width(), s.height());
|
||||
} else if (!m_implicitWidthSetByUser) {
|
||||
setImplicitWidth(s.width());
|
||||
} else if (!m_implicitHeightSetByUser) {
|
||||
setImplicitHeight(s.height());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@ -113,7 +130,14 @@ void IconItem::updateImplicitSize()
|
||||
|
||||
// Fall back to initializing implicit size to the Dialog size.
|
||||
const int implicitSize = KIconLoader::global()->currentSize(KIconLoader::Dialog);
|
||||
setImplicitSize(implicitSize, implicitSize);
|
||||
|
||||
if (!m_implicitWidthSetByUser && !m_implicitHeightSetByUser) {
|
||||
setImplicitSize(implicitSize, implicitSize);
|
||||
} else if (!m_implicitWidthSetByUser) {
|
||||
setImplicitWidth(implicitSize);
|
||||
} else if (!m_implicitHeightSetByUser) {
|
||||
setImplicitHeight(implicitSize);
|
||||
}
|
||||
}
|
||||
|
||||
void IconItem::setSource(const QVariant &source)
|
||||
@ -418,6 +442,20 @@ Plasma::Svg::Status IconItem::status() const
|
||||
return m_status;
|
||||
}
|
||||
|
||||
void IconItem::setImplicitHeight2(int height)
|
||||
{
|
||||
m_implicitHeightSetByUser = true;
|
||||
setImplicitHeight(height);
|
||||
emit implicitHeightChanged2();
|
||||
}
|
||||
|
||||
void IconItem::setImplicitWidth2(int width)
|
||||
{
|
||||
m_implicitWidthSetByUser = true;
|
||||
setImplicitWidth(width);
|
||||
emit implicitWidthChanged2();
|
||||
}
|
||||
|
||||
void IconItem::updatePolish()
|
||||
{
|
||||
QQuickItem::updatePolish();
|
||||
|
@ -119,6 +119,10 @@ class IconItem : public QQuickItem
|
||||
*/
|
||||
Q_PROPERTY(int paintedHeight READ paintedHeight NOTIFY paintedSizeChanged)
|
||||
|
||||
Q_PROPERTY(int implicitHeight READ implicitHeight WRITE setImplicitHeight2 NOTIFY implicitHeightChanged2)
|
||||
|
||||
Q_PROPERTY(int implicitWidth READ implicitWidth WRITE setImplicitWidth2 NOTIFY implicitWidthChanged2)
|
||||
|
||||
public:
|
||||
IconItem(QQuickItem *parent = 0);
|
||||
~IconItem();
|
||||
@ -155,6 +159,9 @@ public:
|
||||
void setStatus(Plasma::Svg::Status status);
|
||||
Plasma::Svg::Status status() const;
|
||||
|
||||
void setImplicitHeight2(int height);
|
||||
void setImplicitWidth2(int height);
|
||||
|
||||
void updatePolish() Q_DECL_OVERRIDE;
|
||||
QSGNode* updatePaintNode(QSGNode * oldNode, UpdatePaintNodeData * updatePaintNodeData) Q_DECL_OVERRIDE;
|
||||
|
||||
@ -176,6 +183,8 @@ Q_SIGNALS:
|
||||
void colorGroupChanged();
|
||||
void paintedSizeChanged();
|
||||
void statusChanged();
|
||||
void implicitHeightChanged2();
|
||||
void implicitWidthChanged2();
|
||||
|
||||
private Q_SLOTS:
|
||||
void schedulePixmapUpdate();
|
||||
@ -210,6 +219,8 @@ private:
|
||||
bool m_sizeChanged;
|
||||
bool m_allowNextAnimation;
|
||||
bool m_blockNextAnimation;
|
||||
bool m_implicitHeightSetByUser;
|
||||
bool m_implicitWidthSetByUser;
|
||||
|
||||
QPixmap m_iconPixmap;
|
||||
QPixmap m_oldIconPixmap;
|
||||
|
Loading…
x
Reference in New Issue
Block a user