feat: add power menu & clipboard
This commit is contained in:
1 parent
fda7ea8524
commit
bc3a22d1c1
6 files changed
+536
-88
No files matched your search
@@ -8,9 +8,28 @@ import "../Shared"
|
||||
PanelWindow {
|
||||
id: paletteWindow
|
||||
property QtObject rootState
|
||||
property bool enterQueued: false
|
||||
property var usageCounts: ({})
|
||||
property string lastUsedApp: ""
|
||||
|
||||
function launchApp(index) {
|
||||
if (index < 0 || index >= appModel.count) return;
|
||||
let item = appModel.get(index);
|
||||
let desktopName = item.desktopName;
|
||||
let appPath = item.appPath;
|
||||
|
||||
logHistoryProcess.command = ["bash", "-c", "echo '" + desktopName + "' >> ~/.cache/quickshell-app-history.txt"];
|
||||
logHistoryProcess.restart();
|
||||
|
||||
launchProcess.command = [
|
||||
"bash", "-c",
|
||||
"EXEC=$(awk -F= '/^Exec=/ {print $2; exit}' \"$1\" | sed 's/ %[a-zA-Z]//g'); if command -v uwsm &>/dev/null; then eval \"uwsm app -- $EXEC\"; elif command -v niri &>/dev/null; then eval \"niri msg action spawn -- $EXEC\"; else nohup eval \"$EXEC\" </dev/null >/dev/null 2>&1 & fi",
|
||||
"_", appPath
|
||||
];
|
||||
launchProcess.restart();
|
||||
rootState.commandPaletteOpen = false;
|
||||
}
|
||||
|
||||
visible: rootState.commandPaletteOpen
|
||||
|
||||
anchors {
|
||||
@@ -39,7 +58,7 @@ PanelWindow {
|
||||
id: container
|
||||
// Sized appropriately for a 2560x1440 screen
|
||||
width: 800
|
||||
height: Math.min(600, (appList.count > 0 ? appList.contentHeight : 0) + 50 + Theme.geometry.padding * 2 + Theme.geometry.spacing)
|
||||
height: Math.min(600, (appList.count > 0 ? appList.contentHeight : 0) + (searchInput.text.length > 0 ? 50 + Theme.geometry.spacing : 0) + Theme.geometry.padding * 2)
|
||||
anchors.centerIn: parent
|
||||
radius: Theme.geometry.radius
|
||||
color: Theme.colors.background
|
||||
@@ -60,14 +79,19 @@ PanelWindow {
|
||||
Column {
|
||||
anchors.fill: parent
|
||||
anchors.margins: Theme.geometry.padding
|
||||
spacing: Theme.geometry.spacing
|
||||
spacing: searchInput.text.length > 0 ? Theme.geometry.spacing : 0
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 50
|
||||
height: searchInput.text.length > 0 ? 50 : 0
|
||||
opacity: searchInput.text.length > 0 ? 1 : 0
|
||||
clip: true
|
||||
color: Theme.colors.surface
|
||||
radius: Theme.geometry.radius
|
||||
|
||||
Behavior on height { NumberAnimation { duration: Theme.animation.durationFast } }
|
||||
Behavior on opacity { NumberAnimation { duration: Theme.animation.durationFast } }
|
||||
|
||||
TextInput {
|
||||
id: searchInput
|
||||
anchors.fill: parent
|
||||
@@ -117,21 +141,10 @@ PanelWindow {
|
||||
}
|
||||
|
||||
Keys.onReturnPressed: (event) => {
|
||||
if (appList.currentIndex >= 0 && appList.currentIndex < appModel.count) {
|
||||
let item = appModel.get(appList.currentIndex);
|
||||
let desktopName = item.desktopName;
|
||||
let appPath = item.appPath;
|
||||
|
||||
logHistoryProcess.command = ["bash", "-c", "echo '" + desktopName + "' >> ~/.cache/quickshell-app-history.txt"];
|
||||
logHistoryProcess.restart();
|
||||
|
||||
launchProcess.command = [
|
||||
"bash", "-c",
|
||||
"EXEC=$(awk -F= '/^Exec=/ {print $2; exit}' \"$1\" | sed 's/ %[a-zA-Z]//g'); if command -v uwsm &>/dev/null; then eval \"uwsm app -- $EXEC\"; elif command -v niri &>/dev/null; then eval \"niri msg action spawn -- $EXEC\"; else nohup eval \"$EXEC\" </dev/null >/dev/null 2>&1 & fi",
|
||||
"_", appPath
|
||||
];
|
||||
launchProcess.restart();
|
||||
rootState.commandPaletteOpen = false;
|
||||
if (appList.count > 0 && appList.currentIndex >= 0 && appList.currentIndex < appModel.count) {
|
||||
paletteWindow.launchApp(appList.currentIndex);
|
||||
} else {
|
||||
paletteWindow.enterQueued = true;
|
||||
}
|
||||
event.accepted = true;
|
||||
}
|
||||
@@ -223,6 +236,11 @@ PanelWindow {
|
||||
}
|
||||
|
||||
appList.currentIndex = 0;
|
||||
|
||||
if (paletteWindow.enterQueued && appModel.count > 0) {
|
||||
paletteWindow.enterQueued = false;
|
||||
paletteWindow.launchApp(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -230,7 +248,7 @@ PanelWindow {
|
||||
ListView {
|
||||
id: appList
|
||||
width: parent.width
|
||||
height: parent.height - 50 - Theme.geometry.spacing
|
||||
height: parent.height - (searchInput.text.length > 0 ? 50 + Theme.geometry.spacing : 0)
|
||||
clip: true
|
||||
spacing: Theme.geometry.spacing
|
||||
|
||||
@@ -289,19 +307,7 @@ PanelWindow {
|
||||
onEntered: appList.currentIndex = index
|
||||
onClicked: {
|
||||
appList.currentIndex = index;
|
||||
let desktopName = model.desktopName;
|
||||
let appPath = model.appPath;
|
||||
|
||||
logHistoryProcess.command = ["bash", "-c", "echo '" + desktopName + "' >> ~/.cache/quickshell-app-history.txt"];
|
||||
logHistoryProcess.restart();
|
||||
|
||||
launchProcess.command = [
|
||||
"bash", "-c",
|
||||
"EXEC=$(awk -F= '/^Exec=/ {print $2; exit}' \"$1\" | sed 's/ %[a-zA-Z]//g'); if command -v uwsm &>/dev/null; then eval \"uwsm app -- $EXEC\"; elif command -v niri &>/dev/null; then eval \"niri msg action spawn -- $EXEC\"; else nohup eval \"$EXEC\" </dev/null >/dev/null 2>&1 & fi",
|
||||
"_", appPath
|
||||
];
|
||||
launchProcess.restart();
|
||||
rootState.commandPaletteOpen = false;
|
||||
paletteWindow.launchApp(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -331,6 +337,7 @@ PanelWindow {
|
||||
if (visible) {
|
||||
container.scale = 1.0;
|
||||
searchInput.text = "";
|
||||
paletteWindow.enterQueued = false;
|
||||
appModel.clear(); // Clear so it re-populates clean
|
||||
|
||||
// Read history first, then search
|
||||
|
||||
Reference in new issue
Block a user