diff options
Diffstat (limited to 'src/imports/controls/doc/snippets')
15 files changed, 411 insertions, 28 deletions
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-action.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-action.qml new file mode 100644 index 00000000..1913e131 --- /dev/null +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-action.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.10 +import QtQuick.Controls 2.3 + +Item { + //! [action] + Action { + id: copyAction + text: qsTr("&Copy") + icon.name: "edit-copy" + shortcut: StandardKey.Copy + onTriggered: window.activeFocusItem.copy() + } + //! [action] + + //! [toolbutton] + ToolButton { + id: toolButton + action: copyAction + } + //! [toolbutton] + + //! [menuitem] + MenuItem { + id: menuItem + action: copyAction + text: qsTr("&Copy selected Text") + } + //! [menuitem] +} diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-button-icononly.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-button-icononly.qml new file mode 100644 index 00000000..32b0797a --- /dev/null +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-button-icononly.qml @@ -0,0 +1,34 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.10 +import QtQuick.Controls 2.3 + +Button { + icon.source: "qrc:/qt-project.org/imports/QtQuick/Controls.2/images/check.png" + display: Button.IconOnly +} diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-button-textbesideicon.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-button-textbesideicon.qml new file mode 100644 index 00000000..870da262 --- /dev/null +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-button-textbesideicon.qml @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.10 +import QtQuick.Controls 2.3 + +Button { + text: "Button" + icon.source: "qrc:/qt-project.org/imports/QtQuick/Controls.2/images/check.png" + display: Button.TextBesideIcon +} diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-button-textonly.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-button-textonly.qml new file mode 100644 index 00000000..fe871639 --- /dev/null +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-button-textonly.qml @@ -0,0 +1,34 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.10 +import QtQuick.Controls 2.3 + +Button { + text: "Button" + display: Button.TextOnly +} diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-menu-custom.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-menu-custom.qml index 7298b4d3..2d05b74a 100644 --- a/src/imports/controls/doc/snippets/qtquickcontrols2-menu-custom.qml +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-menu-custom.qml @@ -25,36 +25,109 @@ ** ****************************************************************************/ -//! [file] -import QtQuick 2.6 -import QtQuick.Controls 2.1 +import QtQuick 2.10 +import QtQuick.Controls 2.3 -Item { +ApplicationWindow { id: window - width: menu.contentItem.width - height: menu.contentItem.height + width: menu.width + height: menu.height visible: true + Component.onCompleted: menu.popup(menu.itemAt(1)) + // Indent it like this so that the indenting in the generated doc is normal. Menu { id: menu - contentItem.parent: window - background: Rectangle { - implicitWidth: 200 - implicitHeight: 200 - color: "#ffffff" - border.color: "#353637" + + Action { text: qsTr("Tool Bar"); checkable: true } + Action { text: qsTr("Side Bar"); checkable: true; checked: true } + Action { text: qsTr("Status Bar"); checkable: true; checked: true } + + MenuSeparator { + contentItem: Rectangle { + implicitWidth: 200 + implicitHeight: 1 + color: "#21be2b" + } } - MenuItem { - text: qsTr("New...") + Menu { + title: qsTr("Advanced") + // ... } - MenuItem { - text: qsTr("Open...") + + topPadding: 2 + bottomPadding: 2 + + delegate: MenuItem { + id: menuItem + implicitWidth: 200 + implicitHeight: 40 + + arrow: Canvas { + x: parent.width - width + implicitWidth: 40 + implicitHeight: 40 + visible: menuItem.subMenu + onPaint: { + var ctx = getContext("2d") + ctx.fillStyle = menuItem.highlighted ? "#ffffff" : "#21be2b" + ctx.moveTo(15, 15) + ctx.lineTo(width - 15, height / 2) + ctx.lineTo(15, height - 15) + ctx.closePath() + ctx.fill() + } + } + + indicator: Item { + implicitWidth: 40 + implicitHeight: 40 + Rectangle { + width: 26 + height: 26 + anchors.centerIn: parent + visible: menuItem.checkable + border.color: "#21be2b" + radius: 3 + Rectangle { + width: 14 + height: 14 + anchors.centerIn: parent + visible: menuItem.checked + color: "#21be2b" + radius: 2 + } + } + } + + contentItem: Text { + leftPadding: menuItem.indicator.width + rightPadding: menuItem.arrow.width + text: menuItem.text + font: menuItem.font + opacity: enabled ? 1.0 : 0.3 + color: menuItem.highlighted ? "#ffffff" : "#21be2b" + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + } + + background: Rectangle { + implicitWidth: 200 + implicitHeight: 40 + opacity: enabled ? 1 : 0.3 + color: menuItem.highlighted ? "#21be2b" : "transparent" + } } - MenuItem { - text: qsTr("Save") + + background: Rectangle { + implicitWidth: 200 + implicitHeight: 40 + color: "#ffffff" + border.color: "#21be2b" + radius: 2 } } -} -//! [file] +} //! [eof] diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-menubar-custom.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-menubar-custom.qml new file mode 100644 index 00000000..513ad440 --- /dev/null +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-menubar-custom.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.10 +import QtQuick.Controls 2.3 + +ApplicationWindow { + id: window + visible: true + width: menuBar.implicitWidth + height: menuBar.height + + Component.onCompleted: menuBar.itemAt(1).highlighted = true + + header: + +// Indent it like this so that the indenting in the generated doc is normal. +MenuBar { + id: menuBar + + Menu { title: qsTr("File") } + Menu { title: qsTr("Edit") } + Menu { title: qsTr("View") } + Menu { title: qsTr("Help") } + + delegate: MenuBarItem { + id: menuBarItem + + contentItem: Text { + text: menuBarItem.text + font: menuBarItem.font + opacity: enabled ? 1.0 : 0.3 + color: menuBarItem.highlighted ? "#ffffff" : "#21be2b" + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + } + + background: Rectangle { + implicitWidth: 40 + implicitHeight: 40 + opacity: enabled ? 1 : 0.3 + color: menuBarItem.highlighted ? "#21be2b" : "transparent" + } + } + + background: Rectangle { + implicitWidth: 40 + implicitHeight: 40 + color: "#ffffff" + + Rectangle { + color: "#21be2b" + width: parent.width + height: 1 + anchors.bottom: parent.bottom + } + } +} +} //! [eof] diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-menubar.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-menubar.qml new file mode 100644 index 00000000..550680f6 --- /dev/null +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-menubar.qml @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.10 +import QtQuick.Controls 2.3 + +//! [begin] +ApplicationWindow { + id: window + width: 320 + height: 260 + visible: true + + //! [skipfrom] + Component.onCompleted: { + menuBar.itemAt(0).triggered() + menuBar.itemAt(0).menu.itemAt(2).highlighted = true + } + //! [skipto] + + menuBar: MenuBar { + Menu { + title: qsTr("&File") + Action { text: qsTr("&New...") } + Action { text: qsTr("&Open...") } + Action { text: qsTr("&Save") } + Action { text: qsTr("Save &As...") } + MenuSeparator { } + Action { text: qsTr("&Quit") } + } + Menu { + title: qsTr("&Edit") + Action { text: qsTr("Cu&t") } + Action { text: qsTr("&Copy") } + Action { text: qsTr("&Paste") } + } + Menu { + title: qsTr("&Help") + Action { text: qsTr("&About") } + } + } +} +//! [end] diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-scrollbar-policy.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-scrollbar-policy.qml index 1862aa70..fdcef987 100644 --- a/src/imports/controls/doc/snippets/qtquickcontrols2-scrollbar-policy.qml +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-scrollbar-policy.qml @@ -25,7 +25,7 @@ ** ****************************************************************************/ -import QtQuick 2.9 +import QtQuick 2.10 import QtQuick.Controls 2.2 //! [1] diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-scrollview-custom.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-scrollview-custom.qml index e3d56a60..0d5686f3 100644 --- a/src/imports/controls/doc/snippets/qtquickcontrols2-scrollview-custom.qml +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-scrollview-custom.qml @@ -25,7 +25,7 @@ ** ****************************************************************************/ -import QtQuick 2.9 +import QtQuick 2.10 import QtQuick.Controls 2.2 Item { diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-scrollview-interactive.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-scrollview-interactive.qml index 2485d363..9770de33 100644 --- a/src/imports/controls/doc/snippets/qtquickcontrols2-scrollview-interactive.qml +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-scrollview-interactive.qml @@ -25,7 +25,7 @@ ** ****************************************************************************/ -import QtQuick 2.9 +import QtQuick 2.10 import QtQuick.Controls 2.2 //! [file] diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-scrollview-listview.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-scrollview-listview.qml index cf084425..b3eff14f 100644 --- a/src/imports/controls/doc/snippets/qtquickcontrols2-scrollview-listview.qml +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-scrollview-listview.qml @@ -25,7 +25,7 @@ ** ****************************************************************************/ -import QtQuick 2.9 +import QtQuick 2.10 import QtQuick.Controls 2.2 Item { diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-scrollview-policy.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-scrollview-policy.qml index 853cbde6..efd23100 100644 --- a/src/imports/controls/doc/snippets/qtquickcontrols2-scrollview-policy.qml +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-scrollview-policy.qml @@ -25,7 +25,7 @@ ** ****************************************************************************/ -import QtQuick 2.9 +import QtQuick 2.10 import QtQuick.Controls 2.2 //! [file] diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-scrollview.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-scrollview.qml index 0a76bfcd..74c0e85c 100644 --- a/src/imports/controls/doc/snippets/qtquickcontrols2-scrollview.qml +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-scrollview.qml @@ -25,7 +25,7 @@ ** ****************************************************************************/ -import QtQuick 2.9 +import QtQuick 2.10 import QtQuick.Controls 2.2 Rectangle { diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-stackview-visible.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-stackview-visible.qml index 15717a7b..c80b6e4d 100644 --- a/src/imports/controls/doc/snippets/qtquickcontrols2-stackview-visible.qml +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-stackview-visible.qml @@ -25,7 +25,7 @@ ** ****************************************************************************/ -import QtQuick 2.9 +import QtQuick 2.10 import QtQuick.Controls 2.2 //! [1] diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-swipedelegate-transition.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-swipedelegate-transition.qml index 82c2994b..a6936fe8 100644 --- a/src/imports/controls/doc/snippets/qtquickcontrols2-swipedelegate-transition.qml +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-swipedelegate-transition.qml @@ -25,7 +25,7 @@ ** ****************************************************************************/ -import QtQuick 2.9 +import QtQuick 2.10 import QtQuick.Controls 2.2 //! [1] |