1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-05-12 07:19:41 -04:00

quickshell: drop support for 0.2, require 0.3+

- Remove all compat code
- Rewire LegacyNetworkService to use Quickshell.Networking
- Add parentWindow to settings child windows
This commit is contained in:
bbedward
2026-05-11 13:04:29 -04:00
parent 3989c7f801
commit b8f4c350a8
52 changed files with 1472 additions and 2064 deletions

View File

@@ -5,6 +5,7 @@ import QtCore
import QtQuick
import Qt.labs.folderlistmodel
import Quickshell
import Quickshell.Io
import qs.Common
import qs.Services
@@ -154,35 +155,43 @@ Singleton {
}
function loadPluginManifestFile(manifestPathNoScheme, sourceTag, mtimeEpochMs) {
const manifestId = "m_" + Math.random().toString(36).slice(2);
const qml = `
import QtQuick
import Quickshell.Io
FileView {
id: fv
property string absPath: ""
onLoaded: {
try {
let raw = text()
if (raw.charCodeAt(0) === 0xFEFF) raw = raw.slice(1)
const manifest = JSON.parse(raw)
root._onManifestParsed(absPath, manifest, "${sourceTag}", ${mtimeEpochMs})
} catch (e) {
log.error("bad manifest", absPath, e.message)
knownManifests[absPath] = { mtime: ${mtimeEpochMs}, source: "${sourceTag}", bad: true }
}
fv.destroy()
}
onLoadFailed: (err) => {
log.warn("manifest load failed", absPath, err)
fv.destroy()
}
}
`;
const loader = manifestFvComp.createObject(root, {
absPath: manifestPathNoScheme,
path: manifestPathNoScheme,
sourceTag: sourceTag,
mtimeEpochMs: mtimeEpochMs
});
}
const loader = Qt.createQmlObject(qml, root, "mf_" + manifestId);
loader.absPath = manifestPathNoScheme;
loader.path = manifestPathNoScheme;
Component {
id: manifestFvComp
FileView {
id: fv
property string absPath: ""
property string sourceTag: ""
property double mtimeEpochMs: 0
onLoaded: {
try {
let raw = text();
if (raw.charCodeAt(0) === 0xFEFF)
raw = raw.slice(1);
const manifest = JSON.parse(raw);
root._onManifestParsed(absPath, manifest, sourceTag, mtimeEpochMs);
} catch (e) {
root.log.error("bad manifest", absPath, e.message);
root.knownManifests[absPath] = {
mtime: mtimeEpochMs,
source: sourceTag,
bad: true
};
}
fv.destroy();
}
onLoadFailed: err => {
root.log.warn("manifest load failed", absPath, err);
fv.destroy();
}
}
}
function _onManifestParsed(absPath, manifest, sourceTag, mtimeEpochMs) {
@@ -670,10 +679,10 @@ Singleton {
_stateLoaded[pluginId] = true;
_ensureStateDir();
const path = getPluginStatePath(pluginId);
const escapedPath = path.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
try {
const qml = 'import QtQuick; import Quickshell.Io; FileView { path: "' + escapedPath + '"; blockLoading: true; blockWrites: true; atomicWrites: true }';
const fv = Qt.createQmlObject(qml, root, "sf_" + pluginId);
const fv = stateLoadFvComp.createObject(root, {
path: path
});
const raw = fv.text();
if (raw && raw.trim()) {
_stateCache[pluginId] = JSON.parse(raw);
@@ -694,10 +703,10 @@ Singleton {
return;
}
const path = getPluginStatePath(pluginId);
const escapedPath = path.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
try {
const qml = 'import QtQuick; import Quickshell.Io; FileView { path: "' + escapedPath + '"; blockWrites: true; atomicWrites: true }';
const fv = Qt.createQmlObject(qml, root, "sw_" + pluginId);
const fv = stateSaveFvComp.createObject(root, {
path: path
});
_stateWriters[pluginId] = fv;
fv.loaded.connect(function () {
fv.setText(content);
@@ -710,6 +719,23 @@ Singleton {
}
}
Component {
id: stateLoadFvComp
FileView {
blockLoading: true
blockWrites: true
atomicWrites: true
}
}
Component {
id: stateSaveFvComp
FileView {
blockWrites: true
atomicWrites: true
}
}
function _flushDirtyStates() {
const dirty = _stateDirtyPlugins;
_stateDirtyPlugins = {};
@@ -748,22 +774,8 @@ Singleton {
}
function createPluginDirectory() {
const mkdirProcess = Qt.createComponent("data:text/plain,import Quickshell.Io; Process { }");
if (mkdirProcess.status === Component.Ready) {
const process = mkdirProcess.createObject(root);
process.command = ["mkdir", "-p", pluginDirectory];
process.exited.connect(function (exitCode) {
if (exitCode !== 0) {
log.error("Failed to create plugin directory, exit code:", exitCode);
}
process.destroy();
});
process.running = true;
return true;
} else {
log.error("Failed to create mkdir process");
return false;
}
Quickshell.execDetached(["mkdir", "-p", pluginDirectory]);
return true;
}
// Launcher plugin helper functions