From 6b3ba885568621dc7c274e7d285bcccc760bf581 Mon Sep 17 00:00:00 2001 From: Andrei Smirnov Date: Thu, 2 Sep 2021 12:57:32 +0300 Subject: [PATCH] Added app restart confirmation modal --- .../Profile/Sections/AppearanceContainer.qml | 32 ++++++++++++---- .../Sections/ConfirmAppRestartModal.qml | 38 +++++++++++++++++++ ui/app/AppLayouts/Profile/Sections/qmldir | 1 + 3 files changed, 63 insertions(+), 8 deletions(-) create mode 100644 ui/app/AppLayouts/Profile/Sections/ConfirmAppRestartModal.qml diff --git a/ui/app/AppLayouts/Profile/Sections/AppearanceContainer.qml b/ui/app/AppLayouts/Profile/Sections/AppearanceContainer.qml index 7ba4119475..664181de70 100644 --- a/ui/app/AppLayouts/Profile/Sections/AppearanceContainer.qml +++ b/ui/app/AppLayouts/Profile/Sections/AppearanceContainer.qml @@ -183,21 +183,37 @@ ScrollView { StatusSlider { id: zoomSlider + readonly property int initialValue: { + let scaleFactorStr = utilsModel.readTextFile(uiScaleFilePath) + if (scaleFactorStr === "") { + return 100 + } + let scaleFactor = parseFloat(scaleFactorStr) + if (isNaN(scaleFactor)) { + return 100 + } + return scaleFactor * 100 + } anchors.top: labelZoom.bottom anchors.topMargin: Style.current.padding width: parent.width minimumValue: 50 maximumValue: 200 stepSize: 50 - value: { - let scaleFactorStr = utilsModel.readTextFile(uiScaleFilePath) - if (scaleFactorStr === "") { - return 100 - } - return parseFloat(scaleFactorStr) * 100 - } + value: initialValue onValueChanged: { - utilsModel.writeTextFile(uiScaleFilePath, value / 100.0) + if (value !== initialValue) { + utilsModel.writeTextFile(uiScaleFilePath, value / 100.0) + } + } + onPressedChanged: { + if (!pressed && value !== initialValue) { + confirmAppRestartModal.open() + } + } + + ConfirmAppRestartModal { + id: confirmAppRestartModal } } diff --git a/ui/app/AppLayouts/Profile/Sections/ConfirmAppRestartModal.qml b/ui/app/AppLayouts/Profile/Sections/ConfirmAppRestartModal.qml new file mode 100644 index 0000000000..3a9fa3a585 --- /dev/null +++ b/ui/app/AppLayouts/Profile/Sections/ConfirmAppRestartModal.qml @@ -0,0 +1,38 @@ +import QtQuick 2.13 +import QtQuick.Controls 2.13 +import QtQuick.Layouts 1.13 +import "../../../../imports" +import "../../../../shared" +import "../../../../shared/status" + +ModalPopup { + height: 237 + width: 400 + + property Popup parentPopup + + title: qsTr("Application Restart") + + StyledText { + text: qsTr("Status app will be closed. Please restart it for the changes to take into effect.") + font.pixelSize: 15 + anchors.left: parent.left + anchors.right: parent.right + wrapMode: Text.WordWrap + } + + footer: Item { + id: footerContainer + width: parent.width + height: children[0].height + + StatusButton { + anchors.right: parent.right + anchors.rightMargin: Style.current.smallPadding + type: "warn" + text: qsTr("Proceed") + anchors.bottom: parent.bottom + onClicked: Qt.quit() + } + } +} diff --git a/ui/app/AppLayouts/Profile/Sections/qmldir b/ui/app/AppLayouts/Profile/Sections/qmldir index 91db04827d..3a3734b743 100644 --- a/ui/app/AppLayouts/Profile/Sections/qmldir +++ b/ui/app/AppLayouts/Profile/Sections/qmldir @@ -10,3 +10,4 @@ HelpContainer 1.0 HelpContainer.qml AboutContainer 1.0 AboutContainer.qml BackupSeedModal 1.0 BackupSeedModal.qml LanguageModal 1.0 LanguageModal.qml +ConfirmAppRestartModal 1.0 ConfirmAppRestartModal.qml