widgets: add DankRefreshButton and use it

This commit is contained in:
bbedward
2026-09-02 09:59:51 -04:00
parent 875d32176d
commit 3effe6e7db
10 changed files with 38 additions and 112 deletions
Generated
+3 -3
View File
@@ -3,11 +3,11 @@
"dank-qml-common": {
"flake": false,
"locked": {
"lastModified": 1788356469,
"narHash": "sha256-Ix5qkwAVJkslauOoRdcvIVyLwOm05kp7Q39cdKwNp2w=",
"lastModified": 1788357544,
"narHash": "sha256-3iKd3Wg2p/1Ii7YVkMpvwwsrn1ttF4Dun/N7Jxwv1Vg=",
"owner": "AvengeMedia",
"repo": "dank-qml-common",
"rev": "55aadfe506bd491122421aab8c9c0b8bb2501e45",
"rev": "bc8e3e4421a80e8b76ce2aaae901158b187c6490",
"type": "github"
},
"original": {
@@ -165,13 +165,13 @@ Rectangle {
}
}
DankActionButton {
DankRefreshButton {
anchors.verticalCenter: parent.verticalCenter
iconName: "refresh"
buttonSize: 28
iconSize: 16
iconColor: Theme.surfaceVariantText
visible: currentConnectionType === "wifi" && NetworkService.wifiEnabled && !NetworkService.wifiToggling && !NetworkService.isScanning
visible: currentConnectionType === "wifi" && NetworkService.wifiEnabled && !NetworkService.wifiToggling
busy: NetworkService.isScanning
onClicked: NetworkService.scanWifi()
}
@@ -182,10 +182,10 @@ Rectangle {
textSize: Theme.fontSizeSmall
readonly property var labelsByType: ({
"ethernet": I18n.tr("Ethernet"),
"wifi": I18n.tr("WiFi"),
"cellular": I18n.tr("Cellular")
})
"ethernet": I18n.tr("Ethernet"),
"wifi": I18n.tr("WiFi"),
"cellular": I18n.tr("Cellular")
})
visible: connectionTypes.length > 1 && NetworkService.backend === "networkmanager" && DMSService.apiVersion > 10
model: connectionTypes.map(t => labelsByType[t] || t)
@@ -176,28 +176,15 @@ DankPopout {
color: SystemUpdateService.hasError ? Theme.error : Theme.surfaceVariantText
}
DankActionButton {
DankRefreshButton {
id: refreshButton
buttonSize: 28
iconName: "refresh"
iconSize: 18
iconColor: Theme.surfaceText
enabled: !SystemUpdateService.isChecking && !SystemUpdateService.isUpgrading
opacity: enabled ? 1.0 : 0.5
busy: SystemUpdateService.isChecking
enabled: !busy && !SystemUpdateService.isUpgrading
opacity: SystemUpdateService.isUpgrading ? 0.5 : 1.0
onClicked: SystemUpdateService.checkForUpdates()
RotationAnimator on rotation {
from: 0
to: 360
duration: 1000
loops: Animation.Infinite
running: SystemUpdateService.isChecking
onRunningChanged: {
if (!running)
refreshButton.rotation = 0;
}
}
}
}
}
+4 -28
View File
@@ -155,33 +155,21 @@ Item {
anchors.verticalCenter: parent.verticalCenter
}
DankActionButton {
DankRefreshButton {
id: refreshButtonTwo
anchors.verticalCenter: parent.verticalCenter
iconName: isRefreshing ? "" : "refresh"
iconColor: Theme.withAlpha(Theme.surfaceText, 0.4)
tooltipText: I18n.tr("Refresh Weather")
tooltipSide: "left"
enabled: !isRefreshing
property bool isRefreshing: false
busy: refreshTimerTwo.running
onClicked: {
isRefreshing = true;
WeatherService.forceRefresh();
refreshTimerTwo.restart();
}
DankSpinner {
anchors.centerIn: parent
size: refreshButtonTwo.iconSize
visible: refreshButtonTwo.isRefreshing
}
Timer {
id: refreshTimerTwo
interval: 2000
onTriggered: refreshButtonTwo.isRefreshing = false
}
}
}
@@ -856,34 +844,22 @@ Item {
onClicked: SessionData.setWeatherHourlyDetailed(!SessionData.weatherHourlyDetailed)
}
DankActionButton {
DankRefreshButton {
id: refreshButton
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
iconName: isRefreshing ? "" : "refresh"
iconColor: Theme.withAlpha(Theme.surfaceText, 0.4)
tooltipText: I18n.tr("Refresh Weather")
tooltipSide: "left"
enabled: !isRefreshing
property bool isRefreshing: false
busy: refreshTimer.running
onClicked: {
isRefreshing = true;
WeatherService.forceRefresh();
refreshTimer.restart();
}
DankSpinner {
anchors.centerIn: parent
size: refreshButton.iconSize
visible: refreshButton.isRefreshing
}
Timer {
id: refreshTimer
interval: 2000
onTriggered: refreshButton.isRefreshing = false
}
}
}
@@ -193,10 +193,10 @@ Item {
onClicked: PopoutService.showHiddenNetworkModal()
}
DankActionButton {
iconName: "refresh"
DankRefreshButton {
buttonSize: 32
visible: NetworkService.wifiEnabled && !NetworkService.wifiToggling && !NetworkService.isScanning
visible: NetworkService.wifiEnabled && !NetworkService.wifiToggling
busy: NetworkService.isScanning
onClicked: NetworkService.scanWifi()
}
+4 -22
View File
@@ -464,21 +464,12 @@ Item {
}
}
DankActionButton {
DankRefreshButton {
id: scanDevicesBtn
iconName: "refresh"
buttonSize: 32
anchors.verticalCenter: parent.verticalCenter
enabled: !CupsService.loadingDevices
busy: CupsService.loadingDevices
onClicked: CupsService.getDevices()
RotationAnimator on rotation {
running: CupsService.loadingDevices
loops: Animation.Infinite
from: 0
to: 360
duration: 1000
}
}
}
@@ -745,21 +736,12 @@ Item {
}
}
DankActionButton {
DankRefreshButton {
id: refreshPpdsBtn
iconName: "refresh"
buttonSize: 32
anchors.verticalCenter: parent.verticalCenter
enabled: !CupsService.loadingPPDs
busy: CupsService.loadingPPDs
onClicked: CupsService.getPPDs()
RotationAnimator on rotation {
running: CupsService.loadingPPDs
loops: Animation.Infinite
from: 0
to: 360
duration: 1000
}
}
}
+2 -3
View File
@@ -352,12 +352,11 @@ DankFloatingWindow {
anchors.verticalCenter: parent.verticalCenter
spacing: Theme.spacingXS
DankActionButton {
DankRefreshButton {
id: refreshButton
iconName: "refresh"
iconSize: 18
iconColor: Theme.primary
visible: !root.isLoading
busy: root.isLoading
onClicked: root.refreshThemes()
}
+7 -28
View File
@@ -749,42 +749,21 @@ Item {
width: parent.width
height: 70
DankIcon {
DankRefreshButton {
id: refreshButton
name: "refresh"
size: Theme.iconSize - 4
color: Theme.onSurface_38
anchors.right: parent.right
anchors.top: parent.top
smoothTransform: isRefreshing
property bool isRefreshing: false
enabled: !isRefreshing
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: parent.enabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
onClicked: {
refreshButton.isRefreshing = true;
WeatherService.forceRefresh();
refreshTimer.restart();
}
enabled: parent.enabled
iconSize: Theme.iconSize - 4
iconColor: Theme.onSurface_38
busy: refreshTimer.running
onClicked: {
WeatherService.forceRefresh();
refreshTimer.restart();
}
Timer {
id: refreshTimer
interval: 2000
onTriggered: refreshButton.isRefreshing = false
}
RotationAnimator on rotation {
running: refreshButton.isRefreshing
from: 0
to: 360
duration: 1000
loops: Animation.Infinite
}
}
+3
View File
@@ -0,0 +1,3 @@
import qs.DankCommon.Widgets as DankCommon
DankCommon.DankRefreshButton {}