aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2015-04-29 09:37:15 +0200
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2015-06-11 14:29:29 +0000
commitdbf0b858952f57be61dc1b2765c05d25e86db546 (patch)
treebf6f8c493be82ab5587c56ef4fef53c687e858c6 /src/imports
parent0b2dc1a4d4824981a6f26fc82dd491dbc1bbbb12 (diff)
Add SwipeView
Based on the old TabView prototype, easy to use together with TabBar. The side-swiping feature will be removed from TabView to keep it simple and light-weight. Change-Id: I214b88688b98897962d335fe00008d222e0656a8 Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'src/imports')
-rw-r--r--src/imports/extras/SwipeView.qml73
-rw-r--r--src/imports/extras/extras.pro3
-rw-r--r--src/imports/extras/qmldir1
-rw-r--r--src/imports/extras/qtquickextras2plugin.cpp2
4 files changed, 78 insertions, 1 deletions
diff --git a/src/imports/extras/SwipeView.qml b/src/imports/extras/SwipeView.qml
new file mode 100644
index 00000000..85e31874
--- /dev/null
+++ b/src/imports/extras/SwipeView.qml
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** 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.6
+import QtQuick.Extras 2.0
+
+AbstractSwipeView {
+ id: control
+
+ property alias spacing: listView.spacing
+
+ contentWidth: listView.implicitWidth
+ contentHeight: listView.contentHeight
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + topPadding + bottomPadding)
+
+ Accessible.role: Accessible.PageTabList
+
+ contentItem: ListView {
+ id: listView
+
+ currentIndex: control.currentIndex
+
+ x: control.leftPadding
+ y: control.topPadding
+ width: parent.width - control.leftPadding - control.rightPadding
+ height: parent.height - control.topPadding - control.bottomPadding
+
+ orientation: Qt.Horizontal
+ snapMode: ListView.SnapOneItem
+ boundsBehavior: Flickable.StopAtBounds
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ preferredHighlightBegin: 0
+ preferredHighlightEnd: 0
+ highlightMoveDuration: 250
+
+ model: control.model
+ }
+}
diff --git a/src/imports/extras/extras.pro b/src/imports/extras/extras.pro
index 437fcab4..675a058f 100644
--- a/src/imports/extras/extras.pro
+++ b/src/imports/extras/extras.pro
@@ -9,7 +9,8 @@ OTHER_FILES += \
qmldir
QML_FILES = \
- Drawer.qml
+ Drawer.qml \
+ SwipeView.qml
SOURCES += \
$$PWD/qtquickextras2plugin.cpp
diff --git a/src/imports/extras/qmldir b/src/imports/extras/qmldir
index ec2bc05a..d21f666e 100644
--- a/src/imports/extras/qmldir
+++ b/src/imports/extras/qmldir
@@ -2,3 +2,4 @@ module QtQuick.Extras
plugin qtquickextras2plugin
classname QtQuickExtras2Plugin
Drawer 2.0 Drawer.qml
+SwipeView 2.0 SwipeView.qml
diff --git a/src/imports/extras/qtquickextras2plugin.cpp b/src/imports/extras/qtquickextras2plugin.cpp
index e2e0d62d..2a099ae2 100644
--- a/src/imports/extras/qtquickextras2plugin.cpp
+++ b/src/imports/extras/qtquickextras2plugin.cpp
@@ -37,6 +37,7 @@
#include <QtQml/qqmlextensionplugin.h>
#include <QtQuickExtras/private/qquickdrawer_p.h>
+#include <QtQuickExtras/private/qquickswipeview_p.h>
QT_BEGIN_NAMESPACE
@@ -52,6 +53,7 @@ public:
void QtQuickExtras2Plugin::registerTypes(const char *uri)
{
qmlRegisterType<QQuickDrawer>(uri, 2, 0, "AbstractDrawer");
+ qmlRegisterType<QQuickSwipeView>(uri, 2, 0, "AbstractSwipeView");
}
QT_END_NAMESPACE