support minimumSize
if the root object has a minimumSize set, set it as minimum size for the declarative widget, and keep it in sync
This commit is contained in:
parent
db97a9b6cb
commit
c12af537e4
@ -60,6 +60,8 @@ public:
|
|||||||
void execute(const QString &fileName);
|
void execute(const QString &fileName);
|
||||||
void finishExecute();
|
void finishExecute();
|
||||||
void scheduleExecutionEnd();
|
void scheduleExecutionEnd();
|
||||||
|
void minimumWidthChanged();
|
||||||
|
void minimumHeightChanged();
|
||||||
|
|
||||||
|
|
||||||
DeclarativeWidget *q;
|
DeclarativeWidget *q;
|
||||||
@ -152,18 +154,19 @@ void DeclarativeWidgetPrivate::finishExecute()
|
|||||||
lay->addItem(widget);
|
lay->addItem(widget);
|
||||||
} else {
|
} else {
|
||||||
q->setLayout(0);
|
q->setLayout(0);
|
||||||
qreal width = 0;
|
qreal minimumWidth = 0;
|
||||||
qreal height = 0;
|
qreal minimumHeight = 0;
|
||||||
if (object) {
|
if (object) {
|
||||||
width = object->property("width").toReal();
|
minimumWidth = object->property("minimumWidth").toReal();
|
||||||
height = object->property("height").toReal();
|
minimumHeight = object->property("minimumHeight").toReal();
|
||||||
object->setProperty("width", q->size().width());
|
object->setProperty("width", q->size().width());
|
||||||
object->setProperty("height", q->size().height());
|
object->setProperty("height", q->size().height());
|
||||||
|
QObject::connect(object, SIGNAL(minimumWidthChanged()), q, SLOT(minimumWidthChanged()));
|
||||||
|
QObject::connect(object, SIGNAL(minimumHeightChanged()), q, SLOT(minimumHeightChanged()));
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME: find a better way to have a minimum size
|
if (minimumWidth > 0 && minimumHeight > 0) {
|
||||||
if (width > 0 && height > 0) {
|
q->setMinimumSize(minimumWidth, minimumHeight);
|
||||||
q->setMinimumSize(width, height);
|
|
||||||
} else {
|
} else {
|
||||||
q->setMinimumSize(-1, -1);
|
q->setMinimumSize(-1, -1);
|
||||||
}
|
}
|
||||||
@ -171,7 +174,17 @@ void DeclarativeWidgetPrivate::finishExecute()
|
|||||||
emit q->finished();
|
emit q->finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeclarativeWidgetPrivate::minimumWidthChanged()
|
||||||
|
{
|
||||||
|
qreal minimumWidth = root->property("minimumWidth").toReal();
|
||||||
|
q->setMinimumWidth(minimumWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeclarativeWidgetPrivate::minimumHeightChanged()
|
||||||
|
{
|
||||||
|
qreal minimumHeight = root->property("minimumHeight").toReal();
|
||||||
|
q->setMinimumHeight(minimumHeight);
|
||||||
|
}
|
||||||
|
|
||||||
DeclarativeWidget::DeclarativeWidget(QGraphicsWidget *parent)
|
DeclarativeWidget::DeclarativeWidget(QGraphicsWidget *parent)
|
||||||
: QGraphicsWidget(parent),
|
: QGraphicsWidget(parent),
|
||||||
|
@ -129,6 +129,8 @@ private:
|
|||||||
|
|
||||||
Q_PRIVATE_SLOT(d, void finishExecute())
|
Q_PRIVATE_SLOT(d, void finishExecute())
|
||||||
Q_PRIVATE_SLOT(d, void scheduleExecutionEnd())
|
Q_PRIVATE_SLOT(d, void scheduleExecutionEnd())
|
||||||
|
Q_PRIVATE_SLOT(d, void minimumWidthChanged())
|
||||||
|
Q_PRIVATE_SLOT(d, void minimumHeightChanged())
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Plasma
|
} // namespace Plasma
|
||||||
|
Loading…
x
Reference in New Issue
Block a user