aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/controls
diff options
context:
space:
mode:
Diffstat (limited to 'src/imports/controls')
-rw-r--r--src/imports/controls/Button.qml16
-rw-r--r--src/imports/controls/CheckBox.qml20
-rw-r--r--src/imports/controls/ComboBox.qml1
-rw-r--r--src/imports/controls/Frame.qml9
-rw-r--r--src/imports/controls/GroupBox.qml6
-rw-r--r--src/imports/controls/ItemDelegate.qml20
-rw-r--r--src/imports/controls/MenuItem.qml24
-rw-r--r--src/imports/controls/RadioButton.qml20
-rw-r--r--src/imports/controls/SpinBox.qml1
-rw-r--r--src/imports/controls/StackView.qml14
-rw-r--r--src/imports/controls/Switch.qml20
-rw-r--r--src/imports/controls/TabButton.qml17
-rw-r--r--src/imports/controls/TextArea.qml2
-rw-r--r--src/imports/controls/TextField.qml2
-rw-r--r--src/imports/controls/ToolButton.qml17
-rw-r--r--src/imports/controls/controls.pri4
-rw-r--r--src/imports/controls/controls.pro6
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-button-contentItem.png (renamed from src/imports/controls/doc/images/qtlabscontrols-button-label.png)bin1550 -> 1550 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter1.pngbin0 -> 5877 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter2-listview-header.gifbin0 -> 176936 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter2.pngbin0 -> 22195 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter3-listview-header.gifbin0 -> 262432 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter3-view-margins.pngbin0 -> 3895 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter3.gifbin0 -> 169856 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter4-long-message.pngbin0 -> 16495 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter4-message-timestamp.pngbin0 -> 10762 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter4.gifbin0 -> 102536 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-material-dark.pngbin0 -> 21774 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-material-test.pngbin0 -> 18308 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-material.pngbin0 -> 19284 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-universal-dark.pngbin0 -> 19534 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-universal.pngbin0 -> 18259 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-material-dark.pngbin0 -> 16739 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-material-test.pngbin0 -> 2970 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-material.pngbin0 -> 3524 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-universal-dark.pngbin0 -> 9875 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-universal.pngbin0 -> 11716 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-checkbox-contentItem.png (renamed from src/imports/controls/doc/images/qtlabscontrols-checkbox-label.png)bin2582 -> 2582 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-frame-frame.pngbin341 -> 0 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-groupbox-frame.pngbin2653 -> 0 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-itemdelegate-contentItem.png (renamed from src/imports/controls/doc/images/qtlabscontrols-itemdelegate-label.png)bin3441 -> 3441 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-radiobutton-contentItem.png (renamed from src/imports/controls/doc/images/qtlabscontrols-radiobutton-label.png)bin3435 -> 3435 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-switch-contentItem.png (renamed from src/imports/controls/doc/images/qtlabscontrols-switch-label.png)bin2605 -> 2605 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-toolbar-frame.pngbin217 -> 0 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-toolbutton-contentItem.png (renamed from src/imports/controls/doc/images/qtlabscontrols-toolbutton-label.png)bin1682 -> 1682 bytes
-rw-r--r--src/imports/controls/doc/snippets/qtlabscontrols-button-contentItem.qml (renamed from src/imports/controls/doc/snippets/qtlabscontrols-button-label.qml)2
-rw-r--r--src/imports/controls/doc/snippets/qtlabscontrols-checkbox-contentItem.qml (renamed from src/imports/controls/doc/snippets/qtlabscontrols-checkbox-label.qml)2
-rw-r--r--src/imports/controls/doc/snippets/qtlabscontrols-frame-frame.qml40
-rw-r--r--src/imports/controls/doc/snippets/qtlabscontrols-groupbox-frame.qml41
-rw-r--r--src/imports/controls/doc/snippets/qtlabscontrols-itemdelegate-contentItem.qml (renamed from src/imports/controls/doc/snippets/qtlabscontrols-itemdelegate-label.qml)2
-rw-r--r--src/imports/controls/doc/snippets/qtlabscontrols-radiobutton-contentItem.qml (renamed from src/imports/controls/doc/snippets/qtlabscontrols-radiobutton-label.qml)2
-rw-r--r--src/imports/controls/doc/snippets/qtlabscontrols-switch-contentItem.qml (renamed from src/imports/controls/doc/snippets/qtlabscontrols-switch-label.qml)2
-rw-r--r--src/imports/controls/doc/snippets/qtlabscontrols-toolbar-frame.qml38
-rw-r--r--src/imports/controls/doc/snippets/qtlabscontrols-toolbutton-contentItem.qml (renamed from src/imports/controls/doc/snippets/qtlabscontrols-toolbutton-label.qml)2
-rw-r--r--src/imports/controls/doc/src/qtlabscontrols-chattutorial.qdoc861
-rw-r--r--src/imports/controls/doc/src/qtlabscontrols-customize.qdoc80
-rw-r--r--src/imports/controls/doc/src/qtlabscontrols-differences.qdoc2
-rw-r--r--src/imports/controls/doc/src/qtlabscontrols-fileselectors.qdoc141
-rw-r--r--src/imports/controls/doc/src/qtlabscontrols-index.qdoc1
-rw-r--r--src/imports/controls/doc/src/qtlabscontrols-material.qdoc21
-rw-r--r--src/imports/controls/doc/src/qtlabscontrols-styles.qdoc1
-rw-r--r--src/imports/controls/doc/src/qtlabscontrols-universal.qdoc21
-rw-r--r--src/imports/controls/material/Button.qml17
-rw-r--r--src/imports/controls/material/CheckBox.qml21
-rw-r--r--src/imports/controls/material/ComboBox.qml1
-rw-r--r--src/imports/controls/material/Frame.qml9
-rw-r--r--src/imports/controls/material/GroupBox.qml6
-rw-r--r--src/imports/controls/material/ItemDelegate.qml21
-rw-r--r--src/imports/controls/material/MenuItem.qml21
-rw-r--r--src/imports/controls/material/RadioButton.qml21
-rw-r--r--src/imports/controls/material/RangeSlider.qml1
-rw-r--r--src/imports/controls/material/Slider.qml1
-rw-r--r--src/imports/controls/material/SpinBox.qml1
-rw-r--r--src/imports/controls/material/StackView.qml14
-rw-r--r--src/imports/controls/material/Switch.qml21
-rw-r--r--src/imports/controls/material/TabBar.qml2
-rw-r--r--src/imports/controls/material/TabButton.qml17
-rw-r--r--src/imports/controls/material/TextArea.qml2
-rw-r--r--src/imports/controls/material/TextField.qml2
-rw-r--r--src/imports/controls/material/ToolButton.qml17
-rw-r--r--src/imports/controls/material/qquickmaterialprogressring.cpp29
-rw-r--r--src/imports/controls/material/qquickmaterialprogressring_p.h10
-rw-r--r--src/imports/controls/material/qquickmaterialprogressstrip.cpp14
-rw-r--r--src/imports/controls/material/qquickmaterialprogressstrip_p.h10
-rw-r--r--src/imports/controls/material/qquickmaterialstyle.cpp128
-rw-r--r--src/imports/controls/material/qquickmaterialstyle_p.h4
-rw-r--r--src/imports/controls/material/qquickmaterialtheme_p.h2
-rw-r--r--src/imports/controls/material/qtlabsmaterialstyleplugin.cpp18
-rw-r--r--src/imports/controls/plugins.qmltypes30
-rw-r--r--src/imports/controls/qquickbusyindicatorring.cpp14
-rw-r--r--src/imports/controls/qquickbusyindicatorring_p.h10
-rw-r--r--src/imports/controls/qquickprogressstrip.cpp14
-rw-r--r--src/imports/controls/qquickprogressstrip_p.h10
-rw-r--r--src/imports/controls/qtlabscontrolsplugin.cpp21
-rw-r--r--src/imports/controls/universal/Button.qml17
-rw-r--r--src/imports/controls/universal/CheckBox.qml20
-rw-r--r--src/imports/controls/universal/ComboBox.qml1
-rw-r--r--src/imports/controls/universal/Frame.qml9
-rw-r--r--src/imports/controls/universal/GroupBox.qml6
-rw-r--r--src/imports/controls/universal/ItemDelegate.qml20
-rw-r--r--src/imports/controls/universal/MenuItem.qml24
-rw-r--r--src/imports/controls/universal/RadioButton.qml20
-rw-r--r--src/imports/controls/universal/SpinBox.qml1
-rw-r--r--src/imports/controls/universal/StackView.qml8
-rw-r--r--src/imports/controls/universal/Switch.qml20
-rw-r--r--src/imports/controls/universal/TabButton.qml17
-rw-r--r--src/imports/controls/universal/TextArea.qml2
-rw-r--r--src/imports/controls/universal/TextField.qml2
-rw-r--r--src/imports/controls/universal/ToolButton.qml17
-rw-r--r--src/imports/controls/universal/qquickuniversalfocusrectangle_p.h4
-rw-r--r--src/imports/controls/universal/qquickuniversalimageprovider.cpp79
-rw-r--r--src/imports/controls/universal/qquickuniversalimageprovider_p.h65
-rw-r--r--src/imports/controls/universal/qquickuniversalprogressring.cpp38
-rw-r--r--src/imports/controls/universal/qquickuniversalprogressring_p.h10
-rw-r--r--src/imports/controls/universal/qquickuniversalprogressstrip.cpp29
-rw-r--r--src/imports/controls/universal/qquickuniversalprogressstrip_p.h10
-rw-r--r--src/imports/controls/universal/qquickuniversalstyle.cpp76
-rw-r--r--src/imports/controls/universal/qquickuniversalstyle_p.h4
-rw-r--r--src/imports/controls/universal/qquickuniversaltheme_p.h2
-rw-r--r--src/imports/controls/universal/qtlabsuniversalstyleplugin.cpp18
-rw-r--r--src/imports/controls/universal/universal.pri2
121 files changed, 1608 insertions, 880 deletions
diff --git a/src/imports/controls/Button.qml b/src/imports/controls/Button.qml
index 290f4ce4..67e9bffe 100644
--- a/src/imports/controls/Button.qml
+++ b/src/imports/controls/Button.qml
@@ -41,21 +41,17 @@ T.Button {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- label ? label.implicitWidth + leftPadding + rightPadding : 0)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- label ? label.implicitHeight + topPadding + bottomPadding : 0)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ contentItem.implicitHeight + topPadding + bottomPadding)
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 6
leftPadding: 8
rightPadding: 8
- //! [label]
- label: Text {
- x: control.leftPadding
- y: control.topPadding
- width: control.availableWidth
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
text: control.text
font: control.font
opacity: enabled || highlighted ? 1 : 0.3
@@ -64,7 +60,7 @@ T.Button {
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
- //! [label]
+ //! [contentItem]
//! [background]
background: Rectangle {
diff --git a/src/imports/controls/CheckBox.qml b/src/imports/controls/CheckBox.qml
index 4b7af3b1..52061681 100644
--- a/src/imports/controls/CheckBox.qml
+++ b/src/imports/controls/CheckBox.qml
@@ -41,13 +41,11 @@ T.CheckBox {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- (label ? label.implicitWidth : 0) +
- (indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? spacing : 0) + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- Math.max(label ? label.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 6
spacing: 6
@@ -81,12 +79,10 @@ T.CheckBox {
}
//! [indicator]
- //! [label]
- label: Text {
- x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
- y: control.topPadding
- width: control.availableWidth - indicator.width - control.spacing
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -96,5 +92,5 @@ T.CheckBox {
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
}
diff --git a/src/imports/controls/ComboBox.qml b/src/imports/controls/ComboBox.qml
index 2745a0d8..6e3dc91b 100644
--- a/src/imports/controls/ComboBox.qml
+++ b/src/imports/controls/ComboBox.qml
@@ -36,6 +36,7 @@
import QtQuick 2.6
import QtQuick.Window 2.2
+import Qt.labs.controls 1.0
import Qt.labs.templates 1.0 as T
T.ComboBox {
diff --git a/src/imports/controls/Frame.qml b/src/imports/controls/Frame.qml
index 3c9326e1..1f1bfac6 100644
--- a/src/imports/controls/Frame.qml
+++ b/src/imports/controls/Frame.qml
@@ -52,13 +52,10 @@ T.Frame {
contentItem: Item { }
//! [contentItem]
- //! [frame]
- frame: Rectangle {
- width: parent.width
- height: parent.height
-
+ //! [background]
+ background: Rectangle {
color: "transparent"
border.color: "#bdbebf"
}
- //! [frame]
+ //! [background]
}
diff --git a/src/imports/controls/GroupBox.qml b/src/imports/controls/GroupBox.qml
index bc1801c2..7ae14c24 100644
--- a/src/imports/controls/GroupBox.qml
+++ b/src/imports/controls/GroupBox.qml
@@ -70,8 +70,8 @@ T.GroupBox {
}
//! [label]
- //! [frame]
- frame: Rectangle {
+ //! [background]
+ background: Rectangle {
y: control.topPadding - control.padding
width: parent.width
height: parent.height - control.topPadding + control.padding
@@ -79,5 +79,5 @@ T.GroupBox {
color: "transparent"
border.color: "#bdbebf"
}
- //! [frame]
+ //! [background]
}
diff --git a/src/imports/controls/ItemDelegate.qml b/src/imports/controls/ItemDelegate.qml
index b5dfb4b6..13a13e1e 100644
--- a/src/imports/controls/ItemDelegate.qml
+++ b/src/imports/controls/ItemDelegate.qml
@@ -41,23 +41,19 @@ T.ItemDelegate {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- (label ? label.implicitWidth : 0) +
- (indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? spacing : 0) + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- Math.max(label ? label.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 12
spacing: 12
- //! [label]
- label: Text {
- x: control.mirrored ? control.width - width - control.rightPadding : control.leftPadding
- y: control.topPadding
- width: control.availableWidth - (control.checkable ? indicator.width + control.spacing : 0)
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.checkable && control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.checkable && !control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -67,7 +63,7 @@ T.ItemDelegate {
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
//! [indicator]
indicator: Image {
diff --git a/src/imports/controls/MenuItem.qml b/src/imports/controls/MenuItem.qml
index ae5a8e38..75866fbe 100644
--- a/src/imports/controls/MenuItem.qml
+++ b/src/imports/controls/MenuItem.qml
@@ -40,21 +40,19 @@ import Qt.labs.templates 1.0 as T
T.MenuItem {
id: control
- implicitWidth: background ? background.implicitWidth
- : (label ? label.implicitWidth : 0) + (indicator ? indicator.implicitWidth : 0)
- + (label && indicator ? spacing : 0) + leftPadding + rightPadding
- implicitHeight: background ? background.implicitHeight
- : (label ? label.implicitHeight : 0) + (indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ contentItem.implicitWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
+ indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 6
- //! [label]
- label: Text {
- x: control.mirrored ? control.leftPadding : control.width - width - control.rightPadding
- y: control.topPadding
- width: control.availableWidth - (control.checkable ? indicator.width + control.spacing : 0)
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.checkable && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.checkable && control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -64,7 +62,7 @@ T.MenuItem {
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
//! [indicator]
indicator: Image {
diff --git a/src/imports/controls/RadioButton.qml b/src/imports/controls/RadioButton.qml
index 8e1e0bce..f1e10a6c 100644
--- a/src/imports/controls/RadioButton.qml
+++ b/src/imports/controls/RadioButton.qml
@@ -42,13 +42,11 @@ T.RadioButton {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- (label ? label.implicitWidth : 0) +
- (indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? spacing : 0) + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- Math.max(label ? label.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 6
spacing: 6
@@ -78,12 +76,10 @@ T.RadioButton {
}
//! [indicator]
- //! [label]
- label: Text {
- x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
- y: control.topPadding
- width: control.availableWidth - indicator.width - control.spacing
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -93,5 +89,5 @@ T.RadioButton {
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
}
diff --git a/src/imports/controls/SpinBox.qml b/src/imports/controls/SpinBox.qml
index 77f89206..d3184626 100644
--- a/src/imports/controls/SpinBox.qml
+++ b/src/imports/controls/SpinBox.qml
@@ -74,6 +74,7 @@ T.SpinBox {
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
+ readOnly: !control.editable
validator: control.validator
inputMethodHints: Qt.ImhFormattedNumbersOnly
}
diff --git a/src/imports/controls/StackView.qml b/src/imports/controls/StackView.qml
index f0869307..2de21885 100644
--- a/src/imports/controls/StackView.qml
+++ b/src/imports/controls/StackView.qml
@@ -39,41 +39,41 @@ import Qt.labs.controls 1.0
import Qt.labs.templates 1.0 as T
T.StackView {
- id: root
+ id: control
//! [popEnter]
popEnter: Transition {
- XAnimator { from: (root.mirrored ? -1 : 1) * -root.width; to: 0; duration: 400; easing.type: Easing.OutCubic }
+ XAnimator { from: (control.mirrored ? -1 : 1) * -control.width; to: 0; duration: 400; easing.type: Easing.OutCubic }
}
//! [popEnter]
//! [popExit]
popExit: Transition {
- XAnimator { from: 0; to: (root.mirrored ? -1 : 1) * root.width; duration: 400; easing.type: Easing.OutCubic }
+ XAnimator { from: 0; to: (control.mirrored ? -1 : 1) * control.width; duration: 400; easing.type: Easing.OutCubic }
}
//! [popExit]
//! [pushEnter]
pushEnter: Transition {
- XAnimator { from: (root.mirrored ? -1 : 1) * root.width; to: 0; duration: 400; easing.type: Easing.OutCubic }
+ XAnimator { from: (control.mirrored ? -1 : 1) * control.width; to: 0; duration: 400; easing.type: Easing.OutCubic }
}
//! [pushEnter]
//! [pushExit]
pushExit: Transition {
- XAnimator { from: 0; to: (root.mirrored ? -1 : 1) * -root.width; duration: 400; easing.type: Easing.OutCubic }
+ XAnimator { from: 0; to: (control.mirrored ? -1 : 1) * -control.width; duration: 400; easing.type: Easing.OutCubic }
}
//! [pushExit]
//! [replaceEnter]
replaceEnter: Transition {
- XAnimator { from: (root.mirrored ? -1 : 1) * root.width; to: 0; duration: 400; easing.type: Easing.OutCubic }
+ XAnimator { from: (control.mirrored ? -1 : 1) * control.width; to: 0; duration: 400; easing.type: Easing.OutCubic }
}
//! [replaceEnter]
//! [replaceExit]
replaceExit: Transition {
- XAnimator { from: 0; to: (root.mirrored ? -1 : 1) * -root.width; duration: 400; easing.type: Easing.OutCubic }
+ XAnimator { from: 0; to: (control.mirrored ? -1 : 1) * -control.width; duration: 400; easing.type: Easing.OutCubic }
}
//! [replaceExit]
}
diff --git a/src/imports/controls/Switch.qml b/src/imports/controls/Switch.qml
index 51348e77..01f561a1 100644
--- a/src/imports/controls/Switch.qml
+++ b/src/imports/controls/Switch.qml
@@ -41,13 +41,11 @@ T.Switch {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- (label ? label.implicitWidth : 0) +
- (indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? spacing : 0) + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- Math.max(label ? label.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 6
spacing: 6
@@ -87,12 +85,10 @@ T.Switch {
}
//! [indicator]
- //! [label]
- label: Text {
- x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
- y: control.topPadding
- width: control.availableWidth - indicator.width - control.spacing
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -102,5 +98,5 @@ T.Switch {
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
}
diff --git a/src/imports/controls/TabButton.qml b/src/imports/controls/TabButton.qml
index 178a0a7f..63a88b10 100644
--- a/src/imports/controls/TabButton.qml
+++ b/src/imports/controls/TabButton.qml
@@ -41,20 +41,15 @@ T.TabButton {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- label ? label.contentWidth + leftPadding + rightPadding : 0)
+ contentItem.contentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- label ? label.contentHeight + topPadding + bottomPadding : 0)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ contentItem.contentHeight + topPadding + bottomPadding)
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 6
- //! [label]
- label: Text {
- x: control.leftPadding
- y: control.topPadding
- width: control.availableWidth
- height: control.availableHeight
-
+ //! [contentItem]
+ contentItem: Text {
text: control.text
font: control.font
elide: Text.ElideRight
@@ -63,7 +58,7 @@ T.TabButton {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
//! [background]
background: Rectangle {
diff --git a/src/imports/controls/TextArea.qml b/src/imports/controls/TextArea.qml
index 8326fc89..46b6bc6c 100644
--- a/src/imports/controls/TextArea.qml
+++ b/src/imports/controls/TextArea.qml
@@ -67,7 +67,7 @@ T.TextArea {
color: "#c2c2c2"
horizontalAlignment: control.horizontalAlignment
verticalAlignment: control.verticalAlignment
- visible: !control.length && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
+ visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
elide: Text.ElideRight
}
}
diff --git a/src/imports/controls/TextField.qml b/src/imports/controls/TextField.qml
index d9f31b2f..7abf540b 100644
--- a/src/imports/controls/TextField.qml
+++ b/src/imports/controls/TextField.qml
@@ -66,7 +66,7 @@ T.TextField {
color: "#bdbebf"
horizontalAlignment: control.horizontalAlignment
verticalAlignment: control.verticalAlignment
- visible: !control.displayText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
+ visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
elide: Text.ElideRight
}
diff --git a/src/imports/controls/ToolButton.qml b/src/imports/controls/ToolButton.qml
index 314ce966..a610dc2b 100644
--- a/src/imports/controls/ToolButton.qml
+++ b/src/imports/controls/ToolButton.qml
@@ -41,20 +41,15 @@ T.ToolButton {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- label ? label.implicitWidth + leftPadding + rightPadding : 0)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- label ? label.implicitHeight + topPadding + bottomPadding : 0)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ contentItem.implicitHeight + topPadding + bottomPadding)
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 6
- //! [label]
- label: Text {
- x: control.leftPadding
- y: control.topPadding
- width: control.availableWidth
- height: control.availableHeight
-
+ //! [contentItem]
+ contentItem: Text {
text: control.text
font: control.font
color: control.enabled ? "#26282a" : "#c2c2c2"
@@ -62,7 +57,7 @@ T.ToolButton {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
//! [background]
background: Rectangle {
diff --git a/src/imports/controls/controls.pri b/src/imports/controls/controls.pri
index c3391929..32e86f3a 100644
--- a/src/imports/controls/controls.pri
+++ b/src/imports/controls/controls.pri
@@ -1,4 +1,4 @@
-QML_FILES = \
+QML_CONTROLS = \
ApplicationWindow.qml \
BusyIndicator.qml \
Button.qml \
@@ -33,3 +33,5 @@ QML_FILES = \
ToolBar.qml \
ToolButton.qml \
Tumbler.qml
+
+!qtquickcompiler: QML_FILES += $$QML_CONTROLS
diff --git a/src/imports/controls/controls.pro b/src/imports/controls/controls.pro
index a9861617..0fc73673 100644
--- a/src/imports/controls/controls.pro
+++ b/src/imports/controls/controls.pro
@@ -27,5 +27,11 @@ RESOURCES += \
include(controls.pri)
!static: include(designer/designer.pri)
+qtquickcompiler {
+ qmlfiles.prefix = /qt-project.org/imports/Qt/labs/controls
+ qmlfiles.files += $$QML_CONTROLS
+ RESOURCES += qmlfiles
+}
+
CONFIG += no_cxx_module
load(qml_plugin)
diff --git a/src/imports/controls/doc/images/qtlabscontrols-button-label.png b/src/imports/controls/doc/images/qtlabscontrols-button-contentItem.png
index 73d8f2fb..73d8f2fb 100644
--- a/src/imports/controls/doc/images/qtlabscontrols-button-label.png
+++ b/src/imports/controls/doc/images/qtlabscontrols-button-contentItem.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter1.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter1.png
new file mode 100644
index 00000000..ee03535f
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter1.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter2-listview-header.gif b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter2-listview-header.gif
new file mode 100644
index 00000000..17096519
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter2-listview-header.gif
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter2.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter2.png
new file mode 100644
index 00000000..c2c49e3e
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter2.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter3-listview-header.gif b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter3-listview-header.gif
new file mode 100644
index 00000000..07eb93b1
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter3-listview-header.gif
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter3-view-margins.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter3-view-margins.png
new file mode 100644
index 00000000..9ca0fe69
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter3-view-margins.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter3.gif b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter3.gif
new file mode 100644
index 00000000..1763b1f3
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter3.gif
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter4-long-message.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter4-long-message.png
new file mode 100644
index 00000000..acbe1886
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter4-long-message.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter4-message-timestamp.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter4-message-timestamp.png
new file mode 100644
index 00000000..e4a578cc
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter4-message-timestamp.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter4.gif b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter4.gif
new file mode 100644
index 00000000..dd47c4cb
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter4.gif
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-material-dark.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-material-dark.png
new file mode 100644
index 00000000..9a3d00bd
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-material-dark.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-material-test.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-material-test.png
new file mode 100644
index 00000000..501ea772
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-material-test.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-material.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-material.png
new file mode 100644
index 00000000..57782b58
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-material.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-universal-dark.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-universal-dark.png
new file mode 100644
index 00000000..22183c82
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-universal-dark.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-universal.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-universal.png
new file mode 100644
index 00000000..327076d3
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-universal.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-material-dark.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-material-dark.png
new file mode 100644
index 00000000..19a7b685
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-material-dark.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-material-test.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-material-test.png
new file mode 100644
index 00000000..4cc4caa3
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-material-test.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-material.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-material.png
new file mode 100644
index 00000000..bdc9bcd3
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-material.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-universal-dark.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-universal-dark.png
new file mode 100644
index 00000000..f10d6cb6
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-universal-dark.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-universal.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-universal.png
new file mode 100644
index 00000000..a6913c3c
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-universal.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-checkbox-label.png b/src/imports/controls/doc/images/qtlabscontrols-checkbox-contentItem.png
index d5a1ef2e..d5a1ef2e 100644
--- a/src/imports/controls/doc/images/qtlabscontrols-checkbox-label.png
+++ b/src/imports/controls/doc/images/qtlabscontrols-checkbox-contentItem.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-frame-frame.png b/src/imports/controls/doc/images/qtlabscontrols-frame-frame.png
deleted file mode 100644
index a379d915..00000000
--- a/src/imports/controls/doc/images/qtlabscontrols-frame-frame.png
+++ /dev/null
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-groupbox-frame.png b/src/imports/controls/doc/images/qtlabscontrols-groupbox-frame.png
deleted file mode 100644
index 2ed75011..00000000
--- a/src/imports/controls/doc/images/qtlabscontrols-groupbox-frame.png
+++ /dev/null
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-itemdelegate-label.png b/src/imports/controls/doc/images/qtlabscontrols-itemdelegate-contentItem.png
index 89f094c6..89f094c6 100644
--- a/src/imports/controls/doc/images/qtlabscontrols-itemdelegate-label.png
+++ b/src/imports/controls/doc/images/qtlabscontrols-itemdelegate-contentItem.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-radiobutton-label.png b/src/imports/controls/doc/images/qtlabscontrols-radiobutton-contentItem.png
index 457555b7..457555b7 100644
--- a/src/imports/controls/doc/images/qtlabscontrols-radiobutton-label.png
+++ b/src/imports/controls/doc/images/qtlabscontrols-radiobutton-contentItem.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-switch-label.png b/src/imports/controls/doc/images/qtlabscontrols-switch-contentItem.png
index 50f608ab..50f608ab 100644
--- a/src/imports/controls/doc/images/qtlabscontrols-switch-label.png
+++ b/src/imports/controls/doc/images/qtlabscontrols-switch-contentItem.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-toolbar-frame.png b/src/imports/controls/doc/images/qtlabscontrols-toolbar-frame.png
deleted file mode 100644
index 12b4c348..00000000
--- a/src/imports/controls/doc/images/qtlabscontrols-toolbar-frame.png
+++ /dev/null
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-toolbutton-label.png b/src/imports/controls/doc/images/qtlabscontrols-toolbutton-contentItem.png
index f4797098..f4797098 100644
--- a/src/imports/controls/doc/images/qtlabscontrols-toolbutton-label.png
+++ b/src/imports/controls/doc/images/qtlabscontrols-toolbutton-contentItem.png
Binary files differ
diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-button-label.qml b/src/imports/controls/doc/snippets/qtlabscontrols-button-contentItem.qml
index 4fbeab08..ee59ab7f 100644
--- a/src/imports/controls/doc/snippets/qtlabscontrols-button-label.qml
+++ b/src/imports/controls/doc/snippets/qtlabscontrols-button-contentItem.qml
@@ -32,7 +32,7 @@ Button {
width: 80
text: "Button"
Rectangle {
- anchors.fill: label
+ anchors.fill: contentItem
color: 'transparent'
border.color: 'red'
}
diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-checkbox-label.qml b/src/imports/controls/doc/snippets/qtlabscontrols-checkbox-contentItem.qml
index fcb3a49d..bef150a3 100644
--- a/src/imports/controls/doc/snippets/qtlabscontrols-checkbox-label.qml
+++ b/src/imports/controls/doc/snippets/qtlabscontrols-checkbox-contentItem.qml
@@ -31,7 +31,7 @@ import Qt.labs.controls 1.0
CheckBox {
text: "CheckBox"
Rectangle {
- anchors.fill: label
+ anchors.fill: contentItem
color: "transparent"
border.color: "red"
}
diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-frame-frame.qml b/src/imports/controls/doc/snippets/qtlabscontrols-frame-frame.qml
deleted file mode 100644
index e4c9e32b..00000000
--- a/src/imports/controls/doc/snippets/qtlabscontrols-frame-frame.qml
+++ /dev/null
@@ -1,40 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** 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 The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import Qt.labs.controls 1.0
-
-Frame {
- width: 100
- height: 100
- Rectangle {
- parent: frame
- anchors.fill: parent
- color: 'transparent'
- border.color: 'red'
- }
-}
diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-groupbox-frame.qml b/src/imports/controls/doc/snippets/qtlabscontrols-groupbox-frame.qml
deleted file mode 100644
index 49ecc00d..00000000
--- a/src/imports/controls/doc/snippets/qtlabscontrols-groupbox-frame.qml
+++ /dev/null
@@ -1,41 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** 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 The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import Qt.labs.controls 1.0
-
-GroupBox {
- width: 100
- height: 100
- title: "GroupBox"
- Rectangle {
- parent: frame
- anchors.fill: parent
- color: 'transparent'
- border.color: 'red'
- }
-}
diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-itemdelegate-label.qml b/src/imports/controls/doc/snippets/qtlabscontrols-itemdelegate-contentItem.qml
index 696560a5..43e6f85e 100644
--- a/src/imports/controls/doc/snippets/qtlabscontrols-itemdelegate-label.qml
+++ b/src/imports/controls/doc/snippets/qtlabscontrols-itemdelegate-contentItem.qml
@@ -33,7 +33,7 @@ ItemDelegate {
checked: true
checkable: true
Rectangle {
- anchors.fill: label
+ anchors.fill: contentItem
color: "transparent"
border.color: "red"
}
diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-radiobutton-label.qml b/src/imports/controls/doc/snippets/qtlabscontrols-radiobutton-contentItem.qml
index eab52fbe..14bb7c47 100644
--- a/src/imports/controls/doc/snippets/qtlabscontrols-radiobutton-label.qml
+++ b/src/imports/controls/doc/snippets/qtlabscontrols-radiobutton-contentItem.qml
@@ -31,7 +31,7 @@ import Qt.labs.controls 1.0
RadioButton {
text: "RadioButton"
Rectangle {
- anchors.fill: label
+ anchors.fill: contentItem
color: "transparent"
border.color: "red"
}
diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-switch-label.qml b/src/imports/controls/doc/snippets/qtlabscontrols-switch-contentItem.qml
index c739bf57..99f2af7e 100644
--- a/src/imports/controls/doc/snippets/qtlabscontrols-switch-label.qml
+++ b/src/imports/controls/doc/snippets/qtlabscontrols-switch-contentItem.qml
@@ -31,7 +31,7 @@ import Qt.labs.controls 1.0
Switch {
text: "Switch"
Rectangle {
- anchors.fill: label
+ anchors.fill: contentItem
color: "transparent"
border.color: "red"
}
diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-toolbar-frame.qml b/src/imports/controls/doc/snippets/qtlabscontrols-toolbar-frame.qml
deleted file mode 100644
index b887d464..00000000
--- a/src/imports/controls/doc/snippets/qtlabscontrols-toolbar-frame.qml
+++ /dev/null
@@ -1,38 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** 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 The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import Qt.labs.controls 1.0
-
-ToolBar {
- width: 100
- frame: Rectangle {
- anchors.fill: parent
- color: 'transparent'
- border.color: 'red'
- }
-}
diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-toolbutton-label.qml b/src/imports/controls/doc/snippets/qtlabscontrols-toolbutton-contentItem.qml
index 5a8c3a50..9a25d130 100644
--- a/src/imports/controls/doc/snippets/qtlabscontrols-toolbutton-label.qml
+++ b/src/imports/controls/doc/snippets/qtlabscontrols-toolbutton-contentItem.qml
@@ -31,7 +31,7 @@ import Qt.labs.controls 1.0
ToolButton {
text: "ToolButton"
Rectangle {
- anchors.fill: label
+ anchors.fill: contentItem
color: 'transparent'
border.color: 'red'
}
diff --git a/src/imports/controls/doc/src/qtlabscontrols-chattutorial.qdoc b/src/imports/controls/doc/src/qtlabscontrols-chattutorial.qdoc
new file mode 100644
index 00000000..eeadd070
--- /dev/null
+++ b/src/imports/controls/doc/src/qtlabscontrols-chattutorial.qdoc
@@ -0,0 +1,861 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/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$
+**
+****************************************************************************/
+
+/*!
+\example chattutorial
+\title Qt Labs Controls - Chat Tutorial
+\brief Tutorial about writing a basic chat client using Qt Labs Controls.
+\ingroup qtlabscontrols-examples
+
+This tutorial shows how to write a basic chat application using Qt Labs
+Controls. It will also explain how to integrate an SQL database into a Qt
+application.
+
+\section1 Chapter 1: Setting Up
+
+When setting up a new project, it's easiest to use
+\l {Qt Creator Manual}{Qt Creator}. For this project, we chose the
+\l {Creating Qt Quick Projects}{Qt Quick application} template, which creates a
+basic "Hello World" application with all of the necessary files.
+
+\section2 main.cpp
+
+As we created a Qt Quick application, our \c main.cpp has two includes:
+
+\quotefromfile chattutorial/chapter1-settingup/main.cpp
+\skipto include
+\printline include
+\printline include
+
+The first gives us access to QGuiApplication. All Qt applications require
+an application object, but the precise type depends on what the application
+does. QCoreApplication is sufficient for non-graphical applications.
+QGuiApplication is sufficient for graphical applications that do not use
+\l {Qt Widgets}, while QApplication is required for those that do.
+
+The second include makes QQmlApplicationEngine available, along with
+some useful functions required for making C++ types accessible from QML.
+
+Within \c main(), we set up the application object and QML engine:
+
+\skipto main
+\printuntil }
+
+To enable Qt's support for \l {High DPI Support in Qt}{high DPI scaling}, it
+is necessary to set an attribute before the application object is constructed.
+
+After that's done, we construct the application object, passing any application
+arguments provided by the user.
+
+Next, the QML engine is created. \l QQmlApplicationEngine is a convenient
+wrapper over QQmlEngine, providing the \l {QQmlApplicationEngine::load}{load()}
+function to easily load QML for an application. It also adds some convenience
+for using \l {Using File Selectors with Qt Labs Controls}{file selectors}.
+
+Once we've set up things in C++, we can move on to the user interface in QML.
+
+\section2 main.qml
+
+\quotefromfile chattutorial/chapter1-settingup/main.qml
+\skipto import
+\printuntil import Qt.labs.controls 1.0
+
+First, we import the \l {Qt Quick} module. This gives us
+access to graphical primitives such as \l Item, \l Rectangle, \l Text, and so
+on.
+For the full list of types, see the \l {Qt Quick QML Types} documentation.
+
+Next, we import the Qt Labs Controls module. Amongst other things, this
+makes \l ApplicationWindow available:
+
+\skipto ApplicationWindow
+\printuntil visible: true
+\printuntil }
+\printuntil }
+\printuntil }
+
+ApplicationWindow is a \l Window with some added convenience for creating a
+\l {ApplicationWindow::}{header} and a \l {ApplicationWindow::}{footer}.
+It also provides the foundation for \l {Popup}{popups} and supports some
+basic styling, such as the background \l {Window::}{color}.
+
+There are three properties that are almost always set when using
+ApplicationWindow: \l {Window::}{width}, \l {Window::}{height}, and
+\l {Window::}{visible}.
+Once we've set these, we have a properly sized, empty window ready to be
+filled with content.
+
+The first \e "screen" in our application will be a list of contacts. It would
+be nice to have some text at the top of each screen that describes its purpose.
+The header and footer properties of ApplicationWindow could work in
+this situation. They have some characteristics that make them ideal for
+items that should be displayed on every screen of an application:
+
+\list
+\li They are anchored to the top and bottom of the window, respectively.
+\li They fill the width of the window.
+\endlist
+
+However, when the contents of the header and footer varies depending on
+which screen the user is viewing, it can be much easier to use \l Page.
+For now, we'll just add one page, but in the next chapter, we'll demonstrate
+how to navigate between several pages.
+
+Now that we have a Page, we can assign a \l Label to its \l {Page::}{header}
+property. Label extends the primitive \l Text item from the Qt Quick module by
+adding \l {Styling Qt Labs Controls}{styling} and \l {Control::}{font}
+inheritance. This means that a Label can look different depending on which
+style is in use, and can also propagate its pixel size to its children.
+
+We want some distance between the top of the application window and the text,
+so we set the \l {Text::padding}{padding} property. This will allocate extra
+space on each side of the label (within its bounds). We could have also set the
+\l {Text::}{topPadding} and \l {Text::}{bottomPadding} properties explicitly.
+
+We set the text of the label using the \c qsTr() function, which ensures that
+the text can be translated by \l {Writing Source Code for Translation}{Qt's
+translation system}. It's a good idea to do this for text that will
+be visible to the end users of your application.
+
+By default, text is vertically aligned to the top of its bounds, while the
+horizontal alignment depends on the natural direction of the text; for example,
+text that is read from left to right will be aligned to the left. If we
+used these defaults, our text would be at the top-left corner of the window.
+This is not desirable for a header, so we align the text to the center of its
+bounds, both horizontally and vertically.
+
+\section2 The Project File
+
+The \c .pro or \l {Creating Project Files}{project} file contains all of the
+information needed by \l {qmake Manual}{qmake} to generate a Makefile, which is
+then used to compile and link the application.
+
+\quotefromfile chattutorial/chapter1-settingup/chapter1-settingup.pro
+\printline TEMPLATE
+
+The first line tells \c qmake which kind of project this is. We're building an
+application, so we use the \c app template.
+
+\printline QT
+
+The next line declares the Qt libraries that we want to use from C++.
+
+\printline CONFIG
+
+This line states that a C++11 compatible compiler is required to build the
+project.
+
+\printline SOURCES
+
+The \c SOURCES variable lists all of the source files that should be compiled.
+A similar variable, \c HEADERS, is available for header files.
+
+\printline RESOURCES
+
+The next line tells \c qmake that we have a collection of
+\l {The Qt Resource System}{resources} that should be built into the
+executable.
+
+\printline QML_IMPORT_PATH
+
+\c QML_IMPORT_PATH is added by Qt Creator in case you have a custom module that
+you'd like to be made available to Creator's code model.
+
+\printline include
+
+This line includes a generated \c .pri file that handles deployment of our
+application to certain devices.
+
+Now we can build and run the application:
+
+\image qtlabscontrols-chattutorial-chapter1.png
+
+\section1 Chapter 2: Lists
+
+In this chapter, we'll explain how to create a list of interactive items using
+\l ListView and \l ItemDelegate.
+
+ListView comes from the Qt Quick module, and displays a list of items
+populated from a \l {Model/View Programming}{model}. ItemDelegate comes from
+the Qt Labs Controls module, and provides a standard view item for use in views
+and controls such as ListView and \l ComboBox. For example, each ItemDelegate
+can display text, be checked on and off, and react to mouse clicks.
+
+Here is our ListView:
+
+\quotefromfile chattutorial/chapter2-lists/main.qml
+\dots 8
+\codeline
+\skipto ListView
+\printuntil }
+\printuntil }
+\printuntil }
+\codeline
+\dots 8
+
+\section2 Sizing and Positioning
+
+The first thing we do is set a size for the view. It should fill the available
+space on the page, so we use \l {Item::anchors}{anchors.fill}. Note that
+Page ensures that its header and footer have enough of their own space
+reserved, so the view in this case will sit below the header, for example.
+
+Next, we set \l {Flickable::leftMargin}{margins} around the ListView to put
+some distance between it and the edges of the window. The margin properties
+reserve space within the bounds of the view, which means that the empty areas
+can still be \e "flicked" by the user.
+
+The items should be nicely spaced out within the view, so the
+\l {ListView::}{spacing} property is set to \c 20.
+
+\section2 Model
+
+In order to quickly populate the view with some items, we've used a JavaScript
+array as the model. One of the greatest strengths of QML is its ability to
+make prototyping an application extremely quick, and this is an example of
+that. It's also possible to simply assign a \l {Integers as Models}{number} to
+the model property to indicate how many items you need. For example, if you
+assign \c 10 to the \c model property, each item's display text will be a
+number from \c 0 to \c 9.
+
+However, once the application gets past the prototype stage, it quickly becomes
+necessary to use some real data. For this, it's best to use a proper C++ model
+by \l {QAbstractItemModel subclass}{subclassing QAbstractItemModel}.
+
+\section2 Delegate
+
+On to the \l {ListView::}{delegate}. We assign the corresponding text from the
+model to the \l {ItemDelegate::}{text} property of ItemDelegate. The exact
+manner in which the data from the model is made available to each delegate
+depends on the type of model used. See \l {Models and Views in Qt Quick} for
+more information.
+
+In our application, the width of each item in the view should be the same
+as the width of the view. This ensures that the user has a lot of room with
+which to select a contact from the list, which is an important factor on
+devices with small touch screens, like mobile phones. However, the width of the
+view includes our \c 48 pixel margins, so we must account for that in our
+assignment to the width property.
+
+Next, we define an \l Image. This will display a picture of the user's contact.
+The image will be \c 40 pixels wide and \c 40 pixels high. We'll base the
+height of the delegate on the image's height, so that we don't have any empty
+vertical space.
+
+\image qtlabscontrols-chattutorial-chapter2.png
+
+\section1 Chapter 3: Navigation
+
+In this chapter, you'll learn how to use \l StackView to navigate between pages
+in an application. Here's the revised \c main.qml:
+
+\quotefromfile chattutorial/chapter3-navigation/main.qml
+\skipto import
+\printuntil }
+\printuntil }
+\printuntil }
+
+\section2 StackView
+
+As its name suggests, StackView provides stack-based navigation. The last item
+to be \e "pushed" onto the stack is the first one to be removed, and the
+top-most item is always the one that is visible.
+
+In the same manner as we did with Page, we tell the StackView to fill the
+application window. The only thing left to do after that is to give it an item
+to display, via \l {StackView::}{initialItem}. StackView accepts
+\l {Item}{items}, \l {Component}{components} and \l [QML]{url}{URLs}.
+
+You'll notice that we moved the code for the contact list into
+\c ContactPage.qml. It's a good idea to do this as soon as you have a general
+idea of which screens your application will contain. Doing so not only makes
+your code easier to read, but ensures that items are only instantiated from
+a given component when completely necessary, reducing memory usage.
+
+\note Qt Creator provides several convenient
+\l {Refactoring QML Code}{refactoring options for QML}, one of which allows you
+to move a block of code into a separate file (\c {Alt + Enter > Move Component
+into Separate File}).
+
+Another thing to consider when using ListView is whether to refer to it by
+\l {Item::}{id}, or use the attached \l {ListView::view}{ListView.view}
+property. The best approach depends on a few different factors. Giving the
+view an id will result in shorter and more efficient binding expressions, as
+the attached property has a very small amount of overhead. However, if you plan
+on reusing the delegate in other views, it is better to use the attached
+properties to avoid tying the delegate to a particular view. For example, using
+the attached properties, the \c width assignment in our delegate becomes:
+
+\code
+width: ListView.view.width - ListView.view.leftMargin - ListView.view.rightMargin
+\endcode
+
+In chapter 2, we added a ListView below the header. If you run the application
+for that chapter, you'll see that the contents of the view can be scrolled over
+the top of the header:
+
+\image qtlabscontrols-chattutorial-chapter2-listview-header.gif
+
+This is not that nice, especially if the text in the
+delegates is long enough that it reaches the text in the header. What we
+ideally want to do is to have a solid block of color under the header text, but
+\e {above} the view. This ensures that the listview contents can't visually
+interfere with the header contents. Note that it's also possible to achieve
+this by setting the \l {Item::}{clip} property of the view to \c true, but
+doing so \l {Clipping}{can affect performance}.
+
+\l ToolBar is the right tool for this job. It is a container of both
+application-wide and context-sensitive actions and controls, such as navigation
+buttons and search fields. Best of all, it has a background color that, as
+usual, comes from the application style. Here it is in action:
+
+\quotefromfile chattutorial/chapter3-navigation/ContactPage.qml
+\skipto header
+\printuntil }
+\printuntil }
+
+\image qtlabscontrols-chattutorial-chapter3-listview-header.gif
+
+It has no layout of its own, so we center the label within it ourselves.
+
+The rest of the code is the same as it was in chapter 2, except that we've
+taken advantage of the \l {AbstractButton::}{clicked} signal to push the next
+page onto the stackview:
+
+\skipto onClicked
+\printline onClicked
+
+When pushing a \l Component or \l [QML] url onto StackView, it's often
+necessary to initialize the (eventually) instantiated item with some variables.
+StackView's \l push() function accounts for this, by taking a JavaScript object
+as the second argument. We use this to provide the next page with a contact's
+name, which it then uses to display the relevant conversation. Note the
+\c {root.StackView.view.push} syntax; this is necessary because of how
+\l {A Note About Accessing Attached Properties and Signal Handlers}
+{attached properties} work.
+
+Let's step through \c ConversationPage.qml, beginning with the imports:
+
+\quotefromfile chattutorial/chapter3-navigation/ConversationPage.qml
+\skipto import
+\printline import
+\printline import
+\printline import
+
+These are the same as before, except for the addition of the \c QtQuick.Layouts
+import, which we'll cover shortly.
+
+\skipto Page
+\printuntil }
+\printuntil }
+\printuntil }
+\dots 4
+
+The root item of this component is another Page, which has a custom property
+called \c inConversationWith. For now, this property will simply determine what
+the label in the header displays. Later on, we'll use it in the SQL query that
+populates the list of messages in the conversation.
+
+To allow the user to go back to the Contact page, we add a \l ToolButton that
+calls \l {StackView::pop}{pop()} when clicked. A \l ToolButton is functionally
+similar to \l Button, but provides a look that is more suitable within a
+ToolBar.
+
+There are two ways of laying out items in QML: \l {Item Positioners}
+and \l {Qt Quick Layouts}. Item positioners (\l Row, \l Column, and so on) are
+useful for situations where the size of items is known or fixed, and all that
+is required is to neatly position them in a certain formation. The layouts in
+Qt Quick Layouts can both position and resize items, making them well suited
+for resizable user interfaces. Below, we use \l ColumnLayout to vertically
+lay out a ListView and a \l Pane:
+
+\skipto ColumnLayout
+\printto Layout.margins
+\codeline
+\dots 12
+\codeline
+\skipuntil ScrollBar
+\printline }
+\codeline
+\dots 8
+\codeline
+\printuntil Layout.fillWidth: true
+\dots 12
+\skipuntil }
+\skipuntil }
+\skipuntil }
+\skipuntil }
+\printline }
+
+Pane is basically a rectangle whose color comes from the application's style.
+It is similar to \l Frame, with the only difference being that it has no stroke
+around its border.
+
+Items that are direct children of a layout have various
+\l {Layout}{attached properties} available to them. We use
+\l {Layout::fillWidth}{Layout.fillWidth} and
+\l {Layout::fillHeight}{Layout.fillHeight} on the ListView to ensure
+that it takes as much space within the ColumnLayout as it can. The
+same is done for the Pane. As ColumnLayout is a vertical layout, there
+aren't any items to the left or right of each child, so this will result in
+each item consuming the entire width of the layout.
+
+On the other hand, the \l {Layout::fillHeight}{Layout.fillHeight} statement in
+the ListView will enable it to occupy the remaining space that is left after
+accommodating the Pane.
+
+Let's look at the listview in detail:
+
+\quotefromfile chattutorial/chapter3-navigation/ConversationPage.qml
+\skipto ListView
+\printuntil ScrollBar
+\printuntil }
+
+After filling the width and height of its parent, we also set some margins on
+the view. This gives us a nice alignment with the placeholder text in the
+"compose message" field:
+
+\omit
+TODO: recreate image
+\endomit
+\image qtlabscontrols-chattutorial-chapter3-view-margins.png
+
+Next, we set \l {ListView::}{displayMarginBeginning} and \l
+{ListView::}{displayMarginEnd}. These properties ensure that the delegates
+outside the bounds of the view do not disappear while scrolling at the edges of
+the view. It's easiest to understand this by commenting out the properties and
+seeing what happens when scrolling the view.
+
+We then flip the vertical direction of the view, so that first items are at the
+bottom. The delegates are spaced out by 12 pixels, and a \e "dummy" model is
+assigned for testing purposes, until we implement the real model in chapter 4.
+
+Within the delegate, we declare a \l Row as the root item, as we want the
+avatar to be followed by the message contents, as shown in the image above.
+
+Messages sent by the user should be distinguished from those sent by a contact.
+For now, we set a dummy property \c sentByMe, which simply uses the index
+of the delegate to alternate between different authors. Using this property,
+we distinguish between different authors in three ways:
+
+\list
+\li Messages sent by the user are aligned to the right side of the screen
+by setting \c anchors.right to \c parent.right.
+
+\li By setting the \c visible property of the avatar (which is simply a
+Rectangle for now) based on \c sentByMe, we only show it if the message was
+sent by a contact.
+
+\li We change the color of the rectangle depending on the author. Since we
+do not want to display dark text on a dark background, and vice versa, we also
+set the text color depending on who the author is. In chapter 5, we'll see how
+styling takes care of matters like this for us.
+\endlist
+
+At the bottom of the screen, we place a \l TextArea item to allow multi-line
+text input, and a button to send the message. We use Pane to cover the area
+under these two items, in the same way that we use ToolBar to prevent the
+contents of the listview from interfering with the page header:
+
+\skipto Pane
+\printuntil }
+\printuntil }
+\printuntil }
+\printuntil }
+
+The TextArea should fill the available width of the screen. We assign some
+placeholder text to provide a visual cue to the user as to where they should
+begin typing. The text within the input area is wrapped to ensure that it
+does not go outside of the screen.
+
+Finally, the button is only enabled when there is actually a message to send.
+
+\image qtlabscontrols-chattutorial-chapter3.gif
+
+\section1 Chapter 4: Models
+
+In chapter 4, we'll take you through the process of creating both read-only and
+read-write SQL models in C++ and exposing them to QML to populate views.
+
+\section2 QSqlQueryModel
+
+In order to keep the tutorial simple, we've chosen to make the list of user
+contacts non-editable. \l QSqlQueryModel is the logical choice for this
+purpose, as it provides a read-only data model for SQL result sets.
+
+Let's take a look at our \c SqlContactModel class that derives from
+QSqlQueryModel:
+
+\quotefromfile chattutorial/chapter4-models/sqlcontactmodel.h
+\skipto #include
+\printuntil };
+
+There's not much going on here, so let's move on to the \c .cpp file:
+
+\quotefromfile chattutorial/chapter4-models/sqlcontactmodel.cpp
+\skipto #include
+\printuntil }
+\printuntil }
+\printuntil }
+
+We include the header file of our class and those that we require from Qt. We
+then define a static function named \c createTable() that we'll use to create
+the SQL table (if it doesn't already exist), and then populate it with some
+dummy contacts.
+
+The call to \l {QSqlDatabase::database}{database()} might look a little bit
+confusing because we have not set up a specific database yet. If no connection
+name is passed to this function, it will return a \e {"default connection"},
+whose creation we will cover soon.
+
+\skipto SqlContactModel
+\printuntil }
+
+In the constructor, we call \c createTable(). We then construct a query that
+will be used to populate the model. In this case, we are simply interested in
+all rows of the \c Contacts table.
+
+\section2 QSqlTableModel
+
+\c SqlConversationModel is more complex:
+
+\quotefromfile chattutorial/chapter4-models/sqlconversationmodel.h
+\skipto #include
+\printuntil };
+
+We use both the \c Q_PROPERTY and \c Q_INVOKABLE macros, and therefore we must
+let \l {Using the Meta-Object Compiler (moc)}{moc} know by using the \c
+Q_OBJECT macro.
+
+The \c recipient property will be set from QML to let the model know which
+conversation it should retrieve messages for.
+
+We override the \l {QSqlTableModel::data}{data()} and
+\l {QSqlTableModel::roleNames}{roleNames()} functions so that we can use our
+custom roles in QML.
+
+We also define the \c sendMessage() function that we want to call from
+QML, hence the \c Q_INVOKABLE macro.
+
+Let's take a look at the \c .cpp file:
+
+\quotefromfile chattutorial/chapter4-models/sqlconversationmodel.cpp
+\skipto #include
+\printuntil }
+\printuntil }
+\printuntil }
+
+This is very similar to \c sqlcontactmodel.cpp, with the exception that we are
+now operating on the \c Conversations table. We also define
+\c conversationsTableName as a static const variable, as we use it in a couple
+of places throughout the file.
+
+\skipto SqlConversationModel
+\printuntil }
+
+As with \c SqlContactModel, the first thing that we do in the constructor is
+create the table. We tell QSqlTableModel the name of the table we'll be using
+via the \l {QSqlTableModel::setTable}{setTable()} function. To ensure that the
+latest messages in the conversation are shown first, we sort the query results
+by the \c timestamp field in descending order. This goes hand in hand with
+setting ListView's \l {ListView::}{verticalLayoutDirection} property to
+\c ListView.BottomToTop (which we covered in chapter 3).
+
+\skipto ::recipient(
+\printuntil }
+\printuntil }
+
+In \c setRecipient(), we set a filter over the results returned from
+the database.
+
+\skipto ::data(
+\printuntil }
+
+The \c data() function falls back to QSqlTableModel's implementation if the
+role is not a custom user role. If the role is a user role, we can subtract
+Qt::UserRole from it to get the index of that field and then use that to find
+the value that we need to return.
+
+\skipto ::roleNames(
+\printuntil }
+
+In \c roleNames(), we return a mapping of our custom role values to role names.
+This enables us to use these roles in QML. It can be useful to declare an enum
+to hold all of the role values, but since we don't refer to any specific value
+in code outside of this function, we don't bother.
+
+\skipto ::sendMessage(
+\printuntil }
+
+The \c sendMessage() function uses the given \c recipient and a \c message to
+insert a new record into the database. Due to our usage
+of \l QSqlTableModel::OnManualSubmit, we must manually call
+\l {QSqlTableModel::submitAll}{submitAll()}.
+
+\section2 Connecting to the Database and Registering Types With QML
+
+Now that we've established the model classes, let's take a look at \c main.cpp:
+
+\quotefromfile chattutorial/chapter4-models/main.cpp
+\skipto #include
+\printuntil return app.exec();
+\printuntil }
+
+\c connectToDatabase() creates the connection to the SQLite database, creating
+the actual file if it doesn't already exist.
+
+Within \c main(), we call \l {qmlRegisterType}{qmlRegisterType()} to
+register our models as types within QML.
+
+\section2 Using the Models in QML
+
+Now that we have the models available as QML types, there are some minor
+changes to be done to \c ContactPage.qml. To be able to use the types,
+we must first import them using the URI we set in \c main.cpp:
+
+\quotefromfile chattutorial/chapter4-models/ContactPage.qml
+\skipto import org.qtproject.examples.chattutorial 1.0
+\printline import org.qtproject.examples.chattutorial 1.0
+
+We then replace the dummy model with the proper one:
+
+\skipto model: SqlContactModel {}
+\printline model: SqlContactModel {}
+
+Within the delegate, we use a different syntax for accessing the model data:
+
+\skipto text: model.display
+\printline text: model.display
+
+In \c ConversationPage.qml, we add the same \c chattutorial import, and replace
+the dummy model:
+
+\quotefromfile chattutorial/chapter4-models/ConversationPage.qml
+\skipto model: SqlConversationModel {
+\printuntil }
+
+Within the model, we set the \c recipient property to the name of the contact
+for which the page is being displayed.
+
+The root delegate item changes from a Row to a Column, to accommodate the
+timestamp that we want to display below every message:
+
+\skipto delegate: Column {
+\printuntil Label {
+\printuntil }
+\printuntil }
+\printuntil }
+\printuntil }
+\printuntil }
+
+\image qtlabscontrols-chattutorial-chapter4-message-timestamp.png
+
+Now that we have a proper model, we can use its \c recipient role in the
+expression for the \c sentByMe property.
+
+The Rectangle that was used for the avatar has been converted into an Image.
+The image has its own implicit size, so we don't need to specify it explicitly.
+As before, we only show the avatar when the author isn't the user, except this
+time we set the \c source of the image to an empty URL instead of using the
+\c visible property.
+
+We want each message background to be slightly wider (12 pixels each side) than
+its text. However, if it's too long, we want to limit its width to the edge
+of the listview, hence the usage of \c Math.min(). When the message wasn't sent
+by us, an avatar will always come before it, so we account for that by
+subtracting the width of the avatar and the row spacing.
+
+For example, in the image above, the implicit width of the message text is the
+smaller value. However, in the image below, the message text is quite long, so
+the smaller value (the width of the view) is chosen, ensuring that the text
+stops at the opposite edge of the screen:
+
+\image qtlabscontrols-chattutorial-chapter4-long-message.png
+
+In order to display the timestamp for each message that we discussed earlier,
+we use a Label. The date and time are formatted with
+\l {QtQml::Qt::formatDateTime}{Qt.formatDateTime()}, using a custom format.
+
+The \e "send" button must now react to being clicked:
+
+\skipto Button
+\printuntil }
+\printuntil }
+
+First, we call the invokable \c sendMessage() function of the model, which
+inserts a new row into the Conversations database table. Then, we clear the
+text field to make way for future input.
+
+\image qtlabscontrols-chattutorial-chapter4.gif
+
+\section1 Chapter 5: Styling
+
+Styles in Qt Labs Controls are designed to work on any platform. In this
+chapter, we'll do some minor visual tweaks to make sure our application
+looks good when run with the \l {Default Style}{Default},
+\l {Material Style}{Material}, and \l {Universal Style}{Universal} styles.
+
+So far, we've just been testing the application with the Default style. If we
+\l {Selecting and Configuring Styles}{run it with the Material style}, for
+example, we'll immediately see some issues. Here is the Contacts page:
+
+\image qtlabscontrols-chattutorial-chapter5-contacts-material-test.png
+
+The header text is black on a dark blue background, which is very difficult to
+read. The same thing occurs with the Conversations page:
+
+\image qtlabscontrols-chattutorial-chapter5-conversations-material-test.png
+
+The solution is to tell the toolbar that it should use the \e "Dark" theme, so
+that this information is propagated to its children, allowing them to switch
+their text color to something lighter. The simplest way of doing so is to
+import the Material style directly and use the Material attached property:
+
+\code
+ import Qt.labs.controls.material 1.0
+
+ // ...
+
+ header: ToolBar {
+ Material.theme: Material.Dark
+
+ // ...
+ }
+\endcode
+
+However, this brings with it a hard dependency to the Material style; the
+Material style plugin \e must be deployed with the application, even if the
+target device doesn't use it, otherwise the QML engine will fail to find the
+import.
+
+Instead, it is better to rely on Qt Labs Controls' built-in support for
+\l {Using File Selectors with Qt Labs Controls}{style-based file selectors}.
+To do this, we must move the ToolBar out into its own file. We'll call it
+\c ChatToolBar.qml. This will be the \e "default" version of the file, which
+means that it will be used when the \l {Default Style}{Default style} is in
+use. Here's the new file:
+
+\quotefromfile chattutorial/chapter5-styling/ChatToolBar.qml
+\skipto import
+\printuntil }
+
+As we only use the ToolBar type within this file, we only need the
+Qt Labs Controls import. The code itself has not changed from how it was
+in \c ContactPage.qml, which is how it should be; for the default version
+of the file, nothing needs to be different.
+
+Back in \c ContactPage.qml, we update the code to use the new type:
+
+\quotefromfile chattutorial/chapter5-styling/ContactPage.qml
+\skipto ToolBar
+\printuntil }
+\printuntil }
+
+Now we need to add the Material version of the toolbar. File selectors expect
+variants of a file to be in appropriately named directories that exist
+alongside the default version of the file. This means that we need to add a
+folder named "+material" in the same directory that ChatToolBar.qml is in:
+the root folder. The "+" is required by \l QFileSelector as a way of ensuring
+that the selection feature is not accidentally triggered.
+
+Here's \c +material/ChatToolBar.qml:
+
+\quotefromfile chattutorial/chapter5-styling/+material/ChatToolBar.qml
+\skipto import
+\printuntil }
+
+We'll make the same changes to \c ConversationPage.qml:
+
+\quotefromfile chattutorial/chapter5-styling/ConversationPage.qml
+\skipto header: ChatToolBar
+\printuntil }
+\printuntil }
+\printuntil }
+
+Now both pages look correct:
+
+\image qtlabscontrols-chattutorial-chapter5-contacts-material.png
+\image qtlabscontrols-chattutorial-chapter5-conversations-material.png
+
+Let's try out the Universal style:
+
+\image qtlabscontrols-chattutorial-chapter5-contacts-universal.png
+\image qtlabscontrols-chattutorial-chapter5-conversations-universal.png
+
+No issues there. For a relatively simple application such as this one, there
+should be very few adjustments necessary when switching styles.
+
+Now let's try each style's dark theme. The Default style has no dark theme, as
+it would add a slight overhead to a style that is designed to be as performant
+as possible. We'll test out the Material style first, so add an entry to
+\c qtlabscontrols.conf that tells it to use its dark theme:
+
+\code
+[material]
+Primary=Indigo
+Accent=Indigo
+Theme=Dark
+\endcode
+
+Once this is done, build and run the application. This is what you should see:
+
+\image qtlabscontrols-chattutorial-chapter5-contacts-material-dark.png
+\image qtlabscontrols-chattutorial-chapter5-conversations-material-dark.png
+
+Both pages look fine. Now add an entry for the Universal style:
+
+\code
+[universal]
+Theme=Dark
+\endcode
+
+After building and running the application, you should see these results:
+
+\image qtlabscontrols-chattutorial-chapter5-contacts-universal-dark.png
+\image qtlabscontrols-chattutorial-chapter5-conversations-universal-dark.png
+
+\section1 Summary
+
+In this tutorial, we've taken you through the following steps of writing a
+basic application using Qt Labs Controls:
+
+\list
+\li Creating a new project using Qt Creator.
+\li Setting up a basic ApplicationWindow.
+\li Defining headers and footers with Page.
+\li Displaying content in a ListView.
+\li Refactoring components into their own files.
+\li Navigating between screens with StackView.
+\li Using layouts to allow an application to resize gracefully.
+\li Implementing both custom read-only and writable models that integrate an
+SQL database into the application.
+\li Integrating C++ with QML via \l Q_PROPERTY, \l Q_INVOKABLE, and
+\l qmlRegisterType().
+\li Testing and configuring multiple styles.
+\endlist
+
+*/
diff --git a/src/imports/controls/doc/src/qtlabscontrols-customize.qdoc b/src/imports/controls/doc/src/qtlabscontrols-customize.qdoc
index 4aff46a4..1187b07d 100644
--- a/src/imports/controls/doc/src/qtlabscontrols-customize.qdoc
+++ b/src/imports/controls/doc/src/qtlabscontrols-customize.qdoc
@@ -57,7 +57,7 @@
\section1 Customizing Button
Button consists of two visual items: \l {Control::background}{background}
- and \l {AbstractButton::label}{label}.
+ and \l {Control::contentItem}{content item}.
\section3 Background
@@ -65,17 +65,17 @@
\snippet Button.qml background
- \section3 Label
+ \section3 Content item
- \image qtlabscontrols-button-label.png
+ \image qtlabscontrols-button-contentItem.png
- \snippet Button.qml label
+ \snippet Button.qml contentItem
\section1 Customizing CheckBox
CheckBox consists of three visual items: \l {Control::background}{background},
- \l {AbstractButton::label}{label} and \l {AbstractButton::indicator}{indicator}.
+ \l {Control::contentItem}{contentItem} and \l {AbstractButton::indicator}{indicator}.
\section3 Background
@@ -83,11 +83,11 @@
CheckBox has no background item by default.
- \section3 Label
+ \section3 Content item
- \image qtlabscontrols-checkbox-label.png
+ \image qtlabscontrols-checkbox-contentItem.png
- \snippet CheckBox.qml label
+ \snippet CheckBox.qml contentItem
\section3 Indicator
@@ -162,38 +162,25 @@
\section1 Customizing Frame
- Frame consists of two visual items: \l {Control::background}{background}
- and \l {Frame::frame}{frame}.
+ Frame consists of one visual item: \l {Control::background}{background}.
\section3 Background
\image qtlabscontrols-frame-background.png
- Frame has no background item by default.
-
- \section3 Frame
-
- \image qtlabscontrols-frame-frame.png
-
- \snippet Frame.qml frame
+ \snippet Frame.qml background
\section1 Customizing GroupBox
- GroupBox consists of three visual items: \l {Control::background}{background},
- \l {Frame::frame}{frame} and \l {GroupBox::label}{label}.
+ GroupBox consists of two visual items: \l {Control::background}{background}
+ and \l {GroupBox::label}{label}.
\section3 Background
\image qtlabscontrols-groupbox-background.png
- GroupBox has no background item by default.
-
- \section3 Frame
-
- \image qtlabscontrols-groupbox-frame.png
-
- \snippet GroupBox.qml frame
+ \snippet GroupBox.qml background
\section3 Label
@@ -205,7 +192,7 @@
\section1 Customizing ItemDelegate
ItemDelegate consists of three visual items: \l {Control::background}{background},
- \l {AbstractButton::label}{label} and \l {AbstractButton::indicator}{indicator}.
+ \l {Control::contentItem}{content item} and \l {AbstractButton::indicator}{indicator}.
The indicator is only visible for \l {AbstractButton::checkable}{checkable} items.
\section3 Background
@@ -214,11 +201,11 @@
\snippet ItemDelegate.qml background
- \section3 Label
+ \section3 Content item
- \image qtlabscontrols-itemdelegate-label.png
+ \image qtlabscontrols-itemdelegate-contentItem.png
- \snippet ItemDelegate.qml label
+ \snippet ItemDelegate.qml contentItem
\section3 Indicator
@@ -292,7 +279,7 @@
\section1 Customizing RadioButton
RadioButton consists of three visual items: \l {Control::background}{background},
- \l {AbstractButton::label}{label} and \l {AbstractButton::indicator}{indicator}.
+ \l {Control::contentItem}{content item} and \l {AbstractButton::indicator}{indicator}.
\section3 Background
@@ -300,11 +287,11 @@
RadioButton has no background item by default.
- \section3 Label
+ \section3 Content item
- \image qtlabscontrols-radiobutton-label.png
+ \image qtlabscontrols-radiobutton-contentItem.png
- \snippet RadioButton.qml label
+ \snippet RadioButton.qml contentItem
\section3 Indicator
@@ -484,7 +471,7 @@
\section1 Customizing Switch
Switch consists of three visual items: \l {Control::background}{background},
- \l {AbstractButton::label}{label} and \l {AbstractButton::indicator}{indicator}.
+ \l {Control::contentItem}{content item} and \l {AbstractButton::indicator}{indicator}.
\section3 Background
@@ -492,11 +479,11 @@
Switch has no background item by default.
- \section3 Label
+ \section3 Content item
- \image qtlabscontrols-switch-label.png
+ \image qtlabscontrols-switch-contentItem.png
- \snippet Switch.qml label
+ \snippet Switch.qml contentItem
\section3 Indicator
@@ -533,8 +520,7 @@
\section1 Customizing ToolBar
- ToolBar consists of two visual items: \l {Control::background}{background} and
- \l {Frame::frame}{frame}.
+ ToolBar consists of one visual item: \l {Control::background}{background}.
\section3 Background
@@ -542,17 +528,11 @@
\snippet ToolBar.qml background
- \section3 Frame
-
- \image qtlabscontrols-toolbar-frame.png
-
- ToolBar has no frame item by default.
-
\section1 Customizing ToolButton
ToolButton consists of two visual items: \l {Control::background}{background}
- and \l {AbstractButton::label}{label}.
+ and \l {Control::contentItem}{content item}.
\section3 Background
@@ -560,11 +540,11 @@
\snippet ToolButton.qml background
- \section3 Label
+ \section3 Content item
- \image qtlabscontrols-toolbutton-label.png
+ \image qtlabscontrols-toolbutton-contentItem.png
- \snippet ToolButton.qml label
+ \snippet ToolButton.qml contentItem
\section1 Customizing Tumbler
diff --git a/src/imports/controls/doc/src/qtlabscontrols-differences.qdoc b/src/imports/controls/doc/src/qtlabscontrols-differences.qdoc
index 7fcce7a3..87bf152d 100644
--- a/src/imports/controls/doc/src/qtlabscontrols-differences.qdoc
+++ b/src/imports/controls/doc/src/qtlabscontrols-differences.qdoc
@@ -155,7 +155,7 @@
\qml
Button {
- label: Label {
+ contentItem: Label {
// ...
}
}
diff --git a/src/imports/controls/doc/src/qtlabscontrols-fileselectors.qdoc b/src/imports/controls/doc/src/qtlabscontrols-fileselectors.qdoc
new file mode 100644
index 00000000..4e14c37b
--- /dev/null
+++ b/src/imports/controls/doc/src/qtlabscontrols-fileselectors.qdoc
@@ -0,0 +1,141 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/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 qtlabscontrols-fileselectors.html
+ \title Using File Selectors with Qt Labs Controls
+
+ \l {QFileSelector}{File selectors} provide a convenient way of selecting
+ file variants. Qt offers the platform name and the locale as built-in
+ selectors. Qt Labs Controls extends the built-in selectors with the name
+ of the style that an application is running with.
+
+ By using file selectors, style-specific tweaks can be applied without
+ creating a hard dependency to a style. From the available file variants,
+ only the selected QML file is loaded by the QML engine. Each file variant
+ can assume the context, that is, a specific style. This typically leads
+ to some code duplication, but on the other hand, cuts the aforementioned
+ hard dependency to the style, and leads to simpler and more efficient
+ QML code. The same technique is used to implement the \l {Styling Qt
+ Labs Controls}{Qt Labs Controls styles}.
+
+ The following example demonstrates a custom rounded button that has a
+ styled drop shadow in the \l {Material Style}{Material style}, and looks
+ flat in other styles. The files are organized so that the Material version
+ of \c CustomButton.qml is placed into a \c +material sub-directory.
+
+ \code
+ :/main.qml
+ :/CustomButton.qml
+ :/+material/CustomButton.qml
+ \endcode
+
+ By default, \c main.qml will use \c CustomButton.qml for the \c CustomButton
+ type. However, when the application is run with the Material style, the
+ \c material selector will be present and the \c +material/CustomButton.qml
+ version will be used instead.
+
+ \code
+ // main.qml
+ import QtQuick 2.6
+ import Qt.labs.controls 1.0
+
+ ApplicationWindow {
+ id: window
+ visible: true
+
+ CustomButton {
+ text: "Button"
+ anchors.centerIn: parent
+ }
+ }
+ \endcode
+
+ The base implementation of the custom button is a simple rounded
+ flat button.
+
+ \code
+ // CustomButton.qml
+ import QtQuick 2.6
+ import Qt.labs.controls 1.0
+
+ Button {
+ id: control
+
+ background: Rectangle {
+ radius: width / 2
+ implicitWidth: 36
+ implicitHeight: 36
+ color: control.pressed ? "#ccc" : "#eee"
+ }
+ }
+ \endcode
+
+ The Material style's implementation of the custom button imports the
+ Material style, requests a dark theme to get light text, and creates
+ a drop shadow for the background.
+
+ \code
+ // +material/CustomButton.qml
+ import QtQuick 2.6
+ import QtGraphicalEffects 1.0
+ import Qt.labs.controls 1.0
+ import Qt.labs.controls.material 1.0
+
+ Button {
+ id: control
+
+ Material.theme: Material.Dark
+
+ background: Rectangle {
+ implicitWidth: 48
+ implicitHeight: 48
+ color: Material.accentColor
+ radius: width / 2
+
+ layer.enabled: control.enabled
+ layer.effect: DropShadow {
+ verticalOffset: 1
+ color: Material.dropShadowColor
+ samples: control.pressed ? 20 : 10
+ spread: 0.5
+ }
+ }
+ }
+ \endcode
+
+ \note It is recommended to use \l QQmlApplicationEngine, which internally
+ creates a \l QQmlFileSelector instance. This is all that is needed to take
+ QML file selectors in use.
+
+ \section1 Related Information
+ \list
+ \li \l {QFileSelector}
+ \li \l {QQmlFileSelector}
+ \li \l {Styling Qt Labs Controls}
+ \endlist
+*/
diff --git a/src/imports/controls/doc/src/qtlabscontrols-index.qdoc b/src/imports/controls/doc/src/qtlabscontrols-index.qdoc
index 2f554db7..e8fa2303 100644
--- a/src/imports/controls/doc/src/qtlabscontrols-index.qdoc
+++ b/src/imports/controls/doc/src/qtlabscontrols-index.qdoc
@@ -48,6 +48,7 @@
\li \l{Getting Started with Qt Labs Controls}
\li \l{Styling Qt Labs Controls}
\li \l{High-DPI Support in Qt Labs Controls}
+ \li \l{Using File Selectors with Qt Labs Controls}
\li \l{Differences between Qt Quick Controls}
\endlist
diff --git a/src/imports/controls/doc/src/qtlabscontrols-material.qdoc b/src/imports/controls/doc/src/qtlabscontrols-material.qdoc
index e2cadbda..d5a3bd00 100644
--- a/src/imports/controls/doc/src/qtlabscontrols-material.qdoc
+++ b/src/imports/controls/doc/src/qtlabscontrols-material.qdoc
@@ -116,13 +116,20 @@
\image qtlabscontrols-material-dark.png
\endtable
- \note The Material style must be separately imported to gain access to
- these style-specific attributes. It should be noted that regardless of the
- references to the Material style, the same application code runs with any
- other style. The Material style-specific attributes only have an effect
- when the application is run with the Material style. Furthermore, in case
- of explicit Material style-specific references, the Material style must
- be deployed with the application.
+ \section2 Dependency
+
+ The Material style must be separately imported to gain access to the
+ attributes that are specific to the Material style. It should be noted
+ that regardless of the references to the Material style, the same
+ application code runs with any other style. Material-specific attributes
+ only have an effect when the application is run with the Material style.
+
+ If the Material style is imported in a QML file that is always loaded, the
+ Material style must be deployed with the application in order to be able
+ to run the application regardless of which style the application is run with.
+ By using \l {Using File Selectors with Qt Labs Controls}{file selectors},
+ style-specific tweaks can be applied without creating a hard dependency to
+ a style.
\section2 Pre-defined Colors
diff --git a/src/imports/controls/doc/src/qtlabscontrols-styles.qdoc b/src/imports/controls/doc/src/qtlabscontrols-styles.qdoc
index 858a9105..46939712 100644
--- a/src/imports/controls/doc/src/qtlabscontrols-styles.qdoc
+++ b/src/imports/controls/doc/src/qtlabscontrols-styles.qdoc
@@ -115,5 +115,6 @@
\li \l {Default Style}
\li \l {Material Style}
\li \l {Universal Style}
+ \li \l{Using File Selectors with Qt Labs Controls}
\endlist
*/
diff --git a/src/imports/controls/doc/src/qtlabscontrols-universal.qdoc b/src/imports/controls/doc/src/qtlabscontrols-universal.qdoc
index bf3dcfdc..3c09bdd0 100644
--- a/src/imports/controls/doc/src/qtlabscontrols-universal.qdoc
+++ b/src/imports/controls/doc/src/qtlabscontrols-universal.qdoc
@@ -116,13 +116,20 @@
\image qtlabscontrols-universal-dark.png
\endtable
- \note The Universal style must be separately imported to gain access to
- these style-specific attributes. It should be noted that regardless of the
- references to the Universal style, the same application code runs with any
- other style. The Universal style-specific attributes only have an effect
- when the application is run with the Universal style. Furthermore, in case
- of explicit Universal style-specific references, the Universal style must
- be deployed with the application.
+ \section2 Dependency
+
+ The Universal style must be separately imported to gain access to the
+ attributes that are specific to the Universal style. It should be noted
+ that regardless of the references to the Universal style, the same
+ application code runs with any other style. Universal-specific attributes
+ only have an effect when the application is run with the Universal style.
+
+ If the Universal style is imported in a QML file that is always loaded, the
+ Universal style must be deployed with the application in order to be able
+ to run the application regardless of which style the application is run with.
+ By using \l {Using File Selectors with Qt Labs Controls}{file selectors},
+ style-specific tweaks can be applied without creating a hard dependency to
+ a style.
\labs
diff --git a/src/imports/controls/material/Button.qml b/src/imports/controls/material/Button.qml
index a869c915..4dc9bfc5 100644
--- a/src/imports/controls/material/Button.qml
+++ b/src/imports/controls/material/Button.qml
@@ -43,23 +43,18 @@ T.Button {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- label ? label.implicitWidth + leftPadding + rightPadding : 0)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- label ? label.implicitHeight + topPadding + bottomPadding : 0)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ contentItem.implicitHeight + topPadding + bottomPadding)
+ baselineOffset: contentItem.y + contentItem.baselineOffset
// external vertical padding is 6 (to increase touch area)
padding: 12
leftPadding: 8
rightPadding: 8
- //! [label]
- label: Text {
- x: control.leftPadding
- y: control.topPadding
- width: control.availableWidth
- height: control.availableHeight
-
+ //! [contentItem]
+ contentItem: Text {
text: control.text
font: control.font
color: !control.enabled ? control.Material.hintTextColor :
@@ -68,7 +63,7 @@ T.Button {
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
- //! [label]
+ //! [contentItem]
//! [background]
background: Rectangle {
diff --git a/src/imports/controls/material/CheckBox.qml b/src/imports/controls/material/CheckBox.qml
index 230f696f..fd6ef256 100644
--- a/src/imports/controls/material/CheckBox.qml
+++ b/src/imports/controls/material/CheckBox.qml
@@ -37,18 +37,17 @@
import QtQuick 2.6
import Qt.labs.templates 1.0 as T
import Qt.labs.controls.material 1.0
+import Qt.labs.controls.material.impl 1.0
T.CheckBox {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- (label ? label.implicitWidth : 0) +
- (indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? spacing : 0) + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- Math.max(label ? label.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ baselineOffset: contentItem.y + contentItem.baselineOffset
spacing: 8
topPadding: 14
@@ -143,12 +142,10 @@ T.CheckBox {
}
//! [indicator]
- //! [label]
- label: Text {
- x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
- y: control.topPadding
- width: control.availableWidth - indicator.width - control.spacing
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -158,5 +155,5 @@ T.CheckBox {
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
}
diff --git a/src/imports/controls/material/ComboBox.qml b/src/imports/controls/material/ComboBox.qml
index 1c293567..ef073370 100644
--- a/src/imports/controls/material/ComboBox.qml
+++ b/src/imports/controls/material/ComboBox.qml
@@ -36,6 +36,7 @@
import QtQuick 2.6
import QtQuick.Window 2.2
+import Qt.labs.controls 1.0
import Qt.labs.templates 1.0 as T
import Qt.labs.controls.material 1.0
import QtGraphicalEffects 1.0
diff --git a/src/imports/controls/material/Frame.qml b/src/imports/controls/material/Frame.qml
index 9336850d..4c21e40b 100644
--- a/src/imports/controls/material/Frame.qml
+++ b/src/imports/controls/material/Frame.qml
@@ -53,14 +53,11 @@ T.Frame {
contentItem: Item { }
//! [contentItem]
- //! [frame]
- frame: Rectangle {
- width: parent.width
- height: parent.height
-
+ //! [background]
+ background: Rectangle {
radius: 3
color: "transparent"
border.color: control.Material.frameColor
}
- //! [frame]
+ //! [background]
}
diff --git a/src/imports/controls/material/GroupBox.qml b/src/imports/controls/material/GroupBox.qml
index 3461cb6e..ef54ea7c 100644
--- a/src/imports/controls/material/GroupBox.qml
+++ b/src/imports/controls/material/GroupBox.qml
@@ -71,8 +71,8 @@ T.GroupBox {
}
//! [label]
- //! [frame]
- frame: Rectangle {
+ //! [background]
+ background: Rectangle {
y: control.topPadding - control.padding
width: parent.width
height: parent.height - control.topPadding + control.padding
@@ -81,5 +81,5 @@ T.GroupBox {
color: "transparent"
border.color: control.Material.frameColor
}
- //! [frame]
+ //! [background]
}
diff --git a/src/imports/controls/material/ItemDelegate.qml b/src/imports/controls/material/ItemDelegate.qml
index acfbfb98..132cce3d 100644
--- a/src/imports/controls/material/ItemDelegate.qml
+++ b/src/imports/controls/material/ItemDelegate.qml
@@ -37,18 +37,17 @@
import QtQuick 2.6
import Qt.labs.templates 1.0 as T
import Qt.labs.controls.material 1.0
+import Qt.labs.controls.material.impl 1.0
T.ItemDelegate {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- (label ? label.implicitWidth : 0) +
- (indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? spacing : 0) + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- Math.max(label ? label.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 16
spacing: 16
@@ -128,12 +127,10 @@ T.ItemDelegate {
}
//! [indicator]
- //! [label]
- label: Text {
- x: control.mirrored || !control.checkable ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
- y: control.topPadding
- width: control.availableWidth - (control.checkable ? indicator.width + control.spacing : 0)
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.checkable && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.checkable && control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -143,7 +140,7 @@ T.ItemDelegate {
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
//! [background]
background: Rectangle {
diff --git a/src/imports/controls/material/MenuItem.qml b/src/imports/controls/material/MenuItem.qml
index 89867e15..e2042894 100644
--- a/src/imports/controls/material/MenuItem.qml
+++ b/src/imports/controls/material/MenuItem.qml
@@ -37,18 +37,17 @@
import QtQuick 2.6
import Qt.labs.templates 1.0 as T
import Qt.labs.controls.material 1.0
+import Qt.labs.controls.material.impl 1.0
T.MenuItem {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- (label ? label.implicitWidth : 0) +
- (indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? spacing : 0) + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- Math.max(label ? label.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 16
spacing: 16
@@ -128,12 +127,10 @@ T.MenuItem {
}
//! [indicator]
- //! [label]
- label: Text {
- x: control.mirrored || !control.checkable ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
- y: control.topPadding
- width: control.availableWidth - (control.checkable ? indicator.width + control.spacing : 0)
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.checkable && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.checkable && control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -143,7 +140,7 @@ T.MenuItem {
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
//! [background]
background: Rectangle {
diff --git a/src/imports/controls/material/RadioButton.qml b/src/imports/controls/material/RadioButton.qml
index f01d2dc9..4c8831a5 100644
--- a/src/imports/controls/material/RadioButton.qml
+++ b/src/imports/controls/material/RadioButton.qml
@@ -37,18 +37,17 @@
import QtQuick 2.6
import Qt.labs.templates 1.0 as T
import Qt.labs.controls.material 1.0
+import Qt.labs.controls.material.impl 1.0
T.RadioButton {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- (label ? label.implicitWidth : 0) +
- (indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? spacing : 0) + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- Math.max(label ? label.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ baselineOffset: contentItem.y + contentItem.baselineOffset
spacing: 8
topPadding: 14
@@ -87,12 +86,10 @@ T.RadioButton {
}
//! [indicator]
- //! [label]
- label: Text {
- x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
- y: control.topPadding
- width: control.availableWidth - indicator.width - control.spacing
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -102,5 +99,5 @@ T.RadioButton {
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
}
diff --git a/src/imports/controls/material/RangeSlider.qml b/src/imports/controls/material/RangeSlider.qml
index bf8c16ef..617f9ac7 100644
--- a/src/imports/controls/material/RangeSlider.qml
+++ b/src/imports/controls/material/RangeSlider.qml
@@ -37,6 +37,7 @@
import QtQuick 2.6
import Qt.labs.templates 1.0 as T
import Qt.labs.controls.material 1.0
+import Qt.labs.controls.material.impl 1.0
T.RangeSlider {
id: control
diff --git a/src/imports/controls/material/Slider.qml b/src/imports/controls/material/Slider.qml
index 139c9151..c121c10b 100644
--- a/src/imports/controls/material/Slider.qml
+++ b/src/imports/controls/material/Slider.qml
@@ -37,6 +37,7 @@
import QtQuick 2.6
import Qt.labs.templates 1.0 as T
import Qt.labs.controls.material 1.0
+import Qt.labs.controls.material.impl 1.0
T.Slider {
id: control
diff --git a/src/imports/controls/material/SpinBox.qml b/src/imports/controls/material/SpinBox.qml
index 5d2044e6..f6aba60d 100644
--- a/src/imports/controls/material/SpinBox.qml
+++ b/src/imports/controls/material/SpinBox.qml
@@ -75,6 +75,7 @@ T.SpinBox {
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
+ readOnly: !control.editable
validator: control.validator
inputMethodHints: Qt.ImhFormattedNumbersOnly
}
diff --git a/src/imports/controls/material/StackView.qml b/src/imports/controls/material/StackView.qml
index c31c13d2..0eb14832 100644
--- a/src/imports/controls/material/StackView.qml
+++ b/src/imports/controls/material/StackView.qml
@@ -38,12 +38,12 @@ import QtQuick 2.4
import Qt.labs.templates 1.0 as T
T.StackView {
- id: root
+ id: control
//! [popEnter]
popEnter: Transition {
// slide_in_left
- NumberAnimation { property: "x"; from: (root.mirrored ? -0.5 : 0.5) * -root.width; to: 0; duration: 200; easing.type: Easing.OutCubic }
+ NumberAnimation { property: "x"; from: (control.mirrored ? -0.5 : 0.5) * -control.width; to: 0; duration: 200; easing.type: Easing.OutCubic }
NumberAnimation { property: "opacity"; from: 0.0; to: 1.0; duration: 200; easing.type: Easing.OutCubic }
}
//! [popEnter]
@@ -51,7 +51,7 @@ T.StackView {
//! [popExit]
popExit: Transition {
// slide_out_right
- NumberAnimation { property: "x"; from: 0; to: (root.mirrored ? -0.5 : 0.5) * root.width; duration: 200; easing.type: Easing.OutCubic }
+ NumberAnimation { property: "x"; from: 0; to: (control.mirrored ? -0.5 : 0.5) * control.width; duration: 200; easing.type: Easing.OutCubic }
NumberAnimation { property: "opacity"; from: 1.0; to: 0.0; duration: 200; easing.type: Easing.OutCubic }
}
//! [popExit]
@@ -59,7 +59,7 @@ T.StackView {
//! [pushEnter]
pushEnter: Transition {
// slide_in_right
- NumberAnimation { property: "x"; from: (root.mirrored ? -0.5 : 0.5) * root.width; to: 0; duration: 200; easing.type: Easing.OutCubic }
+ NumberAnimation { property: "x"; from: (control.mirrored ? -0.5 : 0.5) * control.width; to: 0; duration: 200; easing.type: Easing.OutCubic }
NumberAnimation { property: "opacity"; from: 0.0; to: 1.0; duration: 200; easing.type: Easing.OutCubic }
}
//! [pushEnter]
@@ -67,7 +67,7 @@ T.StackView {
//! [pushExit]
pushExit: Transition {
// slide_out_left
- NumberAnimation { property: "x"; from: 0; to: (root.mirrored ? -0.5 : 0.5) * -root.width; duration: 200; easing.type: Easing.OutCubic }
+ NumberAnimation { property: "x"; from: 0; to: (control.mirrored ? -0.5 : 0.5) * -control.width; duration: 200; easing.type: Easing.OutCubic }
NumberAnimation { property: "opacity"; from: 1.0; to: 0.0; duration: 200; easing.type: Easing.OutCubic }
}
//! [pushExit]
@@ -75,7 +75,7 @@ T.StackView {
//! [replaceEnter]
replaceEnter: Transition {
// slide_in_right
- NumberAnimation { property: "x"; from: (root.mirrored ? -0.5 : 0.5) * root.width; to: 0; duration: 200; easing.type: Easing.OutCubic }
+ NumberAnimation { property: "x"; from: (control.mirrored ? -0.5 : 0.5) * control.width; to: 0; duration: 200; easing.type: Easing.OutCubic }
NumberAnimation { property: "opacity"; from: 0.0; to: 1.0; duration: 200; easing.type: Easing.OutCubic }
}
//! [replaceEnter]
@@ -83,7 +83,7 @@ T.StackView {
//! [replaceExit]
replaceExit: Transition {
// slide_out_left
- NumberAnimation { property: "x"; from: 0; to: (root.mirrored ? -0.5 : 0.5) * -root.width; duration: 200; easing.type: Easing.OutCubic }
+ NumberAnimation { property: "x"; from: 0; to: (control.mirrored ? -0.5 : 0.5) * -control.width; duration: 200; easing.type: Easing.OutCubic }
NumberAnimation { property: "opacity"; from: 1.0; to: 0.0; duration: 200; easing.type: Easing.OutCubic }
}
//! [replaceExit]
diff --git a/src/imports/controls/material/Switch.qml b/src/imports/controls/material/Switch.qml
index 0b9edcab..ca4b1ff6 100644
--- a/src/imports/controls/material/Switch.qml
+++ b/src/imports/controls/material/Switch.qml
@@ -36,6 +36,7 @@
import QtQuick 2.6
import Qt.labs.controls.material 1.0
+import Qt.labs.controls.material.impl 1.0
import Qt.labs.templates 1.0 as T
import QtGraphicalEffects 1.0
@@ -43,13 +44,11 @@ T.Switch {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- (label ? label.implicitWidth : 0) +
- (indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? spacing : 0) + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- Math.max(label ? label.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 8
spacing: 8
@@ -107,12 +106,10 @@ T.Switch {
}
//! [indicator]
- //! [label]
- label: Text {
- x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
- y: control.topPadding
- width: control.availableWidth - indicator.width - control.spacing
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -122,5 +119,5 @@ T.Switch {
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
}
diff --git a/src/imports/controls/material/TabBar.qml b/src/imports/controls/material/TabBar.qml
index dbc62512..6a09dbb5 100644
--- a/src/imports/controls/material/TabBar.qml
+++ b/src/imports/controls/material/TabBar.qml
@@ -69,7 +69,7 @@ T.TabBar {
Rectangle {
height: 2
width: parent.width
- y: parent.height - height
+ y: control.position === T.TabBar.Footer ? 0 : parent.height - height
color: control.Material.accentColor
}
}
diff --git a/src/imports/controls/material/TabButton.qml b/src/imports/controls/material/TabButton.qml
index 27b27e3b..496513dd 100644
--- a/src/imports/controls/material/TabButton.qml
+++ b/src/imports/controls/material/TabButton.qml
@@ -42,20 +42,15 @@ T.TabButton {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- label ? label.contentWidth + leftPadding + rightPadding : 0)
+ contentItem.contentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- label ? label.contentHeight + topPadding + bottomPadding : 0)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ contentItem.contentHeight + topPadding + bottomPadding)
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 12
- //! [label]
- label: Text {
- x: control.leftPadding
- y: control.topPadding
- width: control.availableWidth
- height: control.availableHeight
-
+ //! [contentItem]
+ contentItem: Text {
text: control.text
font: control.font
elide: Text.ElideRight
@@ -63,7 +58,7 @@ T.TabButton {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
//! [background]
background: Item {
diff --git a/src/imports/controls/material/TextArea.qml b/src/imports/controls/material/TextArea.qml
index a5423727..b6f614c0 100644
--- a/src/imports/controls/material/TextArea.qml
+++ b/src/imports/controls/material/TextArea.qml
@@ -92,7 +92,7 @@ T.TextArea {
horizontalAlignment: control.horizontalAlignment
verticalAlignment: control.verticalAlignment
elide: Text.ElideRight
- visible: !control.length && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
+ visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
}
//! [placeholder]
diff --git a/src/imports/controls/material/TextField.qml b/src/imports/controls/material/TextField.qml
index 6a0010f7..eaea710e 100644
--- a/src/imports/controls/material/TextField.qml
+++ b/src/imports/controls/material/TextField.qml
@@ -91,7 +91,7 @@ T.TextField {
horizontalAlignment: control.horizontalAlignment
verticalAlignment: control.verticalAlignment
elide: Text.ElideRight
- visible: !control.displayText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
+ visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
}
//! [placeholder]
diff --git a/src/imports/controls/material/ToolButton.qml b/src/imports/controls/material/ToolButton.qml
index ebdc36f2..34a745c1 100644
--- a/src/imports/controls/material/ToolButton.qml
+++ b/src/imports/controls/material/ToolButton.qml
@@ -42,20 +42,15 @@ T.ToolButton {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- label ? label.implicitWidth + leftPadding + rightPadding : 0)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- label ? label.implicitHeight + topPadding + bottomPadding : 0)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ contentItem.implicitHeight + topPadding + bottomPadding)
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 6
- //! [label]
- label: Text {
- x: control.leftPadding
- y: control.topPadding
- width: control.availableWidth
- height: control.availableHeight
-
+ //! [contentItem]
+ contentItem: Text {
text: control.text
font: control.font
color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
@@ -63,7 +58,7 @@ T.ToolButton {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
//! [background]
background: Rectangle {
diff --git a/src/imports/controls/material/qquickmaterialprogressring.cpp b/src/imports/controls/material/qquickmaterialprogressring.cpp
index c11a347f..d21bb0b6 100644
--- a/src/imports/controls/material/qquickmaterialprogressring.cpp
+++ b/src/imports/controls/material/qquickmaterialprogressring.cpp
@@ -67,11 +67,11 @@ public:
QQuickMaterialRingAnimatorJob();
~QQuickMaterialRingAnimatorJob();
- void initialize(QQuickAnimatorController *controller) Q_DECL_OVERRIDE;
- void updateCurrentTime(int time) Q_DECL_OVERRIDE;
- void writeBack() Q_DECL_OVERRIDE;
- void nodeWasDestroyed() Q_DECL_OVERRIDE;
- void afterNodeSync() Q_DECL_OVERRIDE;
+ void initialize(QQuickAnimatorController *controller) override;
+ void updateCurrentTime(int time) override;
+ void writeBack() override;
+ void nodeWasDestroyed() override;
+ void afterNodeSync() override;
private:
qreal m_devicePixelRatio;
@@ -134,11 +134,12 @@ QColor QQuickMaterialProgressRing::color() const
void QQuickMaterialProgressRing::setColor(QColor color)
{
- if (m_color != color) {
- m_color = color;
- update();
- emit colorChanged();
- }
+ if (m_color == color)
+ return;
+
+ m_color = color;
+ update();
+ emit colorChanged();
}
static const int spanAnimationDuration = 700;
@@ -167,8 +168,8 @@ QQuickAnimatorJob *QQuickMaterialRingAnimator::createJob() const
QQuickMaterialRingAnimatorJob::QQuickMaterialRingAnimatorJob() :
m_devicePixelRatio(1.0),
- m_containerNode(Q_NULLPTR),
- m_window(Q_NULLPTR)
+ m_containerNode(nullptr),
+ m_window(nullptr)
{
}
@@ -258,8 +259,8 @@ void QQuickMaterialRingAnimatorJob::writeBack()
void QQuickMaterialRingAnimatorJob::nodeWasDestroyed()
{
- m_containerNode = Q_NULLPTR;
- m_window = Q_NULLPTR;
+ m_containerNode = nullptr;
+ m_window = nullptr;
}
void QQuickMaterialRingAnimatorJob::afterNodeSync()
diff --git a/src/imports/controls/material/qquickmaterialprogressring_p.h b/src/imports/controls/material/qquickmaterialprogressring_p.h
index 6f4ebc6b..a829f948 100644
--- a/src/imports/controls/material/qquickmaterialprogressring_p.h
+++ b/src/imports/controls/material/qquickmaterialprogressring_p.h
@@ -60,7 +60,7 @@ class QQuickMaterialProgressRing : public QQuickItem
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL)
public:
- explicit QQuickMaterialProgressRing(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickMaterialProgressRing(QQuickItem *parent = nullptr);
~QQuickMaterialProgressRing();
QColor color() const;
@@ -70,7 +70,7 @@ Q_SIGNALS:
void colorChanged();
protected:
- QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) Q_DECL_OVERRIDE;
+ QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override;
private:
QColor m_color;
@@ -79,11 +79,11 @@ private:
class QQuickMaterialRingAnimator : public QQuickAnimator
{
public:
- QQuickMaterialRingAnimator(QObject *parent = Q_NULLPTR);
+ QQuickMaterialRingAnimator(QObject *parent = nullptr);
protected:
- QString propertyName() const Q_DECL_OVERRIDE;
- QQuickAnimatorJob *createJob() const Q_DECL_OVERRIDE;
+ QString propertyName() const override;
+ QQuickAnimatorJob *createJob() const override;
};
QT_END_NAMESPACE
diff --git a/src/imports/controls/material/qquickmaterialprogressstrip.cpp b/src/imports/controls/material/qquickmaterialprogressstrip.cpp
index 1d888183..34590340 100644
--- a/src/imports/controls/material/qquickmaterialprogressstrip.cpp
+++ b/src/imports/controls/material/qquickmaterialprogressstrip.cpp
@@ -54,11 +54,11 @@ class QQuickMaterialProgressStripAnimatorJob : public QQuickAnimatorJob
public:
QQuickMaterialProgressStripAnimatorJob();
- void initialize(QQuickAnimatorController *controller) Q_DECL_OVERRIDE;
- void updateCurrentTime(int time) Q_DECL_OVERRIDE;
- void writeBack() Q_DECL_OVERRIDE;
- void nodeWasDestroyed() Q_DECL_OVERRIDE;
- void afterNodeSync() Q_DECL_OVERRIDE;
+ void initialize(QQuickAnimatorController *controller) override;
+ void updateCurrentTime(int time) override;
+ void writeBack() override;
+ void nodeWasDestroyed() override;
+ void afterNodeSync() override;
void moveNode(QSGTransformNode *node, const QRectF &geometry, qreal progress);
@@ -66,7 +66,7 @@ private:
QSGNode *m_node;
};
-QQuickMaterialProgressStripAnimatorJob::QQuickMaterialProgressStripAnimatorJob() : m_node(Q_NULLPTR)
+QQuickMaterialProgressStripAnimatorJob::QQuickMaterialProgressStripAnimatorJob() : m_node(nullptr)
{
}
@@ -111,7 +111,7 @@ void QQuickMaterialProgressStripAnimatorJob::writeBack()
void QQuickMaterialProgressStripAnimatorJob::nodeWasDestroyed()
{
- m_node = Q_NULLPTR;
+ m_node = nullptr;
}
void QQuickMaterialProgressStripAnimatorJob::afterNodeSync()
diff --git a/src/imports/controls/material/qquickmaterialprogressstrip_p.h b/src/imports/controls/material/qquickmaterialprogressstrip_p.h
index d0618af6..38333ee5 100644
--- a/src/imports/controls/material/qquickmaterialprogressstrip_p.h
+++ b/src/imports/controls/material/qquickmaterialprogressstrip_p.h
@@ -61,7 +61,7 @@ class QQuickMaterialProgressStrip : public QQuickItem
Q_PROPERTY(bool indeterminate READ isIndeterminate WRITE setIndeterminate FINAL)
public:
- QQuickMaterialProgressStrip(QQuickItem *parent = Q_NULLPTR);
+ QQuickMaterialProgressStrip(QQuickItem *parent = nullptr);
QColor color() const;
void setColor(const QColor &color);
@@ -73,7 +73,7 @@ public:
void setIndeterminate(bool indeterminate);
protected:
- QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) Q_DECL_OVERRIDE;
+ QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override;
private:
QColor m_color;
@@ -86,11 +86,11 @@ class QQuickMaterialStripAnimator : public QQuickAnimator
Q_OBJECT
public:
- QQuickMaterialStripAnimator(QObject *parent = Q_NULLPTR);
+ QQuickMaterialStripAnimator(QObject *parent = nullptr);
protected:
- QString propertyName() const Q_DECL_OVERRIDE;
- QQuickAnimatorJob *createJob() const Q_DECL_OVERRIDE;
+ QString propertyName() const override;
+ QQuickAnimatorJob *createJob() const override;
};
QT_END_NAMESPACE
diff --git a/src/imports/controls/material/qquickmaterialstyle.cpp b/src/imports/controls/material/qquickmaterialstyle.cpp
index 57b74d62..280acb77 100644
--- a/src/imports/controls/material/qquickmaterialstyle.cpp
+++ b/src/imports/controls/material/qquickmaterialstyle.cpp
@@ -431,27 +431,30 @@ QQuickMaterialStyle::Theme QQuickMaterialStyle::theme() const
void QQuickMaterialStyle::setTheme(Theme theme)
{
m_explicitTheme = true;
- if (m_theme != theme) {
- m_theme = theme;
- propagateTheme();
- emit themeChanged();
- emit paletteChanged();
- }
+ if (m_theme == theme)
+ return;
+
+ m_theme = theme;
+ propagateTheme();
+ emit themeChanged();
+ emit paletteChanged();
}
void QQuickMaterialStyle::inheritTheme(Theme theme)
{
- if (!m_explicitTheme && m_theme != theme) {
- m_theme = theme;
- propagateTheme();
- emit themeChanged();
- emit paletteChanged();
- }
+ if (m_explicitTheme || m_theme == theme)
+ return;
+
+ m_theme = theme;
+ propagateTheme();
+ emit themeChanged();
+ emit paletteChanged();
}
void QQuickMaterialStyle::propagateTheme()
{
- foreach (QQuickStyle *child, childStyles()) {
+ const auto styles = childStyles();
+ for (QQuickStyle *child : styles) {
QQuickMaterialStyle *material = qobject_cast<QQuickMaterialStyle *>(child);
if (material)
material->inheritTheme(m_theme);
@@ -460,11 +463,12 @@ void QQuickMaterialStyle::propagateTheme()
void QQuickMaterialStyle::resetTheme()
{
- if (m_explicitTheme) {
- m_explicitTheme = false;
- QQuickMaterialStyle *material = qobject_cast<QQuickMaterialStyle *>(parentStyle());
- inheritTheme(material ? material->theme() : defaultTheme);
- }
+ if (!m_explicitTheme)
+ return;
+
+ m_explicitTheme = false;
+ QQuickMaterialStyle *material = qobject_cast<QQuickMaterialStyle *>(parentStyle());
+ inheritTheme(material ? material->theme() : defaultTheme);
}
QVariant QQuickMaterialStyle::primary() const
@@ -499,28 +503,31 @@ void QQuickMaterialStyle::setPrimary(const QVariant &var)
}
m_explicitPrimary = true;
- if (m_primary != primary) {
- m_customPrimary = custom;
- m_primary = primary;
- propagatePrimary();
- emit primaryChanged();
- emit paletteChanged();
- }
+ if (m_primary == primary)
+ return;
+
+ m_customPrimary = custom;
+ m_primary = primary;
+ propagatePrimary();
+ emit primaryChanged();
+ emit paletteChanged();
}
void QQuickMaterialStyle::inheritPrimary(uint primary, bool custom)
{
- if (!m_explicitPrimary && m_primary != primary) {
- m_customPrimary = custom;
- m_primary = primary;
- propagatePrimary();
- emit primaryChanged();
- }
+ if (m_explicitPrimary || m_primary == primary)
+ return;
+
+ m_customPrimary = custom;
+ m_primary = primary;
+ propagatePrimary();
+ emit primaryChanged();
}
void QQuickMaterialStyle::propagatePrimary()
{
- foreach (QQuickStyle *child, childStyles()) {
+ const auto styles = childStyles();
+ for (QQuickStyle *child : styles) {
QQuickMaterialStyle *material = qobject_cast<QQuickMaterialStyle *>(child);
if (material)
material->inheritPrimary(m_primary, m_customPrimary);
@@ -529,12 +536,13 @@ void QQuickMaterialStyle::propagatePrimary()
void QQuickMaterialStyle::resetPrimary()
{
- if (m_explicitPrimary) {
- m_customPrimary = false;
- m_explicitPrimary = false;
- QQuickMaterialStyle *material = qobject_cast<QQuickMaterialStyle *>(parentStyle());
- inheritPrimary(material ? material->m_primary : defaultPrimary, true);
- }
+ if (!m_explicitPrimary)
+ return;
+
+ m_customPrimary = false;
+ m_explicitPrimary = false;
+ QQuickMaterialStyle *material = qobject_cast<QQuickMaterialStyle *>(parentStyle());
+ inheritPrimary(material ? material->m_primary : defaultPrimary, true);
}
QVariant QQuickMaterialStyle::accent() const
@@ -569,28 +577,31 @@ void QQuickMaterialStyle::setAccent(const QVariant &var)
}
m_explicitAccent = true;
- if (m_accent != accent) {
- m_customAccent = custom;
- m_accent = accent;
- propagateAccent();
- emit accentChanged();
- emit paletteChanged();
- }
+ if (m_accent == accent)
+ return;
+
+ m_customAccent = custom;
+ m_accent = accent;
+ propagateAccent();
+ emit accentChanged();
+ emit paletteChanged();
}
void QQuickMaterialStyle::inheritAccent(uint accent, bool custom)
{
- if (!m_explicitAccent && m_accent != accent) {
- m_customAccent = custom;
- m_accent = accent;
- propagateAccent();
- emit accentChanged();
- }
+ if (m_explicitAccent || m_accent == accent)
+ return;
+
+ m_customAccent = custom;
+ m_accent = accent;
+ propagateAccent();
+ emit accentChanged();
}
void QQuickMaterialStyle::propagateAccent()
{
- foreach (QQuickStyle *child, childStyles()) {
+ const auto styles = childStyles();
+ for (QQuickStyle *child : styles) {
QQuickMaterialStyle *material = qobject_cast<QQuickMaterialStyle *>(child);
if (material)
material->inheritAccent(m_accent, m_customAccent);
@@ -599,12 +610,13 @@ void QQuickMaterialStyle::propagateAccent()
void QQuickMaterialStyle::resetAccent()
{
- if (m_explicitAccent) {
- m_customAccent = false;
- m_explicitAccent = false;
- QQuickMaterialStyle *material = qobject_cast<QQuickMaterialStyle *>(parentStyle());
- inheritAccent(material ? material->m_accent : defaultAccent, true);
- }
+ if (!m_explicitAccent)
+ return;
+
+ m_customAccent = false;
+ m_explicitAccent = false;
+ QQuickMaterialStyle *material = qobject_cast<QQuickMaterialStyle *>(parentStyle());
+ inheritAccent(material ? material->m_accent : defaultAccent, true);
}
QColor QQuickMaterialStyle::primaryColor() const
diff --git a/src/imports/controls/material/qquickmaterialstyle_p.h b/src/imports/controls/material/qquickmaterialstyle_p.h
index f92bfe9d..9f3dbbbd 100644
--- a/src/imports/controls/material/qquickmaterialstyle_p.h
+++ b/src/imports/controls/material/qquickmaterialstyle_p.h
@@ -146,7 +146,7 @@ public:
Q_ENUM(Color)
Q_ENUM(Shade)
- explicit QQuickMaterialStyle(QObject *parent = Q_NULLPTR);
+ explicit QQuickMaterialStyle(QObject *parent = nullptr);
static QQuickMaterialStyle *qmlAttachedProperties(QObject *object);
@@ -214,7 +214,7 @@ Q_SIGNALS:
void paletteChanged();
protected:
- void parentStyleChange(QQuickStyle *newParent, QQuickStyle *oldParent) Q_DECL_OVERRIDE;
+ void parentStyleChange(QQuickStyle *newParent, QQuickStyle *oldParent) override;
private:
void init();
diff --git a/src/imports/controls/material/qquickmaterialtheme_p.h b/src/imports/controls/material/qquickmaterialtheme_p.h
index e0279bf6..27ffdddc 100644
--- a/src/imports/controls/material/qquickmaterialtheme_p.h
+++ b/src/imports/controls/material/qquickmaterialtheme_p.h
@@ -61,7 +61,7 @@ public:
~QQuickMaterialTheme();
- const QFont *font(Font type = SystemFont) const Q_DECL_OVERRIDE;
+ const QFont *font(Font type = SystemFont) const override;
private:
QFont systemFont;
diff --git a/src/imports/controls/material/qtlabsmaterialstyleplugin.cpp b/src/imports/controls/material/qtlabsmaterialstyleplugin.cpp
index 11df4464..e4b44890 100644
--- a/src/imports/controls/material/qtlabsmaterialstyleplugin.cpp
+++ b/src/imports/controls/material/qtlabsmaterialstyleplugin.cpp
@@ -47,6 +47,9 @@
static inline void initResources()
{
Q_INIT_RESOURCE(qtlabsmaterialstyleplugin);
+#ifdef QT_STATIC
+ Q_INIT_RESOURCE(qmake_Qt_labs_controls_material);
+#endif
}
QT_BEGIN_NAMESPACE
@@ -57,14 +60,20 @@ class QtLabsMaterialStylePlugin : public QQmlExtensionPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0")
public:
+ QtLabsMaterialStylePlugin(QObject *parent = nullptr);
~QtLabsMaterialStylePlugin();
- void registerTypes(const char *uri) Q_DECL_OVERRIDE;
- void initializeEngine(QQmlEngine *engine, const char *uri) Q_DECL_OVERRIDE;
+ void registerTypes(const char *uri) override;
+ void initializeEngine(QQmlEngine *engine, const char *uri) override;
private:
QQuickProxyTheme *theme;
};
+QtLabsMaterialStylePlugin::QtLabsMaterialStylePlugin(QObject *parent) : QQmlExtensionPlugin(parent)
+{
+ initResources();
+}
+
QtLabsMaterialStylePlugin::~QtLabsMaterialStylePlugin()
{
if (theme) {
@@ -82,7 +91,6 @@ void QtLabsMaterialStylePlugin::registerTypes(const char *uri)
void QtLabsMaterialStylePlugin::initializeEngine(QQmlEngine *engine, const char *uri)
{
Q_UNUSED(engine);
- Q_UNUSED(uri);
QQuickStyleSelector selector;
if (selector.style() == QLatin1String("material")) {
@@ -93,13 +101,13 @@ void QtLabsMaterialStylePlugin::initializeEngine(QQmlEngine *engine, const char
}
}
- initResources();
-
QByteArray import = QByteArray(uri) + ".impl";
qmlRegisterType<QQuickMaterialProgressRing>(import, 1, 0, "ProgressRing");
qmlRegisterType<QQuickMaterialProgressStrip>(import, 1, 0, "ProgressStrip");
qmlRegisterType<QQuickMaterialRingAnimator>(import, 1, 0, "RingAnimator");
qmlRegisterType<QQuickMaterialStripAnimator>(import, 1, 0, "StripAnimator");
+ qmlRegisterType(QUrl(baseUrl().toString() + QStringLiteral("/Ripple.qml")), import, 1, 0, "Ripple");
+ qmlRegisterType(QUrl(baseUrl().toString() + QStringLiteral("/SliderHandle.qml")), import, 1, 0, "SliderHandle");
}
QT_END_NAMESPACE
diff --git a/src/imports/controls/plugins.qmltypes b/src/imports/controls/plugins.qmltypes
index e9f0cff2..e8083e6b 100644
--- a/src/imports/controls/plugins.qmltypes
+++ b/src/imports/controls/plugins.qmltypes
@@ -28,7 +28,6 @@ Module {
Property { name: "autoExclusive"; type: "bool" }
Property { name: "autoRepeat"; type: "bool" }
Property { name: "indicator"; type: "QQuickItem"; isPointer: true }
- Property { name: "label"; type: "QQuickItem"; isPointer: true }
Signal { name: "pressed" }
Signal { name: "released" }
Signal { name: "canceled" }
@@ -44,6 +43,7 @@ Module {
exports: ["Qt.labs.templates/ApplicationWindow 1.0"]
exportMetaObjectRevisions: [0]
attachedType: "QQuickApplicationWindowAttached"
+ Property { name: "background"; type: "QQuickItem"; isPointer: true }
Property { name: "contentItem"; type: "QQuickItem"; isReadonly: true; isPointer: true }
Property { name: "data"; type: "QObject"; isList: true; isReadonly: true }
Property { name: "activeFocusControl"; type: "QQuickItem"; isReadonly: true; isPointer: true }
@@ -186,7 +186,11 @@ Module {
Property { name: "spacing"; type: "double" }
Property { name: "locale"; type: "QLocale" }
Property { name: "mirrored"; type: "bool"; isReadonly: true }
+ Property { name: "focusPolicy"; type: "Qt::FocusPolicy" }
Property { name: "focusReason"; type: "Qt::FocusReason" }
+ Property { name: "hovered"; type: "bool"; isReadonly: true }
+ Property { name: "hoverEnabled"; type: "bool" }
+ Property { name: "wheelEnabled"; type: "bool" }
Property { name: "background"; type: "QQuickItem"; isPointer: true }
Property { name: "contentItem"; type: "QQuickItem"; isPointer: true }
}
@@ -236,7 +240,6 @@ Module {
prototype: "QQuickPane"
exports: ["Qt.labs.templates/Frame 1.0"]
exportMetaObjectRevisions: [0]
- Property { name: "frame"; type: "QQuickItem"; isPointer: true }
}
Component {
name: "QQuickGroupBox"
@@ -580,6 +583,7 @@ Module {
Property { name: "to"; type: "int" }
Property { name: "value"; type: "int" }
Property { name: "stepSize"; type: "int" }
+ Property { name: "editable"; type: "bool" }
Property { name: "validator"; type: "QValidator"; isPointer: true }
Property { name: "textFromValue"; type: "QJSValue" }
Property { name: "valueFromText"; type: "QJSValue" }
@@ -707,6 +711,14 @@ Module {
prototype: "QQuickContainer"
exports: ["Qt.labs.templates/TabBar 1.0"]
exportMetaObjectRevisions: [0]
+ Enum {
+ name: "Position"
+ values: {
+ "Header": 0,
+ "Footer": 1
+ }
+ }
+ Property { name: "position"; type: "Position" }
}
Component {
name: "QQuickTabButton"
@@ -1012,6 +1024,8 @@ Module {
Property { name: "leftPadding"; revision: 6; type: "double" }
Property { name: "rightPadding"; revision: 6; type: "double" }
Property { name: "bottomPadding"; revision: 6; type: "double" }
+ Property { name: "preeditText"; revision: 7; type: "string"; isReadonly: true }
+ Signal { name: "preeditTextChanged"; revision: 7 }
Signal { name: "contentSizeChanged" }
Signal {
name: "colorChanged"
@@ -1123,6 +1137,7 @@ Module {
revision: 2
Parameter { name: "text"; type: "string" }
}
+ Method { name: "clear"; revision: 7 }
Method {
name: "inputMethodQuery"
revision: 4
@@ -1275,6 +1290,7 @@ Module {
Property { name: "passwordCharacter"; type: "string" }
Property { name: "passwordMaskDelay"; revision: 3; type: "int" }
Property { name: "displayText"; type: "string"; isReadonly: true }
+ Property { name: "preeditText"; revision: 7; type: "string"; isReadonly: true }
Property { name: "autoScroll"; type: "bool" }
Property { name: "selectByMouse"; type: "bool" }
Property { name: "mouseSelectionMode"; type: "SelectionMode" }
@@ -1330,6 +1346,7 @@ Module {
revision: 3
Parameter { name: "delay"; type: "int" }
}
+ Signal { name: "preeditTextChanged"; revision: 7 }
Signal {
name: "activeFocusOnPressChanged"
Parameter { name: "activeFocusOnPress"; type: "bool" }
@@ -1386,6 +1403,7 @@ Module {
revision: 3
Parameter { name: "position"; type: "int" }
}
+ Method { name: "clear"; revision: 7 }
Method {
name: "positionAt"
Parameter { name: "args"; type: "QQmlV4Function"; isPointer: true }
@@ -1424,6 +1442,14 @@ Module {
prototype: "QQuickFrame"
exports: ["Qt.labs.templates/ToolBar 1.0"]
exportMetaObjectRevisions: [0]
+ Enum {
+ name: "Position"
+ values: {
+ "Header": 0,
+ "Footer": 1
+ }
+ }
+ Property { name: "position"; type: "Position" }
}
Component {
name: "QQuickToolButton"
diff --git a/src/imports/controls/qquickbusyindicatorring.cpp b/src/imports/controls/qquickbusyindicatorring.cpp
index 96213fa4..06e62c16 100644
--- a/src/imports/controls/qquickbusyindicatorring.cpp
+++ b/src/imports/controls/qquickbusyindicatorring.cpp
@@ -50,11 +50,11 @@ public:
QQuickBusyIndicatorAnimatorJob();
~QQuickBusyIndicatorAnimatorJob();
- void initialize(QQuickAnimatorController *controller) Q_DECL_OVERRIDE;
- void updateCurrentTime(int time) Q_DECL_OVERRIDE;
- void writeBack() Q_DECL_OVERRIDE;
- void nodeWasDestroyed() Q_DECL_OVERRIDE;
- void afterNodeSync() Q_DECL_OVERRIDE;
+ void initialize(QQuickAnimatorController *controller) override;
+ void updateCurrentTime(int time) override;
+ void writeBack() override;
+ void nodeWasDestroyed() override;
+ void afterNodeSync() override;
private:
QSGNode *m_node;
@@ -159,7 +159,7 @@ QQuickAnimatorJob *QQuickBusyIndicatorAnimator::createJob() const
return new QQuickBusyIndicatorAnimatorJob;
}
-QQuickBusyIndicatorAnimatorJob::QQuickBusyIndicatorAnimatorJob() : m_node(Q_NULLPTR)
+QQuickBusyIndicatorAnimatorJob::QQuickBusyIndicatorAnimatorJob() : m_node(nullptr)
{
}
@@ -217,7 +217,7 @@ void QQuickBusyIndicatorAnimatorJob::writeBack()
void QQuickBusyIndicatorAnimatorJob::nodeWasDestroyed()
{
- m_node = Q_NULLPTR;
+ m_node = nullptr;
}
void QQuickBusyIndicatorAnimatorJob::afterNodeSync()
diff --git a/src/imports/controls/qquickbusyindicatorring_p.h b/src/imports/controls/qquickbusyindicatorring_p.h
index 4697628d..cd1e70ad 100644
--- a/src/imports/controls/qquickbusyindicatorring_p.h
+++ b/src/imports/controls/qquickbusyindicatorring_p.h
@@ -58,21 +58,21 @@ class QQuickBusyIndicatorRing : public QQuickItem
Q_OBJECT
public:
- explicit QQuickBusyIndicatorRing(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickBusyIndicatorRing(QQuickItem *parent = nullptr);
~QQuickBusyIndicatorRing();
protected:
- QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) Q_DECL_OVERRIDE;
+ QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override;
};
class QQuickBusyIndicatorAnimator : public QQuickAnimator
{
public:
- QQuickBusyIndicatorAnimator(QObject *parent = Q_NULLPTR);
+ QQuickBusyIndicatorAnimator(QObject *parent = nullptr);
protected:
- QString propertyName() const Q_DECL_OVERRIDE;
- QQuickAnimatorJob *createJob() const Q_DECL_OVERRIDE;
+ QString propertyName() const override;
+ QQuickAnimatorJob *createJob() const override;
};
QT_END_NAMESPACE
diff --git a/src/imports/controls/qquickprogressstrip.cpp b/src/imports/controls/qquickprogressstrip.cpp
index e9480ff1..0fc72087 100644
--- a/src/imports/controls/qquickprogressstrip.cpp
+++ b/src/imports/controls/qquickprogressstrip.cpp
@@ -47,11 +47,11 @@ public:
QQuickProgressAnimatorJob();
~QQuickProgressAnimatorJob();
- void initialize(QQuickAnimatorController *controller) Q_DECL_OVERRIDE;
- void afterNodeSync() Q_DECL_OVERRIDE;
- void updateCurrentTime(int time) Q_DECL_OVERRIDE;
- void writeBack() Q_DECL_OVERRIDE;
- void nodeWasDestroyed() Q_DECL_OVERRIDE;
+ void initialize(QQuickAnimatorController *controller) override;
+ void afterNodeSync() override;
+ void updateCurrentTime(int time) override;
+ void writeBack() override;
+ void nodeWasDestroyed() override;
private:
QSGNode *m_node;
@@ -210,7 +210,7 @@ QQuickAnimatorJob *QQuickProgressAnimator::createJob() const
}
QQuickProgressAnimatorJob::QQuickProgressAnimatorJob() :
- m_node(Q_NULLPTR)
+ m_node(nullptr)
{
}
@@ -308,7 +308,7 @@ void QQuickProgressAnimatorJob::writeBack()
void QQuickProgressAnimatorJob::nodeWasDestroyed()
{
- m_node = Q_NULLPTR;
+ m_node = nullptr;
}
QT_END_NAMESPACE
diff --git a/src/imports/controls/qquickprogressstrip_p.h b/src/imports/controls/qquickprogressstrip_p.h
index c34698dc..105c6a29 100644
--- a/src/imports/controls/qquickprogressstrip_p.h
+++ b/src/imports/controls/qquickprogressstrip_p.h
@@ -60,7 +60,7 @@ class QQuickProgressStrip : public QQuickItem
Q_PROPERTY(qreal progress READ progress WRITE setProgress NOTIFY progressChanged FINAL)
public:
- explicit QQuickProgressStrip(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickProgressStrip(QQuickItem *parent = nullptr);
~QQuickProgressStrip();
bool isIndeterminate() const;
@@ -74,7 +74,7 @@ Q_SIGNALS:
void indeterminateChanged();
protected:
- QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) Q_DECL_OVERRIDE;
+ QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override;
private:
qreal m_progress;
@@ -84,11 +84,11 @@ private:
class QQuickProgressAnimator : public QQuickAnimator
{
public:
- QQuickProgressAnimator(QObject *parent = Q_NULLPTR);
+ QQuickProgressAnimator(QObject *parent = nullptr);
protected:
- QString propertyName() const Q_DECL_OVERRIDE;
- QQuickAnimatorJob *createJob() const Q_DECL_OVERRIDE;
+ QString propertyName() const override;
+ QQuickAnimatorJob *createJob() const override;
};
QT_END_NAMESPACE
diff --git a/src/imports/controls/qtlabscontrolsplugin.cpp b/src/imports/controls/qtlabscontrolsplugin.cpp
index 4258fb9c..37b68ef5 100644
--- a/src/imports/controls/qtlabscontrolsplugin.cpp
+++ b/src/imports/controls/qtlabscontrolsplugin.cpp
@@ -36,7 +36,9 @@
#include <QtQml/qqmlextensionplugin.h>
#include <QtCore/qurl.h>
+#include <QtCore/qfile.h>
#include <QtCore/qcoreapplication.h>
+#include <QtCore/private/qfileselector_p.h>
#include <QtLabsTemplates/private/qquickabstractbutton_p.h>
#include <QtLabsTemplates/private/qquickbuttongroup_p.h>
@@ -51,6 +53,9 @@
static inline void initResources()
{
Q_INIT_RESOURCE(qtlabscontrolsplugin);
+#ifdef QT_STATIC
+ Q_INIT_RESOURCE(qmake_Qt_labs_controls);
+#endif
}
QT_BEGIN_NAMESPACE
@@ -61,10 +66,16 @@ class QtLabsControlsPlugin: public QQmlExtensionPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0")
public:
+ QtLabsControlsPlugin(QObject *parent = nullptr);
void registerTypes(const char *uri);
void initializeEngine(QQmlEngine *engine, const char *uri);
};
+QtLabsControlsPlugin::QtLabsControlsPlugin(QObject *parent) : QQmlExtensionPlugin(parent)
+{
+ initResources();
+}
+
void QtLabsControlsPlugin::registerTypes(const char *uri)
{
qmlRegisterType<QQuickAbstractButton>(uri, 1, 0, "AbstractButton");
@@ -74,7 +85,14 @@ void QtLabsControlsPlugin::registerTypes(const char *uri)
qmlRegisterType<QQuickControl>(uri, 1, 0, "Control");
QQuickStyleSelector selector;
- selector.setBaseUrl(baseUrl());
+ if (QFile::exists(QLatin1String(":/qt-project.org/imports/Qt/labs/controls/ApplicationWindow.qml")))
+ selector.setBaseUrl(QUrl(QLatin1String("qrc:/qt-project.org/imports/Qt/labs/controls")));\
+ else
+ selector.setBaseUrl(baseUrl());
+
+ const QString style = selector.style();
+ if (!style.isEmpty())
+ QFileSelectorPrivate::addStatics(QStringList() << style);
qmlRegisterType(selector.select(QStringLiteral("/ApplicationWindow.qml")), uri, 1, 0, "ApplicationWindow");
qmlRegisterType(selector.select(QStringLiteral("/BusyIndicator.qml")), uri, 1, 0, "BusyIndicator");
@@ -116,7 +134,6 @@ void QtLabsControlsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
{
Q_UNUSED(engine);
Q_UNUSED(uri);
- initResources();
const QByteArray import = QByteArray(uri) + ".impl";
qmlRegisterType<QQuickBusyIndicatorRing>(import, 1, 0, "BusyRing");
diff --git a/src/imports/controls/universal/Button.qml b/src/imports/controls/universal/Button.qml
index 1dc94c89..5198b756 100644
--- a/src/imports/controls/universal/Button.qml
+++ b/src/imports/controls/universal/Button.qml
@@ -42,10 +42,10 @@ T.Button {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- label ? label.implicitWidth + leftPadding + rightPadding : 0)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- label ? label.implicitHeight + topPadding + bottomPadding : 0)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ contentItem.implicitHeight + topPadding + bottomPadding)
+ baselineOffset: contentItem.y + contentItem.baselineOffset
topPadding: 4
leftPadding: 8
@@ -54,13 +54,8 @@ T.Button {
property bool useSystemFocusVisuals: true
- //! [label]
- label: Text {
- x: control.leftPadding
- y: control.topPadding
- width: control.availableWidth
- height: control.availableHeight
-
+ //! [contentItem]
+ contentItem: Text {
text: control.text
font: control.font
elide: Text.ElideRight
@@ -69,7 +64,7 @@ T.Button {
color: !control.enabled ? control.Universal.baseLowColor : control.Universal.baseHighColor
}
- //! [label]
+ //! [contentItem]
//! [background]
background: Rectangle {
diff --git a/src/imports/controls/universal/CheckBox.qml b/src/imports/controls/universal/CheckBox.qml
index 37c20d00..2dff0488 100644
--- a/src/imports/controls/universal/CheckBox.qml
+++ b/src/imports/controls/universal/CheckBox.qml
@@ -42,13 +42,11 @@ T.CheckBox {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- (label ? label.implicitWidth : 0) +
- (indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? spacing : 0) + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- Math.max(label ? label.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 6
spacing: 8
@@ -92,12 +90,10 @@ T.CheckBox {
}
//! [indicator]
- //! [label]
- label: Text {
- x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
- y: control.topPadding
- width: control.availableWidth - indicator.width - control.spacing
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -108,5 +104,5 @@ T.CheckBox {
color: !control.enabled ? control.Universal.baseLowColor : control.Universal.baseHighColor
}
- //! [label]
+ //! [contentItem]
}
diff --git a/src/imports/controls/universal/ComboBox.qml b/src/imports/controls/universal/ComboBox.qml
index 03278e10..fe6a033f 100644
--- a/src/imports/controls/universal/ComboBox.qml
+++ b/src/imports/controls/universal/ComboBox.qml
@@ -36,6 +36,7 @@
import QtQuick 2.6
import QtQuick.Window 2.2
+import Qt.labs.controls 1.0
import Qt.labs.templates 1.0 as T
import Qt.labs.controls.universal 1.0
diff --git a/src/imports/controls/universal/Frame.qml b/src/imports/controls/universal/Frame.qml
index 9427dc2f..70f1647d 100644
--- a/src/imports/controls/universal/Frame.qml
+++ b/src/imports/controls/universal/Frame.qml
@@ -53,13 +53,10 @@ T.Frame {
contentItem: Item { }
//! [contentItem]
- //! [frame]
- frame: Rectangle {
- width: parent.width
- height: parent.height
-
+ //! [background]
+ background: Rectangle {
color: "transparent"
border.color: control.Universal.chromeDisabledLowColor
}
- //! [frame]
+ //! [background]
}
diff --git a/src/imports/controls/universal/GroupBox.qml b/src/imports/controls/universal/GroupBox.qml
index b4e28eb1..2b8ae935 100644
--- a/src/imports/controls/universal/GroupBox.qml
+++ b/src/imports/controls/universal/GroupBox.qml
@@ -71,8 +71,8 @@ T.GroupBox {
}
//! [label]
- //! [frame]
- frame: Rectangle {
+ //! [background]
+ background: Rectangle {
y: control.topPadding - control.padding
width: parent.width
height: parent.height - control.topPadding + control.padding
@@ -80,5 +80,5 @@ T.GroupBox {
color: "transparent"
border.color: control.Universal.chromeDisabledLowColor
}
- //! [frame]
+ //! [background]
}
diff --git a/src/imports/controls/universal/ItemDelegate.qml b/src/imports/controls/universal/ItemDelegate.qml
index 2aaf270b..3296a7cd 100644
--- a/src/imports/controls/universal/ItemDelegate.qml
+++ b/src/imports/controls/universal/ItemDelegate.qml
@@ -42,13 +42,11 @@ T.ItemDelegate {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- (label ? label.implicitWidth : 0) +
- (indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? spacing : 0) + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- Math.max(label ? label.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ baselineOffset: contentItem.y + contentItem.baselineOffset
spacing: 12
@@ -67,12 +65,10 @@ T.ItemDelegate {
}
//! [indicator]
- //! [label]
- label: Text {
- x: control.mirrored || !control.checkable ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
- y: control.topPadding
- width: control.availableWidth - (control.checkable ? indicator.width + control.spacing : 0)
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.checkable && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.checkable && control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -83,7 +79,7 @@ T.ItemDelegate {
color: !control.enabled ? control.Universal.baseLowColor : control.Universal.baseHighColor
}
- //! [label]
+ //! [contentItem]
//! [background]
background: Rectangle {
diff --git a/src/imports/controls/universal/MenuItem.qml b/src/imports/controls/universal/MenuItem.qml
index fee5d886..cc8cb75d 100644
--- a/src/imports/controls/universal/MenuItem.qml
+++ b/src/imports/controls/universal/MenuItem.qml
@@ -41,12 +41,12 @@ import Qt.labs.controls.universal 1.0
T.MenuItem {
id: control
- implicitWidth: background ? background.implicitWidth
- : (label ? label.implicitWidth : 0) + (indicator ? indicator.implicitWidth : 0)
- + (label && indicator ? spacing : 0) + leftPadding + rightPadding
- implicitHeight: background ? background.implicitHeight
- : (label ? label.implicitHeight : 0) + (indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ contentItem.implicitWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
+ indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
+ baselineOffset: contentItem.y + contentItem.baselineOffset
topPadding: 11
leftPadding: 12
@@ -54,12 +54,10 @@ T.MenuItem {
bottomPadding: 13
spacing: 12
- //! [label]
- label: Text {
- x: control.mirrored || !control.checkable ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
- y: control.topPadding
- width: control.availableWidth - (control.checkable ? indicator.width + control.spacing : 0)
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.checkable && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.checkable && control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -69,7 +67,7 @@ T.MenuItem {
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
//! [indicator]
indicator: Image {
diff --git a/src/imports/controls/universal/RadioButton.qml b/src/imports/controls/universal/RadioButton.qml
index 95e55db9..a391d670 100644
--- a/src/imports/controls/universal/RadioButton.qml
+++ b/src/imports/controls/universal/RadioButton.qml
@@ -42,13 +42,11 @@ T.RadioButton {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- (label ? label.implicitWidth : 0) +
- (indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? spacing : 0) + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- Math.max(label ? label.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 6
spacing: 8
@@ -98,12 +96,10 @@ T.RadioButton {
}
//! [indicator]
- //! [label]
- label: Text {
- x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
- y: control.topPadding
- width: control.availableWidth - indicator.width - control.spacing
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -114,5 +110,5 @@ T.RadioButton {
color: !control.enabled ? control.Universal.baseLowColor : control.Universal.baseHighColor
}
- //! [label]
+ //! [contentItem]
}
diff --git a/src/imports/controls/universal/SpinBox.qml b/src/imports/controls/universal/SpinBox.qml
index c903baf4..cfb18391 100644
--- a/src/imports/controls/universal/SpinBox.qml
+++ b/src/imports/controls/universal/SpinBox.qml
@@ -79,6 +79,7 @@ T.SpinBox {
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: TextInput.AlignVCenter
+ readOnly: !control.editable
validator: control.validator
inputMethodHints: Qt.ImhFormattedNumbersOnly
}
diff --git a/src/imports/controls/universal/StackView.qml b/src/imports/controls/universal/StackView.qml
index b49c2dbb..cbc5665d 100644
--- a/src/imports/controls/universal/StackView.qml
+++ b/src/imports/controls/universal/StackView.qml
@@ -39,13 +39,13 @@ import Qt.labs.templates 1.0 as T
import Qt.labs.controls.universal 1.0
T.StackView {
- id: root
+ id: control
//! [popEnter]
popEnter: Transition {
ParallelAnimation {
NumberAnimation { property: "opacity"; from: 0; to: 1; duration: 200; easing.type: Easing.InQuint }
- NumberAnimation { property: "x"; from: (root.mirrored ? -0.3 : 0.3) * -root.width; to: 0; duration: 400; easing.type: Easing.OutCubic }
+ NumberAnimation { property: "x"; from: (control.mirrored ? -0.3 : 0.3) * -control.width; to: 0; duration: 400; easing.type: Easing.OutCubic }
}
}
//! [popEnter]
@@ -60,7 +60,7 @@ T.StackView {
pushEnter: Transition {
ParallelAnimation {
NumberAnimation { property: "opacity"; from: 0; to: 1; duration: 200; easing.type: Easing.InQuint }
- NumberAnimation { property: "x"; from: (root.mirrored ? -0.3 : 0.3) * root.width; to: 0; duration: 400; easing.type: Easing.OutCubic }
+ NumberAnimation { property: "x"; from: (control.mirrored ? -0.3 : 0.3) * control.width; to: 0; duration: 400; easing.type: Easing.OutCubic }
}
}
//! [pushEnter]
@@ -75,7 +75,7 @@ T.StackView {
replaceEnter: Transition {
ParallelAnimation {
NumberAnimation { property: "opacity"; from: 0; to: 1; duration: 200; easing.type: Easing.InQuint }
- NumberAnimation { property: "x"; from: (root.mirrored ? -0.3 : 0.3) * root.width; to: 0; duration: 400; easing.type: Easing.OutCubic }
+ NumberAnimation { property: "x"; from: (control.mirrored ? -0.3 : 0.3) * control.width; to: 0; duration: 400; easing.type: Easing.OutCubic }
}
}
//! [replaceEnter]
diff --git a/src/imports/controls/universal/Switch.qml b/src/imports/controls/universal/Switch.qml
index 768291fc..dbbb3112 100644
--- a/src/imports/controls/universal/Switch.qml
+++ b/src/imports/controls/universal/Switch.qml
@@ -42,13 +42,11 @@ T.Switch {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- (label ? label.implicitWidth : 0) +
- (indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? spacing : 0) + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- Math.max(label ? label.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 5
spacing: 8
@@ -90,12 +88,10 @@ T.Switch {
}
//! [indicator]
- //! [label]
- label: Text {
- x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
- y: control.topPadding
- width: control.availableWidth - indicator.width - control.spacing
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -106,5 +102,5 @@ T.Switch {
color: !control.enabled ? control.Universal.baseLowColor : control.Universal.baseHighColor
}
- //! [label]
+ //! [contentItem]
}
diff --git a/src/imports/controls/universal/TabButton.qml b/src/imports/controls/universal/TabButton.qml
index c736a87b..e49bfadd 100644
--- a/src/imports/controls/universal/TabButton.qml
+++ b/src/imports/controls/universal/TabButton.qml
@@ -42,20 +42,15 @@ T.TabButton {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- label ? label.implicitWidth + leftPadding + rightPadding : 0)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- label ? label.implicitHeight + topPadding + bottomPadding : 0)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ contentItem.implicitHeight + topPadding + bottomPadding)
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 12 // PivotItemMargin
- //! [label]
- label: Text {
- x: control.leftPadding
- y: control.topPadding
- width: control.availableWidth
- height: control.availableHeight
-
+ //! [contentItem]
+ contentItem: Text {
text: control.text
font: control.font
elide: Text.ElideRight
@@ -63,5 +58,5 @@ T.TabButton {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
}
diff --git a/src/imports/controls/universal/TextArea.qml b/src/imports/controls/universal/TextArea.qml
index 255f5774..80d62cf4 100644
--- a/src/imports/controls/universal/TextArea.qml
+++ b/src/imports/controls/universal/TextArea.qml
@@ -72,7 +72,7 @@ T.TextArea {
font: control.font
color: !control.enabled ? control.Universal.chromeDisabledLowColor :
control.activeFocus ? control.Universal.chromeBlackMediumLowColor : control.Universal.baseMediumColor
- visible: !control.length && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
+ visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
horizontalAlignment: control.horizontalAlignment
verticalAlignment: control.verticalAlignment
elide: Text.ElideRight
diff --git a/src/imports/controls/universal/TextField.qml b/src/imports/controls/universal/TextField.qml
index fe9e071d..288dad02 100644
--- a/src/imports/controls/universal/TextField.qml
+++ b/src/imports/controls/universal/TextField.qml
@@ -73,7 +73,7 @@ T.TextField {
font: control.font
color: !control.enabled ? control.Universal.chromeDisabledLowColor :
control.activeFocus ? control.Universal.chromeBlackMediumLowColor : control.Universal.baseMediumColor
- visible: !control.displayText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
+ visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
horizontalAlignment: control.horizontalAlignment
verticalAlignment: control.verticalAlignment
elide: Text.ElideRight
diff --git a/src/imports/controls/universal/ToolButton.qml b/src/imports/controls/universal/ToolButton.qml
index a8fa8bd5..57d5d045 100644
--- a/src/imports/controls/universal/ToolButton.qml
+++ b/src/imports/controls/universal/ToolButton.qml
@@ -42,22 +42,17 @@ T.ToolButton {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- label ? label.implicitWidth + leftPadding + rightPadding : 0)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- label ? label.implicitHeight + topPadding + bottomPadding : 0)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ contentItem.implicitHeight + topPadding + bottomPadding)
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 6
property bool useSystemFocusVisuals: true
- //! [label]
- label: Text {
- x: control.leftPadding
- y: control.topPadding
- width: control.availableWidth
- height: control.availableHeight
-
+ //! [contentItem]
+ contentItem: Text {
text: control.text
font: control.font
color: control.enabled ? control.Universal.baseHighColor : control.Universal.baseLowColor
@@ -65,7 +60,7 @@ T.ToolButton {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
//! [background]
background: Rectangle {
diff --git a/src/imports/controls/universal/qquickuniversalfocusrectangle_p.h b/src/imports/controls/universal/qquickuniversalfocusrectangle_p.h
index 6b15bc8d..628db5b2 100644
--- a/src/imports/controls/universal/qquickuniversalfocusrectangle_p.h
+++ b/src/imports/controls/universal/qquickuniversalfocusrectangle_p.h
@@ -57,9 +57,9 @@ class QQuickUniversalFocusRectangle : public QQuickPaintedItem
Q_OBJECT
public:
- QQuickUniversalFocusRectangle(QQuickItem *parent = Q_NULLPTR);
+ QQuickUniversalFocusRectangle(QQuickItem *parent = nullptr);
- void paint(QPainter *painter) Q_DECL_OVERRIDE;
+ void paint(QPainter *painter) override;
};
QT_END_NAMESPACE
diff --git a/src/imports/controls/universal/qquickuniversalimageprovider.cpp b/src/imports/controls/universal/qquickuniversalimageprovider.cpp
deleted file mode 100644
index 7cb7b926..00000000
--- a/src/imports/controls/universal/qquickuniversalimageprovider.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the Qt Labs Controls module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** 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 The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qquickuniversalimageprovider_p.h"
-
-#include <QtCore/qdebug.h>
-#include <QtGui/qpainter.h>
-#include <QtGui/qguiapplication.h>
-#include <QtGui/qscreen.h>
-#include <QtGui/qicon.h>
-
-QT_BEGIN_NAMESPACE
-
-QQuickUniversalImageProvider::QQuickUniversalImageProvider() : QQuickImageProvider(Image)
-{
-}
-
-QImage QQuickUniversalImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
-{
- Q_UNUSED(requestedSize);
-
- int sep = id.indexOf(QLatin1Char('/'));
- QString name = id.left(sep);
- QString color = id.mid(sep + 1);
- qreal dpr = qApp->primaryScreen()->devicePixelRatio();
- QString file = qt_findAtNxFile(QStringLiteral(":/qt-project.org/imports/Qt/labs/controls/universal/images/") + name + QStringLiteral(".png"), dpr);
-
- QImage image(file);
- if (image.isNull()) {
- qWarning() << "QQuickUniversalImageProvider: unknown id:" << id;
- return QImage();
- }
-
- if (size)
- *size = image.size();
-
- if (!color.isEmpty()) {
- QPainter painter(&image);
- painter.setCompositionMode(QPainter::CompositionMode_SourceIn);
- painter.fillRect(image.rect(), QColor(color));
- }
-
- return image;
-}
-
-QT_END_NAMESPACE
diff --git a/src/imports/controls/universal/qquickuniversalimageprovider_p.h b/src/imports/controls/universal/qquickuniversalimageprovider_p.h
deleted file mode 100644
index 15648157..00000000
--- a/src/imports/controls/universal/qquickuniversalimageprovider_p.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the Qt Labs Controls module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** 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 The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QQUICKUNIVERSALIMAGEPROVIDER_P_H
-#define QQUICKUNIVERSALIMAGEPROVIDER_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtQuick/qquickimageprovider.h>
-
-QT_BEGIN_NAMESPACE
-
-class QQuickUniversalImageProvider : public QQuickImageProvider
-{
-public:
- QQuickUniversalImageProvider();
-
- QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize) Q_DECL_OVERRIDE;
-};
-
-QT_END_NAMESPACE
-
-#endif // QQUICKUNIVERSALIMAGEPROVIDER_P_H
diff --git a/src/imports/controls/universal/qquickuniversalprogressring.cpp b/src/imports/controls/universal/qquickuniversalprogressring.cpp
index 2fe66047..38931525 100644
--- a/src/imports/controls/universal/qquickuniversalprogressring.cpp
+++ b/src/imports/controls/universal/qquickuniversalprogressring.cpp
@@ -53,11 +53,11 @@ class QQuickUniversalProgressRingAnimatorJob : public QQuickAnimatorJob
public:
QQuickUniversalProgressRingAnimatorJob();
- void initialize(QQuickAnimatorController *controller) Q_DECL_OVERRIDE;
- void updateCurrentTime(int time) Q_DECL_OVERRIDE;
- void writeBack() Q_DECL_OVERRIDE;
- void nodeWasDestroyed() Q_DECL_OVERRIDE;
- void afterNodeSync() Q_DECL_OVERRIDE;
+ void initialize(QQuickAnimatorController *controller) override;
+ void updateCurrentTime(int time) override;
+ void writeBack() override;
+ void nodeWasDestroyed() override;
+ void afterNodeSync() override;
private:
struct Phase {
@@ -73,7 +73,7 @@ private:
Phase m_phases[PhaseCount];
};
-QQuickUniversalProgressRingAnimatorJob::QQuickUniversalProgressRingAnimatorJob() : m_node(Q_NULLPTR)
+QQuickUniversalProgressRingAnimatorJob::QQuickUniversalProgressRingAnimatorJob() : m_node(nullptr)
{
m_phases[0] = Phase(433, -110, 10, QEasingCurve::BezierSpline);
m_phases[1] = Phase(767, 10, 93, QEasingCurve::Linear );
@@ -121,7 +121,7 @@ void QQuickUniversalProgressRingAnimatorJob::updateCurrentTime(int time)
if (visible) {
int phaseIndex, remain = time, elapsed = 0;
- for (phaseIndex = 0; phaseIndex < PhaseCount; ++phaseIndex) {
+ for (phaseIndex = 0; phaseIndex < PhaseCount - 1; ++phaseIndex) {
if (remain <= m_phases[phaseIndex].duration + begin)
break;
remain -= m_phases[phaseIndex].duration;
@@ -153,7 +153,7 @@ void QQuickUniversalProgressRingAnimatorJob::writeBack()
void QQuickUniversalProgressRingAnimatorJob::nodeWasDestroyed()
{
- m_node = Q_NULLPTR;
+ m_node = nullptr;
}
void QQuickUniversalProgressRingAnimatorJob::afterNodeSync()
@@ -191,11 +191,12 @@ int QQuickUniversalProgressRing::count() const
void QQuickUniversalProgressRing::setCount(int count)
{
- if (m_count != count) {
- m_count = count;
- update();
- emit countChanged();
- }
+ if (m_count == count)
+ return;
+
+ m_count = count;
+ update();
+ emit countChanged();
}
QColor QQuickUniversalProgressRing::color() const
@@ -205,11 +206,12 @@ QColor QQuickUniversalProgressRing::color() const
void QQuickUniversalProgressRing::setColor(const QColor &color)
{
- if (m_color != color) {
- m_color = color;
- update();
- emit colorChanged();
- }
+ if (m_color == color)
+ return;
+
+ m_color = color;
+ update();
+ emit colorChanged();
}
QSGNode *QQuickUniversalProgressRing::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
diff --git a/src/imports/controls/universal/qquickuniversalprogressring_p.h b/src/imports/controls/universal/qquickuniversalprogressring_p.h
index 1d484e3a..f32beb54 100644
--- a/src/imports/controls/universal/qquickuniversalprogressring_p.h
+++ b/src/imports/controls/universal/qquickuniversalprogressring_p.h
@@ -60,7 +60,7 @@ class QQuickUniversalProgressRing : public QQuickItem
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL)
public:
- QQuickUniversalProgressRing(QQuickItem *parent = Q_NULLPTR);
+ QQuickUniversalProgressRing(QQuickItem *parent = nullptr);
int count() const;
void setCount(int count);
@@ -73,7 +73,7 @@ Q_SIGNALS:
void colorChanged();
protected:
- QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) Q_DECL_OVERRIDE;
+ QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override;
private:
int m_count;
@@ -85,11 +85,11 @@ class QQuickUniversalProgressRingAnimator : public QQuickAnimator
Q_OBJECT
public:
- QQuickUniversalProgressRingAnimator(QObject *parent = Q_NULLPTR);
+ QQuickUniversalProgressRingAnimator(QObject *parent = nullptr);
protected:
- QString propertyName() const Q_DECL_OVERRIDE;
- QQuickAnimatorJob *createJob() const Q_DECL_OVERRIDE;
+ QString propertyName() const override;
+ QQuickAnimatorJob *createJob() const override;
};
QT_END_NAMESPACE
diff --git a/src/imports/controls/universal/qquickuniversalprogressstrip.cpp b/src/imports/controls/universal/qquickuniversalprogressstrip.cpp
index 39ce1b5c..1ae5b371 100644
--- a/src/imports/controls/universal/qquickuniversalprogressstrip.cpp
+++ b/src/imports/controls/universal/qquickuniversalprogressstrip.cpp
@@ -62,11 +62,11 @@ class QQuickUniversalProgressStripAnimatorJob : public QQuickAnimatorJob
public:
QQuickUniversalProgressStripAnimatorJob();
- void initialize(QQuickAnimatorController *controller) Q_DECL_OVERRIDE;
- void updateCurrentTime(int time) Q_DECL_OVERRIDE;
- void writeBack() Q_DECL_OVERRIDE;
- void nodeWasDestroyed() Q_DECL_OVERRIDE;
- void afterNodeSync() Q_DECL_OVERRIDE;
+ void initialize(QQuickAnimatorController *controller) override;
+ void updateCurrentTime(int time) override;
+ void writeBack() override;
+ void nodeWasDestroyed() override;
+ void afterNodeSync() override;
private:
struct Phase {
@@ -82,7 +82,7 @@ private:
Phase m_ellipsePhases[PhaseCount];
};
-QQuickUniversalProgressStripAnimatorJob::QQuickUniversalProgressStripAnimatorJob() : m_node(Q_NULLPTR)
+QQuickUniversalProgressStripAnimatorJob::QQuickUniversalProgressStripAnimatorJob() : m_node(nullptr)
{
m_borderPhases[0] = Phase( 500, -50, 0);
m_borderPhases[1] = Phase(1500, 0, 0);
@@ -148,7 +148,7 @@ void QQuickUniversalProgressStripAnimatorJob::updateCurrentTime(int time)
if (visible) {
{
int phaseIndex, remain = time, elapsed = 0;
- for (phaseIndex = 0; phaseIndex < PhaseCount; ++phaseIndex) {
+ for (phaseIndex = 0; phaseIndex < PhaseCount - 1; ++phaseIndex) {
if (remain <= m_borderPhases[phaseIndex].duration + begin)
break;
remain -= m_borderPhases[phaseIndex].duration;
@@ -171,7 +171,7 @@ void QQuickUniversalProgressStripAnimatorJob::updateCurrentTime(int time)
curve.addCubicBezierSegment(QPointF(0.4, 0.0), QPointF(0.6, 1.0), QPointF(1.0, 1.0));
int phaseIndex, remain = time, elapsed = 0;
- for (phaseIndex = 0; phaseIndex < PhaseCount; ++phaseIndex) {
+ for (phaseIndex = 0; phaseIndex < PhaseCount - 1; ++phaseIndex) {
if (remain <= m_ellipsePhases[phaseIndex].duration + begin)
break;
remain -= m_ellipsePhases[phaseIndex].duration;
@@ -203,7 +203,7 @@ void QQuickUniversalProgressStripAnimatorJob::writeBack()
void QQuickUniversalProgressStripAnimatorJob::nodeWasDestroyed()
{
- m_node = Q_NULLPTR;
+ m_node = nullptr;
}
void QQuickUniversalProgressStripAnimatorJob::afterNodeSync()
@@ -241,11 +241,12 @@ QColor QQuickUniversalProgressStrip::color() const
void QQuickUniversalProgressStrip::setColor(const QColor &color)
{
- if (m_color != color) {
- m_color = color;
- update();
- emit colorChanged();
- }
+ if (m_color == color)
+ return;
+
+ m_color = color;
+ update();
+ emit colorChanged();
}
QSGNode *QQuickUniversalProgressStrip::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
diff --git a/src/imports/controls/universal/qquickuniversalprogressstrip_p.h b/src/imports/controls/universal/qquickuniversalprogressstrip_p.h
index b61e73c6..1b2c729d 100644
--- a/src/imports/controls/universal/qquickuniversalprogressstrip_p.h
+++ b/src/imports/controls/universal/qquickuniversalprogressstrip_p.h
@@ -59,7 +59,7 @@ class QQuickUniversalProgressStrip : public QQuickItem
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL)
public:
- QQuickUniversalProgressStrip(QQuickItem *parent = Q_NULLPTR);
+ QQuickUniversalProgressStrip(QQuickItem *parent = nullptr);
QColor color() const;
void setColor(const QColor &color);
@@ -68,7 +68,7 @@ Q_SIGNALS:
void colorChanged();
protected:
- QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) Q_DECL_OVERRIDE;
+ QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override;
private:
QColor m_color;
@@ -79,11 +79,11 @@ class QQuickUniversalProgressStripAnimator : public QQuickAnimator
Q_OBJECT
public:
- QQuickUniversalProgressStripAnimator(QObject *parent = Q_NULLPTR);
+ QQuickUniversalProgressStripAnimator(QObject *parent = nullptr);
protected:
- QString propertyName() const Q_DECL_OVERRIDE;
- QQuickAnimatorJob *createJob() const Q_DECL_OVERRIDE;
+ QString propertyName() const override;
+ QQuickAnimatorJob *createJob() const override;
};
QT_END_NAMESPACE
diff --git a/src/imports/controls/universal/qquickuniversalstyle.cpp b/src/imports/controls/universal/qquickuniversalstyle.cpp
index 2f9c86cb..17a214f4 100644
--- a/src/imports/controls/universal/qquickuniversalstyle.cpp
+++ b/src/imports/controls/universal/qquickuniversalstyle.cpp
@@ -154,27 +154,30 @@ QQuickUniversalStyle::Theme QQuickUniversalStyle::theme() const
void QQuickUniversalStyle::setTheme(Theme theme)
{
m_hasTheme = true;
- if (m_theme != theme) {
- m_theme = theme;
- propagateTheme();
- emit themeChanged();
- emit paletteChanged();
- }
+ if (m_theme == theme)
+ return;
+
+ m_theme = theme;
+ propagateTheme();
+ emit themeChanged();
+ emit paletteChanged();
}
void QQuickUniversalStyle::inheritTheme(Theme theme)
{
- if (!m_hasTheme && m_theme != theme) {
- m_theme = theme;
- propagateTheme();
- emit themeChanged();
- emit paletteChanged();
- }
+ if (m_hasTheme || m_theme == theme)
+ return;
+
+ m_theme = theme;
+ propagateTheme();
+ emit themeChanged();
+ emit paletteChanged();
}
void QQuickUniversalStyle::propagateTheme()
{
- foreach (QQuickStyle *child, childStyles()) {
+ const auto styles = childStyles();
+ for (QQuickStyle *child : styles) {
QQuickUniversalStyle *universal = qobject_cast<QQuickUniversalStyle *>(child);
if (universal)
universal->inheritTheme(m_theme);
@@ -183,11 +186,12 @@ void QQuickUniversalStyle::propagateTheme()
void QQuickUniversalStyle::resetTheme()
{
- if (m_hasTheme) {
- m_hasTheme = false;
- QQuickUniversalStyle *universal = qobject_cast<QQuickUniversalStyle *>(parentStyle());
- inheritTheme(universal ? universal->theme() : DefaultTheme);
- }
+ if (!m_hasTheme)
+ return;
+
+ m_hasTheme = false;
+ QQuickUniversalStyle *universal = qobject_cast<QQuickUniversalStyle *>(parentStyle());
+ inheritTheme(universal ? universal->theme() : DefaultTheme);
}
QVariant QQuickUniversalStyle::accent() const
@@ -220,25 +224,28 @@ void QQuickUniversalStyle::setAccent(const QVariant &var)
}
m_hasAccent = true;
- if (m_accent != accent) {
- m_accent = accent;
- propagateAccent();
- emit accentChanged();
- }
+ if (m_accent == accent)
+ return;
+
+ m_accent = accent;
+ propagateAccent();
+ emit accentChanged();
}
void QQuickUniversalStyle::inheritAccent(QRgb accent)
{
- if (!m_hasAccent && m_accent != accent) {
- m_accent = accent;
- propagateAccent();
- emit accentChanged();
- }
+ if (m_hasAccent || m_accent == accent)
+ return;
+
+ m_accent = accent;
+ propagateAccent();
+ emit accentChanged();
}
void QQuickUniversalStyle::propagateAccent()
{
- foreach (QQuickStyle *child, childStyles()) {
+ const auto styles = childStyles();
+ for (QQuickStyle *child : styles) {
QQuickUniversalStyle *universal = qobject_cast<QQuickUniversalStyle *>(child);
if (universal)
universal->inheritAccent(m_accent);
@@ -247,11 +254,12 @@ void QQuickUniversalStyle::propagateAccent()
void QQuickUniversalStyle::resetAccent()
{
- if (m_hasAccent) {
- m_hasAccent = false;
- QQuickUniversalStyle *universal = qobject_cast<QQuickUniversalStyle *>(parentStyle());
- inheritAccent(universal ? universal->m_accent : DefaultAccent);
- }
+ if (!m_hasAccent)
+ return;
+
+ m_hasAccent = false;
+ QQuickUniversalStyle *universal = qobject_cast<QQuickUniversalStyle *>(parentStyle());
+ inheritAccent(universal ? universal->m_accent : DefaultAccent);
}
QColor QQuickUniversalStyle::altHighColor() const
diff --git a/src/imports/controls/universal/qquickuniversalstyle_p.h b/src/imports/controls/universal/qquickuniversalstyle_p.h
index 00a04c65..bba1876d 100644
--- a/src/imports/controls/universal/qquickuniversalstyle_p.h
+++ b/src/imports/controls/universal/qquickuniversalstyle_p.h
@@ -87,7 +87,7 @@ class QQuickUniversalStyle : public QQuickStyle
Q_PROPERTY(QColor listMediumColor READ listMediumColor NOTIFY paletteChanged FINAL)
public:
- explicit QQuickUniversalStyle(QObject *parent = Q_NULLPTR);
+ explicit QQuickUniversalStyle(QObject *parent = nullptr);
static QQuickUniversalStyle *qmlAttachedProperties(QObject *object);
@@ -190,7 +190,7 @@ Q_SIGNALS:
void paletteChanged();
protected:
- void parentStyleChange(QQuickStyle *newParent, QQuickStyle *oldParent) Q_DECL_OVERRIDE;
+ void parentStyleChange(QQuickStyle *newParent, QQuickStyle *oldParent) override;
private:
void init();
diff --git a/src/imports/controls/universal/qquickuniversaltheme_p.h b/src/imports/controls/universal/qquickuniversaltheme_p.h
index 20243917..809d7a89 100644
--- a/src/imports/controls/universal/qquickuniversaltheme_p.h
+++ b/src/imports/controls/universal/qquickuniversaltheme_p.h
@@ -61,7 +61,7 @@ public:
~QQuickUniversalTheme();
- const QFont *font(Font type = SystemFont) const Q_DECL_OVERRIDE;
+ const QFont *font(Font type = SystemFont) const override;
private:
QFont systemFont;
diff --git a/src/imports/controls/universal/qtlabsuniversalstyleplugin.cpp b/src/imports/controls/universal/qtlabsuniversalstyleplugin.cpp
index b3a82781..51a71ea1 100644
--- a/src/imports/controls/universal/qtlabsuniversalstyleplugin.cpp
+++ b/src/imports/controls/universal/qtlabsuniversalstyleplugin.cpp
@@ -36,18 +36,21 @@
#include <QtQml/qqmlextensionplugin.h>
#include "qquickuniversalfocusrectangle_p.h"
-#include "qquickuniversalimageprovider_p.h"
#include "qquickuniversalprogressring_p.h"
#include "qquickuniversalprogressstrip_p.h"
#include "qquickuniversalstyle_p.h"
#include "qquickuniversaltheme_p.h"
#include <QtGui/private/qguiapplication_p.h>
+#include <QtLabsControls/private/qquickcolorimageprovider_p.h>
#include <QtLabsControls/private/qquickstyleselector_p.h>
static inline void initResources()
{
Q_INIT_RESOURCE(qtlabsuniversalstyleplugin);
+#ifdef QT_STATIC
+ Q_INIT_RESOURCE(qmake_Qt_labs_controls_universal);
+#endif
}
QT_BEGIN_NAMESPACE
@@ -58,14 +61,20 @@ class QtLabsUniversalStylePlugin: public QQmlExtensionPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0")
public:
+ QtLabsUniversalStylePlugin(QObject *parent = nullptr);
~QtLabsUniversalStylePlugin();
- void registerTypes(const char *uri) Q_DECL_OVERRIDE;
- void initializeEngine(QQmlEngine *engine, const char *uri) Q_DECL_OVERRIDE;
+ void registerTypes(const char *uri) override;
+ void initializeEngine(QQmlEngine *engine, const char *uri) override;
private:
QQuickProxyTheme *theme;
};
+QtLabsUniversalStylePlugin::QtLabsUniversalStylePlugin(QObject *parent) : QQmlExtensionPlugin(parent)
+{
+ initResources();
+}
+
QtLabsUniversalStylePlugin::~QtLabsUniversalStylePlugin()
{
if (theme) {
@@ -91,8 +100,7 @@ void QtLabsUniversalStylePlugin::initializeEngine(QQmlEngine *engine, const char
}
}
- initResources();
- engine->addImageProvider(QStringLiteral("universal"), new QQuickUniversalImageProvider);
+ engine->addImageProvider(QStringLiteral("universal"), new QQuickColorImageProvider(QStringLiteral(":/qt-project.org/imports/Qt/labs/controls/universal/images")));
QByteArray import = QByteArray(uri) + ".impl";
qmlRegisterType<QQuickUniversalFocusRectangle>(import, 1, 0, "FocusRectangle");
diff --git a/src/imports/controls/universal/universal.pri b/src/imports/controls/universal/universal.pri
index c7717d78..965228cb 100644
--- a/src/imports/controls/universal/universal.pri
+++ b/src/imports/controls/universal/universal.pri
@@ -34,7 +34,6 @@ QML_FILES += \
HEADERS += \
$$PWD/qquickuniversalfocusrectangle_p.h \
- $$PWD/qquickuniversalimageprovider_p.h \
$$PWD/qquickuniversalprogressring_p.h \
$$PWD/qquickuniversalprogressstrip_p.h \
$$PWD/qquickuniversalstyle_p.h \
@@ -42,7 +41,6 @@ HEADERS += \
SOURCES += \
$$PWD/qquickuniversalfocusrectangle.cpp \
- $$PWD/qquickuniversalimageprovider.cpp \
$$PWD/qquickuniversalprogressring.cpp \
$$PWD/qquickuniversalprogressstrip.cpp \
$$PWD/qquickuniversalstyle.cpp \