summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Dale <richard.dale@codethink.co.uk>2013-07-04 09:56:52 +0100
committerRichard Dale <richard.dale@codethink.co.uk>2013-07-04 09:56:52 +0100
commitacf9e50d52c4d09a1aed9490bb2f3c5de7dce9bb (patch)
tree5b05df5a9e67f397bc7629f0921bc30c64bcc03e
parenta7e874ddf3496766903fc88e52fb61573c3d3f74 (diff)
parentaa4ddfd8443f07badc0899d835027e46c6e0dfd8 (diff)
downloadqtquickcontrols-acf9e50d52c4d09a1aed9490bb2f3c5de7dce9bb.tar.gz
Merge v5.1.0 releasebaserock/morph
-rw-r--r--examples/quick/controls/gallery/content/Controls.qml8
-rw-r--r--examples/quick/controls/gallery/content/Layouts.qml107
-rw-r--r--examples/quick/controls/gallery/content/ModelView.qml2
-rw-r--r--examples/quick/controls/gallery/content/Panel.qml140
-rw-r--r--examples/quick/controls/gallery/content/Styles.qml379
-rw-r--r--examples/quick/controls/gallery/images/bubble.pngbin0 -> 214 bytes
-rw-r--r--examples/quick/controls/gallery/images/button-pressed.pngbin0 -> 3094 bytes
-rw-r--r--examples/quick/controls/gallery/images/button.pngbin0 -> 3164 bytes
-rw-r--r--examples/quick/controls/gallery/images/page.pngbin639 -> 0 bytes
-rw-r--r--examples/quick/controls/gallery/images/panel.pngbin1756 -> 0 bytes
-rw-r--r--examples/quick/controls/gallery/images/progress-background.pngbin0 -> 456 bytes
-rw-r--r--examples/quick/controls/gallery/images/progress-fill.pngbin0 -> 507 bytes
-rw-r--r--examples/quick/controls/gallery/images/slider-handle.pngbin0 -> 3523 bytes
-rw-r--r--examples/quick/controls/gallery/images/textfield.pngbin0 -> 3023 bytes
-rw-r--r--examples/quick/controls/gallery/main.qml227
-rw-r--r--examples/quick/controls/gallery/resources.qrc11
-rw-r--r--examples/quick/controls/shared/qt_quick_controls_examplemain.h11
-rw-r--r--examples/quick/controls/splitview/main.qml8
-rw-r--r--examples/quick/controls/tableview/main.qml96
-rw-r--r--examples/quick/controls/text/example.html22
-rw-r--r--examples/quick/controls/text/qml/ToolBarSeparator.qml61
-rw-r--r--examples/quick/controls/text/qml/images/logo32.pngbin1410 -> 0 bytes
-rw-r--r--examples/quick/controls/text/qml/images/qt-logo.pngbin0 -> 3960 bytes
-rw-r--r--examples/quick/controls/text/qml/main.qml199
-rw-r--r--examples/quick/controls/text/resources.qrc51
-rw-r--r--examples/quick/controls/text/src/documenthandler.cpp60
-rw-r--r--examples/quick/controls/text/src/documenthandler.h16
-rw-r--r--examples/quick/controls/text/src/main.cpp14
-rw-r--r--examples/quick/controls/text/text.pro3
-rw-r--r--examples/quick/controls/touch/content/ButtonPage.qml2
-rw-r--r--examples/quick/controls/touch/content/TabBarPage.qml4
-rw-r--r--examples/quick/controls/touch/main.qml12
-rw-r--r--src/controls/ApplicationWindow.qml8
-rw-r--r--src/controls/Button.qml24
-rw-r--r--src/controls/ComboBox.qml25
-rw-r--r--src/controls/GroupBox.qml12
-rw-r--r--src/controls/ProgressBar.qml14
-rw-r--r--src/controls/ScrollView.qml17
-rw-r--r--src/controls/Slider.qml47
-rw-r--r--src/controls/SpinBox.qml30
-rw-r--r--src/controls/SplitView.qml71
-rw-r--r--src/controls/StackView.qml269
-rw-r--r--src/controls/StatusBar.qml86
-rw-r--r--src/controls/TabView.qml7
-rw-r--r--src/controls/TableView.qml350
-rw-r--r--src/controls/TableViewColumn.qml12
-rw-r--r--src/controls/TextArea.qml19
-rw-r--r--src/controls/TextField.qml7
-rw-r--r--src/controls/ToolBar.qml85
-rw-r--r--src/controls/ToolButton.qml14
-rw-r--r--src/controls/controls.pro2
-rw-r--r--src/controls/doc/images/qtquickcontrols-example-gallery.pngbin53632 -> 34070 bytes
-rw-r--r--src/controls/doc/qtquickcontrols.qdocconf20
-rw-r--r--src/controls/doc/src/qtquickcontrols-index.qdoc34
-rw-r--r--src/controls/doc/src/qtquickcontrols-overview.qdoc79
-rw-r--r--src/controls/plugins.qmltypes8
-rw-r--r--src/controls/qmldir2
-rw-r--r--src/controls/qquickaction.cpp10
-rw-r--r--src/controls/qquickaction_p.h9
-rw-r--r--src/controls/qquickexclusivegroup.cpp16
-rw-r--r--src/controls/qquickmenu.cpp4
-rw-r--r--src/controls/qquickmenuitem.cpp13
-rw-r--r--src/controls/qquickstack.cpp38
-rw-r--r--src/controls/qquickstack_p.h12
-rw-r--r--src/layouts/doc/images/rowlayout-minimum.pngbin0 -> 5481 bytes
-rw-r--r--src/layouts/doc/qtquicklayouts.qdocconf35
-rw-r--r--src/layouts/doc/src/qtquicklayouts-index.qdoc26
-rw-r--r--src/layouts/doc/src/qtquicklayouts-overview.qdoc135
-rw-r--r--src/layouts/doc/src/qtquicklayouts.qdoc (renamed from src/controls/doc/src/styles.qdoc)23
-rw-r--r--src/layouts/doc/src/snippets/windowconstraints.qml89
-rw-r--r--src/layouts/plugins.qmltypes6
-rw-r--r--src/layouts/qquickgridlayoutengine.cpp95
-rw-r--r--src/layouts/qquickgridlayoutengine_p.h10
-rw-r--r--src/layouts/qquicklayout.cpp60
-rw-r--r--src/layouts/qquicklayout_p.h19
-rw-r--r--src/layouts/qquicklinearlayout.cpp121
-rw-r--r--src/layouts/qquicklinearlayout_p.h7
-rw-r--r--src/private/AbstractCheckable.qml17
-rw-r--r--src/private/BasicButton.qml46
-rw-r--r--src/private/Control.qml6
-rw-r--r--src/private/ScrollBar.qml2
-rw-r--r--src/private/ScrollViewHelper.qml12
-rw-r--r--src/private/Style.qml3
-rw-r--r--src/private/TabBar.qml11
-rw-r--r--src/private/plugin.cpp4
-rw-r--r--src/private/private.pro6
-rw-r--r--src/private/qmldir2
-rw-r--r--src/private/qquickabstractstyle.cpp (renamed from src/private/qquickpaddedstyle.cpp)58
-rw-r--r--src/private/qquickabstractstyle_p.h (renamed from src/private/qquickpaddedstyle_p.h)25
-rw-r--r--src/private/qquickcontrolsettings.cpp11
-rw-r--r--src/private/qquickcontrolsettings_p.h3
-rw-r--r--src/private/qquickstyleitem.cpp108
-rw-r--r--src/private/qquickstyleitem_p.h9
-rw-r--r--src/private/style.js15
-rw-r--r--src/styles/Base/ButtonStyle.qml7
-rw-r--r--src/styles/Base/CheckBoxStyle.qml10
-rw-r--r--src/styles/Base/ComboBoxStyle.qml7
-rw-r--r--src/styles/Base/GroupBoxStyle.qml3
-rw-r--r--src/styles/Base/MenuBarStyle.qml1
-rw-r--r--src/styles/Base/MenuStyle.qml7
-rw-r--r--src/styles/Base/ProgressBarStyle.qml14
-rw-r--r--src/styles/Base/RadioButtonStyle.qml12
-rw-r--r--src/styles/Base/ScrollViewStyle.qml146
-rw-r--r--src/styles/Base/SliderStyle.qml10
-rw-r--r--src/styles/Base/SpinBoxStyle.qml5
-rw-r--r--src/styles/Base/StatusBarStyle.qml14
-rw-r--r--src/styles/Base/TabViewStyle.qml36
-rw-r--r--src/styles/Base/TableViewStyle.qml62
-rw-r--r--src/styles/Base/TextFieldStyle.qml3
-rw-r--r--src/styles/Base/ToolBarStyle.qml36
-rw-r--r--src/styles/Base/ToolButtonStyle.qml1
-rw-r--r--src/styles/Desktop/ButtonStyle.qml4
-rw-r--r--src/styles/Desktop/CheckBoxStyle.qml14
-rw-r--r--src/styles/Desktop/ComboBoxStyle.qml2
-rw-r--r--src/styles/Desktop/GroupBoxStyle.qml10
-rw-r--r--src/styles/Desktop/RadioButtonStyle.qml2
-rw-r--r--src/styles/Desktop/ScrollViewStyle.qml6
-rw-r--r--src/styles/Desktop/SliderStyle.qml2
-rw-r--r--src/styles/Desktop/SpinBoxStyle.qml21
-rw-r--r--src/styles/Desktop/StatusBarStyle.qml15
-rw-r--r--src/styles/Desktop/TabViewStyle.qml17
-rw-r--r--src/styles/Desktop/TableViewStyle.qml46
-rw-r--r--src/styles/Desktop/TextFieldStyle.qml8
-rw-r--r--src/styles/Desktop/ToolBarStyle.qml14
-rw-r--r--src/styles/Desktop/ToolButtonStyle.qml13
-rw-r--r--src/styles/doc/qtquickcontrolsstyles.qdocconf43
-rw-r--r--src/styles/doc/src/qtquickcontrolsstyles-index.qdoc99
-rw-r--r--src/styles/styles.pro2
-rw-r--r--tests/auto/README.txt38
-rw-r--r--tests/auto/controls/data/tableview/table_activated.qml17
-rw-r--r--tests/auto/controls/data/tableview/table_delegate.qml6
-rw-r--r--tests/auto/controls/data/tableview/table_dynamiccolumns.qml65
-rw-r--r--tests/auto/controls/data/tst_combobox.qml10
-rw-r--r--tests/auto/controls/data/tst_rowlayout.qml86
-rw-r--r--tests/auto/controls/data/tst_shortcuts.qml2
-rw-r--r--tests/auto/controls/data/tst_slider.qml11
-rw-r--r--tests/auto/controls/data/tst_spinbox.qml20
-rw-r--r--tests/auto/controls/data/tst_stack.qml6
-rw-r--r--tests/auto/controls/data/tst_stackview.qml (renamed from tests/auto/controls/data/tst_pagestack.qml)4
-rw-r--r--tests/auto/controls/data/tst_tableview.qml206
-rw-r--r--tests/auto/controls/data/tst_tabview.qml48
-rw-r--r--tests/auto/testplugin/README.txt11
-rw-r--r--tests/manual/scrollview/main.qml20
143 files changed, 3336 insertions, 1647 deletions
diff --git a/examples/quick/controls/gallery/content/Controls.qml b/examples/quick/controls/gallery/content/Controls.qml
index 310eee59..c1403da5 100644
--- a/examples/quick/controls/gallery/content/Controls.qml
+++ b/examples/quick/controls/gallery/content/Controls.qml
@@ -180,6 +180,14 @@ Item {
height: parent.height - group1.height - group2.height - 2 * parent.spacing
anchors { right: parent.right }
}
+
+ MouseArea {
+ id: contextMenu
+ parent: area.viewport
+ anchors.fill: parent
+ acceptedButtons: Qt.RightButton
+ onPressed: editmenu.popup()
+ }
}
}
}
diff --git a/examples/quick/controls/gallery/content/Layouts.qml b/examples/quick/controls/gallery/content/Layouts.qml
new file mode 100644
index 00000000..ac0a53a3
--- /dev/null
+++ b/examples/quick/controls/gallery/content/Layouts.qml
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Layouts 1.0
+
+Item {
+ id:root
+ anchors.fill: parent
+ anchors.margins: 8
+
+ ColumnLayout {
+ id: mainLayout
+ anchors.fill: parent
+ spacing: 4
+ GroupBox {
+ id: rowBox
+ title: "Row layout"
+ Layout.fillWidth: true
+ RowLayout {
+ id: rowLayout
+ anchors.fill: parent
+ TextField {
+ placeholderText: "This wants to grow horizontally"
+ Layout.fillWidth: true
+ }
+ Button {
+ text: "Button"
+ }
+ }
+ }
+
+ GroupBox {
+ id: gridBox
+ title: "Grid layout"
+ Layout.fillWidth: true
+
+ GridLayout {
+ id: gridLayout
+ anchors.fill: parent
+ rows: 3
+ flow: GridLayout.TopToBottom
+
+ Label { text: "Line 1" }
+ Label { text: "Line 2" }
+ Label { text: "Line 3" }
+
+ TextField { }
+ TextField { }
+ TextField { }
+
+ TextArea {
+ text: "This widget spans over three rows in the GridLayout.\n"
+ + "All items in the GridLayout are implicitly positioned from top to bottom."
+ Layout.rowSpan: 3
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ }
+ }
+ }
+ TextArea {
+ id: t3
+ text: "This fills the whole cell"
+ Layout.minimumHeight: 30
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ }
+ }
+}
diff --git a/examples/quick/controls/gallery/content/ModelView.qml b/examples/quick/controls/gallery/content/ModelView.qml
index e6a6040f..483d99ee 100644
--- a/examples/quick/controls/gallery/content/ModelView.qml
+++ b/examples/quick/controls/gallery/content/ModelView.qml
@@ -51,7 +51,7 @@ Item {
width: 600
height: 300
anchors.fill: parent
- anchors.margins: Qt.platform.os === "mac" ? 12 : 6
+ anchors.margins: Qt.platform.os === "osx" ? 12 : 6
// XmlListModel {
// id: flickerModel
diff --git a/examples/quick/controls/gallery/content/Panel.qml b/examples/quick/controls/gallery/content/Panel.qml
deleted file mode 100644
index bdb10f83..00000000
--- a/examples/quick/controls/gallery/content/Panel.qml
+++ /dev/null
@@ -1,140 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Quick Controls module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-
-
-
-import QtQuick 2.1
-import QtQuick.Controls 1.0
-
-Rectangle {
- id:root
-
- width: 540
- height: 340
- color:"#c3c3c3"
- ScrollView {
- frameVisible: false
- anchors.fill: parent
-
- Item {
- width:600
- height:600
- BorderImage {
- id: page
- source: "../images/page.png"
- y:10; x:50
- width: 400; height: 400
- border.left: 12; border.top: 12
- border.right: 12; border.bottom: 12
- Text {
- id:text
- anchors.fill: parent
- anchors.margins: 40
- text:textfield.text
- }
- Rectangle {
- border.color: "#444"
- anchors.centerIn: parent
- color: Qt.rgba(s1.value, s2.value, s3.value)
- width: 200
- height: width
- }
-
- }
-
- BorderImage {
- id: sidebar
- source: "../images/panel.png"
- anchors.left: parent.left
- anchors.top: parent.top
- width: show ? 160 : 40
- height:root.height
- Behavior on width { NumberAnimation { easing.type: Easing.OutSine ; duration: 250 } }
- property bool show: false
- border.left: 0;
- border.right: 26;
- MouseArea {
- id:mouseArea
- anchors.fill: parent
- onClicked: sidebar.show = !sidebar.show
- }
- Column {
- id: panel1
- opacity: sidebar.show ? 1 : 0
- Behavior on opacity { NumberAnimation { easing.type:Easing.InCubic; duration: 600} }
-
- scale: sidebar.show ? 1 : 0
- Behavior on scale { NumberAnimation { easing.type:Easing.InCubic; duration: 200 } }
- transformOrigin: Item.Top
-
- anchors.top: parent.top
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.margins: 12
- spacing:12
-
- Button { width: parent.width - 12; text: "Close Panel"; onClicked: sidebar.show = false}
- TextField { id: textfield; text: "Some text" ; width: parent.width - 12}
- SpinBox { width: parent.width - 12}
- CheckBox{ id: expander; text:"Sliders"}
- }
-
- Column {
- id: panel2
- opacity: expander.checked && sidebar.show ? 1 : 0
- scale: opacity
- Behavior on opacity{ NumberAnimation { easing.type:Easing.OutSine; duration: 300}}
- transformOrigin: Item.Top
- anchors.top: panel1.bottom
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.margins: 12
- spacing: 12
- Slider { id: s1; width:parent.width - 12; value:0.5}
- Slider { id: s2; width:parent.width - 12; value:0.5}
- Slider { id: s3; width:parent.width - 12; value:0.5}
-
- }
- }
- }
- }
-}
diff --git a/examples/quick/controls/gallery/content/Styles.qml b/examples/quick/controls/gallery/content/Styles.qml
index b5e98f80..e46a9ea0 100644
--- a/examples/quick/controls/gallery/content/Styles.qml
+++ b/examples/quick/controls/gallery/content/Styles.qml
@@ -45,195 +45,308 @@
import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Controls.Styles 1.0
-import QtQuick.Dialogs 1.0
+import QtQuick.Particles 2.0
+import QtQuick.Layouts 1.0
Item {
id: root
width: 300
height: 200
- ColorDialog {
- id: colorDialog
- color: "#afe"
- property color last: "#afe"
- onRejected: color = last
- onVisibleChanged: if (visible) last = color
- }
-
- Column {
- anchors.margins: 20
- anchors.horizontalCenter: parent.horizontalCenter
+ property int columnWidth: 120
+ GridLayout {
+ rowSpacing: 12
+ columnSpacing: 30
anchors.top: parent.top
- spacing: 20
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.margins: 30
- Row {
- spacing: 8
- Button {
- text: "Set color…"
- style: ButtonStyle { }
- onClicked: colorDialog.open()
- }
- Button {
- text: "Push me"
- style: ButtonStyle { }
- }
- Button {
- text: "Push me"
- style: buttonStyle
- }
+ Button {
+ text: "Push me"
+ style: ButtonStyle { }
+ implicitWidth: columnWidth
}
- Row {
- spacing: 8
- TextField {
- style: TextFieldStyle { }
- }
- TextField {
- style: TextFieldStyle { }
- }
- TextField {
- style: textfieldStyle
+ Button {
+ text: "Push me"
+ style: ButtonStyle {
+ background: BorderImage {
+ source: control.pressed ? "../images/button-pressed.png" : "../images/button.png"
+ border.left: 4 ; border.right: 4 ; border.top: 4 ; border.bottom: 4
+ }
}
+ implicitWidth: columnWidth
+ }
+ Button {
+ text: "Push me"
+ style: buttonStyle
+ implicitWidth: columnWidth
}
- Row {
- spacing: 8
- Slider {
- value: 50
- maximumValue: 100
- width: 100
- style: SliderStyle { }
- }
- Slider {
- value: 50
- maximumValue: 100
- width: 100
- style: SliderStyle { }
- }
- Slider {
- value: 50
- maximumValue: 100
- width: 100
- style: sliderStyle
+ TextField {
+ Layout.row: 1
+ style: TextFieldStyle { }
+ implicitWidth: columnWidth
+ }
+ TextField {
+ style: TextFieldStyle {
+ background: BorderImage {
+ source: "../images/textfield.png"
+ border.left: 4 ; border.right: 4 ; border.top: 4 ; border.bottom: 4
+ }
}
+ implicitWidth: columnWidth
+ }
+ TextField {
+ style: textfieldStyle
+ implicitWidth: columnWidth
}
- Row {
- spacing: 8
- ProgressBar {
- value: 50
- maximumValue: 100
- width: 100
- style: ProgressBarStyle{ }
- }
- ProgressBar {
- value: 50
- maximumValue: 100
- width: 100
- style: ProgressBarStyle{ }
- }
- ProgressBar {
- value: 50
- maximumValue: 100
- width: 100
- style: progressbarStyle
+ Slider {
+ id: slider1
+ Layout.row: 2
+ value: 0.5
+ implicitWidth: columnWidth
+ style: SliderStyle { }
+ }
+ Slider {
+ id: slider2
+ value: 0.5
+ implicitWidth: columnWidth
+ style: SliderStyle {
+ groove: BorderImage {
+ height: 6
+ border.top: 1
+ border.bottom: 1
+ source: "../images/progress-background.png"
+ border.left: 6
+ border.right: 6
+ BorderImage {
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../images/progress-fill.png"
+ border.left: 5 ; border.top: 1
+ border.right: 5 ; border.bottom: 1
+ width: styleData.handlePosition
+ height: parent.height
+ }
+ }
+ handle: Item {
+ width: 13
+ height: 13
+ Image {
+ anchors.centerIn: parent
+ source: "../images/slider-handle.png"
+ }
+ }
}
}
+ Slider {
+ id: slider3
+ value: 0.5
+ implicitWidth: columnWidth
+ style: sliderStyle
+ }
- Row {
- spacing: 8
- CheckBox {
- text: "CheckBox"
- style: CheckBoxStyle{}
- }
- RadioButton {
- style: RadioButtonStyle{}
- text: "RadioButton"
- }
+ ProgressBar {
+ Layout.row: 3
+ value: slider1.value
+ implicitWidth: columnWidth
+ style: ProgressBarStyle{ }
+ }
+ ProgressBar {
+ value: slider2.value
+ implicitWidth: columnWidth
+ style: progressBarStyle
+ }
+ ProgressBar {
+ value: slider3.value
+ implicitWidth: columnWidth
+ style: progressBarStyle2
+ }
- ComboBox {
- model: ["Paris", "Oslo", "New York"]
- style: ComboBoxStyle{}
- }
+ CheckBox {
+ text: "CheckBox"
+ style: CheckBoxStyle{}
+ Layout.row: 4
+ implicitWidth: columnWidth
+ }
+ RadioButton {
+ style: RadioButtonStyle{}
+ text: "RadioButton"
+ implicitWidth: columnWidth
}
- Row {
- TabView {
- width: 400
- height: 30
- Tab { title: "One" ; Item {}}
- Tab { title: "Two" ; Item {}}
- Tab { title: "Three" ; Item {}}
- Tab { title: "Four" ; Item {}}
- style: tabViewStyle
- }
+ ComboBox {
+ model: ["Paris", "Oslo", "New York"]
+ style: ComboBoxStyle{}
+ implicitWidth: columnWidth
+ }
+
+ TabView {
+ Layout.row: 5
+ Layout.columnSpan: 3
+ Layout.fillWidth: true
+ implicitHeight: 30
+ Tab { title: "One" ; Item {}}
+ Tab { title: "Two" ; Item {}}
+ Tab { title: "Three" ; Item {}}
+ Tab { title: "Four" ; Item {}}
+ style: TabViewStyle {}
+ }
+
+ TabView {
+ Layout.row: 6
+ Layout.columnSpan: 3
+ Layout.fillWidth: true
+ implicitHeight: 30
+ Tab { title: "One" ; Item {}}
+ Tab { title: "Two" ; Item {}}
+ Tab { title: "Three" ; Item {}}
+ Tab { title: "Four" ; Item {}}
+ style: tabViewStyle
}
}
// Style delegates:
property Component buttonStyle: ButtonStyle {
- panel: Rectangle {
- implicitHeight: 20
- implicitWidth: 100
- color: control.pressed ? "darkGray" : "lightGray"
+ background: Rectangle {
+ implicitHeight: 22
+ implicitWidth: columnWidth
+ color: control.pressed ? "darkGray" : control.activeFocus ? "#cdd" : "#ccc"
antialiasing: true
border.color: "gray"
radius: height/2
- Text {
- anchors.centerIn: parent
- text: control.text
+ Rectangle {
+ anchors.fill: parent
+ anchors.margins: 1
+ color: "transparent"
+ antialiasing: true
+ visible: !control.pressed
+ border.color: "#aaffffff"
+ radius: height/2
}
}
}
property Component textfieldStyle: TextFieldStyle {
background: Rectangle {
- implicitWidth: 100
- implicitHeight: 20
+ implicitWidth: columnWidth
+ implicitHeight: 22
color: "#f0f0f0"
antialiasing: true
border.color: "gray"
radius: height/2
+ Rectangle {
+ anchors.fill: parent
+ anchors.margins: 1
+ color: "transparent"
+ antialiasing: true
+ border.color: "#aaffffff"
+ radius: height/2
+ }
}
}
property Component sliderStyle: SliderStyle {
handle: Rectangle {
- width: 14
- height: 14
+ width: 18
+ height: 18
color: control.pressed ? "darkGray" : "lightGray"
border.color: "gray"
antialiasing: true
radius: height/2
+ Rectangle {
+ anchors.fill: parent
+ anchors.margins: 1
+ color: "transparent"
+ antialiasing: true
+ border.color: "#eee"
+ radius: height/2
+ }
}
groove: Rectangle {
height: 8
- implicitWidth: 100
- implicitHeight: 20
+ implicitWidth: columnWidth
+ implicitHeight: 22
antialiasing: true
- color: "darkGray"
- border.color: "gray"
+ color: "#ccc"
+ border.color: "#777"
radius: height/2
+ Rectangle {
+ anchors.fill: parent
+ anchors.margins: 1
+ color: "transparent"
+ antialiasing: true
+ border.color: "#66ffffff"
+ radius: height/2
+ }
}
}
- property Component progressbarStyle: ProgressBarStyle {
- panel: Rectangle {
- implicitWidth: 100
- implicitHeight: 20
+ property Component progressBarStyle: ProgressBarStyle {
+ background: BorderImage {
+ source: "../images/progress-background.png"
+ border.left: 2 ; border.right: 2 ; border.top: 2 ; border.bottom: 2
+ }
+ progress: Item {
+ clip: true
+ BorderImage {
+ anchors.fill: parent
+ anchors.rightMargin: (control.value < control.maximumValue) ? -4 : 0
+ source: "../images/progress-fill.png"
+ border.left: 10 ; border.right: 10
+ Rectangle {
+ width: 1
+ color: "#a70"
+ opacity: 0.8
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 1
+ anchors.right: parent.right
+ visible: control.value < control.maximumValue
+ anchors.rightMargin: -parent.anchors.rightMargin
+ }
+ }
+ ParticleSystem{ id: bubbles }
+ ImageParticle{
+ id: fireball
+ system: bubbles
+ source: "../images/bubble.png"
+ opacity: 0.7
+ }
+ Emitter{
+ system: bubbles
+ anchors.bottom: parent.bottom
+ anchors.margins: 4
+ anchors.bottomMargin: -4
+ anchors.left: parent.left
+ anchors.right: parent.right
+ size: 4
+ sizeVariation: 4
+ acceleration: PointDirection{ y: -6; xVariation: 3 }
+ emitRate: 6 * control.value
+ lifeSpan: 3000
+ }
+ }
+ }
+
+ property Component progressBarStyle2: ProgressBarStyle {
+ background: Rectangle {
+ implicitWidth: columnWidth
+ implicitHeight: 24
color: "#f0f0f0"
border.color: "gray"
- antialiasing: true
- radius: height/2
+ }
+ progress: Rectangle {
+ color: "#ccc"
+ border.color: "gray"
Rectangle {
- implicitWidth: 100
- implicitHeight: 20
- color: "#f0f0f0"
- border.color: "gray"
- antialiasing: true
- radius: height/2
+ color: "transparent"
+ border.color: "#44ffffff"
+ anchors.fill: parent
+ anchors.margins: 1
}
}
}
@@ -250,21 +363,21 @@ Item {
}
border.color: "#898989"
Rectangle { anchors.fill: parent ; anchors.margins: 1 ; border.color: "white" ; color: "transparent" }
-
}
tab: Item {
- implicitWidth: image.sourceSize.width
+ property int totalOverlap: tabOverlap * (control.count - 1)
+ implicitWidth: Math.min ((styleData.availableWidth + totalOverlap)/control.count - 4, image.sourceSize.width)
implicitHeight: image.sourceSize.height
BorderImage {
id: image
anchors.fill: parent
- source: tab.selected ? "../images/tab_selected.png" : "../images/tab.png"
- border.left: 50
+ source: styleData.selected ? "../images/tab_selected.png" : "../images/tab.png"
+ border.left: 30
smooth: false
- border.right: 50
+ border.right: 30
}
Text {
- text: tab.title
+ text: styleData.title
anchors.centerIn: parent
}
}
diff --git a/examples/quick/controls/gallery/images/bubble.png b/examples/quick/controls/gallery/images/bubble.png
new file mode 100644
index 00000000..62aa1efe
--- /dev/null
+++ b/examples/quick/controls/gallery/images/bubble.png
Binary files differ
diff --git a/examples/quick/controls/gallery/images/button-pressed.png b/examples/quick/controls/gallery/images/button-pressed.png
new file mode 100644
index 00000000..d64cdaa7
--- /dev/null
+++ b/examples/quick/controls/gallery/images/button-pressed.png
Binary files differ
diff --git a/examples/quick/controls/gallery/images/button.png b/examples/quick/controls/gallery/images/button.png
new file mode 100644
index 00000000..8ab41cc8
--- /dev/null
+++ b/examples/quick/controls/gallery/images/button.png
Binary files differ
diff --git a/examples/quick/controls/gallery/images/page.png b/examples/quick/controls/gallery/images/page.png
deleted file mode 100644
index b46f205d..00000000
--- a/examples/quick/controls/gallery/images/page.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/controls/gallery/images/panel.png b/examples/quick/controls/gallery/images/panel.png
deleted file mode 100644
index 02d655eb..00000000
--- a/examples/quick/controls/gallery/images/panel.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/controls/gallery/images/progress-background.png b/examples/quick/controls/gallery/images/progress-background.png
new file mode 100644
index 00000000..55a069df
--- /dev/null
+++ b/examples/quick/controls/gallery/images/progress-background.png
Binary files differ
diff --git a/examples/quick/controls/gallery/images/progress-fill.png b/examples/quick/controls/gallery/images/progress-fill.png
new file mode 100644
index 00000000..b588c958
--- /dev/null
+++ b/examples/quick/controls/gallery/images/progress-fill.png
Binary files differ
diff --git a/examples/quick/controls/gallery/images/slider-handle.png b/examples/quick/controls/gallery/images/slider-handle.png
new file mode 100644
index 00000000..ac4d4a0d
--- /dev/null
+++ b/examples/quick/controls/gallery/images/slider-handle.png
Binary files differ
diff --git a/examples/quick/controls/gallery/images/textfield.png b/examples/quick/controls/gallery/images/textfield.png
new file mode 100644
index 00000000..1d4a38ab
--- /dev/null
+++ b/examples/quick/controls/gallery/images/textfield.png
Binary files differ
diff --git a/examples/quick/controls/gallery/main.qml b/examples/quick/controls/gallery/main.qml
index 7da74031..ec00627b 100644
--- a/examples/quick/controls/gallery/main.qml
+++ b/examples/quick/controls/gallery/main.qml
@@ -51,10 +51,11 @@ import "content"
ApplicationWindow {
title: "Component Gallery"
- width: 580
+ width: 600
height: 400
minimumHeight: 400
- minimumWidth: 340
+ minimumWidth: 570
+
property string loremIpsum:
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor "+
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor "+
@@ -69,150 +70,112 @@ ApplicationWindow {
onAccepted: imageViewer.open(fileUrl)
}
- toolBar: ToolBar {
- id: toolbar
- RowLayout {
- spacing: 2
- anchors.verticalCenter: parent.verticalCenter
- ToolButton {
- iconSource: "images/window-new.png"
- anchors.verticalCenter: parent.verticalCenter
- onClicked: window1.visible = !window1.visible
- Accessible.name: "New window"
- tooltip: "Toggle visibility of the second window"
- }
- ToolButton {
- action: openAction
- }
- ToolButton {
- iconSource: "images/document-save-as.png"
- anchors.verticalCenter: parent.verticalCenter
- tooltip: "(Pretend to) save as..."
- }
- }
+ Action {
+ id: openAction
+ text: "&Open"
+ shortcut: "Ctrl+O"
+ iconSource: "images/document-open.png"
+ onTriggered: fileDialog.open()
+ tooltip: "Open an image"
+ }
- ChildWindow { id: window1 }
+ Action {
+ id: copyAction
+ text: "&Copy"
+ shortcut: "Ctrl+C"
+ iconName: "edit-copy"
+ enabled: (!!activeFocusItem && !!activeFocusItem["copy"])
+ onTriggered: activeFocusItem.copy()
+ }
- Action {
- id: openAction
- text: "&Open"
- shortcut: "Ctrl+O"
- iconSource: "images/document-open.png"
- onTriggered: fileDialog.open()
- tooltip: "open an image"
- }
+ Action {
+ id: cutAction
+ text: "Cu&t"
+ shortcut: "Ctrl+X"
+ iconName: "edit-cut"
+ enabled: (!!activeFocusItem && !!activeFocusItem["cut"])
+ onTriggered: activeFocusItem.cut()
+ }
+
+ Action {
+ id: pasteAction
+ text: "&Paste"
+ shortcut: "Ctrl+V"
+ iconName: "edit-paste"
+ enabled: (!!activeFocusItem && !!activeFocusItem["paste"])
+ onTriggered: activeFocusItem.paste()
+ }
+
+ ExclusiveGroup {
+ id: textFormatGroup
Action {
- id: copyAction
- text: "&Copy"
- shortcut: "Ctrl+C"
- iconName: "edit-copy"
- enabled: (!!activeFocusItem && !!activeFocusItem["copy"])
- onTriggered: activeFocusItem.copy()
+ id: a1
+ text: "Align Left"
+ checkable: true
+ Component.onCompleted: checked = true
}
Action {
- id: cutAction
- text: "Cu&t"
- shortcut: "Ctrl+X"
- iconName: "edit-cut"
- enabled: (!!activeFocusItem && !!activeFocusItem["cut"])
- onTriggered: activeFocusItem.cut()
+ id: a2
+ text: "Center"
+ checkable: true
}
Action {
- id: pasteAction
- text: "&Paste"
- shortcut: "Ctrl+V"
- iconName: "edit-paste"
- enabled: (!!activeFocusItem && !!activeFocusItem["paste"])
- onTriggered: activeFocusItem.paste()
+ id: a3
+ text: "Align Right"
+ checkable: true
}
+ }
- ExclusiveGroup {
- id: textFormatGroup
-
- Action {
- id: a1
- text: "Align Left"
- checkable: true
- Component.onCompleted: checked = true
- }
-
- Action {
- id: a2
- text: "Center"
- checkable: true
- }
-
- Action {
- id: a3
- text: "Align Right"
- checkable: true
- }
- }
+ ChildWindow { id: window1 }
+ Menu {
+ id: editmenu
+ MenuItem { action: cutAction }
+ MenuItem { action: copyAction }
+ MenuItem { action: pasteAction }
+ MenuSeparator {}
Menu {
- id: editmenu
- MenuItem { action: cutAction }
- MenuItem { action: copyAction }
- MenuItem { action: pasteAction }
- MenuSeparator {}
- Menu {
- title: "Text Format"
- MenuItem { action: a1 }
- MenuItem { action: a2 }
- MenuItem { action: a3 }
- MenuSeparator { }
- MenuItem { text: "Allow Hyphenation"; checkable: true }
- MenuSeparator { }
- Menu {
- title: "More Stuff"
- MenuItem { action: cutAction }
- MenuItem { action: copyAction }
- MenuItem { action: pasteAction }
- MenuSeparator { }
- Menu {
- title: "More Stuff"
- MenuItem { action: cutAction }
- MenuItem { action: copyAction }
- MenuItem { action: pasteAction }
- MenuSeparator { }
- Menu {
- title: "More Stuff"
- MenuItem { action: cutAction }
- MenuItem { action: copyAction }
- MenuItem { action: pasteAction }
- MenuSeparator { }
- Menu {
- title: "More Stuff"
- MenuItem { action: cutAction }
- MenuItem { action: copyAction }
- MenuItem { action: pasteAction }
- }
- }
- }
- }
- }
- Menu {
- title: "Font Style"
- MenuItem { text: "Bold"; checkable: true }
- MenuItem { text: "Italic"; checkable: true }
- MenuItem { text: "Underline"; checkable: true }
- }
+ title: "Text Format"
+ MenuItem { action: a1 }
+ MenuItem { action: a2 }
+ MenuItem { action: a3 }
+ MenuSeparator { }
+ MenuItem { text: "Allow Hyphenation"; checkable: true }
}
- MouseArea {
- anchors.fill: parent
- acceptedButtons: Qt.RightButton
- onPressed: editmenu.popup()
+ Menu {
+ title: "Font Style"
+ MenuItem { text: "Bold"; checkable: true }
+ MenuItem { text: "Italic"; checkable: true }
+ MenuItem { text: "Underline"; checkable: true }
}
+ }
- CheckBox {
- id: enabledCheck
- text: "Enabled"
- checked: true
- anchors.right: parent.right
- anchors.verticalCenter: parent.verticalCenter
+ toolBar: ToolBar {
+ id: toolbar
+ RowLayout {
+ id: toolbarLayout
+ spacing: 0
+ width: parent.width
+ ToolButton {
+ iconSource: "images/window-new.png"
+ onClicked: window1.visible = !window1.visible
+ Accessible.name: "New window"
+ tooltip: "Toggle visibility of the second window"
+ }
+ ToolButton { action: openAction }
+ ToolButton {
+ iconSource: "images/document-save-as.png"
+ tooltip: "(Pretend to) Save as..."
+ }
+ Item { Layout.fillWidth: true }
+ CheckBox {
+ id: enabledCheck
+ text: "Enabled"
+ checked: true
+ }
}
}
@@ -265,7 +228,7 @@ ApplicationWindow {
enabled: enabledCheck.checked
tabPosition: controlPage.item ? controlPage.item.tabPosition : Qt.TopEdge
anchors.fill: parent
- anchors.margins: Qt.platform.os === "mac" ? 12 : 2
+ anchors.margins: Qt.platform.os === "osx" ? 12 : 2
Tab {
id: controlPage
@@ -281,8 +244,8 @@ ApplicationWindow {
Styles { anchors.fill: parent }
}
Tab {
- title: "Sidebar"
- Panel { anchors.fill:parent }
+ title: "Layouts"
+ Layouts { anchors.fill:parent }
}
}
}
diff --git a/examples/quick/controls/gallery/resources.qrc b/examples/quick/controls/gallery/resources.qrc
index 14e88e52..6f487274 100644
--- a/examples/quick/controls/gallery/resources.qrc
+++ b/examples/quick/controls/gallery/resources.qrc
@@ -5,18 +5,23 @@
<file>content/Controls.qml</file>
<file>content/ImageViewer.qml</file>
<file>content/ModelView.qml</file>
- <file>content/Panel.qml</file>
+ <file>content/Layouts.qml</file>
<file>content/Styles.qml</file>
<file>images/document-open.png</file>
<file>images/document-open@2x.png</file>
<file>images/document-save-as.png</file>
<file>images/document-save-as@2x.png</file>
<file>images/folder_new.png</file>
- <file>images/page.png</file>
<file>images/tab.png</file>
<file>images/tab_selected.png</file>
<file>images/window-new.png</file>
<file>images/window-new@2x.png</file>
- <file>images/panel.png</file>
+ <file>images/bubble.png</file>
+ <file>images/button-pressed.png</file>
+ <file>images/button.png</file>
+ <file>images/progress-background.png</file>
+ <file>images/progress-fill.png</file>
+ <file>images/textfield.png</file>
+ <file>images/slider-handle.png</file>
</qresource>
</RCC>
diff --git a/examples/quick/controls/shared/qt_quick_controls_examplemain.h b/examples/quick/controls/shared/qt_quick_controls_examplemain.h
index e3cae9a0..324d7110 100644
--- a/examples/quick/controls/shared/qt_quick_controls_examplemain.h
+++ b/examples/quick/controls/shared/qt_quick_controls_examplemain.h
@@ -64,20 +64,13 @@ QT_BEGIN_NAMESPACE
int main(int argc, char *argv[]) \
{ \
Application app(argc, argv); \
- QQmlEngine engine; \
- QQmlComponent component(&engine); \
- component.loadUrl(QUrl(#url)); \
- if ( !component.isReady() ) { \
- qWarning("%s", qPrintable(component.errorString())); \
- return -1; \
- } \
- QObject *topLevel = component.create(); \
+ QQmlApplicationEngine engine(QUrl(#url)); \
+ QObject *topLevel = engine.rootObjects().value(0); \
QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel); \
if ( !window ) { \
qWarning("Error: Your root item has to be a Window."); \
return -1; \
} \
- QObject::connect(&engine, SIGNAL(quit()), &app, SLOT(quit())); \
window->show(); \
return app.exec(); \
}
diff --git a/examples/quick/controls/splitview/main.qml b/examples/quick/controls/splitview/main.qml
index f035e644..4fa8504a 100644
--- a/examples/quick/controls/splitview/main.qml
+++ b/examples/quick/controls/splitview/main.qml
@@ -61,14 +61,6 @@ ApplicationWindow {
color: "lightsteelblue"
}
- Rectangle {
- id: column1
- width: 200
- Layout.minimumWidth: 100
- Layout.maximumWidth: 300
- color: "lightsteelblue"
- }
-
SplitView {
orientation: Qt.Vertical
Layout.fillWidth: true
diff --git a/examples/quick/controls/tableview/main.qml b/examples/quick/controls/tableview/main.qml
index 0e568314..1a9246f8 100644
--- a/examples/quick/controls/tableview/main.qml
+++ b/examples/quick/controls/tableview/main.qml
@@ -104,9 +104,9 @@ Window {
ListModel {
id: nestedModel
- ListElement{controlState: ListElement { description: "Core" ; color:"#ffaacc"}}
- ListElement{controlState: ListElement { description: "Second" ; color:"#ffccaa"}}
- ListElement{controlState: ListElement { description: "Third" ; color:"#ffffaa"}}
+ ListElement{content: ListElement { description: "Core" ; color:"#ffaacc"}}
+ ListElement{content: ListElement { description: "Second" ; color:"#ffccaa"}}
+ ListElement{content: ListElement { description: "Third" ; color:"#ffffaa"}}
}
ListModel {
@@ -129,7 +129,7 @@ Window {
focus:true
enabled: enabledCheck.checked
- property int margins: Qt.platform.os === "mac" ? 16 : 0
+ property int margins: Qt.platform.os === "osx" ? 16 : 0
height: parent.height - 34
anchors.right: parent.right
@@ -176,14 +176,14 @@ Window {
anchors.margins: 12
TableViewColumn {
- role: "controlState"
+ role: "content"
title: "Text and Color"
width: 220
}
itemDelegate: Item {
Rectangle{
- color: itemValue.get(0).color
+ color: styleData.value.get(0).color
anchors.top:parent.top
anchors.right:parent.right
anchors.bottom:parent.bottom
@@ -196,9 +196,9 @@ Window {
anchors.margins: 4
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
- elide: itemElideMode
- text: itemValue.get(0).description
- color: itemTextColor
+ elide: styleData.elideMode
+ text: styleData.value.get(0).description
+ color: styleData.textColor
}
}
@@ -251,32 +251,23 @@ Window {
anchors.margins: 4
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
- elide: itemElideMode
- text: itemValue !== undefined ? itemValue : ""
- color: itemTextColor
+ elide: styleData.elideMode
+ text: styleData.value !== undefined ? styleData.value : ""
+ color: styleData.textColor
}
}
}
Component {
- id: slickRowDelegate
- Rectangle { color: alternateBackground ? "#cef" : "white" }
- }
-
- Component {
id: delegate2
- Item {
- height: itemSelected? 60 : 20
- Behavior on height{ NumberAnimation{} }
- Text {
- width: parent.width
- anchors.margins: 4
- anchors.left: parent.left
- anchors.verticalCenter: parent.verticalCenter
- elide: itemElideMode
- text: itemValue !== undefined ? itemValue : ""
- color: itemTextColor
- }
+ Text {
+ width: parent.width
+ anchors.margins: 4
+ anchors.left: parent.left
+ anchors.verticalCenter: parent.verticalCenter
+ elide: styleData.elideMode
+ text: styleData.value !== undefined ? styleData.value : ""
+ color: styleData.textColor
}
}
@@ -289,10 +280,10 @@ Window {
anchors.margins: 4
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
- elide: itemElideMode
- text: itemValue !== undefined ? itemValue : ""
- color: itemTextColor
- visible: !itemSelected
+ elide: styleData.elideMode
+ text: styleData.value !== undefined ? styleData.value : ""
+ color: styleData.textColor
+ visible: !styleData.selected
}
Loader { // Initialize text editor lazily to improve performance
id: loaderEditor
@@ -301,19 +292,19 @@ Window {
Connections {
target: loaderEditor.item
onAccepted: {
- if (typeof itemValue === 'number')
- model.setProperty(row, role, Number(parseFloat(loaderEditor.item.text).toFixed(0)))
+ if (typeof styleData.value === 'number')
+ model.setProperty(styleData.row, styleData.role, Number(parseFloat(loaderEditor.item.text).toFixed(0)))
else
- model.setProperty(row, role, loaderEditor.item.text)
+ model.setProperty(styleData.row, styleData.role, loaderEditor.item.text)
}
}
- sourceComponent: itemSelected ? editor : null
+ sourceComponent: styleData.selected ? editor : null
Component {
id: editor
TextInput {
id: textinput
- color: itemTextColor
- text: itemValue
+ color: styleData.textColor
+ text: styleData.value
MouseArea {
id: mouseArea
anchors.fill: parent
@@ -354,25 +345,22 @@ Window {
source: "images/header.png"
border{left:2;right:2;top:2;bottom:2}
Text {
- text: itemValue
+ text: styleData.value
anchors.centerIn:parent
color:"#333"
}
}
rowDelegate: Rectangle {
- height: 20
- color: rowSelected ? "#448" : (alternateBackground ? "#eee" : "#fff")
- border.color:"#ccc"
- border.width: 1
- anchors.left: parent ? parent.left : undefined
- anchors.leftMargin: -2
- anchors.rightMargin: -1
+ height: (delegateChooser.currentIndex == 1 && styleData.selected) ? 30 : 20
+ Behavior on height{ NumberAnimation{} }
+
+ color: styleData.selected ? "#448" : (styleData.alternate? "#eee" : "#fff")
BorderImage{
id: selected
anchors.fill: parent
source: "images/selectedrow.png"
- visible: rowSelected
+ visible: styleData.selected
border{left:2; right:2; top:2; bottom:2}
SequentialAnimation {
running: true; loops: Animation.Infinite
@@ -383,14 +371,10 @@ Window {
}
itemDelegate: {
- switch (delegateChooser.currentIndex) {
- case 0:
- return delegate1
- case 1:
- return delegate2
- case 2:
- return editableDelegate
- }
+ if (delegateChooser.currentIndex == 2)
+ return editableDelegate;
+ else
+ return delegate1;
}
}
}
diff --git a/examples/quick/controls/text/example.html b/examples/quick/controls/text/example.html
index 0560897b..52bb507a 100644
--- a/examples/quick/controls/text/example.html
+++ b/examples/quick/controls/text/example.html
@@ -1,11 +1,13 @@
-<html><head><meta name="qrichtext" content="1" /><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>QTextEdit Example</title><style type="text/css">
+<html><head><meta name="qrichtext" content="1" /><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>TextArea Example</title><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;">
-<p align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:20pt; font-weight:600;">QTextEdit</span></p>
-<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:11pt;">The QTextEdit widget is an advanced editor that supports formatted rich text. It can be used to display HTML and other rich document formats. Internally, QTextEdit uses the QTextDocument class to describe both the high-level structure of each document and the low-level formatting of paragraphs.</span></p>
-<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;">If you are viewing this document in the <span style=" font-style:italic;">textedit</span> example, you can edit this document to explore Qt's rich text editing features. We have included some comments in each of the following sections to encourage you to experiment. </p>
+<p align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:20pt; font-weight:600;">TextArea</span></p>
+<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:11pt;">The TextArea control is an advanced editor that supports formatted rich text. It can be used to display HTML and other rich document formats. Internally, TextArea uses the QQuickTextDocument class to describe both the high-level structure of each document and the low-level formatting of paragraphs.</span></p>
+<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;">If you are viewing this document in the <span style=" font-style:italic;">Text Editor</span> example, you can edit this document to explore Qt's rich text editing features. We have included some comments in each of the following sections to encourage you to experiment. </p>
<p style=" margin-top:16px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:18pt; font-weight:600;"><span style=" font-size:16pt;">Font and Paragraph Styles</span></p>
-<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:11pt;">QTextEdit supports </span><span style=" font-size:11pt; font-weight:600;">bold</span><span style=" font-size:11pt;">, </span><span style=" font-size:11pt; font-style:italic;">italic</span><span style=" font-size:11pt;">, and </span><span style=" font-size:11pt; text-decoration: underline;">underlined</span><span style=" font-size:11pt;"> font styles, and can display </span><span style=" font-size:11pt; font-weight:600; color:#00007f;">multicolored</span><span style=" font-size:11pt;"> </span><span style=" font-size:11pt; font-weight:600; color:#aa0000;">text</span><span style=" font-size:11pt;">. Font families such as </span><span style=" font-family:'Times'; font-size:11pt; font-weight:600;">Times New Roman</span><span style=" font-size:11pt;"> and </span><span style=" font-family:'Courier'; font-size:11pt; font-weight:600;">Courier</span><span style=" font-size:11pt;"> can also be used directly. </span><span style=" font-size:11pt; font-style:italic;">If you place the cursor in a region of styled text, the controls in the tool bars will change to reflect the current style.</span></p>
+<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:11pt;">TextArea supports </span><span style=" font-size:11pt; font-weight:600;">bold</span><span style=" font-size:11pt;">, </span><span style=" font-size:11pt; font-style:italic;">italic</span><span style=" font-size:11pt;">, and </span><span style=" font-size:11pt; text-decoration: underline;">underlined</span><span style=" font-size:11pt;"> font styles, and can display </span><span style=" font-size:11pt; font-weight:600; color:#00007f;">multicolored</span>
+<span style=" font-size:11pt;"> </span><span style=" font-size:11pt; font-weight:600; color:#aa0000;">text</span><span style=" font-size:11pt;">. Font families such as</span><span style=" font-family:'Helvetica'; font-size:11pt; font-weight:600;"> Helvetica</span><span style=" font-size:11pt;"> and
+</span><span style=" font-family:'Courier'; font-size:11pt; font-weight:600;"> Courier</span><span style=" font-size:11pt;"> can also be used directly.<span style=" font-size:11pt; font-style:italic;"> If you place the cursor in a region of styled text, the corresponding controls in the tool bar will change to reflect the current style, font size and color.</span></p>
<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;">Paragraphs can be formatted so that the text is left-aligned, right-aligned, centered, or fully justified.</p>
<p align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><span style=" font-style:italic;">Try changing the alignment of some text and resize the editor to see how the text layout changes.</span> </p>
<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:16pt; font-weight:600;">Lists</span></p>
@@ -13,7 +15,7 @@ p, li { white-space: pre-wrap; }
<ul style="-qt-list-indent: 1;"><li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Disc symbols are typically used for top-level list items. </li></ul>
<ul type=circle style="-qt-list-indent: 2;"><li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Circle symbols can be used to distinguish between items in lower-level lists.</li></ul>
<ul type=square style="-qt-list-indent: 3;"><li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Square symbols provide a reasonable alternative to discs and circles. </li></ul>
-<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;">Ordered lists can be created that can be used for tables of contents. Different characters can be used to enumerate items, and we can use both Roman and Arabic numerals in the same list structure: </p>
+<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;">Ordered lists can be used for tables of contents. Different characters can be used to enumerate items, and one can use both Roman and Arabic numerals in the same list structure: </p>
<ol style="-qt-list-indent: 1;"><li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Introduction</li>
<li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Qt Tools </li></ol>
<ol type=a style="-qt-list-indent: 2;"><li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Qt Assistant</li>
@@ -26,9 +28,9 @@ p, li { white-space: pre-wrap; }
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"></p>
<p style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><span style=" font-size:16pt; font-weight:600;">Images</span></p>
<p style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt; font-weight:600;"><span style=" font-size:11pt; font-weight:400;">Inline images are treated like ordinary ranges of characters in the text editor, so they flow with the surrounding text. Images can also be selected in the same way as text, making it easy to cut, copy, and paste them. </span></p>
-<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><img src="qrc:qml/images/logo32.png" /><span style=" font-style:italic;"> Try to select this image by clicking and dragging over it with the mouse, or use the text cursor to select it by holding down Shift and using the arrow keys. You can then cut or copy it, and paste it into different parts of this document.</span></p>
+<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><img src="qrc:qml/images/qt-logo.png" /><span style=" font-style:italic;"> Try to select this image by clicking and dragging over it with the mouse, or use the text cursor to select it by holding down Shift and using the arrow keys. You can then cut or copy it, and paste it into different parts of this document.</span></p>
<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><span style=" font-size:16pt; font-weight:600;">Tables</span></p>
-<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt; font-weight:600;"><span style=" font-size:11pt; font-weight:400;">QTextEdit can arrange and format tables, supporting features such as row and column spans, text formatting within cells, and size constraints for columns. </span></p>
+<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt; font-weight:600;"><span style=" font-size:11pt; font-weight:400;">TextArea can arrange and format tables, supporting features such as row and column spans, text formatting within cells, and size constraints for columns. </span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"></p>
<table border="1" align="center" width="90%" cellspacing="0" cellpadding="4">
@@ -72,8 +74,6 @@ p, li { white-space: pre-wrap; }
<td></td></tr></table>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"></p>
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt; font-style:italic;">Try adding text to the cells in the table and experiment with the alignment of the paragraphs.</p>
-<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><span style=" font-size:16pt; font-weight:600;">Hyperlinks</span></p>
-<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:11pt;">QTextEdit is designed to support hyperlinks between documents, and this feature is used extensively in </span><span style=" font-size:11pt; font-style:italic;">Qt Assistant</span><span style=" font-size:11pt;">. Hyperlinks are automatically created when an HTML file is imported into an editor. Since the rich text framework supports hyperlinks natively, they can also be created programatically.</span></p>
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><span style=" font-size:16pt; font-weight:600;">Undo and Redo</span></p>
-<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;">Full support for undo and redo operations is built into QTextEdit and the underlying rich text framework. Operations on a document can be packaged together to make editing a more comfortable experience for the user.</p>
+<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;">Full support for undo and redo operations is built into TextArea and the underlying rich text framework. Operations on a document can be packaged together to make editing easier for the user.</p>
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><span style=" font-style:italic;">Try making changes to this document and press Ctrl+Z to undo them. You can always recover the original contents of the document.</span> </p></body></html>
diff --git a/examples/quick/controls/text/qml/ToolBarSeparator.qml b/examples/quick/controls/text/qml/ToolBarSeparator.qml
new file mode 100644
index 00000000..40a2bc58
--- /dev/null
+++ b/examples/quick/controls/text/qml/ToolBarSeparator.qml
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.1
+
+Item {
+ width: 8
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ anchors.margins: 6
+ Rectangle {
+ width: 1
+ height: parent.height
+ anchors.horizontalCenter: parent.horizontalCenter
+ color: "#22000000"
+ }
+ Rectangle {
+ width: 1
+ height: parent.height
+ anchors.horizontalCenterOffset: 1
+ anchors.horizontalCenter: parent.horizontalCenter
+ color: "#33ffffff"
+ }
+}
diff --git a/examples/quick/controls/text/qml/images/logo32.png b/examples/quick/controls/text/qml/images/logo32.png
deleted file mode 100644
index 5f91e987..00000000
--- a/examples/quick/controls/text/qml/images/logo32.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/controls/text/qml/images/qt-logo.png b/examples/quick/controls/text/qml/images/qt-logo.png
new file mode 100644
index 00000000..6dedc8bf
--- /dev/null
+++ b/examples/quick/controls/text/qml/images/qt-logo.png
Binary files differ
diff --git a/examples/quick/controls/text/qml/main.qml b/examples/quick/controls/text/qml/main.qml
index dd8b1848..d8f175ed 100644
--- a/examples/quick/controls/text/qml/main.qml
+++ b/examples/quick/controls/text/qml/main.qml
@@ -42,6 +42,7 @@ import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Layouts 1.0
import QtQuick.Dialogs 1.0
+import QtQuick.Window 2.1
import org.qtproject.example 1.0
ApplicationWindow {
@@ -52,33 +53,66 @@ ApplicationWindow {
title: document.documentTitle + " - Text Editor Example"
+ ApplicationWindow {
+ id: aboutBox
+
+ width: 280
+ height: 120
+ title: "About Text"
+
+ ColumnLayout {
+ anchors.fill: parent
+ anchors.margins: 8
+ Item {
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ Label {
+ anchors.centerIn: parent
+ horizontalAlignment: Text.AlignHCenter
+ text: "This is a basic text editor \nwritten with Qt Quick Controls"
+ }
+ }
+ Button {
+ text: "Ok"
+ isDefault: true
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottom: parent.bottom
+ onClicked: aboutBox.close()
+ }
+ Keys.onReturnPressed: aboutBox.close()
+ focus: true
+ }
+ }
+
Action {
- id: cut
+ id: cutAction
text: "Cut"
shortcut: "ctrl+x"
iconSource: "images/editcut.png"
iconName: "edit-cut"
+ onTriggered: textArea.cut()
}
Action {
- id: copy
+ id: copyAction
text: "Copy"
shortcut: "Ctrl+C"
iconSource: "images/editcopy.png"
iconName: "edit-copy"
- onTriggered: console.log("Ctrl C pressed - in action...")
+ onTriggered: textArea.copy()
}
Action {
- id: paste
+ id: pasteAction
text: "Paste"
shortcut: "ctrl+v"
iconSource: "qrc:images/editpaste.png"
iconName: "edit-paste"
+ onTriggered: textArea.paste()
}
Action {
- id: alignLeft
+ id: alignLeftAction
text: "&Left"
iconSource: "images/textleft.png"
iconName: "format-justify-left"
@@ -88,16 +122,16 @@ ApplicationWindow {
checked: document.alignment == Qt.AlignLeft
}
Action {
- id: alignCenter
+ id: alignCenterAction
text: "C&enter"
iconSource: "images/textcenter.png"
iconName: "format-justify-center"
- onTriggered: document.alignment = Qt.AlignCenter
+ onTriggered: document.alignment = Qt.AlignHCenter
checkable: true
- checked: document.alignment == Qt.AlignCenter
+ checked: document.alignment == Qt.AlignHCenter
}
Action {
- id: alignRight
+ id: alignRightAction
text: "&Right"
iconSource: "images/textright.png"
iconName: "format-justify-right"
@@ -106,7 +140,7 @@ ApplicationWindow {
checked: document.alignment == Qt.AlignRight
}
Action {
- id: alignJustify
+ id: alignJustifyAction
text: "&Justify"
iconSource: "images/textjustify.png"
iconName: "format-justify-fill"
@@ -116,7 +150,7 @@ ApplicationWindow {
}
Action {
- id: bold
+ id: boldAction
text: "&Bold"
iconSource: "images/textbold.png"
iconName: "format-text-bold"
@@ -124,8 +158,9 @@ ApplicationWindow {
checkable: true
checked: document.bold
}
+
Action {
- id: italic
+ id: italicAction
text: "&Italic"
iconSource: "images/textitalic.png"
iconName: "format-text-italic"
@@ -134,7 +169,7 @@ ApplicationWindow {
checked: document.italic
}
Action {
- id: underline
+ id: underlineAction
text: "&Underline"
iconSource: "images/textunder.png"
iconName: "format-text-underline"
@@ -142,56 +177,61 @@ ApplicationWindow {
checkable: true
checked: document.underline
}
- Action {
- id: color
- text: "&Color ..."
- iconSource: "images/textcolor.png"
- iconName: "format-text-color"
- }
FileDialog {
- id: file
+ id: fileDialog
nameFilters: ["Text files (*.txt)", "HTML files (*.html)"]
onAccepted: document.fileUrl = fileUrl
}
+ ColorDialog {
+ id: colorDialog
+ color: "black"
+ onAccepted: document.textColor = color
+ }
+
Action {
- id: fileOpen
+ id: fileOpenAction
iconSource: "images/fileopen.png"
iconName: "document-open"
text: "Open"
- onTriggered: file.open()
+ onTriggered: fileDialog.open()
}
menuBar: MenuBar {
Menu {
title: "&File"
- MenuItem { action: fileOpen }
+ MenuItem { action: fileOpenAction }
MenuItem { text: "Quit"; onTriggered: Qt.quit() }
}
Menu {
title: "&Edit"
- MenuItem { action: copy }
- MenuItem { action: cut }
- MenuItem { action: paste }
+ MenuItem { action: copyAction }
+ MenuItem { action: cutAction }
+ MenuItem { action: pasteAction }
}
Menu {
title: "F&ormat"
- MenuItem { action: bold }
- MenuItem { action: italic }
- MenuItem { action: underline }
+ MenuItem { action: boldAction }
+ MenuItem { action: italicAction }
+ MenuItem { action: underlineAction }
MenuSeparator {}
- MenuItem { action: alignLeft }
- MenuItem { action: alignCenter }
- MenuItem { action: alignRight }
- MenuItem { action: alignJustify }
+ MenuItem { action: alignLeftAction }
+ MenuItem { action: alignCenterAction }
+ MenuItem { action: alignRightAction }
+ MenuItem { action: alignJustifyAction }
MenuSeparator {}
- MenuItem { action: color }
+ MenuItem {
+ text: "&Color ..."
+ onTriggered: {
+ colorDialog.color = document.textColor
+ colorDialog.open()
+ }
+ }
}
Menu {
title: "&Help"
- MenuItem { text: "About..." }
- MenuItem { text: "About Qt" }
+ MenuItem { text: "About..." ; onTriggered: aboutBox.show() }
}
}
@@ -200,39 +240,72 @@ ApplicationWindow {
width: parent.width
RowLayout {
anchors.fill: parent
- spacing: 1
- ToolButton { action: fileOpen }
+ spacing: 0
+ ToolButton { action: fileOpenAction }
+
+ ToolBarSeparator {}
+
+ ToolButton { action: copyAction }
+ ToolButton { action: cutAction }
+ ToolButton { action: pasteAction }
+
+ ToolBarSeparator {}
+
+ ToolButton { action: boldAction }
+ ToolButton { action: italicAction }
+ ToolButton { action: underlineAction }
- Item { width: 4 }
- ToolButton { action: copy }
- ToolButton { action: cut }
- ToolButton { action: paste }
- Item { width: 4 }
- ToolButton { action: bold }
- ToolButton { action: italic }
- ToolButton { action: underline }
+ ToolBarSeparator {}
- Item { width: 4 }
- ToolButton { action: alignLeft }
- ToolButton { action: alignCenter }
- ToolButton { action: alignRight }
- ToolButton { action: alignJustify }
+ ToolButton { action: alignLeftAction }
+ ToolButton { action: alignCenterAction }
+ ToolButton { action: alignRightAction }
+ ToolButton { action: alignJustifyAction }
+
+ ToolBarSeparator {}
+
+ ToolButton {
+ id: colorButton
+ property var color : document.textColor
+ Rectangle {
+ id: colorRect
+ anchors.fill: parent
+ anchors.margins: 8
+ color: Qt.darker(document.textColor, colorButton.pressed ? 1.4 : 1)
+ border.width: 1
+ border.color: Qt.darker(colorRect.color, 2)
+ }
+ onClicked: {
+ colorDialog.color = document.textColor
+ colorDialog.open()
+ }
+ }
Item { Layout.fillWidth: true }
}
}
+
ToolBar {
id: secondaryToolBar
width: parent.width
RowLayout {
anchors.fill: parent
- anchors.margins: 4
ComboBox {
- model: document.defaultFontSizes
- onCurrentTextChanged: document.fontSize = currentText
- currentIndex: document.defaultFontSizes.indexOf(document.fontSize + "")
+ id: fontFamilyComboBox
+ implicitWidth: 150
+ model: Qt.fontFamilies()
+ property bool special : false
+ onCurrentTextChanged: {
+ if (special == false || currentIndex != 0)
+ document.fontFamily = currentText
+ }
+ }
+ SpinBox {
+ id: fontSizeSpinBox
+ implicitWidth: 50
+ value: 0
+ onValueChanged: document.fontSize = value
}
- TextField { id: fontEdit; enabled: false }
Item { Layout.fillWidth: true }
}
}
@@ -240,6 +313,7 @@ ApplicationWindow {
TextArea {
Accessible.name: "document"
id: textArea
+ frameVisible: false
width: parent.width
anchors.top: secondaryToolBar.bottom
anchors.bottom: parent.bottom
@@ -254,8 +328,17 @@ ApplicationWindow {
cursorPosition: textArea.cursorPosition
selectionStart: textArea.selectionStart
selectionEnd: textArea.selectionEnd
- onCurrentFontChanged: {
- fontEdit.text = currentFont.family
+ Component.onCompleted: document.fileUrl = "qrc:/example.html"
+ onFontSizeChanged: fontSizeSpinBox.value = document.fontSize
+ onFontFamilyChanged: {
+ var index = Qt.fontFamilies().indexOf(document.fontFamily)
+ if (index == -1) {
+ fontFamilyComboBox.currentIndex = 0
+ fontFamilyComboBox.special = true
+ } else {
+ fontFamilyComboBox.currentIndex = index
+ fontFamilyComboBox.special = false
+ }
}
}
}
diff --git a/examples/quick/controls/text/resources.qrc b/examples/quick/controls/text/resources.qrc
index e67fac6a..27c7b921 100644
--- a/examples/quick/controls/text/resources.qrc
+++ b/examples/quick/controls/text/resources.qrc
@@ -1,26 +1,27 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/">
- <file>qml/main.qml</file>
- <file>qml/images/logo32.png</file>
- <file>qml/images/editcopy.png</file>
- <file>qml/images/editcut.png</file>
- <file>qml/images/editpaste.png</file>
- <file>qml/images/editredo.png</file>
- <file>qml/images/editundo.png</file>
- <file>qml/images/exportpdf.png</file>
- <file>qml/images/filenew.png</file>
- <file>qml/images/fileopen.png</file>
- <file>qml/images/fileprint.png</file>
- <file>qml/images/filesave.png</file>
- <file>qml/images/textbold.png</file>
- <file>qml/images/textcenter.png</file>
- <file>qml/images/textitalic.png</file>
- <file>qml/images/textjustify.png</file>
- <file>qml/images/textleft.png</file>
- <file>qml/images/textright.png</file>
- <file>qml/images/textunder.png</file>
- <file>qml/images/zoomin.png</file>
- <file>qml/images/zoomout.png</file>
- <file>example.html</file>
-</qresource>
+<RCC>
+ <qresource prefix="/">
+ <file>qml/main.qml</file>
+ <file>qml/ToolBarSeparator.qml</file>
+ <file>qml/images/editcopy.png</file>
+ <file>qml/images/editcut.png</file>
+ <file>qml/images/editpaste.png</file>
+ <file>qml/images/editredo.png</file>
+ <file>qml/images/editundo.png</file>
+ <file>qml/images/exportpdf.png</file>
+ <file>qml/images/filenew.png</file>
+ <file>qml/images/fileopen.png</file>
+ <file>qml/images/fileprint.png</file>
+ <file>qml/images/filesave.png</file>
+ <file>qml/images/textbold.png</file>
+ <file>qml/images/textcenter.png</file>
+ <file>qml/images/textitalic.png</file>
+ <file>qml/images/textjustify.png</file>
+ <file>qml/images/textleft.png</file>
+ <file>qml/images/textright.png</file>
+ <file>qml/images/textunder.png</file>
+ <file>qml/images/zoomin.png</file>
+ <file>qml/images/zoomout.png</file>
+ <file>example.html</file>
+ <file>qml/images/qt-logo.png</file>
+ </qresource>
</RCC>
diff --git a/examples/quick/controls/text/src/documenthandler.cpp b/examples/quick/controls/text/src/documenthandler.cpp
index 48b6d033..e0c9610d 100644
--- a/examples/quick/controls/text/src/documenthandler.cpp
+++ b/examples/quick/controls/text/src/documenthandler.cpp
@@ -52,7 +52,6 @@ DocumentHandler::DocumentHandler()
, m_selectionStart(0)
, m_selectionEnd(0)
{
- setFileUrl(QUrl("qrc:/example.html"));
}
void DocumentHandler::setTarget(QQuickItem *target)
@@ -91,6 +90,8 @@ void DocumentHandler::setFileUrl(const QUrl &arg)
emit textChanged();
emit documentTitleChanged();
+
+ reset();
}
}
emit fileUrlChanged();
@@ -135,12 +136,18 @@ void DocumentHandler::setCursorPosition(int position)
m_cursorPosition = position;
- emit currentFontChanged();
+ reset();
+}
+
+void DocumentHandler::reset()
+{
+ emit fontFamilyChanged();
emit alignmentChanged();
emit boldChanged();
emit italicChanged();
emit underlineChanged();
emit fontSizeChanged();
+ emit textColorChanged();
}
QTextCursor DocumentHandler::textCursor() const
@@ -166,13 +173,11 @@ void DocumentHandler::mergeFormatOnWordOrSelection(const QTextCharFormat &format
void DocumentHandler::setSelectionStart(int position)
{
m_selectionStart = position;
-// emit selectionStartChanged();
}
void DocumentHandler::setSelectionEnd(int position)
{
m_selectionEnd = position;
-// emit selectionEndChanged();
}
void DocumentHandler::setAlignment(Qt::Alignment a)
@@ -188,10 +193,8 @@ void DocumentHandler::setAlignment(Qt::Alignment a)
Qt::Alignment DocumentHandler::alignment() const
{
-// if (!m_doc || m_doc->isEmpty() || m_cursorPosition < 0)
-// return Qt::AlignLeft;
QTextCursor cursor = textCursor();
- if (cursor.isNull() || cursor.blockNumber() == 0)
+ if (cursor.isNull())
return Qt::AlignLeft;
return textCursor().blockFormat().alignment();
}
@@ -199,7 +202,7 @@ Qt::Alignment DocumentHandler::alignment() const
bool DocumentHandler::bold() const
{
QTextCursor cursor = textCursor();
- if (cursor.isNull() || cursor.blockNumber() == 0)
+ if (cursor.isNull())
return false;
return textCursor().charFormat().fontWeight() == QFont::Bold;
}
@@ -207,7 +210,7 @@ bool DocumentHandler::bold() const
bool DocumentHandler::italic() const
{
QTextCursor cursor = textCursor();
- if (cursor.isNull() || cursor.blockNumber() == 0)
+ if (cursor.isNull())
return false;
return textCursor().charFormat().fontItalic();
}
@@ -215,7 +218,7 @@ bool DocumentHandler::italic() const
bool DocumentHandler::underline() const
{
QTextCursor cursor = textCursor();
- if (cursor.isNull() || cursor.blockNumber() == 0)
+ if (cursor.isNull())
return false;
return textCursor().charFormat().fontUnderline();
}
@@ -264,13 +267,44 @@ void DocumentHandler::setFontSize(int arg)
emit fontSizeChanged();
}
-QFont DocumentHandler::currentFont() const
+QColor DocumentHandler::textColor() const
+{
+ QTextCursor cursor = textCursor();
+ if (cursor.isNull())
+ return QColor(Qt::black);
+ QTextCharFormat format = cursor.charFormat();
+ return format.foreground().color();
+}
+
+void DocumentHandler::setTextColor(const QColor &c)
+{
+ QTextCursor cursor = textCursor();
+ if (cursor.isNull())
+ return;
+ QTextCharFormat format;
+ format.setForeground(QBrush(c));
+ mergeFormatOnWordOrSelection(format);
+ emit textColorChanged();
+}
+
+QString DocumentHandler::fontFamily() const
{
QTextCursor cursor = textCursor();
if (cursor.isNull())
- return QFont();
+ return QString();
QTextCharFormat format = cursor.charFormat();
- return format.font();
+ return format.font().family();
+}
+
+void DocumentHandler::setFontFamily(const QString &arg)
+{
+ QTextCursor cursor = textCursor();
+ if (cursor.isNull())
+ return;
+ QTextCharFormat format;
+ format.setFontFamily(arg);
+ mergeFormatOnWordOrSelection(format);
+ emit fontFamilyChanged();
}
QStringList DocumentHandler::defaultFontSizes() const
diff --git a/examples/quick/controls/text/src/documenthandler.h b/examples/quick/controls/text/src/documenthandler.h
index c60bc1d5..a759c403 100644
--- a/examples/quick/controls/text/src/documenthandler.h
+++ b/examples/quick/controls/text/src/documenthandler.h
@@ -63,7 +63,8 @@ class DocumentHandler : public QObject
Q_PROPERTY(int selectionStart READ selectionStart WRITE setSelectionStart NOTIFY selectionStartChanged)
Q_PROPERTY(int selectionEnd READ selectionEnd WRITE setSelectionEnd NOTIFY selectionEndChanged)
- Q_PROPERTY(QFont currentFont READ currentFont NOTIFY currentFontChanged)
+ Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor NOTIFY textColorChanged)
+ Q_PROPERTY(QString fontFamily READ fontFamily WRITE setFontFamily NOTIFY fontFamilyChanged)
Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
Q_PROPERTY(bool bold READ bold WRITE setBold NOTIFY boldChanged)
@@ -93,7 +94,9 @@ public:
int selectionStart() const { return m_selectionStart; }
int selectionEnd() const { return m_selectionEnd; }
- QFont currentFont() const;
+ QString fontFamily() const;
+
+ QColor textColor() const;
Qt::Alignment alignment() const;
void setAlignment(Qt::Alignment a);
@@ -114,6 +117,8 @@ public Q_SLOTS:
void setItalic(bool arg);
void setUnderline(bool arg);
void setFontSize(int arg);
+ void setTextColor(const QColor &arg);
+ void setFontFamily(const QString &arg);
void setFileUrl(const QUrl &arg);
void setText(const QString &arg);
@@ -126,7 +131,8 @@ Q_SIGNALS:
void selectionStartChanged();
void selectionEndChanged();
- void currentFontChanged();
+ void fontFamilyChanged();
+ void textColorChanged();
void alignmentChanged();
void boldChanged();
@@ -142,6 +148,7 @@ Q_SIGNALS:
void documentTitleChanged();
private:
+ void reset();
QTextCursor textCursor() const;
void mergeFormatOnWordOrSelection(const QTextCharFormat &format);
@@ -153,9 +160,6 @@ private:
int m_selectionEnd;
QFont m_font;
- bool m_bold;
- bool m_italic;
- bool m_underline;
int m_fontSize;
QUrl m_fileUrl;
QString m_text;
diff --git a/examples/quick/controls/text/src/main.cpp b/examples/quick/controls/text/src/main.cpp
index 0fc064dc..8d2b8dd0 100644
--- a/examples/quick/controls/text/src/main.cpp
+++ b/examples/quick/controls/text/src/main.cpp
@@ -49,24 +49,14 @@
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- QQmlEngine engine;
-
qmlRegisterType<DocumentHandler>("org.qtproject.example", 1, 0, "DocumentHandler");
-
- QQmlComponent component(&engine);
- component.loadUrl(QUrl("qrc:/qml/main.qml"));
- if ( !component.isReady() ) {
- qWarning("%s", qPrintable(component.errorString()));
- return -1;
- }
- QObject *topLevel = component.create();
+ QQmlApplicationEngine engine(QUrl("qrc:/qml/main.qml"));
+ QObject *topLevel = engine.rootObjects().value(0);
QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);
if ( !window ) {
qWarning("Error: Your root item has to be a Window.");
return -1;
}
-
- QObject::connect(&engine, SIGNAL(quit()), &app, SLOT(quit()));
window->show();
return app.exec();
}
diff --git a/examples/quick/controls/text/text.pro b/examples/quick/controls/text/text.pro
index ce6d5f33..864ce0bb 100644
--- a/examples/quick/controls/text/text.pro
+++ b/examples/quick/controls/text/text.pro
@@ -7,7 +7,8 @@ qtHaveModule(widgets) {
include(src/src.pri)
OTHER_FILES += \
- qml/main.qml
+ qml/main.qml \
+ qml/ToolBarSeparator.qml
RESOURCES += \
resources.qrc
diff --git a/examples/quick/controls/touch/content/ButtonPage.qml b/examples/quick/controls/touch/content/ButtonPage.qml
index 635ce3b9..f431a52e 100644
--- a/examples/quick/controls/touch/content/ButtonPage.qml
+++ b/examples/quick/controls/touch/content/ButtonPage.qml
@@ -86,7 +86,7 @@ Item {
anchors.margins: 20
style: touchStyle
text: "Dont press me"
- onClicked: if (pageStack) pageStack.pop()
+ onClicked: if (stackView) stackView.pop()
}
}
diff --git a/examples/quick/controls/touch/content/TabBarPage.qml b/examples/quick/controls/touch/content/TabBarPage.qml
index c96314be..7651a3c1 100644
--- a/examples/quick/controls/touch/content/TabBarPage.qml
+++ b/examples/quick/controls/touch/content/TabBarPage.qml
@@ -80,11 +80,11 @@ Item {
anchors.fill: parent
border.bottom: 8
border.top: 8
- source: tab.selected ? "../images/tab_selected.png":"../images/tabs_standard.png"
+ source: styleData.selected ? "../images/tab_selected.png":"../images/tabs_standard.png"
Text {
anchors.centerIn: parent
color: "white"
- text: tab.title.toUpperCase()
+ text: styleData.title.toUpperCase()
font.pixelSize: 16
}
Rectangle {
diff --git a/examples/quick/controls/touch/main.qml b/examples/quick/controls/touch/main.qml
index 3058a0d3..9f93cb78 100644
--- a/examples/quick/controls/touch/main.qml
+++ b/examples/quick/controls/touch/main.qml
@@ -54,8 +54,8 @@ ApplicationWindow {
// Implements back key navigation
Keys.onReleased: {
if (event.key === Qt.Key_Back) {
- if (pageStack.depth > 1) {
- pageStack.pop();
+ if (stackView.depth > 1) {
+ stackView.pop();
event.accepted = true;
} else { Qt.quit(); }
}
@@ -72,7 +72,7 @@ ApplicationWindow {
width: opacity ? 60 : 0
anchors.left: parent.left
anchors.leftMargin: 20
- opacity: pageStack.depth > 1 ? 1 : 0
+ opacity: stackView.depth > 1 ? 1 : 0
anchors.verticalCenter: parent.verticalCenter
antialiasing: true
height: 60
@@ -87,7 +87,7 @@ ApplicationWindow {
id: backmouse
anchors.fill: parent
anchors.margins: -10
- onClicked: pageStack.pop()
+ onClicked: stackView.pop()
}
}
@@ -126,7 +126,7 @@ ApplicationWindow {
}
StackView {
- id: pageStack
+ id: stackView
anchors.fill: parent
initialItem: Item {
@@ -137,7 +137,7 @@ ApplicationWindow {
anchors.fill: parent
delegate: AndroidDelegate {
text: title
- onClicked: pageStack.push(Qt.resolvedUrl(page))
+ onClicked: stackView.push(Qt.resolvedUrl(page))
}
}
}
diff --git a/src/controls/ApplicationWindow.qml b/src/controls/ApplicationWindow.qml
index f2e181a5..602661a3 100644
--- a/src/controls/ApplicationWindow.qml
+++ b/src/controls/ApplicationWindow.qml
@@ -125,14 +125,6 @@ Window {
/*! \internal */
default property alias data: contentArea.data
- /*! \internal */
- Binding {
- target: contentItem
- property: "activeFocusOnTab"
- when: activeFocusItem
- value: activeFocusItem ? ( (activeFocusItem != contentItem) ? !activeFocusItem.activeFocusOnTab : true ) : false
- }
-
color: syspal.window
SystemPalette {id: syspal}
diff --git a/src/controls/Button.qml b/src/controls/Button.qml
index 1a9b198e..0a3cb131 100644
--- a/src/controls/Button.qml
+++ b/src/controls/Button.qml
@@ -72,20 +72,6 @@ BasicButton {
*/
property bool isDefault: false
- /*! This property holds the text shown on the button. If the button has no
- text, the \l text property will be an empty string.
-
- The default value is the empty string.
- */
- property string text
-
- /*! This property holds the icon shown on the button. If the button has no
- icon, the \l iconSource property will be an empty string.
-
- The default value is the empty string.
- */
- property url iconSource
-
/*! Assign a \l Menu to this property to get a pull-down menu button.
The default value is \c null.
@@ -94,7 +80,7 @@ BasicButton {
/*! \qmlproperty bool BasicButton::pressed
- This property holds whether the button is pressed. */
+ This property holds whether the button is being pressed. */
readonly property bool pressed: __behavior.effectivePressed || menu && menu.__popupVisible
activeFocusOnTab: true
@@ -115,6 +101,14 @@ BasicButton {
value: button
}
+ Binding {
+ target: button
+ property: "tooltip"
+ // We don't want a tooltip if it's the same as the button text
+ when: !!text && !(action && (!!action.tooltip || action.tooltip === text))
+ value: ""
+ }
+
Connections {
target: __behavior
onEffectivePressedChanged: {
diff --git a/src/controls/ComboBox.qml b/src/controls/ComboBox.qml
index 7b13bc8e..9282c58d 100644
--- a/src/controls/ComboBox.qml
+++ b/src/controls/ComboBox.qml
@@ -80,23 +80,36 @@ import QtQuick.Controls.Private 1.0
Control {
id: comboBox
- /*! The model to populate the ComboBox from. */
+ /*! \qmlproperty model ComboBox::model
+ The model to populate the ComboBox from. */
property alias model: popupItems.model
+
+ /*! The model role used for populating the ComboBox. */
property string textRole: ""
- /*! The index of the currently selected item in the ComboBox. */
+ /*! \qmlproperty int ComboBox::currentIndex
+ The index of the currently selected item in the ComboBox. */
property alias currentIndex: popup.__selectedIndex
- /*! The text of the currently selected item in the ComboBox. */
+
+ /*! \qmlproperty string ComboBox::currentText
+ The text of the currently selected item in the ComboBox. */
readonly property alias currentText: popup.selectedText
/*! This property specifies whether the combobox should gain active focus when pressed.
The default value is \c false. */
property bool activeFocusOnPress: false
- /*! \internal */
+ /*! \qmlproperty bool ComboBox::pressed
+
+ This property holds whether the button is being pressed. */
readonly property bool pressed: mouseArea.pressed && mouseArea.containsMouse || popup.__popupVisible
- /*! \internal */
- property alias __containsMouse: mouseArea.containsMouse
+
+ /*! \qmlproperty bool ComboBox::hovered
+
+ This property indicates whether the control is being hovered.
+ */
+ readonly property alias hovered: mouseArea.containsMouse
+
/*! \internal */
property var __popup: popup
diff --git a/src/controls/GroupBox.qml b/src/controls/GroupBox.qml
index e358dd9d..4aa6a50f 100644
--- a/src/controls/GroupBox.qml
+++ b/src/controls/GroupBox.qml
@@ -159,7 +159,8 @@ Item {
/*! \internal */
property alias __style: styleLoader.item
- implicitWidth: (!anchors.fill ? container.calcWidth() : 0) + loader.leftMargin + loader.rightMargin
+ implicitWidth: Math.max((!anchors.fill ? container.calcWidth() : 0) + loader.leftMargin + loader.rightMargin,
+ sizeHint.implicitWidth + (checkable ? 24 : 6))
implicitHeight: (!anchors.fill ? container.calcHeight() : 0) + loader.topMargin + loader.bottomMargin
Layout.minimumWidth: implicitWidth
@@ -181,6 +182,7 @@ Item {
property int rightMargin: __style ? __style.padding.right : 0
sourceComponent: styleLoader.item ? styleLoader.item.panel : null
onLoaded: item.z = -1
+ Text { id: sizeHint ; visible: false ; text: title }
Loader {
id: styleLoader
property alias __control: groupbox
@@ -212,7 +214,11 @@ Item {
enabled: (!groupbox.checkable || groupbox.checked)
property Item layoutItem: container.children.length === 1 ? container.children[0] : null
- function calcWidth () { return (layoutItem ? (layoutItem.implicitWidth || layoutItem.width) : container.childrenRect.width) }
- function calcHeight () { return (layoutItem ? (layoutItem.implicitHeight || layoutItem.height) : container.childrenRect.height) }
+ function calcWidth () { return (layoutItem ? (layoutItem.implicitWidth || layoutItem.width) +
+ (layoutItem.anchors.fill ? layoutItem.anchors.leftMargin +
+ layoutItem.anchors.rightMargin : 0) : container.childrenRect.width) }
+ function calcHeight () { return (layoutItem ? (layoutItem.implicitHeight || layoutItem.height) +
+ (layoutItem.anchors.fill ? layoutItem.anchors.topMargin +
+ layoutItem.anchors.bottomMargin : 0) : container.childrenRect.height) }
}]
}
diff --git a/src/controls/ProgressBar.qml b/src/controls/ProgressBar.qml
index 33e21514..e472e66e 100644
--- a/src/controls/ProgressBar.qml
+++ b/src/controls/ProgressBar.qml
@@ -98,6 +98,12 @@ Control {
*/
property int orientation: Qt.Horizontal
+ /*! \qmlproperty bool ProgressBar::hovered
+
+ This property indicates whether the control is being hovered.
+ */
+ readonly property alias hovered: hoverArea.containsMouse
+
/*! \internal */
style: Qt.createComponent(Settings.style + "/ProgressBarStyle.qml", progressbar)
@@ -123,7 +129,13 @@ Control {
implicitWidth:(__panel ? __panel.implicitWidth : 0)
implicitHeight: (__panel ? __panel.implicitHeight: 0)
- /* \internal */
+ MouseArea {
+ id: hoverArea
+ anchors.fill: parent
+ hoverEnabled: true
+ }
+
+ /*! \internal */
function setValue(v) {
var newval = parseFloat(v)
if (!isNaN(newval)) {
diff --git a/src/controls/ScrollView.qml b/src/controls/ScrollView.qml
index 31f69b8f..aa980ddd 100644
--- a/src/controls/ScrollView.qml
+++ b/src/controls/ScrollView.qml
@@ -86,8 +86,9 @@ import QtQuick.Controls.Styles 1.0
FocusScope {
id: root
- implicitWidth: 200
- implicitHeight: 100
+
+ implicitWidth: 240
+ implicitHeight: 150
/*!
This property tells the ScrollView if it should render
@@ -146,8 +147,8 @@ FocusScope {
/*! \internal */
property Component style: Qt.createComponent(Settings.style + "/ScrollViewStyle.qml", root)
- /* \internal */
- property PaddedStyle __style: styleLoader.item
+ /*! \internal */
+ property Style __style: styleLoader.item
activeFocusOnTab: true
@@ -236,11 +237,15 @@ FocusScope {
property bool horizontalRecursionGuard: false
property bool verticalRecursionGuard: false
- horizontalMaximumValue: flickableItem ? flickableItem.contentWidth - viewport.width : 0
- verticalMaximumValue: flickableItem ? flickableItem.contentHeight - viewport.height + __viewTopMargin : 0
+ horizontalMinimumValue: flickableItem ? flickableItem.originX : 0
+ horizontalMaximumValue: flickableItem ? flickableItem.originX + flickableItem.contentWidth - viewport.width : 0
+
+ verticalMinimumValue: flickableItem ? flickableItem.originY : 0
+ verticalMaximumValue: flickableItem ? flickableItem.originY + flickableItem.contentHeight - viewport.height + __viewTopMargin : 0
Connections {
target: flickableItem
+
onContentYChanged: {
wheelArea.verticalRecursionGuard = true
wheelArea.verticalValue = flickableItem.contentY
diff --git a/src/controls/Slider.qml b/src/controls/Slider.qml
index 711c449b..64dcfff1 100644
--- a/src/controls/Slider.qml
+++ b/src/controls/Slider.qml
@@ -108,9 +108,16 @@ Control {
/*!
\qmlproperty bool Slider::pressed
- This property indicates if slider handle is currently being pressed.
+ This property indicates whether the slider handle is being pressed.
*/
- property alias pressed: mouseArea.pressed
+ readonly property alias pressed: mouseArea.pressed
+
+ /*!
+ \qmlproperty bool Slider::hovered
+
+ This property indicates whether the control is being hovered.
+ */
+ readonly property alias hovered: mouseArea.containsMouse
/*!
\qmlproperty real Slider::stepSize
@@ -145,7 +152,7 @@ Control {
/*!
\qmlproperty bool Slider::activeFocusOnPress
- This property indicates if the Slider should receive active focus when
+ This property indicates whether the Slider should receive active focus when
pressed.
*/
property bool activeFocusOnPress: false
@@ -153,7 +160,7 @@ Control {
/*!
\qmlproperty bool Slider::tickmarksEnabled
- This property indicates if the Slider should display tickmarks
+ This property indicates whether the Slider should display tickmarks
at step intervals.
The default value is \c false.
@@ -161,9 +168,6 @@ Control {
property bool tickmarksEnabled: false
/*! \internal */
- property bool __containsMouse: mouseArea.containsMouse
-
- /*! \internal */
property bool __horizontal: orientation === Qt.Horizontal
/*! \internal */
@@ -174,19 +178,6 @@ Control {
Accessible.role: Accessible.Slider
Accessible.name: value
- /*!
- \qmlmethod Slider::formatValue
-
- This method returns the current slider value in a way that is more suitable
- for user display, such as the \l value rounded to only two decimal places.
-
- By default this function returns the nearest \c int value.
- */
-
- function formatValue(v) {
- return Math.round(v);
- }
-
style: Qt.createComponent(Settings.style + "/SliderStyle.qml", slider)
Keys.onRightPressed: value += (maximumValue - minimumValue)/10.0
@@ -210,6 +201,14 @@ Control {
anchors.horizontalCenter: !__horizontal ? parent.horizontalCenter : undefined
width: __panel.handleWidth
height: __panel.handleHeight
+
+ function updatePos() {
+ if (updateValueWhileDragging && !mouseArea.drag.active)
+ range.position = __horizontal ? x : y
+ }
+
+ onXChanged: updatePos();
+ onYChanged: updatePos();
}
MouseArea {
@@ -260,14 +259,6 @@ Control {
}
}
- // Range position normally follows handle, except when
- // 'updateValueWhileDragging' is false.
- Binding {
- when: updateValueWhileDragging && !mouseArea.drag.active
- target: range
- property: "position"
- value: __horizontal ? fakeHandle.x : fakeHandle.y
- }
// During the drag, we simply ignore the position set from the range, this
// means that setting a value while dragging will not "interrupt" the
diff --git a/src/controls/SpinBox.qml b/src/controls/SpinBox.qml
index ec563afc..b1f87cec 100644
--- a/src/controls/SpinBox.qml
+++ b/src/controls/SpinBox.qml
@@ -75,6 +75,8 @@ Control {
id: spinbox
/*!
+ \qmlproperty real SpinBox::value
+
The value of this SpinBox, clamped to \l minimumValue and \l maximumValue.
The default value is \c{0.0}.
@@ -82,6 +84,8 @@ Control {
property alias value: validator.value
/*!
+ \qmlproperty real SpinBox::minimumValue
+
The minimum value of the SpinBox range.
The \l value is clamped to this value.
@@ -90,6 +94,8 @@ Control {
property alias minimumValue: validator.minimumValue
/*!
+ \qmlproperty real SpinBox::maximumValue
+
The maximum value of the SpinBox range.
The \l value is clamped to this value. If maximumValue is smaller than
\l minimumValue, \l minimumValue will be enforced.
@@ -98,7 +104,7 @@ Control {
*/
property alias maximumValue: validator.maximumValue
- /*!
+ /*! \qmlproperty real SpinBox::stepSize
The amount by which the \l value is incremented/decremented when a
spin button is pressed.
@@ -106,13 +112,16 @@ Control {
*/
property alias stepSize: validator.stepSize
- /*! The suffix for the value. I.e "cm" */
+ /*! \qmlproperty string SpinBox::suffix
+ The suffix for the value. I.e "cm" */
property alias suffix: validator.suffix
- /*! The prefix for the value. I.e "$" */
+ /*! \qmlproperty string SpinBox::prefix
+ The prefix for the value. I.e "$" */
property alias prefix: validator.prefix
- /*! This property indicates the amount of decimals.
+ /*! \qmlproperty int SpinBox::decimals
+ This property indicates the amount of decimals.
Note that if you enter more decimals than specified, they will
be truncated to the specified amount of decimal places.
The default value is \c{0}.
@@ -125,12 +134,19 @@ Control {
*/
property alias font: input.font
- /*! This property indicates if the Spinbox should get active
+ /*! This property indicates whether the Spinbox should get active
focus when pressed.
The default value is \c true.
*/
property bool activeFocusOnPress: true
+ /*!
+ \qmlproperty bool SpinBox::hovered
+
+ This property indicates whether the control is being hovered.
+ */
+ readonly property alias hovered: mouseArea.containsMouse
+
style: Qt.createComponent(Settings.style + "/SpinBoxStyle.qml", spinbox)
/*! \internal */
@@ -148,7 +164,7 @@ Control {
/*! \internal */
property alias __text: input.text
- __controlState: QtObject {
+ __styleData: QtObject {
readonly property bool upEnabled: value != maximumValue;
readonly property alias upHovered: mouseUp.containsMouse
readonly property alias upPressed: mouseUp.pressed
@@ -157,8 +173,6 @@ Control {
readonly property alias downPressed: mouseDown.pressed
readonly property alias downHovered: mouseDown.containsMouse
- readonly property alias containsMouse: mouseArea.containsMouse
-
readonly property int contentHeight: Math.max(input.implicitHeight, 16)
readonly property int contentWidth: Math.max(maxSizeHint.implicitWidth, minSizeHint.implicitWidth)
}
diff --git a/src/controls/SplitView.qml b/src/controls/SplitView.qml
index fc43874e..8214981a 100644
--- a/src/controls/SplitView.qml
+++ b/src/controls/SplitView.qml
@@ -53,13 +53,14 @@ import QtQuick.Controls.Private 1.0 as Private
SplitView is a control that lays out items horizontally or
vertically with a draggable splitter between each item.
- There will always be one (and only one) item in the SplitView that has \l {Layout}{Layout.fillWidth}
- set to \c true (or Layout.fillHeight, if orientation is Qt.Vertical). This means that the
+ There will always be one (and only one) item in the SplitView that has \l{Layout::fillWidth}{Layout.fillWidth}
+ set to \c true (or \l{Layout::fillHeight}{Layout.fillHeight}, if orientation is Qt.Vertical). This means that the
item will get all leftover space when other items have been laid out.
By default, the last visible child of the SplitView will have this set, but
it can be changed by explicitly setting fillWidth to \c true on another item.
As the fillWidth item will automatically be resized to fit the extra space, explicit assignments
- to width and height will be ignored (but Layout.minimumWidth and Layout.maximumWidth will still be respected).
+ to width and height will be ignored (but \l{Layout::minimumWidth}{Layout.minimumWidth} and
+ \l{Layout::maximumWidth}{Layout.maximumWidth} will still be respected).
A handle can belong to the item either on the left or top side, or on the right or bottom side:
\list
@@ -69,9 +70,17 @@ import QtQuick.Controls.Private 1.0 as Private
This will again control which item gets resized when the user drags a handle,
and which handle gets hidden when an item is told to hide.
- SplitView supports setting attached \l Layout properties on child items, which means that you
- can control minimumWidth, minimumHeight, maximumWidth and maximumHeight (in addition
- to fillWidth/fillHeight) for each child.
+
+ SplitView supports setting attached Layout properties on child items, which
+ means that you can set the following attached properties for each child:
+ \list
+ \li \l{Layout::minimumWidth}{Layout.minimumWidth}
+ \li \l{Layout::minimumHeight}{Layout.minimumHeight}
+ \li \l{Layout::maximumWidth}{Layout.maximumWidth}
+ \li \l{Layout::maximumHeight}{Layout.maximumHeight}
+ \li \l{Layout::fillWidth}{Layout.fillWidth} (\c true for only one child)
+ \li \l{Layout::fillHeight}{Layout.fillHeight} (\c true for only one child)
+ \endlist
Example:
@@ -117,14 +126,17 @@ Item {
/*!
This property holds the delegate that will be instantiated between each
child item. Inside the delegate the following properties are available:
- \list
- \li int \c handleIndex - specifies the index of the splitter handle. The handle
- between the first and the second item will get index 0,
- the next handle index 1 etc.
- \li bool \c pressed: the handle is being pressed.
- \li bool \c resizing: the handle is being dragged.
- \endlist
- */
+
+ \table
+ \row \li readonly property bool styleData.index \li Specifies the index of the splitter handle. The handle
+ between the first and the second item will get index 0,
+ the next handle index 1 etc.
+ \row \li readonly property bool styleData.hovered \li The handle is being hovered.
+ \row \li readonly property bool styleData.pressed \li The handle is being pressed.
+ \row \li readonly property bool styleData.resizing \li The handle is being dragged.
+ \endtable
+
+*/
property Component handleDelegate: Rectangle {
width: 1
height: 1
@@ -176,7 +188,7 @@ Item {
continue
if (splitterItems.children.length > 0)
- handleLoader.createObject(splitterHandles, {"handleIndex":splitterItems.children.length - 1})
+ handleLoader.createObject(splitterHandles, {"__handleIndex":splitterItems.children.length - 1})
item.parent = splitterItems
i-- // item was removed from list
item.widthChanged.connect(d.updateLayout)
@@ -319,18 +331,21 @@ Item {
id: handleLoader
Loader {
id: itemHandle
- property int handleIndex: -1
- property alias containsMouse: mouseArea.containsMouse
- property alias pressed: mouseArea.pressed
- property bool resizing: mouseArea.drag.active
- visible: __items[handleIndex + ((d.fillIndex >= handleIndex) ? 0 : 1)].visible
+ property int __handleIndex: -1
+ property QtObject styleData: QtObject {
+ readonly property int index: __handleIndex
+ readonly property alias hovered: mouseArea.containsMouse
+ readonly property alias pressed: mouseArea.pressed
+ readonly property bool resizing: mouseArea.drag.active
+ onResizingChanged: root.resizing = resizing
+ }
+ visible: __items[__handleIndex + ((d.fillIndex >= __handleIndex) ? 0 : 1)].visible
sourceComponent: handleDelegate
onWidthChanged: d.updateLayout()
onHeightChanged: d.updateLayout()
onXChanged: moveHandle()
onYChanged: moveHandle()
- onResizingChanged: root.resizing = resizing
MouseArea {
id: mouseArea
@@ -357,12 +372,12 @@ Item {
var leftEdge, rightEdge, newWidth, leftStopX, rightStopX
var i
- if (d.fillIndex > handleIndex) {
+ if (d.fillIndex > __handleIndex) {
// Resize item to the left.
// Ensure that the handle is not crossing other handles. So
// find the first visible handle to the left to determine the left edge:
leftEdge = 0
- for (i=handleIndex-1; i>=0; --i) {
+ for (i=__handleIndex-1; i>=0; --i) {
leftHandle = __handles[i]
if (leftHandle.visible) {
leftEdge = leftHandle[d.offset] + leftHandle[d.size]
@@ -371,13 +386,13 @@ Item {
}
// Ensure: leftStopX >= itemHandle[d.offset] >= rightStopX
- var min = d.accumulatedSize(handleIndex+1, __items.length, true)
+ var min = d.accumulatedSize(__handleIndex+1, __items.length, true)
rightStopX = root[d.size] - min - itemHandle[d.size]
leftStopX = Math.max(leftEdge, itemHandle[d.offset])
itemHandle[d.offset] = Math.min(rightStopX, Math.max(leftStopX, itemHandle[d.offset]))
newWidth = itemHandle[d.offset] - leftEdge
- leftItem = __items[handleIndex]
+ leftItem = __items[__handleIndex]
// The next line will trigger 'updateLayout':
leftItem[d.size] = newWidth
} else {
@@ -385,7 +400,7 @@ Item {
// Ensure that the handle is not crossing other handles. So
// find the first visible handle to the right to determine the right edge:
rightEdge = root[d.size]
- for (i=handleIndex+1; i<__handles.length; ++i) {
+ for (i=__handleIndex+1; i<__handles.length; ++i) {
rightHandle = __handles[i]
if (rightHandle.visible) {
rightEdge = rightHandle[d.offset]
@@ -394,13 +409,13 @@ Item {
}
// Ensure: leftStopX <= itemHandle[d.offset] <= rightStopX
- min = d.accumulatedSize(0, handleIndex+1, true)
+ min = d.accumulatedSize(0, __handleIndex+1, true)
leftStopX = min - itemHandle[d.size]
rightStopX = Math.min((rightEdge - itemHandle[d.size]), itemHandle[d.offset])
itemHandle[d.offset] = Math.max(leftStopX, Math.min(itemHandle[d.offset], rightStopX))
newWidth = rightEdge - (itemHandle[d.offset] + itemHandle[d.size])
- rightItem = __items[handleIndex+1]
+ rightItem = __items[__handleIndex+1]
// The next line will trigger 'updateLayout':
rightItem[d.size] = newWidth
}
diff --git a/src/controls/StackView.qml b/src/controls/StackView.qml
index c7b2366f..9559ea87 100644
--- a/src/controls/StackView.qml
+++ b/src/controls/StackView.qml
@@ -52,37 +52,38 @@ import "Private/StackView.js" as JSArray
\brief Provides a stack-based navigation model.
- StackView implements a stack-based navigation model. You use this view when you
- have a set of interlinked information pages for the user to browse.
- Items are pushed onto the stack as the user navigates deeper into the material, and
- popped off again when he chooses to go back.
+ StackView implements a stack-based navigation model, which can be used
+ with a set of interlinked information pages. Items are pushed onto the stack
+ as the user navigates deeper into the material, and popped off again when he
+ chooses to go back.
\section1 Using StackView in an Application
Using the StackView in the application is typically a simple matter of adding
- the StackView as a child of a Window. The stack is usually
- anchored to the edges of the window, except at the top or bottom where it might
- be anchored to a status bar, or some other similar UI component.
- The stack can then be used by invoking its navigation methods. The first item
- to show in the StackView is commonly loaded assigning it to \l initialItem.
+ the StackView as a child of a Window. The stack is usually anchored to the
+ edges of the window, except at the top or bottom where it might be anchored
+ to a status bar, or some other similar UI component. The stack can then be
+ used by invoking its navigation methods. The first item to show in the StackView
+ is commonly loaded assigning it to \l initialItem.
+
+ \note Items pushed onto the stack view have \l{Supported Attached Properties}{Stack attached properties}.
\section1 Basic Navigation
- There are three primary navigation operations in StackView: push(), pop() and
- replace (you replace by specifying argument \c replace to push()).
+ There are three primary navigation operations in StackView: push(), pop(), and
+ replace (replace by specifying argument \c replace to push()).
These correspond to classic stack operations where "push" adds an item to the
top of a stack, "pop" removes the top item from the stack, and "replace" is like a
pop followed by a push in that it replaces the topmost item on the stack with
a new item (but the applied transtition might be different). The topmost item
- in the stack corresponds to the one that is \l{StackView::currentItem} {current},
- i.e. the one that is visible on
- screen. That means that "push" is the logical equivalent of navigating forward or
- deeper into the application, "pop" is the equivalent of navigation back and
- "replace" is the equivalent of replacing the current item with a different item.
-
- Sometimes it is necessary to go back more than a single step in the stack, e.g.
- to return to a "main" item or some kind of section item in the application.
- For this use case, pop() can be provided with a item to pop to. This is called
- an "unwind" operation as the stack gets unwound to the specified item. If the
- item is not found then the stack unwinds until there is only a single item in
+ in the stack corresponds to the one that is \l{StackView::currentItem} {currently}
+ visible on the screen. That means that "push" is the logical equivalent of navigating
+ forward or deeper into the application, "pop" is the equivalent of navigating back,
+ and "replace" is the equivalent of replacing the current item.
+
+ Sometimes it is necessary to go back more than a single step in the stack, for
+ example, to return to a "main" item or some kind of section item in the application.
+ For this use case, it is possible to specify an item as a parameter for pop().
+ This is called an "unwind" operation as the stack gets unwound to the specified item.
+ If the item is not found then the stack unwinds until there is only a single item in
the stack, which becomes the current item. To explicitly unwind to the bottom
of the stack it is recommended to use \l{pop()} {pop(null)}, though technically any
non-existent item will do.
@@ -96,11 +97,11 @@ import "Private/StackView.js" as JSArray
\li \l{pop()}{pop(A)} => [A] - "pop" transition between C and A
\endlist
- Note that when the stack is empty, a push() will not perform a
- transition animation because there is nothing to transition from (which will
- typically happend during application start-up). A pop() on a stack with
- depth 1 or 0 is a no-operation. If removing all items from the stack is
- needed, a separate function clear() is available.
+ \note Note that when the stack is empty, a push() will not perform a
+ transition animation because there is nothing to transition from (typically during
+ application start-up). A pop() on a stack with depth 1 or 0 is a no-operation.
+ If removing all items from the stack is needed, a separate function clear() is
+ available.
Calling push() returns the item that was pushed onto the stack.
Calling pop() returns the item that was popped off the stack. When pop() is
@@ -108,22 +109,22 @@ import "Private/StackView.js" as JSArray
popped, which will also be the one transitioning out) is returned.
\section1 Deep Linking
- Deep linking means launching an application into a particular state. For example
- a Newspaper application could be launched into showing a particular article,
- bypassing the front item (and possible a section item) that would normally have
- to be navigated through to get to the article in question. In terms of StackView, deep
- linking means the ability to modify the state of the stack so that
- you e.g. push a set of items to the top of the stack, or that you completely reset
+ \e{Deep linking} means launching an application into a particular state. For example,
+ a newspaper application could be launched into showing a particular article,
+ bypassing the front item (and possibly a section item) that would normally have
+ to be navigated through to get to the article concerned. In terms of StackView, deep
+ linking means the ability to modify the state of the stack, so much so that it is
+ possible to push a set of items to the top of the stack, or to completely reset
the stack to a given state.
- The API for deep linking in StackView is the same as for basic navigation. If
- you push an array instead of a single item then all the items in that array will
+ The API for deep linking in StackView is the same as for basic navigation. Pushing
+ an array instead of a single item, will involve that all the items in that array will
be pushed onto the stack. The transition animation, however, will be conducted as
if only the last item in the array was pushed onto the stack. The normal semantics
- of push() apply for deep linking, meaning that push() adds whatever you push onto
- the stack. Note also that only the last item in the array will actually be loaded.
- The rest will be lazy loaded as needed when entering
- the screen upon subsequent calls to pop (or when requesting the item by using \a get).
+ of push() apply for deep linking, meaning that push() adds whatever is pushed onto
+ the stack. Note also that only the last item of the array will be loaded.
+ The rest will be lazy-loaded as needed when entering the screen upon subsequent
+ calls to pop (or when requesting the item by using \a get).
This gives us the following result, given the stack [A, B, C]:
@@ -135,93 +136,95 @@ import "Private/StackView.js" as JSArray
\section1 Pushing items
- An item you push onto the StackView can be either an Item, a URL, a
- string with a URL, or a Component. To push it, you assign it
- to a property "item" inside a property list, and send it as argument to \l{StackView::push}{push}:
+ An item pushed onto the StackView can be either an Item, a URL, a string
+ with a URL, or a Component. To push it, assign it to a property "item"
+ inside a property list, and send it as an argument to \l{StackView::push}{push}:
\code
stackView.push({item: yourItem})
\endcode
- The list can contain several properties that controls how the item should be pushed:
+ The list can contain several properties that control how the item should be pushed:
\list
- \li \c item: This property is required, and holds the item you want to push.
- \li \c properties: You can set a property list of QML properties that should be assigned
- to the item upon push. These properties will be copied into the item at the
- time the item is loaded, or about to become the current item (normally upon push).
- \li \c immediate: Set this property to \c true to skip transition effects. When pushing
- an array, you only need to set this property on the first element to make the
+ \li \c item: this property is required, and holds the item to be pushed.
+ \li \c properties: a list of QML properties to be assigned to the item upon push. These
+ properties will be copied into the item at load time, or when the item will become
+ the current item (normally upon push).
+ \li \c immediate: set this property to \c true to skip transition effects. When pushing
+ an array, this property only needs to be set on the first element to make the
whole operation immediate.
- \li \c replace: Set this property to replace the current item on the stack. When pushing
+ \li \c replace: set this property to replace the current item on the stack. When pushing
an array, you only need to set this property on the first element to replace
as many elements on the stack as inside the array.
- \li \c destroyOnPop: Set this property to be explicit to whether or not StackView should
- destroy the item when its popped off the stack. By default (if \a destroyOnPop is
- not specified), StackView will destroy items pushed as components or URLs. Items
- not destroyed will be reparented back to the original parents they had before being
- pushed onto the stack, and hidden. If you need to set this property, do it with
- care, so that items are not leaked.
+ \li \c destroyOnPop: set this boolean to true if StackView needs to destroy the item when
+ it is popped off the stack. By default (if \a destroyOnPop is not specified), StackView
+ will destroy items pushed as components or URLs. Items not destroyed will be re-parented
+ back to the original parents they had before being pushed onto the stack and hidden.
+ If you need to set this property, do it with care, so that items are not leaked.
\endlist
- If the only argument needed is "item", you can also, as a short-hand
- notation, do:
+ If the only argument needed is "item", the following short-hand notation can be applied:
\code
- stackView.push(yourItem).
+ stackView.push(yourItem)
\endcode
You can push several items in one go by using an array of property lists. This is
optimizing compared to pushing items one by one, since StackView then can load only the
last item in the list. The rest will be loaded as they are about to become
- the current item (which happends when the stack is popped). The following example shows how
+ the current item (which happens when the stack is popped). The following example shows how
to push an array of items:
\code
stackView.push([{item: yourItem1}, {item: yourItem2}])
\endcode
- If inline items are pushed, the item gets re-parented into an internal
- container in the StackView. When the item is later popped off, it gets
- re-parented back to its original owner. If, however, an item is pushed
- as a component or a URL, the actual item will be created as a item from that component. This
- happens automatically when the item is about to become the current item in the stack. Ownership
- over the item will then normally be taken by the StackView. It will as such automatically
- destroy the item when it is later popped off. The component that declared the item, by
+ If an inline item is pushed, the item is temporarily re-parented into the StackView. When the item
+ is later popped off, it gets re-parented back to its original owner again.
+ If, however, an item is pushed as a component or a URL, the actual item will be created as an
+ item from that component. This happens automatically when the item is about to become the current
+ item in the stack. Ownership of the item will then normally be taken by the StackView. It will as
+ such automatically destroy the item when it is later popped off. The component that declared the item, by
contrast, remains in the ownership of the application and is not destroyed by the stack.
- You can override this behavior if needed by explicitly setting "destroyOnPop" in the list
- argument given to push.
+ This can be overridden by explicitly setting \c{destroyOnPop} in the list of arguments given to push.
- If you specify the \c properties property to push, these properties will be copied into
- the item at the time the item is loaded (in case of a component or URL), or instead when
- its about to become the current item (in case of an inline item). This normally happens when
- the item is pushed. The following example shows how this can be done:
+ If the \c properties to be pushed are specified, they will be copied into the item at loading time
+ (in case of a component or URL), or when the item will become the current item (in case of an inline
+ item). The following example shows how this can be done:
\code
- stackView.push({item: someItem, properties: {fgcolor: "red", bgcolor: "blue"}});
+ stackView.push({item: someItem, properties: {fgcolor: "red", bgcolor: "blue"}})
\endcode
- Note that if an item is declared inside another item that is destroyed - even if a component
- was used - that child item also gets destroyed.
- This follows normal Qt parent-child destruction rules but sometimes comes as a surprise
- for developers. In practice this means that if you declare a item B as a child of
- item A and then do a replace from item A to item B, then item B will be destroyed when
- item A was destroyed (as it was popped off the stack) and the application will effectively
- be switching to a item that has been destroyed.
+
+ \note Note that if an item is declared inside another item, and if that parent gets destroyed,
+ (even if a component was used), that child item will also be destroyed.
+ This follows normal Qt parent-child destruction rules, but sometimes comes as a surprise
+ for developers.
\section1 Lifecycle
- An items lifecycle in the StackView goes from instantiation to inactive, activating, active,
- deactivating, inactive, and when no longer needed, destruction.
+ An item's lifecycle in the StackView can have the following transitions:
+ \list 1
+ \li instantiation
+ \li inactive
+ \li activating
+ \li active
+ \li deactivating
+ \li inactive
+ \li destruction
+ \endlist
+
It can move any number of times between inactive and active. When an item is activated,
it's visible on the screen and is considered to be the current item. An item
in a StackView that is not visible is not activated, even if the item is currently the
- top-most item in the stack. When the stack becomes visible the item that is top-most gets
- activated. Likewise if the stack is then hidden, the top-most item would be deactivated.
+ top-most item in the stack. When the stack becomes visible, the item that is top-most gets
+ activated. Likewise if the stack is then hidden, the topmost item would be deactivated.
Popping the item off the top of the stack at this point would not result in further
deactivation since the item is not active.
- There is an attached \l{Stack::status}{Stack.status} property that tracks the lifecycle. The value of status is
- an enumeration with values \c Stack.Inactive, \c Stack.Activating, \c Stack.Active
- and \c Stack.Deactivating. Combined with the normal \c Component.onComplete and
+ There is an attached \l{Stack::status}{Stack.status} property that tracks the lifecycle. The
+ status values list is an enumeration with values \c Stack.Inactive, \c Stack.Activating,
+ \c Stack.Active and \c Stack.Deactivating. Combined with the normal \c Component.onComplete and
\c Component.onDestruction signals the entire lifecycle is thus:
\list
@@ -234,26 +237,26 @@ import "Private/StackView.js" as JSArray
\endlist
\section1 Finding items
- Sometimes it is necessary to search for a item, e.g. in order to unwind the stack to
+ Sometimes it is necessary to search for an item, for example, in order to unwind the stack to
an item to which the application does not have a reference. This is facilitated using a
function find() in StackView. The find() function takes a callback function as its
only argument. The callback gets invoked for each item in the stack (starting at the top).
- If the callback returns true then it signals that a match has been found and the find()
- function returns that item. If the callback fails to return true (i.e. no match is found)
+ If the callback returns true, then it signals that a match has been found and the find()
+ function returns that item. If the callback fails to return true (no match is found),
then find() returns \c null.
- The code below searches for an item in the stack that has a name "foo" and then unwinds to
- that item. Note that since find() returns null if no item is found and since pop unwinds to
- the bottom of the stack if null is given as the target item, the code works well even in the
- case that no matching item was found.
+ The code below searches for an item in the stack that has a name "order_id" and then unwinds to
+ that item. Note that since find() returns \c {null} if no item is found, and since pop unwinds to
+ the bottom of the stack if null is given as the target item, the code works well even in
+ case no matching item is found.
\code
stackView.pop(stackView.find(function(item) {
- return item.name == "foo";
+ return item.name == "order_id";
}));
\endcode
- You can also get to a item in the stack using get(index). You should use
+ You can also get to an item in the stack using \l {get()}{get(index)}. You should use
this function if your item depends on another item in the stack, as the function will
ensure that the item at the given index gets loaded before it is returned.
@@ -314,8 +317,8 @@ import "Private/StackView.js" as JSArray
Implement this function to reset any properties animated on the exitItem so that later
transitions can expect the items to be in a default state.
- A more complex example could look like the following. Here, the items slides in lying on the side before
- they are rotated up in an upright position:
+ A more complex example could look like the following. Here, the items are lying on the side before
+ being rotated to an upright position:
\qml
StackView {
@@ -374,7 +377,7 @@ import "Private/StackView.js" as JSArray
depending on the their internal state. StackView will expect you to return a Component that
contains a StackViewTransition, or a StackViewTransition directly. The former is easier, as StackView will
then create the transition and later destroy it when it's done, while avoiding any sideeffects
- caused by the transition being alive long after it ran. Returning a StackViewTransition directly
+ caused by the transition being alive long after it has run. Returning a StackViewTransition directly
can be useful if you need to write some sort of transition caching for performance reasons.
As an optimization, you can also return \c null to signal that you just want to show/hide the items
immediately without creating or running any transitions. You can also override this function if
@@ -383,9 +386,9 @@ import "Private/StackView.js" as JSArray
\c properties contains the properties that will be assigned to the StackViewTransition before
it runs. In fact, you can add more properties to this object during the call
if you need to initialize additional properties of your custom StackViewTransition when the returned
- component is instanciated.
+ component is instantiated.
- The following example shows how you can decide run-time which animation to use:
+ The following example shows how you can decide which animation to use during runtime :
\qml
StackViewDelegate {
@@ -435,6 +438,15 @@ import "Private/StackView.js" as JSArray
}
}
\endqml
+
+ \section1 Supported Attached Properties
+
+ Items in a StackView support these attached properties:
+ \list
+ \li \l{Stack::index}{Stack.index} - Contains the index of the item inside the StackView
+ \li \l{Stack::view}{Stack.view} - Contains the StackView the item is in
+ \li \l{Stack::status}{Stack.status} - Contains the status of the item
+ \endlist
*/
Item {
@@ -480,28 +492,28 @@ Item {
/*! Pushes an item onto the stack. The function takes a property list as argument, which
should contain one or more of the following properties:
\list
- \li \c item: This property is required, and holds the item you want to push.
- \li \c properties: You can set a property list of QML properties that should be assigned
- to the item upon push. These properties will be copied into the item at the
- time the item is loaded (in case of a component or URL), or else the first time it
- becomes the current item (normally upon push).
- \li \c immediate: Set this property to \c true to skip transition effects. When pushing
+ \li \c item: this property is required, and holds the item you want to push.
+ \li \c properties: a list of QML properties that should be assigned
+ to the item upon push. These properties will be copied into the item when it is
+ loaded (in case of a component or URL), or when it becomes the current item for the
+ first time (normally upon push).
+ \li \c immediate: set this property to \c true to skip transition effects. When pushing
an array, you only need to set this property on the first element to make the
whole operation immediate.
- \li \c replace: Set this property to replace the current item on the stack. When pushing
+ \li \c replace: set this property to replace the current item on the stack. When pushing
an array, you only need to set this property on the first element to replace
as many elements on the stack as inside the array.
- \li \c destroyOnPop: Set this property to be explicit to whether or not StackView should
- destroy the item when its popped off the stack. By default (if \a destroyOnPop is
- not specified), StackView will destroy items pushed as components or URLs. Items
- not destroyed will be reparented back to the original parents they had before being
+ \li \c destroyOnPop: set this property to specify if the item needs to be destroyed
+ when its popped off the stack. By default (if \a destroyOnPop is not specified),
+ StackView will destroy items pushed as components or URLs. Items
+ not destroyed will be re-parented to the original parents they had before being
pushed onto the stack, and hidden. If you need to set this property, do it with
care, so that items are not leaked.
\endlist
You can also push an array of items (property lists) if you need to push several items
in one go. A transition will then only occur between the current item and the last
- item in the list. The other items will be deferred loaded until needed.
+ item in the list. Loading the other items will be deferred until needed.
Examples:
\list
@@ -513,8 +525,8 @@ Item {
\li stackView.push([{item:anitem, immediate:true}, {item:aURL}])
\endlist
- Note: If the only argument needed is "item", you can also, as a short-hand
- notation, do: \c{stackView.push(anItem)}.
+ \note Note: if the only argument needed is "item", you can apply the following short-
+ hand notation: \c{stackView.push(anItem)}.
Returns the item that became current.
@@ -570,11 +582,11 @@ Item {
/*! Pops one or more items off the stack. The function takes a property list as argument
which can contain one or more of the following properties:
\list
- \li \c item: If specified, all items down to (but not including) \a item will be
- popped off. if \a item is \c null, all items down to (but not including) the
+ \li \c item: if specified, all items down to (but not including) \a item will be
+ popped off. If \a item is \c null, all items down to (but not including) the
first item will be popped. If not specified, only the current item will be
popped.
- \li \c immediate: Set this property to \c true to skip transition effects.
+ \li \c immediate: set this property to \c true to skip transition effects.
\endlist
Examples:
@@ -585,8 +597,8 @@ Item {
\li stackView.pop(null)
\endlist
- Note: If the only argument needed is "item", you can also, as a short-hand
- notation, do: \c{stackView.pop(anItem)}.
+ \note Note: If the only argument needed is "item", you can apply the following short-
+ hand notation: \c{stackView.pop(anItem)}.
Returns the item that was popped off
\sa clear()
@@ -657,7 +669,8 @@ Item {
/*! Search for a specific item inside the stack. \a func will
be called for each item in the stack (with the item as argument)
- until the function returns true. Return value will be the item found. E.g:
+ until the function returns true. Return value will be the item found. For
+ example:
find(function(item, index) { return item.isTheOne })
Set \a onlySearchLoadedItems to \c true to not load items that are
not loaded into memory */
@@ -783,7 +796,7 @@ Item {
element.destroyOnPop = true
}
} else {
- // comp is already an Item, so just reparent it into the StackView:
+ // comp is already an Item, so just re-parent it into the StackView:
element.item = comp
element.originalParent = parent
element.item.parent = root
@@ -797,7 +810,7 @@ Item {
}
element.item.Stack.__index = element.index
- element.item.Stack.__stackView = root
+ element.item.Stack.__view = root
// Let item fill all available space by default:
element.item.width = Qt.binding(function() { return root.width })
element.item.height = Qt.binding(function() { return root.height })
@@ -833,7 +846,7 @@ Item {
/*! \internal */
function __cleanup(element) {
// INVARIANT: element has been removed from JSArray. Destroy its
- // item, or reparent it back to the parent it had before it was pushed:
+ // item, or re-parent it back to the parent it had before it was pushed:
var item = element.item
if (element.destroyOnPop) {
item.destroy()
@@ -842,7 +855,7 @@ Item {
// might reenter on pop if pushed several times:
item.visible = false
__setStatus(item, Stack.Inactive)
- item.Stack.__stackView = null
+ item.Stack.__view = null
item.Stack.__index = -1
if (element.originalParent)
item.parent = element.originalParent
@@ -860,7 +873,7 @@ Item {
// Animate item in "outElement" out, and item in "inElement" in. Set a guard to protect
// the user from pushing new items on signals that will fire while preparing for the transition
// (e.g Stack.onCompleted, Stack.onStatusChanged, Stack.onIndexChanged etc). Otherwise, we will enter
- // this function several times, which causes the items to be half-way updated.
+ // this function several times, which causes the items to be updated half-way.
if (__currentTransition)
__currentTransition.animation.complete()
__loadElement(transition.inElement)
@@ -871,7 +884,7 @@ Item {
// Since an item can be pushed several times, we need to update its properties:
enterItem.parent = root
- enterItem.Stack.__stackView = root
+ enterItem.Stack.__view = root
enterItem.Stack.__index = transition.inElement.index
__currentItem = enterItem
diff --git a/src/controls/StatusBar.qml b/src/controls/StatusBar.qml
index 13edc5ef..85cc6681 100644
--- a/src/controls/StatusBar.qml
+++ b/src/controls/StatusBar.qml
@@ -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,72 @@ 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: container.leftMargin + container.rightMargin + container.calcWidth()
+ 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 calcWidth() { return (layoutItem ? (layoutItem.implicitWidth || layoutItem.width) +
+ (layoutItem.anchors.fill ? layoutItem.anchors.leftMargin +
+ layoutItem.anchors.rightMargin : 0) :
+ loader.item ? loader.item.implicitWidth: 0) }
+ function calcHeight () { return (layoutItem ? (layoutItem.implicitHeight || layoutItem.height) +
+ (layoutItem.anchors.fill ? layoutItem.anchors.topMargin +
+ layoutItem.anchors.bottomMargin : 0) : loader.item ? loader.item.implicitHeight : 0) }
+ }]
}
diff --git a/src/controls/TabView.qml b/src/controls/TabView.qml
index d292ce05..6319d72c 100644
--- a/src/controls/TabView.qml
+++ b/src/controls/TabView.qml
@@ -55,7 +55,8 @@ import QtQuick.Controls.Private 1.0
FocusScope {
id: root
- implicitWidth: 150
+
+ implicitWidth: 240
implicitHeight: 150
/*! The current tab index */
@@ -133,7 +134,7 @@ FocusScope {
}
/*! Returns the \l Tab item at \a index. */
- function tabAt(index) {
+ function getTab(index) {
return __tabs.get(index).tab
}
@@ -198,7 +199,7 @@ FocusScope {
anchors.fill: parent
anchors.margins: (frameVisible ? frameWidth : 0)
anchors.topMargin: anchors.margins + (style =="mac" ? 6 : 0)
- anchors.bottomMargin: anchors.margins + (style =="mac" ? 6 : 0)
+ anchors.bottomMargin: anchors.margins
property int frameWidth
property string style
diff --git a/src/controls/TableView.qml b/src/controls/TableView.qml
index ca0df45a..b02a49c0 100644
--- a/src/controls/TableView.qml
+++ b/src/controls/TableView.qml
@@ -65,8 +65,7 @@ import QtQuick.Controls.Styles 1.0
\endcode
You provide title and size of a column header
- by adding a \l TableViewColumn to the default \l header property
- as demonstrated below.
+ by adding a \l TableViewColumn as demonstrated below.
\code
TableView {
@@ -124,26 +123,37 @@ ScrollView {
The default value is \c true. */
property bool headerVisible: true
+ /*! \qmlproperty bool TableView::backgroundVisible
+
+ This property determines if the background should be filled or not.
+
+ The default value is \c true.
+
+ \note The rowDelegate is not affected by this property
+ */
+ property alias backgroundVisible: colorRect.visible
+
/*! This property defines a delegate to draw a specific cell.
In the item delegate you have access to the following special properties:
\list
- \li itemSelected - if the item is currently selected
- \li itemValue - the value or text for this item
- \li itemTextColor - the default text color for an item
- \li row - the index of the row
- \li column - the index of the column
- \li itemElideMode - the elide mode of the column
- \li itemTextAlignment - the horizontal text alignment of the column
+ \li styleData.selected - if the item is currently selected
+ \li styleData.value - the value or text for this item
+ \li styleData.textColor - the default text color for an item
+ \li styleData.row - the index of the row
+ \li styleData.column - the index of the column
+ \li styleData.elideMode - the elide mode of the column
+ \li styleData.textAlignment - the horizontal text alignment of the column
\endlist
+
Example:
\code
itemDelegate: Item {
Text {
anchors.verticalCenter: parent.verticalCenter
- color: itemTextColor
- elide: itemElideMode
- text: itemValue
+ color: styleData.textColor
+ elide: styleData.elideMode
+ text: styleData.value
}
}
\endcode */
@@ -153,20 +163,23 @@ ScrollView {
In the row delegate you have access to the following special properties:
\list
- \li alternateBackground - if the row uses the alternate background color
- \li rowSelected - if the row is currently selected
- \li index - the index of the row
+ \li styleData.alternate - true when the row uses the alternate background color
+ \li styleData.selected - true when the row is currently selected
+ \li styleData.row - the index of the row
\endlist
*/
property Component rowDelegate: __style ? __style.rowDelegate : null
- /*! \qmlproperty color TableView::backgroundColor
+ /*! This property defines a delegate to draw a header.
- 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:
+ \list
+ \li styleData.value - the value or text for this item
+ \li styleData.column - the index of the column
+ \li styleData.pressed - true when the column is being pressed
+ \li styleData.containsMouse - true when the column is under the mouse
+ \endlist
+ */
property Component headerDelegate: __style ? __style.headerDelegate : null
/*! Index of the current sort column.
@@ -190,9 +203,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 */
@@ -206,8 +218,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
@@ -226,10 +239,30 @@ ScrollView {
/*! \internal */
property alias __currentRowItem: listView.currentItem
- /*! \qmlsignal TableView::activated()
- Emitted when the user activates an item by single or double-clicking (depending on the platform).
+ /*! \qmlsignal TableView::activated(int row)
+
+ Emitted when the user activates an item by mouse or keyboard interaction.
+ Mouse activation is triggered by single- or double-clicking, depending on the platform.
+
+ \a row int provides access to the activated row index.
*/
- signal activated
+ signal activated(int row)
+
+ /*! \qmlsignal TableView::clicked(int row)
+
+ Emitted when the user clicks a valid row by single clicking
+
+ \a row int provides access to the clicked row index.
+ */
+ signal clicked(int row)
+
+ /*! \qmlsignal TableView::doubleClicked(int row)
+
+ Emitted when the user double clicks a valid row.
+
+ \a row int provides access to the clicked row index.
+ */
+ signal doubleClicked(int row)
/*!
\qmlmethod TableView::positionViewAtRow( int row, PositionMode mode )
@@ -255,13 +288,13 @@ ScrollView {
Depending on how the model is populated, the model may not be ready when
TableView Component.onCompleted is called. In that case you may need to
- delay the call to positionViewAtRow by using a \l {Timer}.
+ delay the call to positionViewAtRow by using a \l {QtQml::Timer}{Timer}.
\note This method should only be called after the component has completed.
*/
function positionViewAtRow(row, mode) {
- listView.positionViewAtRow(row, mode)
+ listView.positionViewAtIndex(row, mode)
}
/*!
@@ -278,17 +311,89 @@ 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)
+
+ else if (object.__view) {
+ console.warn("TableView::insertColumn(): you cannot add a column to multiple views")
+ return null
+ }
+ if (index >= 0 && index <= columnCount && object.Accessible.role === Accessible.ColumnHeader) {
+ object.__view = root
+ 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)
Accessible.role: Accessible.Table
- width: 200
- height: 200
+ implicitWidth: 200
+ implicitHeight: 150
frameVisible: true
- __scrollBarTopMargin: Qt.platform.os === "mac" ? headerrow.height : 0
+ __scrollBarTopMargin: Qt.platform.os === "osx" ? headerrow.height : 0
__viewTopMargin: headerrow.height
/*! \internal */
@@ -327,7 +432,7 @@ ScrollView {
id: colorRect
parent: viewport
anchors.fill: parent
- color: palette.base
+ color: __style ? __style.backgroundColor : palette.base
z: -1
}
@@ -362,28 +467,39 @@ ScrollView {
autoincrement = false;
autodecrement = false;
}
- var y = Math.min(listView.contentY + listView.height - 5, Math.max(mouseY + listView.contentY, listView.contentY));
- var newIndex = listView.indexAt(0, y);
- if (newIndex >= 0)
- listView.currentIndex = listView.indexAt(0, y);
+
+ if (pressed) {
+ var newIndex = listView.indexAt(0, mouseY + listView.contentY)
+ if (newIndex >= 0)
+ listView.currentIndex = newIndex;
+ }
}
onClicked: {
- if (root.__activateItemOnSingleClick)
- root.activated()
+ var clickIndex = listView.indexAt(0, mouseY + listView.contentY)
+ if (clickIndex > -1) {
+ if (root.__activateItemOnSingleClick)
+ root.activated(clickIndex)
+ root.clicked(clickIndex)
+ }
mouse.accepted = false
}
onPressed: {
+ var newIndex = listView.indexAt(0, mouseY + listView.contentY)
listView.forceActiveFocus()
- var x = Math.min(listView.contentWidth - 5, Math.max(mouseX + listView.contentX, 0))
- var y = Math.min(listView.contentHeight - 5, Math.max(mouseY + listView.contentY, 0))
- listView.currentIndex = listView.indexAt(x, y)
+ if (newIndex > -1) {
+ listView.currentIndex = newIndex
+ }
}
onDoubleClicked: {
- if (!root.__activateItemOnSingleClick)
- root.activated()
+ var clickIndex = listView.indexAt(0, mouseY + listView.contentY)
+ if (clickIndex > -1) {
+ if (!root.__activateItemOnSingleClick)
+ root.activated(clickIndex)
+ root.doubleClicked(clickIndex)
+ }
}
// Note: with boolean preventStealing we are keeping the flickable from
@@ -395,7 +511,7 @@ ScrollView {
// Fills extra rows with alternate color
Column {
id: rowfiller
- property int rowHeight: listView.contentHeight/count
+ property int rowHeight: count ? listView.contentHeight/count : height
property int paddedRowCount: height/rowHeight
property int count: listView.count
y: listView.contentHeight
@@ -408,21 +524,33 @@ ScrollView {
width: rowfiller.width
height: rowfiller.rowHeight
sourceComponent: root.rowDelegate
- readonly property bool alternateBackground: (index + rowCount) % 2 === 1
- readonly property bool rowSelected: false
+ property QtObject styleData: QtObject {
+ readonly property bool alternate: (index + rowCount) % 2 === 1
+ readonly property bool selected: false
+ readonly property bool hasActiveFocus: root.activeFocus
+ }
readonly property var model: listView.model
readonly property var modelData: null
- readonly property bool hasActiveFocus: root.activeFocus
}
}
}
- property list<TableViewColumn> columnheader
+ ListModel {
+ id: columnModel
+ }
+
highlightFollowsCurrentItem: true
model: root.model
- Keys.onUpPressed: root.__decrementCurrentIndex()
- Keys.onDownPressed: root.__incrementCurrentIndex()
+ Keys.onUpPressed: {
+ event.accepted = false
+ root.__decrementCurrentIndex()
+ }
+
+ Keys.onDownPressed: {
+ event.accepted = false
+ root.__incrementCurrentIndex()
+ }
Keys.onPressed: {
if (event.key === Qt.Key_PageUp) {
@@ -431,7 +559,11 @@ ScrollView {
verticalScrollBar.value = __verticalScrollBar.value + listView.height
}
- Keys.onReturnPressed: root.activated();
+ Keys.onReturnPressed: {
+ event.accepted = false
+ if (currentRow > -1)
+ root.activated(currentRow);
+ }
delegate: Item {
id: rowitem
@@ -439,7 +571,7 @@ ScrollView {
height: rowstyle.height
readonly property int rowIndex: model.index
- readonly property bool alternateBackground: alternatingRowColors && rowIndex % 2 == 1
+ readonly property bool alternate: alternatingRowColors && rowIndex % 2 == 1
readonly property var itemModelData: typeof modelData == "undefined" ? null : modelData
readonly property var itemModel: model
readonly property bool itemSelected: ListView.isCurrentItem
@@ -457,19 +589,21 @@ ScrollView {
// these properties are exposed to the row delegate
// Note: these properties should be mirrored in the row filler as well
- readonly property bool alternateBackground: rowitem.alternateBackground
- readonly property bool rowSelected: rowitem.itemSelected
- readonly property int row: rowitem.rowIndex
+ property QtObject styleData: QtObject {
+ readonly property int row: rowitem.rowIndex
+ readonly property bool alternate: rowitem.alternate
+ readonly property bool selected: rowitem.itemSelected
+ readonly property bool hasActiveFocus: root.activeFocus
+ }
readonly property var model: listView.model
readonly property var modelData: rowitem.itemModelData
- readonly property bool hasActiveFocus: root.activeFocus
}
Row {
id: itemrow
height: parent.height
Repeater {
id: repeater
- model: root.columnCount
+ model: columnModel
Loader {
id: itemDelegateLoader
@@ -482,20 +616,22 @@ ScrollView {
readonly property var model: listView.model
readonly property var modelData: itemModelData
- readonly property var itemValue: __hasModelRole ? itemModel[role] // Qml ListModel and QAbstractItemModel
- : __hasModelDataRole ? modelData[role] // QObjectList / QObject
- : modelData != undefined ? modelData : "" // Models without role
- readonly property bool itemSelected: rowitem.itemSelected
- readonly property color itemTextColor: rowitem.itemTextColor
- readonly property int row: rowitem.rowIndex
- readonly property int column: index
- readonly property int itemElideMode: __column.elideMode
- readonly property int itemTextAlignment: __column.horizontalAlignment
- readonly property string role: __column.role
-
- readonly property TableViewColumn __column: columns[index]
- readonly property bool __hasModelRole: role && itemModel.hasOwnProperty(role)
- readonly property bool __hasModelDataRole: role && modelData && modelData.hasOwnProperty(role)
+ property QtObject styleData: QtObject {
+ readonly property var value: __hasModelRole ? itemModel[role] // Qml ListModel and QAbstractItemModel
+ : __hasModelDataRole ? modelData[role] // QObjectList / QObject
+ : modelData != undefined ? modelData : "" // Models without role
+ readonly property int row: rowitem.rowIndex
+ readonly property int column: index
+ readonly property int elideMode: __column.elideMode
+ readonly property int textAlignment: __column.horizontalAlignment
+ readonly property bool selected: rowitem.itemSelected
+ readonly property color textColor: rowitem.itemTextColor
+ readonly property string role: __column.role
+ }
+
+ 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)
}
}
onWidthChanged: listView.contentWidth = width
@@ -513,7 +649,7 @@ ScrollView {
anchors.topMargin: viewport.anchors.topMargin
anchors.leftMargin: viewport.anchors.leftMargin
anchors.margins: viewport.anchors.margins
- anchors.rightMargin: __scroller.rightMargin +
+ anchors.rightMargin: (frameVisible ? __scroller.rightMargin : 0) +
(__scroller.outerFrame && __scrollBarTopMargin ? 0 : __verticalScrollBar.width
+ __scroller.scrollBarSpacing + root.__style.padding.right)
@@ -532,12 +668,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: columnCount == 1 ? viewport.width + __verticalScrollBar.width : modelData.width
+ visible: modelData.visible
height: headerVisible ? headerStyle.height : 0
Loader {
@@ -545,13 +681,12 @@ ScrollView {
sourceComponent: root.headerDelegate
anchors.left: parent.left
anchors.right: parent.right
- property string itemValue: columns[index].title
- property string itemSort: (sortIndicatorVisible && index == sortIndicatorColumn) ? (sortIndicatorOrder == Qt.AscendingOrder ? "up" : "down") : "";
- property bool itemPressed: headerClickArea.pressed
- property bool itemContainsMouse: headerClickArea.containsMouse
- property string itemPosition: columnCount === 1 ? "only" :
- index===columnCount-1 ? "end" :
- index===0 ? "beginning" : ""
+ property QtObject styleData: QtObject {
+ readonly property string value: modelData.title
+ readonly property bool pressed: headerClickArea.pressed
+ readonly property bool containsMouse: headerClickArea.containsMouse
+ readonly property int column: index
+ }
}
Rectangle{
id: targetmark
@@ -576,7 +711,7 @@ ScrollView {
// NOTE: the direction is different from the master branch
// so this indicates that I am using an invalid assumption on item ordering
onPositionChanged: {
- if (pressed) { // only do this while dragging
+ if (pressed && columnCount > 1) { // only do this while dragging
for (var h = columnCount-1 ; h >= 0 ; --h) {
if (drag.target.x > headerrow.children[h].x) {
repeater.targetIndex = h
@@ -593,13 +728,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
}
@@ -607,19 +736,20 @@ ScrollView {
}
drag.maximumX: 1000
drag.minimumX: -1000
- drag.target: draghandle
+ drag.target: columnCount > 1 ? draghandle : null
}
Loader {
id: draghandle
- property string itemValue: columns[index].title
- property string itemSort: (sortIndicatorVisible && index == sortIndicatorColumn) ? (sortIndicatorOrder == Qt.AscendingOrder ? "up" : "down") : "";
- property bool itemPressed: headerClickArea.pressed
- property bool itemContainsMouse: headerClickArea.containsMouse
- property string itemPosition
+ property QtObject styleData: QtObject{
+ 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
@@ -634,9 +764,10 @@ ScrollView {
anchors.rightMargin: -width/2
width: 16 ; height: parent.height
anchors.right: parent.right
+ enabled: columnCount > 1
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
@@ -651,21 +782,22 @@ 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
+ cursorShape: enabled ? Qt.SplitHCursor : Qt.ArrowCursor
}
}
}
}
Loader {
id: loader
- property string itemValue
- property string itemSort
- property bool itemPressed
- property bool itemContainsMouse
- property string itemPosition
+ property QtObject styleData: QtObject{
+ readonly property string value: ""
+ readonly property bool pressed: false
+ readonly property bool containsMouse: false
+ readonly property int column: -1
+ }
anchors.top: parent.top
anchors.right: parent.right
diff --git a/src/controls/TableViewColumn.qml b/src/controls/TableViewColumn.qml
index 919f30de..f1abc553 100644
--- a/src/controls/TableViewColumn.qml
+++ b/src/controls/TableViewColumn.qml
@@ -49,6 +49,10 @@ import QtQuick 2.1
*/
QtObject {
+
+ /*! \internal */
+ property Item __view: null
+
/*! The title text of the column. */
property string title
@@ -56,8 +60,10 @@ QtObject {
property string role
/*! The current width of the column
- The default value depends on platform. */
- property int width: 160
+ The default value depends on platform. If only one
+ column is defined, the width expands to the viewport.
+ */
+ property int width: (__view && __view.columnCount === 1) ? __view.viewport.width : 160
/*! The visible status of the column. */
property bool visible: true
@@ -89,4 +95,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
}
diff --git a/src/controls/TextArea.qml b/src/controls/TextArea.qml
index 6dab90fd..fd715a36 100644
--- a/src/controls/TextArea.qml
+++ b/src/controls/TextArea.qml
@@ -599,20 +599,19 @@ ScrollView {
edit.undo();
}
- /*!
- \qmlproperty color TextArea::backgroundColor
+ /*! \qmlproperty bool TextArea::backgroundVisible
- This property sets the background color of the viewport.
+ This property determines if the background should be filled or not.
- The default value is the base color of the SystemPalette.
+ The default value is \c true.
*/
- property alias backgroundColor: colorRect.color
+ property alias backgroundVisible: colorRect.visible
/*! \internal */
- property int __documentMargin: 4
+ default property alias data: area.data
- width: 280
- height: 120
+ /*! \internal */
+ property int __documentMargin: 4
frameVisible: true
@@ -621,9 +620,9 @@ ScrollView {
Accessible.role: Accessible.EditableText
/*!
- \qmlproperty textDocument TextArea::textDocument
+ \qmlproperty TextDocument TextArea::textDocument
- This property exposes the \l QTextDocument of this TextArea.
+ This property exposes the \l QQuickTextDocument of this TextArea.
\sa TextEdit::textDocument
*/
property alias textDocument: edit.textDocument
diff --git a/src/controls/TextField.qml b/src/controls/TextField.qml
index 903a6462..32b2d4fb 100644
--- a/src/controls/TextField.qml
+++ b/src/controls/TextField.qml
@@ -524,8 +524,11 @@ Control {
textInput.undo();
}
- /*! \internal */
- property alias __containsMouse: mouseArea.containsMouse
+ /*! \qmlproperty bool TextField::hovered
+
+ This property holds whether the control is being hovered.
+ */
+ readonly property alias hovered: mouseArea.containsMouse
/*! \internal */
property alias __contentHeight: textInput.contentHeight
diff --git a/src/controls/ToolBar.qml b/src/controls/ToolBar.qml
index d2adea56..b73a6f3e 100644
--- a/src/controls/ToolBar.qml
+++ b/src/controls/ToolBar.qml
@@ -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,72 @@ 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: container.leftMargin + container.rightMargin + container.calcWidth()
+ 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 calcWidth() { return (layoutItem ? (layoutItem.implicitWidth || layoutItem.width) +
+ (layoutItem.anchors.fill ? layoutItem.anchors.leftMargin +
+ layoutItem.anchors.rightMargin : 0) :
+ loader.item ? loader.item.implicitWidth : 0) }
+ function calcHeight () { return (layoutItem ? (layoutItem.implicitHeight || layoutItem.height) +
+ (layoutItem.anchors.fill ? layoutItem.anchors.topMargin +
+ layoutItem.anchors.bottomMargin : 0) :
+ loader.item ? loader.item.implicitHeight : 0) }
+ }]
}
diff --git a/src/controls/ToolButton.qml b/src/controls/ToolButton.qml
index d6607d28..3c1eab1a 100644
--- a/src/controls/ToolButton.qml
+++ b/src/controls/ToolButton.qml
@@ -46,7 +46,7 @@ import QtQuick.Controls.Private 1.0
\qmltype ToolButton
\inqmlmodule QtQuick.Controls 1.0
\since QtQtuick.Controls 1.0
- \ingroup applicationwindow
+ \ingroup controls
\brief Provides a button type that is typically used within a ToolBar.
ToolButton is functionally similar to \l Button, but can provide a look that is more
@@ -62,18 +62,6 @@ import QtQuick.Controls.Private 1.0
BasicButton {
id: button
- /*! The image label source as file name or resource. */
- property url iconSource
-
- /*! The image label source as theme name.
- When an icon from the platform icon theme is found, this takes
- precedence over iconSource.
- */
- property url iconName
-
- /*! The label text. */
- property string text
-
activeFocusOnTab: true
Accessible.name: text
diff --git a/src/controls/controls.pro b/src/controls/controls.pro
index 928708c2..fbda88fc 100644
--- a/src/controls/controls.pro
+++ b/src/controls/controls.pro
@@ -1,4 +1,4 @@
-TARGET = qtquickcontrols
+TARGET = qtquickcontrolsplugin
TARGETPATH = QtQuick/Controls
QT += qml quick gui-private core-private
diff --git a/src/controls/doc/images/qtquickcontrols-example-gallery.png b/src/controls/doc/images/qtquickcontrols-example-gallery.png
index d3b19bb5..a88eab79 100644
--- a/src/controls/doc/images/qtquickcontrols-example-gallery.png
+++ b/src/controls/doc/images/qtquickcontrols-example-gallery.png
Binary files differ
diff --git a/src/controls/doc/qtquickcontrols.qdocconf b/src/controls/doc/qtquickcontrols.qdocconf
index c04bced2..44fd86ca 100644
--- a/src/controls/doc/qtquickcontrols.qdocconf
+++ b/src/controls/doc/qtquickcontrols.qdocconf
@@ -14,22 +14,17 @@ qhp.QtQuickControls.indexTitle = Qt Quick Controls
qhp.QtQuickControls.indexRoot =
#qhp.QtQuickControls.extraFiles = style/qtquickcontrols.css
-qhp.QtQuickControls.filterAttributes = qtcontrols $QT_VERSION qtrefdoc
+qhp.QtQuickControls.filterAttributes = qtquickcontrols $QT_VERSION qtrefdoc
qhp.QtQuickControls.customFilters.Qt.name = QtQuickControls $QT_VERSION
qhp.QtQuickControls.customFilters.Qt.filterAttributes = qtquickcontrols $QT_VERSION
-qhp.QtQuickControls.subprojects = qtquickcontrolsqmltypes styleqmltypes
+qhp.QtQuickControls.subprojects = qtquickcontrolsqmltypes
qhp.QtQuickControls.subprojects.qtquickcontrolsqmltypes.title = QML Types
qhp.QtQuickControls.subprojects.qtquickcontrolsqmltypes.indexTitle = Qt Quick Controls QML Types
qhp.QtQuickControls.subprojects.qtquickcontrolsqmltypes.selectors = class fake:qmlclass
qhp.QtQuickControls.subprojects.qtquickcontrolsqmltypes.sortPages = true
-qhp.QtQuickControls.subprojects.styleqmltypes.title = Styles QML Types
-qhp.QtQuickControls.subprojects.styleqmltypes.indexTitle = Qt Quick Controls Styles QML Types
-qhp.QtQuickControls.subprojects.styleqmltypes.selectors = class fake:qmlclass
-qhp.QtQuickControls.subprojects.styleqmltypes.sortPages = true
-
-depends = qtqml qtquick qtwidgets qtdoc qtquicklayouts
+depends = qtqml qtquick qtwidgets qtdoc qtquicklayouts qtquickcontrolsstyles
exampledirs += ../../../examples/quick/controls
@@ -37,22 +32,15 @@ exampledirs += ../../../examples/quick/controls
examplesinstallpath = quick/controls
headerdirs += ../
-headerdirs += ../ ../../styles/Base
sourcedirs += ../
-sourcedirs += ../ ../../styles/Base
-sources += ../../private/qstyleitem.cpp \
- ../../private/AbstractCheckable.qml \
+sources += ../../private/AbstractCheckable.qml \
../../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
imagedirs += images
diff --git a/src/controls/doc/src/qtquickcontrols-index.qdoc b/src/controls/doc/src/qtquickcontrols-index.qdoc
index 011de527..96f2a670 100644
--- a/src/controls/doc/src/qtquickcontrols-index.qdoc
+++ b/src/controls/doc/src/qtquickcontrols-index.qdoc
@@ -29,25 +29,14 @@
\page qtquickcontrols-index.html
\title Qt Quick Controls
- \brief The Qt Quick Controls module provides a set of reusable Qt Quick UI components.
+ \brief The Qt Quick Controls module provides a set of UI controls for Qt Quick.
- The Qt Quick Controls module provides a set of reusable UI components to create
- classic desktop-style user interfaces using Qt Quick.
+ The Qt Quick Controls module provides a set of controls that can be used to
+ build complete interfaces in Qt Quick.
The module is new in Qt 5.1 and requires \l{Qt Quick} 2.1.
- \note \l{Qt Quick Layouts} can be used to arrange Qt Quick Controls in a user interface.
-
- \note The current focus is on desktop, but in the long term Qt Quick Controls
- are expected to be supported on mobile platforms too.
-
- \section1 Getting started
-
- The QML types can be imported into your application using the following import statement in your \c {.qml} file.
-
- \code
- import QtQuick.Controls 1.0
- \endcode
+ Visit the \l{Qt Quick Controls Overview} page to get started.
\section1 Application Window
Components used to describe the basic window properties of an application.
@@ -67,21 +56,12 @@
\section1 Related information
- \section2 Guides
\list
+ \li \l{Qt Quick}
\li \l{Qt Quick Controls Overview}
- \endlist
-
- \section2 Reference
- \list
\li \l{Qt Quick Controls QML Types}{Qt Quick Controls QML Types}
- \endlist
-
- \section2 Examples
- \list
\li \l{Qt Quick Controls Examples}
+ \li \l{Qt Quick Controls Styles}
+ \li \l{Qt Quick Layouts}
\endlist
-
- \l {Qt Quick Controls Styles QML Types}
-
*/
diff --git a/src/controls/doc/src/qtquickcontrols-overview.qdoc b/src/controls/doc/src/qtquickcontrols-overview.qdoc
index 82da0b22..4eb6892f 100644
--- a/src/controls/doc/src/qtquickcontrols-overview.qdoc
+++ b/src/controls/doc/src/qtquickcontrols-overview.qdoc
@@ -28,5 +28,82 @@
/*!
\page qtquickcontrols-overview.html
\title Qt Quick Controls Overview
- \brief A set of APIs for working with ...
+ \brief A set of UI controls to create user interfaces in Qt Quick
+
+ The Qt Quick Controls provide a set of UI controls to create user interfaces
+ in Qt Quick.
+
+ \section1 Getting Started
+
+ The QML types can be imported into your application using the following import statement in your \c {.qml} file.
+
+ \code
+ import QtQuick.Controls 1.0
+ \endcode
+
+ \section1 Creating a basic example
+
+ A basic example of a QML file that makes use of controls is shown here:
+
+ \code
+ import QtQuick.Controls 1.0
+
+ ApplicationWindow {
+ title: "My Application"
+
+ Button {
+ text: "Push Me"
+ anchors.centerIn: parent
+ }
+ }
+ \endcode
+
+ For an overview of the controls provided by \l{Qt Quick Controls}, you can look at
+ the \l{Qt Quick Controls - Gallery}{Gallery} example.
+
+ \image qtquickcontrols-example-gallery.png
+
+ \section1 Setting Up Controls from C++
+
+ Although we have traditionally used a QQuickView window to display QML files
+ in a C++ application, doing this means you can only set window properties from C++.
+
+ With Qt Quick Controls, declare an ApplicationWindow as the root item of your application and launch it by using the
+ QQmlApplicationEngine instead. This ensures that you can control top level window properties from QML.
+
+ A basic example of a source file that makes use of controls is shown here:
+
+ \code
+ #include <QApplication>
+ #include <QQmlApplicationEngine>
+
+ int main(int argc, char *argv[])
+ {
+ QApplication app(argc, argv);
+ QQmlApplicationEngine engine("main.qml");
+ return app.exec();
+ }
+ \endcode
+
+ \note We are using QApplication and not QGuiApplication in this example.
+ Though you can use QGuiApplication instead, doing this will eliminate platform-dependent styling.
+ This is because it is relying on the widget module to provide the native look and feel.
+
+ \section2 Using C++ Data From QML
+
+ If you need to register a C++ class to use from QML, you can call, for example,
+ qmlRegisterType() before declaring your QQmlApplicationEngine. You can find the list
+ of all registering functions \l{QQmlEngine}{here}.
+
+ If you need to expose data to QML components, you need to set them
+ to the context of the current QML engine. See QQmlContext for more
+ information.
+
+ \section1 Related information
+
+ \list
+ \li \l{Qt Quick}
+ \li \l{Qt Quick Controls}
+ \li \l{Qt Quick Controls Examples}
+ \endlist
*/
diff --git a/src/controls/plugins.qmltypes b/src/controls/plugins.qmltypes
index 89363578..bd8508da 100644
--- a/src/controls/plugins.qmltypes
+++ b/src/controls/plugins.qmltypes
@@ -3,7 +3,7 @@ import QtQuick.tooling 1.1
// This file describes the plugin-supplied types contained in the library.
// It is used for QML tooling purposes only.
//
-// This file was auto-generated with the command '/home/jpnurmi/Projects/qt5-stable/qtbase/bin/qmlplugindump -notrelocatable QtQuick.Controls 1.0'.
+// This file was auto-generated with the command 'qmlplugindump -notrelocatable QtQuick.Controls 1.0'.
Module {
Component {
@@ -67,6 +67,8 @@ Module {
Property { name: "__contentItem"; type: "QQuickItem"; isPointer: true }
Property { name: "__minimumWidth"; type: "int" }
Property { name: "__font"; type: "QFont" }
+ Property { name: "__xOffset"; type: "double" }
+ Property { name: "__yOffset"; type: "double" }
Signal { name: "__menuClosed" }
Signal { name: "popupVisibleChanged" }
Method { name: "__closeMenu" }
@@ -197,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 }
}
}
diff --git a/src/controls/qmldir b/src/controls/qmldir
index f593439f..c243360c 100644
--- a/src/controls/qmldir
+++ b/src/controls/qmldir
@@ -1,5 +1,5 @@
module QtQuick.Controls
-plugin qtquickcontrols
+plugin qtquickcontrolsplugin
ApplicationWindow 1.0 ApplicationWindow.qml
Button 1.0 Button.qml
CheckBox 1.0 CheckBox.qml
diff --git a/src/controls/qquickaction.cpp b/src/controls/qquickaction.cpp
index a597515f..e240d111 100644
--- a/src/controls/qquickaction.cpp
+++ b/src/controls/qquickaction.cpp
@@ -123,7 +123,7 @@ QT_BEGIN_NAMESPACE
Whether the action is enabled, and can be triggered. Defaults to \c true.
- \sa tigger(), triggered()
+ \sa trigger(), triggered
*/
/*!
@@ -140,7 +140,7 @@ QT_BEGIN_NAMESPACE
If the action is \l checkable, this property reflects its checked state. Defaults to \c false.
Its value is also false while \l checkable is false.
- \sa toggled(), exclusiveGroup
+ \sa toggled, exclusiveGroup
*/
/*!
@@ -169,14 +169,14 @@ QT_BEGIN_NAMESPACE
/*! \qmlmethod Action::trigger()
- Will emit the \l triggered() signal if the action is enabled. Will also emit the
- \l toggled() signal if it is checkable.
+ Will emit the \l triggered signal if the action is enabled. Will also emit the
+ \l toggled signal if it is checkable.
*/
/*! \qmlsignal Action::toggled(checked)
Emitted whenever a action's \l checked property changes.
- This usually happens at the same time as \l triggered().
+ This usually happens at the same time as \l triggered.
*/
QQuickAction::QQuickAction(QObject *parent)
diff --git a/src/controls/qquickaction_p.h b/src/controls/qquickaction_p.h
index e106a920..aa63b408 100644
--- a/src/controls/qquickaction_p.h
+++ b/src/controls/qquickaction_p.h
@@ -57,11 +57,11 @@ class QQuickAction : public QObject
{
Q_OBJECT
- Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
- Q_PROPERTY(QUrl iconSource READ iconSource WRITE setIconSource NOTIFY iconSourceChanged)
+ Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged RESET resetText)
+ Q_PROPERTY(QUrl iconSource READ iconSource WRITE setIconSource NOTIFY iconSourceChanged RESET resetIconSource)
Q_PROPERTY(QString iconName READ iconName WRITE setIconName NOTIFY iconNameChanged)
Q_PROPERTY(QVariant __icon READ iconVariant NOTIFY iconChanged)
- Q_PROPERTY(QString tooltip READ tooltip WRITE setTooltip NOTIFY tooltipChanged)
+ Q_PROPERTY(QString tooltip READ tooltip WRITE setTooltip NOTIFY tooltipChanged RESET resetTooltip)
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged)
Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE isCheckable NOTIFY toggled)
@@ -76,6 +76,7 @@ public:
~QQuickAction();
QString text() const { return m_text; }
+ void resetText() { setText(QString()); }
void setText(const QString &text);
QString shortcut() const;
@@ -87,9 +88,11 @@ public:
void setIconName(const QString &iconName);
QUrl iconSource() const { return m_iconSource; }
+ void resetIconSource() { setIconSource(QString()); }
void setIconSource(const QUrl &iconSource);
QString tooltip() const { return m_tooltip; }
+ void resetTooltip() { setTooltip(QString()); }
void setTooltip(const QString &tooltip);
bool isEnabled() const { return m_enabled; }
diff --git a/src/controls/qquickexclusivegroup.cpp b/src/controls/qquickexclusivegroup.cpp
index eecff416..f1b6935e 100644
--- a/src/controls/qquickexclusivegroup.cpp
+++ b/src/controls/qquickexclusivegroup.cpp
@@ -97,9 +97,9 @@ static bool isChecked(const QObject *o)
}
\endcode
- Several controls already support \l ExclusiveGroup, e.g. \l Action, \l MenuItem, \l Button, and \l RadioButton.
+ Several controls already support ExclusiveGroup, e.g. \l Action, \l MenuItem, \l Button, and \l RadioButton.
- Since \l ExclusiveGroup only supports \l Action as child items, we need to manually assign the \c exclusiveGroup
+ Since ExclusiveGroup only supports \l Action as child items, we need to manually assign the \c exclusiveGroup
property for other objects.
\code
@@ -131,9 +131,9 @@ static bool isChecked(const QObject *o)
\section1 Adding support to ExclusiveGroup
- It is possible to add support for \l ExclusiveGroup for an object, or control. It should have a \c checked
+ It is possible to add support for ExclusiveGroup for an object, or control. It should have a \c checked
property, and either a \c checkedChanged, \c toggled(), or \c toggled(bool) signal. It also needs
- to be bound with \l ExclusiveGroup::bindCheckable(object) when its \l ExclusiveGroup ty[ped property is set.
+ to be bound with \l ExclusiveGroup::bindCheckable() when its ExclusiveGroup ty[ped property is set.
\code
Item {
@@ -149,13 +149,13 @@ static bool isChecked(const QObject *o)
}
\endcode
- The example above shows the minimum necessary to add \l ExclusiveGroup support to any item.
+ The example above shows the minimum necessary to add ExclusiveGroup support to any item.
*/
/*!
\qmlproperty object ExclusiveGroup::current
- The currently selected object. Defaults to the first checked object bound to the \l ExclusiveGroup.
+ The currently selected object. Defaults to the first checked object bound to the ExclusiveGroup.
If there is none, then it defaults to \c null.
*/
@@ -166,7 +166,7 @@ static bool isChecked(const QObject *o)
You should only need to call this function when creating a component you want to be compatible with \c ExclusiveGroup.
- \sa ExclusiveGroup::unbindCheckable(object)
+ \sa ExclusiveGroup::unbindCheckable()
*/
/*!
@@ -176,7 +176,7 @@ static bool isChecked(const QObject *o)
You should only need to call this function when creating a component you want to be compatible with \c ExclusiveGroup.
- \sa ExclusiveGroup::bindCheckable(object)
+ \sa ExclusiveGroup::bindCheckable()
*/
QQuickExclusiveGroup::QQuickExclusiveGroup(QObject *parent)
diff --git a/src/controls/qquickmenu.cpp b/src/controls/qquickmenu.cpp
index efc49cd6..bb0ddae9 100644
--- a/src/controls/qquickmenu.cpp
+++ b/src/controls/qquickmenu.cpp
@@ -100,7 +100,7 @@ QT_BEGIN_NAMESPACE
\endcode
Note that in this case, the \c index parameter passed to \l insertItem() is relative
- to the position of the \l Instatiator in the menu, as opposed to absolute position
+ to the position of the \l Instantiator in the menu, as opposed to absolute position
in the menu.
\sa MenuItem, MenuSeparator
@@ -170,7 +170,7 @@ QT_BEGIN_NAMESPACE
Adds an item to the menu. Returns the newly created \l MenuItem.
- \sa insertItem(int before, string title)
+ \sa insertItem()
*/
/*!
diff --git a/src/controls/qquickmenuitem.cpp b/src/controls/qquickmenuitem.cpp
index 4ac7c7ff..ed03b336 100644
--- a/src/controls/qquickmenuitem.cpp
+++ b/src/controls/qquickmenuitem.cpp
@@ -329,14 +329,14 @@ void QQuickMenuText::updateIcon()
Emitted when either the menu item or its bound action have been activated.
- \sa trigger(), Action::triggered(), Action::toggled()
+ \sa trigger(), Action::triggered, Action::toggled
*/
/*! \qmlmethod MenuItem::trigger()
Manually trigger a menu item. Will also trigger the item's bound action.
- \sa triggered(), Action::trigger()
+ \sa triggered, Action::trigger()
*/
/*!
@@ -360,7 +360,7 @@ void QQuickMenuText::updateIcon()
If the menu item is checkable, this property reflects its checked state. Defaults to \c false.
- \sa checkable, Action::toggled()
+ \sa checkable, Action::toggled
*/
/*! \qmlproperty ExclusiveGroup MenuItem::exclusiveGroup
@@ -378,9 +378,9 @@ void QQuickMenuText::updateIcon()
/*! \qmlsignal MenuItem::toggled(checked)
Emitted whenever a menu item's \c checked property changes.
- This usually happens at the same time as \l triggered().
+ This usually happens at the same time as \l triggered.
- \sa checked, triggered(), Action::triggered(), Action::toggled()
+ \sa checked, triggered, Action::triggered, Action::toggled
*/
/*!
@@ -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())
@@ -502,7 +503,7 @@ void QQuickMenuItem::setBoundAction(QQuickAction *a)
QString QQuickMenuItem::text() const
{
QString ownText = QQuickMenuText::text();
- if (!ownText.isEmpty())
+ if (!ownText.isNull())
return ownText;
return m_boundAction ? m_boundAction->text() : QString();
}
diff --git a/src/controls/qquickstack.cpp b/src/controls/qquickstack.cpp
index 1723ef72..c949ffeb 100644
--- a/src/controls/qquickstack.cpp
+++ b/src/controls/qquickstack.cpp
@@ -47,15 +47,11 @@ QT_BEGIN_NAMESPACE
\qmltype Stack
\instantiates QQuickStack
\inqmlmodule QtQuick.Controls 1.0
- \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 +60,7 @@ QQuickStack::QQuickStack(QObject *object)
: QObject(object),
m_index(-1),
m_status(Inactive),
- m_pageStack(0)
+ m_view(0)
{
}
@@ -75,11 +71,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 +92,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 +117,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();
}
}
diff --git a/src/controls/qquickstack_p.h b/src/controls/qquickstack_p.h
index a4b36644..c34dd1a3 100644
--- a/src/controls/qquickstack_p.h
+++ b/src/controls/qquickstack_p.h
@@ -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
diff --git a/src/layouts/doc/images/rowlayout-minimum.png b/src/layouts/doc/images/rowlayout-minimum.png
new file mode 100644
index 00000000..5875325c
--- /dev/null
+++ b/src/layouts/doc/images/rowlayout-minimum.png
Binary files differ
diff --git a/src/layouts/doc/qtquicklayouts.qdocconf b/src/layouts/doc/qtquicklayouts.qdocconf
index b5649044..85cb0a57 100644
--- a/src/layouts/doc/qtquicklayouts.qdocconf
+++ b/src/layouts/doc/qtquicklayouts.qdocconf
@@ -5,31 +5,30 @@ 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 QML Types
+qhp.QtQuickLayouts.subprojects.qtquicklayoutsqmltypes.selectors = class fake:qmlclass
+qhp.QtQuickLayouts.subprojects.qtquicklayoutsqmltypes.sortPages = true
depends = qtqml qtquick qtwidgets qtdoc qtquickcontrols
-exampledirs += ../../../examples/quick/controls/
+exampledirs += src/snippets
-headerdirs += ../
+headerdirs += ..
-sourcedirs += ../
+sourcedirs += ..
imagedirs += images
diff --git a/src/layouts/doc/src/qtquicklayouts-index.qdoc b/src/layouts/doc/src/qtquicklayouts-index.qdoc
index 433de433..58d7fb8c 100644
--- a/src/layouts/doc/src/qtquicklayouts-index.qdoc
+++ b/src/layouts/doc/src/qtquicklayouts-index.qdoc
@@ -28,23 +28,29 @@
/*!
\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.
- \section1 Getting started
+ 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 QML types can be imported into your application using the following import statement in your \c {.qml} file.
+ The module is new in Qt 5.1 and requires \l{Qt Quick} 2.1.
- \code
- import QtQuick.Layouts 1.0
- \endcode
+ Visit the \l{Qt Quick Layouts Overview} page to get started.
\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
+
+ \list
+ \li \l{Qt Quick}
+ \li \l{Qt Quick Controls}
+ \li \l{Qt Quick Layouts Overview}
+ \li \l{Qt Quick Controls - Basic Layouts Example}
+ \li \l{Qt Quick Layouts QML Types}{Qt Quick Layouts QML Types}
+ \endlist
*/
diff --git a/src/layouts/doc/src/qtquicklayouts-overview.qdoc b/src/layouts/doc/src/qtquicklayouts-overview.qdoc
new file mode 100644
index 00000000..3eeb98d2
--- /dev/null
+++ b/src/layouts/doc/src/qtquicklayouts-overview.qdoc
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 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$
+**
+****************************************************************************/
+
+/*!
+ \page qtquicklayouts-overview.html
+ \title Qt Quick Layouts Overview
+ \brief A set of APIs for arranging QML items in a user interface.
+
+ Qt Quick Layouts are items that are used to arrange items in a user interface. Since Qt Quick
+ Layouts also resize their items, they are well suited for resizable user interfaces.
+
+ \section1 Getting started
+
+ The QML types can be imported into your application using the following import statement in your \c {.qml} file.
+
+ \code
+ import QtQuick.Layouts 1.0
+ \endcode
+
+ \section1 Key Features
+
+
+ Some of the key features are:
+
+ \list
+ \li \l{Layout::alignment}{Alignment} of items can be specified with the
+ \l{Layout::alignment}{Layout.alignment} property
+ \li \l{Layout::fillWidth}{Resizable items} can be specified with the
+ \l{Layout::fillWidth}{Layout.fillWidth} and \l{Layout::fillHeight}{Layout.fillHeight}
+ properties.
+ \li \l{Size constraints} can be specified with
+ \l{Layout::minimumWidth}{Layout.minimumWidth},
+ \l{Layout::preferredWidth}{Layout.preferredWidth}, and
+ \l{Layout::maximumWidth}{Layout.maximumWidth} properties ("Width" can be replaced
+ with "Height" for specifying similar constraints to the height).
+ \li \l{RowLayout::spacing}{Spacings} can be specified with \l{RowLayout::spacing}{spacing},
+ \l{GridLayout::rowSpacing}{rowSpacing} or \l{GridLayout::columnSpacing}{columnSpacing}
+ \endlist
+
+ In addition to the above features, GridLayout adds these features:
+ \list
+ \li \l{Layout::row}{Grid coordinates} can be specified with the \l{Layout::row}{Layout.row} and
+ \l{Layout::column}{Layout.column}.
+ \li \l{GridLayout::flow}{Automatic grid coordinates} used together with the
+ \l{GridLayout::flow}{flow}, \l{GridLayout::rows}{rows}, and
+ \l{GridLayout::columns}{columns} properties.
+ \li \l{Layout::columnSpan}{Spans} across rows or columns can be specified with the
+ \l{Layout::rowSpan}{Layout.rowSpan} and \l{Layout::columnSpan}{Layout.columnSpan}
+ properties.
+ \endlist
+
+
+
+ \section1 Size Constraints
+ Since an item can be resized by its layout, the layout needs to know the
+ \l{Layout::minimumWidth}{minimum}, \l{Layout::preferredWidth}{preferred},
+ and \l{Layout::maximumWidth}{maximum} sizes of all items where \l{Layout::fillWidth}{Layout.fillWidth} or
+ \l{Layout::fillHeight}{Layout.fillHeight} is set to \c true.
+ For instance, the following will produce a layout with two rectangles lying side-by-side that
+ stretches horizontally. The azure rectangle can be resized from 50x150 to 300x150, and the plum
+ rectangle can be resized from 100x100 to ∞x100.
+
+ \snippet windowconstraints.qml rowlayout
+
+ \image rowlayout-minimum.png "RowLayout at its minimum"
+
+ Combining each item's constraints will give these implicit constraints to the layout element:
+
+ \table
+ \header
+ \li
+ \li minimum
+ \li preferred
+ \li maximum
+ \row
+ \li implicit constraints (width)
+ \li 156
+ \li 306
+ \li ∞ (\c Number.POSITIVE_INFINITY)
+ \row
+ \li implicit constraints (heights)
+ \li 150
+ \li 150
+ \li 150
+ \endtable
+
+ Thus, the layout cannot be narrower than 156 or be taller or shorter than 150 without breaking
+ any of the constraints of its child items.
+
+ \section1 Connecting windows and layouts
+ You can just use normal anchoring concepts to ensure that the layout will follow the window
+ resizing.
+
+ \snippet windowconstraints.qml anchoring
+
+ The size constraints of layouts can be used to ensure that the window cannot be resized beyond
+ the layout constraints. You can take the size constraints from the layout and set these
+ constraints on the minimumWidth, minimumHeight, maximumWidth, and maximumHeight of the Window
+ element. The following code ensures that the window cannot be resized beyond the constraints of
+ the layout:
+
+ \snippet windowconstraints.qml bindconstraints
+
+ \note Since layout.Layout.maximumWidth is infinite in this case, we cannot bind that to the
+ maximumWidth property of Window, since that is an integer number. We therefore set a fixed
+ maximum width to 1000.
+
+ Finally, you usually want the initial size of the window to be the layout's implicit size:
+
+ \snippet windowconstraints.qml binddefaultsize
+*/
diff --git a/src/controls/doc/src/styles.qdoc b/src/layouts/doc/src/qtquicklayouts.qdoc
index 40809414..b03ff69b 100644
--- a/src/controls/doc/src/styles.qdoc
+++ b/src/layouts/doc/src/qtquicklayouts.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** 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.
@@ -26,16 +26,21 @@
****************************************************************************/
/*!
- \qmlmodule QtQuick.Controls.Styles 1
- \title Qt Quick Controls Styles QML Types
+ \qmlmodule QtQuick.Layouts 1
+ \title Qt Quick Layouts QML Types
\ingroup qmlmodules
- \brief Provides QML types for Qt Quick Controls styles.
+ \brief Provides QML types for arranging QML items in a user interface.
- The \l{Qt Quick Controls} module provides a set of QML types for handling
- styles.
+ 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}.
- Some of the controls allow custom styling similar to widget style sheets.
- A styling object is usually a collection of properties that control behavior and simple delegates
- that can be replaced with custom QML snippets.
+ 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
*/
diff --git a/src/layouts/doc/src/snippets/windowconstraints.qml b/src/layouts/doc/src/snippets/windowconstraints.qml
new file mode 100644
index 00000000..673169a3
--- /dev/null
+++ b/src/layouts/doc/src/snippets/windowconstraints.qml
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** 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:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Controls 1.0
+import QtQuick.Layouts 1.0
+
+ApplicationWindow {
+ //! [binddefaultsize]
+ width: layout.implicitWidth
+ height: layout.implicitHeight
+ //! [binddefaultsize]
+ //! [bindconstraints]
+ minimumWidth: layout.Layout.minimumWidth
+ minimumHeight: layout.Layout.minimumHeight
+ maximumWidth: 1000
+ maximumHeight: layout.Layout.maximumHeight
+ //! [bindconstraints]
+
+ //! [rowlayout]
+ //! [anchoring]
+ RowLayout {
+ id: layout
+ anchors.fill: parent
+ //! [anchoring]
+ spacing: 6
+ Rectangle {
+ color: 'azure'
+ Layout.fillWidth: true
+ Layout.minimumWidth: 50
+ Layout.preferredWidth: 100
+ Layout.maximumWidth: 300
+ Layout.minimumHeight: 150
+ Text {
+ anchors.centerIn: parent
+ text: parent.width + 'x' + parent.height
+ }
+ }
+ Rectangle {
+ color: 'plum'
+ Layout.fillWidth: true
+ Layout.minimumWidth: 100
+ Layout.preferredWidth: 200
+ Layout.preferredHeight: 100
+ Text {
+ anchors.centerIn: parent
+ text: parent.width + 'x' + parent.height
+ }
+ }
+ }
+ //! [rowlayout]
+}
diff --git a/src/layouts/plugins.qmltypes b/src/layouts/plugins.qmltypes
index c3f1c77c..a0744951 100644
--- a/src/layouts/plugins.qmltypes
+++ b/src/layouts/plugins.qmltypes
@@ -3,7 +3,7 @@ import QtQuick.tooling 1.1
// This file describes the plugin-supplied types contained in the library.
// It is used for QML tooling purposes only.
//
-// This file was auto-generated with the command '/Users/thohartm/dev/qt5/qtbase/bin/qmlplugindump.app/Contents/MacOS/qmlplugindump QtQuick.Layouts 1.0 -notrelocatable'.
+// This file was auto-generated with the command 'qmlplugindump QtQuick.Layouts 1.0 -notrelocatable'.
Module {
Component {
@@ -11,12 +11,14 @@ Module {
defaultProperty: "data"
prototype: "QQuickLinearLayout"
exports: ["QtQuick.Layouts/ColumnLayout 1.0"]
+ exportMetaObjectRevisions: [0]
}
Component {
name: "QQuickGridLayout"
defaultProperty: "data"
prototype: "QQuickGridLayoutBase"
exports: ["QtQuick.Layouts/GridLayout 1.0"]
+ exportMetaObjectRevisions: [0]
Enum {
name: "Flow"
values: {
@@ -36,6 +38,7 @@ Module {
defaultProperty: "data"
prototype: "QQuickItem"
exports: ["QtQuick.Layouts/Layout 1.0"]
+ exportMetaObjectRevisions: [0]
attachedType: "QQuickLayoutAttached"
}
Component {
@@ -66,5 +69,6 @@ Module {
defaultProperty: "data"
prototype: "QQuickLinearLayout"
exports: ["QtQuick.Layouts/RowLayout 1.0"]
+ exportMetaObjectRevisions: [0]
}
}
diff --git a/src/layouts/qquickgridlayoutengine.cpp b/src/layouts/qquickgridlayoutengine.cpp
index bacfd965..7f65d0d5 100644
--- a/src/layouts/qquickgridlayoutengine.cpp
+++ b/src/layouts/qquickgridlayoutengine.cpp
@@ -98,14 +98,62 @@ static inline void combineHints(qreal &current, qreal fallbackHint)
current = fallbackHint;
}
+static inline void combineSize(QSizeF &result, const QSizeF &fallbackSize)
+{
+ combineHints(result.rwidth(), fallbackSize.width());
+ combineHints(result.rheight(), fallbackSize.height());
+}
+
+static inline void combineImplicitHints(QQuickLayoutAttached *info, Qt::SizeHint which, QSizeF *size)
+{
+ if (!info) return;
+
+ Q_ASSERT(which == Qt::MinimumSize || which == Qt::MaximumSize);
+
+ const QSizeF constraint(which == Qt::MinimumSize
+ ? QSizeF(info->minimumWidth(), info->minimumHeight())
+ : QSizeF(info->maximumWidth(), info->maximumHeight()));
+
+ if (!info->isExtentExplicitlySet(Qt::Horizontal, which))
+ combineHints(size->rwidth(), constraint.width());
+ if (!info->isExtentExplicitlySet(Qt::Vertical, which))
+ combineHints(size->rheight(), constraint.height());
+}
+
/*!
\internal
Note: Can potentially return the attached QQuickLayoutAttached object through \a attachedInfo.
It is like this is because it enables it to be reused.
+
+ The goal of this function is to return the effective minimum, preferred and maximum size hints
+ that the layout will use for this item.
+ This function takes care of gathering all explicitly set size hints, normalizes them so
+ that min < pref < max.
+ Further, the hints _not_explicitly_ set will then be initialized with the implicit size hints,
+ which is usually derived from the content of the layouts (or items).
+
+ The following table illustrates the preference of the properties used for measuring layout
+ items. If present, the USER properties will be preferred. If USER properties are not present,
+ the HINT properties will be preferred. Finally, the FALLBACK properties will be used as an
+ ultimate fallback.
+
+ Note that one can query if the value of Layout.minimumWidth or Layout.maximumWidth has been
+ explicitly or implicitly set with QQuickLayoutAttached::isExtentExplicitlySet(). This
+ determines if it should be used as a USER or as a HINT value.
+
+
+ | *Minimum* | *Preferred* | *Maximum* |
++----------------+----------------------+-----------------------+--------------------------+
+|USER (explicit) | Layout.minimumWidth | Layout.preferredWidth | Layout.maximumWidth |
+|HINT (implicit) | Layout.minimumWidth | implicitWidth | Layout.maximumWidth |
+|FALLBACK | 0 | width | Number.POSITIVE_INFINITY |
++----------------+----------------------+-----------------------+--------------------------+
*/
void QQuickGridLayoutItem::effectiveSizeHints_helper(QQuickItem *item, QSizeF *cachedSizeHints, QQuickLayoutAttached **attachedInfo, bool useFallbackToWidthOrHeight)
{
+ for (int i = 0; i < Qt::NSizeHints; ++i)
+ cachedSizeHints[i] = QSizeF();
QQuickLayoutAttached *info = attachedLayoutObject(item, false);
// First, retrieve the user-specified hints from the attached "Layout." properties
if (info) {
@@ -123,16 +171,16 @@ void QQuickGridLayoutItem::effectiveSizeHints_helper(QQuickItem *item, QSizeF *c
for (int i = 0; i < NSizes; ++i) {
SizeGetter getter = horGetters.call[i];
Q_ASSERT(getter);
- cachedSizeHints[i].setWidth((info->*getter)());
+
+ if (info->isExtentExplicitlySet(Qt::Horizontal, (Qt::SizeHint)i))
+ cachedSizeHints[i].setWidth((info->*getter)());
+
getter = verGetters.call[i];
Q_ASSERT(getter);
- cachedSizeHints[i].setHeight((info->*getter)());
+ if (info->isExtentExplicitlySet(Qt::Vertical, (Qt::SizeHint)i))
+ cachedSizeHints[i].setHeight((info->*getter)());
}
- } else {
- for (int i = 0; i < NSizes; ++i)
- cachedSizeHints[i] = QSize();
}
- cachedSizeHints[Qt::MinimumDescent] = QSize(); //### FIXME when baseline support is added
QSizeF &minS = cachedSizeHints[Qt::MinimumSize];
QSizeF &prefS = cachedSizeHints[Qt::PreferredSize];
@@ -144,23 +192,21 @@ void QQuickGridLayoutItem::effectiveSizeHints_helper(QQuickItem *item, QSizeF *c
// to: [10, 10, 60]
normalizeHints(minS.rwidth(), prefS.rwidth(), maxS.rwidth(), descentS.rwidth());
normalizeHints(minS.rheight(), prefS.rheight(), maxS.rheight(), descentS.rheight());
-/*
- The following table illustrates the preference of the properties used for measuring layout
- items. If present, the USER properties will be preferred. If USER properties are not present,
- the HINT 1 properties will be preferred. Finally, the HINT 2 properties will be used as an
- ultimate fallback.
-
- | USER | HINT 1 | HINT 2
- -----+--------------------------------+-------------------+-------
- MIN | Layout.minimumWidth | | 0
- PREF | Layout.preferredWidth | implicitWidth | width
- MAX | Layout.maximumWidth | | 1000000000 (-1)
- -----+--------------------------------+-------------------+--------
-Fixed | Layout.fillWidth | Expanding if layout, Fixed if item |
-
-*/
+
+ // All explicit values gathered, now continue to gather the implicit sizes
+
+ //--- GATHER MAXIMUM SIZE HINTS ---
+ combineImplicitHints(info, Qt::MaximumSize, &maxS);
+ combineSize(maxS, QSizeF(std::numeric_limits<qreal>::infinity(), std::numeric_limits<qreal>::infinity()));
+ // implicit max or min sizes should not limit an explicitly set preferred size
+ expandSize(maxS, prefS);
+ expandSize(maxS, minS);
+
//--- GATHER MINIMUM SIZE HINTS ---
- // They are always 0
+ combineImplicitHints(info, Qt::MinimumSize, &minS);
+ expandSize(minS, QSizeF(0,0));
+ boundSize(minS, prefS);
+ boundSize(minS, maxS);
//--- GATHER PREFERRED SIZE HINTS ---
// First, from implicitWidth/Height
@@ -203,17 +249,12 @@ Fixed | Layout.fillWidth | Expanding if layout, Fixed if item |
item->blockSignals(false);
}
}
- //--- GATHER MAXIMUM SIZE HINTS ---
- combineHints(cachedSizeHints[Qt::MaximumSize].rwidth(), std::numeric_limits<qreal>::infinity());
- combineHints(cachedSizeHints[Qt::MaximumSize].rheight(), std::numeric_limits<qreal>::infinity());
//--- GATHER DESCENT
// ### Not implemented
// Normalize again after the implicit hints have been gathered
- expandSize(minS, QSizeF(0,0));
- boundSize(minS, maxS);
expandSize(prefS, minS);
boundSize(prefS, maxS);
diff --git a/src/layouts/qquickgridlayoutengine_p.h b/src/layouts/qquickgridlayoutengine_p.h
index 29317ffb..8842d36a 100644
--- a/src/layouts/qquickgridlayoutengine_p.h
+++ b/src/layouts/qquickgridlayoutengine_p.h
@@ -112,8 +112,16 @@ public:
void setGeometry(const QRectF &rect)
{
const QRect r(rect.toRect());
+ const QSize newSize(r.size());
m_item->setPosition(r.topLeft());
- m_item->setSize(r.size());
+ QSizeF oldSize(m_item->width(), m_item->height());
+ if (newSize == oldSize) {
+ if (QQuickLayout *lay = qobject_cast<QQuickLayout *>(m_item))
+ if (lay->arrangementIsDirty())
+ lay->rearrange(newSize);
+ } else {
+ m_item->setSize(newSize);
+ }
}
QQuickItem *layoutItem() const { return m_item; }
diff --git a/src/layouts/qquicklayout.cpp b/src/layouts/qquicklayout.cpp
index 48b80255..86eac072 100644
--- a/src/layouts/qquicklayout.cpp
+++ b/src/layouts/qquicklayout.cpp
@@ -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.
diff --git a/src/layouts/qquicklayout_p.h b/src/layouts/qquicklayout_p.h
index 8a334677..76c19717 100644
--- a/src/layouts/qquicklayout_p.h
+++ b/src/layouts/qquicklayout_p.h
@@ -77,9 +77,10 @@ public:
void componentComplete();
virtual QSizeF sizeHint(Qt::SizeHint whichSizeHint) const = 0;
virtual void invalidate(QQuickItem * childItem = 0);
+ virtual void rearrange(const QSizeF &);
+ bool arrangementIsDirty() const { return m_dirty; }
protected:
bool event(QEvent *e);
- virtual void rearrange(const QSizeF &);
enum Orientation {
Vertical = 0,
@@ -175,6 +176,22 @@ public:
qreal sizeHint(Qt::SizeHint which, Qt::Orientation orientation) const;
+ bool isExtentExplicitlySet(Qt::Orientation o, Qt::SizeHint whichSize) const
+ {
+ switch (whichSize) {
+ case Qt::MinimumSize:
+ return o == Qt::Horizontal ? m_isMinimumWidthSet : m_isMinimumHeightSet;
+ case Qt::MaximumSize:
+ return o == Qt::Horizontal ? m_isMaximumWidthSet : m_isMaximumHeightSet;
+ case Qt::PreferredSize:
+ return true; // Layout.preferredWidth is always explicitly set
+ case Qt::MinimumDescent: // Not supported
+ case Qt::NSizeHints:
+ return false;
+ }
+ return false;
+ }
+
signals:
void minimumWidthChanged();
void minimumHeightChanged();
diff --git a/src/layouts/qquicklinearlayout.cpp b/src/layouts/qquicklinearlayout.cpp
index 541e4aca..931bfed5 100644
--- a/src/layouts/qquicklinearlayout.cpp
+++ b/src/layouts/qquicklinearlayout.cpp
@@ -48,33 +48,67 @@
/*!
\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
+
+ Read more about attached properties \l{QML Object Attributes}{here}.
\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
+
+ Read more about attached properties \l{QML Object Attributes}{here}.
+
\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 +146,44 @@
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.
+ 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
- \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.
+ Read more about attached properties \l{QML Object Attributes}{here}.
\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 +216,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 +273,7 @@ void QQuickGridLayoutBase::componentComplete()
void QQuickGridLayoutBase::invalidate(QQuickItem *childItem)
{
Q_D(QQuickGridLayoutBase);
- if (!isComponentComplete())
+ if (!isReady())
return;
quickLayoutDebug() << "QQuickGridLayoutBase::invalidate()";
@@ -267,7 +312,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 +332,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 +341,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 +352,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 +366,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 +384,7 @@ void QQuickGridLayoutBase::removeLayoutItem(QQuickItem *item)
void QQuickGridLayoutBase::onItemVisibleChanged()
{
- if (!isComponentComplete())
+ if (!isReady())
return;
quickLayoutDebug() << "QQuickGridLayoutBase::onItemVisibleChanged";
updateLayoutItems();
@@ -342,6 +392,8 @@ void QQuickGridLayoutBase::onItemVisibleChanged()
void QQuickGridLayoutBase::onItemDestroyed()
{
+ if (!isReady())
+ return;
Q_D(QQuickGridLayoutBase);
quickLayoutDebug() << "QQuickGridLayoutBase::onItemDestroyed";
QQuickItem *inDestruction = static_cast<QQuickItem *>(sender());
@@ -354,6 +406,8 @@ void QQuickGridLayoutBase::onItemDestroyed()
void QQuickGridLayoutBase::onItemImplicitSizeChanged()
{
+ if (!isReady())
+ return;
QQuickItem *item = static_cast<QQuickItem *>(sender());
Q_ASSERT(item);
invalidate(item);
@@ -362,7 +416,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 +466,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 +727,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);
}
diff --git a/src/layouts/qquicklinearlayout_p.h b/src/layouts/qquicklinearlayout_p.h
index 76cc206b..b38bd97f 100644
--- a/src/layouts/qquicklinearlayout_p.h
+++ b/src/layouts/qquicklinearlayout_p.h
@@ -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;
};
diff --git a/src/private/AbstractCheckable.qml b/src/private/AbstractCheckable.qml
index ba203e4d..02348b71 100644
--- a/src/private/AbstractCheckable.qml
+++ b/src/private/AbstractCheckable.qml
@@ -69,10 +69,16 @@ Control {
/*!
\qmlproperty bool AbstractCheckable::pressed
- This property is \c true if the control is pressed.
+ This property is \c true if the control is being pressed.
Set this property to manually invoke a mouse click.
*/
- readonly property alias pressed: mouseArea.effectivePressed
+ property alias pressed: mouseArea.effectivePressed
+
+ /*! \qmlproperty bool AbstractCheckcable::hovered
+
+ This property indicates whether the control is being hovered.
+ */
+ readonly property alias hovered: mouseArea.containsMouse
/*!
This property is \c true if the control is checked.
@@ -99,13 +105,6 @@ Control {
/*! \internal */
property var __cycleStatesHandler: cycleRadioButtonStates
- /*! \internal
-
- This property is \c true if the control currently contains the
- mouse cursor.
- */
- readonly property alias __containsMouse: mouseArea.containsMouse
-
activeFocusOnTab: true
MouseArea {
diff --git a/src/private/BasicButton.qml b/src/private/BasicButton.qml
index 3ef4b6e9..b5e9ab8f 100644
--- a/src/private/BasicButton.qml
+++ b/src/private/BasicButton.qml
@@ -42,6 +42,7 @@ import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Controls.Private 1.0
import QtQuick.Controls.Styles 1.0
+import "style.js" as StyleHelpers
/*!
\qmltype BasicButton
@@ -58,8 +59,14 @@ Control {
/*! \qmlproperty bool BasicButton::pressed
- This property holds whether the button is pressed. */
- readonly property bool pressed: behavior.effectivePressed
+ This property holds whether the button is being pressed. */
+ readonly property alias pressed: behavior.effectivePressed
+
+ /*! \qmlproperty bool BasicButton::hovered
+
+ This property indicates whether the control is being hovered.
+ */
+ readonly property alias hovered: behavior.containsMouse
/*! This property holds whether the button is checkable.
@@ -83,6 +90,9 @@ Control {
If a button has an action associated, the action defines the
button's properties like checked, text, tooltip etc.
+ When an action is set, it's still possible to override the \l text,
+ \l tooltip, \l iconSource, and \l iconName properties.
+
The default value is \c null. */
property Action action: null
@@ -91,17 +101,39 @@ Control {
The default value is \c false. */
property bool activeFocusOnPress: false
+ /*! This property holds the text shown on the button. If the button has no
+ text, the \l text property will be an empty string.
+
+ The default value is the empty string.
+ */
+ property string text: action ? action.text : ""
+
/*! This property holds the button tooltip. */
- property string tooltip
+ property string tooltip: action ? (action.tooltip || StyleHelpers.removeMnemonics(action.text)) : ""
+
+ /*! This property holds the icon shown on the button. If the button has no
+ icon, the iconSource property will be an empty string.
+
+ The default value is the empty string.
+ */
+ property url iconSource: action ? action.iconSource : ""
+
+ /*! The image label source as theme name.
+ When an icon from the platform icon theme is found, this takes
+ precedence over iconSource.
+ */
+ property string iconName: action ? action.iconName : ""
/*! \internal */
property color __textColor: syspal.text
/*! \internal */
property string __position: "only"
/*! \internal */
- property alias __containsMouse: behavior.containsMouse
+ readonly property bool __iconOverriden: button.action && (button.action.iconSource !== button.iconSource || button.action.iconName !== button.iconName)
/*! \internal */
property Action __action: action || ownAction
+ /*! \internal */
+ readonly property Action __iconAction: __iconOverriden ? ownAction : __action
/*! \internal */
onExclusiveGroupChanged: {
@@ -119,7 +151,8 @@ Control {
Action {
id: ownAction
- iconSource: !button.action ? button.iconSource : ""
+ iconSource: !button.action || __iconOverriden ? button.iconSource : ""
+ iconName: !button.action || __iconOverriden ? button.iconName : ""
}
Connections {
@@ -181,9 +214,6 @@ Control {
enabled: action.enabled
checkable: action.checkable
checked: action.checked
- text: action.text
- iconSource: action.iconSource
- tooltip: action.tooltip
}
}
]
diff --git a/src/private/Control.qml b/src/private/Control.qml
index d518adb2..05916c0a 100644
--- a/src/private/Control.qml
+++ b/src/private/Control.qml
@@ -64,14 +64,14 @@ FocusScope {
property Item __panel: panelLoader.item
/*! \internal */
- property var styleHints: []
+ property var styleHints
implicitWidth: __panel ? __panel.implicitWidth: 0
implicitHeight: __panel ? __panel.implicitHeight: 0
activeFocusOnTab: false
/*! \internal */
- property alias __controlState: styleLoader.controlState
+ property alias __styleData: styleLoader.styleData
Loader {
id: panelLoader
@@ -82,7 +82,7 @@ FocusScope {
id: styleLoader
sourceComponent: style
property Item __control: root
- property QtObject controlState: null
+ property QtObject styleData: null
onStatusChanged: {
if (status === Loader.Error)
console.error("Failed to load Style for", root)
diff --git a/src/private/ScrollBar.qml b/src/private/ScrollBar.qml
index ad26d249..2f8e80bc 100644
--- a/src/private/ScrollBar.qml
+++ b/src/private/ScrollBar.qml
@@ -75,7 +75,7 @@ Item {
sourceComponent: __style ? __style.__scrollbar : null
onStatusChanged: if (status === Loader.Error) console.error("Failed to load Style for", root)
property alias __control: scrollbar
- property QtObject controlState: QtObject {
+ property QtObject __styleData: QtObject {
readonly property alias horizontal: internal.horizontal
readonly property alias upPressed: scrollbar.upPressed
readonly property alias downPressed: scrollbar.downPressed
diff --git a/src/private/ScrollViewHelper.qml b/src/private/ScrollViewHelper.qml
index cf5c514f..9e8e78d6 100644
--- a/src/private/ScrollViewHelper.qml
+++ b/src/private/ScrollViewHelper.qml
@@ -57,6 +57,8 @@ Item {
property int availableWidth
property int contentHeight
property int contentWidth
+ property real originX
+ property real originY
property int leftMargin: outerFrame ? root.__style.padding.left : 0
property int rightMargin: outerFrame ? root.__style.padding.right : 0
@@ -74,6 +76,8 @@ Item {
wheelarea.availableHeight = viewport.height
wheelarea.contentWidth = flickableItem !== null ? flickableItem.contentWidth : 0
wheelarea.contentHeight = flickableItem !== null ? flickableItem.contentHeight : 0
+ wheelarea.originX = flickableItem !== null ? flickableItem.originX : 0
+ wheelarea.originY = flickableItem !== null ? flickableItem.originY : 0
recursionGuard = false
}
}
@@ -123,8 +127,8 @@ Item {
visible: contentWidth > availableWidth
height: visible ? implicitHeight : 0
z: 1
- maximumValue: contentWidth > availableWidth ? contentWidth - availableWidth : 0
- minimumValue: 0
+ maximumValue: contentWidth > availableWidth ? originX + contentWidth - availableWidth : 0
+ minimumValue: originX
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: cornerFill.left
@@ -158,8 +162,8 @@ Item {
width: visible ? implicitWidth : 0
z: 1
anchors.bottom: cornerFill.top
- maximumValue: contentHeight > availableHeight ? contentHeight - availableHeight + __viewTopMargin : 0
- minimumValue: 0
+ maximumValue: contentHeight > availableHeight ? originY + contentHeight - availableHeight + __viewTopMargin : 0
+ minimumValue: originY
anchors.right: parent.right
anchors.top: parent.top
anchors.topMargin: __scrollBarTopMargin + topMargin
diff --git a/src/private/Style.qml b/src/private/Style.qml
index 990f61dd..6b4c08ef 100644
--- a/src/private/Style.qml
+++ b/src/private/Style.qml
@@ -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
diff --git a/src/private/TabBar.qml b/src/private/TabBar.qml
index 49b10584..f51d60b2 100644
--- a/src/private/TabBar.qml
+++ b/src/private/TabBar.qml
@@ -170,7 +170,6 @@ FocusScope {
property int tabindex: index
property bool selected : tabView.currentIndex === index
- property bool hover: containsMouse
property string title: modelData.title
property bool nextSelected: tabView.currentIndex === index + 1
property bool previousSelected: tabView.currentIndex === index - 1
@@ -182,10 +181,8 @@ FocusScope {
onPressed: {
tabView.currentIndex = index;
var next = tabbar.nextItemInFocusChain(true);
- if (__isAncestorOf(tabView.tabAt(currentIndex), next))
+ if (__isAncestorOf(tabView.getTab(currentIndex), next))
next.forceActiveFocus();
- else
- tabitem.forceActiveFocus();
}
Loader {
@@ -193,16 +190,16 @@ FocusScope {
property Item control: tabView
property int index: tabindex
- property real availableWidth: tabbar.availableWidth
- property QtObject tab: QtObject {
+ property QtObject styleData: QtObject {
readonly property alias index: tabitem.tabindex
readonly property alias selected: tabitem.selected
readonly property alias title: tabitem.title
readonly property alias nextSelected: tabitem.nextSelected
readonly property alias previsousSelected: tabitem.previousSelected
- readonly property alias hovered: tabitem.hover
+ readonly property alias hovered: tabitem.containsMouse
readonly property bool activeFocus: tabbar.activeFocus
+ readonly property real availableWidth: tabbar.availableWidth
}
sourceComponent: loader.item ? loader.item.tab : null
diff --git a/src/private/plugin.cpp b/src/private/plugin.cpp
index 17bfed07..e33c2d37 100644
--- a/src/private/plugin.cpp
+++ b/src/private/plugin.cpp
@@ -45,7 +45,7 @@
#include "qquicktooltip_p.h"
#include "qquickcontrolsettings_p.h"
#include "qquickspinboxvalidator_p.h"
-#include "qquickpaddedstyle_p.h"
+#include "qquickabstractstyle_p.h"
#ifndef QT_NO_WIDGETS
#include "qquickstyleitem_p.h"
@@ -81,7 +81,7 @@ public:
void QtQuickControlsPrivatePlugin::registerTypes(const char *uri)
{
- qmlRegisterType<QQuickPaddedStyle>(uri, 1, 0, "PaddedStyle");
+ qmlRegisterType<QQuickAbstractStyle>(uri, 1, 0, "AbstractStyle");
qmlRegisterType<QQuickPadding>();
qmlRegisterType<QQuickRangeModel>(uri, 1, 0, "RangeModel");
qmlRegisterType<QQuickWheelArea>(uri, 1, 0, "WheelArea");
diff --git a/src/private/private.pro b/src/private/private.pro
index 9f892452..803b703f 100644
--- a/src/private/private.pro
+++ b/src/private/private.pro
@@ -1,4 +1,4 @@
-TARGET = qtquickcontrolsprivate
+TARGET = qtquickcontrolsprivateplugin
TARGETPATH = QtQuick/Controls/Private
QT += qml quick gui-private core-private
@@ -10,7 +10,7 @@ HEADERS += \
$$PWD/qquickrangemodel_p_p.h \
$$PWD/qquickcontrolsettings_p.h \
$$PWD/qquickwheelarea_p.h \
- $$PWD/qquickpaddedstyle_p.h \
+ $$PWD/qquickabstractstyle_p.h \
$$PWD/qquickpadding_p.h
SOURCES += \
@@ -20,7 +20,7 @@ SOURCES += \
$$PWD/qquickrangemodel.cpp \
$$PWD/qquickcontrolsettings.cpp \
$$PWD/qquickwheelarea.cpp \
- $$PWD/qquickpaddedstyle.cpp
+ $$PWD/qquickabstractstyle.cpp
# private qml files
QML_FILES += \
diff --git a/src/private/qmldir b/src/private/qmldir
index d4b7fc46..7f73028e 100644
--- a/src/private/qmldir
+++ b/src/private/qmldir
@@ -1,5 +1,5 @@
module QtQuick.Controls.Private
-plugin qtquickcontrolsprivate
+plugin qtquickcontrolsprivateplugin
AbstractCheckable 1.0 AbstractCheckable.qml
Control 1.0 Control.qml
FocusFrame 1.0 FocusFrame.qml
diff --git a/src/private/qquickpaddedstyle.cpp b/src/private/qquickabstractstyle.cpp
index 320a3f53..eba57b03 100644
--- a/src/private/qquickpaddedstyle.cpp
+++ b/src/private/qquickabstractstyle.cpp
@@ -39,30 +39,60 @@
**
****************************************************************************/
-#include "qquickpaddedstyle_p.h"
-#include "qquickpadding_p.h"
+#include "qquickabstractstyle_p.h"
+
+QT_BEGIN_NAMESPACE
/*!
- \qmltype PaddedStyle
- \instantiates QQuickPaddedStyle
+ \qmltype AbstractStyle
+ \instantiates QQuickAbstractStyle
\qmlabstract
\internal
*/
-QT_BEGIN_NAMESPACE
+/*!
+ \qmlproperty int AbstractStyle::padding.top
+ \qmlproperty int AbstractStyle::padding.left
+ \qmlproperty int AbstractStyle::padding.right
+ \qmlproperty int AbstractStyle::padding.bottom
+
+ This grouped property holds the \c top, \c left, \c right and \c bottom padding.
+*/
-QQuickPaddedStyle::QQuickPaddedStyle(QQuickItem *parent) :
- QQuickItem(parent)
+QQuickAbstractStyle::QQuickAbstractStyle(QObject *parent) : QObject(parent)
{
}
-/*!
- \qmlproperty int PaddedStyle::padding.top
- \qmlproperty int PaddedStyle::padding.left
- \qmlproperty int PaddedStyle::padding.right
- \qmlproperty int PaddedStyle::padding.bottom
+QQmlListProperty<QObject> QQuickAbstractStyle::data()
+{
+ return QQmlListProperty<QObject>(this, 0, &QQuickAbstractStyle::data_append, &QQuickAbstractStyle::data_count,
+ &QQuickAbstractStyle::data_at, &QQuickAbstractStyle::data_clear);
+}
- This grouped property holds the \c top, \c left, \c right and \c bottom padding.
-*/
+void QQuickAbstractStyle::data_append(QQmlListProperty<QObject> *list, QObject *object)
+{
+ if (QQuickAbstractStyle *style = qobject_cast<QQuickAbstractStyle *>(list->object))
+ style->m_data.append(object);
+}
+
+int QQuickAbstractStyle::data_count(QQmlListProperty<QObject> *list)
+{
+ if (QQuickAbstractStyle *style = qobject_cast<QQuickAbstractStyle *>(list->object))
+ return style->m_data.count();
+ return 0;
+}
+
+QObject *QQuickAbstractStyle::data_at(QQmlListProperty<QObject> *list, int index)
+{
+ if (QQuickAbstractStyle *style = qobject_cast<QQuickAbstractStyle *>(list->object))
+ return style->m_data.at(index);
+ return 0;
+}
+
+void QQuickAbstractStyle::data_clear(QQmlListProperty<QObject> *list)
+{
+ if (QQuickAbstractStyle *style = qobject_cast<QQuickAbstractStyle *>(list->object))
+ style->m_data.clear();
+}
QT_END_NAMESPACE
diff --git a/src/private/qquickpaddedstyle_p.h b/src/private/qquickabstractstyle_p.h
index 1a5a3c95..13764053 100644
--- a/src/private/qquickpaddedstyle_p.h
+++ b/src/private/qquickabstractstyle_p.h
@@ -39,29 +39,40 @@
**
****************************************************************************/
-#ifndef QQUICKPADDEDSTYLE_H
-#define QQUICKPADDEDSTYLE_H
+#ifndef QQUICKABSTRACTSTYLE_H
+#define QQUICKABSTRACTSTYLE_H
-#include <QtQuick/QQuickItem>
-#include <QtQml/QQmlListProperty>
+#include <QtCore/qobject.h>
+#include <QtQml/qqmllist.h>
#include "qquickpadding_p.h"
QT_BEGIN_NAMESPACE
-class QQuickPaddedStyle : public QQuickItem
+class QQuickAbstractStyle : public QObject
{
Q_OBJECT
Q_PROPERTY(QQuickPadding* padding READ padding CONSTANT)
+ Q_PROPERTY(QQmlListProperty<QObject> data READ data DESIGNABLE false)
+ Q_CLASSINFO("DefaultProperty", "data")
public:
- QQuickPaddedStyle(QQuickItem *parent = 0);
+ QQuickAbstractStyle(QObject *parent = 0);
+
QQuickPadding* padding() { return &m_padding; }
+ QQmlListProperty<QObject> data();
+
private:
+ static void data_append(QQmlListProperty<QObject> *list, QObject *object);
+ static int data_count(QQmlListProperty<QObject> *list);
+ static QObject *data_at(QQmlListProperty<QObject> *list, int index);
+ static void data_clear(QQmlListProperty<QObject> *list);
+
QQuickPadding m_padding;
+ QList<QObject *> m_data;
};
QT_END_NAMESPACE
-#endif // QQUICKPADDEDSTYLE_H
+#endif // QQUICKABSTRACTSTYLE_H
diff --git a/src/private/qquickcontrolsettings.cpp b/src/private/qquickcontrolsettings.cpp
index 44db49c2..e2daa17f 100644
--- a/src/private/qquickcontrolsettings.cpp
+++ b/src/private/qquickcontrolsettings.cpp
@@ -133,4 +133,15 @@ QString QQuickControlSettings::styleFilePath() const
return m_path + QLatin1Char('/') + m_name;
}
+extern Q_GUI_EXPORT int qt_defaultDpiX();
+
+qreal QQuickControlSettings::dpiScaleFactor() const
+{
+#ifndef Q_OS_MAC
+ return (qreal(qt_defaultDpiX()) / 96.0);
+#endif
+ return 1.0;
+}
+
+
QT_END_NAMESPACE
diff --git a/src/private/qquickcontrolsettings_p.h b/src/private/qquickcontrolsettings_p.h
index 98e85151..8ff0ecbf 100644
--- a/src/private/qquickcontrolsettings_p.h
+++ b/src/private/qquickcontrolsettings_p.h
@@ -55,6 +55,7 @@ class QQuickControlSettings : public QObject
Q_PROPERTY(QUrl style READ style NOTIFY styleChanged)
Q_PROPERTY(QString styleName READ styleName WRITE setStyleName NOTIFY styleNameChanged)
Q_PROPERTY(QString stylePath READ stylePath WRITE setStylePath NOTIFY stylePathChanged)
+ Q_PROPERTY(qreal dpiScaleFactor READ dpiScaleFactor CONSTANT)
public:
QQuickControlSettings(QQmlEngine *engine);
@@ -67,6 +68,8 @@ public:
QString stylePath() const;
void setStylePath(const QString &path);
+ qreal dpiScaleFactor() const;
+
signals:
void styleChanged();
void styleNameChanged();
diff --git a/src/private/qquickstyleitem.cpp b/src/private/qquickstyleitem.cpp
index cfbb36c8..115841ad 100644
--- a/src/private/qquickstyleitem.cpp
+++ b/src/private/qquickstyleitem.cpp
@@ -177,8 +177,9 @@ void QQuickStyleItem::initStyleOption()
if (m_styleoption)
m_styleoption->state = 0;
- QPlatformTheme::Font platformFont = (m_hints.indexOf("mini") != -1) ? QPlatformTheme::MiniFont :
- (m_hints.indexOf("small") != -1) ? QPlatformTheme::SmallFont :
+ QString sizeHint = m_hints.value("size").toString();
+ QPlatformTheme::Font platformFont = (sizeHint == "mini") ? QPlatformTheme::MiniFont :
+ (sizeHint == "small") ? QPlatformTheme::SmallFont :
QPlatformTheme::SystemFont;
switch (m_itemType) {
@@ -266,11 +267,12 @@ void QQuickStyleItem::initStyleOption()
QStyleOptionHeader::SortDown
: activeControl() == "up" ?
QStyleOptionHeader::SortUp : QStyleOptionHeader::None;
- if (hints().contains("beginning"))
+ QString headerpos = m_properties.value("headerpos").toString();
+ if (headerpos == "beginning")
opt->position = QStyleOptionHeader::Beginning;
- else if (hints().contains("end"))
+ else if (headerpos == "end")
opt->position = QStyleOptionHeader::End;
- else if (hints().contains("only"))
+ else if (headerpos == "only")
opt->position = QStyleOptionHeader::OnlyOneSection;
else
opt->position = QStyleOptionHeader::Middle;
@@ -318,32 +320,30 @@ void QQuickStyleItem::initStyleOption()
QStyleOptionTab *opt = qstyleoption_cast<QStyleOptionTab*>(m_styleoption);
opt->text = text();
- if (m_properties["hasFrame"].toBool())
+ if (m_properties.value("hasFrame").toBool())
opt->features |= QStyleOptionTab::HasFrame;
- if (hints().length() > 2) {
- QString orientation = hints()[0];
- QString position = hints()[1];
- QString selectedPosition = hints()[2];
-
- opt->shape = (orientation == "Bottom") ? QTabBar::RoundedSouth : QTabBar::RoundedNorth;
+ QString orientation = m_properties.value("orientation").toString();
+ QString position = m_properties.value("tabpos").toString();
+ QString selectedPosition = m_properties.value("selectedpos").toString();
+
+ opt->shape = (orientation == "Bottom") ? QTabBar::RoundedSouth : QTabBar::RoundedNorth;
+ if (position == QLatin1String("beginning"))
+ opt->position = QStyleOptionTab::Beginning;
+ else if (position == QLatin1String("end"))
+ opt->position = QStyleOptionTab::End;
+ else if (position == QLatin1String("only"))
+ opt->position = QStyleOptionTab::OnlyOneTab;
+ else
+ opt->position = QStyleOptionTab::Middle;
- if (position == QLatin1String("beginning"))
- opt->position = QStyleOptionTab::Beginning;
- else if (position == QLatin1String("end"))
- opt->position = QStyleOptionTab::End;
- else if (position == QLatin1String("only"))
- opt->position = QStyleOptionTab::OnlyOneTab;
- else
- opt->position = QStyleOptionTab::Middle;
+ if (selectedPosition == QLatin1String("next"))
+ opt->selectedPosition = QStyleOptionTab::NextIsSelected;
+ else if (selectedPosition == QLatin1String("previous"))
+ opt->selectedPosition = QStyleOptionTab::PreviousIsSelected;
+ else
+ opt->selectedPosition = QStyleOptionTab::NotAdjacent;
- if (selectedPosition == QLatin1String("next"))
- opt->selectedPosition = QStyleOptionTab::NextIsSelected;
- else if (selectedPosition == QLatin1String("previous"))
- opt->selectedPosition = QStyleOptionTab::PreviousIsSelected;
- else
- opt->selectedPosition = QStyleOptionTab::NotAdjacent;
- }
} break;
@@ -459,7 +459,7 @@ void QQuickStyleItem::initStyleOption()
QStyleOptionButton *opt = qstyleoption_cast<QStyleOptionButton*>(m_styleoption);
if (!on())
opt->state |= QStyle::State_Off;
- if (m_hints.contains("partiallyChecked"))
+ if (m_properties.value("partiallyChecked").toBool())
opt->state |= QStyle::State_NoChange;
opt->text = text();
}
@@ -643,9 +643,9 @@ void QQuickStyleItem::initStyleOption()
if (m_horizontal)
m_styleoption->state |= QStyle::State_Horizontal;
- if (m_hints.indexOf("mini") != -1) {
+ if (sizeHint == "mini") {
m_styleoption->state |= QStyle::State_Mini;
- } else if (m_hints.indexOf("small") != -1) {
+ } else if (sizeHint == "small") {
m_styleoption->state |= QStyle::State_Small;
}
@@ -734,7 +734,7 @@ QSize QQuickStyleItem::sizeFromContents(int width, int height)
size = qApp->style()->sizeFromContents(QStyle::CT_CheckBox, m_styleoption, QSize(width,height));
break;
case ToolBar:
- size = QSize(200, 40);
+ size = QSize(200, style().contains("windows") ? 30 : 42);
break;
case ToolButton: {
QStyleOptionToolButton *btn = qstyleoption_cast<QStyleOptionToolButton*>(m_styleoption);
@@ -801,10 +801,14 @@ QSize QQuickStyleItem::sizeFromContents(int width, int height)
case Edit:
#ifdef Q_OS_MAC
if (style() =="mac") {
- if (m_hints.indexOf("small") != -1 || m_hints.indexOf("mini") != -1)
+ QString sizeHint = m_hints.value("size").toString();
+ if ((sizeHint == "small") || (sizeHint == "mini"))
size = QSize(width, 19);
else
size = QSize(width, 22);
+ if (style() == "mac" && hints().value("rounded").toBool())
+ size += QSize(4, 4);
+
} else
#endif
{
@@ -938,8 +942,8 @@ QVariant QQuickStyleItem::styleHint(const QString &metric)
if (metric == "comboboxpopup") {
return qApp->style()->styleHint(QStyle::SH_ComboBox_Popup, m_styleoption);
} else if (metric == "highlightedTextColor") {
- QPalette pal = qApp->palette();
- pal.setCurrentColorGroup(active()? QPalette::Active : QPalette::Inactive);
+ QPalette pal = QApplication::palette("QAbstractItemView");
+ pal.setCurrentColorGroup(m_styleoption->palette.currentColorGroup());
return pal.highlightedText().color().name();
} else if (metric == "textColor") {
QPalette pal = qApp->palette();
@@ -965,7 +969,7 @@ QVariant QQuickStyleItem::styleHint(const QString &metric)
// Add SH_Menu_SpaceActivatesItem, SH_Menu_SubMenuPopupDelay
}
-void QQuickStyleItem::setHints(const QStringList &str)
+void QQuickStyleItem::setHints(const QVariantMap &str)
{
if (m_hints != str) {
m_hints = str;
@@ -983,6 +987,11 @@ void QQuickStyleItem::setHints(const QStringList &str)
}
}
+void QQuickStyleItem::resetHints()
+{
+ m_hints.clear();
+}
+
void QQuickStyleItem::setElementType(const QString &str)
{
@@ -1192,8 +1201,11 @@ void QQuickStyleItem::paint(QPainter *painter)
pixmap.fill(Qt::transparent);
QPainter pixpainter(&pixmap);
qApp->style()->drawPrimitive(QStyle::PE_PanelItemViewRow, m_styleoption, &pixpainter);
- if (!qApp->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected) && selected())
- pixpainter.fillRect(m_styleoption->rect, m_styleoption->palette.highlight());
+ if ((style() == "mac" || !qApp->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected)) && selected()) {
+ QPalette pal = QApplication::palette("QAbstractItemView");
+ pal.setCurrentColorGroup(m_styleoption->palette.currentColorGroup());
+ pixpainter.fillRect(m_styleoption->rect, pal.highlight());
+ }
QPixmapCache::insert(pmKey, pixmap);
}
painter->drawPixmap(0, 0, pixmap);
@@ -1208,7 +1220,7 @@ void QQuickStyleItem::paint(QPainter *painter)
case ToolButton:
#ifdef Q_OS_MAC
- if (style() == "mac" && hints().indexOf("segmented") != -1) {
+ if (style() == "mac" && hints().value("segmented").toBool()) {
const QPaintDevice *target = painter->device();
HIThemeSegmentDrawInfo sgi;
sgi.version = 0;
@@ -1224,9 +1236,10 @@ void QQuickStyleItem::paint(QPainter *painter)
}
SInt32 button_height;
GetThemeMetric(kThemeMetricButtonRoundedHeight, &button_height);
- sgi.position = hints().contains("leftmost") ? kHIThemeSegmentPositionFirst:
- hints().contains("rightmost") ? kHIThemeSegmentPositionLast :
- hints().contains("h_middle") ? kHIThemeSegmentPositionMiddle :
+ QString buttonPos = m_properties.value("position").toString();
+ sgi.position = buttonPos == "leftmost" ? kHIThemeSegmentPositionFirst :
+ buttonPos == "rightmost" ? kHIThemeSegmentPositionLast :
+ buttonPos == "h_middle" ? kHIThemeSegmentPositionMiddle :
kHIThemeSegmentPositionOnly;
QRect centered = m_styleoption->rect;
centered.setHeight(button_height);
@@ -1254,12 +1267,7 @@ void QQuickStyleItem::paint(QPainter *painter)
qApp->style()->drawControl(QStyle::CE_ShapedFrame, m_styleoption, painter);
break;
case FocusFrame:
-#ifdef Q_OS_MAC
- if (style() == "mac" && hints().indexOf("rounded") != -1)
- break; // embedded in the line itself
- else
-#endif
- qApp->style()->drawControl(QStyle::CE_FocusFrame, m_styleoption, painter);
+ qApp->style()->drawControl(QStyle::CE_FocusFrame, m_styleoption, painter);
break;
case FocusRect:
qApp->style()->drawPrimitive(QStyle::PE_FrameFocusRect, m_styleoption, painter);
@@ -1285,7 +1293,7 @@ void QQuickStyleItem::paint(QPainter *painter)
break;
case Edit: {
#ifdef Q_OS_MAC
- if (style() == "mac" && hints().indexOf("rounded") != -1) {
+ if (style() == "mac" && hints().value("rounded").toBool()) {
const QPaintDevice *target = painter->device();
HIThemeFrameDrawInfo fdi;
fdi.version = 0;
@@ -1296,9 +1304,7 @@ void QQuickStyleItem::paint(QPainter *painter)
if ((m_styleoption->state & QStyle::State_ReadOnly) || !(m_styleoption->state & QStyle::State_Enabled))
fdi.state = kThemeStateInactive;
fdi.isFocused = hasFocus();
- HIRect hirect = qt_hirectForQRect(m_styleoption->rect,
- QRect(frame_size, frame_size,
- frame_size * 2, frame_size * 2));
+ HIRect hirect = qt_hirectForQRect(m_styleoption->rect.adjusted(2, 2, -2, 2), QRect(0, 0, 0, 0));
HIThemeDrawFrame(&hirect, &fdi, qt_mac_cg_context(target), kHIThemeOrientationNormal);
} else
#endif
diff --git a/src/private/qquickstyleitem_p.h b/src/private/qquickstyleitem_p.h
index 6deaeb16..eee9e6e5 100644
--- a/src/private/qquickstyleitem_p.h
+++ b/src/private/qquickstyleitem_p.h
@@ -67,7 +67,7 @@ class QQuickStyleItem: public QQuickItem
Q_PROPERTY( QString text READ text WRITE setText NOTIFY textChanged)
Q_PROPERTY( QString activeControl READ activeControl WRITE setActiveControl NOTIFY activeControlChanged)
Q_PROPERTY( QString style READ style NOTIFY styleChanged)
- Q_PROPERTY( QStringList hints READ hints WRITE setHints NOTIFY hintChanged)
+ Q_PROPERTY( QVariantMap hints READ hints WRITE setHints NOTIFY hintChanged RESET resetHints)
Q_PROPERTY( QVariantMap properties READ properties WRITE setProperties NOTIFY propertiesChanged)
Q_PROPERTY( QFont font READ font NOTIFY fontChanged)
@@ -140,7 +140,7 @@ public:
QString elementType() const { return m_type; }
QString text() const { return m_text; }
QString activeControl() const { return m_activeControl; }
- QStringList hints() const { return m_hints; }
+ QVariantMap hints() const { return m_hints; }
QVariantMap properties() const { return m_properties; }
QFont font() const { return m_font;}
QString style() const;
@@ -161,8 +161,9 @@ public:
void setElementType(const QString &str);
void setText(const QString &str) { if (m_text != str) {m_text = str; emit textChanged();}}
void setActiveControl(const QString &str) { if (m_activeControl != str) {m_activeControl = str; emit activeControlChanged();}}
- void setHints(const QStringList &str);
+ void setHints(const QVariantMap &str);
void setProperties(const QVariantMap &props) { if (m_properties != props) { m_properties = props; emit propertiesChanged(); } }
+ void resetHints();
int contentWidth() const { return m_contentWidth; }
void setContentWidth(int arg);
@@ -228,7 +229,7 @@ protected:
QString m_type;
QString m_text;
QString m_activeControl;
- QStringList m_hints;
+ QVariantMap m_hints;
QVariantMap m_properties;
QFont m_font;
diff --git a/src/private/style.js b/src/private/style.js
index 81d6b563..2c47ff0e 100644
--- a/src/private/style.js
+++ b/src/private/style.js
@@ -40,13 +40,24 @@
.pragma library
-function replaceAmpersands(match, p1, p2, p3) {
+function underlineAmpersands(match, p1, p2, p3) {
if (p2 === "&")
return p1.concat(p2, p3)
return p1.concat("<u>", p2, "</u>", p3)
}
+function removeAmpersands(match, p1, p2, p3) {
+ return p1.concat(p2, p3)
+}
+
+function replaceAmpersands(text, replaceFunction) {
+ return text.replace(/([^&]*)&(.)([^&]*)/g, replaceFunction)
+}
+
function stylizeMnemonics(text) {
+ return replaceAmpersands(text, underlineAmpersands)
+}
- return text.replace(/([^&]*)&(.)([^&]*)/g, replaceAmpersands)
+function removeMnemonics(text) {
+ return replaceAmpersands(text, removeAmpersands)
}
diff --git a/src/styles/Base/ButtonStyle.qml b/src/styles/Base/ButtonStyle.qml
index a524d93f..519e4d67 100644
--- a/src/styles/Base/ButtonStyle.qml
+++ b/src/styles/Base/ButtonStyle.qml
@@ -45,6 +45,7 @@ import QtQuick.Controls.Private 1.0
\qmltype ButtonStyle
\inqmlmodule QtQuick.Controls.Styles 1.0
\since QtQuick.Controls.Styles 1.0
+ \ingroup controlsstyling
\brief Provides custom styling for Button
You can create a custom button by replacing the "background" delegate
@@ -72,7 +73,7 @@ import QtQuick.Controls.Private 1.0
If you need a custom label, you can replace the label item.
*/
-PaddedStyle {
+Style {
id: buttonstyle
/*! The \l Button attached to this style. */
@@ -92,7 +93,7 @@ PaddedStyle {
bottom: 4
}
- /*! The background of the button. */
+ /*! This defines the background of the button. */
property Component background: Item {
implicitWidth: 100
implicitHeight: 25
@@ -129,7 +130,7 @@ PaddedStyle {
}
}
- /*! The label of the button. */
+ /*! This defines the label of the button. */
property Component label: Text {
renderType: Text.NativeRendering
verticalAlignment: Text.AlignVCenter
diff --git a/src/styles/Base/CheckBoxStyle.qml b/src/styles/Base/CheckBoxStyle.qml
index 1323aa85..6aa6f9b5 100644
--- a/src/styles/Base/CheckBoxStyle.qml
+++ b/src/styles/Base/CheckBoxStyle.qml
@@ -45,13 +45,14 @@ import QtQuick.Controls.Private 1.0
\qmltype CheckBoxStyle
\inqmlmodule QtQuick.Controls.Styles 1.0
\since QtQuick.Controls.Styles 1.0
+ \ingroup controlsstyling
\brief Provides custom styling for CheckBox
Example:
\qml
CheckBox {
text: "Check Box"
- style: CheckBoxStyle{
+ style: CheckBoxStyle {
indicator: Rectangle {
implicitWidth: 16
implicitHeight: 16
@@ -66,13 +67,12 @@ import QtQuick.Controls.Private 1.0
anchors.margins: 4
anchors.fill: parent
}
- }
}
}
}
\endqml
*/
-PaddedStyle {
+Style {
id: checkboxStyle
/*! The \l CheckBox attached to this style. */
@@ -83,7 +83,7 @@ PaddedStyle {
SystemPalette.Active : SystemPalette.Disabled
}
- /*! The text label. */
+ /*! This defines the text label. */
property Component label: Text {
text: control.text
color: __syspal.text
@@ -102,7 +102,7 @@ PaddedStyle {
/*! The spacing between indicator and label. */
property int spacing: 4
- /*! The indicator button. */
+ /*! This defines the indicator button. */
property Component indicator: Item {
implicitWidth: 18
implicitHeight: 18
diff --git a/src/styles/Base/ComboBoxStyle.qml b/src/styles/Base/ComboBoxStyle.qml
index 9795d1a8..7984a329 100644
--- a/src/styles/Base/ComboBoxStyle.qml
+++ b/src/styles/Base/ComboBoxStyle.qml
@@ -46,10 +46,11 @@ import QtQuick.Controls.Private 1.0
\qmltype ComboBoxStyle
\inqmlmodule QtQuick.Controls.Styles 1.0
\since QtQuick.Controls.Styles 1.0
+ \ingroup controlsstyling
\brief Provides custom styling for ComboBox
*/
-PaddedStyle {
+Style {
/*! \internal */
property var __syspal: SystemPalette {
@@ -62,7 +63,7 @@ PaddedStyle {
/*! The padding between the background and the label components. */
padding { top: 4 ; left: 6 ; right: 6 ; bottom:4 }
- /*! The background of the button. */
+ /*! This defines the background of the button. */
property Component background: Item {
implicitWidth: 100
implicitHeight: 25
@@ -98,7 +99,7 @@ PaddedStyle {
}
}
- /*! The label of the button. */
+ /*! This defines the label of the button. */
property Component label: Item {
implicitWidth: textitem.implicitWidth + 20
Text {
diff --git a/src/styles/Base/GroupBoxStyle.qml b/src/styles/Base/GroupBoxStyle.qml
index 86fc83fe..1c3acada 100644
--- a/src/styles/Base/GroupBoxStyle.qml
+++ b/src/styles/Base/GroupBoxStyle.qml
@@ -45,9 +45,10 @@ import QtQuick.Controls.Private 1.0
\qmltype GroupBoxStyle
\internal
\inqmlmodule QtQuick.Controls.Styles 1.0
+ \ingroup controlsstyling
\since QtQuick.Controls.Styles 1.0
*/
-PaddedStyle {
+Style {
/*! \internal */
property var __syspal: SystemPalette {
diff --git a/src/styles/Base/MenuBarStyle.qml b/src/styles/Base/MenuBarStyle.qml
index e5b91be6..4effd6ee 100644
--- a/src/styles/Base/MenuBarStyle.qml
+++ b/src/styles/Base/MenuBarStyle.qml
@@ -45,6 +45,7 @@ import "../../Private/style.js" as StyleHelpers
/*!
\qmltype MenuBarStyle
\internal
+ \ingroup applicationwindowstyling
\inqmlmodule QtQuick.Controls.Styles 1.0
*/
diff --git a/src/styles/Base/MenuStyle.qml b/src/styles/Base/MenuStyle.qml
index 69dffc73..eab18f7d 100644
--- a/src/styles/Base/MenuStyle.qml
+++ b/src/styles/Base/MenuStyle.qml
@@ -43,6 +43,13 @@ import QtQuick.Controls 1.0
import QtQuick.Controls.Private 1.0
import "../../Private/style.js" as StyleHelpers
+/*!
+ \qmltype MenuStyle
+ \internal
+ \ingroup menusstyling
+ \inqmlmodule QtQuick.Controls.Styles 1.0
+*/
+
Style {
id: styleRoot
diff --git a/src/styles/Base/ProgressBarStyle.qml b/src/styles/Base/ProgressBarStyle.qml
index 1d7c98a8..ada97c10 100644
--- a/src/styles/Base/ProgressBarStyle.qml
+++ b/src/styles/Base/ProgressBarStyle.qml
@@ -47,6 +47,7 @@ import QtQuick.Controls.Private 1.0
\inqmlmodule QtQuick.Controls.Styles 1.0
\since QtQuick.Controls.Styles 1.0
+ \ingroup controlsstyling
\brief Provides custom styling for ProgressBar
Example:
@@ -71,7 +72,7 @@ import QtQuick.Controls.Private 1.0
\endqml
*/
-PaddedStyle {
+Style {
id: progressBarStyle
/*! \internal */
@@ -89,11 +90,14 @@ PaddedStyle {
/*! This property holds the visible contents of the progress bar
You can access the Slider through the \c control property.
- For convenience, you can also access the readonly property \c controlState.progress
+ For convenience, you can also access the readonly property \c styleData.progress
which provides the current progress as a \c real in the range [0-1]
*/
padding { top: 0 ; left: 0 ; right: 0 ; bottom: 0 }
+ /*! \qmlproperty Component ProgressBarStyle::progress
+ The progress component for this style.
+ */
property Component progress: Rectangle {
property color progressColor: "#49d"
anchors.fill: parent
@@ -129,6 +133,9 @@ PaddedStyle {
}
}
+ /*! \qmlproperty Component ProgressBarStyle::background
+ The background component for this style.
+ */
property Component background: Item {
implicitWidth: 200
implicitHeight: 24
@@ -145,6 +152,9 @@ PaddedStyle {
}
}
+ /*! \qmlproperty Component ProgressBarStyle::panel
+ The panel component for this style.
+ */
property Component panel: Item{
property bool horizontal: control.orientation == Qt.Horizontal
implicitWidth: horizontal ? backgroundLoader.implicitWidth : backgroundLoader.implicitHeight
diff --git a/src/styles/Base/RadioButtonStyle.qml b/src/styles/Base/RadioButtonStyle.qml
index 49d15e3d..ef3f2229 100644
--- a/src/styles/Base/RadioButtonStyle.qml
+++ b/src/styles/Base/RadioButtonStyle.qml
@@ -45,13 +45,14 @@ import QtQuick.Controls.Private 1.0
\qmltype RadioButtonStyle
\inqmlmodule QtQuick.Controls.Styles 1.0
\since QtQuick.Controls.Styles 1.0
+ \ingroup controlsstyling
\brief Provides custom styling for RadioButton
Example:
\qml
RadioButton {
text: "Radio Button"
- style: RadioButtonStyle{
+ style: RadioButtonStyle {
indicator: Rectangle {
implicitWidth: 16
implicitHeight: 16
@@ -65,14 +66,13 @@ import QtQuick.Controls.Private 1.0
radius: 9
anchors.margins: 4
}
- }
}
}
- }
+ }
\endqml
*/
-PaddedStyle {
+Style {
id: radiobuttonStyle
/*! \internal */
@@ -83,7 +83,7 @@ PaddedStyle {
/*! The \l RadioButton attached to this style. */
readonly property RadioButton control: __control
- /*! The text label. */
+ /*! This defines the text label. */
property Component label: Text {
text: control.text
renderType: Text.NativeRendering
@@ -97,7 +97,7 @@ PaddedStyle {
/*! The spacing between indicator and label. */
property int spacing: 4
- /*! The indicator button. */
+ /*! This defines the indicator button. */
property Component indicator: Rectangle {
width: 17
height: 17
diff --git a/src/styles/Base/ScrollViewStyle.qml b/src/styles/Base/ScrollViewStyle.qml
index 8bf5a120..ed7dd171 100644
--- a/src/styles/Base/ScrollViewStyle.qml
+++ b/src/styles/Base/ScrollViewStyle.qml
@@ -45,9 +45,10 @@ import QtQuick.Controls.Private 1.0
\qmltype ScrollViewStyle
\inqmlmodule QtQuick.Controls.Styles 1.0
\since QtQuick.Controls.Styles 1.0
+ \ingroup viewsstyling
\brief Provides custom styling for ScrollView
*/
-PaddedStyle {
+Style {
id: root
/*! \internal */
@@ -95,10 +96,12 @@ PaddedStyle {
/*! This component controls the appearance of the
scroll bar background.
- \list
- \li property bool hovered
- \li property bool horizontal
- \endlist
+ You can access the following state properties:
+
+ \table
+ \row \li property bool \b styleData.hovered
+ \row \li property bool \b styleData.horizontal
+ \endtable
*/
property Component scrollBarBackground: Item {
@@ -109,26 +112,28 @@ PaddedStyle {
anchors.fill: parent
color: "#ddd"
border.color: "#aaa"
- anchors.rightMargin: horizontal ? -2 : -1
- anchors.leftMargin: horizontal ? -2 : 0
- anchors.topMargin: horizontal ? 0 : -2
- anchors.bottomMargin: horizontal ? -1 : -2
+ anchors.rightMargin: styleData.horizontal ? -2 : -1
+ anchors.leftMargin: styleData.horizontal ? -2 : 0
+ anchors.topMargin: styleData.horizontal ? 0 : -2
+ anchors.bottomMargin: styleData.horizontal ? -1 : -2
}
}
/*! This component controls the appearance of the
scroll bar handle.
- \list
- \li property bool hovered
- \li property bool pressed
- \li property bool horizontal
- \endlist
+ You can access the following state properties:
+
+ \table
+ \row \li property bool \b styleData.hovered
+ \row \li property bool \b styleData.pressed
+ \row \li property bool \b styleData.horizontal
+ \endtable
*/
property Component handle: BorderImage{
- opacity: pressed ? 0.5 : hovered ? 1 : 0.8
- source: "images/scrollbar-handle-" + (horizontal ? "horizontal" : "vertical") + ".png"
+ opacity: styleData.pressed ? 0.5 : styleData.hovered ? 1 : 0.8
+ source: "images/scrollbar-handle-" + (styleData.horizontal ? "horizontal" : "vertical") + ".png"
border.left: 2
border.top: 2
border.right: 2
@@ -140,11 +145,11 @@ PaddedStyle {
You can access the following state properties:
- \list
- \li property bool hovered
- \li property bool pressed
- \li property bool horizontal
- \endlist
+ \table
+ \row \li property bool \b styleData.hovered
+ \row \li property bool \b styleData.pressed
+ \row \li property bool \b styleData.horizontal
+ \endtable
*/
property Component incrementControl: Rectangle {
implicitWidth: 16
@@ -161,13 +166,13 @@ PaddedStyle {
border.color: "#88ffffff"
}
Image {
- source: horizontal ? "images/arrow-right.png" : "images/arrow-down.png"
+ source: styleData.horizontal ? "images/arrow-right.png" : "images/arrow-down.png"
anchors.centerIn: parent
opacity: control.enabled ? 0.7 : 0.5
}
gradient: Gradient {
- GradientStop {color: pressed ? "lightgray" : "white" ; position: 0}
- GradientStop {color: pressed ? "lightgray" : "lightgray" ; position: 1}
+ GradientStop {color: styleData.pressed ? "lightgray" : "white" ; position: 0}
+ GradientStop {color: styleData.pressed ? "lightgray" : "lightgray" ; position: 1}
}
}
}
@@ -175,21 +180,23 @@ PaddedStyle {
/*! This component controls the appearance of the
scroll bar decrement button.
- \list
- \li property bool hovered
- \li property bool pressed
- \li property bool horizontal
- \endlist
+ You can access the following state properties:
+
+ \table
+ \row \li property bool \b styleData.hovered
+ \row \li property bool \b styleData.pressed
+ \row \li property bool \b styleData.horizontal
+ \endtable
*/
property Component decrementControl: Rectangle {
implicitWidth: 16
implicitHeight: 16
Rectangle {
anchors.fill: parent
- anchors.topMargin: horizontal ? 0 : -1
- anchors.leftMargin: horizontal ? -1 : 0
- anchors.bottomMargin: horizontal ? -1 : 0
- anchors.rightMargin: horizontal ? 0 : -1
+ anchors.topMargin: styleData.horizontal ? 0 : -1
+ anchors.leftMargin: styleData.horizontal ? -1 : 0
+ anchors.bottomMargin: styleData.horizontal ? -1 : 0
+ anchors.rightMargin: styleData.horizontal ? 0 : -1
color: "lightgray"
Rectangle {
anchors.fill: parent
@@ -198,15 +205,15 @@ PaddedStyle {
border.color: "#88ffffff"
}
Image {
- source: horizontal ? "images/arrow-left.png" : "images/arrow-up.png"
+ source: styleData.horizontal ? "images/arrow-left.png" : "images/arrow-up.png"
anchors.centerIn: parent
- anchors.verticalCenterOffset: horizontal ? 0 : -1
- anchors.horizontalCenterOffset: horizontal ? -1 : 0
+ anchors.verticalCenterOffset: styleData.horizontal ? 0 : -1
+ anchors.horizontalCenterOffset: styleData.horizontal ? -1 : 0
opacity: control.enabled ? 0.7 : 0.5
}
gradient: Gradient {
- GradientStop {color: pressed ? "lightgray" : "white" ; position: 0}
- GradientStop {color: pressed ? "lightgray" : "lightgray" ; position: 1}
+ GradientStop {color: styleData.pressed ? "lightgray" : "white" ; position: 0}
+ GradientStop {color: styleData.pressed ? "lightgray" : "lightgray" ; position: 1}
}
border.color: "#aaa"
}
@@ -217,14 +224,13 @@ PaddedStyle {
id: panel
property string activeControl: ""
property bool scrollToClickPosition: true
- property var controlStateRef: controlState
- implicitWidth: controlState.horizontal ? 200 : bg.implicitWidth
- implicitHeight: controlState.horizontal ? bg.implicitHeight : 200
+ implicitWidth: __styleData.horizontal ? 200 : bg.implicitWidth
+ implicitHeight: __styleData.horizontal ? bg.implicitHeight : 200
function pixelMetric(arg) {
if (arg === "scrollbarExtent")
- return (controlState.horizontal ? bg.height : bg.width);
+ return (__styleData.horizontal ? bg.height : bg.width);
return 0;
}
@@ -240,7 +246,7 @@ PaddedStyle {
else if (itemIsHit(decrementLoader, argX, argY))
return "down";
else if (itemIsHit(bg, argX, argY)) {
- if (controlState.horizontal && argX < handleControl.x || !controlState.horizontal && argY < handleControl.y)
+ if (__styleData.horizontal && argX < handleControl.x || !__styleData.horizontal && argY < handleControl.y)
return "upPage"
else
return "downPage"
@@ -253,7 +259,7 @@ PaddedStyle {
if (arg === "handle") {
return Qt.rect(handleControl.x, handleControl.y, handleControl.width, handleControl.height);
} else if (arg === "groove") {
- if (controlState.horizontal) {
+ if (__styleData.horizontal) {
return Qt.rect(incrementLoader.width - handleOverlap,
0,
__control.width - (incrementLoader.width + decrementLoader.width - handleOverlap * 2),
@@ -278,49 +284,57 @@ PaddedStyle {
anchors.top: parent.top
anchors.left: parent.left
sourceComponent: decrementControl
- property bool hovered: activeControl === "up"
- property bool pressed: controlState.upPressed
- property bool horizontal: controlState.horizontal
+ property QtObject styleData: QtObject {
+ readonly property bool hovered: activeControl === "up"
+ readonly property bool pressed: __styleData.upPressed
+ readonly property bool horizontal: __styleData.horizontal
+ }
}
Loader {
id: bg
- anchors.top: controlState.horizontal ? undefined : incrementLoader.bottom
- anchors.bottom: controlState.horizontal ? undefined : decrementLoader.top
- anchors.left: controlState.horizontal ? incrementLoader.right : undefined
- anchors.right: controlState.horizontal ? decrementLoader.left : undefined
+ anchors.top: __styleData.horizontal ? undefined : incrementLoader.bottom
+ anchors.bottom: __styleData.horizontal ? undefined : decrementLoader.top
+ anchors.left: __styleData.horizontal ? incrementLoader.right : undefined
+ anchors.right: __styleData.horizontal ? decrementLoader.left : undefined
sourceComponent: scrollBarBackground
- property bool horizontal: controlState.horizontal
- property bool hovered: activeControl !== "none"
+ property QtObject styleData: QtObject {
+ readonly property bool horizontal: __styleData.horizontal
+ readonly property bool hovered: activeControl !== "none"
+ }
}
Loader {
id: decrementLoader
- anchors.bottom: controlState.horizontal ? undefined : parent.bottom
- anchors.right: controlState.horizontal ? parent.right : undefined
+ anchors.bottom: __styleData.horizontal ? undefined : parent.bottom
+ anchors.right: __styleData.horizontal ? parent.right : undefined
sourceComponent: incrementControl
- property bool hovered: activeControl === "down"
- property bool pressed: controlState.downPressed
- property bool horizontal: controlState.horizontal
+ property QtObject styleData: QtObject {
+ readonly property bool hovered: activeControl === "down"
+ readonly property bool pressed: __styleData.downPressed
+ readonly property bool horizontal: __styleData.horizontal
+ }
}
property var flickableItem: control.flickableItem
- property int extent: Math.max(minimumHandleLength, controlState.horizontal ?
+ property int extent: Math.max(minimumHandleLength, __styleData.horizontal ?
(flickableItem ? flickableItem.width/flickableItem.contentWidth : 0 ) * bg.width :
(flickableItem ? flickableItem.height/flickableItem.contentHeight : 0) * bg.height)
Loader {
id: handleControl
- height: controlState.horizontal ? implicitHeight : extent
- width: controlState.horizontal ? extent : implicitWidth
+ height: __styleData.horizontal ? implicitHeight : extent
+ width: __styleData.horizontal ? extent : implicitWidth
anchors.top: bg.top
anchors.left: bg.left
- anchors.topMargin: controlState.horizontal ? 0 : -handleOverlap + (__control.value / __control.maximumValue) * (bg.height + 2 * handleOverlap- height)
- anchors.leftMargin: controlState.horizontal ? -handleOverlap + (__control.value / __control.maximumValue) * (bg.width + 2 * handleOverlap - width) : 0
+ anchors.topMargin: __styleData.horizontal ? 0 : -handleOverlap + (__control.value / __control.maximumValue) * (bg.height + 2 * handleOverlap- height)
+ anchors.leftMargin: __styleData.horizontal ? -handleOverlap + (__control.value / __control.maximumValue) * (bg.width + 2 * handleOverlap - width) : 0
sourceComponent: handle
- property bool hovered: activeControl === "handle"
- property bool pressed: controlState.handlePressed
- property bool horizontal: controlState.horizontal
+ property QtObject styleData: QtObject {
+ readonly property bool hovered: activeControl === "handle"
+ readonly property bool pressed: __styleData.handlePressed
+ readonly property bool horizontal: __styleData.horizontal
+ }
}
}
diff --git a/src/styles/Base/SliderStyle.qml b/src/styles/Base/SliderStyle.qml
index 7870e2f2..a6df15c0 100644
--- a/src/styles/Base/SliderStyle.qml
+++ b/src/styles/Base/SliderStyle.qml
@@ -45,6 +45,7 @@ import QtQuick.Controls.Private 1.0
\qmltype SliderStyle
\inqmlmodule QtQuick.Controls.Styles 1.0
\since QtQuick.Controls.Styles 1.0
+ \ingroup controlsstyling
\brief Provides custom styling for Slider
The slider style allows you to create a custom appearance for
@@ -78,7 +79,7 @@ import QtQuick.Controls.Private 1.0
}
\endqml
*/
-PaddedStyle {
+Style {
id: styleitem
/*! \internal */
@@ -121,7 +122,8 @@ PaddedStyle {
}
/*! This property holds the background groove of the slider.
- You can access the handle position through the \c handlePosition property.
+
+ You can access the handle position through the \c styleData.handlePosition property.
*/
property Component groove: Item {
anchors.verticalCenter: parent.verticalCenter
@@ -163,7 +165,9 @@ PaddedStyle {
Loader {
id: grooveLoader
- property int handlePosition: handleLoader.x + handleLoader.width/2
+ property QtObject styleData: QtObject {
+ readonly property int handlePosition: handleLoader.x + handleLoader.width/2
+ }
x: padding.left
sourceComponent: groove
width: (horizontal ? parent.width : parent.height) - padding.left - padding.right
diff --git a/src/styles/Base/SpinBoxStyle.qml b/src/styles/Base/SpinBoxStyle.qml
index 9b37fe5b..931db588 100644
--- a/src/styles/Base/SpinBoxStyle.qml
+++ b/src/styles/Base/SpinBoxStyle.qml
@@ -46,10 +46,11 @@ import QtQuick.Controls.Private 1.0
\internal
\inqmlmodule QtQuick.Controls.Styles 1.0
\since QtQuick.Controls.Styles 1.0
+ \ingroup controlsstyling
\brief Provides custom styling for SpinBox
*/
-PaddedStyle {
+Style {
id: spinboxStyle
/*! The \l SpinBox attached to this style. */
@@ -129,7 +130,7 @@ PaddedStyle {
/*! \internal */
property Component panel: Item {
id: styleitem
- implicitWidth: controlState.contentWidth + 26
+ implicitWidth: styleData.contentWidth + 26
implicitHeight: backgroundLoader.implicitHeight
property color foregroundColor: spinboxStyle.textColor
diff --git a/src/styles/Base/StatusBarStyle.qml b/src/styles/Base/StatusBarStyle.qml
index 049b15f2..f8ffffd9 100644
--- a/src/styles/Base/StatusBarStyle.qml
+++ b/src/styles/Base/StatusBarStyle.qml
@@ -44,16 +44,20 @@ import QtQuick.Controls.Private 1.0
/*!
\qmltype StatusBarStyle
\internal
+ \ingroup applicationwindowstyling
\inqmlmodule QtQuick.Controls.Styles 1.0
\since QtQuick.Controls.Styles 1.0
*/
-Item {
- implicitHeight: 22
- implicitWidth: 200
+Style {
- Rectangle {
+ padding.left: 3
+ padding.right: 3
+ padding.top: 3
+ padding.bottom: 2
- anchors.fill: parent
+ property Component panel: Rectangle {
+ implicitHeight: 16
+ implicitWidth: 200
gradient: Gradient{
GradientStop{color: "#eee" ; position: 0}
diff --git a/src/styles/Base/TabViewStyle.qml b/src/styles/Base/TabViewStyle.qml
index dfe1e4e9..f5cd1047 100644
--- a/src/styles/Base/TabViewStyle.qml
+++ b/src/styles/Base/TabViewStyle.qml
@@ -45,6 +45,7 @@ import QtQuick.Controls.Private 1.0
\qmltype TabViewStyle
\inqmlmodule QtQuick.Controls.Styles 1.0
\since QtQuick.Controls.Styles 1.0
+ \ingroup viewsstyling
\brief Provides custom styling for TabView
\qml
@@ -59,7 +60,7 @@ import QtQuick.Controls.Private 1.0
style: TabViewStyle {
frameOverlap: 1
tab: Rectangle {
- color: tab.selected ? "steelblue" :"lightsteelblue"
+ color: styleData.selected ? "steelblue" :"lightsteelblue"
border.color: "steelblue"
implicitWidth: Math.max(text.width + 4, 80)
implicitHeight: 20
@@ -67,8 +68,8 @@ import QtQuick.Controls.Private 1.0
Text {
id: text
anchors.centerIn: parent
- text: tab.title
- color: tab.selected ? "white" : "black"
+ text: styleData.title
+ color: styleData.selected ? "white" : "black"
}
}
frame: Rectangle { color: "steelblue" }
@@ -119,23 +120,24 @@ Style {
}
/*! This defines the tab. You can access the tab state through the
- \c tab property, with the following properties:
+ \c styleData property, with the following properties:
\table
- \li readonly property int index - This is the current tab index.
- \li readonly property bool selected - This is the active tab.
- \li readonly property string title - Tab title text.
- \li readonly property bool nextSelected - The next tab is selected.
- \li readonly property bool previousSelected - The previous tab is selected.
- \li readonly property bool hovered - The tab is currently under the mouse.
- \li readonly property bool activeFocus - The tab button has keyboard focus.
+ \row \li readonly property int \b styleData.index \li This is the current tab index.
+ \row \li readonly property bool \b styleData.selected \li This is the active tab.
+ \row \li readonly property string \b styleData.title \li Tab title text.
+ \row \li readonly property bool \b styleData.nextSelected \li The next tab is selected.
+ \row \li readonly property bool \b styleData.previousSelected \li The previous tab is selected.
+ \row \li readonly property bool \b styleData.hovered \li The tab is being hovered.
+ \row \li readonly property bool \b styleData.activeFocus \li The tab button has keyboard focus.
+ \row \li readonly property bool \b styleData.availableWidth \li The available width for the tabs.
\endtable
*/
property Component tab: Item {
scale: control.tabPosition === Qt.TopEdge ? 1 : -1
property int totalOverlap: tabOverlap * (control.count - 1)
- property real maxTabWidth: (availableWidth + totalOverlap) / control.count
+ property real maxTabWidth: (styleData.availableWidth + totalOverlap) / control.count
implicitWidth: Math.round(Math.min(maxTabWidth, textitem.implicitWidth + 20))
implicitHeight: Math.round(textitem.implicitHeight + 10)
@@ -143,16 +145,16 @@ Style {
clip: true
Item {
anchors.fill: parent
- anchors.bottomMargin: tab.selected ? 0 : 2
+ anchors.bottomMargin: styleData.selected ? 0 : 2
clip: true
BorderImage {
anchors.fill: parent
- source: tab.selected ? "images/tab_selected.png" : "images/tab.png"
+ source: styleData.selected ? "images/tab_selected.png" : "images/tab.png"
border.top: 6
border.bottom: 6
border.left: 6
border.right: 6
- anchors.topMargin: tab.selected ? 0 : 1
+ anchors.topMargin: styleData.selected ? 0 : 1
}
BorderImage {
anchors.fill: parent
@@ -160,7 +162,7 @@ Style {
anchors.leftMargin: -2
anchors.rightMargin: -1
source: "images/focusframe.png"
- visible: tab.activeFocus && tab.selected
+ visible: styleData.activeFocus && styleData.selected
border.left: 4
border.right: 4
border.top: 4
@@ -170,7 +172,7 @@ Style {
Text {
id: textitem
anchors.centerIn: parent
- text: tab.title
+ text: styleData.title
renderType: Text.NativeRendering
scale: control.tabPosition === Qt.TopEdge ? 1 : -1
color: __syspal.text
diff --git a/src/styles/Base/TableViewStyle.qml b/src/styles/Base/TableViewStyle.qml
index 669b934f..ff7237b0 100644
--- a/src/styles/Base/TableViewStyle.qml
+++ b/src/styles/Base/TableViewStyle.qml
@@ -45,6 +45,7 @@ import QtQuick.Controls.Private 1.0
\qmltype TableViewStyle
\inqmlmodule QtQuick.Controls.Styles 1.0
\since QtQuick.Controls.Styles 1.0
+ \ingroup viewsstyling
\brief Provides custom styling for TableView
Note that this class derives from \l ScrollViewStyle
@@ -59,7 +60,13 @@ ScrollViewStyle {
/*! The text color. */
property color textColor: __syspal.text
- /*! The text highlight color, used behind selections. */
+ /*! The background color. */
+ property color backgroundColor: __syspal.base
+
+ /*! The alternate background color. */
+ property color alternateBackgroundColor: Qt.darker(__syspal.base, 1.06)
+
+ /*! The text highlight color, used within selections. */
property color highlightedTextColor: "white"
/*! Activates items on single click. */
@@ -67,15 +74,19 @@ ScrollViewStyle {
padding.top: control.headerVisible ? 0 : 1
- /* Delegate for header. This delegate is described in \l TableView::headerDelegate */
+ /*! \qmlproperty Component TableViewStyle::headerDelegate
+ Delegate for header. This delegate is described in \l {TableView::headerDelegate}
+ */
property Component headerDelegate: BorderImage {
source: "images/header.png"
+ border.left: 4
Text {
anchors.fill: parent
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignLeft
- anchors.leftMargin: 4
- text: itemValue
+ anchors.leftMargin: 12
+ text: styleData.value
+ elide: Text.ElideRight
color: textColor
renderType: Text.NativeRendering
}
@@ -89,52 +100,63 @@ ScrollViewStyle {
}
}
- /* Delegate for header. This delegate is described in \l TableView::rowDelegate */
+ /*! \qmlproperty Component TableViewStyle::rowDelegate
+ Delegate for header. This delegate is described in \l {TableView::rowDelegate}
+ */
property Component rowDelegate: Rectangle {
- implicitHeight: 20
- implicitWidth: 80
- property color selectedColor: hasActiveFocus ? "#38d" : "#999"
+ height: 20
+ property color selectedColor: styleData.hasActiveFocus ? "#38d" : "#999"
gradient: Gradient {
- GradientStop { color: rowSelected ? Qt.lighter(selectedColor, 1.3) : alternateBackground ? "#f2f2f2" : "white" ; position: 0 }
- GradientStop { color: rowSelected ? Qt.lighter(selectedColor, 1.0) : alternateBackground ? "#f2f2f2" : "white" ; position: 1 }
+ GradientStop {
+ color: styleData.selected ? Qt.lighter(selectedColor, 1.3) :
+ styleData.alternate ? alternateBackgroundColor : backgroundColor
+ position: 0
+ }
+ GradientStop {
+ color: styleData.selected ? Qt.lighter(selectedColor, 1.0) :
+ styleData.alternate ? alternateBackgroundColor : backgroundColor
+ position: 1
+ }
}
Rectangle {
anchors.bottom: parent.bottom
width: parent.width
height: 1
- color: rowSelected ? Qt.darker(selectedColor, 1.4) : "transparent"
+ color: styleData.selected ? Qt.darker(selectedColor, 1.4) : "transparent"
}
Rectangle {
anchors.top: parent.top
width: parent.width ; height: 1
- color: rowSelected ? Qt.darker(selectedColor, 1.1) : "transparent"
+ color: styleData.selected ? Qt.darker(selectedColor, 1.1) : "transparent"
}
}
- /* Delegate for header. This delegate is described in \l TableView::itemDelegate */
+ /*! \qmlproperty Component TableViewStyle::itemDelegate
+ Delegate for item. This delegate is described in \l {TableView::itemDelegate}
+ */
property Component itemDelegate: Item {
height: Math.max(16, label.implicitHeight)
- property int implicitWidth: sizehint.paintedWidth + 4
+ property int implicitWidth: sizehint.paintedWidth + 20
Text {
id: label
objectName: "label"
width: parent.width
- anchors.margins: 6
+ anchors.leftMargin: 12
anchors.left: parent.left
anchors.right: parent.right
- horizontalAlignment: itemTextAlignment
+ horizontalAlignment: styleData.textAlignment
anchors.verticalCenter: parent.verticalCenter
anchors.verticalCenterOffset: 1
- elide: itemElideMode
- text: itemValue != undefined ? itemValue : ""
- color: itemTextColor
+ elide: styleData.elideMode
+ text: styleData.value != undefined ? styleData.value : ""
+ color: styleData.textColor
renderType: Text.NativeRendering
}
Text {
id: sizehint
font: label.font
- text: itemValue ? itemValue : ""
+ text: styleData.value ? styleData.value : ""
visible: false
}
}
diff --git a/src/styles/Base/TextFieldStyle.qml b/src/styles/Base/TextFieldStyle.qml
index 3c1a10a6..16d0fe94 100644
--- a/src/styles/Base/TextFieldStyle.qml
+++ b/src/styles/Base/TextFieldStyle.qml
@@ -45,6 +45,7 @@ import QtQuick.Controls.Private 1.0
\qmltype TextFieldStyle
\inqmlmodule QtQuick.Controls.Styles 1.0
\since QtQuick.Controls.Styles 1.0
+ \ingroup controlsstyling
\brief Provides custom styling for TextField.
Example:
@@ -64,7 +65,7 @@ import QtQuick.Controls.Private 1.0
\endqml
*/
-PaddedStyle {
+Style {
id: style
/*! \internal */
diff --git a/src/styles/Base/ToolBarStyle.qml b/src/styles/Base/ToolBarStyle.qml
index aa21195a..a5c03e7a 100644
--- a/src/styles/Base/ToolBarStyle.qml
+++ b/src/styles/Base/ToolBarStyle.qml
@@ -39,26 +39,36 @@
****************************************************************************/
import QtQuick 2.1
import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
/*!
\qmltype ToolBarStyle
\internal
+ \ingroup applicationwindowstyling
\inqmlmodule QtQuick.Controls.Styles 1.0
*/
-Item {
- implicitHeight: 42
- implicitWidth: 200
- Rectangle {
- anchors.fill: parent
- gradient: Gradient{
- GradientStop{color: "#eee" ; position: 0}
- GradientStop{color: "#ccc" ; position: 1}
- }
+Style {
+
+ padding.left: 6
+ padding.right: 6
+ padding.top: 3
+ padding.bottom: 3
+
+ property Component panel: Item {
+ implicitHeight: 40
+ implicitWidth: 200
Rectangle {
- anchors.bottom: parent.bottom
- width: parent.width
- height: 1
- color: "#999"
+ anchors.fill: parent
+ gradient: Gradient{
+ GradientStop{color: "#eee" ; position: 0}
+ GradientStop{color: "#ccc" ; position: 1}
+ }
+ Rectangle {
+ anchors.bottom: parent.bottom
+ width: parent.width
+ height: 1
+ color: "#999"
+ }
}
}
}
diff --git a/src/styles/Base/ToolButtonStyle.qml b/src/styles/Base/ToolButtonStyle.qml
index e8d05d6c..0ead0750 100644
--- a/src/styles/Base/ToolButtonStyle.qml
+++ b/src/styles/Base/ToolButtonStyle.qml
@@ -44,6 +44,7 @@ import QtQuick.Controls.Private 1.0
/*!
\qmltype ToolButtonStyle
\internal
+ \ingroup controlsstyling
\inqmlmodule QtQuick.Controls.Styles 1.0
*/
Style {
diff --git a/src/styles/Desktop/ButtonStyle.qml b/src/styles/Desktop/ButtonStyle.qml
index 3ae42c03..53c4ef7f 100644
--- a/src/styles/Desktop/ButtonStyle.qml
+++ b/src/styles/Desktop/ButtonStyle.qml
@@ -46,7 +46,7 @@ Style {
elementType: "button"
sunken: control.pressed || (control.checkable && control.checked)
raised: !(control.pressed || (control.checkable && control.checked))
- hover: control.__containsMouse
+ hover: control.hovered
text: control.iconSource === "" ? "" : control.text
hasFocus: control.activeFocus
hints: control.styleHints
@@ -54,7 +54,7 @@ Style {
activeControl: control.isDefault ? "default" : "f"
properties: {
- "icon": control.__action.__icon,
+ "icon": control.__iconAction.__icon,
"menu": control.menu
}
}
diff --git a/src/styles/Desktop/CheckBoxStyle.qml b/src/styles/Desktop/CheckBoxStyle.qml
index 65c517ba..9b19300f 100644
--- a/src/styles/Desktop/CheckBoxStyle.qml
+++ b/src/styles/Desktop/CheckBoxStyle.qml
@@ -52,19 +52,11 @@ Style {
elementType: "checkbox"
sunken: control.pressed
on: control.checked || control.pressed
- hover: control.__containsMouse
+ hover: control.hovered
enabled: control.enabled
hasFocus: control.activeFocus && styleitem.style == "mac"
- hints: {
- if (control.checkedState === Qt.PartiallyChecked)
- control.styleHints.push("partiallyChecked");
- else {
- var index = control.styleHints.indexOf("partiallyChecked");
- if (index !== -1)
- control.styleHints.splice(index, 1);
- }
- control.styleHints;
- }
+ hints: control.styleHints
+ properties: {"partiallyChecked": (control.checkedState === Qt.PartiallyChecked) }
contentHeight: textitem.implicitHeight
contentWidth: textitem.implicitWidth + indicatorWidth
property int indicatorWidth: pixelMetric("indicatorwidth") + (macStyle ? 2 : 4)
diff --git a/src/styles/Desktop/ComboBoxStyle.qml b/src/styles/Desktop/ComboBoxStyle.qml
index 78e52f53..95397641 100644
--- a/src/styles/Desktop/ComboBoxStyle.qml
+++ b/src/styles/Desktop/ComboBoxStyle.qml
@@ -58,7 +58,7 @@ Style {
elementType: "combobox"
sunken: control.pressed
raised: !sunken
- hover: control.__containsMouse
+ hover: control.hovered
enabled: control.enabled
// The style makes sure the text rendering won't overlap the decoration.
// In that case, 35 pixels margin in this case looks good enough. Worst
diff --git a/src/styles/Desktop/GroupBoxStyle.qml b/src/styles/Desktop/GroupBoxStyle.qml
index 3c4bfc43..81d6de86 100644
--- a/src/styles/Desktop/GroupBoxStyle.qml
+++ b/src/styles/Desktop/GroupBoxStyle.qml
@@ -42,7 +42,7 @@ import QtQuick.Controls 1.0
import QtQuick.Controls.Private 1.0
-PaddedStyle {
+Style {
readonly property GroupBox control: __control
property var __style: StyleItem { id: style }
@@ -55,10 +55,10 @@ PaddedStyle {
}
padding {
- top: (control.title.length > 0 || control.checkable ? titleHeight : 0) + 6
- left: 8
- right: 8
- bottom: 6
+ top: Math.round(Settings.dpiScaleFactor * (control.title.length > 0 || control.checkable ? titleHeight : 0) + (style.style == "mac" ? 9 : 6))
+ left: Math.round(Settings.dpiScaleFactor * 8)
+ right: Math.round(Settings.dpiScaleFactor * 8)
+ bottom: Math.round(Settings.dpiScaleFactor * 7 + (style.style.indexOf("windows") > -1 ? 2 : 0))
}
property Component panel: StyleItem {
diff --git a/src/styles/Desktop/RadioButtonStyle.qml b/src/styles/Desktop/RadioButtonStyle.qml
index c5a3c80d..b41b959a 100644
--- a/src/styles/Desktop/RadioButtonStyle.qml
+++ b/src/styles/Desktop/RadioButtonStyle.qml
@@ -56,7 +56,7 @@ Style {
anchors.verticalCenterOffset: macStyle ? -1 : 0
sunken: control.pressed
on: control.checked || control.pressed
- hover: control.__containsMouse
+ hover: control.hovered
enabled: control.enabled
hasFocus: control.activeFocus && styleitem.style == "mac"
hints: control.styleHints
diff --git a/src/styles/Desktop/ScrollViewStyle.qml b/src/styles/Desktop/ScrollViewStyle.qml
index 42c9fc3e..deddc354 100644
--- a/src/styles/Desktop/ScrollViewStyle.qml
+++ b/src/styles/Desktop/ScrollViewStyle.qml
@@ -42,7 +42,7 @@ import QtQuick.Controls 1.0
import QtQuick.Controls.Private 1.0
import "." as Desktop
-PaddedStyle {
+Style {
id: root
padding {
@@ -74,11 +74,11 @@ PaddedStyle {
elementType: "scrollbar"
hover: activeControl != "none"
activeControl: "none"
- sunken: __control.upPressed | __control.downPressed | __control.handlePressed
+ sunken: __styleData.upPressed | __styleData.downPressed | __styleData.handlePressed
minimum: __control.minimumValue
maximum: __control.maximumValue
value: __control.value
- horizontal: __control.orientation === Qt.Horizontal
+ horizontal: __styleData.horizontal
enabled: __control.enabled
implicitWidth: horizontal ? 200 : pixelMetric("scrollbarExtent")
diff --git a/src/styles/Desktop/SliderStyle.qml b/src/styles/Desktop/SliderStyle.qml
index 1c89d21c..fbe2cfb6 100644
--- a/src/styles/Desktop/SliderStyle.qml
+++ b/src/styles/Desktop/SliderStyle.qml
@@ -40,7 +40,7 @@
import QtQuick 2.1
import QtQuick.Controls.Private 1.0
-PaddedStyle {
+Style {
readonly property Item control: __control
property Component panel: StyleItem {
elementType: "slider"
diff --git a/src/styles/Desktop/SpinBoxStyle.qml b/src/styles/Desktop/SpinBoxStyle.qml
index 2da3db1f..24f51427 100644
--- a/src/styles/Desktop/SpinBoxStyle.qml
+++ b/src/styles/Desktop/SpinBoxStyle.qml
@@ -41,7 +41,7 @@ import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Controls.Private 1.0
-PaddedStyle {
+Style {
readonly property SpinBox control: __control
property var __syspal: SystemPalette {
@@ -50,11 +50,12 @@ PaddedStyle {
}
padding {
- top: control.__panel ? control.__panel.topPadding + (control.__panel.style === "mac" ? 1 : 0) : 0
+ top: control.__panel ? control.__panel.topPadding + (styleitem.style === "mac" ? 2 : 0) : 0
left: control.__panel ? control.__panel.leftPadding : 0
right: control.__panel ? control.__panel.rightPadding : 0
bottom: control.__panel ? control.__panel.bottomPadding : 0
}
+ StyleItem {id: styleitem ; visible: false}
property Component panel: Item {
id: style
@@ -114,17 +115,17 @@ PaddedStyle {
id: styleitem
elementType: "spinbox"
anchors.fill: parent
- sunken: (controlState.downEnabled && controlState.downPressed) || (controlState.upEnabled && controlState.upPressed)
- hover: controlState.containsMouse
+ sunken: (styleData.downEnabled && styleData.downPressed) || (styleData.upEnabled && styleData.upPressed)
+ hover: control.hovered
hints: control.styleHints
hasFocus: control.activeFocus
enabled: control.enabled
- value: (controlState.upPressed ? 1 : 0) |
- (controlState.downPressed ? 1<<1 : 0) |
- (controlState.upEnabled ? (1<<2) : 0) |
- (controlState.downEnabled ? (1<<3) : 0)
- contentWidth: controlState.contentWidth
- contentHeight: controlState.contentHeight
+ value: (styleData.upPressed ? 1 : 0) |
+ (styleData.downPressed ? 1<<1 : 0) |
+ (styleData.upEnabled ? (1<<2) : 0) |
+ (styleData.downEnabled ? (1<<3) : 0)
+ contentWidth: styleData.contentWidth
+ contentHeight: styleData.contentHeight
}
}
}
diff --git a/src/styles/Desktop/StatusBarStyle.qml b/src/styles/Desktop/StatusBarStyle.qml
index 6921a2fe..930ca773 100644
--- a/src/styles/Desktop/StatusBarStyle.qml
+++ b/src/styles/Desktop/StatusBarStyle.qml
@@ -46,11 +46,16 @@ import QtQuick.Controls.Private 1.0
\internal
\inqmlmodule QtQuick.Controls.Styles 1.0
*/
-Item {
- implicitHeight: 20
- implicitWidth: parent ? parent.width : style.implicitWidth
- StyleItem {
- id: style
+Style {
+
+ padding.left: 4
+ padding.right: 4
+ padding.top: 3
+ padding.bottom: 2
+
+ property Component panel: StyleItem {
+ implicitHeight: 16
+ implicitWidth: 200
anchors.fill: parent
elementType: "statusbar"
}
diff --git a/src/styles/Desktop/TabViewStyle.qml b/src/styles/Desktop/TabViewStyle.qml
index 455b99db..51b70ea4 100644
--- a/src/styles/Desktop/TabViewStyle.qml
+++ b/src/styles/Desktop/TabViewStyle.qml
@@ -51,7 +51,7 @@ Style {
property StyleItem __barstyle: StyleItem {
elementType: "tab"
- hints: [control.tabPosition === Qt.TopEdge ? "Top" : "Bottom"]
+ properties: { "tabposition" : (control.tabPosition === Qt.TopEdge ? "Top" : "Bottom") }
visible: false
}
@@ -65,6 +65,7 @@ Style {
minimum: tabbarItem && tabsVisible && tabbarItem.tab(currentIndex) ? tabbarItem.tab(currentIndex).width : 0
maximum: tabbarItem && tabsVisible ? tabbarItem.width : width
properties: { "selectedTabRect" : tabbarItem.__selectedTabRect, "orientation" : control.tabPosition }
+ hints: control.styleHints
Component.onCompleted: {
stack.frameWidth = styleitem.pixelMetric("defaultframewidth");
stack.style = style;
@@ -74,13 +75,13 @@ Style {
property Component tab: Item {
id: item
property string tabpos: control.count === 1 ? "only" : index === 0 ? "beginning" : index === control.count - 1 ? "end" : "middle"
- property string selectedpos: tab.nextSelected ? "next" : tab.previousSelected ? "previous" : ""
+ property string selectedpos: styleData.nextSelected ? "next" : styleData.previousSelected ? "previous" : ""
property string orientation: control.tabPosition === Qt.TopEdge ? "Top" : "Bottom"
property int tabHSpace: __barstyle.pixelMetric("tabhspace");
property int tabVSpace: __barstyle.pixelMetric("tabvspace");
property int totalOverlap: tabOverlap * (control.count - 1)
property real maxTabWidth: (control.width + totalOverlap) / control.count
- implicitWidth: Math.min(maxTabWidth, Math.max(50, styleitem.textWidth(tab.title)) + tabHSpace + 2)
+ implicitWidth: Math.min(maxTabWidth, Math.max(50, styleitem.textWidth(styleData.title)) + tabHSpace + 2)
implicitHeight: Math.max(styleitem.font.pixelSize + tabVSpace + 6, 0)
StyleItem {
@@ -94,12 +95,12 @@ Style {
anchors.rightMargin: -paintMargins
anchors.bottomMargin: -1
anchors.leftMargin: -paintMargins + (style === "mac" && selected ? -1 : 0)
- properties: { "hasFrame" : true }
- hints: [orientation, tabpos, selectedpos]
+ properties: { "hasFrame" : true, "orientation": orientation, "tabpos": tabpos, "selectedpos": selectedpos }
+ hints: control.styleHints
- selected: tab.selected
- text: elidedText(tab.title, tabbarItem.elide, item.width - item.tabHSpace)
- hover: tab.hovered
+ selected: styleData.selected
+ text: elidedText(styleData.title, tabbarItem.elide, item.width - item.tabHSpace)
+ hover: styleData.hovered
hasFocus: tabbarItem.activeFocus && selected
}
}
diff --git a/src/styles/Desktop/TableViewStyle.qml b/src/styles/Desktop/TableViewStyle.qml
index da6a47e5..171678a3 100644
--- a/src/styles/Desktop/TableViewStyle.qml
+++ b/src/styles/Desktop/TableViewStyle.qml
@@ -44,10 +44,15 @@ import QtQuick.Controls.Private 1.0
ScrollViewStyle {
id: root
+ property var __syspal: SystemPalette {
+ colorGroup: control.enabled ?
+ SystemPalette.Active : SystemPalette.Disabled
+ }
readonly property TableView control: __control
property bool activateItemOnSingleClick: __styleitem.styleHint("activateItemOnSingleClick")
- property color textColor: __styleitem.styleHint("textColor")
- property color highlightedTextColor: __styleitem.styleHint("highlightedTextColor")
+ property color textColor: __styleitem.textColor
+ property color backgroundColor: __syspal.base
+ property color highlightedTextColor: __styleitem.highlightedTextColor
property StyleItem __styleitem: StyleItem{
property color textColor: styleHint("textColor")
@@ -55,50 +60,59 @@ ScrollViewStyle {
elementType: "item"
visible: false
active: control.activeFocus
+ onActiveChanged: {
+ highlightedTextColor = styleHint("highlightedTextColor")
+ textColor = styleHint("textColor")
+ }
}
property Component headerDelegate: StyleItem {
elementType: "header"
activeControl: itemSort
raised: true
- sunken: itemPressed
- text: itemValue
- hover: itemContainsMouse
- hints: itemPosition
+ sunken: styleData.pressed
+ text: styleData.value
+ hover: styleData.containsMouse
+ hints: control.styleHints
+ properties: {"headerpos": headerPosition}
+ property string itemSort: (control.sortIndicatorVisible && styleData.column === control.sortIndicatorColumn) ? (control.sortIndicatorOrder == Qt.AscendingOrder ? "up" : "down") : "";
+ property string headerPosition: control.columnCount === 1 ? "only" :
+ styleData.column === control.columnCount-1 ? "end" :
+ styleData.column === 0 ? "beginning" : ""
}
property Component rowDelegate: StyleItem {
id: rowstyle
elementType: "itemrow"
- activeControl: alternateBackground ? "alternate" : ""
- selected: rowSelected ? true : false
+ activeControl: styleData.alternate ? "alternate" : ""
+ selected: styleData.selected ? true : false
height: Math.max(16, rowstyle.implicitHeight)
- active: hasActiveFocus
+ active: styleData.hasActiveFocus
}
property Component itemDelegate: Item {
height: Math.max(16, label.implicitHeight)
- property int implicitWidth: sizehint.paintedWidth + 4
+ property int implicitWidth: sizehint.paintedWidth + 16
Text {
id: label
objectName: "label"
width: parent.width
- anchors.margins: 6
+ anchors.leftMargin: 8
font: __styleitem.font
anchors.left: parent.left
anchors.right: parent.right
- horizontalAlignment: itemTextAlignment
+ horizontalAlignment: styleData.textAlignment
anchors.verticalCenter: parent.verticalCenter
- elide: itemElideMode
- text: itemValue != undefined ? itemValue : ""
- color: itemTextColor
+ elide: styleData.elideMode
+ text: styleData.value !== undefined ? styleData.value : ""
+ color: styleData.textColor
renderType: Text.NativeRendering
}
Text {
id: sizehint
font: label.font
- text: itemValue ? itemValue : ""
+ text: styleData.value ? styleData.value : ""
visible: false
}
}
diff --git a/src/styles/Desktop/TextFieldStyle.qml b/src/styles/Desktop/TextFieldStyle.qml
index 9a093d2a..8f71a45c 100644
--- a/src/styles/Desktop/TextFieldStyle.qml
+++ b/src/styles/Desktop/TextFieldStyle.qml
@@ -48,7 +48,7 @@ Style {
sunken: true
hasFocus: control.activeFocus
- hover: __containsMouse
+ hover: hovered
hints: control.styleHints
SystemPalette {
@@ -64,9 +64,9 @@ Style {
property color selectedTextColor: syspal.highlightedText
- property bool rounded: hints.indexOf("rounded") > -1
+ property bool rounded: !!hints["rounded"]
property int topMargin: style === "mac" ? 3 : 2
- property int leftMargin: rounded ? 8 : 4
+ property int leftMargin: rounded ? 12 : 4
property int rightMargin: leftMargin
property int bottomMargin: 2
@@ -76,7 +76,7 @@ Style {
FocusFrame {
anchors.fill: parent
- visible: textfield.activeFocus && textfieldstyle.styleHint("focuswidget")
+ visible: textfield.activeFocus && textfieldstyle.styleHint("focuswidget") && !rounded
}
}
}
diff --git a/src/styles/Desktop/ToolBarStyle.qml b/src/styles/Desktop/ToolBarStyle.qml
index 4c7e036e..56dfbce3 100644
--- a/src/styles/Desktop/ToolBarStyle.qml
+++ b/src/styles/Desktop/ToolBarStyle.qml
@@ -46,10 +46,16 @@ import QtQuick.Controls.Private 1.0
\internal
\inqmlmodule QtQuick.Controls.Styles 1.0
*/
-Item {
- implicitHeight: Math.max(childrenRect.height, toolbar.implicitHeight)
- implicitWidth: parent ? parent.width : toolbar.implicitWidth
- StyleItem {
+Style {
+
+ padding.left: 6
+ padding.right: 6
+ padding.top: 1
+ padding.bottom: style.style == "mac" ? 1 : 2
+
+ StyleItem { id: style ; visible: false}
+
+ property Component panel: StyleItem {
id: toolbar
anchors.fill: parent
elementType: "toolbar"
diff --git a/src/styles/Desktop/ToolButtonStyle.qml b/src/styles/Desktop/ToolButtonStyle.qml
index b54eeee2..54726962 100644
--- a/src/styles/Desktop/ToolButtonStyle.qml
+++ b/src/styles/Desktop/ToolButtonStyle.qml
@@ -46,16 +46,17 @@ Style {
anchors.fill: parent
elementType: "toolbutton"
- on: control.pressed || (control.checkable && control.checked)
- sunken: control.pressed || (control.checkable && control.checked)
- raised: !(control.checkable && control.checked) && control.__containsMouse
- hover: control.__containsMouse
+ on: control.checkable && control.checked
+ sunken: control.pressed
+ raised: !(control.checkable && control.checked) && control.hovered
+ hover: control.hovered
hasFocus: control.activeFocus
- hints: control.styleHints.concat([control.__position])
+ hints: control.styleHints
text: control.text
properties: {
- "icon": control.__action.__icon
+ "icon": control.__iconAction.__icon,
+ "position": control.__position
}
}
}
diff --git a/src/styles/doc/qtquickcontrolsstyles.qdocconf b/src/styles/doc/qtquickcontrolsstyles.qdocconf
new file mode 100644
index 00000000..6c1e51b1
--- /dev/null
+++ b/src/styles/doc/qtquickcontrolsstyles.qdocconf
@@ -0,0 +1,43 @@
+include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf)
+
+project = QtQuickControlsStyles
+description = Qt Quick Controls Styles Reference Documentation
+url = http://qt-project.org/doc/qt-$QT_VER/qtquickcontrolsstyles/
+version = $QT_VERSION
+
+qhp.projects = QtQuickControlsStyles
+
+qhp.QtQuickControlsStyles.file = qtquickcontrolsstyles.qhp
+qhp.QtQuickControlsStyles.namespace = org.qt-project.qtquickcontrolsstyles.$QT_VERSION_TAG
+qhp.QtQuickControlsStyles.virtualFolder = qtquickcontrolsstyles
+qhp.QtQuickControlsStyles.indexTitle = Qt Quick Controls Styles
+qhp.QtQuickControlsStyles.indexRoot =
+#qhp.QtQuickControlsStyles.extraFiles = style/qtquickcontrolsstyles.css
+
+qhp.QtQuickControlsStyles.filterAttributes = qtquickcontrolsstyles $QT_VERSION qtrefdoc
+qhp.QtQuickControlsStyles.customFilters.Qt.name = QtQuickControlsStyles $QT_VERSION
+qhp.QtQuickControlsStyles.customFilters.Qt.filterAttributes = qtquickcontrolsstyles $QT_VERSION
+
+qhp.QtQuickControlsStyles.subprojects = qtquickcontrolsstylesqmltypes
+qhp.QtQuickControlsStyles.subprojects.qtquickcontrolsstylesqmltypes.title = QML Types
+qhp.QtQuickControlsStyles.subprojects.qtquickcontrolsstylesqmltypes.indexTitle = Qt Quick Controls Styles QML Types
+qhp.QtQuickControlsStyles.subprojects.qtquickcontrolsstylesqmltypes.selectors = class fake:qmlclass
+qhp.QtQuickControlsStyles.subprojects.qtquickcontrolsstylesqmltypes.sortPages = true
+
+depends = qtqml qtquick qtwidgets qtdoc qtquicklayouts qtquickcontrols
+
+exampledirs += ../../../examples/quick/controlsstyles
+
+# Specify the install path under QT_INSTALL_EXAMPLES
+examplesinstallpath = quick/controlsstyles
+
+headerdirs += ../Base
+
+sourcedirs += ../Base
+
+sources += ../../private/qquickstyleitem.cpp \
+ ../../private/Style.qml \
+ ../../private/qquickabstractstyle.h \
+ ../../private/qquickabstractstyle.cpp
+
+imagedirs += images
diff --git a/src/styles/doc/src/qtquickcontrolsstyles-index.qdoc b/src/styles/doc/src/qtquickcontrolsstyles-index.qdoc
new file mode 100644
index 00000000..ed4a0082
--- /dev/null
+++ b/src/styles/doc/src/qtquickcontrolsstyles-index.qdoc
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 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$
+**
+****************************************************************************/
+
+
+
+/*!
+ \group applicationwindowstyling
+ \title Styling Application Window
+ \internal
+*/
+
+/*!
+ \group viewsstyling
+ \title Styling Views
+*/
+
+/*!
+ \group controlsstyling
+ \title Styling Controls
+*/
+
+/*!
+ \group menusstyling
+ \title Styling Menus
+ \internal
+*/
+
+
+/*!
+ \page qtquickcontrolsstyles-index.html
+ \title Qt Quick Controls Styles
+ \brief The Qt Quick Controls Styles submodule provides custom styles for Qt Quick Controls.
+
+ The Qt Quick Controls Styles submodule allows custom styling for \l {Qt Quick Controls}.
+
+ The submodule is new in Qt 5.1 and requires \l{Qt Quick} 2.1.
+
+ \section1 Getting started
+
+ The QML types can be imported into your application using the following import statement in your \c {.qml} file.
+
+ \code
+ import QtQuick.Controls.Styles 1.0
+ \endcode
+
+ \section1 Styling Views
+ \annotatedlist viewsstyling
+
+ \section1 Styling Controls
+ \annotatedlist controlsstyling
+
+ \section1 Related information
+
+ \list
+ \li \l{Qt Quick}
+ \li \l{Qt Quick Controls}
+ \li \l{Qt Quick Controls Styles QML Types}
+ \endlist
+
+*/
+
+/*!
+ \qmlmodule QtQuick.Controls.Styles 1
+ \title Qt Quick Controls Styles QML Types
+ \ingroup qmlmodules
+ \brief Provides QML types for Qt Quick Controls styles.
+
+ The \l{Qt Quick Controls} module provides a set of QML types for handling
+ styles.
+
+ Some of the controls allow custom styling similar to widget style sheets.
+ A styling object is usually a collection of properties that control behavior and simple delegates
+ that can be replaced with custom QML snippets.
+
+*/
diff --git a/src/styles/styles.pro b/src/styles/styles.pro
index 4c0ee5d3..158c1dd1 100644
--- a/src/styles/styles.pro
+++ b/src/styles/styles.pro
@@ -1,5 +1,7 @@
TARGETPATH = QtQuick/Controls/Styles
+QMAKE_DOCS = $$PWD/doc/qtquickcontrolsstyles.qdocconf
+
# Base
QML_FILES = \
Base/ButtonStyle.qml \
diff --git a/tests/auto/README.txt b/tests/auto/README.txt
new file mode 100644
index 00000000..948242f0
--- /dev/null
+++ b/tests/auto/README.txt
@@ -0,0 +1,38 @@
+
+Here are some tips if you need to run the Qt Quick Controls auto tests.
+
+ - Testplugin
+
+Some autotests require the test plugin under testplugin/QtQuickControlsTests.
+
+The test plugin is not installed (i.e. to the qml folder), so
+in order for the tst_controls to find it, you can either:
+
+- Run make check in the controls folder. The plugin will be found
+at run time because IMPORTPATH is defined in the pro file.
+
+- In Qt Creator run settings or in the console, set QML2_IMPORT_PATH
+macro to the testplugin path. At run time QML2_IMPORT_PATH is used by
+by qmlscene to find imports required.
+i.e: export QML2_IMPORT_PATH=<path_qtquickcontrols_git_clone>/tests/auto/testplugin
+
+- Use the -import command-line option:
+$ cd build/qt5/qtquickcontrols/tests/auto/controls
+$ ./tst_controls -import ../testplugin
+
+ - Running specific tests:
+
+i) It is possible to run a single file using the -input option. For example:
+
+$ ./tst_controls -input data/test.qml
+
+$ ./tst_controls -input <full_path>/test.qml
+
+Specifying the full path to the qml test file is for example needed for shadow builds.
+
+
+ii) The -functions command-line option will return a list of the current tests functions.
+It is possible to run a single test function using the name of the test function as an argument. For example:
+
+tst_controls Test_Name::function1
+
diff --git a/tests/auto/controls/data/tableview/table_activated.qml b/tests/auto/controls/data/tableview/table_activated.qml
index 52d420c4..227fbd88 100644
--- a/tests/auto/controls/data/tableview/table_activated.qml
+++ b/tests/auto/controls/data/tableview/table_activated.qml
@@ -42,11 +42,22 @@ import QtQuick 2.1
import QtQuick.Controls 1.0
TableView {
- height: 70
+ height: 120
model: 10
- property bool test: false
- onActivated: test = true
+ headerVisible: false
+ frameVisible: false
+ rowDelegate: Rectangle {
+ width: parent.width
+ height: 20
+ }
+
+ property int test: -1
+ property int testClick: -1
+ property int testDoubleClick: -1
+ onActivated: test = row
+ onClicked: testClick = row
+ onDoubleClicked: testDoubleClick = row
TableViewColumn {
width: 100
diff --git a/tests/auto/controls/data/tableview/table_delegate.qml b/tests/auto/controls/data/tableview/table_delegate.qml
index a3ab621d..82b08ba5 100644
--- a/tests/auto/controls/data/tableview/table_delegate.qml
+++ b/tests/auto/controls/data/tableview/table_delegate.qml
@@ -56,14 +56,14 @@ TableView {
}
headerDelegate: Text {
height: 40
- text: itemValue
+ text: styleData.value
}
itemDelegate: Text {
width: parent.width
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
- text: itemValue !== undefined ? itemValue : ""
- color: itemTextColor
+ text: styleData.value !== undefined ? styleData.value : ""
+ color: styleData.textColor
MouseArea {
anchors.fill: parent
onClicked: table.test = 1
diff --git a/tests/auto/controls/data/tableview/table_dynamiccolumns.qml b/tests/auto/controls/data/tableview/table_dynamiccolumns.qml
new file mode 100644
index 00000000..ce2cb93c
--- /dev/null
+++ b/tests/auto/controls/data/tableview/table_dynamiccolumns.qml
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+
+TableView {
+ id: tableView
+
+ TableViewColumn { title: "static" }
+
+ Component {
+ id: component
+ TableViewColumn { }
+ }
+
+ Component.onCompleted: {
+ addColumn(component.createObject(tableView, {title: "added item"}))
+
+ var col1 = addColumn(component)
+ col1.title = "added component"
+
+ insertColumn(0, component.createObject(tableView, {title: "inserted item"}))
+
+ var col2 = insertColumn(0, component)
+ col2.title = "inserted component"
+ }
+}
diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml
index c36218a3..4cb57351 100644
--- a/tests/auto/controls/data/tst_combobox.qml
+++ b/tests/auto/controls/data/tst_combobox.qml
@@ -217,20 +217,20 @@ TestCase {
}
function test_activeFocusOnPress(){
- if (Qt.platform.os === "mac")
+ if (Qt.platform.os === "osx")
skip("When the menu pops up on OS X, it does not return and the test fails after time out")
var comboBox = Qt.createQmlObject('import QtQuick.Controls 1.0 ; ComboBox { model: 4 }', container, '');
comboBox.activeFocusOnPress = false
verify(!comboBox.activeFocus)
- if (Qt.platform.os === "mac") // on mac when the menu open, the __popup function does not return
+ if (Qt.platform.os === "osx") // on mac when the menu open, the __popup function does not return
timer.start()
else // two mouse clicks to open and close the popup menu
mouseClick(comboBox, comboBox.x + 1, comboBox.y + 1)
mouseClick(comboBox, comboBox.x + 1, comboBox.y + 1)
verify(!comboBox.activeFocus)
comboBox.activeFocusOnPress = true
- if (Qt.platform.os === "mac") // on mac when the menu open, the __popup function does not return
+ if (Qt.platform.os === "osx") // on mac when the menu open, the __popup function does not return
timer.start()
else // two mouse clicks to open and close the popup menu
mouseClick(comboBox, comboBox.x + 1, comboBox.y + 1)
@@ -240,7 +240,7 @@ TestCase {
}
function test_spaceKey(){
- if (Qt.platform.os === "mac")
+ if (Qt.platform.os === "osx")
skip("When the menu pops up on OS X, it does not return and the test fails after time out")
var comboBox = Qt.createQmlObject('import QtQuick.Controls 1.0 ; ComboBox { model: 4 }', container, '');
@@ -259,7 +259,7 @@ TestCase {
}
function test_currentIndexInMenu() {
- if (Qt.platform.os === "mac")
+ if (Qt.platform.os === "osx")
skip("When the menu pops up on OS X, it does not return and the test fails after time out")
var comboBox = Qt.createQmlObject('import QtQuick.Controls 1.0 ; ComboBox { model: 4 }', container, '');
diff --git a/tests/auto/controls/data/tst_rowlayout.qml b/tests/auto/controls/data/tst_rowlayout.qml
index fd21f475..d04419f0 100644
--- a/tests/auto/controls/data/tst_rowlayout.qml
+++ b/tests/auto/controls/data/tst_rowlayout.qml
@@ -459,6 +459,12 @@ Item {
{ tag: "propagateMaximumWidth", layoutHints: [10, 20, -1], childHints: [11, 21, 30], expected:[10, 20, 30]},
{ tag: "propagateAll", layoutHints: [-1, -1, -1], childHints: [10, 20, 30], expected:[10, 20, 30]},
{ tag: "propagateCrazy", layoutHints: [-1, -1, -1], childHints: [40, 21, 30], expected:[30, 30, 30]},
+ { tag: "expandMinToExplicitPref", layoutHints: [-1, 1, -1], childHints: [11, 21, 31], expected:[ 1, 1, 31]},
+ { tag: "expandMaxToExplicitPref", layoutHints: [-1, 99, -1], childHints: [11, 21, 31], expected:[11, 99, 99]},
+ { tag: "expandAllToExplicitMin", layoutHints: [99, -1, -1], childHints: [11, 21, 31], expected:[99, 99, 99]},
+ { tag: "expandPrefToExplicitMin", layoutHints: [24, -1, -1], childHints: [11, 21, 31], expected:[24, 24, 31]},
+ { tag: "boundPrefToExplicitMax", layoutHints: [-1, -1, 19], childHints: [11, 21, 31], expected:[11, 19, 19]},
+ { tag: "boundAllToExplicitMax", layoutHints: [-1, -1, 9], childHints: [11, 21, 31], expected:[ 9, 9, 9]},
];
}
@@ -468,22 +474,21 @@ Item {
function test_sizeHint(data) {
var layout = layout_sizeHint_Component.createObject(container)
- layout.Layout.minimumWidth = data.layoutHints[0]
- layout.Layout.preferredWidth = data.layoutHints[1]
- layout.Layout.maximumWidth = data.layoutHints[2]
- var child = layout.children[0].children[0]
+ var grid = layout.children[0]
+ grid.Layout.minimumWidth = data.layoutHints[0]
+ grid.Layout.preferredWidth = data.layoutHints[1]
+ grid.Layout.maximumWidth = data.layoutHints[2]
+
+ var child = grid.children[0]
if (data.implicitWidth !== undefined) {
child.implicitWidth = data.implicitWidth
}
-
child.Layout.minimumWidth = data.childHints[0]
child.Layout.preferredWidth = data.childHints[1]
child.Layout.maximumWidth = data.childHints[2]
- var grid = layout.children[0]
- var preferredWidth = layout.Layout.preferredWidth >= 0 ? layout.Layout.preferredWidth : layout.implicitWidth
- var effectiveSizeHintResult = [layout.Layout.minimumWidth, preferredWidth, layout.Layout.maximumWidth]
+ var effectiveSizeHintResult = [layout.Layout.minimumWidth, layout.implicitWidth, layout.Layout.maximumWidth]
compare(effectiveSizeHintResult, data.expected)
layout.destroy()
}
@@ -633,5 +638,70 @@ Item {
compare(r1.y, 6) // 5.5
layout.destroy();
}
+
+
+ Component {
+ id: layout_deleteLayout
+ ColumnLayout {
+ property int dummyproperty: 0 // yes really - its needed
+ RowLayout {
+ Text { text: "label1" } // yes, both are needed
+ Text { text: "label2" }
+ }
+ }
+ }
+
+ function test_destroyLayout()
+ {
+ var layout = layout_deleteLayout.createObject(container)
+ layout.children[0].children[0].visible = true
+ layout.visible = false
+ layout.destroy() // Do not crash
+ }
+
+
+ Component {
+ id: rearrangeNestedLayouts_Component
+ RowLayout {
+ id: layout
+ anchors.fill: parent
+ width: 200
+ height: 20
+ RowLayout {
+ id: row
+ spacing: 0
+
+ Rectangle {
+ id: fixed
+ color: 'red'
+ implicitWidth: 20
+ implicitHeight: 20
+ }
+ Rectangle {
+ id: filler
+ color: 'grey'
+ Layout.fillWidth: true
+ implicitHeight: 20
+ }
+ }
+ }
+ }
+
+ function test_rearrangeNestedLayouts()
+ {
+ var layout = rearrangeNestedLayouts_Component.createObject(container)
+ var fixed = layout.children[0].children[0]
+ var filler = layout.children[0].children[1]
+
+ compare(itemRect(fixed), [0,0,20,20])
+ compare(itemRect(filler), [20,0,180,20])
+
+ fixed.implicitWidth = 100
+ wait(20); // wait for at least 20 ms (this matches the time between two frame
+ // repaints for 50hz displays)
+ compare(itemRect(fixed), [0,0,100,20])
+ compare(itemRect(filler), [100,0,100,20])
+
+ }
}
}
diff --git a/tests/auto/controls/data/tst_shortcuts.qml b/tests/auto/controls/data/tst_shortcuts.qml
index c0a668d4..b28d24a9 100644
--- a/tests/auto/controls/data/tst_shortcuts.qml
+++ b/tests/auto/controls/data/tst_shortcuts.qml
@@ -78,7 +78,7 @@ TestCase {
{ key: Qt.Key_D, modifier: Qt.AltModifier, expected: "alt d pressed" },
{ key: Qt.Key_T, modifier: Qt.NoModifier, expected: "no key press" },
// on mac we don't have mnemonics
- { key: Qt.Key_T, modifier: Qt.AltModifier, expected: Qt.platform.os === "mac" ? "no key press" : "alt t pressed" },
+ { key: Qt.Key_T, modifier: Qt.AltModifier, expected: Qt.platform.os === "osx" ? "no key press" : "alt t pressed" },
]
}
diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml
index 96b4d422..177a8fcb 100644
--- a/tests/auto/controls/data/tst_slider.qml
+++ b/tests/auto/controls/data/tst_slider.qml
@@ -282,5 +282,16 @@ Item {
verify(control.value > 0.5)
control.destroy()
}
+
+ function test_valueAndHandlePosition()
+ {
+ var slider = Qt.createQmlObject('import QtQuick.Controls 1.0; Slider {minimumValue: 0; maximumValue: 100; width: 100; height: 20; stepSize: 1}', container, '');
+ slider.forceActiveFocus()
+ slider.value = 0
+ compare(slider.__handlePos, 0)
+ slider.value = 50
+ compare(slider.__handlePos, 50)
+ slider.destroy()
+ }
}
}
diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml
index 9cc0662e..15ac98b9 100644
--- a/tests/auto/controls/data/tst_spinbox.qml
+++ b/tests/auto/controls/data/tst_spinbox.qml
@@ -178,22 +178,22 @@ Item {
setCoordinates(spinbox)
mouseMove(spinbox, mainCoord.x, mainCoord.y)
- compare(spinbox.__controlState.containsMouse, true)
- compare(spinbox.__controlState.upHovered, false)
- compare(spinbox.__controlState.downHovered, false)
+ compare(spinbox.hovered, true)
+ compare(spinbox.__styleData.upHovered, false)
+ compare(spinbox.__styleData.downHovered, false)
mouseMove(spinbox.parent, upCoord.x, upCoord.y)
- compare(spinbox.__controlState.upHovered, true)
- compare(spinbox.__controlState.downHovered, false)
+ compare(spinbox.__styleData.upHovered, true)
+ compare(spinbox.__styleData.downHovered, false)
mouseMove(spinbox, downCoord.x, downCoord.y)
- compare(spinbox.__controlState.upHovered, false)
- compare(spinbox.__controlState.downHovered, true)
+ compare(spinbox.__styleData.upHovered, false)
+ compare(spinbox.__styleData.downHovered, true)
mouseMove(spinbox, mainCoord.x - 2, mainCoord.y - 2)
- compare(spinbox.__controlState.containsMouse, false)
- compare(spinbox.__controlState.upHovered, false)
- compare(spinbox.__controlState.downHovered, false)
+ compare(spinbox.hovered, false)
+ compare(spinbox.__styleData.upHovered, false)
+ compare(spinbox.__styleData.downHovered, false)
spinbox.destroy()
}
diff --git a/tests/auto/controls/data/tst_stack.qml b/tests/auto/controls/data/tst_stack.qml
index fa833680..a7363de7 100644
--- a/tests/auto/controls/data/tst_stack.qml
+++ b/tests/auto/controls/data/tst_stack.qml
@@ -58,8 +58,8 @@ TestCase {
compare(item.status, 0); // Stack.Inactive
}
- function test_pageStack() {
- var item = Qt.createQmlObject('import QtQuick 2.0; import QtQuick.Controls 1.0; Item { property StackView pageStack: Stack.pageStack }', testCase, '');
- compare(item.pageStack, null);
+ function test_view() {
+ var item = Qt.createQmlObject('import QtQuick 2.0; import QtQuick.Controls 1.0; Item { property StackView view: Stack.view }', testCase, '');
+ compare(item.view, null);
}
}
diff --git a/tests/auto/controls/data/tst_pagestack.qml b/tests/auto/controls/data/tst_stackview.qml
index b20556fb..3daac785 100644
--- a/tests/auto/controls/data/tst_pagestack.qml
+++ b/tests/auto/controls/data/tst_stackview.qml
@@ -60,10 +60,10 @@ TestCase {
StackView {}
}
- function test_pagestack() {
+ function test_stackview() {
var component = stackComponent
var stack = component.createObject(testCase);
- verify (stack !== null, "pagestack created is null")
+ verify (stack !== null, "stackview created is null")
verify (stack.depth === 0)
stack.push(anItem)
verify (stack.depth === 1)
diff --git a/tests/auto/controls/data/tst_tableview.qml b/tests/auto/controls/data/tst_tableview.qml
index 6de8d577..a54bbdcb 100644
--- a/tests/auto/controls/data/tst_tableview.qml
+++ b/tests/auto/controls/data/tst_tableview.qml
@@ -55,6 +55,11 @@ TestCase {
width:400
height:400
+ Component {
+ id: newColumn
+ TableViewColumn { }
+ }
+
function test_usingqmlmodel_data() {
return [
{tag: "listmodel", a: "tableview/table5_listmodel.qml", expected: "A"},
@@ -173,7 +178,14 @@ TestCase {
compare(component.status, Component.Ready)
var table = component.createObject(container);
verify(table !== null, "table created is null")
- table.forceActiveFocus();
+
+ // wait for items to be created
+ var timeout = 2000
+ while (timeout >= 0 && table.rowAt(15, 55) === -1) {
+ timeout -= 50
+ wait(50)
+ }
+
compare(table.test, 0)
mouseClick(table, 15 , 55, Qt.LeftButton)
compare(table.test, 1)
@@ -186,12 +198,27 @@ TestCase {
var table = component.createObject(container);
verify(table !== null, "table created is null")
table.forceActiveFocus();
- compare(table.test, false)
+ compare(table.test, -1)
+ compare(table.testClick, table.currentRow)
+
+ if (!table.__activateItemOnSingleClick)
+ mouseDoubleClick(table, 15 , 45, Qt.LeftButton)
+ else
+ mouseClick(table, 15, 45, Qt.LeftButton)
+
+ compare(table.testDoubleClick, table.currentRow)
+ compare(table.test, table.currentRow)
+ compare(table.testClick, table.currentRow)
+
if (!table.__activateItemOnSingleClick)
mouseDoubleClick(table, 15 , 15, Qt.LeftButton)
else
mouseClick(table, 15, 15, Qt.LeftButton)
- compare(table.test, true)
+
+ compare(table.testDoubleClick, table.currentRow)
+ compare(table.testClick, table.currentRow)
+ compare(table.test, table.currentRow)
+
table.destroy()
}
@@ -202,6 +229,7 @@ TestCase {
verify(table !== null, "table created is null")
table.forceActiveFocus();
compare(table.activatedTest, false)
+ waitForRendering(table)
if (!table.__activateItemOnSingleClick)
mouseDoubleClick(table, 15 , 50, Qt.LeftButton)
else
@@ -228,6 +256,178 @@ TestCase {
table.destroy()
}
+ function test_columnWidth() {
+ var tableView = Qt.createQmlObject('import QtQuick 2.1; import QtQuick.Controls 1.0; TableView { }', testCase, '');
+ compare(tableView.columnCount, 0)
+ var column = newColumn.createObject(testCase, {title: "title 1"});
+ verify(column.__view === null)
+ compare(column.width, 160)
+ compare(column.title, "title 1")
+ tableView.addColumn(column)
+ compare(column.__view, tableView)
+ compare(column.width, tableView.viewport.width)
+ var tableView2 = Qt.createQmlObject('import QtQuick 2.1; import QtQuick.Controls 1.0; TableView { }', testCase, '');
+ tableView2.addColumn(column) // should not work
+ compare(column.__view, tableView) //same as before
+ tableView2.destroy()
+ tableView.destroy()
+ }
+
+ function test_dynamicColumns() {
+ var component = Qt.createComponent("tableview/table_dynamiccolumns.qml")
+ compare(component.status, Component.Ready)
+ var table = component.createObject(container)
+
+ // insertColumn(component), insertColumn(item),
+ // addColumn(component), addColumn(item), and static TableViewColumn {}
+ compare(table.columnCount, 5)
+ compare(table.getColumn(0).title, "inserted component")
+ compare(table.getColumn(1).title, "inserted item")
+ table.destroy()
+ }
+
+ function test_addRemoveColumn() {
+ var tableView = Qt.createQmlObject('import QtQuick 2.1; import QtQuick.Controls 1.0; TableView { }', testCase, '');
+ compare(tableView.columnCount, 0)
+ tableView.addColumn(newColumn.createObject(testCase, {title: "title 1"}))
+ compare(tableView.columnCount, 1)
+ tableView.addColumn(newColumn.createObject(testCase, {title: "title 2"}))
+ compare(tableView.columnCount, 2)
+ compare(tableView.getColumn(0).title, "title 1")
+ compare(tableView.getColumn(1).title, "title 2")
+
+ tableView.insertColumn(1, newColumn.createObject(testCase, {title: "title 3"}))
+ compare(tableView.columnCount, 3)
+ compare(tableView.getColumn(0).title, "title 1")
+ compare(tableView.getColumn(1).title, "title 3")
+ compare(tableView.getColumn(2).title, "title 2")
+
+ tableView.insertColumn(0, newColumn.createObject(testCase, {title: "title 4"}))
+ compare(tableView.columnCount, 4)
+ compare(tableView.getColumn(0).title, "title 4")
+ compare(tableView.getColumn(1).title, "title 1")
+ compare(tableView.getColumn(2).title, "title 3")
+ compare(tableView.getColumn(3).title, "title 2")
+
+ tableView.removeColumn(0)
+ compare(tableView.columnCount, 3)
+ compare(tableView.getColumn(0).title, "title 1")
+ compare(tableView.getColumn(1).title, "title 3")
+ compare(tableView.getColumn(2).title, "title 2")
+
+ tableView.removeColumn(1)
+ compare(tableView.columnCount, 2)
+ compare(tableView.getColumn(0).title, "title 1")
+ compare(tableView.getColumn(1).title, "title 2")
+
+ tableView.removeColumn(1)
+ compare(tableView.columnCount, 1)
+ compare(tableView.getColumn(0).title, "title 1")
+
+ tableView.removeColumn(0)
+ compare(tableView.columnCount, 0)
+ tableView.destroy()
+ }
+
+ function test_moveColumn_data() {
+ return [
+ {tag:"0->1 (0)", from: 0, to: 1},
+ {tag:"0->1 (1)", from: 0, to: 1},
+ {tag:"0->1 (2)", from: 0, to: 1},
+
+ {tag:"0->2 (0)", from: 0, to: 2},
+ {tag:"0->2 (1)", from: 0, to: 2},
+ {tag:"0->2 (2)", from: 0, to: 2},
+
+ {tag:"1->0 (0)", from: 1, to: 0},
+ {tag:"1->0 (1)", from: 1, to: 0},
+ {tag:"1->0 (2)", from: 1, to: 0},
+
+ {tag:"1->2 (0)", from: 1, to: 2},
+ {tag:"1->2 (1)", from: 1, to: 2},
+ {tag:"1->2 (2)", from: 1, to: 2},
+
+ {tag:"2->0 (0)", from: 2, to: 0},
+ {tag:"2->0 (1)", from: 2, to: 0},
+ {tag:"2->0 (2)", from: 2, to: 0},
+
+ {tag:"2->1 (0)", from: 2, to: 1},
+ {tag:"2->1 (1)", from: 2, to: 1},
+ {tag:"2->1 (2)", from: 2, to: 1},
+
+ {tag:"0->0", from: 0, to: 0},
+ {tag:"-1->0", from: -1, to: 0},
+ {tag:"0->-1", from: 0, to: -1},
+ {tag:"1->10", from: 1, to: 10},
+ {tag:"10->2", from: 10, to: 2},
+ {tag:"10->-1", from: 10, to: -1}
+ ]
+ }
+
+ function test_moveColumn(data) {
+ var tableView = Qt.createQmlObject('import QtQuick 2.1; import QtQuick.Controls 1.0; TableView { }', testCase, '');
+ compare(tableView.columnCount, 0)
+
+ var titles = ["title 1", "title 2", "title 3"]
+
+ var i = 0;
+ for (i = 0; i < titles.length; ++i)
+ tableView.addColumn(newColumn.createObject(testCase, {title: titles[i]}))
+
+ compare(tableView.columnCount, titles.length)
+ for (i = 0; i < tableView.columnCount; ++i)
+ compare(tableView.getColumn(i).title, titles[i])
+
+ tableView.moveColumn(data.from, data.to)
+
+ compare(tableView.columnCount, titles.length)
+
+ if (data.from >= 0 && data.from < tableView.columnCount && data.to >= 0 && data.to < tableView.columnCount) {
+ var title = titles[data.from]
+ titles.splice(data.from, 1)
+ titles.splice(data.to, 0, title)
+ }
+
+ compare(tableView.columnCount, titles.length)
+ for (i = 0; i < tableView.columnCount; ++i)
+ compare(tableView.getColumn(i).title, titles[i])
+
+ tableView.destroy()
+ }
+
+ function test_positionViewAtRow() {
+ var test_instanceStr =
+ 'import QtQuick 2.1; \
+ import QtQuick.Controls 1.0; \
+ TableView { \
+ TableViewColumn { \
+ } \
+ model: 1000; \
+ headerVisible: false; \
+ }'
+
+ var table = Qt.createQmlObject(test_instanceStr, testCase, '')
+ waitForRendering(table)
+
+ var beginPos = table.mapFromItem(table.viewport, 0, 0)
+
+ table.positionViewAtRow(0, ListView.Beginning)
+ compare(table.rowAt(beginPos.x, beginPos.y), 0)
+
+ table.positionViewAtRow(100, ListView.Beginning)
+ compare(table.rowAt(beginPos.x, beginPos.y), 100)
+
+ var endPos = table.mapFromItem(table.viewport, 0, table.viewport.height - 1)
+
+ table.positionViewAtRow(900, ListView.End)
+ compare(table.rowAt(endPos.x, endPos.y), 900)
+
+ table.positionViewAtRow(999, ListView.End)
+ compare(table.rowAt(endPos.x, endPos.y), 999)
+
+ table.destroy()
+ }
+
// In TableView, drawn text = table.__currentRowItem.children[1].children[1].itemAt(0).children[0].children[0].text
function findAChild(item, name)
diff --git a/tests/auto/controls/data/tst_tabview.qml b/tests/auto/controls/data/tst_tabview.qml
index 992baf22..8093ebc3 100644
--- a/tests/auto/controls/data/tst_tabview.qml
+++ b/tests/auto/controls/data/tst_tabview.qml
@@ -72,12 +72,12 @@ TestCase {
function test_changeIndex() {
var tabView = Qt.createQmlObject('import QtQuick 2.1; import QtQuick.Controls 1.0; TabView { Repeater { model: 3; Tab { Text { text: index } } } }', testCase, '');
compare(tabView.count, 3)
- verify(tabView.tabAt(1).item == undefined)
+ verify(tabView.getTab(1).item == undefined)
tabView.currentIndex = 1
- verify(tabView.tabAt(1).item !== undefined)
- verify(tabView.tabAt(2).item == undefined)
+ verify(tabView.getTab(1).item !== undefined)
+ verify(tabView.getTab(2).item == undefined)
tabView.currentIndex = 1
- verify(tabView.tabAt(2).item !== undefined)
+ verify(tabView.getTab(2).item !== undefined)
tabView.destroy()
}
@@ -89,36 +89,36 @@ TestCase {
compare(tabView.count, 1)
tabView.addTab("title 2", newTab)
compare(tabView.count, 2)
- compare(tabView.tabAt(0).title, "title 1")
- compare(tabView.tabAt(1).title, "title 2")
+ compare(tabView.getTab(0).title, "title 1")
+ compare(tabView.getTab(1).title, "title 2")
tabView.insertTab(1, "title 3")
compare(tabView.count, 3)
- compare(tabView.tabAt(0).title, "title 1")
- compare(tabView.tabAt(1).title, "title 3")
- compare(tabView.tabAt(2).title, "title 2")
+ compare(tabView.getTab(0).title, "title 1")
+ compare(tabView.getTab(1).title, "title 3")
+ compare(tabView.getTab(2).title, "title 2")
tabView.insertTab(0, "title 4")
compare(tabView.count, 4)
- compare(tabView.tabAt(0).title, "title 4")
- compare(tabView.tabAt(1).title, "title 1")
- compare(tabView.tabAt(2).title, "title 3")
- compare(tabView.tabAt(3).title, "title 2")
+ compare(tabView.getTab(0).title, "title 4")
+ compare(tabView.getTab(1).title, "title 1")
+ compare(tabView.getTab(2).title, "title 3")
+ compare(tabView.getTab(3).title, "title 2")
tabView.removeTab(0)
compare(tabView.count, 3)
- compare(tabView.tabAt(0).title, "title 1")
- compare(tabView.tabAt(1).title, "title 3")
- compare(tabView.tabAt(2).title, "title 2")
+ compare(tabView.getTab(0).title, "title 1")
+ compare(tabView.getTab(1).title, "title 3")
+ compare(tabView.getTab(2).title, "title 2")
tabView.removeTab(1)
compare(tabView.count, 2)
- compare(tabView.tabAt(0).title, "title 1")
- compare(tabView.tabAt(1).title, "title 2")
+ compare(tabView.getTab(0).title, "title 1")
+ compare(tabView.getTab(1).title, "title 2")
tabView.removeTab(1)
compare(tabView.count, 1)
- compare(tabView.tabAt(0).title, "title 1")
+ compare(tabView.getTab(0).title, "title 1")
tabView.removeTab(0)
compare(tabView.count, 0)
@@ -172,7 +172,7 @@ TestCase {
compare(tabView.count, titles.length)
for (i = 0; i < tabView.count; ++i)
- compare(tabView.tabAt(i).title, titles[i])
+ compare(tabView.getTab(i).title, titles[i])
tabView.currentIndex = data.currentBefore
tabView.moveTab(data.from, data.to)
@@ -186,7 +186,7 @@ TestCase {
compare(tabView.count, titles.length)
for (i = 0; i < tabView.count; ++i)
- compare(tabView.tabAt(i).title, titles[i])
+ compare(tabView.getTab(i).title, titles[i])
tabView.destroy()
}
@@ -212,11 +212,11 @@ TestCase {
var tabView = Qt.createQmlObject(test_tabView, testCase, '')
// insertTab(), addTab(), createObject() and static Tab {}
compare(tabView.count, 4)
- compare(tabView.tabAt(0).title, "inserted")
+ compare(tabView.getTab(0).title, "inserted")
var tab = tabView.tabComponent.createObject(tabView)
compare(tabView.count, 5)
- compare(tabView.tabAt(4).title, "dynamic")
+ compare(tabView.getTab(4).title, "dynamic")
tab.destroy()
wait(0)
compare(tabView.count, 4)
@@ -365,7 +365,7 @@ TestCase {
waitForRendering(tab3)
mouseClick(tab3, tab3.width/2, tab3.height/2)
- verify(tab3.activeFocus)
+ verify(!tab3.activeFocus)
verify(!textField.activeFocus)
tabView.destroy()
diff --git a/tests/auto/testplugin/README.txt b/tests/auto/testplugin/README.txt
deleted file mode 100644
index c22837db..00000000
--- a/tests/auto/testplugin/README.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-
-The test plugin is not installed (i.e. to the qml folder).
-In order for the tst_controls to find it, you can either:
-
-- Run make check in the controls folder. The plugin will be found
-at run time because IMPORTPATH is defined in the pro file.
-
-- In Qt Creator run settings or in the console, set QML2_IMPORT_PATH
-macro to the testplugin path. At run time QML2_IMPORT_PATH is used by
-by qmlscene to find imports required.
-i.e: export QML2_IMPORT_PATH=<path_qtquickcontrols_git_clone>/tests/auto/testplugin
diff --git a/tests/manual/scrollview/main.qml b/tests/manual/scrollview/main.qml
index 71accd8e..a245ca88 100644
--- a/tests/manual/scrollview/main.qml
+++ b/tests/manual/scrollview/main.qml
@@ -78,6 +78,12 @@ ApplicationWindow {
value: 1000
implicitWidth: 80
}
+ CheckBox {
+ id: largeCheck
+ text: "Large"
+ checked: false
+ implicitWidth: 80
+ }
Item { Layout.fillWidth: true }
}
}
@@ -139,6 +145,7 @@ ApplicationWindow {
frameVisible: frameCheck.checked
text: loremIpsum + loremIpsum + loremIpsum + loremIpsum
anchors.fill: parent
+ font.pixelSize: largeCheck.checked ? 26 : 13
}
}
Tab {
@@ -152,7 +159,7 @@ ApplicationWindow {
model: 30
delegate: Rectangle {
width: parent.width
- height: 30
+ height: largeCheck.checked ? 60 : 30
Text {
anchors.fill: parent
anchors.margins: 4
@@ -177,6 +184,17 @@ ApplicationWindow {
model: 10
frameVisible: frameCheck.checked
+ rowDelegate: Rectangle {
+ width: parent.width
+ height: largeCheck.checked ? 60 : 30
+ Rectangle {
+ anchors.bottom: parent.bottom
+ width: parent.width
+ height: 1
+ color: "darkgray"
+ }
+ }
+
TableViewColumn {title: "first"
width: view.viewport.width
}