Merge pull request #1983 from 21pages/cm

add missing cm close window handler
This commit is contained in:
RustDesk 2022-11-07 05:54:05 +08:00 committed by GitHub
commit d89c1d3093
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -134,6 +134,7 @@ class ConnectionManagerState extends State<ConnectionManager> {
showMaximize: false,
showMinimize: true,
showClose: true,
onWindowCloseButton: handleWindowCloseButton,
controller: serverModel.tabController,
maxLabelWidth: 100,
tail: buildScrollJumper(),
@ -206,6 +207,27 @@ class ConnectionManagerState extends State<ConnectionManager> {
],
));
}
Future<bool> handleWindowCloseButton() async {
var tabController = gFFI.serverModel.tabController;
final connLength = tabController.length;
if (connLength <= 1) {
windowManager.close();
return true;
} else {
final opt = "enable-confirm-closing-tabs";
final bool res;
if (!option2bool(opt, await bind.mainGetOption(key: opt))) {
res = true;
} else {
res = await closeConfirmDialog();
}
if (res) {
windowManager.close();
}
return res;
}
}
}
Widget buildConnectionCard(Client client) {