Source

Target

Showing with 469 additions and 169 deletions
......@@ -52,14 +52,20 @@ import QtQuick.Controls.Private 1.0
The common way of using StatusBar is in relation to \l ApplicationWindow.
Note that the StatusBar does not provide a layout of its own, but requires
you to position its contents, for instance by creating a \l Row.
you to position its contents, for instance by creating a \l RowLayout.
If only a single item is used within the StatusBar, it will resize to fit the implicitHeight
of its contained item. This makes it particularly suitable for use together with layouts.
Otherwise the height is platform dependent.
\code
import QtQuick.Controls 1.0
import QtQuick.Layouts 1.0
ApplicationWindow {
statusBar: StatusBar {
Label {
text: "Read Only"
anchors.centerIn: parent
RowLayout {
Label { text: "Read Only" }
}
}
}
......@@ -68,16 +74,68 @@ import QtQuick.Controls.Private 1.0
Item {
id: statusbar
activeFocusOnTab: false
Accessible.role: Accessible.StatusBar
width: parent ? parent.width : implicitWidth
implicitWidth: loader.item.implicitHeight
implicitHeight: loader.item ? loader.item.implicitHeight : 0
implicitWidth: loader.item ? loader.item.implicitWidth : 200
implicitHeight: Math.max(container.topMargin + container.bottomMargin + container.calcHeight(),
loader.item ? loader.item.implicitHeight : 19)
/*! \internal */
property Component style: Qt.createComponent(Settings.style + "/StatusBarStyle.qml", statusbar)
Loader {
id: loader
anchors.fill: parent
sourceComponent: style
property var __control: statusbar
}
/*! \internal */
property alias __style: styleLoader.item
/*! \internal */
default property alias __content: container.data
/*!
\qmlproperty Item StatusBar::contentItem
This property holds the content Item of the status bar.
Items declared as children of a StatusBar are automatically parented to the StatusBar's contentItem.
Items created dynamically need to be explicitly parented to the contentItem:
\note The implicit size of the StatusBar is calculated based on the size of its content. If you want to anchor
items inside the status bar, you must specify an explicit width and height on the StatusBar itself.
*/
readonly property alias contentItem: container
data: [
Loader {
id: loader
anchors.fill: parent
sourceComponent: styleLoader.item ? styleLoader.item.panel : null
onLoaded: item.z = -1
Loader {
id: styleLoader
property alias __control: statusbar
sourceComponent: style
}
},
Item {
id: container
z: 1
focus: true
anchors.fill: parent
anchors.topMargin: topMargin
anchors.leftMargin: leftMargin
anchors.rightMargin: rightMargin
anchors.bottomMargin: bottomMargin
property int topMargin: __style ? __style.padding.top : 0
property int bottomMargin: __style ? __style.padding.bottom : 0
property int leftMargin: __style ? __style.padding.left : 0
property int rightMargin: __style ? __style.padding.right : 0
property Item layoutItem: container.children.length === 1 ? container.children[0] : null
function calcHeight () { return (layoutItem ? (layoutItem.implicitHeight || layoutItem.height) +
(layoutItem.anchors.fill ? layoutItem.anchors.topMargin +
layoutItem.anchors.bottomMargin : 0) : loader.item ? loader.item.implicitHeight : 0) }
}]
}
......@@ -133,7 +133,7 @@ FocusScope {
}
/*! Returns the \l Tab item at \a index. */
function tabAt(index) {
function getTab(index) {
return __tabs.get(index).tab
}
......
......@@ -161,12 +161,6 @@ ScrollView {
*/
property Component rowDelegate: __style ? __style.rowDelegate : null
/*! \qmlproperty color TableView::backgroundColor
This property sets the background color of the viewport.
The default value is the base color of the SystemPalette. */
property alias backgroundColor: colorRect.color
/*! This property defines a delegate to draw a header.
In the header delegate you have access to the following special properties:
......@@ -200,9 +194,8 @@ ScrollView {
*/
property int sortIndicatorOrder: Qt.AscendingOrder
/*! \qmlproperty list<TableViewColumn> TableView::columns
This property contains the TableViewColumn items */
default property alias columns: listView.columnheader
/*! \internal */
default property alias __columns: root.data
/*! \qmlproperty Component TableView::contentHeader
This is the content header of the TableView */
......@@ -216,8 +209,9 @@ ScrollView {
The current number of rows */
readonly property alias rowCount: listView.count
/*! The current number of columns */
readonly property int columnCount: columns.length
/*! \qmlproperty int TableView::columnCount
The current number of columns */
readonly property alias columnCount: columnModel.count
/*! \qmlproperty string TableView::section.property
\qmlproperty enumeration TableView::section.criteria
......@@ -288,6 +282,73 @@ ScrollView {
return listView.indexAt(obj.x, obj.y)
}
/*! Adds a \a column and returns the added column.
The \a column argument can be an instance of TableViewColumn,
or a Component. The component has to contain a TableViewColumn.
Otherwise \c null is returned.
*/
function addColumn(column) {
return insertColumn(columnCount, column)
}
/*! Inserts a \a column at the given \a index and returns the inserted column.
The \a column argument can be an instance of TableViewColumn,
or a Component. The component has to contain a TableViewColumn.
Otherwise \c null is returned.
*/
function insertColumn(index, column) {
var object = column
if (typeof column['createObject'] === 'function')
object = column.createObject(root)
if (index >= 0 && index <= columnCount && object.Accessible.role === Accessible.ColumnHeader) {
columnModel.insert(index, {columnItem: object})
return object
}
if (object !== column)
object.destroy()
console.warn("TableView::insertColumn(): invalid argument")
return null
}
/*! Removes and destroys a column at the given \a index. */
function removeColumn(index) {
if (index < 0 || index >= columnCount) {
console.warn("TableView::removeColumn(): invalid argument")
return
}
var column = columnModel.get(index).columnItem
columnModel.remove(index, 1)
column.destroy()
}
/*! Moves a column \a from index \a to another. */
function moveColumn(from, to) {
if (from < 0 || from >= columnCount || to < 0 || to >= columnCount) {
console.warn("TableView::moveColumn(): invalid argument")
return
}
columnModel.move(from, to, 1)
}
/*! Returns the column at the given \a index
or \c null if the \a index is invalid. */
function getColumn(index) {
if (index < 0 || index >= columnCount)
return null
return columnModel.get(index).columnItem
}
Component.onCompleted: {
for (var i = 0; i < __columns.length; ++i) {
var column = __columns[i]
if (column.Accessible.role === Accessible.ColumnHeader)
addColumn(column)
}
}
style: Qt.createComponent(Settings.style + "/TableViewStyle.qml", root)
......@@ -337,7 +398,7 @@ ScrollView {
id: colorRect
parent: viewport
anchors.fill: parent
color: palette.base
color: __style ? __style.backgroundColor : palette.base
z: -1
}
......@@ -429,7 +490,10 @@ ScrollView {
}
}
property list<TableViewColumn> columnheader
ListModel {
id: columnModel
}
highlightFollowsCurrentItem: true
model: root.model
......@@ -483,7 +547,7 @@ ScrollView {
height: parent.height
Repeater {
id: repeater
model: root.columnCount
model: columnModel
Loader {
id: itemDelegateLoader
......@@ -509,7 +573,7 @@ ScrollView {
readonly property string role: __column.role
}
readonly property TableViewColumn __column: columns[index]
readonly property TableViewColumn __column: columnItem
readonly property bool __hasModelRole: styleData.role && itemModel.hasOwnProperty(styleData.role)
readonly property bool __hasModelDataRole: styleData.role && modelData && modelData.hasOwnProperty(styleData.role)
}
......@@ -548,12 +612,12 @@ ScrollView {
property int targetIndex: -1
property int dragIndex: -1
model: columnCount
model: columnModel
delegate: Item {
z:-index
width: columns[index].width
visible: columns[index].visible
width: modelData.width
visible: modelData.visible
height: headerVisible ? headerStyle.height : 0
Loader {
......@@ -562,7 +626,7 @@ ScrollView {
anchors.left: parent.left
anchors.right: parent.right
property QtObject styleData: QtObject {
readonly property string value: columns[index].title
readonly property string value: modelData.title
readonly property bool pressed: headerClickArea.pressed
readonly property bool containsMouse: headerClickArea.containsMouse
readonly property int column: index
......@@ -608,13 +672,7 @@ ScrollView {
onReleased: {
if (repeater.targetIndex >= 0 && repeater.targetIndex != index ) {
// Rearrange the header sections
var items = new Array
for (var i = 0 ; i< columnCount ; ++i)
items.push(columns[i])
items.splice(index, 1);
items.splice(repeater.targetIndex, 0, columns[index]);
columns = items
columnModel.move(index, repeater.targetIndex, 1)
if (sortIndicatorColumn == index)
sortIndicatorColumn = repeater.targetIndex
}
......@@ -628,14 +686,14 @@ ScrollView {
Loader {
id: draghandle
property QtObject styleData: QtObject{
readonly property string value: columns[index].title
readonly property string value: modelData.title
readonly property bool pressed: headerClickArea.pressed
readonly property bool containsMouse: headerClickArea.containsMouse
readonly property int column: index
}
parent: tableHeader
width: columns[index].width
width: modelData.width
height: parent.height
sourceComponent: root.headerDelegate
visible: headerClickArea.pressed
......@@ -651,8 +709,8 @@ ScrollView {
width: 16 ; height: parent.height
anchors.right: parent.right
onPositionChanged: {
var newHeaderWidth = columns[index].width + (mouseX - offset)
columns[index].width = Math.max(minimumSize, newHeaderWidth)
var newHeaderWidth = modelData.width + (mouseX - offset)
modelData.width = Math.max(minimumSize, newHeaderWidth)
}
property bool found:false
......@@ -667,7 +725,7 @@ ScrollView {
minWidth = Math.max(minWidth, item.children[1].children[index].children[0].implicitWidth)
}
if (minWidth)
columns[index].width = minWidth
modelData.width = minWidth
}
onPressedChanged: if (pressed) offset=mouseX
cursorShape: Qt.SplitHCursor
......
......@@ -89,4 +89,6 @@ QtObject {
/*! The delegate of the column. This can be used to set the
\l TableView::itemDelegate for a specific column. */
property Component delegate
Accessible.role: Accessible.ColumnHeader
}
......@@ -621,7 +621,7 @@ ScrollView {
Accessible.role: Accessible.EditableText
/*!
\qmlproperty textDocument TextArea::textDocument
\qmlproperty TextDocument TextArea::textDocument
This property exposes the \l QTextDocument of this TextArea.
\sa TextEdit::textDocument
......
......@@ -53,13 +53,20 @@ import QtQuick.Controls.Private 1.0
provides styling and is generally designed to work well with ToolButton as
well as other controls.
Note that the ToolBar does not provide a layout of its own, but requires you
to position its contents, for instance by creating a Row.
Note that the ToolBar does not provide a layout of its own, but requires
you to position its contents, for instance by creating a \l RowLayout.
If only a single item is used within the ToolBar, it will resize to fit the implicitHeight
of its contained item. This makes it particularly suitable for use together with layouts.
Otherwise the height is platform dependent.
\code
import QtQuick.Controls 1.0
import QtQuick.Layouts 1.0
ApplicationWindow {
toolBar: ToolBar {
Row {
RowLayout {
ToolButton { ... }
ToolButton { ... }
ToolButton { ... }
......@@ -71,16 +78,68 @@ import QtQuick.Controls.Private 1.0
Item {
id: toolbar
activeFocusOnTab: false
Accessible.role: Accessible.ToolBar
width: parent ? parent.width : implicitWidth
implicitWidth: loader.item ? loader.item.implicitWidth : 0
implicitHeight: loader.item ? loader.item.implicitHeight : 0
implicitWidth: loader.item ? loader.item.implicitWidth : 200
implicitHeight: container.topMargin + container.bottomMargin + container.calcHeight()
/*! \internal */
property Component style: Qt.createComponent(Settings.style + "/ToolBarStyle.qml", toolbar)
Loader {
id: loader
anchors.fill: parent
sourceComponent: style
property var __control: toolbar
}
/*! \internal */
property alias __style: styleLoader.item
/*! \internal */
default property alias __content: container.data
/*!
\qmlproperty Item ToolBar::contentItem
This property holds the content Item of the tool bar.
Items declared as children of a ToolBar are automatically parented to the ToolBar's contentItem.
Items created dynamically need to be explicitly parented to the contentItem:
\note The implicit size of the ToolBar is calculated based on the size of its content. If you want to anchor
items inside the tool bar, you must specify an explicit width and height on the ToolBar itself.
*/
readonly property alias contentItem: container
data: [
Loader {
id: loader
anchors.fill: parent
sourceComponent: styleLoader.item ? styleLoader.item.panel : null
onLoaded: item.z = -1
Loader {
id: styleLoader
property alias __control: toolbar
sourceComponent: style
}
},
Item {
id: container
z: 1
focus: true
anchors.fill: parent
anchors.topMargin: topMargin
anchors.leftMargin: leftMargin
anchors.rightMargin: rightMargin
anchors.bottomMargin: bottomMargin
property int topMargin: __style ? __style.padding.top : 0
property int bottomMargin: __style ? __style.padding.bottom : 0
property int leftMargin: __style ? __style.padding.left : 0
property int rightMargin: __style ? __style.padding.right : 0
property Item layoutItem: container.children.length === 1 ? container.children[0] : null
function calcHeight () { return (layoutItem ? (layoutItem.implicitHeight || layoutItem.height) +
(layoutItem.anchors.fill ? layoutItem.anchors.topMargin +
layoutItem.anchors.bottomMargin : 0) :
loader.item ? loader.item.implicitHeight : 0) }
}]
}
src/controls/doc/images/qtquickcontrols-example-gallery.png

52.4 KB | W: | H:

src/controls/doc/images/qtquickcontrols-example-gallery.png

33.3 KB | W: | H:

src/controls/doc/images/qtquickcontrols-example-gallery.png
src/controls/doc/images/qtquickcontrols-example-gallery.png
src/controls/doc/images/qtquickcontrols-example-gallery.png
src/controls/doc/images/qtquickcontrols-example-gallery.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -47,12 +47,11 @@ sources += ../../private/qstyleitem.cpp \
../../private/BasicButton.qml \
../../private/FocusFrame.qml \
../../private/ModalPopupBehavior.qml \
../../private/PageSlideTransition.qml \
../../private/ScrollBar.qml \
../../private/TabBar.qml \
../../private/Control.qml \
../../private/Style.qml \
../../private/qquickpaddedstyle.h \
../../private/qquickpaddedstyle.cpp
../../private/qquickabstractstyle.h \
../../private/qquickabstractstyle.cpp
imagedirs += images
......@@ -199,7 +199,7 @@ Module {
Property { name: "__index"; type: "int" }
Property { name: "status"; type: "Status"; isReadonly: true }
Property { name: "__status"; type: "Status" }
Property { name: "pageStack"; type: "QQuickItem"; isReadonly: true; isPointer: true }
Property { name: "__stackView"; type: "QQuickItem"; isPointer: true }
Property { name: "view"; type: "QQuickItem"; isReadonly: true; isPointer: true }
Property { name: "__view"; type: "QQuickItem"; isPointer: true }
}
}
......@@ -401,6 +401,7 @@ QQuickMenuItem::QQuickMenuItem(QObject *parent)
{
connect(this, SIGNAL(__textChanged()), this, SIGNAL(textChanged()));
connect(action(), SIGNAL(shortcutChanged(QString)), this, SLOT(updateShortcut()));
connect(action(), SIGNAL(triggered()), this, SIGNAL(triggered()));
connect(action(), SIGNAL(toggled(bool)), this, SLOT(updateChecked()));
if (platformItem())
......
......@@ -50,12 +50,9 @@ QT_BEGIN_NAMESPACE
\ingroup views
\brief Provides attached properties for items pushed onto a StackView.
The Stack attached property provides information when an item becomes
active or inactive through the \l{Stack::status}{Stack.status} property.
Status will be \c Stack.Activating when an item is transitioning into
being the current item on the screen, and \c Stack.Active once the
transition stops. When it leaves the screen, it will be
\c Stack.Deactivating, and then \c Stack.Inactive.
The Stack type provides attached properties for items pushed onto a \l StackView.
It gives specific information about the item, such as its \l status and
\l index in the stack \l view the item is in.
\sa StackView
*/
......@@ -64,7 +61,7 @@ QQuickStack::QQuickStack(QObject *object)
: QObject(object),
m_index(-1),
m_status(Inactive),
m_pageStack(0)
m_view(0)
{
}
......@@ -75,11 +72,11 @@ QQuickStack *QQuickStack::qmlAttachedProperties(QObject *object)
/*!
\readonly
\qmlproperty int Stack::index
\qmlattachedproperty int Stack::index
This property holds the index of the item inside \l{pageStack}{StackView},
so that \l{StackView::get()}{pageStack.get(index)} will return the item itself.
If \l{Stack::pageStack}{pageStack} is \c null, \a index will be \c -1.
This property holds the index of the item inside \l{view}{StackView},
so that \l{StackView::get()}{StackView.get(index)} will return the item itself.
If \l{Stack::view}{view} is \c null, \a index will be \c -1.
*/
int QQuickStack::index() const
{
......@@ -96,7 +93,7 @@ void QQuickStack::setIndex(int index)
/*!
\readonly
\qmlproperty enumeration Stack::status
\qmlattachedproperty enumeration Stack::status
This property holds the status of the item. It can have one of the following values:
\list
......@@ -121,21 +118,21 @@ void QQuickStack::setStatus(Status status)
/*!
\readonly
\qmlproperty StackView Stack::pageStack
\qmlattachedproperty StackView Stack::view
This property holds the StackView the item is in. If the item is not inside
a StackView, \a pageStack will be \c null.
a StackView, \a view will be \c null.
*/
QQuickItem *QQuickStack::pageStack() const
QQuickItem *QQuickStack::view() const
{
return m_pageStack;
return m_view;
}
void QQuickStack::setStackView(QQuickItem *pageStack)
void QQuickStack::setView(QQuickItem *view)
{
if (m_pageStack != pageStack) {
m_pageStack = pageStack;
emit pageStackChanged();
if (m_view != view) {
m_view = view;
emit viewChanged();
}
}
......
......@@ -53,8 +53,8 @@ class QQuickStack : public QObject
Q_PROPERTY(int __index READ index WRITE setIndex NOTIFY indexChanged)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
Q_PROPERTY(Status __status READ status WRITE setStatus NOTIFY statusChanged)
Q_PROPERTY(QQuickItem* pageStack READ pageStack NOTIFY pageStackChanged)
Q_PROPERTY(QQuickItem* __stackView READ pageStack WRITE setStackView NOTIFY pageStackChanged)
Q_PROPERTY(QQuickItem* view READ view NOTIFY viewChanged)
Q_PROPERTY(QQuickItem* __view READ view WRITE setView NOTIFY viewChanged)
Q_ENUMS(Status)
public:
......@@ -75,18 +75,18 @@ public:
Status status() const;
void setStatus(Status status);
QQuickItem *pageStack() const;
void setStackView(QQuickItem *pageStack);
QQuickItem *view() const;
void setView(QQuickItem *view);
signals:
void statusChanged();
void pageStackChanged();
void viewChanged();
void indexChanged();
private:
int m_index;
Status m_status;
QQuickItem *m_pageStack;
QQuickItem *m_view;
};
QT_END_NAMESPACE
......
......@@ -5,31 +5,29 @@ description = Qt Quick Layouts Reference Documentation
url = http://qt-project.org/doc/qt-$QT_VER/qtquicklayouts/
version = $QT_VERSION
qhp.projects = qtquicklayouts
qhp.projects = QtQuickLayouts
qhp.qtquicklayouts.file = qtquicklayouts.qhp
qhp.qtquicklayouts.namespace = org.qt-project.qtquicklayouts.$QT_VERSION_TAG
qhp.qtquicklayouts.virtualFolder = qtquicklayouts
qhp.qtquicklayouts.indexTitle = Qt Quick Layouts
qhp.qtquicklayouts.indexRoot =
qhp.QtQuickLayouts.file = qtquicklayouts.qhp
qhp.QtQuickLayouts.namespace = org.qt-project.qtquicklayouts.$QT_VERSION_TAG
qhp.QtQuickLayouts.virtualFolder = qtquicklayouts
qhp.QtQuickLayouts.indexTitle = Qt Quick Layouts
qhp.QtQuickLayouts.indexRoot =
qhp.qtquicklayouts.filterAttributes = qtquicklayouts $QT_VERSION qtrefdoc
qhp.qtquicklayouts.customFilters.Qt.name = QtQuickLayouts $QT_VERSION
qhp.qtquicklayouts.customFilters.Qt.filterAttributes = qtquicklayouts $QT_VERSION
qhp.QtQuickLayouts.filterAttributes = qtquicklayouts $QT_VERSION qtrefdoc
qhp.QtQuickLayouts.customFilters.Qt.name = QtQuickLayouts $QT_VERSION
qhp.QtQuickLayouts.customFilters.Qt.filterAttributes = qtquicklayouts $QT_VERSION
qhp.qtquicklayouts.subprojects = qtquicklayoutsqmltypes
qhp.qtquicklayouts.subprojects.qtquicklayoutsqmltypes.title = QML Types
qhp.qtquicklayouts.subprojects.qtquicklayoutsqmltypes.indexTitle = Qt Quick Layouts
qhp.qtquicklayouts.subprojects.qtquicklayoutsqmltypes.selectors = class fake:headerfile
qhp.qtquicklayouts.subprojects.qtquicklayoutsqmltypes.sortPages = true
qhp.qtquicklayouts.subprojects.qtquicklayoutsqmltypes.type = manual
qhp.QtQuickLayouts.subprojects = qtquicklayoutsqmltypes
qhp.QtQuickLayouts.subprojects.qtquicklayoutsqmltypes.title = QML Types
qhp.QtQuickLayouts.subprojects.qtquicklayoutsqmltypes.indexTitle = Qt Quick Layouts
qhp.QtQuickLayouts.subprojects.qtquicklayoutsqmltypes.selectors = class fake:qmlClass
qhp.QtQuickLayouts.subprojects.qtquicklayoutsqmltypes.sortPages = true
qhp.QtQuickLayouts.subprojects.qtquicklayoutsqmltypes.type = manual
depends = qtqml qtquick qtwidgets qtdoc qtquickcontrols
exampledirs += ../../../examples/quick/controls/
headerdirs += ..
headerdirs += ../
sourcedirs += ../
sourcedirs += ..
imagedirs += images
......@@ -28,9 +28,15 @@
/*!
\page qtquicklayouts-index.html
\title Qt Quick Layouts
\ingroup qmlmodules
\brief A module with a set of QML elements that arranges QML items in an user interface.
\brief A module with a set of QML elements that arrange QML items in a user interface.
Qt Quick Layouts are a set of QML types used to arrange items in a user interface. In contrast
to \l{Item Positioners}{positioners}, Qt Quick Layouts can also resize their items. This makes
them well suited for resizable user interfaces. Since layouts are items they can consequently
be nested.
The module is new in Qt 5.1 and requires \l{Qt Quick} 2.1.
\section1 Getting started
......@@ -41,10 +47,13 @@
\endcode
\section1 Layouts
Layouts are items that are used to arrange items in the user interface. The layout is dynamic -
when the layout changes geometry it will typically influence the arrangement of its child
items. Since a layout is an item, layouts can consequently be nested.
\annotatedlist layouts
\section1 Related information
\section2 Reference
\list
\li \l{Qt Quick Layouts QML Types}{Qt Quick Layouts QML Types}
\endlist
*/
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\qmlmodule QtQuick.Layouts 1
\title Qt Quick Layouts QML Types
\ingroup qmlmodules
\brief Provides QML types for arranging QML items in a user interface.
The \l{Qt Quick Layouts} module provides QML types for arranging
QML items in a user interface.
These QML types work in conjunction with \l{Qt Quick} and
\l{Qt Quick Controls}.
The QML types can be imported into your application using the
following import statement in your .qml file.
\code
import QtQuick.Layouts 1.0
\endcode
*/
......@@ -60,11 +60,33 @@
For instance, you can specify \l minimumWidth, \l preferredWidth, and
\l maximumWidth if the default values are not satisfactory.
\l fillWidth and \l fillHeight allows you to specify whether an item should
fill the cell(s) it occupies. This allows it to stretch between \l minimumWidth
and \l maximumWidth (or \l minimumHeight and \l maximumHeight if \l fillHeight is \c true).
When a layout is resized, items may grow or shrink. Due to this, items have a
\l{Layout::minimumWidth}{minimum size}, \l{Layout::preferredWidth}{preferred size} and a
\l{Layout::maximumWidth}{maximum size}.
For each item, preferred size may come from one of several sources. It can be specified with
the \l preferredWidth and \l preferredHeight properties. If these properties are not
specified, it will use the item's \l{Item::implicitWidth}{implicitWidth} or
\l{Item::implicitHeight}{implicitHeight} as the preferred size.
Finally, if neither of these properties are set, it will use the \l{Item::width}{width} and
\l{Item::height}{height} properties of the item. Note that is provided only as a final
fallback. If you want to override the preferred size, you should use
\l preferredWidth or \l preferredHeight.
If minimum size have not been explicitly specified on an item, the size is set to \c 0.
If maximum size have not been explicitly specified on an item, the size is set to
\c Number.POSITIVE_INFINITY.
For layouts, the implicit minimum and maximum size depends on the content of the layouts.
The \l fillWidth and \l fillHeight properties can either be \c true or \c false. If it is \c
false, the item's size will be fixed to its preferred size. Otherwise, it will grow or shrink
between its minimum and maximum size as the layout is resized.
\note It is not recommended to have bindings to the x, y, width, or height properties of items
in a layout, since this would conflict with the goal of the Layout, and also cause binding
loops.
If \l fillWidth or \l fillHeight is \c false, the items' size will be fixed to its preferred size.
\sa GridLayout
\sa RowLayout
......@@ -100,7 +122,7 @@ QQuickLayoutAttached::QQuickLayoutAttached(QObject *parent)
}
/*!
\qmlproperty real Layout::minimumWidth
\qmlattachedproperty real Layout::minimumWidth
This property holds the maximum width of an item in a layout.
The default value is the items implicit minimum width.
......@@ -129,7 +151,7 @@ void QQuickLayoutAttached::setMinimumWidth(qreal width)
}
/*!
\qmlproperty real Layout::minimumHeight
\qmlattachedproperty real Layout::minimumHeight
The default value is the items implicit minimum height.
......@@ -156,7 +178,7 @@ void QQuickLayoutAttached::setMinimumHeight(qreal height)
}
/*!
\qmlproperty real Layout::preferredWidth
\qmlattachedproperty real Layout::preferredWidth
This property holds the preferred width of an item in a layout.
If the preferred width is -1 it will be ignored, and the layout
......@@ -177,7 +199,7 @@ void QQuickLayoutAttached::setPreferredWidth(qreal width)
}
/*!
\qmlproperty real Layout::preferredHeight
\qmlattachedproperty real Layout::preferredHeight
This property holds the preferred height of an item in a layout.
If the preferred height is -1 it will be ignored, and the layout
......@@ -198,14 +220,14 @@ void QQuickLayoutAttached::setPreferredHeight(qreal height)
}
/*!
\qmlproperty real Layout::maximumWidth
\qmlattachedproperty real Layout::maximumWidth
This property holds the maximum width of an item in a layout.
The default value is the items implicit maximum width.
If the item is a layout, the implicit maximum width will be the maximum width the layout can
have without any of its items grow beyond their maximum width.
The implicit maximum width for any other item is \c Number.POSITIVE_INFINITE.
The implicit maximum width for any other item is \c Number.POSITIVE_INFINITY.
Setting this value to -1 will reset the width back to its implicit maximum width.
......@@ -226,13 +248,13 @@ void QQuickLayoutAttached::setMaximumWidth(qreal width)
}
/*!
\qmlproperty real Layout::maximumHeight
\qmlattachedproperty real Layout::maximumHeight
The default value is the items implicit maximum height.
If the item is a layout, the implicit maximum height will be the maximum height the layout can
have without any of its items grow beyond their maximum height.
The implicit maximum height for any other item is \c Number.POSITIVE_INFINITE.
The implicit maximum height for any other item is \c Number.POSITIVE_INFINITY.
Setting this value to -1 will reset the height back to its implicit maximum height.
......@@ -299,7 +321,7 @@ void QQuickLayoutAttached::setMaximumImplicitSize(const QSizeF &sz)
}
/*!
\qmlproperty bool Layout::fillWidth
\qmlattachedproperty bool Layout::fillWidth
If this property is \c true, the item will be as wide as possible while respecting
the given constraints. If the property is \c false, the item will have a fixed width
......@@ -319,7 +341,7 @@ void QQuickLayoutAttached::setFillWidth(bool fill)
}
/*!
\qmlproperty bool Layout::fillHeight
\qmlattachedproperty bool Layout::fillHeight
If this property is \c true, the item will be as tall as possible while respecting
the given constraints. If the property is \c false, the item will have a fixed height
......@@ -339,7 +361,7 @@ void QQuickLayoutAttached::setFillHeight(bool fill)
}
/*!
\qmlproperty int Layout::row
\qmlattachedproperty int Layout::row
This property allows you to specify the row position of an item in a \l GridLayout.
......@@ -357,7 +379,7 @@ void QQuickLayoutAttached::setRow(int row)
}
/*!
\qmlproperty int Layout::column
\qmlattachedproperty int Layout::column
This property allows you to specify the column position of an item in a \l GridLayout.
......@@ -376,7 +398,7 @@ void QQuickLayoutAttached::setColumn(int column)
/*!
\qmlproperty Qt.Alignment Layout::alignment
\qmlattachedproperty Qt.Alignment Layout::alignment
This property allows you to specify the alignment of an item within the cell(s) it occupies.
......@@ -385,7 +407,7 @@ void QQuickLayoutAttached::setColumn(int column)
/*!
\qmlproperty int Layout::rowSpan
\qmlattachedproperty int Layout::rowSpan
This property allows you to specify the row span of an item in a \l GridLayout.
......@@ -397,7 +419,7 @@ void QQuickLayoutAttached::setColumn(int column)
/*!
\qmlproperty int Layout::columnSpan
\qmlattachedproperty int Layout::columnSpan
This property allows you to specify the column span of an item in a \l GridLayout.
......
......@@ -48,33 +48,63 @@
/*!
\qmltype RowLayout
\instantiates QQuickRowLayout
\inherits Item
\inqmlmodule QtQuick.Layouts 1.0
\ingroup layouts
\brief Identical to \l GridLayout, but having only one row.
It is available as a convenience for developers, as it offers a cleaner API.
Items in a RowLayout support these attached properties:
\list
\li \l{Layout::minimumWidth}{Layout.minimumWidth}
\li \l{Layout::minimumHeight}{Layout.minimumHeight}
\li \l{Layout::preferredWidth}{Layout.preferredWidth}
\li \l{Layout::preferredHeight}{Layout.preferredHeight}
\li \l{Layout::maximumWidth}{Layout.maximumWidth}
\li \l{Layout::maximumHeight}{Layout.maximumHeight}
\li \l{Layout::fillWidth}{Layout.fillWidth}
\li \l{Layout::fillHeight}{Layout.fillHeight}
\li \l{Layout::alignment}{Layout.alignment}
\endlist
\sa ColumnLayout
\sa GridLayout
\sa Row
*/
/*!
\qmltype ColumnLayout
\instantiates QQuickColumnLayout
\inherits Item
\inqmlmodule QtQuick.Layouts 1.0
\ingroup layouts
\brief Identical to \l GridLayout, but having only one column.
It is available as a convenience for developers, as it offers a cleaner API.
Items in a ColumnLayout support these attached properties:
\list
\li \l{Layout::minimumWidth}{Layout.minimumWidth}
\li \l{Layout::minimumHeight}{Layout.minimumHeight}
\li \l{Layout::preferredWidth}{Layout.preferredWidth}
\li \l{Layout::preferredHeight}{Layout.preferredHeight}
\li \l{Layout::maximumWidth}{Layout.maximumWidth}
\li \l{Layout::maximumHeight}{Layout.maximumHeight}
\li \l{Layout::fillWidth}{Layout.fillWidth}
\li \l{Layout::fillHeight}{Layout.fillHeight}
\li \l{Layout::alignment}{Layout.alignment}
\endlist
\sa RowLayout
\sa GridLayout
\sa Column
*/
/*!
\qmltype GridLayout
\instantiates QQuickGridLayout
\inherits Item
\inqmlmodule QtQuick.Layouts 1.0
\ingroup layouts
\brief Provides a way of dynamically arranging items in a grid.
......@@ -112,39 +142,42 @@
specify the row span or column span by setting the \l{Layout::rowSpan}{Layout.rowSpan} or
\l{Layout::columnSpan}{Layout.columnSpan} properties.
When the layout is resized, items may grow or shrink. Due to this, items have a
\l{Layout::minimumWidth}{minimum size}, \l{Layout::preferredWidth}{preferred size} and a
\l{Layout::maximumWidth}{maximum size}.
Preferred size may come from one of several sources. It can be specified with the
\l{Layout::preferredWidth}{Layout.preferredWidth} and
\l{Layout::preferredHeight}{Layout.preferredHeight} properties. If these properties are not
specified, it will use the items' \l{Item::implicitWidth}{implicitWidth} or
\l{Item::implicitHeight}{implicitHeight} as the preferred size.
Finally, if neither of these properties are set, it will use the \l{Item::width}{width} and
\l{Item::height}{height} properties of the item. Note that is provided only as a final
fallback. If you want to override the preferred size, you should use
\l{Layout::preferredWidth}{Layout.preferredWidth} or
\l{Layout::preferredHeight}{Layout.preferredHeight}.
The \l{Layout::fillWidth}{Layout.fillWidth} and \l{Layout::fillHeight}{Layout.fillHeight} can
either be \c true or \c false. If it is \c false, the items size will be fixed to its preferred
size. Otherwise, it will grow or shrink between its minimum and maximum size.
\note It is not recommended to have bindings to the width and height properties of items in a
GridLayout, since this would conflict with the goal of the GridLayout.
Items in a GridLayout support these attached properties:
\list
\li \l{Layout::row}{Layout.row}
\li \l{Layout::column}{Layout.column}
\li \l{Layout::rowSpan}{Layout.rowSpan}
\li \l{Layout::columnSpan}{Layout.columnSpan}
\li \l{Layout::minimumWidth}{Layout.minimumWidth}
\li \l{Layout::minimumHeight}{Layout.minimumHeight}
\li \l{Layout::preferredWidth}{Layout.preferredWidth}
\li \l{Layout::preferredHeight}{Layout.preferredHeight}
\li \l{Layout::maximumWidth}{Layout.maximumWidth}
\li \l{Layout::maximumHeight}{Layout.maximumHeight}
\li \l{Layout::fillWidth}{Layout.fillWidth}
\li \l{Layout::fillHeight}{Layout.fillHeight}
\li \l{Layout::alignment}{Layout.alignment}
\endlist
\sa RowLayout
\sa ColumnLayout
\sa Grid
*/
QT_BEGIN_NAMESPACE
static const qreal q_declarativeLayoutDefaultSpacing = 4.0;
static qreal quickLayoutDefaultSpacing()
{
qreal spacing = 5.0;
#ifndef Q_OS_MAC
// On mac the DPI is always 72 so we should not scale it
spacing = qRound(spacing * (qreal(qt_defaultDpiX()) / 96.0));
#endif
return spacing;
}
QQuickGridLayoutBase::QQuickGridLayoutBase(QQuickGridLayoutBasePrivate &dd,
Qt::Orientation orientation,
......@@ -177,12 +210,18 @@ QSizeF QQuickGridLayoutBase::sizeHint(Qt::SizeHint whichSizeHint) const
return d->engine.sizeHint(whichSizeHint, QSizeF());
}
QQuickGridLayoutBase::~QQuickGridLayoutBase()
{
d_func()->m_isReady = false;
}
void QQuickGridLayoutBase::componentComplete()
{
Q_D(QQuickGridLayoutBase);
quickLayoutDebug() << objectName() << "QQuickGridLayoutBase::componentComplete()" << parent();
d->m_disableRearrange = true;
QQuickLayout::componentComplete(); // will call our geometryChange(), (where isComponentComplete() == true)
d->m_isReady = true;
d->m_disableRearrange = false;
updateLayoutItems();
......@@ -228,7 +267,7 @@ void QQuickGridLayoutBase::componentComplete()
void QQuickGridLayoutBase::invalidate(QQuickItem *childItem)
{
Q_D(QQuickGridLayoutBase);
if (!isComponentComplete())
if (!isReady())
return;
quickLayoutDebug() << "QQuickGridLayoutBase::invalidate()";
......@@ -267,7 +306,7 @@ void QQuickGridLayoutBase::invalidate(QQuickItem *childItem)
void QQuickGridLayoutBase::updateLayoutItems()
{
Q_D(QQuickGridLayoutBase);
if (!isComponentComplete() || !isVisible())
if (!isReady() || !isVisible())
return;
quickLayoutDebug() << "QQuickGridLayoutBase::updateLayoutItems";
d->engine.deleteItems();
......@@ -287,7 +326,7 @@ void QQuickGridLayoutBase::itemChange(ItemChange change, const ItemChangeData &v
QObject::connect(item, SIGNAL(implicitWidthChanged()), this, SLOT(onItemImplicitSizeChanged()));
QObject::connect(item, SIGNAL(implicitHeightChanged()), this, SLOT(onItemImplicitSizeChanged()));
if (isComponentComplete() && isVisible())
if (isReady() && isVisible())
updateLayoutItems();
} else if (change == ItemChildRemovedChange) {
quickLayoutDebug() << "ItemChildRemovedChange";
......@@ -296,7 +335,7 @@ void QQuickGridLayoutBase::itemChange(ItemChange change, const ItemChangeData &v
QObject::disconnect(item, SIGNAL(visibleChanged()), this, SLOT(onItemVisibleChanged()));
QObject::disconnect(item, SIGNAL(implicitWidthChanged()), this, SLOT(onItemImplicitSizeChanged()));
QObject::disconnect(item, SIGNAL(implicitHeightChanged()), this, SLOT(onItemImplicitSizeChanged()));
if (isComponentComplete() && isVisible())
if (isReady() && isVisible())
updateLayoutItems();
}
......@@ -307,7 +346,7 @@ void QQuickGridLayoutBase::geometryChanged(const QRectF &newGeometry, const QRec
{
Q_D(QQuickGridLayoutBase);
QQuickLayout::geometryChanged(newGeometry, oldGeometry);
if (d->m_disableRearrange || !isComponentComplete() || !newGeometry.isValid())
if (d->m_disableRearrange || !isReady() || !newGeometry.isValid())
return;
quickLayoutDebug() << "QQuickGridLayoutBase::geometryChanged" << newGeometry << oldGeometry;
rearrange(newGeometry.size());
......@@ -321,6 +360,11 @@ void QQuickGridLayoutBase::removeGridItem(QGridLayoutItem *gridItem)
d->engine.removeRows(index, 1, d->orientation);
}
bool QQuickGridLayoutBase::isReady() const
{
return d_func()->m_isReady;
}
void QQuickGridLayoutBase::removeLayoutItem(QQuickItem *item)
{
Q_D(QQuickGridLayoutBase);
......@@ -334,7 +378,7 @@ void QQuickGridLayoutBase::removeLayoutItem(QQuickItem *item)
void QQuickGridLayoutBase::onItemVisibleChanged()
{
if (!isComponentComplete())
if (!isReady())
return;
quickLayoutDebug() << "QQuickGridLayoutBase::onItemVisibleChanged";
updateLayoutItems();
......@@ -342,6 +386,8 @@ void QQuickGridLayoutBase::onItemVisibleChanged()
void QQuickGridLayoutBase::onItemDestroyed()
{
if (!isReady())
return;
Q_D(QQuickGridLayoutBase);
quickLayoutDebug() << "QQuickGridLayoutBase::onItemDestroyed";
QQuickItem *inDestruction = static_cast<QQuickItem *>(sender());
......@@ -354,6 +400,8 @@ void QQuickGridLayoutBase::onItemDestroyed()
void QQuickGridLayoutBase::onItemImplicitSizeChanged()
{
if (!isReady())
return;
QQuickItem *item = static_cast<QQuickItem *>(sender());
Q_ASSERT(item);
invalidate(item);
......@@ -362,7 +410,7 @@ void QQuickGridLayoutBase::onItemImplicitSizeChanged()
void QQuickGridLayoutBase::rearrange(const QSizeF &size)
{
Q_D(QQuickGridLayoutBase);
if (!isComponentComplete())
if (!isReady())
return;
quickLayoutDebug() << objectName() << "QQuickGridLayoutBase::rearrange()" << size;
......@@ -412,9 +460,10 @@ QQuickGridLayout::QQuickGridLayout(QQuickItem *parent /* = 0*/)
: QQuickGridLayoutBase(*new QQuickGridLayoutPrivate, Qt::Horizontal, parent)
{
Q_D(QQuickGridLayout);
d->columnSpacing = q_declarativeLayoutDefaultSpacing;
d->rowSpacing = q_declarativeLayoutDefaultSpacing;
d->engine.setSpacing(q_declarativeLayoutDefaultSpacing, Qt::Horizontal | Qt::Vertical);
const qreal defaultSpacing = quickLayoutDefaultSpacing();
d->columnSpacing = defaultSpacing;
d->rowSpacing = defaultSpacing;
d->engine.setSpacing(defaultSpacing, Qt::Horizontal | Qt::Vertical);
}
/*!
......@@ -672,7 +721,7 @@ QQuickLinearLayout::QQuickLinearLayout(Qt::Orientation orientation,
: QQuickGridLayoutBase(*new QQuickLinearLayoutPrivate, orientation, parent)
{
Q_D(QQuickLinearLayout);
d->spacing = q_declarativeLayoutDefaultSpacing;
d->spacing = quickLayoutDefaultSpacing();
d->engine.setSpacing(d->spacing, Qt::Horizontal | Qt::Vertical);
}
......
......@@ -62,8 +62,7 @@ public:
explicit QQuickGridLayoutBase(QQuickGridLayoutBasePrivate &dd,
Qt::Orientation orientation,
QQuickItem *parent = 0);
~QQuickGridLayoutBase() {}
~QQuickGridLayoutBase();
void componentComplete();
void invalidate(QQuickItem *childItem = 0);
Qt::Orientation orientation() const;
......@@ -86,6 +85,7 @@ protected slots:
private:
void removeGridItem(QGridLayoutItem *gridItem);
bool isReady() const;
Q_DECLARE_PRIVATE(QQuickGridLayoutBase)
};
......@@ -95,10 +95,11 @@ class QQuickGridLayoutBasePrivate : public QQuickLayoutPrivate
Q_DECLARE_PUBLIC(QQuickGridLayoutBase)
public:
QQuickGridLayoutBasePrivate() : m_disableRearrange(true) { }
QQuickGridLayoutBasePrivate() : m_disableRearrange(true), m_isReady(false) { }
QQuickGridLayoutEngine engine;
Qt::Orientation orientation;
bool m_disableRearrange;
bool m_isReady;
QSet<QQuickItem *> m_ignoredItems;
};
......
......@@ -64,7 +64,7 @@ FocusScope {
property Item __panel: panelLoader.item
/*! \internal */
property var styleHints: []
property var styleHints
implicitWidth: __panel ? __panel.implicitWidth: 0
implicitHeight: __panel ? __panel.implicitHeight: 0
......
......@@ -39,6 +39,7 @@
****************************************************************************/
import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Controls.Private 1.0
/*!
\qmltype Style
......@@ -46,7 +47,7 @@ import QtQuick.Controls 1.0
\inqmlmodule QtQuick.Controls.Private 1.0
*/
QtObject {
AbstractStyle {
/*! The control attached to this style */
readonly property Item control: __control
......