support maximum and preferred sizes as well
This commit is contained in:
parent
4f67a643a9
commit
8db63c42a9
@ -62,6 +62,10 @@ public:
|
||||
void scheduleExecutionEnd();
|
||||
void minimumWidthChanged();
|
||||
void minimumHeightChanged();
|
||||
void maximumWidthChanged();
|
||||
void maximumHeightChanged();
|
||||
void preferredWidthChanged();
|
||||
void preferredHeightChanged();
|
||||
|
||||
|
||||
DeclarativeWidget *q;
|
||||
@ -157,13 +161,28 @@ void DeclarativeWidgetPrivate::finishExecute()
|
||||
q->setLayout(0);
|
||||
qreal minimumWidth = 0;
|
||||
qreal minimumHeight = 0;
|
||||
qreal maximumWidth = 0;
|
||||
qreal maximumHeight = 0;
|
||||
qreal preferredWidth = 0;
|
||||
qreal preferredHeight = 0;
|
||||
if (object) {
|
||||
minimumWidth = object->property("minimumWidth").toReal();
|
||||
minimumHeight = object->property("minimumHeight").toReal();
|
||||
object->setProperty("width", q->size().width());
|
||||
object->setProperty("height", q->size().height());
|
||||
|
||||
minimumWidth = object->property("minimumWidth").toReal();
|
||||
minimumHeight = object->property("minimumHeight").toReal();
|
||||
QObject::connect(object, SIGNAL(minimumWidthChanged()), q, SLOT(minimumWidthChanged()));
|
||||
QObject::connect(object, SIGNAL(minimumHeightChanged()), q, SLOT(minimumHeightChanged()));
|
||||
|
||||
maximumWidth = object->property("maximumWidth").toReal();
|
||||
maximumHeight = object->property("maximumHeight").toReal();
|
||||
QObject::connect(object, SIGNAL(maximumWidthChanged()), q, SLOT(maximumWidthChanged()));
|
||||
QObject::connect(object, SIGNAL(maximumHeightChanged()), q, SLOT(maximumHeightChanged()));
|
||||
|
||||
preferredWidth = object->property("preferredWidth").toReal();
|
||||
preferredHeight = object->property("preferredHeight").toReal();
|
||||
QObject::connect(object, SIGNAL(preferredWidthChanged()), q, SLOT(preferredWidthChanged()));
|
||||
QObject::connect(object, SIGNAL(preferredHeightChanged()), q, SLOT(preferredHeightChanged()));
|
||||
}
|
||||
|
||||
if (minimumWidth > 0 && minimumHeight > 0) {
|
||||
@ -171,6 +190,18 @@ void DeclarativeWidgetPrivate::finishExecute()
|
||||
} else {
|
||||
q->setMinimumSize(-1, -1);
|
||||
}
|
||||
|
||||
if (maximumWidth > 0 && maximumHeight > 0) {
|
||||
q->setMaximumSize(maximumWidth, maximumHeight);
|
||||
} else {
|
||||
q->setMaximumSize(-1, -1);
|
||||
}
|
||||
|
||||
if (preferredWidth > 0 && preferredHeight > 0) {
|
||||
q->setPreferredSize(preferredWidth, preferredHeight);
|
||||
} else {
|
||||
q->setPreferredSize(-1, -1);
|
||||
}
|
||||
}
|
||||
emit q->finished();
|
||||
}
|
||||
@ -187,6 +218,30 @@ void DeclarativeWidgetPrivate::minimumHeightChanged()
|
||||
q->setMinimumHeight(minimumHeight);
|
||||
}
|
||||
|
||||
void DeclarativeWidgetPrivate::maximumWidthChanged()
|
||||
{
|
||||
qreal maximumWidth = root->property("maximumWidth").toReal();
|
||||
q->setMaximumWidth(maximumWidth);
|
||||
}
|
||||
|
||||
void DeclarativeWidgetPrivate::maximumHeightChanged()
|
||||
{
|
||||
qreal maximumHeight = root->property("maximumHeight").toReal();
|
||||
q->setMaximumHeight(maximumHeight);
|
||||
}
|
||||
|
||||
void DeclarativeWidgetPrivate::preferredWidthChanged()
|
||||
{
|
||||
qreal preferredWidth = root->property("preferredWidth").toReal();
|
||||
q->setPreferredWidth(preferredWidth);
|
||||
}
|
||||
|
||||
void DeclarativeWidgetPrivate::preferredHeightChanged()
|
||||
{
|
||||
qreal preferredHeight = root->property("preferredHeight").toReal();
|
||||
q->setPreferredHeight(preferredHeight);
|
||||
}
|
||||
|
||||
DeclarativeWidget::DeclarativeWidget(QGraphicsWidget *parent)
|
||||
: QGraphicsWidget(parent),
|
||||
d(new DeclarativeWidgetPrivate(this))
|
||||
|
@ -131,6 +131,10 @@ private:
|
||||
Q_PRIVATE_SLOT(d, void scheduleExecutionEnd())
|
||||
Q_PRIVATE_SLOT(d, void minimumWidthChanged())
|
||||
Q_PRIVATE_SLOT(d, void minimumHeightChanged())
|
||||
Q_PRIVATE_SLOT(d, void maximumWidthChanged())
|
||||
Q_PRIVATE_SLOT(d, void maximumHeightChanged())
|
||||
Q_PRIVATE_SLOT(d, void preferredWidthChanged())
|
||||
Q_PRIVATE_SLOT(d, void preferredHeightChanged())
|
||||
};
|
||||
|
||||
} // namespace Plasma
|
||||
|
Loading…
x
Reference in New Issue
Block a user