mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
keybinds: fix cheatsheet on non niri
- separate read only logic from writeread
This commit is contained in:
@@ -17,7 +17,11 @@ DankModal {
|
|||||||
modalWidth: _maxW
|
modalWidth: _maxW
|
||||||
modalHeight: _maxH
|
modalHeight: _maxH
|
||||||
onBackgroundClicked: close()
|
onBackgroundClicked: close()
|
||||||
onOpened: () => Qt.callLater(() => modalFocusScope.forceActiveFocus())
|
onOpened: {
|
||||||
|
Qt.callLater(() => modalFocusScope.forceActiveFocus());
|
||||||
|
if (KeybindsService.cheatsheetAvailable)
|
||||||
|
KeybindsService.loadCheatsheet();
|
||||||
|
}
|
||||||
|
|
||||||
HyprlandFocusGrab {
|
HyprlandFocusGrab {
|
||||||
windows: [root.contentWindow]
|
windows: [root.contentWindow]
|
||||||
@@ -66,7 +70,7 @@ DankModal {
|
|||||||
spacing: Theme.spacingL
|
spacing: Theme.spacingL
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
text: KeybindsService.keybinds.title || "Keybinds"
|
text: KeybindsService.cheatsheet.title || "Keybinds"
|
||||||
font.pixelSize: Theme.fontSizeLarge
|
font.pixelSize: Theme.fontSizeLarge
|
||||||
font.weight: Font.Bold
|
font.weight: Font.Bold
|
||||||
color: Theme.primary
|
color: Theme.primary
|
||||||
@@ -82,7 +86,7 @@ DankModal {
|
|||||||
|
|
||||||
Component.onCompleted: root.activeFlickable = mainFlickable
|
Component.onCompleted: root.activeFlickable = mainFlickable
|
||||||
|
|
||||||
property var rawBinds: KeybindsService.keybinds.binds || {}
|
property var rawBinds: KeybindsService.cheatsheet.binds || {}
|
||||||
property var categories: {
|
property var categories: {
|
||||||
const processed = {};
|
const processed = {};
|
||||||
for (const cat in rawBinds) {
|
for (const cat in rawBinds) {
|
||||||
|
|||||||
@@ -22,6 +22,18 @@ Singleton {
|
|||||||
|
|
||||||
property bool available: CompositorService.isNiri && shortcutInhibitorAvailable
|
property bool available: CompositorService.isNiri && shortcutInhibitorAvailable
|
||||||
property string currentProvider: "niri"
|
property string currentProvider: "niri"
|
||||||
|
|
||||||
|
readonly property string cheatsheetProvider: {
|
||||||
|
if (CompositorService.isNiri)
|
||||||
|
return "niri";
|
||||||
|
if (CompositorService.isHyprland)
|
||||||
|
return "hyprland";
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
property bool cheatsheetAvailable: cheatsheetProvider !== ""
|
||||||
|
property bool cheatsheetLoading: false
|
||||||
|
property var cheatsheet: ({})
|
||||||
|
|
||||||
property bool loading: false
|
property bool loading: false
|
||||||
property bool saving: false
|
property bool saving: false
|
||||||
property bool fixing: false
|
property bool fixing: false
|
||||||
@@ -58,17 +70,14 @@ Singleton {
|
|||||||
signal bindSaveCompleted(bool success)
|
signal bindSaveCompleted(bool success)
|
||||||
signal bindRemoved(string key)
|
signal bindRemoved(string key)
|
||||||
signal dmsBindsFixed
|
signal dmsBindsFixed
|
||||||
|
signal cheatsheetLoaded
|
||||||
Component.onCompleted: {
|
|
||||||
if (available)
|
|
||||||
Qt.callLater(loadBinds);
|
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: CompositorService
|
target: CompositorService
|
||||||
function onCompositorChanged() {
|
function onCompositorChanged() {
|
||||||
if (CompositorService.isNiri)
|
if (!CompositorService.isNiri)
|
||||||
Qt.callLater(root.loadBinds);
|
return;
|
||||||
|
Qt.callLater(root.loadBinds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,6 +89,31 @@ Singleton {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: cheatsheetProcess
|
||||||
|
running: false
|
||||||
|
|
||||||
|
stdout: StdioCollector {
|
||||||
|
onStreamFinished: {
|
||||||
|
try {
|
||||||
|
root.cheatsheet = JSON.parse(text);
|
||||||
|
} catch (e) {
|
||||||
|
console.error("[KeybindsService] Failed to parse cheatsheet:", e);
|
||||||
|
root.cheatsheet = {};
|
||||||
|
}
|
||||||
|
root.cheatsheetLoading = false;
|
||||||
|
root.cheatsheetLoaded();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onExited: exitCode => {
|
||||||
|
if (exitCode === 0)
|
||||||
|
return;
|
||||||
|
console.warn("[KeybindsService] Cheatsheet load failed with code:", exitCode);
|
||||||
|
root.cheatsheetLoading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: loadProcess
|
id: loadProcess
|
||||||
running: false
|
running: false
|
||||||
@@ -199,6 +233,14 @@ Singleton {
|
|||||||
loadBinds(true);
|
loadBinds(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function loadCheatsheet() {
|
||||||
|
if (cheatsheetProcess.running || !cheatsheetAvailable)
|
||||||
|
return;
|
||||||
|
cheatsheetLoading = true;
|
||||||
|
cheatsheetProcess.command = ["dms", "keybinds", "show", cheatsheetProvider];
|
||||||
|
cheatsheetProcess.running = true;
|
||||||
|
}
|
||||||
|
|
||||||
function loadBinds(showLoading) {
|
function loadBinds(showLoading) {
|
||||||
if (loadProcess.running || !available)
|
if (loadProcess.running || !available)
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user