aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/imports/controls/plugins.qmltypes1
-rw-r--r--src/imports/templates/plugins.qmltypes1
-rw-r--r--src/templates/qquickapplicationwindow.cpp50
-rw-r--r--src/templates/qquickapplicationwindow_p.h5
4 files changed, 57 insertions, 0 deletions
diff --git a/src/imports/controls/plugins.qmltypes b/src/imports/controls/plugins.qmltypes
index dbb70704..e8083e6b 100644
--- a/src/imports/controls/plugins.qmltypes
+++ b/src/imports/controls/plugins.qmltypes
@@ -43,6 +43,7 @@ Module {
exports: ["Qt.labs.templates/ApplicationWindow 1.0"]
exportMetaObjectRevisions: [0]
attachedType: "QQuickApplicationWindowAttached"
+ Property { name: "background"; type: "QQuickItem"; isPointer: true }
Property { name: "contentItem"; type: "QQuickItem"; isReadonly: true; isPointer: true }
Property { name: "data"; type: "QObject"; isList: true; isReadonly: true }
Property { name: "activeFocusControl"; type: "QQuickItem"; isReadonly: true; isPointer: true }
diff --git a/src/imports/templates/plugins.qmltypes b/src/imports/templates/plugins.qmltypes
index d194f28d..229a194e 100644
--- a/src/imports/templates/plugins.qmltypes
+++ b/src/imports/templates/plugins.qmltypes
@@ -37,6 +37,7 @@ Module {
exports: ["Qt.labs.templates/ApplicationWindow 1.0"]
exportMetaObjectRevisions: [0]
attachedType: "QQuickApplicationWindowAttached"
+ Property { name: "background"; type: "QQuickItem"; isPointer: true }
Property { name: "contentItem"; type: "QQuickItem"; isReadonly: true; isPointer: true }
Property { name: "data"; type: "QObject"; isList: true; isReadonly: true }
Property { name: "activeFocusControl"; type: "QQuickItem"; isReadonly: true; isPointer: true }
diff --git a/src/templates/qquickapplicationwindow.cpp b/src/templates/qquickapplicationwindow.cpp
index 7756a7bf..f0a009ff 100644
--- a/src/templates/qquickapplicationwindow.cpp
+++ b/src/templates/qquickapplicationwindow.cpp
@@ -99,6 +99,7 @@ class QQuickApplicationWindowPrivate : public QQuickItemChangeListener
public:
QQuickApplicationWindowPrivate()
: complete(false)
+ , background(nullptr)
, contentItem(nullptr)
, header(nullptr)
, footer(nullptr)
@@ -123,6 +124,7 @@ public:
void setActiveFocusControl(QQuickItem *item);
bool complete;
+ QQuickItem *background;
QQuickItem *contentItem;
QQuickItem *header;
QQuickItem *footer;
@@ -167,6 +169,18 @@ void QQuickApplicationWindowPrivate::relayout()
p->widthValid = false;
}
}
+
+ if (background) {
+ QQuickItemPrivate *p = QQuickItemPrivate::get(background);
+ if (!p->widthValid && qFuzzyIsNull(background->x())) {
+ background->setWidth(q->width());
+ p->widthValid = false;
+ }
+ if (!p->heightValid && qFuzzyIsNull(background->y())) {
+ background->setHeight(q->height());
+ p->heightValid = false;
+ }
+ }
}
void QQuickApplicationWindowPrivate::itemImplicitWidthChanged(QQuickItem *item)
@@ -231,6 +245,42 @@ QQuickApplicationWindow::~QQuickApplicationWindow()
}
/*!
+ \qmlproperty Item Qt.labs.controls::ApplicationWindow::background
+
+ This property holds the background item.
+
+ The background item is stacked under the \l {contentItem}{content item},
+ but above the \l {Window::color}{background color} of the window.
+
+ \note If the background item has no explicit size specified, it automatically
+ follows the control's size. In most cases, there is no need to specify
+ width or height for a background item.
+*/
+QQuickItem *QQuickApplicationWindow::background() const
+{
+ Q_D(const QQuickApplicationWindow);
+ return d->background;
+}
+
+void QQuickApplicationWindow::setBackground(QQuickItem *background)
+{
+ Q_D(QQuickApplicationWindow);
+ if (d->background == background)
+ return;
+
+ delete d->background;
+ d->background = background;
+ if (background) {
+ background->setParentItem(QQuickWindow::contentItem());
+ if (qFuzzyIsNull(background->z()))
+ background->setZ(-1);
+ if (isComponentComplete())
+ d->relayout();
+ }
+ emit backgroundChanged();
+}
+
+/*!
\qmlproperty Item Qt.labs.controls::ApplicationWindow::header
This property holds the window header item. The header item is positioned to
diff --git a/src/templates/qquickapplicationwindow_p.h b/src/templates/qquickapplicationwindow_p.h
index 960e5714..87105040 100644
--- a/src/templates/qquickapplicationwindow_p.h
+++ b/src/templates/qquickapplicationwindow_p.h
@@ -63,6 +63,7 @@ class QQuickApplicationWindowAttachedPrivate;
class Q_LABSTEMPLATES_EXPORT QQuickApplicationWindow : public QQuickWindowQmlImpl
{
Q_OBJECT
+ Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL)
Q_PROPERTY(QQuickItem *contentItem READ contentItem CONSTANT FINAL)
Q_PROPERTY(QQmlListProperty<QObject> data READ contentData FINAL)
Q_PROPERTY(QQuickItem *activeFocusControl READ activeFocusControl NOTIFY activeFocusControlChanged FINAL)
@@ -77,6 +78,9 @@ public:
explicit QQuickApplicationWindow(QWindow *parent = nullptr);
~QQuickApplicationWindow();
+ QQuickItem *background() const;
+ void setBackground(QQuickItem *background);
+
QQuickItem *contentItem() const;
QQmlListProperty<QObject> contentData();
@@ -101,6 +105,7 @@ public:
static QQuickApplicationWindowAttached *qmlAttachedProperties(QObject *object);
Q_SIGNALS:
+ void backgroundChanged();
void activeFocusControlChanged();
void headerChanged();
void footerChanged();