Rename appLauncher IPC to launcher, add calculator IPC

This commit is contained in:
Ly-sec 2025-08-24 12:58:40 +02:00
parent 1f9dec3e4c
commit c3515ddcc0
3 changed files with 69 additions and 37 deletions

View file

@ -8,7 +8,6 @@ Item {
IpcHandler { IpcHandler {
target: "settings" target: "settings"
function toggle() { function toggle() {
settingsPanel.toggle(Quickshell.screens[0]) settingsPanel.toggle(Quickshell.screens[0])
} }
@ -16,18 +15,16 @@ Item {
IpcHandler { IpcHandler {
target: "notifications" target: "notifications"
function toggleHistory() { function toggleHistory() {
notificationHistoryPanel.toggle(Quickshell.screens[0]) notificationHistoryPanel.toggle(Quickshell.screens[0])
} }
function toggleDoNotDisturb() {
function toggleDoNotDisturb() {// TODO // TODO
} }
} }
IpcHandler { IpcHandler {
target: "idleInhibitor" target: "idleInhibitor"
function toggle() { function toggle() {
return IdleInhibitorService.manualToggle() return IdleInhibitorService.manualToggle()
} }
@ -35,28 +32,48 @@ Item {
IpcHandler { IpcHandler {
target: "appLauncher" target: "appLauncher"
function toggle() { function toggle() {
launcherPanel.toggle(Quickshell.screens[0]) launcherPanel.toggle(Quickshell.screens[0])
} }
function clipboard() { function clipboard() {
launcherPanel.toggle(Quickshell.screens[0]) launcherPanel.toggle(Quickshell.screens[0])
launcherPanel.searchText = ">clip " // Use the setSearchText function to set clipboard mode
Qt.callLater(() => {
launcherPanel.setSearchText(">clip ")
})
}
function calculator() {
launcherPanel.toggle(Quickshell.screens[0])
// Use the setSearchText function to set calculator mode
Qt.callLater(() => {
launcherPanel.setSearchText(">calc ")
})
} }
} }
IpcHandler { IpcHandler {
target: "launcher" target: "launcher"
function toggle() { function toggle() {
launcherPanel.toggle(Quickshell.screens[0]) launcherPanel.toggle(Quickshell.screens[0])
} }
function clipboard() {
launcherPanel.toggle(Quickshell.screens[0])
// Use the setSearchText function to set clipboard mode
Qt.callLater(() => {
launcherPanel.setSearchText(">clip ")
})
}
function calculator() {
launcherPanel.toggle(Quickshell.screens[0])
// Use the setSearchText function to set calculator mode
Qt.callLater(() => {
launcherPanel.setSearchText(">calc ")
})
}
} }
IpcHandler { IpcHandler {
target: "lockScreen" target: "lockScreen"
function toggle() { function toggle() {
// Only lock if not already locked (prevents the red screen issue) // Only lock if not already locked (prevents the red screen issue)
// Note: No unlock via IPC for security reasons // Note: No unlock via IPC for security reasons
@ -68,11 +85,9 @@ Item {
IpcHandler { IpcHandler {
target: "brightness" target: "brightness"
function increase() { function increase() {
BrightnessService.increaseBrightness() BrightnessService.increaseBrightness()
} }
function decrease() { function decrease() {
BrightnessService.decreaseBrightness() BrightnessService.decreaseBrightness()
} }
@ -80,11 +95,8 @@ Item {
IpcHandler { IpcHandler {
target: "powerPanel" target: "powerPanel"
function toggle() { function toggle() {
powerPanel.toggle(Quickshell.screens[0]) powerPanel.toggle(Quickshell.screens[0])
} }
} }
} }

View file

@ -24,11 +24,29 @@ NPanel {
panelAnchorLeft: launcherPosition !== "center" && (launcherPosition.endsWith("_left")) panelAnchorLeft: launcherPosition !== "center" && (launcherPosition.endsWith("_left"))
panelAnchorRight: launcherPosition !== "center" && (launcherPosition.endsWith("_right")) panelAnchorRight: launcherPosition !== "center" && (launcherPosition.endsWith("_right"))
// Properties
property string searchText: ""
// Add function to set search text programmatically
function setSearchText(text) {
searchText = text
if (searchInput) {
searchInput.text = text
searchInput.cursorPosition = text.length
searchInput.forceActiveFocus()
}
}
onOpened: { onOpened: {
// Reset state when panel opens to avoid sticky modes // Reset state when panel opens to avoid sticky modes
if (searchText === "") {
searchText = "" searchText = ""
selectedIndex = 0 selectedIndex = 0
} }
if (searchInput) {
searchInput.forceActiveFocus()
}
}
// Import modular components // Import modular components
Calculator { Calculator {
@ -50,7 +68,6 @@ NPanel {
// Properties // Properties
property var desktopEntries: DesktopEntries.applications.values property var desktopEntries: DesktopEntries.applications.values
property string searchText: ""
property int selectedIndex: 0 property int selectedIndex: 0
// Refresh clipboard when user starts typing clipboard commands // Refresh clipboard when user starts typing clipboard commands
@ -141,15 +158,11 @@ NPanel {
// Command execution functions // Command execution functions
function executeCalcCommand() { function executeCalcCommand() {
searchText = ">calc " setSearchText(">calc ")
searchInput.text = searchText
searchInput.cursorPosition = searchText.length
} }
function executeClipCommand() { function executeClipCommand() {
searchText = ">clip " setSearchText(">clip ")
searchInput.text = searchText
searchInput.cursorPosition = searchText.length
} }
// Navigation functions // Navigation functions
@ -252,8 +265,12 @@ NPanel {
anchors.leftMargin: Style.marginS * scaling anchors.leftMargin: Style.marginS * scaling
anchors.right: parent.right anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
text: searchText
onTextChanged: { onTextChanged: {
// Update the parent searchText property
if (searchText !== text) {
searchText = text searchText = text
}
// Defer selectedIndex reset to avoid binding loops // Defer selectedIndex reset to avoid binding loops
Qt.callLater(() => selectedIndex = 0) Qt.callLater(() => selectedIndex = 0)
} }

View file

@ -101,10 +101,13 @@ mkdir -p ~/.config/quickshell && curl -sL https://github.com/noctalia-dev/noctal
qs qs
# Launcher # Launcher
qs ipc call appLauncher toggle qs ipc call launcher toggle
# Clipboard History # Clipboard History
qs ipc call appLauncher clipboard qs ipc call launcher clipboard
# Calculator
qs ipc call launcher calculator
# Brightness # Brightness
qs ipc call brightness increase qs ipc call brightness increase