1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-05-12 15:29:43 -04:00

feat: consolidate plugin directory management into a single dynamic button (#2400)

* feat: add Open Dir button to Plugins settings

* feat: consolidate plugin directory management into a single dynamic button
This commit is contained in:
Huỳnh Thiện Lộc
2026-05-12 20:29:17 +07:00
committed by GitHub
parent 9b68fc8213
commit 4bc62cc6ec
2 changed files with 31 additions and 12 deletions

View File

@@ -250,11 +250,15 @@ FocusScope {
}
DankButton {
text: I18n.tr("Create Dir")
iconName: "create_new_folder"
text: PluginService.pluginDirectoryExists ? I18n.tr("Open Dir") : I18n.tr("Create Dir")
iconName: PluginService.pluginDirectoryExists ? "folder_open" : "create_new_folder"
onClicked: {
PluginService.createPluginDirectory();
ToastService.showInfo("Created plugin directory: " + PluginService.pluginDirectory);
if (PluginService.pluginDirectoryExists) {
PluginService.openPluginDirectory();
} else {
PluginService.createPluginDirectory();
ToastService.showInfo("Created plugin directory: " + PluginService.pluginDirectory);
}
}
}
}

View File

@@ -20,14 +20,9 @@ Singleton {
property var pluginLauncherComponents: ({})
property var pluginDesktopComponents: ({})
property var availablePluginsList: []
property string pluginDirectory: {
var configDir = StandardPaths.writableLocation(StandardPaths.ConfigLocation);
var configDirStr = configDir.toString();
if (configDirStr.startsWith("file://")) {
configDirStr = configDirStr.substring(7);
}
return configDirStr + "/DankMaterialShell/plugins";
}
readonly property string pluginDirectory: Paths.strip(Paths.config) + "/plugins"
property bool pluginDirectoryExists: false
property string systemPluginDirectory: "/etc/xdg/quickshell/dms-plugins"
property var knownManifests: ({})
@@ -64,10 +59,23 @@ Singleton {
onTriggered: root._flushDirtyStates()
}
Process {
id: directoryCheckProcess
command: ["test", "-d", root.pluginDirectory]
onExited: (exitCode) => {
root.pluginDirectoryExists = (exitCode === 0);
}
}
function checkPluginDirectoryExists() {
directoryCheckProcess.running = true;
}
Component.onCompleted: {
userWatcher.folder = Paths.toFileUrl(root.pluginDirectory);
systemWatcher.folder = Paths.toFileUrl(root.systemPluginDirectory);
Qt.callLater(resyncAll);
Qt.callLater(checkPluginDirectoryExists);
}
FolderListModel {
@@ -758,6 +766,7 @@ Singleton {
systemWatcher.folder = "";
systemWatcher.folder = systemUrl;
resyncDebounce.restart();
checkPluginDirectoryExists();
}
function forceRescanPlugin(pluginId) {
@@ -775,6 +784,12 @@ Singleton {
function createPluginDirectory() {
Quickshell.execDetached(["mkdir", "-p", pluginDirectory]);
Qt.callLater(checkPluginDirectoryExists);
return true;
}
function openPluginDirectory() {
Qt.openUrlExternally(Paths.toFileUrl(pluginDirectory));
return true;
}