ArchUpdater: add AUR support
This commit is contained in:
parent
74e65d75cb
commit
a1f87c50bc
3 changed files with 195 additions and 80 deletions
|
|
@ -16,6 +16,7 @@ NPanel {
|
|||
// When the panel opens
|
||||
onOpened: {
|
||||
ArchUpdaterService.doPoll()
|
||||
ArchUpdaterService.doAurPoll()
|
||||
}
|
||||
|
||||
panelContent: Rectangle {
|
||||
|
|
@ -61,8 +62,7 @@ NPanel {
|
|||
|
||||
// Update summary
|
||||
Text {
|
||||
text: ArchUpdaterService.updatePackages.length + " package" + (ArchUpdaterService.updatePackages.length
|
||||
!== 1 ? "s" : "") + " can be updated"
|
||||
text: ArchUpdaterService.totalUpdates + " package" + (ArchUpdaterService.totalUpdates !== 1 ? "s" : "") + " can be updated"
|
||||
font.pointSize: Style.fontSizeL * scaling
|
||||
font.family: Settings.data.ui.fontDefault
|
||||
font.weight: Style.fontWeightMedium
|
||||
|
|
@ -72,31 +72,35 @@ NPanel {
|
|||
|
||||
// Package selection info
|
||||
Text {
|
||||
text: ArchUpdaterService.selectedPackagesCount + " of " + ArchUpdaterService.updatePackages.length + " packages selected"
|
||||
text: ArchUpdaterService.selectedPackagesCount + " of " + ArchUpdaterService.totalUpdates + " packages selected"
|
||||
font.pointSize: Style.fontSizeS * scaling
|
||||
font.family: Settings.data.ui.fontDefault
|
||||
color: Color.mOnSurfaceVariant
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
// Package list
|
||||
// Unified list
|
||||
Rectangle {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
color: Color.mSurfaceVariant
|
||||
radius: Style.radiusM * scaling
|
||||
|
||||
// Combine repo and AUR lists in order: repos first, then AUR
|
||||
property var items: (ArchUpdaterService.repoPackages || []).concat(ArchUpdaterService.aurPackages || [])
|
||||
|
||||
ListView {
|
||||
id: packageListView
|
||||
id: unifiedList
|
||||
anchors.fill: parent
|
||||
anchors.margins: Style.marginS * scaling
|
||||
clip: true
|
||||
model: ArchUpdaterService.updatePackages
|
||||
model: parent.items
|
||||
spacing: Style.marginXS * scaling
|
||||
cacheBuffer: 300 * scaling
|
||||
|
||||
delegate: Rectangle {
|
||||
width: packageListView.width
|
||||
height: 50 * scaling
|
||||
width: unifiedList.width
|
||||
height: 56 * scaling
|
||||
color: Color.transparent
|
||||
radius: Style.radiusS * scaling
|
||||
|
||||
|
|
@ -105,34 +109,16 @@ NPanel {
|
|||
anchors.margins: Style.marginS * scaling
|
||||
spacing: Style.marginS * scaling
|
||||
|
||||
// Checkbox for selection
|
||||
// Checkbox for selection (pure bindings; no imperative state)
|
||||
NIconButton {
|
||||
id: checkbox
|
||||
icon: "check_box_outline_blank"
|
||||
onClicked: {
|
||||
const isSelected = ArchUpdaterService.isPackageSelected(modelData.name)
|
||||
if (isSelected) {
|
||||
ArchUpdaterService.togglePackageSelection(modelData.name)
|
||||
icon = "check_box_outline_blank"
|
||||
colorFg = Color.mOnSurfaceVariant
|
||||
} else {
|
||||
ArchUpdaterService.togglePackageSelection(modelData.name)
|
||||
icon = "check_box"
|
||||
colorFg = Color.mPrimary
|
||||
}
|
||||
}
|
||||
icon: ArchUpdaterService.isPackageSelected(modelData.name) ? "check_box" : "check_box_outline_blank"
|
||||
onClicked: ArchUpdaterService.togglePackageSelection(modelData.name)
|
||||
colorBg: Color.transparent
|
||||
colorFg: Color.mOnSurfaceVariant
|
||||
colorFg: ArchUpdaterService.isPackageSelected(
|
||||
modelData.name) ? ((modelData.source === "aur") ? Color.mSecondary : Color.mPrimary) : Color.mOnSurfaceVariant
|
||||
Layout.preferredWidth: 30 * scaling
|
||||
Layout.preferredHeight: 30 * scaling
|
||||
|
||||
Component.onCompleted: {
|
||||
// Set initial state
|
||||
if (ArchUpdaterService.isPackageSelected(modelData.name)) {
|
||||
icon = "check_box"
|
||||
colorFg = Color.mPrimary
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Package info
|
||||
|
|
@ -140,13 +126,38 @@ NPanel {
|
|||
Layout.fillWidth: true
|
||||
spacing: Style.marginXXS * scaling
|
||||
|
||||
Text {
|
||||
text: modelData.name
|
||||
font.pointSize: Style.fontSizeM * scaling
|
||||
font.family: Settings.data.ui.fontDefault
|
||||
font.weight: Style.fontWeightMedium
|
||||
color: Color.mOnSurface
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
spacing: Style.marginXS * scaling
|
||||
|
||||
Text {
|
||||
text: modelData.name
|
||||
font.pointSize: Style.fontSizeM * scaling
|
||||
font.family: Settings.data.ui.fontDefault
|
||||
font.weight: Style.fontWeightMedium
|
||||
color: Color.mOnSurface
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
// Source badge (custom rectangle)
|
||||
Rectangle {
|
||||
visible: !!modelData.source
|
||||
radius: 9999
|
||||
color: modelData.source === "aur" ? Color.mSecondary : Color.mPrimary
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
implicitHeight: Math.max(Style.fontSizeXS * 1.7 * scaling, 16 * scaling)
|
||||
// Width based on label content + horizontal padding
|
||||
implicitWidth: badgeText.implicitWidth + Math.max(12 * scaling, Style.marginS * scaling)
|
||||
|
||||
NText {
|
||||
id: badgeText
|
||||
anchors.centerIn: parent
|
||||
text: modelData.source === "aur" ? "AUR" : "Repo"
|
||||
font.pointSize: Style.fontSizeXS * scaling
|
||||
font.weight: Style.fontWeightBold
|
||||
color: modelData.source === "aur" ? Color.mOnSecondary : Color.mOnPrimary
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
|
|
@ -176,6 +187,7 @@ NPanel {
|
|||
tooltipText: "Check for updates"
|
||||
onClicked: {
|
||||
ArchUpdaterService.doPoll()
|
||||
ArchUpdaterService.doAurPoll()
|
||||
}
|
||||
colorBg: Color.mSurfaceVariant
|
||||
colorFg: Color.mOnSurface
|
||||
|
|
|
|||
|
|
@ -14,62 +14,79 @@ NIconButton {
|
|||
|
||||
sizeRatio: 0.8
|
||||
colorBg: Color.mSurfaceVariant
|
||||
colorFg: Color.mOnSurface
|
||||
// Highlight color based on update source
|
||||
colorFg: {
|
||||
if (ArchUpdaterService.totalUpdates === 0)
|
||||
return Color.mOnSurface
|
||||
if (ArchUpdaterService.updates > 0 && ArchUpdaterService.aurUpdates > 0)
|
||||
return Color.mPrimary
|
||||
if (ArchUpdaterService.updates > 0)
|
||||
return Color.mPrimary
|
||||
return Color.mSecondary
|
||||
}
|
||||
colorBorder: Color.transparent
|
||||
colorBorderHover: Color.transparent
|
||||
|
||||
// Enhanced icon states with better visual feedback
|
||||
// Icon states
|
||||
icon: {
|
||||
if (ArchUpdaterService.busy)
|
||||
if (ArchUpdaterService.busy || ArchUpdaterService.aurBusy)
|
||||
return "sync"
|
||||
if (ArchUpdaterService.updatePackages.length > 0) {
|
||||
// Show different icons based on update count
|
||||
const count = ArchUpdaterService.updatePackages.length
|
||||
if (ArchUpdaterService.totalUpdates > 0) {
|
||||
const count = ArchUpdaterService.totalUpdates
|
||||
if (count > 50)
|
||||
return "system_update_alt" // Many updates
|
||||
return "system_update_alt"
|
||||
if (count > 10)
|
||||
return "system_update" // Moderate updates
|
||||
return "system_update" // Few updates
|
||||
return "system_update"
|
||||
return "system_update"
|
||||
}
|
||||
return "task_alt"
|
||||
}
|
||||
|
||||
// Enhanced tooltip with more information
|
||||
// Tooltip with repo vs AUR breakdown and sample lists
|
||||
tooltipText: {
|
||||
if (ArchUpdaterService.busy)
|
||||
if (ArchUpdaterService.busy || ArchUpdaterService.aurBusy)
|
||||
return "Checking for updates…"
|
||||
|
||||
var count = ArchUpdaterService.updatePackages.length
|
||||
if (count === 0)
|
||||
const repoCount = ArchUpdaterService.updates
|
||||
const aurCount = ArchUpdaterService.aurUpdates
|
||||
const total = ArchUpdaterService.totalUpdates
|
||||
|
||||
if (total === 0)
|
||||
return "System is up to date ✓"
|
||||
|
||||
var header = count === 1 ? "One package can be upgraded:" : (count + " packages can be upgraded:")
|
||||
let header = total === 1 ? "One package can be upgraded:" : (total + " packages can be upgraded:")
|
||||
|
||||
var list = ArchUpdaterService.updatePackages || []
|
||||
var s = ""
|
||||
var limit = Math.min(list.length, 8)
|
||||
// Reduced to 8 for better readability
|
||||
for (var i = 0; i < limit; ++i) {
|
||||
var p = list[i]
|
||||
s += (i ? "\n" : "") + (p.name + ": " + p.oldVersion + " → " + p.newVersion)
|
||||
function sampleList(arr, n, colorLabel) {
|
||||
const limit = Math.min(arr.length, n)
|
||||
let s = ""
|
||||
for (var i = 0; i < limit; ++i) {
|
||||
const p = arr[i]
|
||||
s += (i ? "\n" : "") + (p.name + ": " + p.oldVersion + " → " + p.newVersion)
|
||||
}
|
||||
if (arr.length > limit)
|
||||
s += "\n… and " + (arr.length - limit) + " more"
|
||||
return (colorLabel ? (colorLabel + "\n") : "") + (s || "None")
|
||||
}
|
||||
if (list.length > 8)
|
||||
s += "\n… and " + (list.length - 8) + " more"
|
||||
|
||||
return header + "\n\n" + s + "\n\nClick to update system"
|
||||
const repoHeader = repoCount > 0 ? ("Repo (" + repoCount + "):") : "Repo: 0"
|
||||
const aurHeader = aurCount > 0 ? ("AUR (" + aurCount + "):") : "AUR: 0"
|
||||
|
||||
const repoBlock = repoCount > 0 ? (repoHeader + "\n\n" + sampleList(ArchUpdaterService.repoPackages,
|
||||
5)) : repoHeader
|
||||
const aurBlock = aurCount > 0 ? (aurHeader + "\n\n" + sampleList(ArchUpdaterService.aurPackages, 5)) : aurHeader
|
||||
|
||||
return header + "\n\n" + repoBlock + "\n\n" + aurBlock + "\n\nClick to update system"
|
||||
}
|
||||
|
||||
// Enhanced click behavior with confirmation
|
||||
onClicked: {
|
||||
if (ArchUpdaterService.busy)
|
||||
if (ArchUpdaterService.busy || ArchUpdaterService.aurBusy)
|
||||
return
|
||||
|
||||
if (ArchUpdaterService.updatePackages.length > 0) {
|
||||
// Show confirmation dialog for updates
|
||||
if (ArchUpdaterService.totalUpdates > 0) {
|
||||
PanelService.getPanel("archUpdaterPanel").toggle(screen, this)
|
||||
} else {
|
||||
// Just refresh if no updates available
|
||||
ArchUpdaterService.doPoll()
|
||||
ArchUpdaterService.doAurPoll()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue