Files
NixOS-Configs/home/hypr/quickshell/components/AppleMenu.qml

159 lines
4.0 KiB
QML

import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import "../theme"
import ".."
Rectangle {
id: root
width: 220
implicitHeight: menuColumn.implicitHeight + 12
radius: Theme.radiusMedium
color: Theme.menuDropdownBg
border.color: Theme.menuDropdownBorder
border.width: 1
// Drop shadow
layer.enabled: true
ColumnLayout {
id: menuColumn
anchors.fill: parent
anchors.margins: 6
spacing: 2
// About This Mac
MenuItem {
text: "About This Mac"
onTriggered: {
GlobalState.appleMenuVisible = false;
GlobalState.toggleAboutMac();
}
}
MenuSeparator {}
MenuItem {
text: "System Preferences..."
onTriggered: {
GlobalState.launchApp("pavucontrol");
}
}
MenuItem {
text: "App Store..."
onTriggered: {
GlobalState.launchApp("foot -e zsh -c 'echo NixOS Packages; nix-env -qaP | head -n 50; exec zsh'");
}
}
MenuSeparator {}
MenuItem {
text: "Activity Monitor"
shortcut: "⌥⌘Esc"
onTriggered: {
GlobalState.launchApp("foot -e btop");
}
}
MenuSeparator {}
MenuItem {
text: "Sleep"
onTriggered: {
GlobalState.appleMenuVisible = false;
GlobalState.launchApp("systemctl suspend");
}
}
MenuItem {
text: "Restart..."
onTriggered: {
GlobalState.appleMenuVisible = false;
GlobalState.launchApp("systemctl reboot");
}
}
MenuItem {
text: "Shut Down..."
onTriggered: {
GlobalState.appleMenuVisible = false;
GlobalState.launchApp("systemctl poweroff");
}
}
MenuSeparator {}
MenuItem {
text: "Lock Screen"
shortcut: "⌃⌘Q"
onTriggered: {
GlobalState.appleMenuVisible = false;
GlobalState.launchApp("hyprlock");
}
}
MenuItem {
text: "Log Out anish..."
shortcut: "⇧⌘Q"
onTriggered: {
GlobalState.appleMenuVisible = false;
GlobalState.launchApp("hyprctl dispatch exit");
}
}
}
component MenuItem: Rectangle {
id: itemRoot
property string text: ""
property string shortcut: ""
signal triggered()
Layout.fillWidth: true
Layout.preferredHeight: 22
radius: Theme.radiusSmall
color: mouseArea.containsMouse ? Theme.menuHoverBlue : "transparent"
RowLayout {
anchors.fill: parent
anchors.leftMargin: 10
anchors.rightMargin: 10
spacing: 8
Text {
text: itemRoot.text
font.family: Theme.fontFamily
font.pixelSize: Theme.fontSizeNormal
color: mouseArea.containsMouse ? Theme.menuTextHover : Theme.textPrimary
Layout.fillWidth: true
elide: Text.ElideRight
}
Text {
visible: itemRoot.shortcut !== ""
text: itemRoot.shortcut
font.family: Theme.fontFamily
font.pixelSize: Theme.fontSizeSmall
color: mouseArea.containsMouse ? Theme.menuTextHover : Theme.textTertiary
}
}
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: itemRoot.triggered()
}
}
component MenuSeparator: Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: 1
Layout.topMargin: 3
Layout.bottomMargin: 3
color: Qt.rgba(1.0, 1.0, 1.0, 0.12)
}
}