summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Bache-Wiig <jens.bache-wiig@digia.com>2013-05-23 17:57:37 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-24 18:04:44 +0200
commita0857d28e01e3a5769ac8f106d088fde648161e8 (patch)
tree43a618a92f4813f3d163db02253cb89e0b56f901
parent7adbdc017982aec8645e152c7891ea51f84ff8ee (diff)
downloadqtquickcontrols-a0857d28e01e3a5769ac8f106d088fde648161e8.tar.gz
Enable padding as a grouped property
We want padding to be a grouped property as the existing Margins property looks rather odd and insconsistent. Change-Id: I9e614f9161aaf01af200b19a1fb46a51beec6fb4 Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
-rw-r--r--src/controls/Button.qml5
-rw-r--r--src/controls/CheckBox.qml3
-rw-r--r--src/controls/ComboBox.qml3
-rw-r--r--src/controls/ProgressBar.qml2
-rw-r--r--src/controls/RadioButton.qml3
-rw-r--r--src/controls/ScrollView.qml4
-rw-r--r--src/controls/Slider.qml2
-rw-r--r--src/controls/SpinBox.qml8
-rw-r--r--src/controls/TabView.qml2
-rw-r--r--src/controls/TextField.qml2
-rw-r--r--src/controls/doc/qtquickcontrols.qdocconf4
-rw-r--r--src/controls/doc/src/qtquickcontrols-index.qdoc3
-rw-r--r--src/controls/doc/src/styles.qdoc6
-rw-r--r--src/private/Control.qml20
-rw-r--r--src/private/Margins.qml53
-rw-r--r--src/private/plugin.cpp3
-rw-r--r--src/private/private.pro8
-rw-r--r--src/private/qquickpaddedstyle.cpp68
-rw-r--r--src/private/qquickpaddedstyle_p.h67
-rw-r--r--src/private/qquickpadding_p.h91
-rw-r--r--src/styles/Base/ButtonStyle.qml15
-rw-r--r--src/styles/Base/CheckBoxStyle.qml14
-rw-r--r--src/styles/Base/ComboBoxStyle.qml9
-rw-r--r--src/styles/Base/GroupBoxStyle.qml9
-rw-r--r--src/styles/Base/ProgressBarStyle.qml10
-rw-r--r--src/styles/Base/RadioButtonStyle.qml9
-rw-r--r--src/styles/Base/ScrollViewStyle.qml9
-rw-r--r--src/styles/Base/SliderStyle.qml10
-rw-r--r--src/styles/Base/SpinBoxStyle.qml12
-rw-r--r--src/styles/Base/TextFieldStyle.qml9
-rw-r--r--src/styles/Desktop/GroupBoxStyle.qml4
-rw-r--r--src/styles/Desktop/ScrollViewStyle.qml4
-rw-r--r--src/styles/Desktop/SliderStyle.qml5
-rw-r--r--src/styles/Desktop/SpinBoxStyle.qml27
-rw-r--r--src/styles/Desktop/TableViewStyle.qml1
35 files changed, 389 insertions, 115 deletions
diff --git a/src/controls/Button.qml b/src/controls/Button.qml
index 2418bfa2..1a9b198e 100644
--- a/src/controls/Button.qml
+++ b/src/controls/Button.qml
@@ -57,8 +57,7 @@ import QtQuick.Controls.Private 1.0
Button is similar to the QPushButton widget.
You can create a custom appearance for a Button by
- assigning a ButtonStyle.
-
+ assigning a \l ButtonStyle.
*/
BasicButton {
id: button
@@ -66,7 +65,7 @@ BasicButton {
/*! This property holds whether the push button is the default button.
Default buttons decide what happens when the user presses enter in a
dialog without giving a button explicit focus. \note This property only
- changes the style of the button. The expected behavior needs to be
+ changes the appearance of the button. The expected behavior needs to be
implemented by the user.
The default value is \c false.
diff --git a/src/controls/CheckBox.qml b/src/controls/CheckBox.qml
index ad82a948..48d5e8b2 100644
--- a/src/controls/CheckBox.qml
+++ b/src/controls/CheckBox.qml
@@ -85,6 +85,9 @@ import QtQuick.Controls.Private 1.0
\endqml
Whenever a CheckBox is clicked, it emits the \l {AbstractCheckable::clicked}{clicked()} signal.
+
+ You can create a custom appearance for a CheckBox by
+ assigning a \l CheckBoxStyle.
*/
AbstractCheckable {
diff --git a/src/controls/ComboBox.qml b/src/controls/ComboBox.qml
index 4d207360..7b13bc8e 100644
--- a/src/controls/ComboBox.qml
+++ b/src/controls/ComboBox.qml
@@ -72,6 +72,9 @@ import QtQuick.Controls.Private 1.0
onCurrentIndexChanged: console.debug(currentText + ", " + cbItems.get(currentIndex).color)
}
\endqml
+
+ You can create a custom appearance for a ComboBox by
+ assigning a \l ComboBoxStyle.
*/
Control {
diff --git a/src/controls/ProgressBar.qml b/src/controls/ProgressBar.qml
index 1e78ed92..33e21514 100644
--- a/src/controls/ProgressBar.qml
+++ b/src/controls/ProgressBar.qml
@@ -52,6 +52,8 @@ import QtQuick.Controls.Private 1.0
The ProgressBar is used to give an indication of the progress of an operation.
\l value is updated regularly and must be between \l minimumValue and \l maximumValue.
+ You can create a custom appearance for a ProgressBar by
+ assigning a \l ProgressBarStyle.
*/
Control {
diff --git a/src/controls/RadioButton.qml b/src/controls/RadioButton.qml
index 963d085c..fde08817 100644
--- a/src/controls/RadioButton.qml
+++ b/src/controls/RadioButton.qml
@@ -72,6 +72,9 @@ import QtQuick.Controls.Private 1.0
}
}
\endqml
+
+ You can create a custom appearance for a RadioButton by
+ assigning a \l RadioButtonStyle.
*/
AbstractCheckable {
diff --git a/src/controls/ScrollView.qml b/src/controls/ScrollView.qml
index bbd21b24..31f69b8f 100644
--- a/src/controls/ScrollView.qml
+++ b/src/controls/ScrollView.qml
@@ -81,7 +81,7 @@ import QtQuick.Controls.Styles 1.0
\l flickableItem.
You can create a custom appearance for a ScrollView by
- assigning a ScrollViewStyle.
+ assigning a \l ScrollViewStyle.
*/
FocusScope {
@@ -147,7 +147,7 @@ FocusScope {
property Component style: Qt.createComponent(Settings.style + "/ScrollViewStyle.qml", root)
/* \internal */
- property Style __style: styleLoader.item
+ property PaddedStyle __style: styleLoader.item
activeFocusOnTab: true
diff --git a/src/controls/Slider.qml b/src/controls/Slider.qml
index 469843c6..711c449b 100644
--- a/src/controls/Slider.qml
+++ b/src/controls/Slider.qml
@@ -63,7 +63,7 @@ import QtQuick.Controls.Private 1.0
needed, you can set the \l stepSize.
You can create a custom appearance for a Slider by
- assigning a SliderStyle.
+ assigning a \l SliderStyle.
*/
Control {
diff --git a/src/controls/SpinBox.qml b/src/controls/SpinBox.qml
index bf8e6647..2f90ff95 100644
--- a/src/controls/SpinBox.qml
+++ b/src/controls/SpinBox.qml
@@ -201,10 +201,10 @@ Control {
id: input
clip: true
anchors.fill: parent
- anchors.leftMargin: __panel ? __panel.margins.left : 0
- anchors.topMargin: __panel ? __panel.margins.top : 0
- anchors.rightMargin: __panel ? __panel.margins.right: 0
- anchors.bottomMargin: __panel ? __panel.margins.bottom: 0
+ anchors.leftMargin: __style ? __style.padding.left : 0
+ anchors.topMargin: __style ? __style.padding.top : 0
+ anchors.rightMargin: __style ? __style.padding.right: 0
+ anchors.bottomMargin: __style ? __style.padding.bottom: 0
focus: true
activeFocusOnPress: spinbox.activeFocusOnPress
diff --git a/src/controls/TabView.qml b/src/controls/TabView.qml
index 98c2466b..d292ce05 100644
--- a/src/controls/TabView.qml
+++ b/src/controls/TabView.qml
@@ -50,7 +50,7 @@ import QtQuick.Controls.Private 1.0
\brief A control that allows the user to select one of multiple stacked items.
You can create a custom appearance for a TabView by
- assigning a TabViewStyle.
+ assigning a \l TabViewStyle.
*/
FocusScope {
diff --git a/src/controls/TextField.qml b/src/controls/TextField.qml
index 81c30fc1..903a6462 100644
--- a/src/controls/TextField.qml
+++ b/src/controls/TextField.qml
@@ -56,7 +56,7 @@ import "Styles"
TextField to be used for a password input field.
You can create a custom appearance for a TextField by
- assigning a TextFieldStyle.
+ assigning a \l TextFieldStyle.
\sa TextArea, TextInput
*/
diff --git a/src/controls/doc/qtquickcontrols.qdocconf b/src/controls/doc/qtquickcontrols.qdocconf
index a098c3d3..c04bced2 100644
--- a/src/controls/doc/qtquickcontrols.qdocconf
+++ b/src/controls/doc/qtquickcontrols.qdocconf
@@ -51,6 +51,8 @@ sources += ../../private/qstyleitem.cpp \
../../private/ScrollBar.qml \
../../private/TabBar.qml \
../../private/Control.qml \
- ../../private/Style.qml
+ ../../private/Style.qml \
+ ../../private/qquickpaddedstyle.h \
+ ../../private/qquickpaddedstyle.cpp
imagedirs += images
diff --git a/src/controls/doc/src/qtquickcontrols-index.qdoc b/src/controls/doc/src/qtquickcontrols-index.qdoc
index e9e4f708..011de527 100644
--- a/src/controls/doc/src/qtquickcontrols-index.qdoc
+++ b/src/controls/doc/src/qtquickcontrols-index.qdoc
@@ -81,4 +81,7 @@
\list
\li \l{Qt Quick Controls Examples}
\endlist
+
+ \l {Qt Quick Controls Styles QML Types}
+
*/
diff --git a/src/controls/doc/src/styles.qdoc b/src/controls/doc/src/styles.qdoc
index 4bb0ae26..40809414 100644
--- a/src/controls/doc/src/styles.qdoc
+++ b/src/controls/doc/src/styles.qdoc
@@ -31,7 +31,11 @@
\ingroup qmlmodules
\brief Provides QML types for Qt Quick Controls styles.
- The \l{Qt Quick Controls} module provides a set of QML types for handling
+ The \l{Qt Quick Controls} module provides a set of QML types for handling
styles.
+ Some of the controls allow custom styling similar to widget style sheets.
+ A styling object is usually a collection of properties that control behavior and simple delegates
+ that can be replaced with custom QML snippets.
+
*/
diff --git a/src/private/Control.qml b/src/private/Control.qml
index 6c963d22..d518adb2 100644
--- a/src/private/Control.qml
+++ b/src/private/Control.qml
@@ -43,30 +43,34 @@ import QtQuick.Controls.Styles 1.0
/*!
\qmltype Control
\internal
+ \qmlabstract
\inqmlmodule QtQuick.Controls.Private 1.0
*/
FocusScope {
id: root
+ /*! \qmlproperty Component Control::style
+
+ The style Component for this control.
+ \sa {Qt Quick Controls Styles QML Types}
+
+ */
property Component style
- /* \internal */
- property Style __style: styleLoader.item
+ /*! \internal */
+ property QtObject __style: styleLoader.item
- /* \internal */
+ /*! \internal */
property Item __panel: panelLoader.item
- /* \internal */
+ /*! \internal */
property var styleHints: []
- /* \internal */
implicitWidth: __panel ? __panel.implicitWidth: 0
-
- /* \internal */
implicitHeight: __panel ? __panel.implicitHeight: 0
-
activeFocusOnTab: false
+ /*! \internal */
property alias __controlState: styleLoader.controlState
Loader {
diff --git a/src/private/Margins.qml b/src/private/Margins.qml
deleted file mode 100644
index c52f55b8..00000000
--- a/src/private/Margins.qml
+++ /dev/null
@@ -1,53 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Quick Controls module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-import QtQuick 2.1
-import QtQuick.Controls.Styles 1.0
-
-/*!
- \qmltype Margins
- \internal
- \inqmlmodule QtQuick.Controls.Private 1.0
-*/
-QtObject {
- property int top
- property int left
- property int right
- property int bottom
-}
diff --git a/src/private/plugin.cpp b/src/private/plugin.cpp
index 0392a249..17bfed07 100644
--- a/src/private/plugin.cpp
+++ b/src/private/plugin.cpp
@@ -45,6 +45,7 @@
#include "qquicktooltip_p.h"
#include "qquickcontrolsettings_p.h"
#include "qquickspinboxvalidator_p.h"
+#include "qquickpaddedstyle_p.h"
#ifndef QT_NO_WIDGETS
#include "qquickstyleitem_p.h"
@@ -80,6 +81,8 @@ public:
void QtQuickControlsPrivatePlugin::registerTypes(const char *uri)
{
+ qmlRegisterType<QQuickPaddedStyle>(uri, 1, 0, "PaddedStyle");
+ qmlRegisterType<QQuickPadding>();
qmlRegisterType<QQuickRangeModel>(uri, 1, 0, "RangeModel");
qmlRegisterType<QQuickWheelArea>(uri, 1, 0, "WheelArea");
qmlRegisterType<QQuickSpinBoxValidator>(uri, 1, 0, "SpinBoxValidator");
diff --git a/src/private/private.pro b/src/private/private.pro
index 16b6cf81..88ce0b04 100644
--- a/src/private/private.pro
+++ b/src/private/private.pro
@@ -9,7 +9,9 @@ HEADERS += \
$$PWD/qquickrangemodel_p.h \
$$PWD/qquickrangemodel_p_p.h \
$$PWD/qquickcontrolsettings_p.h \
- $$PWD/qquickwheelarea_p.h
+ $$PWD/qquickwheelarea_p.h \
+ $$PWD/qquickpaddedstyle_p.h \
+ $$PWD/qquickpadding_p.h
SOURCES += \
$$PWD/plugin.cpp \
@@ -17,7 +19,8 @@ SOURCES += \
$$PWD/qquickspinboxvalidator.cpp \
$$PWD/qquickrangemodel.cpp \
$$PWD/qquickcontrolsettings.cpp \
- $$PWD/qquickwheelarea.cpp
+ $$PWD/qquickwheelarea.cpp \
+ $$PWD/qquickpaddedstyle.cpp
# private qml files
QML_FILES += \
@@ -25,7 +28,6 @@ QML_FILES += \
TabBar.qml \
BasicButton.qml \
Control.qml \
- Margins.qml \
Style.qml \
style.js \
ModalPopupBehavior.qml \
diff --git a/src/private/qquickpaddedstyle.cpp b/src/private/qquickpaddedstyle.cpp
new file mode 100644
index 00000000..320a3f53
--- /dev/null
+++ b/src/private/qquickpaddedstyle.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickpaddedstyle_p.h"
+#include "qquickpadding_p.h"
+
+/*!
+ \qmltype PaddedStyle
+ \instantiates QQuickPaddedStyle
+ \qmlabstract
+ \internal
+*/
+
+QT_BEGIN_NAMESPACE
+
+QQuickPaddedStyle::QQuickPaddedStyle(QQuickItem *parent) :
+ QQuickItem(parent)
+{
+}
+
+/*!
+ \qmlproperty int PaddedStyle::padding.top
+ \qmlproperty int PaddedStyle::padding.left
+ \qmlproperty int PaddedStyle::padding.right
+ \qmlproperty int PaddedStyle::padding.bottom
+
+ This grouped property holds the \c top, \c left, \c right and \c bottom padding.
+*/
+
+QT_END_NAMESPACE
diff --git a/src/private/qquickpaddedstyle_p.h b/src/private/qquickpaddedstyle_p.h
new file mode 100644
index 00000000..1a5a3c95
--- /dev/null
+++ b/src/private/qquickpaddedstyle_p.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKPADDEDSTYLE_H
+#define QQUICKPADDEDSTYLE_H
+
+#include <QtQuick/QQuickItem>
+#include <QtQml/QQmlListProperty>
+#include "qquickpadding_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QQuickPaddedStyle : public QQuickItem
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QQuickPadding* padding READ padding CONSTANT)
+
+public:
+ QQuickPaddedStyle(QQuickItem *parent = 0);
+ QQuickPadding* padding() { return &m_padding; }
+
+private:
+ QQuickPadding m_padding;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKPADDEDSTYLE_H
diff --git a/src/private/qquickpadding_p.h b/src/private/qquickpadding_p.h
new file mode 100644
index 00000000..1830df4c
--- /dev/null
+++ b/src/private/qquickpadding_p.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKPADDING_H
+#define QQUICKPADDING_H
+
+#include <QtCore/qobject.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickPadding : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(int left READ left WRITE setLeft NOTIFY leftChanged)
+ Q_PROPERTY(int top READ top WRITE setTop NOTIFY topChanged)
+ Q_PROPERTY(int right READ right WRITE setRight NOTIFY rightChanged)
+ Q_PROPERTY(int bottom READ bottom WRITE setBottom NOTIFY bottomChanged)
+
+ int m_left;
+ int m_top;
+ int m_right;
+ int m_bottom;
+
+public:
+ QQuickPadding(QObject *parent = 0) :
+ QObject(parent),
+ m_left(0),
+ m_top(0),
+ m_right(0),
+ m_bottom(0) {}
+
+ int left() const { return m_left; }
+ int top() const { return m_top; }
+ int right() const { return m_right; }
+ int bottom() const { return m_bottom; }
+
+public slots:
+ void setLeft(int arg) { if (m_left != arg) {m_left = arg; emit leftChanged();}}
+ void setTop(int arg) { if (m_top != arg) {m_top = arg; emit topChanged();}}
+ void setRight(int arg) { if (m_right != arg) {m_right = arg; emit rightChanged();}}
+ void setBottom(int arg) {if (m_bottom != arg) {m_bottom = arg; emit bottomChanged();}}
+
+signals:
+ void leftChanged();
+ void topChanged();
+ void rightChanged();
+ void bottomChanged();
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKPADDING_H
diff --git a/src/styles/Base/ButtonStyle.qml b/src/styles/Base/ButtonStyle.qml
index 91796292..a524d93f 100644
--- a/src/styles/Base/ButtonStyle.qml
+++ b/src/styles/Base/ButtonStyle.qml
@@ -72,14 +72,25 @@ import QtQuick.Controls.Private 1.0
If you need a custom label, you can replace the label item.
*/
-Style {
+PaddedStyle {
id: buttonstyle
/*! The \l Button attached to this style. */
readonly property Button control: __control
+ /*! \internal */
+ property var __syspal: SystemPalette {
+ colorGroup: control.enabled ?
+ SystemPalette.Active : SystemPalette.Disabled
+ }
+
/*! The padding between the background and the label components. */
- property Margins padding: Margins { top: 4 ; left: 4 ; right: 4 ; bottom: 4 }
+ padding {
+ top: 4
+ left: 4
+ right: 4
+ bottom: 4
+ }
/*! The background of the button. */
property Component background: Item {
diff --git a/src/styles/Base/CheckBoxStyle.qml b/src/styles/Base/CheckBoxStyle.qml
index ccf40f0d..1323aa85 100644
--- a/src/styles/Base/CheckBoxStyle.qml
+++ b/src/styles/Base/CheckBoxStyle.qml
@@ -72,11 +72,16 @@ import QtQuick.Controls.Private 1.0
}
\endqml
*/
-Style {
+PaddedStyle {
id: checkboxStyle
/*! The \l CheckBox attached to this style. */
readonly property CheckBox control: __control
+ /*! \internal */
+ property var __syspal: SystemPalette {
+ colorGroup: control.enabled ?
+ SystemPalette.Active : SystemPalette.Disabled
+ }
/*! The text label. */
property Component label: Text {
@@ -87,7 +92,12 @@ Style {
}
/*! The content padding. */
- property Margins padding: Margins { top: 0 ; left: 0 ; right: 4 ; bottom: 0 }
+ padding {
+ top: 0
+ left: 0
+ right: 4
+ bottom: 0
+ }
/*! The spacing between indicator and label. */
property int spacing: 4
diff --git a/src/styles/Base/ComboBoxStyle.qml b/src/styles/Base/ComboBoxStyle.qml
index deb5ea50..9795d1a8 100644
--- a/src/styles/Base/ComboBoxStyle.qml
+++ b/src/styles/Base/ComboBoxStyle.qml
@@ -49,13 +49,18 @@ import QtQuick.Controls.Private 1.0
\brief Provides custom styling for ComboBox
*/
-Style {
+PaddedStyle {
+ /*! \internal */
+ property var __syspal: SystemPalette {
+ colorGroup: control.enabled ?
+ SystemPalette.Active : SystemPalette.Disabled
+ }
/*! The \l ComboBox attached to this style. */
readonly property ComboBox control: __control
/*! The padding between the background and the label components. */
- property Margins padding: Margins { top: 4 ; left: 6 ; right: 6 ; bottom:4 }
+ padding { top: 4 ; left: 6 ; right: 6 ; bottom:4 }
/*! The background of the button. */
property Component background: Item {
diff --git a/src/styles/Base/GroupBoxStyle.qml b/src/styles/Base/GroupBoxStyle.qml
index d8538b95..86fc83fe 100644
--- a/src/styles/Base/GroupBoxStyle.qml
+++ b/src/styles/Base/GroupBoxStyle.qml
@@ -47,13 +47,18 @@ import QtQuick.Controls.Private 1.0
\inqmlmodule QtQuick.Controls.Styles 1.0
\since QtQuick.Controls.Styles 1.0
*/
-Style {
+PaddedStyle {
+ /*! \internal */
+ property var __syspal: SystemPalette {
+ colorGroup: control.enabled ?
+ SystemPalette.Active : SystemPalette.Disabled
+ }
/*! The \l GroupBox attached to this style. */
readonly property GroupBox control: __control
/*! The margin from the content item to the groupbox. */
- property Margins padding: Margins {
+ padding {
top: (control.title.length > 0 || control.checkable ? 16 : 0) + 10
left: 8
right: 8
diff --git a/src/styles/Base/ProgressBarStyle.qml b/src/styles/Base/ProgressBarStyle.qml
index 94c3bc41..1d7c98a8 100644
--- a/src/styles/Base/ProgressBarStyle.qml
+++ b/src/styles/Base/ProgressBarStyle.qml
@@ -71,9 +71,14 @@ import QtQuick.Controls.Private 1.0
\endqml
*/
-Style {
+PaddedStyle {
id: progressBarStyle
+ /*! \internal */
+ property var __syspal: SystemPalette {
+ colorGroup: control.enabled ?
+ SystemPalette.Active : SystemPalette.Disabled
+ }
/*! The \l ProgressBar attached to this style. */
readonly property ProgressBar control: __control
@@ -87,8 +92,7 @@ Style {
For convenience, you can also access the readonly property \c controlState.progress
which provides the current progress as a \c real in the range [0-1]
*/
- property Margins padding: Margins { top: 0 ; left: 0 ; right: 0 ; bottom: 0 }
-
+ padding { top: 0 ; left: 0 ; right: 0 ; bottom: 0 }
property Component progress: Rectangle {
property color progressColor: "#49d"
diff --git a/src/styles/Base/RadioButtonStyle.qml b/src/styles/Base/RadioButtonStyle.qml
index e1696ad2..49d15e3d 100644
--- a/src/styles/Base/RadioButtonStyle.qml
+++ b/src/styles/Base/RadioButtonStyle.qml
@@ -72,9 +72,14 @@ import QtQuick.Controls.Private 1.0
\endqml
*/
-Style {
+PaddedStyle {
id: radiobuttonStyle
+ /*! \internal */
+ property var __syspal: SystemPalette {
+ colorGroup: control.enabled ?
+ SystemPalette.Active : SystemPalette.Disabled
+ }
/*! The \l RadioButton attached to this style. */
readonly property RadioButton control: __control
@@ -87,7 +92,7 @@ Style {
}
/*! The content padding. */
- property Margins padding: Margins { top: 0 ; left: 0 ; right: 4 ; bottom: 0 }
+ padding { top: 0 ; left: 0 ; right: 4 ; bottom: 0 }
/*! The spacing between indicator and label. */
property int spacing: 4
diff --git a/src/styles/Base/ScrollViewStyle.qml b/src/styles/Base/ScrollViewStyle.qml
index a6f3a39a..8bf5a120 100644
--- a/src/styles/Base/ScrollViewStyle.qml
+++ b/src/styles/Base/ScrollViewStyle.qml
@@ -47,14 +47,19 @@ import QtQuick.Controls.Private 1.0
\since QtQuick.Controls.Styles 1.0
\brief Provides custom styling for ScrollView
*/
-Style {
+PaddedStyle {
id: root
+ /*! \internal */
+ property var __syspal: SystemPalette {
+ colorGroup: control.enabled ?
+ SystemPalette.Active : SystemPalette.Disabled
+ }
/*! The \l ScrollView attached to this style. */
readonly property ScrollView control: __control
/*! This property controls the frame border padding of the scrollView. */
- property Margins padding: Margins {left: 1; top: 1; right: 1; bottom: 1}
+ padding {left: 1; top: 1; right: 1; bottom: 1}
/*! This Component paints the corner area between scroll bars */
property Component corner: Rectangle { color: "#ccc" }
diff --git a/src/styles/Base/SliderStyle.qml b/src/styles/Base/SliderStyle.qml
index 0e244b62..7870e2f2 100644
--- a/src/styles/Base/SliderStyle.qml
+++ b/src/styles/Base/SliderStyle.qml
@@ -78,14 +78,18 @@ import QtQuick.Controls.Private 1.0
}
\endqml
*/
-Style {
+PaddedStyle {
id: styleitem
+ /*! \internal */
+ property var __syspal: SystemPalette {
+ colorGroup: control.enabled ?
+ SystemPalette.Active : SystemPalette.Disabled
+ }
/*! The \l Slider attached to this style. */
readonly property Slider control: __control
- /*! The padding around the groove item. */
- property Margins padding: Margins { top: 0 ; left: 0 ; right: 0 ; bottom: 0 }
+ padding { top: 0 ; left: 0 ; right: 0 ; bottom: 0 }
/*! This property holds the item for the slider handle.
You can access the slider through the \c control property
diff --git a/src/styles/Base/SpinBoxStyle.qml b/src/styles/Base/SpinBoxStyle.qml
index 07ddf6d7..9b37fe5b 100644
--- a/src/styles/Base/SpinBoxStyle.qml
+++ b/src/styles/Base/SpinBoxStyle.qml
@@ -49,14 +49,20 @@ import QtQuick.Controls.Private 1.0
\brief Provides custom styling for SpinBox
*/
-Style {
+PaddedStyle {
id: spinboxStyle
/*! The \l SpinBox attached to this style. */
readonly property SpinBox control: __control
+ /*! \internal */
+ property var __syspal: SystemPalette {
+ colorGroup: control.enabled ?
+ SystemPalette.Active : SystemPalette.Disabled
+ }
+
/*! The content margins of the text field. */
- property Margins margins: Margins { top: 0 ; left: 5 ; right: 12 ; bottom: 0 }
+ padding { top: 0 ; left: 5 ; right: 12 ; bottom: 0 }
/*! The text color. */
property color textColor: __syspal.text
@@ -130,7 +136,7 @@ Style {
property color selectionColor: spinboxStyle.selectionColor
property color selectedTextColor: spinboxStyle.selectedTextColor
- property var margins: spinboxStyle.margins
+ property var margins: spinboxStyle.padding
property rect upRect: Qt.rect(width - incrementControlLoader.implicitWidth, 0, incrementControlLoader.implicitWidth, height / 2 + 1)
property rect downRect: Qt.rect(width - decrementControlLoader.implicitWidth, height / 2, decrementControlLoader.implicitWidth, height / 2)
diff --git a/src/styles/Base/TextFieldStyle.qml b/src/styles/Base/TextFieldStyle.qml
index 4e7e8b66..3c1a10a6 100644
--- a/src/styles/Base/TextFieldStyle.qml
+++ b/src/styles/Base/TextFieldStyle.qml
@@ -64,14 +64,19 @@ import QtQuick.Controls.Private 1.0
\endqml
*/
-Style {
+PaddedStyle {
id: style
+ /*! \internal */
+ property var __syspal: SystemPalette {
+ colorGroup: control.enabled ?
+ SystemPalette.Active : SystemPalette.Disabled
+ }
/*! The \l TextField attached to this style. */
readonly property TextField control: __control
/*! The content margins of the text field. */
- property Margins padding: Margins { top: 4 ; left: 6 ; right: 6 ; bottom:4 }
+ padding { top: 4 ; left: 6 ; right: 6 ; bottom:4 }
/*! The current font. */
property font font
diff --git a/src/styles/Desktop/GroupBoxStyle.qml b/src/styles/Desktop/GroupBoxStyle.qml
index d22341c5..3c4bfc43 100644
--- a/src/styles/Desktop/GroupBoxStyle.qml
+++ b/src/styles/Desktop/GroupBoxStyle.qml
@@ -42,7 +42,7 @@ import QtQuick.Controls 1.0
import QtQuick.Controls.Private 1.0
-Style {
+PaddedStyle {
readonly property GroupBox control: __control
property var __style: StyleItem { id: style }
@@ -54,7 +54,7 @@ Style {
titleHeight = 9
}
- property Margins padding: Margins {
+ padding {
top: (control.title.length > 0 || control.checkable ? titleHeight : 0) + 6
left: 8
right: 8
diff --git a/src/styles/Desktop/ScrollViewStyle.qml b/src/styles/Desktop/ScrollViewStyle.qml
index cc13cb42..42c9fc3e 100644
--- a/src/styles/Desktop/ScrollViewStyle.qml
+++ b/src/styles/Desktop/ScrollViewStyle.qml
@@ -42,10 +42,10 @@ import QtQuick.Controls 1.0
import QtQuick.Controls.Private 1.0
import "." as Desktop
-Style {
+PaddedStyle {
id: root
- property Margins padding: Margins {
+ padding {
property int frameWidth: __styleitem.pixelMetric("defaultframewidth")
left: frameWidth
top: frameWidth
diff --git a/src/styles/Desktop/SliderStyle.qml b/src/styles/Desktop/SliderStyle.qml
index d84c21ef..c55ef874 100644
--- a/src/styles/Desktop/SliderStyle.qml
+++ b/src/styles/Desktop/SliderStyle.qml
@@ -40,7 +40,8 @@
import QtQuick 2.1
import QtQuick.Controls.Private 1.0
-Style {
+PaddedStyle {
+ readonly property Item control: __control
property Component panel: StyleItem {
elementType: "slider"
sunken: control.pressed
@@ -60,5 +61,5 @@ Style {
property int handleWidth: 15
property int handleHeight: 15
}
- property Margins padding: Margins { top: 0 ; left: 0 ; right: 0 ; bottom: 0 }
+ padding { top: 0 ; left: 0 ; right: 0 ; bottom: 0 }
}
diff --git a/src/styles/Desktop/SpinBoxStyle.qml b/src/styles/Desktop/SpinBoxStyle.qml
index 02b2ecbe..644b4972 100644
--- a/src/styles/Desktop/SpinBoxStyle.qml
+++ b/src/styles/Desktop/SpinBoxStyle.qml
@@ -41,21 +41,27 @@ import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Controls.Private 1.0
-Style {
+PaddedStyle {
readonly property SpinBox control: __control
+
+ property var __syspal: SystemPalette {
+ colorGroup: control.enabled ?
+ SystemPalette.Active : SystemPalette.Disabled
+ }
+
+ padding {
+ top: control.__panel ? control.__panel.topPadding : 0
+ left: control.__panel ? control.__panel.leftPadding : 0
+ right: control.__panel ? control.__panel.rightPadding : 0
+ bottom: control.__panel ? control.__panel.bottomPadding : 0
+ }
+
property Component panel: Item {
id: style
property rect upRect
property rect downRect
- property Margins margins: Margins{
- top: edit.anchors.topMargin
- left: 2 + edit.anchors.leftMargin
- right: 2 + edit.anchors.leftMargin
- bottom: edit.anchors.bottomMargin
- }
-
property int horizontalTextAlignment: Qt.AlignLeft
property int verticalTextAlignment: Qt.AlignVCenter
@@ -64,6 +70,11 @@ Style {
property color selectionColor: __syspal.highlight
property color selectedTextColor: __syspal.highlightedText
+ property int topPadding: edit.anchors.topMargin
+ property int leftPadding: 2 + edit.anchors.leftMargin
+ property int rightPadding: 2 + edit.anchors.leftMargin
+ property int bottomPadding: edit.anchors.bottomMargin
+
width: 100
height: styleitem.implicitHeight
diff --git a/src/styles/Desktop/TableViewStyle.qml b/src/styles/Desktop/TableViewStyle.qml
index 6cb13749..da6a47e5 100644
--- a/src/styles/Desktop/TableViewStyle.qml
+++ b/src/styles/Desktop/TableViewStyle.qml
@@ -44,6 +44,7 @@ import QtQuick.Controls.Private 1.0
ScrollViewStyle {
id: root
+ readonly property TableView control: __control
property bool activateItemOnSingleClick: __styleitem.styleHint("activateItemOnSingleClick")
property color textColor: __styleitem.styleHint("textColor")
property color highlightedTextColor: __styleitem.styleHint("highlightedTextColor")