ensure margins update in all cases

setElementPrefix does not trigger repaintNeeded() from the svg object;
repaintNeeded() is for internal changes. if you change the svg from your
own application code, the app code needs to react to those changes in its
own time and way.

so margins was never seeing that it was getting changed when setElementPrefix
was called -> pixel imperfections in layouts.
This commit is contained in:
Aaron Seigo 2012-11-07 12:43:11 +01:00
parent 1023ceda85
commit 554f0b9909
2 changed files with 15 additions and 3 deletions

View File

@ -31,7 +31,8 @@ FrameSvgItemMargins::FrameSvgItemMargins(Plasma::FrameSvg *frameSvg, QObject *pa
: QObject(parent),
m_frameSvg(frameSvg)
{
connect(m_frameSvg, SIGNAL(repaintNeeded()), this, SIGNAL(marginsChanged()));
kDebug() << "margins at: " << left() << top() << right() << bottom();
connect(m_frameSvg, SIGNAL(repaintNeeded()), this, SLOT(update()));
}
qreal FrameSvgItemMargins::left() const
@ -54,6 +55,11 @@ qreal FrameSvgItemMargins::bottom() const
return m_frameSvg->marginSize(BottomMargin);
}
void FrameSvgItemMargins::update()
{
emit marginsChanged();
}
FrameSvgItem::FrameSvgItem(QDeclarativeItem *parent)
: QDeclarativeItem(parent)
{
@ -70,8 +76,9 @@ FrameSvgItem::~FrameSvgItem()
void FrameSvgItem::setImagePath(const QString &path)
{
if (m_frameSvg->imagePath() == path)
if (m_frameSvg->imagePath() == path) {
return;
}
m_frameSvg->setImagePath(path);
m_frameSvg->setElementPrefix(m_prefix);
@ -88,13 +95,15 @@ QString FrameSvgItem::imagePath() const
void FrameSvgItem::setPrefix(const QString &prefix)
{
if (m_prefix == prefix)
if (m_prefix == prefix) {
return;
}
m_frameSvg->setElementPrefix(prefix);
m_prefix = prefix;
emit prefixChanged();
m_margins->update();
update();
}

View File

@ -59,6 +59,9 @@ public:
qreal right() const;
qreal bottom() const;
public Q_SLOTS:
void update();
Q_SIGNALS:
void marginsChanged();