diff options
20 files changed, 740 insertions, 0 deletions
diff --git a/src/imports/controls/ItemDelegate.qml b/src/imports/controls/ItemDelegate.qml new file mode 100644 index 00000000..5735d0b3 --- /dev/null +++ b/src/imports/controls/ItemDelegate.qml @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.templates 1.0 as T + +T.ItemDelegate { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + (label ? label.implicitWidth : 0) + + (indicator ? indicator.implicitWidth : 0) + + (label && indicator ? spacing : 0) + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + Math.max(label ? label.implicitHeight : 0, + indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) + + padding: 12 + spacing: 12 + + //! [label] + label: Text { + x: control.mirrored ? control.width - width - control.rightPadding : control.leftPadding + y: control.topPadding + width: control.availableWidth - (control.checkable ? indicator.width + control.spacing : 0) + height: control.availableHeight + + text: control.text + font: control.font + color: control.enabled ? "#26282a" : "#bdbebf" + elide: Text.ElideRight + visible: control.text + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + } + //! [label] + + //! [indicator] + indicator: Image { + x: control.mirrored ? control.leftPadding : control.width - width - control.rightPadding + y: control.topPadding + (control.availableHeight - height) / 2 + + visible: control.checked + source: control.checkable ? "qrc:/images/check.png" : "" + } + //! [indicator] + + //! [background] + background: Rectangle { + implicitWidth: 100 + implicitHeight: 40 + color: control.pressed ? "#bdbebf" : "transparent" + } + //! [background] +} diff --git a/src/imports/controls/controls.pri b/src/imports/controls/controls.pri index 41f25c45..530ca6f4 100644 --- a/src/imports/controls/controls.pri +++ b/src/imports/controls/controls.pri @@ -7,6 +7,7 @@ QML_FILES = \ Drawer.qml \ Frame.qml \ GroupBox.qml \ + ItemDelegate.qml \ Label.qml \ PageIndicator.qml \ ProgressBar.qml \ diff --git a/src/imports/controls/doc/images/qtlabscontrols-itemdelegate-background.png b/src/imports/controls/doc/images/qtlabscontrols-itemdelegate-background.png Binary files differnew file mode 100644 index 00000000..a311c109 --- /dev/null +++ b/src/imports/controls/doc/images/qtlabscontrols-itemdelegate-background.png diff --git a/src/imports/controls/doc/images/qtlabscontrols-itemdelegate-indicator.png b/src/imports/controls/doc/images/qtlabscontrols-itemdelegate-indicator.png Binary files differnew file mode 100644 index 00000000..b458b1a0 --- /dev/null +++ b/src/imports/controls/doc/images/qtlabscontrols-itemdelegate-indicator.png diff --git a/src/imports/controls/doc/images/qtlabscontrols-itemdelegate-label.png b/src/imports/controls/doc/images/qtlabscontrols-itemdelegate-label.png Binary files differnew file mode 100644 index 00000000..6b43db0f --- /dev/null +++ b/src/imports/controls/doc/images/qtlabscontrols-itemdelegate-label.png diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-itemdelegate-background.qml b/src/imports/controls/doc/snippets/qtlabscontrols-itemdelegate-background.qml new file mode 100644 index 00000000..10d5696e --- /dev/null +++ b/src/imports/controls/doc/snippets/qtlabscontrols-itemdelegate-background.qml @@ -0,0 +1,39 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.labs.controls 1.0 + +ItemDelegate { + text: "ItemDelegate" + checked: true + checkable: true + background: Rectangle { + color: 'transparent' + border.color: 'red' + } +} diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-itemdelegate-indicator.qml b/src/imports/controls/doc/snippets/qtlabscontrols-itemdelegate-indicator.qml new file mode 100644 index 00000000..fb80957d --- /dev/null +++ b/src/imports/controls/doc/snippets/qtlabscontrols-itemdelegate-indicator.qml @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.labs.controls 1.0 + +ItemDelegate { + text: "ItemDelegate" + checked: true + checkable: true + Rectangle { + anchors.fill: indicator + color: "transparent" + border.color: "red" + } +} diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-itemdelegate-label.qml b/src/imports/controls/doc/snippets/qtlabscontrols-itemdelegate-label.qml new file mode 100644 index 00000000..696560a5 --- /dev/null +++ b/src/imports/controls/doc/snippets/qtlabscontrols-itemdelegate-label.qml @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.labs.controls 1.0 + +ItemDelegate { + text: "ItemDelegate" + checked: true + checkable: true + Rectangle { + anchors.fill: label + color: "transparent" + border.color: "red" + } +} diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-itemdelegate.qml b/src/imports/controls/doc/snippets/qtlabscontrols-itemdelegate.qml new file mode 100644 index 00000000..d02f722a --- /dev/null +++ b/src/imports/controls/doc/snippets/qtlabscontrols-itemdelegate.qml @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.labs.controls 1.0 + +//! [1] +ListView { + width: 160 + height: 240 + + model: Qt.fontFamilies() + + delegate: ItemDelegate { + text: modelData + width: parent.width + onClicked: console.log("clicked:", modelData) + } + + ScrollIndicator.vertical: ScrollIndicator { } +} +//! [1] diff --git a/src/imports/controls/doc/src/qtlabscontrols-customize.qdoc b/src/imports/controls/doc/src/qtlabscontrols-customize.qdoc index b6e28af7..dddb3a8a 100644 --- a/src/imports/controls/doc/src/qtlabscontrols-customize.qdoc +++ b/src/imports/controls/doc/src/qtlabscontrols-customize.qdoc @@ -170,6 +170,31 @@ \snippet GroupBox.qml label + \section1 Customizing ItemDelegate + + ItemDelegate consists of three visual items: \l {Control::background}{background}, + \l {AbstractButton::label}{label} and \l {AbstractButton::indicator}{indicator}. + The indicator is only visible for \l {AbstractButton::checkable}{checkable} items. + + \section3 Background + + \image qtlabscontrols-itemdelegate-background.png + + \snippet ItemDelegate.qml background + + \section3 Label + + \image qtlabscontrols-itemdelegate-label.png + + \snippet ItemDelegate.qml label + + \section3 Indicator + + \image qtlabscontrols-itemdelegate-indicator.png + + \snippet ItemDelegate.qml indicator + + \section1 Customizing Label Label can have a visual \l {Label::background}{background} item. diff --git a/src/imports/controls/material/ItemDelegate.qml b/src/imports/controls/material/ItemDelegate.qml new file mode 100644 index 00000000..57ec374c --- /dev/null +++ b/src/imports/controls/material/ItemDelegate.qml @@ -0,0 +1,202 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.templates 1.0 as T +import Qt.labs.controls.material 1.0 + +T.ItemDelegate { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + (label ? label.implicitWidth : 0) + + (indicator ? indicator.implicitWidth : 0) + + (label && indicator ? spacing : 0) + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + Math.max(label ? label.implicitHeight : 0, + indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) + + padding: 16 + spacing: 16 + + //! [indicator] + indicator: Rectangle { + id: indicatorItem + x: text ? (control.mirrored ? control.width - width - control.rightPadding : control.leftPadding) : control.leftPadding + (control.availableWidth - width) / 2 + y: control.topPadding + (control.availableHeight - height) / 2 + implicitWidth: 20 + implicitHeight: 20 + border.color: control.Material.secondaryTextColor + radius: 2 + + visible: control.checkable + + Component.onCompleted: { + color = control.checked || control.pressed ? control.Material.accentColor : "transparent"; + border.width = control.checked || control.pressed ? 0 : 2; + } + + Ripple { + width: parent.width + height: width + control: control + colored: control.checked + opacity: control.pressed ? 1 : 0 + } + + // TODO: This needs to be transparent + Image { + id: checkImage + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + source: "qrc:/qt-project.org/imports/Qt/labs/controls/material/images/check.png" + fillMode: Image.PreserveAspectFit + + Component.onCompleted: { + width = control.checked || control.pressed ? 16 : 0; + height = control.checked || control.pressed ? 16 : 0; + } + } + + Connections { + target: control + onCheckedChanged: { + pressScaleAnimation.start(); + if (control.checked) + checkedAnimation.start(); + else + uncheckedAnimation.start(); + } + } + + SequentialAnimation { + id: pressScaleAnimation + + NumberAnimation { + target: indicatorItem + property: "scale" + // Go down 2 pixels in size. + to: 1 - 2 / indicatorItem.width + duration: 120 + } + NumberAnimation { + target: indicatorItem + property: "scale" + to: 1 + duration: 120 + } + } + + SequentialAnimation { + id: checkedAnimation + + PropertyAction { + target: indicatorItem.border + property: "color" + value: control.Material.accentColor + } + NumberAnimation { + target: indicatorItem.border + property: "width" + from: 2 + to: indicatorItem.width / 2 + easing.type: Easing.OutCubic + duration: 100 + } + NumberAnimation { + target: checkImage + properties: "width, height" + from: 0 + to: 16 + duration: 100 + } + } + + SequentialAnimation { + id: uncheckedAnimation + + PropertyAction { + target: indicatorItem.border + property: "color" + value: control.Material.secondaryTextColor + } + NumberAnimation { + target: checkImage + properties: "width, height" + from: 16 + to: 0 + duration: 100 + } + NumberAnimation { + target: indicatorItem.border + property: "width" + from: indicatorItem.width / 2 + to: 2 + easing.type: Easing.OutCubic + duration: 100 + } + PropertyAction { + target: indicatorItem + property: "color" + value: "transparent" + } + } + } + //! [indicator] + + //! [label] + label: Text { + x: control.mirrored || !control.checkable ? control.leftPadding : (indicator.x + indicator.width + control.spacing) + y: control.topPadding + width: control.availableWidth - (control.checkable ? indicator.width + control.spacing : 0) + height: control.availableHeight + + text: control.text + font: control.font + color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor + elide: Text.ElideRight + visible: control.text + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + } + //! [label] + + //! [background] + background: Rectangle { + color: control.pressed ? control.Material.flatButtonPressColor : control.Material.backgroundColor + } + //! [background] +} diff --git a/src/imports/controls/material/material.pri b/src/imports/controls/material/material.pri index e2c09777..2ed4604c 100644 --- a/src/imports/controls/material/material.pri +++ b/src/imports/controls/material/material.pri @@ -15,6 +15,7 @@ QML_FILES += \ $$PWD/Drawer.qml \ $$PWD/Frame.qml \ $$PWD/GroupBox.qml \ + $$PWD/ItemDelegate.qml \ $$PWD/Label.qml \ $$PWD/PageIndicator.qml \ $$PWD/ProgressBar.qml \ diff --git a/src/imports/controls/qtlabscontrolsplugin.cpp b/src/imports/controls/qtlabscontrolsplugin.cpp index 9bfb8010..20f1750e 100644 --- a/src/imports/controls/qtlabscontrolsplugin.cpp +++ b/src/imports/controls/qtlabscontrolsplugin.cpp @@ -85,6 +85,7 @@ void QtLabsControlsPlugin::registerTypes(const char *uri) qmlRegisterType(selector.select(QStringLiteral("/Drawer.qml")), uri, 1, 0, "Drawer"); qmlRegisterType(selector.select(QStringLiteral("/Frame.qml")), uri, 1, 0, "Frame"); qmlRegisterType(selector.select(QStringLiteral("/GroupBox.qml")), uri, 1, 0, "GroupBox"); + qmlRegisterType(selector.select(QStringLiteral("/ItemDelegate.qml")), uri, 1, 0, "ItemDelegate"); qmlRegisterType(selector.select(QStringLiteral("/Label.qml")), uri, 1, 0, "Label"); qmlRegisterType(selector.select(QStringLiteral("/PageIndicator.qml")), uri, 1, 0, "PageIndicator"); qmlRegisterType(selector.select(QStringLiteral("/ProgressBar.qml")), uri, 1, 0, "ProgressBar"); diff --git a/src/imports/controls/universal/ItemDelegate.qml b/src/imports/controls/universal/ItemDelegate.qml new file mode 100644 index 00000000..bb1f6672 --- /dev/null +++ b/src/imports/controls/universal/ItemDelegate.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.templates 1.0 as T +import Qt.labs.controls.universal 1.0 + +T.ItemDelegate { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + (label ? label.implicitWidth : 0) + + (indicator ? indicator.implicitWidth : 0) + + (label && indicator ? spacing : 0) + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + Math.max(label ? label.implicitHeight : 0, + indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) + + spacing: 12 + + topPadding: 11 + leftPadding: 12 + rightPadding: 12 + bottomPadding: 13 + + font.pixelSize: Universal.fontSize + font.family: Universal.fontFamily + + //! [indicator] + indicator: Image { + x: text ? (control.mirrored ? control.width - width - control.rightPadding : control.leftPadding) : control.leftPadding + (control.availableWidth - width) / 2 + y: control.topPadding + (control.availableHeight - height) / 2 + + visible: control.checked + source: !control.checkable ? "" : "image://universal/checkmark/" + (!control.enabled ? control.Universal.baseLowColor : control.pressed ? control.Universal.baseHighColor : control.Universal.baseMediumHighColor) + } + //! [indicator] + + //! [label] + label: Text { + x: control.mirrored || !control.checkable ? control.leftPadding : (indicator.x + indicator.width + control.spacing) + y: control.topPadding + width: control.availableWidth - (control.checkable ? indicator.width + control.spacing : 0) + height: control.availableHeight + + text: control.text + font: control.font + elide: Text.ElideRight + visible: control.text + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + renderType: Text.NativeRendering + + color: !control.enabled ? control.Universal.baseLowColor : control.Universal.baseHighColor + } + //! [label] + + //! [background] + background: Rectangle { + visible: control.pressed + color: control.Universal.listMediumColor + } + //! [background] +} diff --git a/src/imports/controls/universal/universal.pri b/src/imports/controls/universal/universal.pri index 38e94fb5..16e52d17 100644 --- a/src/imports/controls/universal/universal.pri +++ b/src/imports/controls/universal/universal.pri @@ -6,6 +6,7 @@ QML_FILES += \ $$PWD/Dial.qml \ $$PWD/Frame.qml \ $$PWD/GroupBox.qml \ + $$PWD/ItemDelegate.qml \ $$PWD/Label.qml \ $$PWD/PageIndicator.qml \ $$PWD/ProgressBar.qml \ diff --git a/src/imports/templates/qtlabstemplatesplugin.cpp b/src/imports/templates/qtlabstemplatesplugin.cpp index 1f8d0949..6db254b9 100644 --- a/src/imports/templates/qtlabstemplatesplugin.cpp +++ b/src/imports/templates/qtlabstemplatesplugin.cpp @@ -47,6 +47,7 @@ #include <QtLabsTemplates/private/qquickdrawer_p.h> #include <QtLabsTemplates/private/qquickframe_p.h> #include <QtLabsTemplates/private/qquickgroupbox_p.h> +#include <QtLabsTemplates/private/qquickitemdelegate_p.h> #include <QtLabsTemplates/private/qquicklabel_p.h> #include <QtLabsTemplates/private/qquickpageindicator_p.h> #include <QtLabsTemplates/private/qquickpanel_p.h> @@ -93,6 +94,7 @@ void QtLabsTemplatesPlugin::registerTypes(const char *uri) qmlRegisterType<QQuickDrawer>(uri, 1, 0, "Drawer"); qmlRegisterType<QQuickFrame>(uri, 1, 0, "Frame"); qmlRegisterType<QQuickGroupBox>(uri, 1, 0, "GroupBox"); + qmlRegisterType<QQuickItemDelegate>(uri, 1, 0, "ItemDelegate"); qmlRegisterType<QQuickLabel>(uri, 1, 0, "Label"); qmlRegisterType<QQuickPageIndicator>(uri, 1, 0, "PageIndicator"); qmlRegisterType<QQuickPanel>(uri, 1, 0, "Panel"); diff --git a/src/templates/qquickitemdelegate.cpp b/src/templates/qquickitemdelegate.cpp new file mode 100644 index 00000000..7e13b638 --- /dev/null +++ b/src/templates/qquickitemdelegate.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 Labs Templates 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 "qquickitemdelegate_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \qmltype ItemDelegate + \inherits AbstractButton + \instantiates QQuickItemDelegate + \inqmlmodule Qt.labs.controls + \brief An item delegate. + + ItemDelegate presents a standard view item. It can be used as a delegate + in various views and controls, such as \l ListView and \l ComboBox. + + ItemDelegate inherits its API from AbstractButton. For instance, you can set + \l {AbstractButton::text}{text}, make items \l {AbstractButton::checkable}{checkable}, + and react to \l {AbstractButton::clicked}{clicks} using the AbstractButton API. + + \snippet qtlabscontrols-itemdelegate.qml 1 + + \sa {Customizing ItemDelegate} +*/ + +QQuickItemDelegate::QQuickItemDelegate(QQuickItem *parent) : QQuickAbstractButton(parent) +{ +} + +#ifndef QT_NO_ACCESSIBILITY +QAccessible::Role QQuickItemDelegate::accessibleRole() const +{ + return QAccessible::ListItem; +} +#endif + +QT_END_NAMESPACE diff --git a/src/templates/qquickitemdelegate_p.h b/src/templates/qquickitemdelegate_p.h new file mode 100644 index 00000000..e3f415a6 --- /dev/null +++ b/src/templates/qquickitemdelegate_p.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Templates module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQUICKITEMDELEGATE_P_H +#define QQUICKITEMDELEGATE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtLabsTemplates/private/qquickabstractbutton_p.h> + +QT_BEGIN_NAMESPACE + +class QQuickItemDelegatePrivate; + +class Q_LABSTEMPLATES_EXPORT QQuickItemDelegate : public QQuickAbstractButton +{ + Q_OBJECT + +public: + explicit QQuickItemDelegate(QQuickItem *parent = Q_NULLPTR); + +protected: +#ifndef QT_NO_ACCESSIBILITY + QAccessible::Role accessibleRole() const Q_DECL_OVERRIDE; +#endif + +private: + Q_DISABLE_COPY(QQuickItemDelegate) + Q_DECLARE_PRIVATE(QQuickItemDelegate) +}; + +Q_DECLARE_TYPEINFO(QQuickItemDelegate, Q_COMPLEX_TYPE); + +QT_END_NAMESPACE + +#endif // QQUICKITEMDELEGATE_P_H diff --git a/src/templates/templates.pri b/src/templates/templates.pri index 34344e03..0bcde3da 100644 --- a/src/templates/templates.pri +++ b/src/templates/templates.pri @@ -17,6 +17,7 @@ HEADERS += \ $$PWD/qquickframe_p.h \ $$PWD/qquickframe_p_p.h \ $$PWD/qquickgroupbox_p.h \ + $$PWD/qquickitemdelegate_p.h \ $$PWD/qquicklabel_p.h \ $$PWD/qquicklabel_p_p.h \ $$PWD/qquickoverlay_p.h \ @@ -58,6 +59,7 @@ SOURCES += \ $$PWD/qquickdrawer.cpp \ $$PWD/qquickframe.cpp \ $$PWD/qquickgroupbox.cpp \ + $$PWD/qquickitemdelegate.cpp \ $$PWD/qquicklabel.cpp \ $$PWD/qquickoverlay.cpp \ $$PWD/qquickpageindicator.cpp \ diff --git a/tests/auto/sanity/BLACKLIST b/tests/auto/sanity/BLACKLIST index bfa3ebab..b28175af 100644 --- a/tests/auto/sanity/BLACKLIST +++ b/tests/auto/sanity/BLACKLIST @@ -1,5 +1,7 @@ [signalHandlers:material/CheckBox.qml] * +[signalHandlers:material/ItemDelegate.qml] +* [signalHandlers:material/TextArea.qml] * [signalHandlers:material/TextField.qml] @@ -8,6 +10,8 @@ * [anchors:material/CheckBox.qml] * +[anchors:material/ItemDelegate.qml] +* [anchors:material/RadioButton.qml] * [anchors:material/RangeSlider.qml] @@ -18,6 +22,8 @@ * [attachedObjects:material/CheckBox.qml] * +[attachedObjects:material/ItemDelegate.qml] +* [attachedObjects:material/RadioButton.qml] * [attachedObjects:material/RangeSlider.qml] |