set default meaningful implicitWidth/height
svgItem has naturalSize as implicit size framesvgitem has the sum of their borders
This commit is contained in:
parent
01e84b4483
commit
3d21d43182
@ -83,6 +83,14 @@ void FrameSvgItem::setImagePath(const QString &path)
|
|||||||
m_frameSvg->setImagePath(path);
|
m_frameSvg->setImagePath(path);
|
||||||
m_frameSvg->setElementPrefix(m_prefix);
|
m_frameSvg->setElementPrefix(m_prefix);
|
||||||
|
|
||||||
|
if (implicitWidth() <= 0) {
|
||||||
|
setImplicitWidth(m_frameSvg->marginSize(Plasma::LeftMargin) + m_frameSvg->marginSize(Plasma::RightMargin));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (implicitHeight() <= 0) {
|
||||||
|
setImplicitHeight(m_frameSvg->marginSize(Plasma::TopMargin) + m_frameSvg->marginSize(Plasma::BottomMargin));
|
||||||
|
}
|
||||||
|
|
||||||
emit imagePathChanged();
|
emit imagePathChanged();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@ -102,6 +110,14 @@ void FrameSvgItem::setPrefix(const QString &prefix)
|
|||||||
m_frameSvg->setElementPrefix(prefix);
|
m_frameSvg->setElementPrefix(prefix);
|
||||||
m_prefix = prefix;
|
m_prefix = prefix;
|
||||||
|
|
||||||
|
if (implicitWidth() <= 0) {
|
||||||
|
setImplicitWidth(m_frameSvg->marginSize(Plasma::LeftMargin) + m_frameSvg->marginSize(Plasma::RightMargin));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (implicitHeight() <= 0) {
|
||||||
|
setImplicitHeight(m_frameSvg->marginSize(Plasma::TopMargin) + m_frameSvg->marginSize(Plasma::BottomMargin));
|
||||||
|
}
|
||||||
|
|
||||||
emit prefixChanged();
|
emit prefixChanged();
|
||||||
m_margins->update();
|
m_margins->update();
|
||||||
update();
|
update();
|
||||||
@ -148,9 +164,49 @@ void FrameSvgItem::geometryChanged(const QRectF &newGeometry,
|
|||||||
|
|
||||||
void FrameSvgItem::doUpdate()
|
void FrameSvgItem::doUpdate()
|
||||||
{
|
{
|
||||||
|
if (implicitWidth() <= 0) {
|
||||||
|
setImplicitWidth(m_frameSvg->marginSize(Plasma::LeftMargin) + m_frameSvg->marginSize(Plasma::RightMargin));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (implicitHeight() <= 0) {
|
||||||
|
setImplicitHeight(m_frameSvg->marginSize(Plasma::TopMargin) + m_frameSvg->marginSize(Plasma::BottomMargin));
|
||||||
|
}
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FrameSvgItem::setImplicitWidth(qreal width)
|
||||||
|
{
|
||||||
|
if (implicitWidth() == width) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDeclarativeItem::setImplicitWidth(width);
|
||||||
|
|
||||||
|
emit implicitWidthChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal FrameSvgItem::implicitWidth() const
|
||||||
|
{
|
||||||
|
return QDeclarativeItem::implicitWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FrameSvgItem::setImplicitHeight(qreal height)
|
||||||
|
{
|
||||||
|
if (implicitHeight() == height) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDeclarativeItem::setImplicitHeight(height);
|
||||||
|
|
||||||
|
emit implicitHeightChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal FrameSvgItem::implicitHeight() const
|
||||||
|
{
|
||||||
|
return QDeclarativeItem::implicitHeight();
|
||||||
|
}
|
||||||
|
|
||||||
} // Plasma namespace
|
} // Plasma namespace
|
||||||
|
|
||||||
#include "framesvgitem.moc"
|
#include "framesvgitem.moc"
|
||||||
|
@ -102,6 +102,16 @@ class FrameSvgItem : public QDeclarativeItem
|
|||||||
*/
|
*/
|
||||||
Q_PROPERTY(Plasma::FrameSvg::EnabledBorders enabledBorders READ enabledBorders WRITE setEnabledBorders NOTIFY enabledBordersChanged)
|
Q_PROPERTY(Plasma::FrameSvg::EnabledBorders enabledBorders READ enabledBorders WRITE setEnabledBorders NOTIFY enabledBordersChanged)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* suggested default size hint for width
|
||||||
|
*/
|
||||||
|
Q_PROPERTY(qreal implicitWidth READ implicitWidth WRITE setImplicitWidth NOTIFY implicitWidthChanged)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* suggested default size hint for height
|
||||||
|
*/
|
||||||
|
Q_PROPERTY(qreal implicitHeight READ implicitHeight WRITE setImplicitHeight NOTIFY implicitHeightChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FrameSvgItem(QDeclarativeItem *parent=0);
|
FrameSvgItem(QDeclarativeItem *parent=0);
|
||||||
~FrameSvgItem();
|
~FrameSvgItem();
|
||||||
@ -122,10 +132,18 @@ public:
|
|||||||
void geometryChanged(const QRectF &newGeometry,
|
void geometryChanged(const QRectF &newGeometry,
|
||||||
const QRectF &oldGeometry);
|
const QRectF &oldGeometry);
|
||||||
|
|
||||||
|
void setImplicitWidth(qreal width);
|
||||||
|
qreal implicitWidth() const;
|
||||||
|
|
||||||
|
void setImplicitHeight(qreal height);
|
||||||
|
qreal implicitHeight() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void imagePathChanged();
|
void imagePathChanged();
|
||||||
void prefixChanged();
|
void prefixChanged();
|
||||||
void enabledBordersChanged();
|
void enabledBordersChanged();
|
||||||
|
void implicitWidthChanged();
|
||||||
|
void implicitHeightChanged();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void doUpdate();
|
void doUpdate();
|
||||||
|
@ -54,6 +54,7 @@ public:
|
|||||||
|
|
||||||
void setImplicitWidth(qreal width);
|
void setImplicitWidth(qreal width);
|
||||||
qreal implicitWidth() const;
|
qreal implicitWidth() const;
|
||||||
|
|
||||||
void setImplicitHeight(qreal height);
|
void setImplicitHeight(qreal height);
|
||||||
qreal implicitHeight() const;
|
qreal implicitHeight() const;
|
||||||
|
|
||||||
|
@ -45,6 +45,13 @@ void SvgItem::setElementId(const QString &elementID)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (implicitWidth() <= 0) {
|
||||||
|
setImplicitWidth(naturalSize().width());
|
||||||
|
}
|
||||||
|
if (implicitHeight() <= 0) {
|
||||||
|
setImplicitHeight(naturalSize().height());
|
||||||
|
}
|
||||||
|
|
||||||
m_elementID = elementID;
|
m_elementID = elementID;
|
||||||
emit elementIdChanged();
|
emit elementIdChanged();
|
||||||
emit naturalSizeChanged();
|
emit naturalSizeChanged();
|
||||||
@ -79,6 +86,14 @@ void SvgItem::setSvg(Plasma::Svg *svg)
|
|||||||
connect(svg, SIGNAL(repaintNeeded()), this, SIGNAL(naturalSizeChanged()));
|
connect(svg, SIGNAL(repaintNeeded()), this, SIGNAL(naturalSizeChanged()));
|
||||||
connect(svg, SIGNAL(sizeChanged()), this, SIGNAL(naturalSizeChanged()));
|
connect(svg, SIGNAL(sizeChanged()), this, SIGNAL(naturalSizeChanged()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (implicitWidth() <= 0) {
|
||||||
|
setImplicitWidth(naturalSize().width());
|
||||||
|
}
|
||||||
|
if (implicitHeight() <= 0) {
|
||||||
|
setImplicitHeight(naturalSize().height());
|
||||||
|
}
|
||||||
|
|
||||||
emit svgChanged();
|
emit svgChanged();
|
||||||
emit naturalSizeChanged();
|
emit naturalSizeChanged();
|
||||||
}
|
}
|
||||||
@ -126,9 +141,47 @@ void SvgItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
|
|||||||
|
|
||||||
void SvgItem::updateNeeded()
|
void SvgItem::updateNeeded()
|
||||||
{
|
{
|
||||||
|
if (implicitWidth() <= 0) {
|
||||||
|
setImplicitWidth(naturalSize().width());
|
||||||
|
}
|
||||||
|
if (implicitHeight() <= 0) {
|
||||||
|
setImplicitHeight(naturalSize().height());
|
||||||
|
}
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SvgItem::setImplicitWidth(qreal width)
|
||||||
|
{
|
||||||
|
if (implicitWidth() == width) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDeclarativeItem::setImplicitWidth(width);
|
||||||
|
|
||||||
|
emit implicitWidthChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal SvgItem::implicitWidth() const
|
||||||
|
{
|
||||||
|
return QDeclarativeItem::implicitWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SvgItem::setImplicitHeight(qreal height)
|
||||||
|
{
|
||||||
|
if (implicitHeight() == height) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDeclarativeItem::setImplicitHeight(height);
|
||||||
|
|
||||||
|
emit implicitHeightChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal SvgItem::implicitHeight() const
|
||||||
|
{
|
||||||
|
return QDeclarativeItem::implicitHeight();
|
||||||
|
}
|
||||||
|
|
||||||
} // Plasma namespace
|
} // Plasma namespace
|
||||||
|
|
||||||
#include "svgitem.moc"
|
#include "svgitem.moc"
|
||||||
|
@ -56,6 +56,16 @@ class SvgItem : public QDeclarativeItem
|
|||||||
*/
|
*/
|
||||||
Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged)
|
Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* suggested default size hint for width (default to naturalSize.width)
|
||||||
|
*/
|
||||||
|
Q_PROPERTY(qreal implicitWidth READ implicitWidth WRITE setImplicitWidth NOTIFY implicitWidthChanged)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* suggested default size hint for height (default to naturalSize.height)
|
||||||
|
*/
|
||||||
|
Q_PROPERTY(qreal implicitHeight READ implicitHeight WRITE setImplicitHeight NOTIFY implicitHeightChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SvgItem(QDeclarativeItem *parent=0);
|
SvgItem(QDeclarativeItem *parent=0);
|
||||||
~SvgItem();
|
~SvgItem();
|
||||||
@ -73,11 +83,19 @@ public:
|
|||||||
|
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
|
||||||
|
void setImplicitWidth(qreal width);
|
||||||
|
qreal implicitWidth() const;
|
||||||
|
|
||||||
|
void setImplicitHeight(qreal height);
|
||||||
|
qreal implicitHeight() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void elementIdChanged();
|
void elementIdChanged();
|
||||||
void svgChanged();
|
void svgChanged();
|
||||||
void naturalSizeChanged();
|
void naturalSizeChanged();
|
||||||
void smoothChanged();
|
void smoothChanged();
|
||||||
|
void implicitWidthChanged();
|
||||||
|
void implicitHeightChanged();
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
void updateNeeded();
|
void updateNeeded();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user