1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-30 09:32:05 -04:00
Files
DankMaterialShell/quickshell/Services/ChangelogService.qml
bbedward f76724f7cd logger: add a dedicated QML logging Singleton
- adds log.info/error/debug/warn/fatal
- adds ability to write logs to any file
- add CLI options in addition to env to set log levels
2026-04-29 15:42:30 -04:00

111 lines
2.9 KiB
QML

pragma Singleton
pragma ComponentBehavior: Bound
import QtCore
import QtQuick
import Quickshell
import Quickshell.Io
import qs.Common
import qs.Services
Singleton {
id: root
readonly property var log: Log.scoped("ChangelogService")
readonly property string currentVersion: "1.4"
readonly property bool changelogEnabled: false
readonly property string configDir: Paths.strip(StandardPaths.writableLocation(StandardPaths.ConfigLocation)) + "/DankMaterialShell"
readonly property string changelogMarkerPath: configDir + "/.changelog-" + currentVersion
property bool checkComplete: false
property bool changelogDismissed: false
readonly property bool shouldShowChangelog: {
if (!checkComplete)
return false;
if (!changelogEnabled)
return false;
if (changelogDismissed)
return false;
if (typeof FirstLaunchService !== "undefined" && FirstLaunchService.isFirstLaunch)
return false;
return true;
}
signal changelogRequested
signal changelogCompleted
Component.onCompleted: {
if (!changelogEnabled)
return;
if (FirstLaunchService.checkComplete)
handleFirstLaunchResult();
}
function handleFirstLaunchResult() {
if (FirstLaunchService.isFirstLaunch) {
checkComplete = true;
changelogDismissed = true;
touchMarkerProcess.running = true;
} else {
changelogCheckProcess.running = true;
}
}
Connections {
target: FirstLaunchService
function onCheckCompleteChanged() {
if (FirstLaunchService.checkComplete && root.changelogEnabled && !root.checkComplete)
root.handleFirstLaunchResult();
}
}
function showChangelog() {
changelogRequested();
}
function dismissChangelog() {
changelogDismissed = true;
touchMarkerProcess.running = true;
changelogCompleted();
}
Process {
id: changelogCheckProcess
command: ["sh", "-c", "[ -f '" + changelogMarkerPath + "' ] && echo 'seen' || echo 'show'"]
running: false
stdout: SplitParser {
onRead: data => {
const result = data.trim();
root.checkComplete = true;
switch (result) {
case "seen":
root.changelogDismissed = true;
break;
case "show":
root.changelogRequested();
break;
}
}
}
}
Process {
id: touchMarkerProcess
command: ["sh", "-c", "mkdir -p '" + configDir + "' && touch '" + changelogMarkerPath + "'"]
running: false
onExited: exitCode => {
if (exitCode !== 0) {
log.warn("Failed to create changelog marker");
}
}
}
}