clean up code in updates singleton and popout
This commit is contained in:
+8
-41
@@ -11,8 +11,8 @@ Singleton {
|
||||
id: root
|
||||
|
||||
property int availableUpdates: 0
|
||||
property string cmd: ""
|
||||
property bool commandReady
|
||||
property bool hasHelper
|
||||
property bool loaded
|
||||
property double now: Date.now()
|
||||
property var updates: ({})
|
||||
@@ -38,18 +38,12 @@ Singleton {
|
||||
}
|
||||
|
||||
function performPackageUpdate(pkg: string): void {
|
||||
if (root.cmd === "pacman")
|
||||
pkgUpdateProc.command = ["pkexec", root.cmd, "--noconfirm", "-Sy", pkg];
|
||||
else
|
||||
pkgUpdateProc.command = [root.cmd, "--noconfirm", "--sudo", "pkexec", "-Sy", pkg];
|
||||
pkgUpdateProc.command = ["pkexec", "pacman", "--noconfirm", "-Sy", pkg];
|
||||
pkgUpdateProc.running = true;
|
||||
}
|
||||
|
||||
function performSystemUpdate(): void {
|
||||
if (root.cmd === "pacman")
|
||||
sysUpdateProc.command = ["pkexec", root.cmd, "--noconfirm", "-Syu"];
|
||||
else
|
||||
sysUpdateProc.command = [root.cmd, "--noconfirm", "--sudo", "pkexec", "-Syu"];
|
||||
sysUpdateProc.command = ["pkexec", "pacman", "--noconfirm", "-Syu"];
|
||||
sysUpdateProc.running = true;
|
||||
}
|
||||
|
||||
@@ -87,7 +81,7 @@ Singleton {
|
||||
Process {
|
||||
id: cmdDetect
|
||||
|
||||
command: ["sh", "-c", "command -v checkupdates || command -v yay || command -v paru"]
|
||||
command: ["sh", "-c", "command -v checkupdates"]
|
||||
running: true
|
||||
|
||||
stdout: StdioCollector {
|
||||
@@ -96,47 +90,20 @@ Singleton {
|
||||
let helper;
|
||||
|
||||
if (cmd.length > 0) {
|
||||
helper = cmd.split("/").pop();
|
||||
helper = true;
|
||||
} else {
|
||||
helper = "pacman";
|
||||
}
|
||||
|
||||
if (helper === "checkupdates") {
|
||||
updatesProc.command = [helper];
|
||||
} else {
|
||||
updatesProc.command = [helper, "-Qu"];
|
||||
helper = false;
|
||||
}
|
||||
root.hasHelper = helper;
|
||||
root.commandReady = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: updateCmdDetect
|
||||
|
||||
command: ["sh", "-c", "command -v yay || command -v paru"]
|
||||
running: true
|
||||
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
const cmd = this.text.trim();
|
||||
let helper;
|
||||
|
||||
if (cmd.length > 0) {
|
||||
helper = cmd.split("/").pop();
|
||||
} else {
|
||||
helper = "pacman";
|
||||
}
|
||||
|
||||
root.cmd = helper;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: updatesProc
|
||||
|
||||
command: []
|
||||
command: root.hasHelper ? ["checkupdates"] : []
|
||||
running: false
|
||||
|
||||
stdout: StdioCollector {
|
||||
|
||||
@@ -78,8 +78,6 @@ CustomClippingRect {
|
||||
required property var modelData
|
||||
readonly property list<string> sections: modelData.update.split(" ")
|
||||
|
||||
// anchors.left: parent.left
|
||||
// anchors.right: parent.right
|
||||
color: Colors.tPalette.m3surfaceContainer
|
||||
implicitHeight: root.itemHeight
|
||||
implicitWidth: 600
|
||||
|
||||
Reference in New Issue
Block a user