aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2015-06-27 00:57:26 +0200
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2015-06-30 08:24:42 +0000
commit2ba8261fee95cca0d119879a95f871133f0b51d5 (patch)
tree0dc1471967a3ba3daca026aaace737a8b67b0585
parente7869a71faf9d3b2c120e734c7323df0bf41dff6 (diff)
Control::spacing
Change-Id: I67d81db16e95813b1ed9903017ce4d272093f7bb Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
-rw-r--r--src/controls/qquickcontrol.cpp27
-rw-r--r--src/controls/qquickcontrol_p.h6
-rw-r--r--src/controls/qquickcontrol_p_p.h1
-rw-r--r--src/controls/qquicktabbar.cpp1
-rw-r--r--src/imports/calendar/CalendarView.qml2
-rw-r--r--src/imports/calendar/DayOfWeekRow.qml1
-rw-r--r--src/imports/calendar/WeekNumberColumn.qml1
-rw-r--r--src/imports/controls/CheckBox.qml7
-rw-r--r--src/imports/controls/GroupBox.qml3
-rw-r--r--src/imports/controls/PageIndicator.qml3
-rw-r--r--src/imports/controls/RadioButton.qml7
-rw-r--r--src/imports/controls/Switch.qml7
-rw-r--r--src/imports/controls/TabBar.qml4
-rw-r--r--src/imports/controls/ToggleButton.qml7
-rw-r--r--src/imports/extras/SwipeView.qml3
15 files changed, 61 insertions, 19 deletions
diff --git a/src/controls/qquickcontrol.cpp b/src/controls/qquickcontrol.cpp
index 5415ff8e..1b41c352 100644
--- a/src/controls/qquickcontrol.cpp
+++ b/src/controls/qquickcontrol.cpp
@@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE
QQuickControlPrivate::QQuickControlPrivate() :
hasTopPadding(false), hasLeftPadding(false), hasRightPadding(false), hasBottomPadding(false),
- padding(0), topPadding(0), leftPadding(0), rightPadding(0), bottomPadding(0),
+ padding(0), topPadding(0), leftPadding(0), rightPadding(0), bottomPadding(0), spacing(0),
layoutDirection(Qt::LeftToRight), background(Q_NULLPTR), contentItem(Q_NULLPTR)
{
}
@@ -328,6 +328,31 @@ void QQuickControl::resetBottomPadding()
}
/*!
+ \qmlproperty real QtQuickControls2::Control::spacing
+
+ This property holds the spacing.
+*/
+qreal QQuickControl::spacing() const
+{
+ Q_D(const QQuickControl);
+ return d->spacing;
+}
+
+void QQuickControl::setSpacing(qreal spacing)
+{
+ Q_D(QQuickControl);
+ if (!qFuzzyCompare(d->spacing, spacing)) {
+ d->spacing = spacing;
+ emit spacingChanged();
+ }
+}
+
+void QQuickControl::resetSpacing()
+{
+ setSpacing(0);
+}
+
+/*!
\qmlproperty enumeration QtQuickControls2::Control::layoutDirection
This property holds the layout direction of the control.
diff --git a/src/controls/qquickcontrol_p.h b/src/controls/qquickcontrol_p.h
index 77d33f05..1c9bee3c 100644
--- a/src/controls/qquickcontrol_p.h
+++ b/src/controls/qquickcontrol_p.h
@@ -65,6 +65,7 @@ class Q_QUICKCONTROLS_EXPORT QQuickControl : public QQuickItem
Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding RESET resetLeftPadding NOTIFY leftPaddingChanged FINAL)
Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding RESET resetRightPadding NOTIFY rightPaddingChanged FINAL)
Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged FINAL)
+ Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing RESET resetSpacing NOTIFY spacingChanged FINAL)
Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged FINAL)
Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged FINAL)
Q_PROPERTY(bool mirrored READ isMirrored NOTIFY mirroredChanged FINAL)
@@ -97,6 +98,10 @@ public:
void setBottomPadding(qreal padding);
void resetBottomPadding();
+ qreal spacing() const;
+ void setSpacing(qreal spacing);
+ void resetSpacing();
+
Qt::LayoutDirection layoutDirection() const;
Qt::LayoutDirection effectiveLayoutDirection() const;
void setLayoutDirection(Qt::LayoutDirection direction);
@@ -117,6 +122,7 @@ Q_SIGNALS:
void leftPaddingChanged();
void rightPaddingChanged();
void bottomPaddingChanged();
+ void spacingChanged();
void layoutDirectionChanged();
void effectiveLayoutDirectionChanged();
void mirroredChanged();
diff --git a/src/controls/qquickcontrol_p_p.h b/src/controls/qquickcontrol_p_p.h
index e5beb905..93bfe22f 100644
--- a/src/controls/qquickcontrol_p_p.h
+++ b/src/controls/qquickcontrol_p_p.h
@@ -78,6 +78,7 @@ public:
qreal leftPadding;
qreal rightPadding;
qreal bottomPadding;
+ qreal spacing;
Qt::LayoutDirection layoutDirection;
QQuickItem *background;
QQuickItem *contentItem;
diff --git a/src/controls/qquicktabbar.cpp b/src/controls/qquicktabbar.cpp
index 7714ddbe..ff28f620 100644
--- a/src/controls/qquicktabbar.cpp
+++ b/src/controls/qquicktabbar.cpp
@@ -114,7 +114,6 @@ void QQuickTabBarPrivate::updateLayout()
Q_Q(QQuickTabBar);
const int count = contentModel->count();
if (count > 0 && contentItem) {
- const qreal spacing = contentItem->property("spacing").toReal();
const qreal itemWidth = (contentItem->width() - qMax(0, count - 1) * spacing) / count;
for (int i = 0; i < count; ++i) {
diff --git a/src/imports/calendar/CalendarView.qml b/src/imports/calendar/CalendarView.qml
index 2d77c6f4..9a6c8d1e 100644
--- a/src/imports/calendar/CalendarView.qml
+++ b/src/imports/calendar/CalendarView.qml
@@ -67,6 +67,8 @@ AbstractCalendarView {
contentItem: Grid {
rows: 6
columns: 7
+ rowSpacing: control.spacing
+ columnSpacing: control.spacing
Repeater {
model: control.source
diff --git a/src/imports/calendar/DayOfWeekRow.qml b/src/imports/calendar/DayOfWeekRow.qml
index 50c1cb46..08532527 100644
--- a/src/imports/calendar/DayOfWeekRow.qml
+++ b/src/imports/calendar/DayOfWeekRow.qml
@@ -63,6 +63,7 @@ AbstractDayOfWeekRow {
//! [contentItem]
contentItem: Row {
+ spacing: control.spacing
Repeater {
model: control.source
delegate: control.delegate
diff --git a/src/imports/calendar/WeekNumberColumn.qml b/src/imports/calendar/WeekNumberColumn.qml
index 7235262b..8c0e75fa 100644
--- a/src/imports/calendar/WeekNumberColumn.qml
+++ b/src/imports/calendar/WeekNumberColumn.qml
@@ -63,6 +63,7 @@ AbstractWeekNumberColumn {
//! [contentItem]
contentItem: Column {
+ spacing: control.spacing
Repeater {
model: control.source
delegate: control.delegate
diff --git a/src/imports/controls/CheckBox.qml b/src/imports/controls/CheckBox.qml
index 9e71dda9..833a720f 100644
--- a/src/imports/controls/CheckBox.qml
+++ b/src/imports/controls/CheckBox.qml
@@ -43,7 +43,7 @@ AbstractCheckBox {
implicitWidth: Math.max(background ? background.implicitWidth : 0,
(label ? label.implicitWidth : 0) +
(indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? Theme.spacing : 0) + leftPadding + rightPadding)
+ (label && indicator ? spacing : 0) + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
Math.max(label ? label.implicitHeight : 0,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
@@ -54,6 +54,7 @@ AbstractCheckBox {
Accessible.role: Accessible.CheckBox
padding: Theme.padding
+ spacing: Theme.spacing
//! [indicator]
indicator: Rectangle {
@@ -84,9 +85,9 @@ AbstractCheckBox {
//! [label]
label: Text {
- x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.Theme.spacing)
+ x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
y: control.topPadding
- width: control.availableWidth - indicator.width - control.Theme.spacing
+ width: control.availableWidth - indicator.width - control.spacing
height: control.availableHeight
text: control.text
diff --git a/src/imports/controls/GroupBox.qml b/src/imports/controls/GroupBox.qml
index cc84008f..7a625a81 100644
--- a/src/imports/controls/GroupBox.qml
+++ b/src/imports/controls/GroupBox.qml
@@ -46,8 +46,9 @@ AbstractGroupBox {
contentWidth: contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0
contentHeight: contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0
+ spacing: Theme.spacing
padding: Theme.padding
- topPadding: Theme.padding + (label && title ? label.implicitHeight + Theme.spacing : 0)
+ topPadding: Theme.padding + (label && title ? label.implicitHeight + spacing : 0)
//! [contentItem]
contentItem: Item { }
diff --git a/src/imports/controls/PageIndicator.qml b/src/imports/controls/PageIndicator.qml
index aa7cbc6f..cb74567d 100644
--- a/src/imports/controls/PageIndicator.qml
+++ b/src/imports/controls/PageIndicator.qml
@@ -48,6 +48,7 @@ AbstractPageIndicator {
contentItem.implicitHeight + topPadding + bottomPadding)
padding: Theme.padding
+ spacing: Theme.spacing
//! [delegate]
delegate: Rectangle {
@@ -64,7 +65,7 @@ AbstractPageIndicator {
//! [contentItem]
contentItem: Row {
- spacing: control.Theme.spacing
+ spacing: control.spacing
Repeater {
model: control.count
diff --git a/src/imports/controls/RadioButton.qml b/src/imports/controls/RadioButton.qml
index 106b382e..cd2b553a 100644
--- a/src/imports/controls/RadioButton.qml
+++ b/src/imports/controls/RadioButton.qml
@@ -43,7 +43,7 @@ AbstractRadioButton {
implicitWidth: Math.max(background ? background.implicitWidth : 0,
(label ? label.implicitWidth : 0) +
(indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? Theme.spacing : 0) + leftPadding + rightPadding)
+ (label && indicator ? spacing : 0) + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
Math.max(label ? label.implicitHeight : 0,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
@@ -54,6 +54,7 @@ AbstractRadioButton {
Accessible.role: Accessible.RadioButton
padding: Theme.padding
+ spacing: Theme.spacing
//! [indicator]
indicator: Rectangle {
@@ -85,9 +86,9 @@ AbstractRadioButton {
//! [label]
label: Text {
- x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.Theme.spacing)
+ x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
y: control.topPadding
- width: control.availableWidth - indicator.width - control.Theme.spacing
+ width: control.availableWidth - indicator.width - control.spacing
height: control.availableHeight
text: control.text
diff --git a/src/imports/controls/Switch.qml b/src/imports/controls/Switch.qml
index c1661f35..e61fb152 100644
--- a/src/imports/controls/Switch.qml
+++ b/src/imports/controls/Switch.qml
@@ -43,7 +43,7 @@ AbstractSwitch {
implicitWidth: Math.max(background ? background.implicitWidth : 0,
(label ? label.implicitWidth : 0) +
(indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? Theme.spacing : 0) + leftPadding + rightPadding)
+ (label && indicator ? spacing : 0) + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
Math.max(label ? label.implicitHeight : 0,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
@@ -55,6 +55,7 @@ AbstractSwitch {
Accessible.role: Accessible.Button // TODO: Switch?
padding: Theme.padding
+ spacing: Theme.spacing
//! [indicator]
indicator: Rectangle {
@@ -94,9 +95,9 @@ AbstractSwitch {
//! [label]
label: Text {
- x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.Theme.spacing)
+ x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
y: control.topPadding
- width: control.availableWidth - indicator.width - control.Theme.spacing
+ width: control.availableWidth - indicator.width - control.spacing
height: control.availableHeight
text: control.text
diff --git a/src/imports/controls/TabBar.qml b/src/imports/controls/TabBar.qml
index 02363935..229e5f68 100644
--- a/src/imports/controls/TabBar.qml
+++ b/src/imports/controls/TabBar.qml
@@ -49,11 +49,13 @@ AbstractTabBar {
Accessible.role: Accessible.PageTabList
+ spacing: 1
+
//! [contentItem]
contentItem: ListView {
id: listView
- spacing: 1
+ spacing: control.spacing
orientation: ListView.Horizontal
boundsBehavior: Flickable.StopAtBounds
snapMode: ListView.SnapToItem
diff --git a/src/imports/controls/ToggleButton.qml b/src/imports/controls/ToggleButton.qml
index 1655a317..2ecc0f18 100644
--- a/src/imports/controls/ToggleButton.qml
+++ b/src/imports/controls/ToggleButton.qml
@@ -43,7 +43,7 @@ AbstractToggleButton {
implicitWidth: Math.max(background ? background.implicitWidth : 0,
(label ? label.implicitWidth : 0) +
(indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? Theme.spacing : 0) + leftPadding + rightPadding)
+ (label && indicator ? spacing : 0) + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
Math.max(label ? label.implicitHeight : 0,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
@@ -55,6 +55,7 @@ AbstractToggleButton {
Accessible.role: Accessible.Button
padding: Theme.padding
+ spacing: Theme.spacing
//! [indicator]
indicator: Rectangle {
@@ -93,9 +94,9 @@ AbstractToggleButton {
//! [label]
label: Text {
- x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.Theme.spacing)
+ x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
y: control.topPadding
- width: control.availableWidth - indicator.width - control.Theme.spacing
+ width: control.availableWidth - indicator.width - control.spacing
height: control.availableHeight
text: control.text
diff --git a/src/imports/extras/SwipeView.qml b/src/imports/extras/SwipeView.qml
index e52a8b44..f234d84a 100644
--- a/src/imports/extras/SwipeView.qml
+++ b/src/imports/extras/SwipeView.qml
@@ -40,8 +40,6 @@ import QtQuick.Extras 2.0
AbstractSwipeView {
id: control
- property alias spacing: listView.spacing
-
implicitWidth: Math.max(background ? background.implicitWidth : 0,
contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
@@ -56,6 +54,7 @@ AbstractSwipeView {
model: control.contentModel
currentIndex: control.currentIndex
+ spacing: control.spacing
orientation: Qt.Horizontal
snapMode: ListView.SnapOneItem
boundsBehavior: Flickable.StopAtBounds