Skip to content

Commit

Permalink
add action for one update
Browse files Browse the repository at this point in the history
  • Loading branch information
bouteillerAlan committed Mar 13, 2024
1 parent 50b2de1 commit aa7c764
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 22 deletions.
4 changes: 4 additions & 0 deletions a2n.archupdate.plasmoid/contents/config/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<default>yay</default>
</entry>

<entry name="updateCommandOne" type="String">
<default>yay -Sy</default>
</entry>

<entry name="countArchCommand" type="String">
<default>checkupdates | wc -l</default>
</entry>
Expand Down
11 changes: 11 additions & 0 deletions a2n.archupdate.plasmoid/contents/service/Updater.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Item {
property string listArchCommand: Plasmoid.configuration.listArchCommand
property string listAurCommand: Plasmoid.configuration.listAurCommand
property string updateCommand: Plasmoid.configuration.updateCommand
property string updateCommandOne: Plasmoid.configuration.updateCommandOne
property bool notCloseCommand: Plasmoid.configuration.notCloseCommand

function countArch() {
Expand Down Expand Up @@ -48,6 +49,16 @@ Item {
}
}

function launchOneUpdate(packageName) {
if (updateCommandOne !== '' && packageName) {
if (notCloseCommand) {
cmd.exec("konsole --noclose -e '" + updateCommandOne + " " + packageName + "'")
} else {
cmd.exec("konsole -e '" + updateCommandOne + " " + packageName + "'")
}
}
}

function killProcess(process) {
cmd.exec("kill -9 " + process)
}
Expand Down
10 changes: 10 additions & 0 deletions a2n.archupdate.plasmoid/contents/ui/Full.qml
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,25 @@ PlasmaExtras.Representation {
id: updateIcon
height: Kirigami.Units.iconSizes.medium
icon.name: "install-symbolic"
display: PlasmaComponents.AbstractButton.IconOnly
text: i18n("Install all update")
onClicked: update()
visible: main.hasUpdate()
PlasmaComponents.ToolTip {
text: parent.text
}
}

PlasmaComponents.ToolButton {
id: checkUpdatesIcon
height: Kirigami.Units.iconSizes.medium
icon.name: "view-refresh-symbolic"
display: PlasmaComponents.AbstractButton.IconOnly
text: i18n("Refresh list")
onClicked: refresh()
PlasmaComponents.ToolTip {
text: parent.text
}
}
}
}
Expand Down
52 changes: 31 additions & 21 deletions a2n.archupdate.plasmoid/contents/ui/components/ListItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ PlasmaComponents.ItemDelegate {

width: parent.width

function updateOne() {
updater.launchOneUpdate(name)
}

// generate & style the name of the package
function generateName() {
const nc = plasmoid.configuration.nameUseCustomColor ? plasmoid.configuration.nameColor : Kirigami.Theme.textColor
Expand All @@ -31,30 +35,36 @@ PlasmaComponents.ItemDelegate {
return '<font color="' + fvc + '">' + fv + '</font><font color="' + sc + '"> ' + plasmoid.configuration.separatorText + ' </font><font color="' + tvc + '">' + tv + '</font>'
}

// Add MouseArea to detect mouse hover
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
onEntered: listItem.highlighted = true
onExited: listItem.highlighted = false
}
contentItem: RowLayout {
ColumnLayout {
spacing: 2

contentItem: ColumnLayout {
spacing: 2
Kirigami.Heading {
id: itemHeading
level: 3
width: parent.width
text: generateName()
}

Kirigami.Heading {
id: itemHeading
level: 3
width: parent.width
text: generateName()
Controls.Label {
id: itemLabel
width: parent.width
wrapMode: Text.Wrap
text: generateVersion()
}
}

Controls.Label {
id: itemLabel
width: parent.width
wrapMode: Text.Wrap
text: generateVersion()
ColumnLayout {
Layout.alignment: Qt.AlignRight
PlasmaComponents.ToolButton {
id: actionToolButton
icon.name: "system-run-symbolic"
display: PlasmaComponents.AbstractButton.IconOnly
text: i18n("Update " + name)
onClicked: updateOne()
PlasmaComponents.ToolTip {
text: parent.text
}
}
}
}

Expand Down
8 changes: 7 additions & 1 deletion a2n.archupdate.plasmoid/contents/ui/config/configCommand.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Kirigami.ScrollablePage {
property alias cfg_notCloseCommand: notCloseBox.checked

property alias cfg_updateCommand: updateCommandInput.text
property alias cfg_updateCommandOne: updateCommandOneInput.text
property alias cfg_countArchCommand: countArchCommandInput.text
property alias cfg_countAurCommand: countAurCommandInput.text

Expand Down Expand Up @@ -124,7 +125,12 @@ Kirigami.ScrollablePage {

Controls.TextField {
id: updateCommandInput
Kirigami.FormData.label: "Update command: "
Kirigami.FormData.label: "Update all command: "
}

Controls.TextField {
id: updateCommandOneInput
Kirigami.FormData.label: "Update one command: "
}

}
Expand Down

0 comments on commit aa7c764

Please sign in to comment.