Disable buttons when they're loading
This commit is contained in:
parent
bf3847dd66
commit
0c0ede8b40
|
@ -6,10 +6,11 @@ Button {
|
||||||
id: button
|
id: button
|
||||||
spacing: theme.spacing
|
spacing: theme.spacing
|
||||||
leftPadding: spacing / 1.5
|
leftPadding: spacing / 1.5
|
||||||
rightPadding: spacing / 1.5
|
rightPadding: leftPadding
|
||||||
topPadding: spacing / 2
|
topPadding: spacing / 2
|
||||||
bottomPadding: spacing / 2
|
bottomPadding: topPadding
|
||||||
iconItem.svgName: loading ? "hourglass" : icon.name
|
iconItem.svgName: loading ? "hourglass" : icon.name
|
||||||
|
enabled: ! loading
|
||||||
|
|
||||||
onVisibleChanged: if (! visible) loading = false
|
onVisibleChanged: if (! visible) loading = false
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@ import QtQuick 2.12
|
||||||
import QtQuick.Controls 2.12
|
import QtQuick.Controls 2.12
|
||||||
|
|
||||||
HRectangle {
|
HRectangle {
|
||||||
opacity: enabled ? 1 : theme.disabledElementsOpacity
|
opacity: loading ? theme.loadingElementsOpacity :
|
||||||
|
enabled ? 1 : theme.disabledElementsOpacity
|
||||||
|
|
||||||
|
|
||||||
property AbstractButton button
|
property AbstractButton button
|
||||||
|
|
|
@ -4,7 +4,8 @@ import QtQuick.Layouts 1.12
|
||||||
|
|
||||||
HRowLayout {
|
HRowLayout {
|
||||||
spacing: button.spacing
|
spacing: button.spacing
|
||||||
opacity: enabled ? 1 : theme.disabledElementsOpacity
|
opacity: loading ? theme.loadingElementsOpacity :
|
||||||
|
enabled ? 1 : theme.disabledElementsOpacity
|
||||||
|
|
||||||
|
|
||||||
property AbstractButton button
|
property AbstractButton button
|
||||||
|
|
|
@ -74,7 +74,7 @@ HRectangle {
|
||||||
id: button
|
id: button
|
||||||
text: modelData.text
|
text: modelData.text
|
||||||
icon.name: modelData.iconName || ""
|
icon.name: modelData.iconName || ""
|
||||||
enabled: modelData.enabled
|
enabled: modelData.enabled && ! button.loading
|
||||||
onClicked: buttonCallbacks[modelData.name](button)
|
onClicked: buttonCallbacks[modelData.name](button)
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
|
@ -19,6 +19,7 @@ int baseElementsHeight: 36 * uiScale
|
||||||
int spacing: 12 * uiScale
|
int spacing: 12 * uiScale
|
||||||
int radius: 5
|
int radius: 5
|
||||||
int animationDuration: 100
|
int animationDuration: 100
|
||||||
|
real loadingElementsOpacity: 0.8
|
||||||
real disabledElementsOpacity: 0.3
|
real disabledElementsOpacity: 0.3
|
||||||
|
|
||||||
string preferredIconPack: "light-thin"
|
string preferredIconPack: "light-thin"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user