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.} =
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]

View File

@ -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: {

View File

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

View File

@ -1,5 +1,8 @@
#include "StatusQ/systemutilsinternal.h"
#include <QCoreApplication>
#include <QProcess>
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);
}

View File

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

View File

@ -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()

View File

@ -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()
}
}
}

View File

@ -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)
}