mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-28 23:42:51 -05:00
changelog: capability to display new release message
This commit is contained in:
90
quickshell/Services/ChangelogService.qml
Normal file
90
quickshell/Services/ChangelogService.qml
Normal file
@@ -0,0 +1,90 @@
|
||||
pragma Singleton
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtCore
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import qs.Common
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
readonly property string currentVersion: "1.2"
|
||||
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;
|
||||
changelogCheckProcess.running = true;
|
||||
}
|
||||
|
||||
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":
|
||||
if (typeof FirstLaunchService === "undefined" || !FirstLaunchService.isFirstLaunch) {
|
||||
root.changelogRequested();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: touchMarkerProcess
|
||||
|
||||
command: ["sh", "-c", "mkdir -p '" + configDir + "' && touch '" + changelogMarkerPath + "'"]
|
||||
running: false
|
||||
|
||||
onExited: exitCode => {
|
||||
if (exitCode !== 0) {
|
||||
console.warn("ChangelogService: Failed to create changelog marker");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user