diff --git a/src/app/global/utils.nim b/src/app/global/utils.nim index 77d4182338..6e9d6ec5de 100644 --- a/src/app/global/utils.nim +++ b/src/app/global/utils.nim @@ -82,9 +82,6 @@ QtObject: proc downloadImageByUrl*(self: Utils, url: string, path: string) {.slot.} = downloadImageByUrl(url, path) - proc restartApplication*(self: Utils) {.slot.} = - restartApplication() - proc generateQRCodeSVG*(self: Utils, text: string, border: int = 0): string = var qr0: array[0..qrcodegen_BUFFER_LEN_MAX, uint8] var tempBuffer: array[0..qrcodegen_BUFFER_LEN_MAX, uint8] diff --git a/storybook/pages/ConfirmChangePasswordModalPage.qml b/storybook/pages/ConfirmChangePasswordModalPage.qml index 4c15922d91..9473a5eb1c 100644 --- a/storybook/pages/ConfirmChangePasswordModalPage.qml +++ b/storybook/pages/ConfirmChangePasswordModalPage.qml @@ -6,16 +6,8 @@ import AppLayouts.Profile.popups 1.0 import Storybook 1.0 -import utils 1.0 - SplitView { - id: root - PopupBackground { - id: popupBg - - property var popupIntance: null - SplitView.fillWidth: true SplitView.fillHeight: true @@ -23,38 +15,21 @@ SplitView { id: reopenButton anchors.centerIn: parent text: "Reopen" - enabled: globalUtilsMock.ready onClicked: modal.open() } - QtObject { - id: globalUtilsMock - - property bool ready: false - property var globalUtils: QtObject { - function restartApplication() { - if (popupBg.popupIntance) - popupBg.popupIntance.close() - } - } - Component.onCompleted: { - Utils.globalUtilsInst = globalUtilsMock.globalUtils - globalUtilsMock.ready = true - } - } - ConfirmChangePasswordModal { id: modal + visible: true - onChangePasswordRequested: { - passwordChangedTimer.start() - } - Component.onCompleted: { - popupBg.popupIntance = modal - } + modal: false + + onChangePasswordRequested: passwordChangedTimer.start() + Timer { id: passwordChangedTimer + interval: 2000 repeat: false onTriggered: { diff --git a/ui/StatusQ/include/StatusQ/systemutilsinternal.h b/ui/StatusQ/include/StatusQ/systemutilsinternal.h index ecd129feab..fdd185092f 100644 --- a/ui/StatusQ/include/StatusQ/systemutilsinternal.h +++ b/ui/StatusQ/include/StatusQ/systemutilsinternal.h @@ -9,4 +9,5 @@ public: explicit SystemUtilsInternal(QObject *parent = nullptr); Q_INVOKABLE QString qtRuntimeVersion() const; + Q_INVOKABLE void restartApplication() const; }; diff --git a/ui/StatusQ/src/systemutilsinternal.cpp b/ui/StatusQ/src/systemutilsinternal.cpp index 92829a2f1a..33ed7be2c8 100644 --- a/ui/StatusQ/src/systemutilsinternal.cpp +++ b/ui/StatusQ/src/systemutilsinternal.cpp @@ -1,5 +1,8 @@ #include "StatusQ/systemutilsinternal.h" +#include +#include + SystemUtilsInternal::SystemUtilsInternal(QObject *parent) : QObject{parent} {} @@ -7,3 +10,9 @@ SystemUtilsInternal::SystemUtilsInternal(QObject *parent) QString SystemUtilsInternal::qtRuntimeVersion() const { return qVersion(); } + +void SystemUtilsInternal::restartApplication() const +{ + QProcess::startDetached(QCoreApplication::applicationFilePath(), {}); + QMetaObject::invokeMethod(QCoreApplication::instance(), "quit", Qt::QueuedConnection); +} diff --git a/ui/app/AppLayouts/Profile/popups/ConfirmChangePasswordModal.qml b/ui/app/AppLayouts/Profile/popups/ConfirmChangePasswordModal.qml index 5899aa1627..ec677e91e7 100644 --- a/ui/app/AppLayouts/Profile/popups/ConfirmChangePasswordModal.qml +++ b/ui/app/AppLayouts/Profile/popups/ConfirmChangePasswordModal.qml @@ -177,7 +177,7 @@ StatusDialog { enabled: !d.dbEncryptionInProgress onClicked: { if (d.passwordChanged) { - Utils.restartApplication(); + SystemUtils.restartApplication(); } else { d.dbEncryptionInProgress = true root.changePasswordRequested() diff --git a/ui/app/AppLayouts/Profile/views/AdvancedView.qml b/ui/app/AppLayouts/Profile/views/AdvancedView.qml index 0023d89658..374d5edd79 100644 --- a/ui/app/AppLayouts/Profile/views/AdvancedView.qml +++ b/ui/app/AppLayouts/Profile/views/AdvancedView.qml @@ -362,7 +362,7 @@ SettingsContentBase { headerSettings.title: qsTr("Language reset") confirmationText: qsTr("Display language will be switched back to English. You must restart the application for changes to take effect.") confirmButtonLabel: qsTr("Restart") - onConfirmButtonClicked: Utils.restartApplication() + onConfirmButtonClicked: SystemUtils.restartApplication() } } @@ -517,7 +517,7 @@ SettingsContentBase { onConfirmButtonClicked: { root.advancedStore.toggleIsGoerliEnabled() close() - Utils.restartApplication() + SystemUtils.restartApplication() } onCancelButtonClicked: { close() diff --git a/ui/app/AppLayouts/Profile/views/LanguageView.qml b/ui/app/AppLayouts/Profile/views/LanguageView.qml index a04cc28572..aa7eabf7a9 100644 --- a/ui/app/AppLayouts/Profile/views/LanguageView.qml +++ b/ui/app/AppLayouts/Profile/views/LanguageView.qml @@ -232,9 +232,7 @@ SettingsContentBase { headerSettings.title: qsTr("Change language") confirmationText: qsTr("Display language has been changed. You must restart the application for changes to take effect.") confirmButtonLabel: qsTr("Restart") - onConfirmButtonClicked: { - Utils.restartApplication() - } + onConfirmButtonClicked: SystemUtils.restartApplication() } } } diff --git a/ui/imports/utils/Utils.qml b/ui/imports/utils/Utils.qml index 76ac4a39dd..d5a9e8d748 100644 --- a/ui/imports/utils/Utils.qml +++ b/ui/imports/utils/Utils.qml @@ -767,10 +767,6 @@ QtObject { property var globalUtilsInst: typeof globalUtils !== "undefined" ? globalUtils : null property var communitiesModuleInst: typeof communitiesModule !== "undefined" ? communitiesModule : null - function restartApplication() { - globalUtilsInst.restartApplication() - } - function isChatKey(value) { return (startsWith0x(value) && isHex(value) && value.length === 132) || globalUtilsInst.isCompressedPubKey(value) }