forked from Shinonome/dots-hyprland
waffles: add action center window
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import qs
|
||||
import qs.services
|
||||
import qs.modules.common
|
||||
import qs.modules.common.functions
|
||||
import qs.modules.waffle.looks
|
||||
|
||||
WBarAttachedPanelContent {
|
||||
id: root
|
||||
|
||||
contentItem: ColumnLayout {
|
||||
anchors.centerIn: parent
|
||||
spacing: 0
|
||||
|
||||
Rectangle {
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
topLeftRadius: root.border.radius - root.border.border.width
|
||||
topRightRadius: topLeftRadius
|
||||
color: Looks.colors.bgPanelBody
|
||||
|
||||
implicitWidth: 360
|
||||
implicitHeight: 380
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
Layout.fillHeight: false
|
||||
Layout.fillWidth: true
|
||||
color: Looks.colors.bgPanelSeparator
|
||||
implicitHeight: 1
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
Layout.fillHeight: false
|
||||
Layout.fillWidth: true
|
||||
bottomLeftRadius: root.border.radius - root.border.border.width
|
||||
bottomRightRadius: bottomLeftRadius
|
||||
color: Looks.colors.bgPanelFooter
|
||||
|
||||
implicitWidth: 360
|
||||
implicitHeight: 47
|
||||
|
||||
// Battery button
|
||||
WPanelFooterButton {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 12
|
||||
|
||||
contentItem: Row {
|
||||
spacing: 4
|
||||
|
||||
FluentIcon {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
icon: WIcons.batteryIcon
|
||||
}
|
||||
WText {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: `${Math.round(Battery.percentage * 100) || 0}%`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Settings button
|
||||
WPanelFooterButton {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 12
|
||||
|
||||
contentItem: FluentIcon {
|
||||
icon: "settings"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import Quickshell.Wayland
|
||||
import Quickshell.Hyprland
|
||||
import qs
|
||||
import qs.services
|
||||
import qs.modules.common
|
||||
import qs.modules.common.widgets
|
||||
|
||||
Scope {
|
||||
id: root
|
||||
|
||||
Connections {
|
||||
target: GlobalStates
|
||||
|
||||
function onSidebarLeftOpenChanged() {
|
||||
if (GlobalStates.sidebarLeftOpen) barLoader.active = true;
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: barLoader
|
||||
active: GlobalStates.sidebarLeftOpen
|
||||
sourceComponent: PanelWindow {
|
||||
id: panelWindow
|
||||
exclusiveZone: 0
|
||||
WlrLayershell.namespace: "quickshell:actionCenter"
|
||||
WlrLayershell.keyboardFocus: WlrKeyboardFocus.OnDemand
|
||||
color: "transparent"
|
||||
|
||||
anchors {
|
||||
bottom: Config.options.waffles.bar.bottom
|
||||
top: !Config.options.waffles.bar.bottom
|
||||
right: true
|
||||
}
|
||||
|
||||
implicitWidth: content.implicitWidth + content.visualMargin * 2
|
||||
implicitHeight: content.implicitHeight + content.visualMargin * 2
|
||||
|
||||
HyprlandFocusGrab {
|
||||
id: focusGrab
|
||||
active: true
|
||||
windows: [panelWindow]
|
||||
onCleared: content.close();
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: GlobalStates
|
||||
function onSidebarLeftOpenChanged() {
|
||||
if (!GlobalStates.sidebarLeftOpen) content.close();
|
||||
}
|
||||
}
|
||||
|
||||
ActionCenterContent {
|
||||
id: content
|
||||
anchors.centerIn: parent
|
||||
|
||||
onClosed: {
|
||||
barLoader.active = false;
|
||||
GlobalStates.sidebarLeftOpen = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function toggleOpen() {
|
||||
GlobalStates.sidebarLeftOpen = !GlobalStates.sidebarLeftOpen;
|
||||
}
|
||||
|
||||
IpcHandler {
|
||||
target: "sidebarLeft"
|
||||
|
||||
function toggle() {
|
||||
root.toggleOpen();
|
||||
}
|
||||
}
|
||||
|
||||
GlobalShortcut {
|
||||
name: "sidebarLeftToggle"
|
||||
description: "Toggles left sidebar on press"
|
||||
|
||||
onPressed: root.toggleOpen();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user