keybinds working for logout menu, very cool
This commit is contained in:
3
Bar.qml
3
Bar.qml
@@ -3,7 +3,9 @@ import QtQuick.Effects
|
|||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Hyprland
|
import Quickshell.Hyprland
|
||||||
|
import Quickshell.Wayland
|
||||||
import "./Bar"
|
import "./Bar"
|
||||||
|
import "./Services/"
|
||||||
import "Color.js" as Colors
|
import "Color.js" as Colors
|
||||||
|
|
||||||
Scope {
|
Scope {
|
||||||
@@ -25,6 +27,7 @@ Scope {
|
|||||||
required property var modelData
|
required property var modelData
|
||||||
property HyprlandMonitor monitor: Hyprland.monitorFor(modelData)
|
property HyprlandMonitor monitor: Hyprland.monitorFor(modelData)
|
||||||
|
|
||||||
|
WlrLayershell.keyboardFocus: IpcManager.focusState
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
exclusionMode: ExclusionMode.Normal
|
exclusionMode: ExclusionMode.Normal
|
||||||
exclusiveZone: barExclusionZone
|
exclusiveZone: barExclusionZone
|
||||||
|
|||||||
116
Bar/Time.qml
116
Bar/Time.qml
@@ -100,6 +100,11 @@ Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
|
function onCloseLogoutMenu() {
|
||||||
|
root.overriden = false;
|
||||||
|
root.logout = false;
|
||||||
|
}
|
||||||
|
|
||||||
function onLogoutMenu() {
|
function onLogoutMenu() {
|
||||||
root.overriden = true;
|
root.overriden = true;
|
||||||
root.logout = true;
|
root.logout = true;
|
||||||
@@ -164,6 +169,49 @@ Container {
|
|||||||
Item {
|
Item {
|
||||||
id: logoutMenuRoot
|
id: logoutMenuRoot
|
||||||
|
|
||||||
|
property var logoutModel: [
|
||||||
|
{
|
||||||
|
color: Colors.red,
|
||||||
|
text: "s",
|
||||||
|
key: Qt.Key_S
|
||||||
|
},
|
||||||
|
{
|
||||||
|
color: Colors.peach,
|
||||||
|
text: "e",
|
||||||
|
key: Qt.Key_E
|
||||||
|
},
|
||||||
|
{
|
||||||
|
color: Colors.yellow,
|
||||||
|
text: "r",
|
||||||
|
key: Qt.Key_R
|
||||||
|
},
|
||||||
|
{
|
||||||
|
color: Colors.green,
|
||||||
|
text: "l",
|
||||||
|
key: Qt.Key_L
|
||||||
|
},
|
||||||
|
{
|
||||||
|
color: Colors.sky,
|
||||||
|
text: "u",
|
||||||
|
key: Qt.Key_U
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
forceActiveFocus();
|
||||||
|
}
|
||||||
|
Keys.onPressed: event => {
|
||||||
|
if (event.key == Qt.Key_Escape) {
|
||||||
|
IpcManager.closeLogoutMenu();
|
||||||
|
} else {
|
||||||
|
for (let button of logoutMenuRoot.logoutModel) {
|
||||||
|
if (button.key == event.key) {
|
||||||
|
event.accepted = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
spacing: root.logoutSpacing
|
spacing: root.logoutSpacing
|
||||||
|
|
||||||
@@ -172,29 +220,36 @@ Container {
|
|||||||
margins: root.logoutMargin
|
margins: root.logoutMargin
|
||||||
}
|
}
|
||||||
|
|
||||||
LogoutButton {
|
Repeater {
|
||||||
color: Colors.red
|
delegate: logoutButton
|
||||||
logoutText: "a"
|
model: logoutMenuRoot.logoutModel
|
||||||
}
|
}
|
||||||
|
|
||||||
LogoutButton {
|
Component {
|
||||||
color: Colors.peach
|
id: logoutButton
|
||||||
logoutText: "a"
|
|
||||||
}
|
|
||||||
|
|
||||||
LogoutButton {
|
Item {
|
||||||
color: Colors.yellow
|
id: logoutButtonRoot
|
||||||
logoutText: "a"
|
|
||||||
}
|
|
||||||
|
|
||||||
LogoutButton {
|
// Key yen isn't on my keyboard, acts as an errorless analog for no bind
|
||||||
color: Colors.green
|
required property var modelData
|
||||||
logoutText: "a"
|
|
||||||
}
|
|
||||||
|
|
||||||
LogoutButton {
|
Layout.fillHeight: true
|
||||||
color: Colors.sky
|
Layout.fillWidth: true
|
||||||
logoutText: "a"
|
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
color: logoutButtonRoot.modelData.color
|
||||||
|
radius: 7
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
anchors.fill: parent
|
||||||
|
horizontalAlignment: Qt.AlignHCenter
|
||||||
|
text: logoutButtonRoot.modelData.text
|
||||||
|
verticalAlignment: Qt.AlignVCenter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -207,7 +262,7 @@ Container {
|
|||||||
property string component: "time"
|
property string component: "time"
|
||||||
|
|
||||||
horizontalAlignment: Qt.AlignCenter
|
horizontalAlignment: Qt.AlignCenter
|
||||||
text: Time.time
|
text: TimeManager.time
|
||||||
verticalAlignment: Qt.AlignVCenter
|
verticalAlignment: Qt.AlignVCenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -379,27 +434,4 @@ Container {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
component LogoutButton: Item {
|
|
||||||
id: logoutButtonRoot
|
|
||||||
|
|
||||||
property color color: Colors.surface1
|
|
||||||
property string logoutText: ""
|
|
||||||
|
|
||||||
Layout.fillHeight: true
|
|
||||||
Layout.fillWidth: true
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
anchors.fill: parent
|
|
||||||
color: logoutButtonRoot.color
|
|
||||||
radius: 7
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
anchors.fill: parent
|
|
||||||
horizontalAlignment: Qt.AlignHCenter
|
|
||||||
text: logoutButtonRoot.logoutText
|
|
||||||
verticalAlignment: Qt.AlignVCenter
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,24 @@ import QtQuick
|
|||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
|
|
||||||
|
import Quickshell.Wayland
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
property var focusState: WlrKeyboardFocus.None
|
||||||
|
|
||||||
|
signal closeLogoutMenu
|
||||||
signal logoutMenu
|
signal logoutMenu
|
||||||
|
|
||||||
|
onCloseLogoutMenu: {
|
||||||
|
root.focusState = WlrKeyboardFocus.None;
|
||||||
|
}
|
||||||
|
|
||||||
IpcHandler {
|
IpcHandler {
|
||||||
function openLogoutMenu(): void {
|
function openLogoutMenu(): void {
|
||||||
root.logoutMenu();
|
root.logoutMenu();
|
||||||
|
root.focusState = WlrKeyboardFocus.Exclusive;
|
||||||
}
|
}
|
||||||
|
|
||||||
target: "root"
|
target: "root"
|
||||||
|
|||||||
Reference in New Issue
Block a user