Gallery example: Add "Help" menu and shortcut
Add a property "control" identifying the control to be demo-ed to the page and add a help shortcut and menu item displaying its help. Change-Id: Ic3c7c31f5a44fccd57ee018fd3681dc6bdffee58 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
This commit is contained in:
parent
ec686af14f
commit
492586930b
|
@ -62,6 +62,15 @@ ApplicationWindow {
|
|||
visible: true
|
||||
title: "Qt Quick Controls 2"
|
||||
|
||||
function help()
|
||||
{
|
||||
var url = "https://doc.qt.io/qt-5/"
|
||||
+ (stackView.depth > 1
|
||||
? "qml-qtquick-controls2-" + stackView.currentItem.control + ".html"
|
||||
: "qtquick-controls2-qmlmodule.html");
|
||||
Qt.openUrlExternally(url)
|
||||
}
|
||||
|
||||
Settings {
|
||||
id: settings
|
||||
property string style: "Default"
|
||||
|
@ -73,6 +82,11 @@ ApplicationWindow {
|
|||
onActivated: navigateBackAction.trigger()
|
||||
}
|
||||
|
||||
Shortcut {
|
||||
sequence: StandardKey.HelpContents
|
||||
onActivated: help()
|
||||
}
|
||||
|
||||
Action {
|
||||
id: navigateBackAction
|
||||
icon.name: stackView.depth > 1 ? "back" : "drawer"
|
||||
|
@ -130,6 +144,10 @@ ApplicationWindow {
|
|||
text: "Settings"
|
||||
onTriggered: settingsDialog.open()
|
||||
}
|
||||
Action {
|
||||
text: "Help"
|
||||
onTriggered: help()
|
||||
}
|
||||
Action {
|
||||
text: "About"
|
||||
onTriggered: aboutDialog.open()
|
||||
|
|
|
@ -54,6 +54,8 @@ import QtQuick.Controls 2.12
|
|||
ScrollablePage {
|
||||
id: page
|
||||
|
||||
readonly property string control : "busyindicator"
|
||||
|
||||
Column {
|
||||
spacing: 40
|
||||
width: parent.width
|
||||
|
|
|
@ -55,6 +55,8 @@ import QtQuick.Controls 2.12
|
|||
ScrollablePage {
|
||||
id: page
|
||||
|
||||
readonly property string control : "button"
|
||||
|
||||
Column {
|
||||
spacing: 40
|
||||
width: parent.width
|
||||
|
|
|
@ -54,6 +54,8 @@ import QtQuick.Controls 2.12
|
|||
ScrollablePage {
|
||||
id: page
|
||||
|
||||
readonly property string control : "checkbox"
|
||||
|
||||
Column {
|
||||
spacing: 40
|
||||
width: parent.width
|
||||
|
|
|
@ -54,6 +54,8 @@ import QtQuick.Controls 2.12
|
|||
ScrollablePage {
|
||||
id: page
|
||||
|
||||
readonly property string control : "combobox"
|
||||
|
||||
Column {
|
||||
spacing: 40
|
||||
width: parent.width
|
||||
|
|
|
@ -54,6 +54,8 @@ import QtQuick.Controls 2.12
|
|||
ScrollablePage {
|
||||
id: page
|
||||
|
||||
property string control : "delaybutton"
|
||||
|
||||
Column {
|
||||
spacing: 40
|
||||
width: parent.width
|
||||
|
|
|
@ -55,6 +55,8 @@ import QtQuick.Controls 2.12
|
|||
Pane {
|
||||
padding: 0
|
||||
|
||||
property string control : "swipedelegate"
|
||||
|
||||
property var delegateComponentMap: {
|
||||
"ItemDelegate": itemDelegateComponent,
|
||||
"SwipeDelegate": swipeDelegateComponent,
|
||||
|
|
|
@ -54,6 +54,8 @@ import QtQuick.Controls 2.12
|
|||
ScrollablePage {
|
||||
id: page
|
||||
|
||||
readonly property string control : "dial"
|
||||
|
||||
Column {
|
||||
spacing: 40
|
||||
width: parent.width
|
||||
|
|
|
@ -55,6 +55,8 @@ import QtQuick.Controls 2.12
|
|||
ScrollablePage {
|
||||
id: page
|
||||
|
||||
readonly property string control : "dialog"
|
||||
|
||||
readonly property int buttonWidth: Math.max(button.implicitWidth, Math.min(button.implicitWidth * 2, page.availableWidth / 3))
|
||||
|
||||
Column {
|
||||
|
|
|
@ -54,6 +54,8 @@ import QtQuick.Controls 2.12
|
|||
ScrollablePage {
|
||||
id: page
|
||||
|
||||
readonly property string control : "frame"
|
||||
|
||||
readonly property int itemWidth: Math.max(button.implicitWidth, Math.min(button.implicitWidth * 3, page.availableWidth / 3 * 2))
|
||||
|
||||
Column {
|
||||
|
|
|
@ -54,6 +54,8 @@ import QtQuick.Controls 2.12
|
|||
ScrollablePage {
|
||||
id: page
|
||||
|
||||
readonly property string control : "groupbox"
|
||||
|
||||
readonly property int itemWidth: Math.max(button.implicitWidth, Math.min(button.implicitWidth * 3, page.availableWidth / 3 * 2))
|
||||
|
||||
Column {
|
||||
|
|
|
@ -54,6 +54,8 @@ import QtQuick.Controls 2.12
|
|||
ScrollablePage {
|
||||
id: page
|
||||
|
||||
readonly property string control : "pageindicator"
|
||||
|
||||
Column {
|
||||
spacing: 40
|
||||
width: parent.width
|
||||
|
|
|
@ -54,6 +54,8 @@ import QtQuick.Controls 2.12
|
|||
ScrollablePage {
|
||||
id: page
|
||||
|
||||
readonly property string control : "progressbar"
|
||||
|
||||
Column {
|
||||
spacing: 40
|
||||
width: parent.width
|
||||
|
|
|
@ -54,6 +54,8 @@ import QtQuick.Controls 2.12
|
|||
ScrollablePage {
|
||||
id: page
|
||||
|
||||
readonly property string control : "radiobutton"
|
||||
|
||||
Column {
|
||||
spacing: 40
|
||||
width: parent.width
|
||||
|
|
|
@ -54,6 +54,8 @@ import QtQuick.Controls 2.12
|
|||
ScrollablePage {
|
||||
id: page
|
||||
|
||||
readonly property string control : "rangeslider"
|
||||
|
||||
Column {
|
||||
spacing: 40
|
||||
width: parent.width
|
||||
|
|
|
@ -54,6 +54,8 @@ import QtQuick.Controls 2.12
|
|||
Flickable {
|
||||
id: flickable
|
||||
|
||||
readonly property string control : "scrollbar"
|
||||
|
||||
contentHeight: pane.height
|
||||
|
||||
Pane {
|
||||
|
|
|
@ -54,6 +54,8 @@ import QtQuick.Controls 2.12
|
|||
Flickable {
|
||||
id: flickable
|
||||
|
||||
readonly property string control : "scrollindicator"
|
||||
|
||||
contentHeight: pane.height
|
||||
|
||||
Pane {
|
||||
|
|
|
@ -54,6 +54,8 @@ import QtQuick.Controls 2.12
|
|||
Page {
|
||||
id: page
|
||||
|
||||
readonly property string control : "flickable"
|
||||
|
||||
default property alias content: pane.contentItem
|
||||
|
||||
Flickable {
|
||||
|
|
|
@ -54,6 +54,8 @@ import QtQuick.Controls 2.12
|
|||
ScrollablePage {
|
||||
id: page
|
||||
|
||||
readonly property string control : "slider"
|
||||
|
||||
Column {
|
||||
spacing: 40
|
||||
width: parent.width
|
||||
|
|
|
@ -54,6 +54,8 @@ import QtQuick.Controls 2.12
|
|||
ScrollablePage {
|
||||
id: page
|
||||
|
||||
readonly property string control : ""
|
||||
|
||||
Column {
|
||||
spacing: 40
|
||||
width: parent.width
|
||||
|
|
|
@ -55,6 +55,8 @@ StackView {
|
|||
id: stackView
|
||||
initialItem: page
|
||||
|
||||
readonly property string control : "stackview"
|
||||
|
||||
Component {
|
||||
id: page
|
||||
|
||||
|
|
|
@ -54,6 +54,8 @@ import QtQuick.Controls 2.12
|
|||
Pane {
|
||||
id: pane
|
||||
|
||||
readonly property string control : "swipeview"
|
||||
|
||||
SwipeView {
|
||||
id: view
|
||||
currentIndex: 1
|
||||
|
|
|
@ -54,6 +54,8 @@ import QtQuick.Controls 2.12
|
|||
ScrollablePage {
|
||||
id: page
|
||||
|
||||
readonly property string control : "switch"
|
||||
|
||||
Column {
|
||||
spacing: 40
|
||||
width: parent.width
|
||||
|
|
|
@ -54,6 +54,8 @@ import QtQuick.Controls 2.12
|
|||
Page {
|
||||
id: page
|
||||
|
||||
readonly property string control : "tabbar"
|
||||
|
||||
SwipeView {
|
||||
id: swipeView
|
||||
anchors.fill: parent
|
||||
|
|
|
@ -54,6 +54,8 @@ import QtQuick.Controls 2.12
|
|||
ScrollablePage {
|
||||
id: page
|
||||
|
||||
readonly property string control : "textarea"
|
||||
|
||||
Column {
|
||||
spacing: 40
|
||||
width: parent.width
|
||||
|
|
|
@ -54,6 +54,8 @@ import QtQuick.Controls 2.12
|
|||
ScrollablePage {
|
||||
id: page
|
||||
|
||||
readonly property string control : "textfield"
|
||||
|
||||
Column {
|
||||
spacing: 40
|
||||
width: parent.width
|
||||
|
|
|
@ -54,6 +54,8 @@ import QtQuick.Controls 2.12
|
|||
ScrollablePage {
|
||||
id: page
|
||||
|
||||
readonly property string control : "tooltip"
|
||||
|
||||
Column {
|
||||
spacing: 40
|
||||
width: parent.width
|
||||
|
|
|
@ -54,6 +54,8 @@ import QtQuick.Controls 2.12
|
|||
ScrollablePage {
|
||||
id: page
|
||||
|
||||
readonly property string control : "tumbler"
|
||||
|
||||
Column {
|
||||
spacing: 40
|
||||
width: parent.width
|
||||
|
|
Loading…
Reference in New Issue