restartApplication() removed from Utils.qml and nim

This commit is contained in:
Michał Cieślak 2024-10-08 14:51:48 +02:00 committed by Michał
parent 417ad03ce1
commit 3f9f175e07
8 changed files with 20 additions and 44 deletions

View File

@ -82,9 +82,6 @@ QtObject:
proc downloadImageByUrl*(self: Utils, url: string, path: string) {.slot.} = proc downloadImageByUrl*(self: Utils, url: string, path: string) {.slot.} =
downloadImageByUrl(url, path) downloadImageByUrl(url, path)
proc restartApplication*(self: Utils) {.slot.} =
restartApplication()
proc generateQRCodeSVG*(self: Utils, text: string, border: int = 0): string = proc generateQRCodeSVG*(self: Utils, text: string, border: int = 0): string =
var qr0: array[0..qrcodegen_BUFFER_LEN_MAX, uint8] var qr0: array[0..qrcodegen_BUFFER_LEN_MAX, uint8]
var tempBuffer: array[0..qrcodegen_BUFFER_LEN_MAX, uint8] var tempBuffer: array[0..qrcodegen_BUFFER_LEN_MAX, uint8]

View File

@ -6,16 +6,8 @@ import AppLayouts.Profile.popups 1.0
import Storybook 1.0 import Storybook 1.0
import utils 1.0
SplitView { SplitView {
id: root
PopupBackground { PopupBackground {
id: popupBg
property var popupIntance: null
SplitView.fillWidth: true SplitView.fillWidth: true
SplitView.fillHeight: true SplitView.fillHeight: true
@ -23,38 +15,21 @@ SplitView {
id: reopenButton id: reopenButton
anchors.centerIn: parent anchors.centerIn: parent
text: "Reopen" text: "Reopen"
enabled: globalUtilsMock.ready
onClicked: modal.open() 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 { ConfirmChangePasswordModal {
id: modal id: modal
visible: true visible: true
onChangePasswordRequested: { modal: false
passwordChangedTimer.start()
} onChangePasswordRequested: passwordChangedTimer.start()
Component.onCompleted: {
popupBg.popupIntance = modal
}
Timer { Timer {
id: passwordChangedTimer id: passwordChangedTimer
interval: 2000 interval: 2000
repeat: false repeat: false
onTriggered: { onTriggered: {

View File

@ -9,4 +9,5 @@ public:
explicit SystemUtilsInternal(QObject *parent = nullptr); explicit SystemUtilsInternal(QObject *parent = nullptr);
Q_INVOKABLE QString qtRuntimeVersion() const; Q_INVOKABLE QString qtRuntimeVersion() const;
Q_INVOKABLE void restartApplication() const;
}; };

View File

@ -1,5 +1,8 @@
#include "StatusQ/systemutilsinternal.h" #include "StatusQ/systemutilsinternal.h"
#include <QCoreApplication>
#include <QProcess>
SystemUtilsInternal::SystemUtilsInternal(QObject *parent) SystemUtilsInternal::SystemUtilsInternal(QObject *parent)
: QObject{parent} : QObject{parent}
{} {}
@ -7,3 +10,9 @@ SystemUtilsInternal::SystemUtilsInternal(QObject *parent)
QString SystemUtilsInternal::qtRuntimeVersion() const { QString SystemUtilsInternal::qtRuntimeVersion() const {
return qVersion(); return qVersion();
} }
void SystemUtilsInternal::restartApplication() const
{
QProcess::startDetached(QCoreApplication::applicationFilePath(), {});
QMetaObject::invokeMethod(QCoreApplication::instance(), "quit", Qt::QueuedConnection);
}

View File

@ -177,7 +177,7 @@ StatusDialog {
enabled: !d.dbEncryptionInProgress enabled: !d.dbEncryptionInProgress
onClicked: { onClicked: {
if (d.passwordChanged) { if (d.passwordChanged) {
Utils.restartApplication(); SystemUtils.restartApplication();
} else { } else {
d.dbEncryptionInProgress = true d.dbEncryptionInProgress = true
root.changePasswordRequested() root.changePasswordRequested()

View File

@ -362,7 +362,7 @@ SettingsContentBase {
headerSettings.title: qsTr("Language reset") 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.") confirmationText: qsTr("Display language will be switched back to English. You must restart the application for changes to take effect.")
confirmButtonLabel: qsTr("Restart") confirmButtonLabel: qsTr("Restart")
onConfirmButtonClicked: Utils.restartApplication() onConfirmButtonClicked: SystemUtils.restartApplication()
} }
} }
@ -517,7 +517,7 @@ SettingsContentBase {
onConfirmButtonClicked: { onConfirmButtonClicked: {
root.advancedStore.toggleIsGoerliEnabled() root.advancedStore.toggleIsGoerliEnabled()
close() close()
Utils.restartApplication() SystemUtils.restartApplication()
} }
onCancelButtonClicked: { onCancelButtonClicked: {
close() close()

View File

@ -232,9 +232,7 @@ SettingsContentBase {
headerSettings.title: qsTr("Change language") headerSettings.title: qsTr("Change language")
confirmationText: qsTr("Display language has been changed. You must restart the application for changes to take effect.") confirmationText: qsTr("Display language has been changed. You must restart the application for changes to take effect.")
confirmButtonLabel: qsTr("Restart") confirmButtonLabel: qsTr("Restart")
onConfirmButtonClicked: { onConfirmButtonClicked: SystemUtils.restartApplication()
Utils.restartApplication()
}
} }
} }
} }

View File

@ -767,10 +767,6 @@ QtObject {
property var globalUtilsInst: typeof globalUtils !== "undefined" ? globalUtils : null property var globalUtilsInst: typeof globalUtils !== "undefined" ? globalUtils : null
property var communitiesModuleInst: typeof communitiesModule !== "undefined" ? communitiesModule : null property var communitiesModuleInst: typeof communitiesModule !== "undefined" ? communitiesModule : null
function restartApplication() {
globalUtilsInst.restartApplication()
}
function isChatKey(value) { function isChatKey(value) {
return (startsWith0x(value) && isHex(value) && value.length === 132) || globalUtilsInst.isCompressedPubKey(value) return (startsWith0x(value) && isHex(value) && value.length === 132) || globalUtilsInst.isCompressedPubKey(value)
} }