添加退出确认 (#174)

This commit is contained in:
orz12 2023-06-06 12:16:07 +08:00 committed by GitHub
parent bbaa8a0235
commit 81440000b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 181 additions and 160 deletions

View File

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick
import QtQuick.Dialogs
import QtQuick.Controls
import QtQuick.Window
import "Logic.js" as Logic
@ -17,7 +18,7 @@ Window {
property var callbacks: Logic.callbacks
property var tipList: []
Item {
Item {
id: mainWindow
width: (parent.width / parent.height < 960 / 540)
? 960 : 540 * parent.width / parent.height
@ -66,6 +67,7 @@ Item {
property bool busy: false
property string busyText: ""
onBusyChanged: busyText = "";
property bool closing: false
BusyIndicator {
id: busyIndicator
@ -181,7 +183,7 @@ Item {
callbacks["ErrorMsg"]("Unknown command " + command + "!");
}
}
}
}
Shortcut {
sequences: [ StandardKey.FullScreen ]
@ -217,10 +219,25 @@ Item {
tipList = tips.trim().split("\n");
}
onClosing: {
MessageDialog {
id: exitMessageDialog
title: realMainWin.title
informativeText: qsTr("Are you sure to exit?")
buttons: MessageDialog.Ok | MessageDialog.Cancel
onAccepted: {
mainWindow.closing = true;
config.winWidth = width;
config.winHeight = height;
config.saveConf();
Backend.quitLobby(false);
realMainWin.close();
}
}
onClosing: (closeEvent) => {
if (!mainWindow.closing) {
closeEvent.accepted = false;
exitMessageDialog.open();
}
}
}

View File

@ -167,6 +167,10 @@
<source>updated packages for md5</source>
<translation></translation>
</message>
<message>
<source>Are you sure to exit?</source>
<translation>退</translation>
</message>
</context>
<context>