add missing cm close window handler

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages 2022-11-06 21:21:57 +08:00
parent 866224ecec
commit a5f647196c

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) {