feat: add menu component

This commit is contained in:
talksik
2025-04-13 13:11:10 -07:00
parent a76422920f
commit eb59ff6430
3 changed files with 60 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
import QtQuick
import QtQuick.Controls.Basic
Menu {
id: menu
topPadding: 2
bottomPadding: 2
background: Rectangle {
implicitWidth: 200
implicitHeight: 40
color: Theme.card
radius: Theme.radius
}
delegate: MenuItem {
id: menuItem
implicitWidth: 200
implicitHeight: 40
contentItem: Text {
leftPadding: menuItem.indicator.width
rightPadding: menuItem.arrow.width
text: menuItem.text
font: menuItem.font
opacity: enabled ? 1.0 : 0.3
color: Theme.foreground
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
background: Rectangle {
implicitWidth: 200
implicitHeight: 40
opacity: enabled ? 1 : 0.3
color: menuItem.highlighted ? Theme.highlight : "transparent"
}
}
}
+1
View File
@@ -28,6 +28,7 @@ set(plain_qml_files
AppImage.qml
AppLink.qml
AppWarning.qml
AppMenu.qml
)
set(qml_singletons
Fonts.qml
+18
View File
@@ -124,5 +124,23 @@ AppWindow {
AppWarning {
Layout.fillWidth: true
}
AppMenu {
id: menu
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 {}
Action { text: "Hello" }
// NOTE: MenuItem is not recommended as it isn't consistent with the menu theming. Please use Action until a fix is made.
}
AppSecondaryButton {
onClicked: menu.open()
text: "Open menu"
}
}
}