Kirigami-addons

ContextMenuPage.qml
1// SPDX-FileCopyrightText: 2024 Joshua Goins <josh@redstrate.com>
2// SPDX-FileCopyrightText: 2024 Carl Schwan <carl@carlschwan.eu>
3// SPDX-License-Identifier: LGPL-2.0-or-later
4
5pragma ComponentBehavior: Bound
6
7import QtQuick
8import QtQuick.Controls as QQC2
9import QtQuick.Controls as T
10import QtQuick.Layouts
11import Qt.labs.qmlmodels
12
13import org.kde.kirigami as Kirigami
14import org.kde.kirigamiaddons.components as KirigamiComponents
15import org.kde.kirigamiaddons.formcard as FormCard
16
17QQC2.ScrollView {
18 id: root
19
20 required property list<T.Action> actions
21 required property T.StackView stackView
22 required property KirigamiComponents.BottomDrawer drawer
23 property string title
24
25 Layout.fillWidth: true
26
27 ColumnLayout {
28 width: root.availableWidth
29 spacing: 0
30
31 Repeater {
32 model: root.actions
33
34 DelegateChooser {
35 role: "separator"
36
37 DelegateChoice {
38 roleValue: true
39
40 FormCard.FormDelegateSeparator {
41 required property T.Action modelData
42
43 visible: modelData.visible === undefined || modelData.visible
44 }
45 }
46
47 DelegateChoice {
48 FormCard.FormButtonDelegate {
49 id: button
50
51 required property T.Action modelData
52
53 action: modelData
54 visible: modelData.visible === undefined || modelData.visible
55
56 Binding {
57 when: !(modelData instanceof Kirigami.Action) || modelData.children.length === 0
58 target: button.trailingLogo
59 property: "source"
60 value: ""
61 }
62
63 onClicked: {
64 if (modelData instanceof Kirigami.Action && modelData.children.length > 0) {
65 root.stackView.push(Qt.resolvedUrl('./ContextMenuPage.qml'), {
66 stackView: root.stackView,
67 actions: modelData.children,
68 title: modelData.text,
69 drawer: root.drawer,
70 });
71 return;
72 }
73 drawer.close();
74 }
75 }
76 }
77 }
78 }
79 }
80}
A single card that follows a form style.
Definition FormCard.qml:35
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 3 2025 11:46:31 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.