Disable buttons when they're loading
This commit is contained in:
parent
bf3847dd66
commit
0c0ede8b40
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue
Block a user