Warning, /plasma/libplasma/tests/components/menu.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2015 Kai Uwe Broulik <kde@privat.broulik.de> 0003 * SPDX-FileCopyrightText: 2019 David Edmundson <kde@davidedmundson.co.uk> 0004 * SPDX-FileCopyrightText: 2020 Noah Davis <noahadvs@gmail.com> 0005 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 */ 0007 import QtQuick 0008 import QtQuick.Layouts 0009 import org.kde.plasma.extras as PlasmaExtras 0010 import org.kde.plasma.components as PC3 0011 import org.kde.kirigami as Kirigami 0012 0013 ComponentBase { 0014 id: root 0015 title: "Plasma Extras Menu" 0016 contentItem: ColumnLayout { 0017 spacing: Kirigami.Units.gridUnit 0018 0019 PC3.Button { 0020 text: "Simple menu" 0021 onClicked: simpleMenu.open(0, height) 0022 0023 PlasmaExtras.Menu { 0024 id: simpleMenu 0025 0026 PlasmaExtras.MenuItem { text: "Hello" } 0027 PlasmaExtras.MenuItem { text: "This is just a simple" } 0028 PlasmaExtras.MenuItem { text: "Menu" } 0029 PlasmaExtras.MenuItem { text: "without separators" } 0030 PlasmaExtras.MenuItem { text: "and other stuff" } 0031 } 0032 } 0033 0034 PC3.Button { 0035 text: "Checkable menu items" 0036 onClicked: checkableMenu.open(0, height) 0037 0038 PlasmaExtras.Menu { 0039 id: checkableMenu 0040 0041 PlasmaExtras.MenuItem { text: "Apple"; checkable: true } 0042 PlasmaExtras.MenuItem { text: "Banana"; checkable: true } 0043 PlasmaExtras.MenuItem { text: "Orange"; checkable: true } 0044 } 0045 } 0046 0047 0048 PC3.Button { 0049 text: "Icons" 0050 onClicked: iconsMenu.open(0, height) 0051 0052 PlasmaExtras.Menu { 0053 id: iconsMenu 0054 0055 PlasmaExtras.MenuItem { text: "Error"; icon: "dialog-error" } 0056 PlasmaExtras.MenuItem { text: "Warning"; icon: "dialog-warning" } 0057 PlasmaExtras.MenuItem { text: "Information"; icon: "dialog-information" } 0058 } 0059 } 0060 0061 PC3.Button { 0062 text: "Separators and sections" 0063 onClicked: sectionsMenu.open(0, height) 0064 0065 PlasmaExtras.Menu { 0066 id: sectionsMenu 0067 0068 PlasmaExtras.MenuItem { text: "A menu"; section: true } 0069 PlasmaExtras.MenuItem { text: "One entry" } 0070 PlasmaExtras.MenuItem { text: "Another entry" } 0071 PlasmaExtras.MenuItem { separator: true } 0072 PlasmaExtras.MenuItem { text: "One item" } 0073 PlasmaExtras.MenuItem { text: "Another item" } 0074 } 0075 } 0076 0077 RowLayout { 0078 spacing: Kirigami.Units.smallSpacing 0079 0080 PC3.Button { 0081 id: minMaxButton 0082 text: "Fixed minimum and maximum width" 0083 onClicked: minMaxMenu.open(0, height) 0084 0085 PlasmaExtras.Menu { 0086 id: minMaxMenu 0087 0088 minimumWidth: minMaxButton.width 0089 maximumWidth: limitMenuMaxWidth.checked ? minMaxButton.width : undefined // has a RESET property 0090 0091 PlasmaExtras.MenuItem { text: "Hello" } 0092 PlasmaExtras.MenuItem { text: "This is just a simple" } 0093 PlasmaExtras.MenuItem { text: "Menu" } 0094 PlasmaExtras.MenuItem { text: "with some very very long text in one item that will " 0095 + "make the menu super huge if you don't do anything about it" } 0096 PlasmaExtras.MenuItem { text: "and other stuff" } 0097 } 0098 } 0099 0100 PC3.CheckBox { 0101 id: limitMenuMaxWidth 0102 anchors.verticalCenter: parent.verticalCenter 0103 text: "Limit maximum width" 0104 checked: true 0105 } 0106 } 0107 0108 PC3.Button { 0109 text: "Don't crash on null MenuItem action" 0110 onClicked: noActionCrashMenu.open(0, height) 0111 0112 PlasmaExtras.Menu { 0113 id: noActionCrashMenu 0114 0115 PlasmaExtras.MenuItem { text: "This is an item" } 0116 PlasmaExtras.MenuItem { text: "Below me should NOT be an empty item"} 0117 PlasmaExtras.MenuItem { action: null } 0118 PlasmaExtras.MenuItem { text: "I am not empty" } 0119 } 0120 } 0121 } 0122 }