mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
sessionMenu: auto-recreate 1..6 for as shortcuts for existing users
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import QtQuick
|
||||
|
||||
QtObject {
|
||||
id: root
|
||||
|
||||
// Add default keybinds (1-6) to session menu power options if none are defined
|
||||
function migrate(adapter, logger, rawJson) {
|
||||
logger.i("Settings", "Migrating settings to v53");
|
||||
|
||||
const powerOptions = rawJson?.sessionMenu?.powerOptions;
|
||||
if (!powerOptions || !Array.isArray(powerOptions))
|
||||
return true;
|
||||
|
||||
// Check if any power option has a keybind defined
|
||||
const hasAnyKeybind = powerOptions.some(opt => opt.keybind && opt.keybind !== "");
|
||||
if (hasAnyKeybind)
|
||||
return true;
|
||||
|
||||
// No keybinds defined — apply defaults matching the action order
|
||||
const defaultKeybinds = {
|
||||
"lock": "1",
|
||||
"suspend": "2",
|
||||
"hibernate": "3",
|
||||
"reboot": "4",
|
||||
"logout": "5",
|
||||
"shutdown": "6"
|
||||
};
|
||||
|
||||
for (let i = 0; i < powerOptions.length; i++) {
|
||||
const action = powerOptions[i].action;
|
||||
if (defaultKeybinds[action]) {
|
||||
adapter.sessionMenu.powerOptions[i].keybind = defaultKeybinds[action];
|
||||
logger.i("Settings", "Set keybind '" + defaultKeybinds[action] + "' for session menu action: " + action);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,8 @@ QtObject {
|
||||
47: migration47Component,
|
||||
48: migration48Component,
|
||||
49: migration49Component,
|
||||
50: migration50Component
|
||||
50: migration50Component,
|
||||
53: migration53Component
|
||||
})
|
||||
|
||||
// Migration components
|
||||
@@ -46,4 +47,5 @@ QtObject {
|
||||
property Component migration48Component: Migration48 {}
|
||||
property Component migration49Component: Migration49 {}
|
||||
property Component migration50Component: Migration50 {}
|
||||
property Component migration53Component: Migration53 {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user