From 0c0ede8b40b7ce0aeb53e0326abec4337c17fc17 Mon Sep 17 00:00:00 2001 From: miruka Date: Tue, 27 Aug 2019 14:21:10 -0400 Subject: [PATCH] Disable buttons when they're loading --- src/qml/Base/HButton.qml | 5 +++-- src/qml/Base/HButtonBackground.qml | 3 ++- src/qml/Base/HButtonContent.qml | 3 ++- src/qml/Base/HInterfaceBox.qml | 2 +- src/themes/Default.qpl | 1 + 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/qml/Base/HButton.qml b/src/qml/Base/HButton.qml index a730486c..1cd39fe7 100644 --- a/src/qml/Base/HButton.qml +++ b/src/qml/Base/HButton.qml @@ -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 diff --git a/src/qml/Base/HButtonBackground.qml b/src/qml/Base/HButtonBackground.qml index b9ee24cb..90840219 100644 --- a/src/qml/Base/HButtonBackground.qml +++ b/src/qml/Base/HButtonBackground.qml @@ -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 diff --git a/src/qml/Base/HButtonContent.qml b/src/qml/Base/HButtonContent.qml index d2123c0c..5ac905d7 100644 --- a/src/qml/Base/HButtonContent.qml +++ b/src/qml/Base/HButtonContent.qml @@ -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 diff --git a/src/qml/Base/HInterfaceBox.qml b/src/qml/Base/HInterfaceBox.qml index 076432b5..d6d5c8b2 100644 --- a/src/qml/Base/HInterfaceBox.qml +++ b/src/qml/Base/HInterfaceBox.qml @@ -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 diff --git a/src/themes/Default.qpl b/src/themes/Default.qpl index 8f8b1ecd..5fddf349 100644 --- a/src/themes/Default.qpl +++ b/src/themes/Default.qpl @@ -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"