64 lines
1.7 KiB
QML
64 lines
1.7 KiB
QML
|
|
import QtQuick
|
||
|
|
import Quickshell
|
||
|
|
import qs.Common
|
||
|
|
import qs.Services
|
||
|
|
|
||
|
|
QtObject {
|
||
|
|
id: root
|
||
|
|
|
||
|
|
property var pluginService: null
|
||
|
|
property string pluginId: "exampleLauncher"
|
||
|
|
|
||
|
|
signal itemsChanged
|
||
|
|
|
||
|
|
Component.onCompleted: {
|
||
|
|
// Example: load a trigger from settings if you want it configurable
|
||
|
|
if (pluginService) {
|
||
|
|
// trigger is usually set in plugin.json, but you can override at runtime
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// Required for launcher plugins
|
||
|
|
function getItems(query) {
|
||
|
|
if (!query || query.trim().length === 0) {
|
||
|
|
return []
|
||
|
|
}
|
||
|
|
|
||
|
|
const q = query.trim().toLowerCase()
|
||
|
|
|
||
|
|
// Very simple demo: echo back what the user typed
|
||
|
|
return [{
|
||
|
|
name: "Echo: " + query,
|
||
|
|
icon: "material:search",
|
||
|
|
comment: "Demo launcher item — replace with real logic",
|
||
|
|
action: "copy:" + query,
|
||
|
|
categories: ["Example"]
|
||
|
|
}]
|
||
|
|
}
|
||
|
|
|
||
|
|
function executeItem(item) {
|
||
|
|
if (!item || !item.action) return
|
||
|
|
|
||
|
|
if (item.action.startsWith("copy:")) {
|
||
|
|
const text = item.action.substring(5)
|
||
|
|
Quickshell.execDetached(["dms", "cl", "copy", text])
|
||
|
|
ToastService.showInfo("Copied to clipboard")
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// Optional but nice: context menu on right-click / Tab
|
||
|
|
function getContextMenuActions(item) {
|
||
|
|
if (!item) return []
|
||
|
|
return [
|
||
|
|
{
|
||
|
|
icon: "content_copy",
|
||
|
|
text: "Copy",
|
||
|
|
action: () => {
|
||
|
|
Quickshell.execDetached(["dms", "cl", "copy", item.action.substring(5)])
|
||
|
|
ToastService.showInfo("Copied")
|
||
|
|
}
|
||
|
|
}
|
||
|
|
]
|
||
|
|
}
|
||
|
|
}
|