Fix ArchUpdater NCheckbox binding

ArchUpdater: Create proper binding, make selective update more robust
This commit is contained in:
Ly-sec 2025-08-28 19:48:20 +02:00
parent 6ac172fe02
commit cbd71bec49
4 changed files with 51 additions and 19 deletions

View file

@ -112,7 +112,11 @@ NPanel {
label: "" label: ""
description: "" description: ""
checked: ArchUpdaterService.isPackageSelected(modelData.name) checked: ArchUpdaterService.isPackageSelected(modelData.name)
onToggled: ArchUpdaterService.togglePackageSelection(modelData.name) onToggled: function (checked) {
ArchUpdaterService.togglePackageSelection(modelData.name)
// Force refresh of the checked property
checkbox.checked = ArchUpdaterService.isPackageSelected(modelData.name)
}
activeColor: (modelData.source === "aur") ? Color.mSecondary : Color.mPrimary activeColor: (modelData.source === "aur") ? Color.mSecondary : Color.mPrimary
activeOnColor: (modelData.source === "aur") ? Color.mOnSecondary : Color.mOnPrimary activeOnColor: (modelData.source === "aur") ? Color.mOnSecondary : Color.mOnPrimary
Layout.fillWidth: false Layout.fillWidth: false

View file

@ -303,11 +303,11 @@ ColumnLayout {
} }
} }
// Temperature // Temperature
ColumnLayout { ColumnLayout {
spacing: Style.marginXS * scaling spacing: Style.marginXS * scaling
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
NLabel { NLabel {
label: "Color temperature" label: "Color temperature"
description: "Select two temperatures in Kelvin" description: "Select two temperatures in Kelvin"
@ -317,7 +317,7 @@ ColumnLayout {
visible: Settings.data.nightLight.enabled visible: Settings.data.nightLight.enabled
spacing: Style.marginM * scaling spacing: Style.marginM * scaling
Layout.fillWidth: false Layout.fillWidth: false
Layout.fillHeight: true Layout.fillHeight: true
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
NText { NText {

View file

@ -142,28 +142,40 @@ Singleton {
return return
updateInProgress = true updateInProgress = true
// Split selected packages by source // Split selected packages by source
const repoPkgs = selectedPackages.filter(pkg => { const repoPkgs = []
const repoPkg = repoPackages.find(p => p.name === pkg) const aurPkgs = []
return repoPkg && repoPkg.source === "repo"
}) for (const pkgName of selectedPackages) {
const aurPkgs = selectedPackages.filter(pkg => { const repoPkg = repoPackages.find(p => p.name === pkgName)
const aurPkg = aurPackages.find(p => p.name === pkg) if (repoPkg && repoPkg.source === "repo") {
return aurPkg && aurPkg.source === "aur" repoPkgs.push(pkgName)
}) }
const aurPkg = aurPackages.find(p => p.name === pkgName)
if (aurPkg && aurPkg.source === "aur") {
aurPkgs.push(pkgName)
}
}
// Update repo packages // Update repo packages
if (repoPkgs.length > 0) { if (repoPkgs.length > 0) {
const repoCommand = ["pkexec", "pacman", "-S", "--noconfirm"].concat(repoPkgs) const repoCommand = ["pkexec", "pacman", "-S", "--noconfirm"].concat(repoPkgs)
Logger.log("ArchUpdater", "Running repo command:", repoCommand.join(" "))
Quickshell.execDetached(repoCommand) Quickshell.execDetached(repoCommand)
} }
// Update AUR packages // Update AUR packages
if (aurPkgs.length > 0) { if (aurPkgs.length > 0) {
const aurCommand = ["sh", "-c", `command -v yay >/dev/null 2>&1 && yay -S ${aurPkgs.join( const aurHelper = getAurHelper()
' ')} --noconfirm || command -v paru >/dev/null 2>&1 && paru -S ${aurPkgs.join( if (aurHelper) {
' ')} --noconfirm || true`] const aurCommand = [aurHelper, "-S", "--noconfirm"].concat(aurPkgs)
Quickshell.execDetached(aurCommand) Logger.log("ArchUpdater", "Running AUR command:", aurCommand.join(" "))
Quickshell.execDetached(aurCommand)
} else {
Logger.warn("ArchUpdater", "No AUR helper found for packages:", aurPkgs.join(", "))
}
} }
// Clear selection and refresh // Clear selection and refresh
@ -172,6 +184,22 @@ Singleton {
refreshAfterUpdate() refreshAfterUpdate()
} }
// Helper function to detect AUR helper
function getAurHelper() {
// Check for yay first, then paru
const yayCheck = Quickshell.exec("command -v yay", true)
if (yayCheck.exitCode === 0 && yayCheck.stdout.trim()) {
return "yay"
}
const paruCheck = Quickshell.exec("command -v paru", true)
if (paruCheck.exitCode === 0 && paruCheck.stdout.trim()) {
return "paru"
}
return null
}
// Package selection functions // Package selection functions
function togglePackageSelection(packageName) { function togglePackageSelection(packageName) {
const index = selectedPackages.indexOf(packageName) const index = selectedPackages.indexOf(packageName)

View file

@ -25,16 +25,16 @@ ColumnLayout {
NLabel { NLabel {
label: root.label label: root.label
description: root.description description: root.description
visible: root.label !== "" || root.description !== "" visible: root.label !== "" || root.description !== ""
} }
// Container // Container
Rectangle { Rectangle {
id: frame id: frame
implicitWidth: parent.width implicitWidth: parent.width
implicitHeight: Style.baseWidgetSize * 1.1 * scaling implicitHeight: Style.baseWidgetSize * 1.1 * scaling
Layout.minimumWidth: 80 * scaling Layout.minimumWidth: 80 * scaling
Layout.maximumWidth: root.inputMaxWidth Layout.maximumWidth: root.inputMaxWidth
radius: Style.radiusM * scaling radius: Style.radiusM * scaling
color: Color.mSurface color: Color.mSurface
border.color: Color.mOutline border.color: Color.mOutline