aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports
diff options
context:
space:
mode:
Diffstat (limited to 'src/imports')
-rw-r--r--src/imports/calendar/CalendarDelegate.qml60
-rw-r--r--src/imports/calendar/CalendarView.qml78
-rw-r--r--src/imports/calendar/DayOfWeekRow.qml75
-rw-r--r--src/imports/calendar/WeekNumberColumn.qml75
-rw-r--r--src/imports/calendar/calendar.pro21
-rw-r--r--src/imports/calendar/qmldir7
-rw-r--r--src/imports/calendar/qtquickcalendar2plugin.cpp71
-rw-r--r--src/imports/controls/ApplicationWindow.qml55
-rw-r--r--src/imports/controls/BusyIndicator.qml80
-rw-r--r--src/imports/controls/Button.qml78
-rw-r--r--src/imports/controls/CheckBox.qml101
-rw-r--r--src/imports/controls/Frame.qml68
-rw-r--r--src/imports/controls/GroupBox.qml89
-rw-r--r--src/imports/controls/Label.qml47
-rw-r--r--src/imports/controls/PageIndicator.qml81
-rw-r--r--src/imports/controls/ProgressBar.qml101
-rw-r--r--src/imports/controls/RadioButton.qml102
-rw-r--r--src/imports/controls/ScrollBar.qml84
-rw-r--r--src/imports/controls/ScrollIndicator.qml84
-rw-r--r--src/imports/controls/Slider.qml104
-rw-r--r--src/imports/controls/SpinBox.qml132
-rw-r--r--src/imports/controls/StackView.js63
-rw-r--r--src/imports/controls/StackView.qml954
-rw-r--r--src/imports/controls/StackViewDelegate.qml142
-rw-r--r--src/imports/controls/StackViewTransition.qml56
-rw-r--r--src/imports/controls/Switch.qml111
-rw-r--r--src/imports/controls/TabBar.qml120
-rw-r--r--src/imports/controls/TabButton.qml75
-rw-r--r--src/imports/controls/TabView.qml96
-rw-r--r--src/imports/controls/TextArea.qml78
-rw-r--r--src/imports/controls/TextField.qml90
-rw-r--r--src/imports/controls/ToggleButton.qml110
-rw-r--r--src/imports/controls/ToolBar.qml67
-rw-r--r--src/imports/controls/ToolButton.qml76
-rw-r--r--src/imports/controls/controls.pro47
-rw-r--r--src/imports/controls/images/spinner_large.pngbin0 -> 15085 bytes
-rw-r--r--src/imports/controls/images/spinner_medium.pngbin0 -> 5934 bytes
-rw-r--r--src/imports/controls/images/spinner_small.pngbin0 -> 4582 bytes
-rw-r--r--src/imports/controls/qmldir29
-rw-r--r--src/imports/controls/qtquickcontrols2plugin.cpp128
-rw-r--r--src/imports/controls/qtquickcontrols2plugin.qrc7
-rw-r--r--src/imports/extras/Drawer.qml56
-rw-r--r--src/imports/extras/SplitView.qml556
-rw-r--r--src/imports/extras/extras.pro19
-rw-r--r--src/imports/extras/qmldir5
-rw-r--r--src/imports/extras/qtquickextras2plugin.cpp61
-rw-r--r--src/imports/imports.pro5
47 files changed, 4544 insertions, 0 deletions
diff --git a/src/imports/calendar/CalendarDelegate.qml b/src/imports/calendar/CalendarDelegate.qml
new file mode 100644
index 00000000..a6b000b7
--- /dev/null
+++ b/src/imports/calendar/CalendarDelegate.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Calendar 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$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Controls 2.0
+import QtQuick.Calendar 2.0
+
+Item {
+ property alias text: label.text
+ property alias color: label.color
+ property real padding
+
+ implicitWidth: label.implicitWidth * 3
+ implicitHeight: label.implicitHeight * 3
+
+ Text {
+ id: label
+ x: padding
+ y: padding
+ width: parent.width - 2 * padding
+ height: parent.height - 2 * padding
+ minimumPointSize: 8
+ fontSizeMode: Text.Fit
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+}
diff --git a/src/imports/calendar/CalendarView.qml b/src/imports/calendar/CalendarView.qml
new file mode 100644
index 00000000..ce6e9908
--- /dev/null
+++ b/src/imports/calendar/CalendarView.qml
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Calendar 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$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Controls 2.0
+import QtQuick.Calendar 2.0
+
+AbstractCalendarView {
+ id: control
+
+ property Component delegate: CalendarDelegate {
+ width: grid.width ? grid.width / 7 : implicitWidth
+ height: grid.height ? grid.height / 6 : implicitHeight
+ opacity: model.month === control.month ? 1 : 0
+ color: model.today ? style.accentColor : style.textColor
+ text: model.day
+ padding: style.padding
+ }
+
+ contentWidth: grid.implicitWidth
+ contentHeight: grid.implicitHeight
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + padding.left + padding.right)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + padding.top + padding.bottom)
+
+ Accessible.name: title
+
+ contentItem: Grid {
+ id: grid
+
+ rows: 6
+ columns: 7
+
+ x: padding.left
+ y: padding.top
+ width: parent.width - padding.left - padding.right
+ height: parent.height - padding.top - padding.bottom
+
+ Repeater {
+ id: repeater
+ model: control.source
+ delegate: control.delegate
+ }
+ }
+}
diff --git a/src/imports/calendar/DayOfWeekRow.qml b/src/imports/calendar/DayOfWeekRow.qml
new file mode 100644
index 00000000..5a33b5ee
--- /dev/null
+++ b/src/imports/calendar/DayOfWeekRow.qml
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Calendar 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$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Controls 2.0
+import QtQuick.Calendar 2.0
+
+AbstractDayOfWeekRow {
+ id: control
+
+ property Component delegate: Text {
+ text: model.shortName
+ font.bold: true
+ color: control.style.textColor
+ width: row.width ? row.width / 7 : implicitWidth
+ height: row.height ? row.height : implicitHeight
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+
+ contentWidth: row.implicitWidth
+ contentHeight: row.implicitHeight
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + padding.left + padding.right)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + padding.top + padding.bottom)
+
+ padding { top: style.padding; bottom: style.padding }
+
+ contentItem: Row {
+ id: row
+
+ x: padding.left
+ y: padding.top
+ width: parent.width - padding.left - padding.right
+ height: parent.height - padding.top - padding.bottom
+
+ Repeater {
+ model: control.source
+ delegate: control.delegate
+ }
+ }
+}
diff --git a/src/imports/calendar/WeekNumberColumn.qml b/src/imports/calendar/WeekNumberColumn.qml
new file mode 100644
index 00000000..e2d1f63c
--- /dev/null
+++ b/src/imports/calendar/WeekNumberColumn.qml
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Calendar 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$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Controls 2.0
+import QtQuick.Calendar 2.0
+
+AbstractWeekNumberColumn {
+ id: control
+
+ property Component delegate: Text {
+ text: model.weekNumber
+ font.bold: true
+ color: control.style.textColor
+ width: column.width ? column.width : implicitWidth
+ height: column.height ? column.height / 6 : implicitHeight
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+
+ contentWidth: column.implicitWidth
+ contentHeight: column.implicitHeight
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + padding.left + padding.right)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + padding.top + padding.bottom)
+
+ padding { left: style.padding; right: style.padding }
+
+ contentItem: Column {
+ id: column
+
+ x: padding.left
+ y: padding.top
+ width: parent.width - padding.left - padding.right
+ height: parent.height - padding.top - padding.bottom
+
+ Repeater {
+ model: control.source
+ delegate: control.delegate
+ }
+ }
+}
diff --git a/src/imports/calendar/calendar.pro b/src/imports/calendar/calendar.pro
new file mode 100644
index 00000000..625be272
--- /dev/null
+++ b/src/imports/calendar/calendar.pro
@@ -0,0 +1,21 @@
+TARGET = qtquickcalendar2plugin
+TARGETPATH = QtQuick/Calendar.2
+IMPORT_VERSION = 2.0
+
+QT += qml quick
+QT += core-private gui-private qml-private quick-private quickcontrols-private quickcalendar-private
+
+OTHER_FILES += \
+ qmldir
+
+QML_FILES = \
+ CalendarDelegate.qml \
+ CalendarView.qml \
+ DayOfWeekRow.qml \
+ WeekNumberColumn.qml
+
+SOURCES += \
+ $$PWD/qtquickcalendar2plugin.cpp
+
+CONFIG += no_cxx_module
+load(qml_plugin)
diff --git a/src/imports/calendar/qmldir b/src/imports/calendar/qmldir
new file mode 100644
index 00000000..af87241f
--- /dev/null
+++ b/src/imports/calendar/qmldir
@@ -0,0 +1,7 @@
+module QtQuick.Calendar
+plugin qtquickcalendar2plugin
+classname QtQuickCalendar2Plugin
+CalendarDelegate 2.0 CalendarDelegate.qml
+CalendarView 2.0 CalendarView.qml
+DayOfWeekRow 2.0 DayOfWeekRow.qml
+WeekNumberColumn 2.0 WeekNumberColumn.qml
diff --git a/src/imports/calendar/qtquickcalendar2plugin.cpp b/src/imports/calendar/qtquickcalendar2plugin.cpp
new file mode 100644
index 00000000..8e84e094
--- /dev/null
+++ b/src/imports/calendar/qtquickcalendar2plugin.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Calendar 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 <QtQml/qqmlextensionplugin.h>
+
+#include <QtQuickCalendar/private/qquickabstractcalendarview_p.h>
+#include <QtQuickCalendar/private/qquickabstractdayofweekrow_p.h>
+#include <QtQuickCalendar/private/qquickabstractweeknumbercolumn_p.h>
+#include <QtQuickCalendar/private/qquickcalendarmodel_p.h>
+#include <QtQuickCalendar/private/qquickdayofweekmodel_p.h>
+#include <QtQuickCalendar/private/qquickmonthmodel_p.h>
+#include <QtQuickCalendar/private/qquickweeknumbermodel_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QtQuickCalendar2Plugin: public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0")
+
+public:
+ void registerTypes(const char *uri);
+};
+
+void QtQuickCalendar2Plugin::registerTypes(const char *uri)
+{
+ qmlRegisterType<QQuickAbstractCalendarView>(uri, 2, 0, "AbstractCalendarView");
+ qmlRegisterType<QQuickAbstractDayOfWeekRow>(uri, 2, 0, "AbstractDayOfWeekRow");
+ qmlRegisterType<QQuickAbstractWeekNumberColumn>(uri, 2, 0, "AbstractWeekNumberColumn");
+ qmlRegisterType<QQuickCalendarModel>(uri, 2, 0, "CalendarModel");
+ qmlRegisterType<QQuickDayOfWeekModel>(uri, 2, 0, "DayOfWeekModel");
+ qmlRegisterType<QQuickMonthModel>(uri, 2, 0, "MonthModel");
+ qmlRegisterType<QQuickWeekNumberModel>(uri, 2, 0, "WeekNumberModel");
+}
+
+QT_END_NAMESPACE
+
+#include "qtquickcalendar2plugin.moc"
diff --git a/src/imports/controls/ApplicationWindow.qml b/src/imports/controls/ApplicationWindow.qml
new file mode 100644
index 00000000..036630e4
--- /dev/null
+++ b/src/imports/controls/ApplicationWindow.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick 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$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Window 2.2
+import QtQuick.Controls 2.0
+
+AbstractApplicationWindow {
+ id: window
+
+ color: style.backgroundColor
+ flags: Qt.Window | Qt.WindowFullscreenButtonHint
+
+ contentWidth: contentItem.children.length === 1 ? contentItem.children[0].implicitWidth : 0
+ contentHeight: contentItem.children.length === 1 ? contentItem.children[0].implicitHeight : 0
+
+ minimumWidth: Math.max(contentWidth,
+ (header ? header.implicitWidth : 0),
+ (footer ? footer.implicitWidth : 0))
+ minimumHeight: contentHeight + (header ? header.implicitHeight : 0)
+ + (footer ? footer.implicitHeight : 0)
+}
diff --git a/src/imports/controls/BusyIndicator.qml b/src/imports/controls/BusyIndicator.qml
new file mode 100644
index 00000000..09abd9dc
--- /dev/null
+++ b/src/imports/controls/BusyIndicator.qml
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick 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$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Controls 2.0
+
+AbstractBusyIndicator {
+ id: control
+
+ implicitWidth: indicator.implicitWidth + padding.left + padding.right
+ implicitHeight: indicator.implicitHeight + padding.top + padding.bottom
+
+ Accessible.role: Accessible.Indicator
+
+ padding { top: style.padding; left: style.padding; right: style.padding; bottom: style.padding }
+
+ indicator: Item {
+ id: delegate
+ implicitWidth: 48
+ implicitHeight: 48
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+ width: parent.width
+ height: parent.height
+
+ opacity: control.running ? 1 : 0
+ Behavior on opacity { OpacityAnimator { duration: 250 } }
+
+ Image {
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+ width: Math.min(parent.width, parent.height)
+ height: width
+ source: width <= 32 ? "qrc:/images/spinner_small.png" :
+ width >= 48 ? "qrc:/images/spinner_large.png" :
+ "qrc:/images/spinner_medium.png"
+
+ RotationAnimator on rotation {
+ duration: 800
+ loops: Animation.Infinite
+ from: 0
+ to: 360
+ running: control.visible && (control.running || delegate.opacity > 0)
+ }
+ }
+ }
+}
diff --git a/src/imports/controls/Button.qml b/src/imports/controls/Button.qml
new file mode 100644
index 00000000..8ec7065b
--- /dev/null
+++ b/src/imports/controls/Button.qml
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick 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$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Controls 2.0
+
+AbstractButton {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ label ? label.implicitWidth + padding.left + padding.right : 0)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ label ? label.implicitHeight + padding.top + padding.bottom : 0)
+
+ Accessible.name: text
+ Accessible.pressed: pressed
+ Accessible.role: Accessible.Button
+
+ padding { top: style.padding; left: style.padding; right: style.padding; bottom: style.padding }
+
+ label: Text {
+ x: padding.left
+ y: padding.top
+ width: parent.width - padding.left - padding.right
+ height: parent.height - padding.top - padding.bottom
+
+ text: control.text
+ color: control.style.selectedTextColor
+ elide: Text.ElideRight
+ opacity: enabled ? 1.0 : control.style.disabledOpacity
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+
+ background: Rectangle {
+ implicitWidth: 26
+ implicitHeight: 26
+
+ radius: style.roundness
+ opacity: control.enabled ? 1.0 : style.disabledOpacity
+ color: Qt.tint(Qt.tint(style.accentColor,
+ control.activeFocus ? style.focusColor : "transparent"),
+ control.pressed ? style.pressColor : "transparent")
+ }
+}
diff --git a/src/imports/controls/CheckBox.qml b/src/imports/controls/CheckBox.qml
new file mode 100644
index 00000000..6bc8f473
--- /dev/null
+++ b/src/imports/controls/CheckBox.qml
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick 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$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Controls 2.0
+
+AbstractCheckBox {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ (label ? label.implicitWidth : 0) +
+ (indicator ? indicator.implicitWidth : 0) +
+ (label && indicator ? style.spacing : 0) + padding.left + padding.right)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ Math.max(label ? label.implicitHeight : 0,
+ indicator ? indicator.implicitHeight : 0) + padding.top + padding.bottom)
+
+ Accessible.name: text
+ Accessible.checked: checked
+ Accessible.pressed: pressed
+ Accessible.role: Accessible.CheckBox
+
+ padding { top: style.padding; left: style.padding; right: style.padding; bottom: style.padding }
+
+ indicator: Rectangle {
+ readonly property bool mirror: control.effectiveLayoutDirection == Qt.RightToLeft
+
+ implicitWidth: 20
+ implicitHeight: 20
+ x: text ? (mirror ? parent.width - width - padding.right : padding.left) : (parent.width - width) / 2
+ y: (parent.height - height) / 2
+
+ radius: style.roundness
+ border.width: control.activeFocus ? 2 : 1
+ border.color: control.activeFocus ? style.focusColor : style.frameColor
+ opacity: enabled ? 1.0 : style.disabledOpacity
+ color: style.backgroundColor
+
+ Rectangle {
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+ width: 12
+ height: 12
+ color: Qt.tint(Qt.tint(control.checked ? style.accentColor : style.baseColor,
+ control.checked && control.activeFocus ? style.focusColor : "transparent"),
+ control.pressed ? style.pressColor : "transparent")
+ border.width: control.checked || control.pressed ? 0 : 1
+ border.color: style.frameColor
+ }
+ }
+
+ label: Text {
+ readonly property bool mirror: control.effectiveLayoutDirection == Qt.RightToLeft
+
+ x: mirror ? padding.left : (indicator.x + indicator.width + control.style.spacing)
+ y: padding.top
+ width: parent.width - indicator.width - control.style.spacing - padding.left - padding.right
+ height: parent.height - padding.top - padding.bottom
+
+ text: control.text
+ color: control.style.textColor
+ elide: Text.ElideRight
+ visible: control.text
+ opacity: enabled ? 1.0 : control.style.disabledOpacity
+ horizontalAlignment: Text.AlignLeft
+ verticalAlignment: Text.AlignVCenter
+ }
+}
diff --git a/src/imports/controls/Frame.qml b/src/imports/controls/Frame.qml
new file mode 100644
index 00000000..62582263
--- /dev/null
+++ b/src/imports/controls/Frame.qml
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick 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$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Controls 2.0
+
+AbstractFrame {
+ id: control
+
+ default property alias data: content.data
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ contentWidth + padding.left + padding.right)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ contentHeight + padding.top + padding.bottom)
+
+ contentWidth: content.children.length === 1 ? content.children[0].implicitWidth : 0
+ contentHeight: content.children.length === 1 ? content.children[0].implicitHeight : 0
+
+ padding { top: style.padding; left: style.padding; right: style.padding; bottom: style.padding }
+
+ contentItem: Item {
+ id: content
+ x: padding.left
+ y: padding.top
+ width: parent.width - padding.left - padding.right
+ height: parent.height - padding.top - padding.bottom
+ }
+
+ background: Rectangle {
+ color: "transparent"
+ radius: style.roundness
+ border.color: style.frameColor
+ }
+}
diff --git a/src/imports/controls/GroupBox.qml b/src/imports/controls/GroupBox.qml
new file mode 100644
index 00000000..39e45adb
--- /dev/null
+++ b/src/imports/controls/GroupBox.qml
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick 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$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Controls 2.0
+
+AbstractGroupBox {
+ id: control
+
+ default property alias data: content.data
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ contentWidth + padding.left + padding.right)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ contentHeight + padding.top + padding.bottom)
+
+ contentWidth: content.children.length === 1 ? content.children[0].implicitWidth : 0
+ contentHeight: content.children.length === 1 ? content.children[0].implicitHeight : 0
+
+ padding {
+ top: style.padding + (label && title ? label.implicitHeight + style.spacing : 0)
+ left: style.padding
+ right: style.padding
+ bottom: style.padding
+ }
+
+ contentItem: Item {
+ id: content
+ x: padding.left
+ y: padding.top
+ width: parent.width - padding.left - padding.right
+ height: parent.height - padding.top - padding.bottom
+ }
+
+ label: Text {
+ x: padding.left
+ width: parent.width - padding.left - padding.right
+
+ text: control.title
+ color: control.style.textColor
+ elide: Text.ElideRight
+ opacity: enabled ? 1.0 : control.style.disabledOpacity
+ horizontalAlignment: Text.AlignLeft
+ verticalAlignment: Text.AlignVCenter
+ }
+
+ frame: Rectangle {
+ y: padding.top - style.padding
+ width: parent.width
+ height: parent.height - padding.top + style.padding
+
+ color: "transparent"
+ radius: style.roundness
+ border.color: style.frameColor
+ }
+}
diff --git a/src/imports/controls/Label.qml b/src/imports/controls/Label.qml
new file mode 100644
index 00000000..872cb978
--- /dev/null
+++ b/src/imports/controls/Label.qml
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick 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$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Controls 2.0
+
+Text {
+ id: control
+
+ // TODO: color: style.textColor
+
+ Accessible.name: text
+ Accessible.role: Accessible.StaticText
+}
diff --git a/src/imports/controls/PageIndicator.qml b/src/imports/controls/PageIndicator.qml
new file mode 100644
index 00000000..db6dbdde
--- /dev/null
+++ b/src/imports/controls/PageIndicator.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick 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$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Controls 2.0
+
+AbstractPageIndicator {
+ id: control
+
+ property alias spacing: row.spacing
+
+ property Component delegate: Rectangle {
+ implicitWidth: 8
+ implicitHeight: 8
+
+ radius: width / 2
+ color: style.shadowColor // TODO
+
+ opacity: index === currentIndex ? 0.75 : 0.25
+ Behavior on opacity { OpacityAnimator { duration: 100 } }
+ }
+
+ Accessible.role: Accessible.Indicator
+
+ contentWidth: row.implicitWidth
+ contentHeight: row.implicitHeight
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + padding.left + padding.right)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + padding.top + padding.bottom)
+
+ padding { top: style.padding; left: style.padding; right: style.padding; bottom: style.padding }
+
+ contentItem: Row {
+ id: row
+
+ x: padding.left
+ y: padding.top
+ width: parent.width - padding.left - padding.right
+ height: parent.height - padding.top - padding.bottom
+
+ spacing: style.spacing
+
+ Repeater {
+ model: control.count
+ delegate: control.delegate
+ }
+ }
+}
diff --git a/src/imports/controls/ProgressBar.qml b/src/imports/controls/ProgressBar.qml
new file mode 100644
index 00000000..8e6342ee
--- /dev/null
+++ b/src/imports/controls/ProgressBar.qml
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick 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$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Controls 2.0
+
+AbstractProgressBar {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ indicator ? indicator.implicitWidth : 0) + padding.left + padding.right
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ indicator ? indicator.implicitHeight : 0) + padding.top + padding.bottom
+
+ Accessible.role: Accessible.ProgressBar
+
+ padding { top: style.padding; left: style.padding; right: style.padding; bottom: style.padding }
+
+ indicator: Item {
+ x: padding.left
+ y: padding.top
+ width: parent.width - padding.left - padding.right
+ height: parent.height - padding.top - padding.bottom
+ scale: control.effectiveLayoutDirection === Qt.RightToLeft ? -1 : 1
+
+ Repeater {
+ model: indeterminate ? 2 : 1
+
+ Rectangle {
+ property real offset: indeterminate ? 0 : control.value
+
+ x: 2 + (indeterminate ? offset * parent.width - 4 : 0)
+ y: (parent.height - height) / 2
+ width: offset * (parent.width - x) - 2
+ height: 2
+
+ color: style.accentColor
+ radius: style.roundness
+
+ SequentialAnimation on offset {
+ loops: Animation.Infinite
+ running: indeterminate && visible
+ PauseAnimation { duration: index ? 520 : 0 }
+ NumberAnimation {
+ easing.type: Easing.OutCubic
+ duration: 1240
+ from: 0
+ to: 1
+ }
+ PauseAnimation { duration: index ? 0 : 520 }
+ }
+ }
+ }
+ }
+
+ background: Rectangle {
+ implicitWidth: 120
+ implicitHeight: 6
+ x: padding.left
+ y: (parent.height - height) / 2
+ width: parent.width - padding.left - padding.bottom
+ height: 6
+
+ radius: style.roundness
+ border.color: style.frameColor
+ color: "transparent"
+ }
+}
diff --git a/src/imports/controls/RadioButton.qml b/src/imports/controls/RadioButton.qml
new file mode 100644
index 00000000..919ab947
--- /dev/null
+++ b/src/imports/controls/RadioButton.qml
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick 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$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Controls 2.0
+
+AbstractRadioButton {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ (label ? label.implicitWidth : 0) +
+ (indicator ? indicator.implicitWidth : 0) +
+ (label && indicator ? style.spacing : 0) + padding.left + padding.right)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ Math.max(label ? label.implicitHeight : 0,
+ indicator ? indicator.implicitHeight : 0) + padding.top + padding.bottom)
+
+ Accessible.name: text
+ Accessible.checked: checked
+ Accessible.pressed: pressed
+ Accessible.role: Accessible.RadioButton
+
+ padding { top: style.padding; left: style.padding; right: style.padding; bottom: style.padding }
+
+ indicator: Rectangle {
+ readonly property bool mirror: control.effectiveLayoutDirection == Qt.RightToLeft
+
+ implicitWidth: 20
+ implicitHeight: 20
+ x: text ? (mirror ? parent.width - width - padding.right : padding.left) : (parent.width - width) / 2
+ y: (parent.height - height) / 2
+
+ radius: width / 2
+ border.width: control.activeFocus ? 2 : 1
+ border.color: control.activeFocus ? style.focusColor : style.frameColor
+ opacity: enabled ? 1.0 : style.disabledOpacity
+ color: style.backgroundColor
+
+ Rectangle {
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+ width: 12
+ height: 12
+ radius: width / 2
+ color: Qt.tint(Qt.tint(control.checked ? style.accentColor : style.baseColor,
+ control.checked && control.activeFocus ? style.focusColor : "transparent"),
+ control.pressed ? style.pressColor : "transparent")
+ border.width: control.checked || control.pressed ? 0 : 1
+ border.color: style.frameColor
+ }
+ }
+
+ label: Text {
+ readonly property bool mirror: control.effectiveLayoutDirection == Qt.RightToLeft
+
+ x: mirror ? padding.left : (indicator.x + indicator.width + control.style.spacing)
+ y: padding.top
+ width: parent.width - indicator.width - control.style.spacing - padding.left - padding.right
+ height: parent.height - padding.top - padding.bottom
+
+ text: control.text
+ color: control.style.textColor
+ elide: Text.ElideRight
+ visible: control.text
+ opacity: enabled ? 1.0 : control.style.disabledOpacity
+ horizontalAlignment: Text.AlignLeft
+ verticalAlignment: Text.AlignVCenter
+ }
+}
diff --git a/src/imports/controls/ScrollBar.qml b/src/imports/controls/ScrollBar.qml
new file mode 100644
index 00000000..83e8ac6b
--- /dev/null
+++ b/src/imports/controls/ScrollBar.qml
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick 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$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Controls 2.0
+
+AbstractScrollBar {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ handle.implicitWidth + padding.left + padding.right)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ handle.implicitHeight + padding.top + padding.bottom)
+
+ Accessible.pressed: pressed
+ Accessible.role: Accessible.ScrollBar
+
+ padding { top: 2; left: 2; right: 2; bottom: 2 }
+
+ handle: Rectangle {
+ id: handle
+
+ implicitWidth: 6
+ implicitHeight: 6
+
+ radius: width / 2
+ color: control.pressed ? style.shadowColor : style.frameColor
+ visible: control.size < 1.0
+ opacity: 0.0
+
+ readonly property bool horizontal: control.orientation === Qt.Horizontal
+ x: padding.left + (horizontal ? control.position * control.width : 0)
+ y: padding.top + (horizontal ? 0 : control.position * control.height)
+ width: horizontal ? control.size * control.width - padding.left - padding.right : implicitWidth
+ height: horizontal ? implicitHeight : control.size * control.height - padding.top - padding.bottom
+
+ states: State {
+ name: "active"
+ when: control.active
+ PropertyChanges { target: handle; opacity: 1.0 - style.disabledOpacity }
+ }
+
+ transitions: Transition {
+ from: "active"
+ SequentialAnimation {
+ PauseAnimation { duration: 450 }
+ NumberAnimation { target: handle; duration: 200; property: "opacity"; to: 0.0 }
+ }
+ }
+ }
+}
diff --git a/src/imports/controls/ScrollIndicator.qml b/src/imports/controls/ScrollIndicator.qml
new file mode 100644
index 00000000..7a4bbba6
--- /dev/null
+++ b/src/imports/controls/ScrollIndicator.qml
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick 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$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Controls 2.0
+
+AbstractScrollIndicator {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ indicator.implicitWidth + padding.left + padding.right)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ indicator.implicitHeight + padding.top + padding.bottom)
+
+ Accessible.role: Accessible.Indicator
+
+ padding { top: 2; left: 2; right: 2; bottom: 2 }
+
+ indicator: Rectangle {
+ id: indicator
+
+ implicitWidth: 2
+ implicitHeight: 2
+
+ color: style.frameColor
+ visible: control.size < 1.0
+ opacity: 0.0
+
+ readonly property bool horizontal: control.orientation === Qt.Horizontal
+ x: padding.left + (horizontal ? control.position * control.width : 0)
+ y: padding.top + (horizontal ? 0 : control.position * control.height)
+ width: horizontal ? control.size * control.width - padding.left - padding.right : implicitWidth
+ height: horizontal ? implicitHeight : control.size * control.height - padding.top - padding.bottom
+
+ states: State {
+ name: "active"
+ when: control.active
+ PropertyChanges { target: indicator; opacity: 1.0 - style.disabledOpacity }
+ }
+
+ transitions: [
+ Transition {
+ from: "active"
+ SequentialAnimation {
+ PauseAnimation { duration: 450 }
+ NumberAnimation { target: indicator; duration: 200; property: "opacity"; to: 0.0 }
+ }
+ }
+ ]
+ }
+}
diff --git a/src/imports/controls/Slider.qml b/src/imports/controls/Slider.qml
new file mode 100644
index 00000000..fc6abc60
--- /dev/null
+++ b/src/imports/controls/Slider.qml
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick 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$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Controls 2.0
+
+AbstractSlider {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ Math.max(track ? track.implicitWidth : 0,
+ handle ? handle.implicitWidth : 0) + padding.left + padding.right)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ Math.max(track ? track.implicitHeight : 0,
+ handle ? handle.implicitHeight : 0) + padding.top + padding.bottom)
+
+ Accessible.pressed: pressed
+ Accessible.role: Accessible.Slider
+
+ padding { top: style.padding; left: style.padding; right: style.padding; bottom: style.padding }
+
+ handle: Rectangle {
+ implicitWidth: 20
+ implicitHeight: 20
+ radius: width / 2
+ border.width: control.activeFocus ? 2 : 1
+ border.color: control.activeFocus ? style.focusColor : style.frameColor
+ color: style.backgroundColor
+
+ readonly property bool horizontal: control.orientation === Qt.Horizontal
+ x: horizontal ? control.visualPosition * (control.width - width) : (control.width - width) / 2
+ y: horizontal ? (control.height - height) / 2 : control.visualPosition * (control.height - height)
+
+ Rectangle {
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+ width: 12
+ height: 12
+ radius: width / 2
+
+ color: Qt.tint(Qt.tint(style.accentColor,
+ control.activeFocus ? style.focusColor : "transparent"),
+ control.pressed ? style.pressColor : "transparent")
+ }
+ }
+
+ track: Rectangle {
+ readonly property bool horizontal: control.orientation === Qt.Horizontal
+ implicitWidth: horizontal ? 120 : 6
+ implicitHeight: horizontal ? 6 : 120
+ x: horizontal ? padding.left : (control.width - width) / 2
+ y: horizontal ? (control.height - height) / 2 : padding.top
+ width: horizontal ? parent.width - padding.left - padding.right : implicitWidth
+ height: horizontal ? implicitHeight : parent.height - padding.top - padding.bottom
+
+ radius: style.roundness
+ border.color: style.frameColor
+ color: style.backgroundColor
+ scale: control.effectiveLayoutDirection === Qt.RightToLeft ? -1 : 1
+
+ Rectangle {
+ x: 2
+ y: 2
+ width: control.position * parent.width - 4
+ height: 2
+
+ color: style.accentColor
+ radius: style.roundness
+ }
+ }
+}
diff --git a/src/imports/controls/SpinBox.qml b/src/imports/controls/SpinBox.qml
new file mode 100644
index 00000000..cf11cfdb
--- /dev/null
+++ b/src/imports/controls/SpinBox.qml
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick 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$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Controls 2.0
+
+AbstractSpinBox {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ (upButton ? upButton.implicitWidth : 0) +
+ (downButton ? downButton.implicitWidth : 0) +
+ (input ? input.implicitWidth : 0) + style.padding * 2)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ (upButton ? upButton.implicitHeight : 0),
+ (downButton ? downButton.implicitHeight : 0),
+ (input ? input.implicitHeight : 0) + style.padding * 2)
+
+ Accessible.role: Accessible.SpinBox
+
+ input: TextInput {
+ x: upButton.width
+ width: parent.width - upButton.width - downButton.width
+ height: parent.height
+
+ color: style.textColor
+ selectionColor: style.selectionColor
+ selectedTextColor: style.selectedTextColor
+ horizontalAlignment: Qt.AlignHCenter
+ verticalAlignment: Qt.AlignVCenter
+ Keys.forwardTo: control
+ }
+
+ validator: IntValidator { }
+
+ upButton: Item {
+ implicitWidth: 26
+ height: parent.height
+ x: parent.width - width
+
+ opacity: enabled ? 1.0 : style.disabledOpacity
+ clip: true
+ Rectangle {
+ x: -radius
+ width: parent.width + radius
+ height: parent.height
+ radius: style.roundness
+ color: Qt.tint(Qt.tint(style.accentColor,
+ control.activeFocus ? style.focusColor : "transparent"),
+ pressed === AbstractSpinBox.UpButton ? style.pressColor : "transparent")
+ }
+ Rectangle {
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+ width: parent.width / 3
+ height: 2
+ color: control.style.selectedTextColor
+ }
+ Rectangle {
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+ width: 2
+ height: parent.height / 3
+ color: control.style.selectedTextColor
+ }
+ }
+
+ downButton: Item {
+ implicitWidth: 26
+ height: parent.height
+
+ opacity: enabled ? 1.0 : style.disabledOpacity
+ clip: true
+ Rectangle {
+ width: parent.width + radius
+ height: parent.height
+ radius: style.roundness
+ color: Qt.tint(Qt.tint(style.accentColor,
+ control.activeFocus ? style.focusColor : "transparent"),
+ pressed === AbstractSpinBox.DownButton ? style.pressColor : "transparent")
+ }
+ Rectangle {
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+ width: parent.width / 3
+ height: 2
+ color: control.style.selectedTextColor
+ }
+ }
+
+ background: Rectangle {
+ implicitWidth: 120
+ radius: style.roundness
+ border.width: control.activeFocus ? 2 : 1
+ border.color: control.activeFocus ? style.focusColor : style.frameColor
+ opacity: enabled ? 1.0 : style.disabledOpacity
+ color: input.acceptableInput ? "white" : "lightpink"
+ }
+}
diff --git a/src/imports/controls/StackView.js b/src/imports/controls/StackView.js
new file mode 100644
index 00000000..37e2066d
--- /dev/null
+++ b/src/imports/controls/StackView.js
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick 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$
+**
+****************************************************************************/
+
+var stackView = [];
+
+function push(p)
+{
+ if (!p)
+ return
+ stackView.push(p)
+ __depth++
+ return p
+}
+
+function pop()
+{
+ if (stackView.length === 0)
+ return null
+ var p = stackView.pop()
+ __depth--
+ return p
+}
+
+function current()
+{
+ if (stackView.length === 0)
+ return null
+ return stackView[stackView.length-1]
+}
+
diff --git a/src/imports/controls/StackView.qml b/src/imports/controls/StackView.qml
new file mode 100644
index 00000000..2c75f063
--- /dev/null
+++ b/src/imports/controls/StackView.qml
@@ -0,0 +1,954 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick 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$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtQuick.Controls 2.0
+import "StackView.js" as JSArray
+
+/*!
+ \qmltype StackView
+ \inherits Item
+ \ingroup views
+ \inqmlmodule QtQuick.Controls
+ \since 5.1
+
+ \brief Provides a stack-based navigation model.
+
+ \image stackview.png
+
+ StackView implements a stack-based navigation model, which can be used
+ with a set of interlinked information pages. Items are pushed onto the stack
+ as the user navigates deeper into the material, and popped off again when he
+ chooses to go back.
+
+ The \l{Qt Quick Controls - Touch Gallery}{touch gallery} example is a good
+ starting point to understand how StackView works. The following snippet
+ from the example shows how it can be used:
+
+ \qml
+ StackView {
+ id: stack
+ initialItem: view
+
+ Component {
+ id: view
+
+ MouseArea {
+ Text {
+ text: stack.depth
+ anchors.centerIn: parent
+ }
+ onClicked: stack.push(view)
+ }
+ }
+ }
+ \endqml
+
+ \section1 Using StackView in an Application
+ Using the StackView in the application is typically a simple matter of adding
+ the StackView as a child of a Window. The stack is usually anchored to the
+ edges of the window, except at the top or bottom where it might be anchored
+ to a status bar, or some other similar UI component. The stack can then be
+ used by invoking its navigation methods. The first item to show in the StackView
+ is commonly loaded assigning it to \l initialItem.
+
+ \note Items pushed onto the stack view have \l{Supported Attached Properties}{Stack attached properties}.
+
+ \section1 Basic Navigation
+ There are three primary navigation operations in StackView: push(), pop(), and
+ replace (replace by specifying argument \c replace to push()).
+ These correspond to classic stack operations where "push" adds an item to the
+ top of a stack, "pop" removes the top item from the stack, and "replace" is like a
+ pop followed by a push in that it replaces the topmost item on the stack with
+ a new item (but the applied transtition might be different). The topmost item
+ in the stack corresponds to the one that is \l{StackView::currentItem} {currently}
+ visible on the screen. That means that "push" is the logical equivalent of navigating
+ forward or deeper into the application, "pop" is the equivalent of navigating back,
+ and "replace" is the equivalent of replacing the current item.
+
+ Sometimes it is necessary to go back more than a single step in the stack, for
+ example, to return to a "main" item or some kind of section item in the application.
+ For this use case, it is possible to specify an item as a parameter for pop().
+ This is called an "unwind" operation as the stack gets unwound to the specified item.
+ If the item is not found then the stack unwinds until there is only a single item in
+ the stack, which becomes the current item. To explicitly unwind to the bottom
+ of the stack it is recommended to use \l{pop()} {pop(null)}, though technically any
+ non-existent item will do.
+
+ Given the stack [A, B, C]:
+
+ \list
+ \li \l{push()}{push(D)} => [A, B, C, D] - "push" transition animation between C and D
+ \li pop() => [A, B] - "pop" transition animation between C and B
+ \li \l{push()}{push(D, replace)} => [A, B, D] - "replace" transition between C and D
+ \li \l{pop()}{pop(A)} => [A] - "pop" transition between C and A
+ \endlist
+
+ \note Note that when the stack is empty, a push() will not perform a
+ transition animation because there is nothing to transition from (typically during
+ application start-up). A pop() on a stack with depth 1 or 0 is a no-operation.
+ If removing all items from the stack is needed, a separate function clear() is
+ available.
+
+ Calling push() returns the item that was pushed onto the stack.
+ Calling pop() returns the item that was popped off the stack. When pop() is
+ called in an unwind operation the top-most item (the first item that was
+ popped, which will also be the one transitioning out) is returned.
+
+ \section1 Deep Linking
+ \e{Deep linking} means launching an application into a particular state. For example,
+ a newspaper application could be launched into showing a particular article,
+ bypassing the front item (and possibly a section item) that would normally have
+ to be navigated through to get to the article concerned. In terms of StackView, deep
+ linking means the ability to modify the state of the stack, so much so that it is
+ possible to push a set of items to the top of the stack, or to completely reset
+ the stack to a given state.
+
+ The API for deep linking in StackView is the same as for basic navigation. Pushing
+ an array instead of a single item, will involve that all the items in that array will
+ be pushed onto the stack. The transition animation, however, will be conducted as
+ if only the last item in the array was pushed onto the stack. The normal semantics
+ of push() apply for deep linking, meaning that push() adds whatever is pushed onto
+ the stack. Note also that only the last item of the array will be loaded.
+ The rest will be lazy-loaded as needed when entering the screen upon subsequent
+ calls to pop (or when requesting the item by using \a get).
+
+ This gives us the following result, given the stack [A, B, C]:
+
+ \list
+ \li \l{push()}{push([D, E, F])} => [A, B, C, D, E, F] - "push" transition animation between C and F
+ \li \l{push()}{push([D, E, F], replace)} => [A, B, D, E, F] - "replace" transition animation between C and F
+ \li clear(); \l{push()}{push([D, E, F])} => [D, E, F] - no transition animation (since the stack was empty)
+ \endlist
+
+ \section1 Pushing items
+
+ An item pushed onto the StackView can be either an Item, a URL, a string
+ with a URL, or a Component. To push it, assign it to a property "item"
+ inside a property list, and send it as an argument to \l{StackView::push}{push}:
+
+ \code
+ stackView.push({item: yourItem})
+ \endcode
+
+ The list can contain several properties that control how the item should be pushed:
+ \list
+ \li \c item: this property is required, and holds the item to be pushed.
+ \li \c properties: a list of QML properties to be assigned to the item upon push. These
+ properties will be copied into the item at load time, or when the item will become
+ the current item (normally upon push).
+ \li \c immediate: set this property to \c true to skip transition effects. When pushing
+ an array, this property only needs to be set on the first element to make the
+ whole operation immediate.
+ \li \c replace: set this property to replace the current item on the stack. When pushing
+ an array, you only need to set this property on the first element to replace
+ as many elements on the stack as inside the array.
+ \li \c destroyOnPop: set this boolean to true if StackView needs to destroy the item when
+ it is popped off the stack. By default (if \a destroyOnPop is not specified), StackView
+ will destroy items pushed as components or URLs. Items not destroyed will be re-parented
+ back to the original parents they had before being pushed onto the stack and hidden.
+ If you need to set this property, do it with care, so that items are not leaked.
+ \endlist
+
+ If the only argument needed is "item", the following short-hand notation can be applied:
+
+ \code
+ stackView.push(yourItem)
+ \endcode
+
+ You can push several items in one go by using an array of property lists. This is
+ optimizing compared to pushing items one by one, since StackView then can load only the
+ last item in the list. The rest will be loaded as they are about to become
+ the current item (which happens when the stack is popped). The following example shows how
+ to push an array of items:
+
+ \code
+ stackView.push([{item: yourItem1}, {item: yourItem2}])
+ \endcode
+
+ If an inline item is pushed, the item is temporarily re-parented into the StackView. When the item
+ is later popped off, it gets re-parented back to its original owner again.
+ If, however, an item is pushed as a component or a URL, the actual item will be created as an
+ item from that component. This happens automatically when the item is about to become the current
+ item in the stack. Ownership of the item will then normally be taken by the StackView. It will as
+ such automatically destroy the item when it is later popped off. The component that declared the item, by
+ contrast, remains in the ownership of the application and is not destroyed by the stack.
+ This can be overridden by explicitly setting \c{destroyOnPop} in the list of arguments given to push.
+
+ If the \c properties to be pushed are specified, they will be copied into the item at loading time
+ (in case of a component or URL), or when the item will become the current item (in case of an inline
+ item). The following example shows how this can be done:
+
+ \code
+ stackView.push({item: someItem, properties: {fgcolor: "red", bgcolor: "blue"}})
+ \endcode
+
+
+ \note Note that if an item is declared inside another item, and if that parent gets destroyed,
+ (even if a component was used), that child item will also be destroyed.
+ This follows normal Qt parent-child destruction rules, but sometimes comes as a surprise
+ for developers.
+
+ \section1 Lifecycle
+ An item's lifecycle in the StackView can have the following transitions:
+ \list 1
+ \li instantiation
+ \li inactive
+ \li activating
+ \li active
+ \li deactivating
+ \li inactive
+ \li destruction
+ \endlist
+
+ It can move any number of times between inactive and active. When an item is activated,
+ it's visible on the screen and is considered to be the current item. An item
+ in a StackView that is not visible is not activated, even if the item is currently the
+ top-most item in the stack. When the stack becomes visible, the item that is top-most gets
+ activated. Likewise if the stack is then hidden, the topmost item would be deactivated.
+ Popping the item off the top of the stack at this point would not result in further
+ deactivation since the item is not active.
+
+ There is an attached \l{Stack::status}{Stack.status} property that tracks the lifecycle. The
+ status values list is an enumeration with values \c Stack.Inactive, \c Stack.Activating,
+ \c Stack.Active and \c Stack.Deactivating. Combined with the normal \c Component.onComplete and
+ \c Component.onDestruction signals the entire lifecycle is thus:
+
+ \list
+ \li Created: Component.onCompleted()
+ \li Activating: Stack.onStatusChanged (Stack.status is Stack.Activating)
+ \li Acivated: Stack.onStatusChanged (Stack.status is Stack.Active)
+ \li Deactivating: Stack.onStatusChanged (Stack.status is Stack.Deactivating)
+ \li Deactivated: Stack.onStatusChanged (Stack.status is Stack.Inactive)
+ \li Destruction: Component.onDestruction()
+ \endlist
+
+ \section1 Finding items
+ Sometimes it is necessary to search for an item, for example, in order to unwind the stack to
+ an item to which the application does not have a reference. This is facilitated using a
+ function find() in StackView. The find() function takes a callback function as its
+ only argument. The callback gets invoked for each item in the stack (starting at the top).
+ If the callback returns true, then it signals that a match has been found and the find()
+ function returns that item. If the callback fails to return true (no match is found),
+ then find() returns \c null.
+
+ The code below searches for an item in the stack that has a name "order_id" and then unwinds to
+ that item. Note that since find() returns \c {null} if no item is found, and since pop unwinds to
+ the bottom of the stack if null is given as the target item, the code works well even in
+ case no matching item is found.
+
+ \code
+ stackView.pop(stackView.find(function(item) {
+ return item.name == "order_id";
+ }));
+ \endcode
+
+ You can also get to an item in the stack using \l {get()}{get(index)}. You should use
+ this function if your item depends on another item in the stack, as the function will
+ ensure that the item at the given index gets loaded before it is returned.
+
+ \code
+ previousItem = stackView.get(myItem.Stack.index - 1));
+ \endcode
+
+ \section1 Transitions
+
+ A transition is performed whenever a item is pushed or popped, and consists of
+ two items: enterItem and exitItem. The StackView itself will never move items
+ around, but instead delegate the job to an external animation set provided
+ by the style or the application developer. How items should visually enter and leave the stack
+ (and the geometry they should end up with) is therefore completely controlled from the outside.
+
+ When the transition starts, the StackView will search for a transition that
+ matches the operation executed. There are three transitions to choose
+ from: pushTransition, popTransition, and replaceTransition. Each implements how
+ enterItem should animate in, and exitItem out. The transitions are
+ collected inside a StackViewDelegate object assigned to
+ \l {StackView::delegate}{delegate}. By default, popTransition and
+ replaceTransition will be the same as pushTransition, unless you set them
+ to something else.
+
+ A simple fade transition could be implemented as:
+
+ \qml
+ StackView {
+ delegate: StackViewDelegate {
+ function transitionFinished(properties)
+ {
+ properties.exitItem.opacity = 1
+ }
+
+ pushTransition: StackViewTransition {
+ PropertyAnimation {
+ target: enterItem
+ property: "opacity"
+ from: 0
+ to: 1
+ }
+ PropertyAnimation {
+ target: exitItem
+ property: "opacity"
+ from: 1
+ to: 0
+ }
+ }
+ }
+ }
+ \endqml
+
+ PushTransition needs to inherit from StackViewTransition, which is a ParallelAnimation that
+ contains the properties \c enterItem and \c exitItem. You set the target of your
+ inner animations to those items. Since the same items instance can be pushed several
+ times to a StackView, you should always override
+ \l {StackViewDelegate::transitionFinished()}{StackViewDelegate.transitionFinished()}.
+ Implement this function to reset any properties animated on the exitItem so that later
+ transitions can expect the items to be in a default state.
+
+ A more complex example could look like the following. Here, the items are lying on the side before
+ being rotated to an upright position:
+
+ \qml
+ StackView {
+ delegate: StackViewDelegate {
+ function transitionFinished(properties)
+ {
+ properties.exitItem.x = 0
+ properties.exitItem.rotation = 0
+ }
+
+ pushTransition: StackViewTransition {
+ SequentialAnimation {
+ ScriptAction {
+ script: enterItem.rotation = 90
+ }
+ PropertyAnimation {
+ target: enterItem
+ property: "x"
+ from: enterItem.width
+ to: 0
+ }
+ PropertyAnimation {
+ target: enterItem
+ property: "rotation"
+ from: 90
+ to: 0
+ }
+ }
+ PropertyAnimation {
+ target: exitItem
+ property: "x"
+ from: 0
+ to: -exitItem.width
+ }
+ }
+ }
+ }
+ \endqml
+
+ \section2 Advanced usage
+
+ When the StackView needs a new transition, it first calls
+ \l {StackViewDelegate::getTransition()}{StackViewDelegate.getTransition()}.
+ The base implementation of this function just looks for a property named \c properties.name inside
+ itself (root), which is how it finds \c {property Component pushTransition} in the examples above.
+
+ \code
+ function getTransition(properties)
+ {
+ return root[properties.name]
+ }
+ \endcode
+
+ You can override this function for your delegate if you need extra logic to decide which
+ transition to return. You could for example introspect the items, and return different animations
+ depending on the their internal state. StackView will expect you to return a Component that
+ contains a StackViewTransition, or a StackViewTransition directly. The former is easier, as StackView will
+ then create the transition and later destroy it when it's done, while avoiding any sideeffects
+ caused by the transition being alive long after it has run. Returning a StackViewTransition directly
+ can be useful if you need to write some sort of transition caching for performance reasons.
+ As an optimization, you can also return \c null to signal that you just want to show/hide the items
+ immediately without creating or running any transitions. You can also override this function if
+ you need to alter the items in any way before the transition starts.
+
+ \c properties contains the properties that will be assigned to the StackViewTransition before
+ it runs. In fact, you can add more properties to this object during the call
+ if you need to initialize additional properties of your custom StackViewTransition when the returned
+ component is instantiated.
+
+ The following example shows how you can decide which animation to use during runtime :
+
+ \qml
+ StackViewDelegate {
+ function getTransition(properties)
+ {
+ return (properties.enterItem.Stack.index % 2) ? horizontalTransition : verticalTransition
+ }
+
+ function transitionFinished(properties)
+ {
+ properties.exitItem.x = 0
+ properties.exitItem.y = 0
+ }
+
+ property Component horizontalTransition: StackViewTransition {
+ PropertyAnimation {
+ target: enterItem
+ property: "x"
+ from: target.width
+ to: 0
+ duration: 300
+ }
+ PropertyAnimation {
+ target: exitItem
+ property: "x"
+ from: 0
+ to: target.width
+ duration: 300
+ }
+ }
+
+ property Component verticalTransition: StackViewTransition {
+ PropertyAnimation {
+ target: enterItem
+ property: "y"
+ from: target.height
+ to: 0
+ duration: 300
+ }
+ PropertyAnimation {
+ target: exitItem
+ property: "y"
+ from: 0
+ to: target.height
+ duration: 300
+ }
+ }
+ }
+ \endqml
+
+ \section1 Supported Attached Properties
+
+ Items in a StackView support these attached properties:
+ \list
+ \li \l{Stack::index}{Stack.index} - Contains the index of the item inside the StackView
+ \li \l{Stack::view}{Stack.view} - Contains the StackView the item is in
+ \li \l{Stack::status}{Stack.status} - Contains the status of the item
+ \endlist
+*/
+
+AbstractStackView {
+ id: root
+
+ depth: root.__depth
+ currentItem: root.__currentItem
+ initialItem: null
+ busy: __currentTransition !== null
+
+ /*! The transitions to use when pushing or popping items.
+ For better understanding on how to apply custom transitions, read \l{Transitions}.
+ \sa {Stack::transitions}{Stack.transitions} */
+ property StackViewDelegate delegate: StackViewDelegate {}
+
+ /*! Pushes an item onto the stack. The function takes a property list as argument, which
+ should contain one or more of the following properties:
+ \list
+ \li \c item: this property is required, and holds the item you want to push.
+ \li \c properties: a list of QML properties that should be assigned
+ to the item upon push. These properties will be copied into the item when it is
+ loaded (in case of a component or URL), or when it becomes the current item for the
+ first time (normally upon push).
+ \li \c immediate: set this property to \c true to skip transition effects. When pushing
+ an array, you only need to set this property on the first element to make the
+ whole operation immediate.
+ \li \c replace: set this property to replace the current item on the stack. When pushing
+ an array, you only need to set this property on the first element to replace
+ as many elements on the stack as inside the array.
+ \li \c destroyOnPop: set this property to specify if the item needs to be destroyed
+ when its popped off the stack. By default (if \a destroyOnPop is not specified),
+ StackView will destroy items pushed as components or URLs. Items
+ not destroyed will be re-parented to the original parents they had before being
+ pushed onto the stack, and hidden. If you need to set this property, do it with
+ care, so that items are not leaked.
+ \endlist
+
+ You can also push an array of items (property lists) if you need to push several items
+ in one go. A transition will then only occur between the current item and the last
+ item in the list. Loading the other items will be deferred until needed.
+
+ Examples:
+ \list
+ \li stackView.push({item:anItem})
+ \li stackView.push({item:aURL, immediate: true, replace: true})
+ \li stackView.push({item:aRectangle, properties:{color:"red"}})
+ \li stackView.push({item:aComponent, properties:{color:"red"}})
+ \li stackView.push({item:aComponent.createObject(), destroyOnPop:true})
+ \li stackView.push([{item:anitem, immediate:true}, {item:aURL}])
+ \endlist
+
+ \note Note: if the only argument needed is "item", you can apply the following short-
+ hand notation: \c{stackView.push(anItem)}.
+
+ Returns the item that became current.
+
+ \sa initialItem
+ \sa {Pushing items}
+ */
+ function push(item) {
+ // Note: we support two different APIs in this function; The old meego API, and
+ // the new "property list" API. Hence the reason for hiding the fact that you
+ // can pass more arguments than shown in the signature:
+ if (__recursionGuard(true))
+ return
+ var properties = arguments[1]
+ var immediate = arguments[2]
+ var replace = arguments[3]
+ var arrayPushed = (item instanceof Array)
+ var firstItem = arrayPushed ? item[0] : item
+ immediate = (immediate || JSArray.stackView.length === 0)
+
+ if (firstItem && firstItem.item && firstItem.hasOwnProperty("x") === false) {
+ // Property list API used:
+ immediate = immediate || firstItem.immediate
+ replace = replace || firstItem.replace
+ }
+
+ // Create, and push, a new javascript object, called "element", onto the stack.
+ // This element contains all the information necessary to construct the item, and
+ // will, after loaded, also contain the loaded item:
+ if (arrayPushed) {
+ if (item.length === 0)
+ return
+ var outElement = replace ? JSArray.pop() : JSArray.current()
+ for (var i=0; i<item.length; ++i)
+ JSArray.push({itemComponent:item[i], loaded: false, index: __depth, properties: properties});
+ } else {
+ outElement = replace ? JSArray.pop() : JSArray.current()
+ JSArray.push({itemComponent:item, loaded: false, index: __depth, properties: properties})
+ }
+
+ var currentElement = JSArray.current()
+ var transition = {
+ inElement: currentElement,
+ outElement: outElement,
+ immediate: immediate,
+ replace: replace,
+ push: true
+ }
+ __performTransition(transition)
+ __recursionGuard(false)
+ return __currentItem
+ }
+
+ /*! Pops one or more items off the stack. The function takes a property list as argument
+ which can contain one or more of the following properties:
+ \list
+ \li \c item: if specified, all items down to (but not including) \a item will be
+ popped off. If \a item is \c null, all items down to (but not including) the
+ first item will be popped. If not specified, only the current item will be
+ popped.
+ \li \c immediate: set this property to \c true to skip transition effects.
+ \endlist
+
+ Examples:
+ \list
+ \li stackView.pop()
+ \li stackView.pop({item:someItem, immediate: true})
+ \li stackView.pop({immediate: true})
+ \li stackView.pop(null)
+ \endlist
+
+ \note Note: If the only argument needed is "item", you can apply the following short-
+ hand notation: \c{stackView.pop(anItem)}.
+
+ Returns the item that was popped off
+ \sa clear()
+ */
+ function pop(item) {
+ if (__depth <= 1)
+ return null
+ if (item && item.hasOwnProperty("x") === false) {
+ // Property list API used:
+ var immediate = (item.immediate === true)
+ item = item.item
+ } else {
+ immediate = (arguments[1] === true)
+ }
+
+ if (item === __currentItem)
+ return
+
+ if (__recursionGuard(true))
+ return
+
+ var outElement = JSArray.pop()
+ var inElement = JSArray.current()
+
+ if (__depth > 1 && item !== undefined && item !== inElement.item) {
+ // Pop from the top until we find 'item', and return the corresponding
+ // element. Skip all non-loaded items (except the first), since no one
+ // has any references to such items anyway:
+ while (__depth > 1 && !JSArray.current().loaded)
+ JSArray.pop()
+ inElement = JSArray.current()
+ while (__depth > 1 && item !== inElement.item) {
+ JSArray.pop()
+ __cleanup(inElement)
+ while (__depth > 1 && !JSArray.current().loaded)
+ JSArray.pop()
+ inElement = JSArray.current()
+ }
+ }
+
+ var transition = {
+ inElement: inElement,
+ outElement: outElement,
+ immediate: immediate,
+ replace: false,
+ push: false
+ }
+ __performTransition(transition)
+ __recursionGuard(false)
+ return outElement.item;
+ }
+
+ /*! Remove all items from the stack. No animations will be applied. */
+ function clear() {
+ if (__recursionGuard(true))
+ return
+ if (__currentTransition)
+ __currentTransition.animation.complete()
+ __currentItem = null
+ var count = __depth
+ for (var i=0; i<count; ++i) {
+ var element = JSArray.pop()
+ if (element.item)
+ __cleanup(element);
+ }
+ __recursionGuard(false)
+ }
+
+ /*! Search for a specific item inside the stack. \a func will
+ be called for each item in the stack (with the item as argument)
+ until the function returns true. Return value will be the item found. For
+ example:
+ find(function(item, index) { return item.isTheOne })
+ Set \a onlySearchLoadedItems to \c true to not load items that are
+ not loaded into memory */
+ function find(func, onlySearchLoadedItems) {
+ for (var i=__depth-1; i>=0; --i) {
+ var element = JSArray.stackView[i];
+ if (onlySearchLoadedItems !== true)
+ __loadElement(element)
+ else if (!element.item)
+ continue
+ if (func(element.item, i))
+ return element.item
+ }
+ return null;
+ }
+
+ /*! Returns the item at position \a index in
+ the stack. If \a dontLoad is true, the
+ item will not be forced to load (and \c null
+ will be returned if not yet loaded) */
+ function get(index, dontLoad)
+ {
+ if (index < 0 || index >= JSArray.stackView.length)
+ return null
+ var element = JSArray.stackView[index]
+ if (dontLoad !== true) {
+ __loadElement(element)
+ return element.item
+ } else if (element.item) {
+ return element.item
+ } else {
+ return null
+ }
+ }
+
+ /*! Immediately completes any ongoing transition.
+ /sa Animation.complete
+ */
+ function completeTransition()
+ {
+ if (__recursionGuard(true))
+ return
+ if (__currentTransition)
+ __currentTransition.animation.complete()
+ __recursionGuard(false)
+ }
+
+ /********* DEPRECATED API *********/
+
+ /*! \internal
+ \deprecated Use Push() instead */
+ function replace(item, properties, immediate) {
+ push(item, properties, immediate, true)
+ }
+
+ /********* PRIVATE API *********/
+
+ /*! \internal The currently top-most item on the stack. */
+ property Item __currentItem: null
+ /*! \internal The number of items currently pushed onto the stack. */
+ property int __depth: 0
+ /*! \internal Stores the transition info while a transition is ongoing */
+ property var __currentTransition: null
+ /*! \internal Stops the user from pushing items while preparing a transition */
+ property bool __guard: false
+
+ Component.onCompleted: {
+ if (initialItem)
+ push(initialItem)
+ }
+
+ Component.onDestruction: {
+ if (__currentTransition)
+ __currentTransition.animation.complete()
+ __currentItem = null
+ }
+
+ /*! \internal */
+ function __recursionGuard(use)
+ {
+ if (use && __guard) {
+ console.warn("Warning: StackView: You cannot push/pop recursively!")
+ console.trace()
+ return true
+ }
+ __guard = use
+ }
+
+ /*! \internal */
+ function __loadElement(element)
+ {
+ if (element.loaded) {
+ if (!element.item) {
+ element.item = invalidItemReplacement.createObject(root)
+ element.item.text = "\nError: The item has been deleted outside StackView!"
+ }
+ return
+ }
+ if (!element.itemComponent) {
+ element.item = invalidItemReplacement.createObject(root)
+ element.item.text = "\nError: Invalid item (item was 'null'). "
+ + "This might indicate that the item was deleted outside StackView!"
+ return
+ }
+
+ var comp = __resolveComponent(element.itemComponent, element)
+
+ // Assign properties to item:
+ if (!element.properties)
+ element.properties = {}
+
+ if (comp.hasOwnProperty("createObject")) {
+ if (comp.status === Component.Error) {
+ element.item = invalidItemReplacement.createObject(root)
+ element.item.text = "\nError: Could not load: " + comp.errorString()
+ } else {
+ element.item = comp.createObject(root, element.properties)
+ // Destroy items we create unless the user specified something else:
+ if (!element.hasOwnProperty("destroyOnPop"))
+ element.destroyOnPop = true
+ }
+ } else {
+ // comp is already an Item, so just re-parent it into the StackView:
+ element.item = comp
+ element.originalParent = parent
+ element.item.parent = root
+ for (var prop in element.properties) {
+ if (element.item.hasOwnProperty(prop))
+ element.item[prop] = element.properties[prop];
+ }
+ // Do not destroy items we didn't create, unless the user specified something else:
+ if (!element.hasOwnProperty("destroyOnPop"))
+ element.destroyOnPop = false
+ }
+
+//TODO element.item.Stack.__index = element.index
+//TODO element.item.Stack.__view = root
+ // Let item fill all available space by default:
+ element.item.width = Qt.binding(function() { return root.width })
+ element.item.height = Qt.binding(function() { return root.height })
+ element.loaded = true
+ }
+
+ /*! \internal */
+ function __resolveComponent(unknownObjectType, element)
+ {
+ // We need this extra resolve function since we don't really
+ // know what kind of object the user pushed. So we try to
+ // figure it out by inspecting the object:
+ if (unknownObjectType.hasOwnProperty("createObject")) {
+ return unknownObjectType
+ } else if (typeof unknownObjectType == "string") {
+ return Qt.createComponent(unknownObjectType)
+ } else if (unknownObjectType.hasOwnProperty("x")) {
+ return unknownObjectType
+ } else if (unknownObjectType.hasOwnProperty("item")) {
+ // INVARIANT: user pushed a JS-object
+ element.properties = unknownObjectType.properties
+ if (!unknownObjectType.item)
+ unknownObjectType.item = invalidItemReplacement
+ if (unknownObjectType.hasOwnProperty("destroyOnPop"))
+ element.destroyOnPop = unknownObjectType.destroyOnPop
+ return __resolveComponent(unknownObjectType.item, element)
+ } else {
+ // We cannot determine the type, so assume its a URL:
+ return Qt.createComponent(unknownObjectType)
+ }
+ }
+
+ /*! \internal */
+ function __cleanup(element) {
+ // INVARIANT: element has been removed from JSArray. Destroy its
+ // item, or re-parent it back to the parent it had before it was pushed:
+ var item = element.item
+ if (element.destroyOnPop) {
+ item.destroy()
+ } else {
+ // Mark the item as no longer part of the StackView. It
+ // might reenter on pop if pushed several times:
+ item.visible = false
+ __setStatus(item, Stack.Inactive)
+//TODO item.Stack.__view = null
+//TODO item.Stack.__index = -1
+ if (element.originalParent)
+ item.parent = element.originalParent
+ }
+ }
+
+ /*! \internal */
+ function __setStatus(item, status) {
+ item.Stack.status = status
+ }
+
+ /*! \internal */
+ function __performTransition(transition)
+ {
+ // Animate item in "outElement" out, and item in "inElement" in. Set a guard to protect
+ // the user from pushing new items on signals that will fire while preparing for the transition
+ // (e.g Stack.onCompleted, Stack.onStatusChanged, Stack.onIndexChanged etc). Otherwise, we will enter
+ // this function several times, which causes the items to be updated half-way.
+ if (__currentTransition)
+ __currentTransition.animation.complete()
+ __loadElement(transition.inElement)
+
+ transition.name = transition.replace ? "replaceTransition" : (transition.push ? "pushTransition" : "popTransition")
+ var enterItem = transition.inElement.item
+ transition.enterItem = enterItem
+
+ // Since an item can be pushed several times, we need to update its properties:
+ enterItem.parent = root
+//TODO enterItem.Stack.__view = root
+//TODO enterItem.Stack.__index = transition.inElement.index
+ __currentItem = enterItem
+
+ if (!transition.outElement) {
+ // A transition consists of two items, but we got just one. So just show the item:
+ enterItem.visible = true
+ __setStatus(enterItem, Stack.Activating)
+ __setStatus(enterItem, Stack.Active)
+ return
+ }
+
+ var exitItem = transition.outElement.item
+ transition.exitItem = exitItem
+ if (enterItem === exitItem)
+ return
+
+ if (root.delegate) {
+ transition.properties = {
+ "name":transition.name,
+ "enterItem":transition.enterItem,
+ "exitItem":transition.exitItem,
+ "immediate":transition.immediate }
+ var anim = root.delegate.getTransition(transition.properties)
+ if (anim.createObject) {
+ anim = anim.createObject(null, transition.properties)
+ anim.runningChanged.connect(function(){ if (anim.running === false) anim.destroy() })
+ }
+ transition.animation = anim
+ }
+
+ if (!transition.animation) {
+ console.warn("Warning: StackView: no", transition.name, "found!")
+ return
+ }
+ if (enterItem.anchors.fill || exitItem.anchors.fill)
+ console.warn("Warning: StackView: cannot transition an item that is anchored!")
+
+ __currentTransition = transition
+ __setStatus(exitItem, Stack.Deactivating)
+ enterItem.visible = true
+ __setStatus(enterItem, Stack.Activating)
+ transition.animation.runningChanged.connect(animationFinished)
+ transition.animation.start()
+ // NB! For empty animations, "animationFinished" is already
+ // executed at this point, leaving __animation === null:
+ if (transition.immediate === true && transition.animation)
+ transition.animation.complete()
+ }
+
+ /*! \internal */
+ function animationFinished()
+ {
+ if (!__currentTransition || __currentTransition.animation.running)
+ return
+
+ __currentTransition.animation.runningChanged.disconnect(animationFinished)
+ __currentTransition.exitItem.visible = false
+ __setStatus(__currentTransition.exitItem, Stack.Inactive);
+ __setStatus(__currentTransition.enterItem, Stack.Active);
+ __currentTransition.properties.animation = __currentTransition.animation
+ root.delegate.transitionFinished(__currentTransition.properties)
+
+ if (!__currentTransition.push || __currentTransition.replace)
+ __cleanup(__currentTransition.outElement)
+
+ __currentTransition = null
+ }
+
+ /*! \internal */
+ property Component invalidItemReplacement: Component {
+ Text {
+ width: parent.width
+ height: parent.height
+ wrapMode: Text.WrapAtWordBoundaryOrAnywhere
+ }
+ }
+}
diff --git a/src/imports/controls/StackViewDelegate.qml b/src/imports/controls/StackViewDelegate.qml
new file mode 100644
index 00000000..2d4355bd
--- /dev/null
+++ b/src/imports/controls/StackViewDelegate.qml
@@ -0,0 +1,142 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick 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$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+
+/*!
+ \qmltype StackViewDelegate
+ \inqmlmodule QtQuick.Controls
+ \since 5.1
+
+ \brief A delegate used by StackView for loading transitions.
+
+ See the documentation for the \l {StackView} component.
+
+*/
+QtObject {
+ id: root
+
+ property bool horizontal: true
+
+ function getTransition(properties)
+ {
+ return root[horizontal ? "horizontalSlide" : "verticalSlide"][properties.name]
+ }
+
+ function transitionFinished(properties)
+ {
+ properties.exitItem.x = 0
+ properties.exitItem.y = 0
+ }
+
+ property QtObject horizontalSlide: QtObject {
+ property Component pushTransition: StackViewTransition {
+ PropertyAnimation {
+ target: enterItem
+ property: "x"
+ from: target.width
+ to: 0
+ duration: 400
+ easing.type: Easing.OutCubic
+ }
+ PropertyAnimation {
+ target: exitItem
+ property: "x"
+ from: 0
+ to: -target.width
+ duration: 400
+ easing.type: Easing.OutCubic
+ }
+ }
+
+ property Component popTransition: StackViewTransition {
+ PropertyAnimation {
+ target: enterItem
+ property: "x"
+ from: -target.width
+ to: 0
+ duration: 400
+ easing.type: Easing.OutCubic
+ }
+ PropertyAnimation {
+ target: exitItem
+ property: "x"
+ from: 0
+ to: target.width
+ duration: 400
+ easing.type: Easing.OutCubic
+ }
+ }
+ property Component replaceTransition: pushTransition
+ }
+
+ property QtObject verticalSlide: QtObject {
+ property Component pushTransition: StackViewTransition {
+ PropertyAnimation {
+ target: enterItem
+ property: "y"
+ from: target.height
+ to: 0
+ duration: 300
+ }
+ PropertyAnimation {
+ target: exitItem
+ property: "y"
+ from: 0
+ to: -target.height
+ duration: 300
+ }
+ }
+
+ property Component popTransition: StackViewTransition {
+ PropertyAnimation {
+ target: enterItem
+ property: "y"
+ from: -target.height
+ to: 0
+ duration: 300
+ }
+ PropertyAnimation {
+ target: exitItem
+ property: "y"
+ from: 0
+ to: target.height
+ duration: 300
+ }
+ property Component replaceTransition: pushTransition
+ }
+ }
+}
diff --git a/src/imports/controls/StackViewTransition.qml b/src/imports/controls/StackViewTransition.qml
new file mode 100644
index 00000000..f057791c
--- /dev/null
+++ b/src/imports/controls/StackViewTransition.qml
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick 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$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+
+ParallelAnimation {
+ id: root
+ /*! The name of the animation that is running. Can be one of the following:
+ \list
+ \li 'PushTransition'
+ \li 'PopTransition'
+ \li 'ReplaceTransition'
+ \endlist
+ */
+ property string name
+ /*! The page that is transitioning in. */
+ property Item enterItem
+ /*! The page that is transitioning out */
+ property Item exitItem
+ /*! Set to \c true if the transition is told to
+ fast-forward directly to its end-state */
+ property bool immediate
+}
diff --git a/src/imports/controls/Switch.qml b/src/imports/controls/Switch.qml
new file mode 100644
index 00000000..51768cc6
--- /dev/null
+++ b/src/imports/controls/Switch.qml
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick 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$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Controls 2.0
+
+AbstractSwitch {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ (label ? label.implicitWidth : 0) +
+ (indicator ? indicator.implicitWidth : 0) +
+ (label && indicator ? style.spacing : 0) + padding.left + padding.right)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ Math.max(label ? label.implicitHeight : 0,
+ indicator ? indicator.implicitHeight : 0) + padding.top + padding.bottom)
+
+ Accessible.name: text
+ Accessible.checkable: true
+ Accessible.checked: checked
+ Accessible.pressed: pressed
+ Accessible.role: Accessible.Button // TODO: Switch?
+
+ padding { top: style.padding; left: style.padding; right: style.padding; bottom: style.padding }
+
+ indicator: Rectangle {
+ readonly property bool mirror: control.effectiveLayoutDirection == Qt.RightToLeft
+
+ implicitWidth: 36
+ implicitHeight: 20
+ x: text ? (mirror ? parent.width - width - padding.right : padding.left) : (parent.width - width) / 2
+ y: (parent.height - height) / 2
+
+ radius: 10
+ border.width: control.activeFocus ? 2 : 1
+ border.color: control.activeFocus ? style.focusColor : style.frameColor
+ opacity: enabled ? 1.0 : style.disabledOpacity
+ color: style.backgroundColor
+
+ Rectangle {
+ width: 12
+ height: 12
+ radius: 6
+
+ color: Qt.tint(Qt.tint(control.checked ? style.accentColor : style.baseColor,
+ control.checked && control.activeFocus ? style.focusColor : "transparent"),
+ control.pressed ? style.pressColor : "transparent")
+ border.width: control.checked || control.pressed ? 0 : 1
+ border.color: style.frameColor
+
+ x: Math.max(4, Math.min(parent.width - width - 4,
+ control.visualPosition * parent.width - (width / 2)))
+ y: (parent.height - height) / 2
+
+ Behavior on x {
+ enabled: !control.pressed
+ SmoothedAnimation { velocity: 200 }
+ }
+ }
+ }
+
+ label: Text {
+ readonly property bool mirror: control.effectiveLayoutDirection == Qt.RightToLeft
+
+ x: mirror ? padding.left : (indicator.x + indicator.width + control.style.spacing)
+ y: padding.top
+ width: parent.width - indicator.width - control.style.spacing - padding.left - padding.right
+ height: parent.height - padding.top - padding.bottom
+
+ text: control.text
+ color: control.style.textColor
+ elide: Text.ElideRight
+ visible: control.text
+ opacity: enabled ? 1.0 : control.style.disabledOpacity
+ horizontalAlignment: Text.AlignLeft
+ verticalAlignment: Text.AlignVCenter
+ }
+}
diff --git a/src/imports/controls/TabBar.qml b/src/imports/controls/TabBar.qml
new file mode 100644
index 00000000..fa6faea9
--- /dev/null
+++ b/src/imports/controls/TabBar.qml
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick 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$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Controls 2.0
+
+AbstractTabBar {
+ id: control
+
+ property list<Item> items
+ readonly property int count: items.length
+ property alias highlight: listView.highlight
+ property alias spacing: listView.spacing
+
+ property Component delegate: TabButton {
+ width: (listView.width - Math.max(0, count - 1) * spacing) / count
+ }
+
+ contentWidth: listView.contentWidth
+ contentHeight: listView.contentHeight
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + padding.left + padding.right)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + padding.top + padding.bottom)
+
+ Accessible.role: Accessible.PageTabList
+
+ ExclusiveGroup {
+ id: group
+ }
+
+ contentItem: ListView {
+ id: listView
+
+ x: padding.left
+ y: padding.top
+ width: parent.width - padding.left - padding.right
+ height: parent.height - padding.top - padding.bottom
+
+ spacing: 1
+ orientation: ListView.Horizontal
+ boundsBehavior: Flickable.StopAtBounds
+ snapMode: ListView.SnapToItem
+
+ model: control.items
+ currentIndex: control.currentIndex
+
+ delegate: Loader {
+ sourceComponent: control.delegate
+ visible: modelData.Tab.visible
+ Binding { target: item; property: "Exclusive.group"; value: group }
+ Binding { target: item; property: "text"; value: modelData.Tab.title }
+ Binding { target: item; property: "checked"; value: control.currentIndex === index }
+ Connections { target: item; onClicked: control.currentIndex = index }
+ }
+
+ property bool completed: false
+ Component.onCompleted: completed = true
+
+ highlightMoveDuration: completed ? 250 : 0
+ highlightResizeDuration: 0
+ highlightFollowsCurrentItem: true
+ highlight: Item {
+ z: 2
+ Rectangle {
+ height: 4
+ width: parent.width
+ y: parent.height - height
+ color: style.accentColor
+ }
+ }
+ }
+
+ background: Rectangle {
+ implicitWidth: 26
+ implicitHeight: 26
+ width: listView.width
+ border.color: style.backgroundColor
+ border.width: 8
+ color: listView.count > 1 ? style.frameColor : style.backgroundColor
+ Rectangle {
+ y: parent.height - height
+ width: parent.width
+ height: 1
+ color: style.frameColor
+ }
+ }
+}
diff --git a/src/imports/controls/TabButton.qml b/src/imports/controls/TabButton.qml
new file mode 100644
index 00000000..3676a4bc
--- /dev/null
+++ b/src/imports/controls/TabButton.qml
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick 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$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Controls 2.0
+
+AbstractTabButton {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ label ? label.implicitWidth + padding.left + padding.right : 0)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ label ? label.implicitHeight + padding.top + padding.bottom : 0)
+
+ Accessible.name: text
+ Accessible.pressed: pressed
+ Accessible.selected: checked
+ Accessible.role: Accessible.PageTab
+
+ padding { top: style.padding; left: style.padding; right: style.padding; bottom: style.padding }
+
+ label: Text {
+ x: padding.left
+ y: padding.top
+ width: parent.width - padding.left - padding.right
+ height: parent.height - padding.top - padding.bottom
+
+ text: control.text
+ font.pointSize: 10
+ elide: Text.ElideRight
+ color: control.pressed ? control.style.accentColor : control.style.textColor
+ opacity: enabled ? 1.0 : control.style.disabledOpacity
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+
+ background: Rectangle {
+ height: parent.height - 1
+ implicitHeight: 26
+ color: style.backgroundColor
+ }
+}
diff --git a/src/imports/controls/TabView.qml b/src/imports/controls/TabView.qml
new file mode 100644
index 00000000..db61675b
--- /dev/null
+++ b/src/imports/controls/TabView.qml
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick 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$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Controls 2.0
+import QtQml.Models 2.1
+
+AbstractTabView {
+ id: control
+
+ default property alias items: listView.items
+ readonly property alias currentItem: listView.currentItem
+ property alias spacing: listView.spacing
+ property alias count: listView.count
+
+ contentWidth: listView.implicitWidth
+ contentHeight: listView.contentHeight
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + padding.left + padding.right)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + padding.top + padding.bottom)
+
+ padding.top: tabBar && tabBar.parent === control ? tabBar.height : 0
+
+ tabBar: TabBar { }
+
+ Accessible.role: Accessible.PageTabList
+
+ Binding { target: tabBar; property: "items"; value: control.items }
+
+ contentItem: ListView {
+ id: listView
+
+ property list<Item> items
+
+ Binding { target: control; property: "currentIndex"; value: listView.currentIndex }
+ Binding { target: listView; property: "currentIndex"; value: control.currentIndex }
+
+ x: padding.left
+ y: padding.top
+ width: parent.width - padding.left - padding.right
+ height: parent.height - padding.top - padding.bottom
+
+ orientation: Qt.Horizontal
+ snapMode: ListView.SnapOneItem
+ boundsBehavior: Flickable.StopAtBounds
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ preferredHighlightBegin: 0
+ preferredHighlightEnd: 0
+ highlightMoveDuration: 250
+
+ model: items
+
+ delegate: Item {
+ id: delegate
+ width: listView.width
+ height: listView.height
+ visible: modelData.Tab.visible
+ Binding { target: modelData; property: "parent"; value: delegate }
+ Binding { target: modelData; property: "Tab.index"; value: index }
+ Binding { target: modelData; property: "Tab.view"; value: control }
+ }
+ }
+}
diff --git a/src/imports/controls/TextArea.qml b/src/imports/controls/TextArea.qml
new file mode 100644
index 00000000..e88fafc8
--- /dev/null
+++ b/src/imports/controls/TextArea.qml
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick 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$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Controls 2.0
+
+AbstractTextArea {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ Math.max(edit ? edit.implicitWidth : 0,
+ placeholder ? placeholder.implicitWidth : 0) + padding.left + padding.right)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ Math.max(edit ? edit.implicitHeight : 0,
+ placeholder ? placeholder.implicitHeight : 0) + padding.top + padding.bottom)
+
+ Accessible.name: text
+ Accessible.multiLine: true
+ Accessible.role: Accessible.EditableText
+ Accessible.readOnly: !edit || edit.readOnly
+ Accessible.description: placeholder ? placeholder.text : ""
+
+ edit: TextEdit {
+ x: padding.left
+ y: padding.top
+ width: parent.width - padding.left - padding.right
+ height: parent.height - padding.top - padding.bottom
+
+ color: style.textColor
+ selectionColor: style.selectionColor
+ selectedTextColor: style.selectedTextColor
+ Keys.forwardTo: control
+ }
+
+ placeholder: Text {
+ x: padding.left
+ y: padding.top
+ width: parent.width - padding.left - padding.right
+ height: parent.height - padding.top - padding.bottom
+
+ color: control.style.textColor
+ opacity: control.style.disabledOpacity
+ visible: edit ? !edit.length : !control.text
+ }
+}
diff --git a/src/imports/controls/TextField.qml b/src/imports/controls/TextField.qml
new file mode 100644
index 00000000..b303b05d
--- /dev/null
+++ b/src/imports/controls/TextField.qml
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick 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$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Controls 2.0
+
+AbstractTextField {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ Math.max(input ? input.implicitWidth : 0,
+ placeholder ? placeholder.implicitWidth : 0) + padding.left + padding.right)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ Math.max(input ? input.implicitHeight : 0,
+ placeholder ? placeholder.implicitHeight : 0) + padding.top + padding.bottom)
+
+ Accessible.name: text
+ Accessible.role: Accessible.EditableText
+ Accessible.readOnly: !input || input.readOnly
+ Accessible.description: placeholder ? placeholder.text : ""
+ Accessible.passwordEdit: !!input && (input.echoMode == TextInput.Password ||
+ input.echoMode === TextInput.PasswordEchoOnEdit)
+
+ padding { top: style.padding; left: style.padding; right: style.padding; bottom: style.padding }
+
+ input: TextInput {
+ x: padding.left
+ y: padding.top
+ width: parent.width - padding.left - padding.right
+ height: parent.height - padding.top - padding.bottom
+
+ color: style.textColor
+ selectionColor: style.selectionColor
+ selectedTextColor: style.selectedTextColor
+ verticalAlignment: TextInput.AlignVCenter
+ Keys.forwardTo: control
+ }
+
+ placeholder: Text {
+ x: padding.left
+ y: padding.top
+ width: parent.width - padding.left - padding.right
+ height: parent.height - padding.top - padding.bottom
+
+ color: control.style.textColor
+ opacity: control.style.disabledOpacity
+ visible: input ? !input.displayText : !control.text
+ }
+
+ background: Rectangle {
+ implicitWidth: 120 // TODO
+ radius: style.roundness
+ border.width: control.activeFocus ? 2 : 1
+ border.color: control.activeFocus ? style.focusColor : style.frameColor
+ opacity: enabled ? 1.0 : style.disabledOpacity
+ }
+}
diff --git a/src/imports/controls/ToggleButton.qml b/src/imports/controls/ToggleButton.qml
new file mode 100644
index 00000000..102c752f
--- /dev/null
+++ b/src/imports/controls/ToggleButton.qml
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick 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$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Controls 2.0
+
+AbstractToggleButton {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ (label ? label.implicitWidth : 0) +
+ (indicator ? indicator.implicitWidth : 0) +
+ (label && indicator ? style.spacing : 0) + padding.left + padding.right)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ Math.max(label ? label.implicitHeight : 0,
+ indicator ? indicator.implicitHeight : 0) + padding.top + padding.bottom)
+
+ Accessible.name: text
+ Accessible.checkable: true
+ Accessible.checked: checked
+ Accessible.pressed: pressed
+ Accessible.role: Accessible.Button
+
+ padding { top: style.padding; left: style.padding; right: style.padding; bottom: style.padding }
+
+ indicator: Rectangle {
+ readonly property bool mirror: control.effectiveLayoutDirection == Qt.RightToLeft
+
+ implicitWidth: 36
+ implicitHeight: 20
+ x: text ? (mirror ? parent.width - width - padding.right : padding.left) : (parent.width - width) / 2
+ y: (parent.height - height) / 2
+
+ radius: style.roundness
+ border.width: control.activeFocus ? 2 : 1
+ border.color: control.activeFocus ? style.focusColor : style.frameColor
+ opacity: enabled ? 1.0 : style.disabledOpacity
+ color: style.backgroundColor
+
+ Rectangle {
+ width: 12
+ height: 12
+
+ color: Qt.tint(Qt.tint(control.checked ? style.accentColor : style.baseColor,
+ control.checked && control.activeFocus ? style.focusColor : "transparent"),
+ control.pressed ? style.pressColor : "transparent")
+ border.width: control.checked || control.pressed ? 0 : 1
+ border.color: style.frameColor
+
+ x: Math.max(4, Math.min(parent.width - width - 4,
+ control.visualPosition * parent.width - (width / 2)))
+ y: (parent.height - height) / 2
+
+ Behavior on x {
+ enabled: !control.pressed
+ SmoothedAnimation { velocity: 200 }
+ }
+ }
+ }
+
+ label: Text {
+ readonly property bool mirror: control.effectiveLayoutDirection == Qt.RightToLeft
+
+ x: mirror ? padding.left : (indicator.x + indicator.width + control.style.spacing)
+ y: padding.top
+ width: parent.width - indicator.width - control.style.spacing - padding.left - padding.right
+ height: parent.height - padding.top - padding.bottom
+
+ text: control.text
+ color: control.style.textColor
+ elide: Text.ElideRight
+ visible: control.text
+ opacity: enabled ? 1.0 : control.style.disabledOpacity
+ horizontalAlignment: Text.AlignLeft
+ verticalAlignment: Text.AlignVCenter
+ }
+}
diff --git a/src/imports/controls/ToolBar.qml b/src/imports/controls/ToolBar.qml
new file mode 100644
index 00000000..87ada6c9
--- /dev/null
+++ b/src/imports/controls/ToolBar.qml
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick 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$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Controls 2.0
+
+AbstractToolBar {
+ id: control
+
+ default property alias data: content.data
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ contentWidth + padding.left + padding.right)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ contentHeight + padding.top + padding.bottom)
+
+ contentWidth: content.children.length === 1 ? content.children[0].implicitWidth : 0
+ contentHeight: content.children.length === 1 ? content.children[0].implicitHeight : 0
+
+ Accessible.role: Accessible.ToolBar
+
+ contentItem: Item {
+ id: content
+ x: padding.left
+ y: padding.top
+ width: parent.width - padding.left - padding.right
+ height: parent.height - padding.top - padding.bottom
+ }
+
+ background: Rectangle {
+ implicitHeight: 26
+ color: style.baseColor
+ }
+}
diff --git a/src/imports/controls/ToolButton.qml b/src/imports/controls/ToolButton.qml
new file mode 100644
index 00000000..c5171c45
--- /dev/null
+++ b/src/imports/controls/ToolButton.qml
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick 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$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Controls 2.0
+
+AbstractButton {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ label ? label.implicitWidth + padding.left + padding.right : 0)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ label ? label.implicitHeight + padding.top + padding.bottom : 0)
+
+ Accessible.name: text
+ Accessible.pressed: pressed
+ Accessible.role: Accessible.Button
+
+ padding { top: style.padding; left: style.padding; right: style.padding; bottom: style.padding }
+
+ label: Text {
+ x: padding.left
+ y: padding.top
+ width: parent.width - padding.left - padding.right
+ height: parent.height - padding.top - padding.bottom
+
+ text: control.text
+ color: control.style.textColor
+ elide: Text.ElideRight
+ opacity: enabled ? 1.0 : control.style.disabledOpacity
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+
+ background: Rectangle {
+ implicitWidth: 26
+ implicitHeight: 26
+
+ opacity: style.disabledOpacity
+ color: style.frameColor
+ visible: control.pressed
+ }
+}
diff --git a/src/imports/controls/controls.pro b/src/imports/controls/controls.pro
new file mode 100644
index 00000000..d9de2bf9
--- /dev/null
+++ b/src/imports/controls/controls.pro
@@ -0,0 +1,47 @@
+TARGET = qtquickcontrols2plugin
+TARGETPATH = QtQuick/Controls.2
+IMPORT_VERSION = 2.0
+
+QT += qml quick
+QT += core-private gui-private qml-private quick-private quickcontrols-private
+
+OTHER_FILES += \
+ qmldir
+
+QML_FILES = \
+ ApplicationWindow.qml \
+ BusyIndicator.qml \
+ Button.qml \
+ CheckBox.qml \
+ Frame.qml \
+ GroupBox.qml \
+ Label.qml \
+ PageIndicator.qml \
+ ProgressBar.qml \
+ RadioButton.qml \
+ ScrollBar.qml \
+ ScrollIndicator.qml \
+ Slider.qml \
+ SpinBox.qml \
+ StackView.js \
+ StackView.qml \
+ StackViewDelegate.qml \
+ StackViewTransition.qml \
+ Switch.qml \
+ TabBar.qml \
+ TabButton.qml \
+ TabView.qml \
+ TextArea.qml \
+ TextField.qml \
+ ToggleButton.qml \
+ ToolBar.qml \
+ ToolButton.qml
+
+SOURCES += \
+ $$PWD/qtquickcontrols2plugin.cpp
+
+RESOURCES += \
+ $$PWD/qtquickcontrols2plugin.qrc
+
+CONFIG += no_cxx_module
+load(qml_plugin)
diff --git a/src/imports/controls/images/spinner_large.png b/src/imports/controls/images/spinner_large.png
new file mode 100644
index 00000000..bfd1b637
--- /dev/null
+++ b/src/imports/controls/images/spinner_large.png
Binary files differ
diff --git a/src/imports/controls/images/spinner_medium.png b/src/imports/controls/images/spinner_medium.png
new file mode 100644
index 00000000..41409d45
--- /dev/null
+++ b/src/imports/controls/images/spinner_medium.png
Binary files differ
diff --git a/src/imports/controls/images/spinner_small.png b/src/imports/controls/images/spinner_small.png
new file mode 100644
index 00000000..2f6048e4
--- /dev/null
+++ b/src/imports/controls/images/spinner_small.png
Binary files differ
diff --git a/src/imports/controls/qmldir b/src/imports/controls/qmldir
new file mode 100644
index 00000000..fcd8700d
--- /dev/null
+++ b/src/imports/controls/qmldir
@@ -0,0 +1,29 @@
+module QtQuick.Controls
+plugin qtquickcontrols2plugin
+classname QtQuickControls2Plugin
+ApplicationWindow 2.0 ApplicationWindow.qml
+BusyIndicator 2.0 BusyIndicator.qml
+Button 2.0 Button.qml
+CheckBox 2.0 CheckBox.qml
+Frame 2.0 Frame.qml
+GroupBox 2.0 GroupBox.qml
+Label 2.0 Label.qml
+PageIndicator 2.0 PageIndicator.qml
+ProgressBar 2.0 ProgressBar.qml
+RadioButton 2.0 RadioButton.qml
+ScrollBar 2.0 ScrollBar.qml
+ScrollIndicator 2.0 ScrollIndicator.qml
+Slider 2.0 Slider.qml
+SpinBox 2.0 SpinBox.qml
+StackView 2.0 StackView.qml
+StackViewDelegate 2.0 StackViewDelegate.qml
+StackViewTransition 2.0 StackViewTransition.qml
+Switch 2.0 Switch.qml
+TabBar 2.0 TabBar.qml
+TabButton 2.0 TabButton.qml
+TabView 2.0 TabView.qml
+TextArea 2.0 TextArea.qml
+TextField 2.0 TextField.qml
+ToggleButton 2.0 ToggleButton.qml
+ToolBar 2.0 ToolBar.qml
+ToolButton 2.0 ToolButton.qml
diff --git a/src/imports/controls/qtquickcontrols2plugin.cpp b/src/imports/controls/qtquickcontrols2plugin.cpp
new file mode 100644
index 00000000..84a02f54
--- /dev/null
+++ b/src/imports/controls/qtquickcontrols2plugin.cpp
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick 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 <QtQml/qqmlextensionplugin.h>
+
+#include <QtQuickControls/private/qquickabstractapplicationwindow_p.h>
+#include <QtQuickControls/private/qquickabstractbusyindicator_p.h>
+#include <QtQuickControls/private/qquickabstractbutton_p.h>
+#include <QtQuickControls/private/qquickabstractcheckbox_p.h>
+#include <QtQuickControls/private/qquickabstractframe_p.h>
+#include <QtQuickControls/private/qquickabstractgroupbox_p.h>
+#include <QtQuickControls/private/qquickabstractpageindicator_p.h>
+#include <QtQuickControls/private/qquickabstractprogressbar_p.h>
+#include <QtQuickControls/private/qquickabstractradiobutton_p.h>
+#include <QtQuickControls/private/qquickabstractscrollbar_p.h>
+#include <QtQuickControls/private/qquickabstractscrollindicator_p.h>
+#include <QtQuickControls/private/qquickabstractslider_p.h>
+#include <QtQuickControls/private/qquickabstractspinbox_p.h>
+#include <QtQuickControls/private/qquickabstractstackview_p.h>
+#include <QtQuickControls/private/qquickabstractswitch_p.h>
+#include <QtQuickControls/private/qquickabstracttabbar_p.h>
+#include <QtQuickControls/private/qquickabstracttabbutton_p.h>
+#include <QtQuickControls/private/qquickabstracttabview_p.h>
+#include <QtQuickControls/private/qquickabstracttextarea_p.h>
+#include <QtQuickControls/private/qquickabstracttextfield_p.h>
+#include <QtQuickControls/private/qquickabstracttogglebutton_p.h>
+#include <QtQuickControls/private/qquickabstracttoolbar_p.h>
+
+#include <QtQuickControls/private/qquickcontrol_p.h>
+#include <QtQuickControls/private/qquickexclusivegroup_p.h>
+#include <QtQuickControls/private/qquickpadding_p.h>
+#include <QtQuickControls/private/qquickstyle_p.h>
+
+void initResources()
+{
+ Q_INIT_RESOURCE(qtquickcontrols2plugin);
+}
+
+QT_BEGIN_NAMESPACE
+
+class QtQuickControls2Plugin: public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0")
+
+public:
+ void registerTypes(const char *uri);
+ void initializeEngine(QQmlEngine *engine, const char *uri);
+};
+
+void QtQuickControls2Plugin::registerTypes(const char *uri)
+{
+ qmlRegisterType<QQuickAbstractApplicationWindow>(uri, 2, 0, "AbstractApplicationWindow");
+ qmlRegisterType<QQuickAbstractBusyIndicator>(uri, 2, 0, "AbstractBusyIndicator");
+ qmlRegisterType<QQuickAbstractButton>(uri, 2, 0, "AbstractButton");
+ qmlRegisterType<QQuickAbstractCheckBox>(uri, 2, 0, "AbstractCheckBox");
+ qmlRegisterType<QQuickAbstractFrame>(uri, 2, 0, "AbstractFrame");
+ qmlRegisterType<QQuickAbstractGroupBox>(uri, 2, 0, "AbstractGroupBox");
+ qmlRegisterType<QQuickAbstractPageIndicator>(uri, 2, 0, "AbstractPageIndicator");
+ qmlRegisterType<QQuickAbstractProgressBar>(uri, 2, 0, "AbstractProgressBar");
+ qmlRegisterType<QQuickAbstractRadioButton>(uri, 2, 0, "AbstractRadioButton");
+ qmlRegisterType<QQuickAbstractScrollBar>(uri, 2, 0, "AbstractScrollBar");
+ qmlRegisterType<QQuickAbstractScrollIndicator>(uri, 2, 0, "AbstractScrollIndicator");
+ qmlRegisterType<QQuickAbstractSlider>(uri, 2, 0, "AbstractSlider");
+ qmlRegisterType<QQuickAbstractSpinBox>(uri, 2, 0, "AbstractSpinBox");
+ qmlRegisterType<QQuickAbstractStackView>(uri, 2, 0, "AbstractStackView");
+ qmlRegisterType<QQuickAbstractSwitch>(uri, 2, 0, "AbstractSwitch");
+ qmlRegisterType<QQuickAbstractTabBar>(uri, 2, 0, "AbstractTabBar");
+ qmlRegisterType<QQuickAbstractTabButton>(uri, 2, 0, "AbstractTabButton");
+ qmlRegisterType<QQuickAbstractTabView>(uri, 2, 0, "AbstractTabView");
+ qmlRegisterType<QQuickAbstractTextArea>(uri, 2, 0, "AbstractTextArea");
+ qmlRegisterType<QQuickAbstractTextField>(uri, 2, 0, "AbstractTextField");
+ qmlRegisterType<QQuickAbstractToggleButton>(uri, 2, 0, "AbstractToggleButton");
+ qmlRegisterType<QQuickAbstractToolBar>(uri, 2, 0, "AbstractToolBar");
+
+ qmlRegisterUncreatableType<QQuickExclusiveAttached>(uri, 2, 0, "Exclusive", "Exclusive is an attached property");
+ qmlRegisterUncreatableType<QQuickStackAttached>(uri, 2, 0, "Stack", "Stack is an attached property");
+ qmlRegisterUncreatableType<QQuickTabAttached>(uri, 2, 0, "Tab", "Tab is an attached property");
+
+ qmlRegisterType<QQuickControl>(uri, 2, 0, "Control");
+ qmlRegisterType<QQuickExclusiveGroup>(uri, 2, 0, "ExclusiveGroup");
+ qmlRegisterType<QQuickPadding>(uri, 2, 0, "Padding");
+ qmlRegisterType<QQuickStyle>(uri, 2, 0, "Style");
+}
+
+void QtQuickControls2Plugin::initializeEngine(QQmlEngine *engine, const char *uri)
+{
+ Q_UNUSED(engine);
+ Q_UNUSED(uri);
+ initResources();
+}
+
+QT_END_NAMESPACE
+
+#include "qtquickcontrols2plugin.moc"
diff --git a/src/imports/controls/qtquickcontrols2plugin.qrc b/src/imports/controls/qtquickcontrols2plugin.qrc
new file mode 100644
index 00000000..544c42f5
--- /dev/null
+++ b/src/imports/controls/qtquickcontrols2plugin.qrc
@@ -0,0 +1,7 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>images/spinner_small.png</file>
+ <file>images/spinner_medium.png</file>
+ <file>images/spinner_large.png</file>
+</qresource>
+</RCC>
diff --git a/src/imports/extras/Drawer.qml b/src/imports/extras/Drawer.qml
new file mode 100644
index 00000000..6a5a9950
--- /dev/null
+++ b/src/imports/extras/Drawer.qml
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Extras 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$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Controls 2.0
+import QtQuick.Extras 2.0
+
+AbstractDrawer {
+ id: control
+
+ width: parent.width // TODO: Window.width
+ height: parent.height // TODO: Window.height
+
+ background: Rectangle {
+ color: style.shadowColor
+ opacity: position * style.disabledOpacity
+ }
+
+ // TODO: make this a proper transition
+ animation: SmoothedAnimation {
+ velocity: 5
+ }
+}
diff --git a/src/imports/extras/SplitView.qml b/src/imports/extras/SplitView.qml
new file mode 100644
index 00000000..56eb56f4
--- /dev/null
+++ b/src/imports/extras/SplitView.qml
@@ -0,0 +1,556 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Extras 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$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtQuick.Controls 1.2
+import QtQuick.Layouts 1.0
+import QtQuick.Controls.Private 1.0 as Private
+import QtQuick.Window 2.1
+
+/*!
+ \qmltype SplitView
+ \inqmlmodule QtQuick.Controls
+ \since 5.1
+ \ingroup views
+ \brief Lays out items with a draggable splitter between each item.
+
+ \image splitview.png
+
+ SplitView is a control that lays out items horizontally or
+ vertically with a draggable splitter between each item.
+
+ There will always be one (and only one) item in the SplitView that has \l{Layout::fillWidth}{Layout.fillWidth}
+ set to \c true (or \l{Layout::fillHeight}{Layout.fillHeight}, if orientation is Qt.Vertical). This means that the
+ item will get all leftover space when other items have been laid out.
+ By default, the last visible child of the SplitView will have this set, but
+ it can be changed by explicitly setting fillWidth to \c true on another item.
+ As the fillWidth item will automatically be resized to fit the extra space, explicit assignments
+ to width and height will be ignored (but \l{Layout::minimumWidth}{Layout.minimumWidth} and
+ \l{Layout::maximumWidth}{Layout.maximumWidth} will still be respected).
+
+ A handle can belong to the item either on the left or top side, or on the right or bottom side:
+ \list
+ \li If the fillWidth item is to the right: the handle belongs to the left item.
+ \li if the fillWidth item is on the left: the handle belongs to the right item.
+ \endlist
+
+ This will again control which item gets resized when the user drags a handle,
+ and which handle gets hidden when an item is told to hide.
+
+ SplitView supports setting attached Layout properties on child items, which
+ means that you can set the following attached properties for each child:
+ \list
+ \li \l{Layout::minimumWidth}{Layout.minimumWidth}
+ \li \l{Layout::minimumHeight}{Layout.minimumHeight}
+ \li \l{Layout::maximumWidth}{Layout.maximumWidth}
+ \li \l{Layout::maximumHeight}{Layout.maximumHeight}
+ \li \l{Layout::fillWidth}{Layout.fillWidth} (\c true for only one child)
+ \li \l{Layout::fillHeight}{Layout.fillHeight} (\c true for only one child)
+ \endlist
+
+ \note Please import QtQuick.Layout 1.0 in your QML file in order to use the Layout
+ attached properties inside SplitView.
+
+ Example:
+
+ To create a SplitView with three items, and let the center item get superfluous space, one
+ could do the following:
+
+ \qml
+ SplitView {
+ anchors.fill: parent
+ orientation: Qt.Horizontal
+
+ Rectangle {
+ width: 200
+ Layout.maximumWidth: 400
+ color: "lightblue"
+ Text {
+ text: "View 1"
+ anchors.centerIn: parent
+ }
+ }
+ Rectangle {
+ id: centerItem
+ Layout.minimumWidth: 50
+ Layout.fillWidth: true
+ color: "lightgray"
+ Text {
+ text: "View 2"
+ anchors.centerIn: parent
+ }
+ }
+ Rectangle {
+ width: 200
+ color: "lightgreen"
+ Text {
+ text: "View 3"
+ anchors.centerIn: parent
+ }
+ }
+ }
+
+ \endqml
+*/
+
+Item {
+ id: root
+
+ /*!
+ \qmlproperty enumeration SplitView::orientation
+
+ This property holds the orientation of the SplitView.
+ The value can be either \c Qt.Horizontal or \c Qt.Vertical.
+ The default value is \c Qt.Horizontal.
+ */
+ property int orientation: Qt.Horizontal
+
+ /*!
+ This property holds the delegate that will be instantiated between each
+ child item. Inside the delegate the following properties are available:
+
+ \table
+ \row \li readonly property bool styleData.index \li Specifies the index of the splitter handle. The handle
+ between the first and the second item will get index 0,
+ the next handle index 1 etc.
+ \row \li readonly property bool styleData.hovered \li The handle is being hovered.
+ \row \li readonly property bool styleData.pressed \li The handle is being pressed.
+ \row \li readonly property bool styleData.resizing \li The handle is being dragged.
+ \endtable
+
+*/
+ property Component handleDelegate: Rectangle {
+ width: 1
+ height: 1
+ color: Qt.darker(pal.window, 1.5)
+ }
+
+ /*!
+ This property is \c true when the user is resizing any of the items by
+ dragging on the splitter handles.
+ */
+ property bool resizing: false
+
+ /*! \internal */
+ default property alias __contents: contents.data
+ /*! \internal */
+ property alias __items: splitterItems.children
+ /*! \internal */
+ property alias __handles: splitterHandles.children
+
+ clip: true
+ Component.onCompleted: d.init()
+ onWidthChanged: d.updateLayout()
+ onHeightChanged: d.updateLayout()
+ onOrientationChanged: d.changeOrientation()
+
+ /*! Add an item to the end of the view.
+ \since QtQuick.Controls 1.3 */
+ function addItem(item) {
+ d.updateLayoutGuard = true
+
+ d.addItem_impl(item)
+
+ d.calculateImplicitSize()
+ d.updateLayoutGuard = false
+ d.updateFillIndex()
+ }
+
+ SystemPalette { id: pal }
+
+ QtObject {
+ id: d
+
+ readonly property string leftMargin: horizontal ? "leftMargin" : "topMargin"
+ readonly property string topMargin: horizontal ? "topMargin" : "leftMargin"
+ readonly property string rightMargin: horizontal ? "rightMargin" : "bottomMargin"
+
+ property bool horizontal: orientation == Qt.Horizontal
+ readonly property string minimum: horizontal ? "minimumWidth" : "minimumHeight"
+ readonly property string maximum: horizontal ? "maximumWidth" : "maximumHeight"
+ readonly property string otherMinimum: horizontal ? "minimumHeight" : "minimumWidth"
+ readonly property string otherMaximum: horizontal ? "maximumHeight" : "maximumWidth"
+ readonly property string offset: horizontal ? "x" : "y"
+ readonly property string otherOffset: horizontal ? "y" : "x"
+ readonly property string size: horizontal ? "width" : "height"
+ readonly property string otherSize: horizontal ? "height" : "width"
+ readonly property string implicitSize: horizontal ? "implicitWidth" : "implicitHeight"
+ readonly property string implicitOtherSize: horizontal ? "implicitHeight" : "implicitWidth"
+
+ property int fillIndex: -1
+ property bool updateLayoutGuard: true
+
+ function extraMarginSize(item, other) {
+ if (typeof(other) === 'undefined')
+ other = false;
+ if (other === horizontal)
+ // vertical
+ return item.Layout.topMargin + item.Layout.bottomMargin
+ return item.Layout.leftMargin + item.Layout.rightMargin
+ }
+
+ function addItem_impl(item)
+ {
+ // temporarily set fillIndex to new item
+ fillIndex = __items.length
+ if (splitterItems.children.length > 0)
+ handleLoader.createObject(splitterHandles, {"__handleIndex":splitterItems.children.length - 1})
+
+ item.parent = splitterItems
+
+ // should match disconnections in Component.onDestruction
+ item.widthChanged.connect(d.updateLayout)
+ item.heightChanged.connect(d.updateLayout)
+ item.Layout.maximumWidthChanged.connect(d.updateLayout)
+ item.Layout.minimumWidthChanged.connect(d.updateLayout)
+ item.Layout.maximumHeightChanged.connect(d.updateLayout)
+ item.Layout.minimumHeightChanged.connect(d.updateLayout)
+ item.Layout.leftMarginChanged.connect(d.updateLayout)
+ item.Layout.topMarginChanged.connect(d.updateLayout)
+ item.Layout.rightMarginChanged.connect(d.updateLayout)
+ item.Layout.bottomMarginChanged.connect(d.updateLayout)
+ item.visibleChanged.connect(d.updateFillIndex)
+ item.Layout.fillWidthChanged.connect(d.updateFillIndex)
+ item.Layout.fillHeightChanged.connect(d.updateFillIndex)
+ }
+
+ function init()
+ {
+ for (var i=0; i<__contents.length; ++i) {
+ var item = __contents[i];
+ if (!item.hasOwnProperty("x"))
+ continue
+ addItem_impl(item)
+ i-- // item was removed from list
+ }
+
+ d.calculateImplicitSize()
+ d.updateLayoutGuard = false
+ d.updateFillIndex()
+ }
+
+ function updateFillIndex()
+ {
+ if (lastItem.visible !== root.visible)
+ return
+ var policy = (root.orientation === Qt.Horizontal) ? "fillWidth" : "fillHeight"
+ for (var i=0; i<__items.length-1; ++i) {
+ if (__items[i].Layout[policy] === true)
+ break;
+ }
+
+ d.fillIndex = i
+ d.updateLayout()
+ }
+
+ function changeOrientation()
+ {
+ if (__items.length == 0)
+ return;
+ d.updateLayoutGuard = true
+
+ // Swap width/height for items and handles:
+ for (var i=0; i<__items.length; ++i) {
+ var item = __items[i]
+ var tmp = item.x
+ item.x = item.y
+ item.y = tmp
+ tmp = item.width
+ item.width = item.height
+ item.height = tmp
+
+ var handle = __handles[i]
+ if (handle) {
+ tmp = handle.x
+ handle.x = handle.y
+ handle.y = handle.x
+ tmp = handle.width
+ handle.width = handle.height
+ handle.height = tmp
+ }
+ }
+
+ // Change d.horizontal explicit, since the binding will change too late:
+ d.horizontal = orientation == Qt.Horizontal
+ d.updateLayoutGuard = false
+ d.updateFillIndex()
+ }
+
+ function calculateImplicitSize()
+ {
+ var implicitSize = 0
+ var implicitOtherSize = 0
+
+ for (var i=0; i<__items.length; ++i) {
+ var item = __items[i];
+ implicitSize += clampedMinMax(item[d.size], item.Layout[minimum], item.Layout[maximum]) + extraMarginSize(item)
+ var os = clampedMinMax(item[otherSize], item.Layout[otherMinimum], item.Layout[otherMaximum])
+ implicitOtherSize = Math.max(implicitOtherSize, os)
+
+ var handle = __handles[i]
+ if (handle)
+ implicitSize += handle[d.size] //### Can handles have margins??
+ }
+
+ root[d.implicitSize] = implicitSize
+ root[d.implicitOtherSize] = implicitOtherSize + extraMarginSize(item, true)
+ }
+
+ function clampedMinMax(value, minimum, maximum)
+ {
+ if (value < minimum)
+ value = minimum
+ if (value > maximum)
+ value = maximum
+ return value
+ }
+
+ function accumulatedSize(firstIndex, lastIndex, includeFillItemMinimum)
+ {
+ // Go through items and handles, and
+ // calculate their accummulated width.
+ var w = 0
+ for (var i=firstIndex; i<lastIndex; ++i) {
+
+ var item = __items[i]
+ if (item.visible || i == d.fillIndex) {
+ if (i !== d.fillIndex)
+ w += item[d.size] + extraMarginSize(item)
+ else if (includeFillItemMinimum && item.Layout[minimum] !== undefined)
+ w += item.Layout[minimum] + extraMarginSize(item)
+ }
+
+ var handle = __handles[i]
+ if (handle && handle.visible)
+ w += handle[d.size]
+ }
+ return w
+ }
+
+ function updateLayout()
+ {
+ // This function will reposition both handles and
+ // items according to the their width/height:
+ if (__items.length === 0)
+ return;
+ if (!lastItem.visible)
+ return;
+ if (d.updateLayoutGuard === true)
+ return
+ d.updateLayoutGuard = true
+
+ // Ensure all items within their min/max:
+ for (var i=0; i<__items.length; ++i) {
+ if (i !== d.fillIndex) {
+ var item = __items[i];
+ var clampedSize = clampedMinMax(item[d.size], item.Layout[d.minimum], item.Layout[d.maximum])
+ if (clampedSize != item[d.size])
+ item[d.size] = clampedSize
+ }
+ }
+
+ // Set size of fillItem to remaining available space.
+ // Special case: If SplitView size is zero, we leave fillItem with the size
+ // it already got, and assume that SplitView ends up with implicit size as size:
+ if (root[d.size] != 0) {
+ var fillItem = __items[fillIndex]
+ var superfluous = root[d.size] - d.accumulatedSize(0, __items.length, false)
+ fillItem[d.size] = clampedMinMax(superfluous - extraMarginSize(fillItem), fillItem.Layout[minimum], fillItem.Layout[maximum]);
+ }
+
+ // Position items and handles according to their width:
+ var lastVisibleItem, lastVisibleHandle, handle
+ var pos = 0;
+ for (i=0; i<__items.length; ++i) {
+ // Position item to the right of the previous visible handle:
+ item = __items[i];
+ if (item.visible || i == d.fillIndex) {
+ pos += item.Layout[leftMargin]
+ item[d.offset] = pos
+ item[d.otherOffset] = item.Layout[topMargin]
+ item[d.otherSize] = clampedMinMax(root[otherSize], item.Layout[otherMinimum], item.Layout[otherMaximum]) - extraMarginSize(item, true)
+ lastVisibleItem = item
+ pos += Math.max(0, item[d.size]) + item.Layout[rightMargin]
+ }
+
+ handle = __handles[i]
+ if (handle && handle.visible) {
+ handle[d.offset] = pos
+ handle[d.otherOffset] = 0 //### can handles have margins?
+ handle[d.otherSize] = root[d.otherSize]
+ lastVisibleHandle = handle
+ pos += handle[d.size]
+ }
+ }
+
+ d.updateLayoutGuard = false
+ }
+ }
+
+ Component {
+ id: handleLoader
+ Loader {
+ id: itemHandle
+
+ property int __handleIndex: -1
+ property QtObject styleData: QtObject {
+ readonly property int index: __handleIndex
+ readonly property alias hovered: mouseArea.containsMouse
+ readonly property alias pressed: mouseArea.pressed
+ readonly property bool resizing: mouseArea.drag.active
+ onResizingChanged: root.resizing = resizing
+ }
+ property bool resizeLeftItem: (d.fillIndex > __handleIndex)
+ visible: __items[__handleIndex + (resizeLeftItem ? 0 : 1)].visible
+ sourceComponent: handleDelegate
+ onWidthChanged: d.updateLayout()
+ onHeightChanged: d.updateLayout()
+ onXChanged: moveHandle()
+ onYChanged: moveHandle()
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ property real defaultMargin: Private.Settings.hasTouchScreen ? Screen.pixelDensity * 3.5 : 2
+ anchors.leftMargin: (parent.width <= 1) ? -defaultMargin : 0
+ anchors.rightMargin: (parent.width <= 1) ? -defaultMargin : 0
+ anchors.topMargin: (parent.height <= 1) ? -defaultMargin : 0
+ anchors.bottomMargin: (parent.height <= 1) ? -defaultMargin : 0
+ hoverEnabled: true
+ drag.threshold: 0
+ drag.target: parent
+ drag.axis: root.orientation === Qt.Horizontal ? Drag.XAxis : Drag.YAxis
+ cursorShape: root.orientation === Qt.Horizontal ? Qt.SplitHCursor : Qt.SplitVCursor
+ }
+
+ function moveHandle() {
+ // Moving the handle means resizing an item. Which one,
+ // left or right, depends on where the fillItem is.
+ // 'updateLayout' will be overridden in case new width violates max/min.
+ // 'updateLayout' will be triggered when an item changes width.
+ if (d.updateLayoutGuard)
+ return
+
+ var leftHandle, leftItem, rightItem, rightHandle
+ var leftEdge, rightEdge, newWidth, leftStopX, rightStopX
+ var i
+
+ if (resizeLeftItem) {
+ // Ensure that the handle is not crossing other handles. So
+ // find the first visible handle to the left to determine the left edge:
+ leftEdge = 0
+ for (i=__handleIndex-1; i>=0; --i) {
+ leftHandle = __handles[i]
+ if (leftHandle.visible) {
+ leftEdge = leftHandle[d.offset] + leftHandle[d.size]
+ break;
+ }
+ }
+
+ // Ensure: leftStopX >= itemHandle[d.offset] >= rightStopX
+ var min = d.accumulatedSize(__handleIndex+1, __items.length, true)
+ rightStopX = root[d.size] - min - itemHandle[d.size]
+ leftStopX = Math.max(leftEdge, itemHandle[d.offset])
+ itemHandle[d.offset] = Math.min(rightStopX, Math.max(leftStopX, itemHandle[d.offset]))
+
+ newWidth = itemHandle[d.offset] - leftEdge
+ leftItem = __items[__handleIndex]
+ // The next line will trigger 'updateLayout':
+ leftItem[d.size] = newWidth
+ } else {
+ // Resize item to the right.
+ // Ensure that the handle is not crossing other handles. So
+ // find the first visible handle to the right to determine the right edge:
+ rightEdge = root[d.size]
+ for (i=__handleIndex+1; i<__handles.length; ++i) {
+ rightHandle = __handles[i]
+ if (rightHandle.visible) {
+ rightEdge = rightHandle[d.offset]
+ break;
+ }
+ }
+
+ // Ensure: leftStopX <= itemHandle[d.offset] <= rightStopX
+ min = d.accumulatedSize(0, __handleIndex+1, true)
+ leftStopX = min - itemHandle[d.size]
+ rightStopX = Math.min((rightEdge - itemHandle[d.size]), itemHandle[d.offset])
+ itemHandle[d.offset] = Math.max(leftStopX, Math.min(itemHandle[d.offset], rightStopX))
+
+ newWidth = rightEdge - (itemHandle[d.offset] + itemHandle[d.size])
+ rightItem = __items[__handleIndex+1]
+ // The next line will trigger 'updateLayout':
+ rightItem[d.size] = newWidth
+ }
+ }
+ }
+ }
+
+ Item {
+ id: contents
+ visible: false
+ anchors.fill: parent
+ }
+ Item {
+ id: splitterItems
+ anchors.fill: parent
+ }
+ Item {
+ id: splitterHandles
+ anchors.fill: parent
+ }
+
+ Item {
+ id: lastItem
+ onVisibleChanged: d.updateFillIndex()
+ }
+
+ Component.onDestruction: {
+ for (var i=0; i<splitterItems.children.length; ++i) {
+ var item = splitterItems.children[i];
+
+ // should match connections in init()
+ item.widthChanged.disconnect(d.updateLayout)
+ item.heightChanged.disconnect(d.updateLayout)
+ item.Layout.maximumWidthChanged.disconnect(d.updateLayout)
+ item.Layout.minimumWidthChanged.disconnect(d.updateLayout)
+ item.Layout.maximumHeightChanged.disconnect(d.updateLayout)
+ item.Layout.minimumHeightChanged.disconnect(d.updateLayout)
+ item.visibleChanged.disconnect(d.updateFillIndex)
+ item.Layout.fillWidthChanged.disconnect(d.updateFillIndex)
+ item.Layout.fillHeightChanged.disconnect(d.updateFillIndex)
+ }
+ }
+}
diff --git a/src/imports/extras/extras.pro b/src/imports/extras/extras.pro
new file mode 100644
index 00000000..18a2da18
--- /dev/null
+++ b/src/imports/extras/extras.pro
@@ -0,0 +1,19 @@
+TARGET = qtquickextras2plugin
+TARGETPATH = QtQuick/Extras.2
+IMPORT_VERSION = 2.0
+
+QT += qml quick
+QT += core-private gui-private qml-private quick-private quickcontrols-private quickextras-private
+
+OTHER_FILES += \
+ qmldir
+
+QML_FILES = \
+ Drawer.qml \
+ SplitView.qml
+
+SOURCES += \
+ $$PWD/qtquickextras2plugin.cpp
+
+CONFIG += no_cxx_module
+load(qml_plugin)
diff --git a/src/imports/extras/qmldir b/src/imports/extras/qmldir
new file mode 100644
index 00000000..850e5a72
--- /dev/null
+++ b/src/imports/extras/qmldir
@@ -0,0 +1,5 @@
+module QtQuick.Extras
+plugin qtquickextras2plugin
+classname QtQuickExtras2Plugin
+Drawer 2.0 Drawer.qml
+SplitView 2.0 SplitView.qml
diff --git a/src/imports/extras/qtquickextras2plugin.cpp b/src/imports/extras/qtquickextras2plugin.cpp
new file mode 100644
index 00000000..08c62dc3
--- /dev/null
+++ b/src/imports/extras/qtquickextras2plugin.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Extras 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 <QtQml/qqmlextensionplugin.h>
+
+#include <QtQuickExtras/private/qquickabstractdrawer_p.h>
+#include <QtQuickExtras/private/qquickabstractsplitview_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QtQuickExtras2Plugin: public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0")
+
+public:
+ void registerTypes(const char *uri);
+};
+
+void QtQuickExtras2Plugin::registerTypes(const char *uri)
+{
+ qmlRegisterType<QQuickAbstractDrawer>(uri, 2, 0, "AbstractDrawer");
+ qmlRegisterType<QQuickAbstractSplitView>(uri, 2, 0, "AbstractSplitView");
+}
+
+QT_END_NAMESPACE
+
+#include "qtquickextras2plugin.moc"
diff --git a/src/imports/imports.pro b/src/imports/imports.pro
new file mode 100644
index 00000000..d141f378
--- /dev/null
+++ b/src/imports/imports.pro
@@ -0,0 +1,5 @@
+TEMPLATE = subdirs
+SUBDIRS += \
+ controls \
+ calendar \
+ extras