Skip to content

Commit

Permalink
Added non-animated loading indicator
Browse files Browse the repository at this point in the history
Added option to use a non-animated loading indicator. On battery-powered
systems, the animated loading indicator uses too much power, especially
when multiple instances of the applet are used.

Closes #4.
  • Loading branch information
liujed committed Sep 21, 2024
1 parent 16abff7 commit d02bdfb
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v0.4.1
* Added option to use a non-animated loading indicator, to reduce power usage
on battery-powered systems.

v0.4
* Ported Andreas Loos's version to Plasma 6.
* Incorporated some improvements from Mircea Kitsune.
Expand Down
3 changes: 3 additions & 0 deletions package/contents/config/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
<entry name="listOpacity" type="Int">
<default>80</default>
</entry>
<entry name="animateBusyIndicator" type="Bool">
<default>true</default>
</entry>
</group>

</kcfg>
33 changes: 29 additions & 4 deletions package/contents/ui/FullRepresentation.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import QtQuick 2.15
import QtQml.XmlListModel
import QtQuick.Controls

import org.kde.kirigami as Kirigami
import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.plasmoid

Expand Down Expand Up @@ -46,7 +47,7 @@ Item {
XmlListModelRole { name: "description"; elementName: "description" }
XmlListModelRole { name: "link"; elementName: "link" }

onStatusChanged: busyIndicator.running = true
onStatusChanged: busyIndicator.isBusy = true
}

Component {
Expand All @@ -55,7 +56,7 @@ Item {
height: layout.height
width: thefeed.width
color: PlasmaCore.Theme.viewBackgroundColor
Component.onCompleted: busyIndicator.running = false
Component.onCompleted: busyIndicator.isBusy = false

Item {
height: layout.height
Expand Down Expand Up @@ -165,10 +166,34 @@ Item {
snapMode: ListView.SnapToItem
}

BusyIndicator {
Item {
id: busyIndicator
running: true
property bool isBusy: true
property var animate: plasmoid.configuration.animateBusyIndicator

onAnimateChanged: updateIndicator()
onIsBusyChanged: updateIndicator()

anchors.centerIn: parent

function updateIndicator() {
animated.running = isBusy && animate
icon.visible = isBusy && !animate
}

BusyIndicator {
id: animated
running: isBusy && animate
anchors.centerIn: parent
}

Kirigami.Icon {
id: icon
source: "view-refresh"
anchors.centerIn: parent
width: animated.width
height: width
}
}

Timer {
Expand Down
10 changes: 9 additions & 1 deletion package/contents/ui/config/ConfigGeneral.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Item {
property alias cfg_url: url.text
property alias cfg_headerColor: headerColorDialog.selectedColor
property alias cfg_listOpacity: listOpacity.value
property alias cfg_animateBusyIndicator: animateBusyIndicator.checked

GridLayout {
id: generalConfig
Expand Down Expand Up @@ -35,7 +36,7 @@ Item {
}

Text {
text: "Header Color"
text: "Header colour"
}
Rectangle {
id: headerColor
Expand Down Expand Up @@ -84,6 +85,13 @@ Item {
return Math.round(Number.fromLocaleString(locale, text) * decimalFactor)
}
}

Text {
}
CheckBox {
id: animateBusyIndicator
text: "Use loading animation"
}
}

ColorDialog {
Expand Down

0 comments on commit d02bdfb

Please sign in to comment.