Disable buttons when they're loading

This commit is contained in:
miruka 2019-08-27 14:21:10 -04:00
parent bf3847dd66
commit 0c0ede8b40
5 changed files with 9 additions and 5 deletions

View File

@ -6,10 +6,11 @@ Button {
id: button
spacing: theme.spacing
leftPadding: spacing / 1.5
rightPadding: spacing / 1.5
rightPadding: leftPadding
topPadding: spacing / 2
bottomPadding: spacing / 2
bottomPadding: topPadding
iconItem.svgName: loading ? "hourglass" : icon.name
enabled: ! loading
onVisibleChanged: if (! visible) loading = false

View File

@ -2,7 +2,8 @@ import QtQuick 2.12
import QtQuick.Controls 2.12
HRectangle {
opacity: enabled ? 1 : theme.disabledElementsOpacity
opacity: loading ? theme.loadingElementsOpacity :
enabled ? 1 : theme.disabledElementsOpacity
property AbstractButton button

View File

@ -4,7 +4,8 @@ import QtQuick.Layouts 1.12
HRowLayout {
spacing: button.spacing
opacity: enabled ? 1 : theme.disabledElementsOpacity
opacity: loading ? theme.loadingElementsOpacity :
enabled ? 1 : theme.disabledElementsOpacity
property AbstractButton button

View File

@ -74,7 +74,7 @@ HRectangle {
id: button
text: modelData.text
icon.name: modelData.iconName || ""
enabled: modelData.enabled
enabled: modelData.enabled && ! button.loading
onClicked: buttonCallbacks[modelData.name](button)
Layout.fillWidth: true

View File

@ -19,6 +19,7 @@ int baseElementsHeight: 36 * uiScale
int spacing: 12 * uiScale
int radius: 5
int animationDuration: 100
real loadingElementsOpacity: 0.8
real disabledElementsOpacity: 0.3
string preferredIconPack: "light-thin"