mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-12 06:41:30 +03:00
add confirm before closing multiple tabs
This commit is contained in:
@@ -232,11 +232,11 @@ class _GeneralState extends State<_General> {
|
||||
controller: scrollController,
|
||||
children: [
|
||||
theme(),
|
||||
abr(),
|
||||
hwcodec(),
|
||||
audio(context),
|
||||
record(context),
|
||||
_Card(title: 'Language', children: [language()]),
|
||||
other()
|
||||
],
|
||||
).marginOnly(bottom: _kListViewBottomMargin));
|
||||
}
|
||||
@@ -267,8 +267,10 @@ class _GeneralState extends State<_General> {
|
||||
]);
|
||||
}
|
||||
|
||||
Widget abr() {
|
||||
return _Card(title: 'Adaptive Bitrate', children: [
|
||||
Widget other() {
|
||||
return _Card(title: 'Other', children: [
|
||||
_OptionCheckBox(context, 'Confirm before closing multiple tabs',
|
||||
'enable-confirm-closing-tabs'),
|
||||
_OptionCheckBox(context, 'Adaptive Bitrate', 'enable-abr'),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart';
|
||||
import 'package:flutter_hbb/utils/multi_window_manager.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../mobile/widgets/dialog.dart';
|
||||
import '../../models/platform_model.dart';
|
||||
|
||||
/// File Transfer for multi tabs
|
||||
class FileManagerTabPage extends StatefulWidget {
|
||||
@@ -35,7 +35,7 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
|
||||
label: params['id'],
|
||||
selectedIcon: selectedIcon,
|
||||
unselectedIcon: unselectedIcon,
|
||||
onTabCloseButton: () => handleTabCloseButton(params['id']),
|
||||
onTabCloseButton: () => () => tabController.closeBy(params['id']),
|
||||
page: FileManagerPage(key: ValueKey(params['id']), id: params['id'])));
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
|
||||
label: id,
|
||||
selectedIcon: selectedIcon,
|
||||
unselectedIcon: unselectedIcon,
|
||||
onTabCloseButton: () => handleTabCloseButton(id),
|
||||
onTabCloseButton: () => tabController.closeBy(id),
|
||||
page: FileManagerPage(key: ValueKey(id), id: id)));
|
||||
} else if (call.method == "onDestroy") {
|
||||
tabController.clear();
|
||||
@@ -98,26 +98,19 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
|
||||
return widget.params["windowId"];
|
||||
}
|
||||
|
||||
void handleTabCloseButton(String peerId) {
|
||||
final session = ffi('ft_$peerId');
|
||||
if (session.ffiModel.pi.hostname.isNotEmpty) {
|
||||
tabController.jumpBy(peerId);
|
||||
clientClose(session.dialogManager);
|
||||
} else {
|
||||
tabController.closeBy(peerId);
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> handleWindowCloseButton() async {
|
||||
final connLength = tabController.state.value.tabs.length;
|
||||
if (connLength < 1) {
|
||||
if (connLength <= 1) {
|
||||
tabController.clear();
|
||||
return true;
|
||||
} else if (connLength == 1) {
|
||||
final currentConn = tabController.state.value.tabs[0];
|
||||
handleTabCloseButton(currentConn.key);
|
||||
return false;
|
||||
} else {
|
||||
final res = await closeConfirmDialog();
|
||||
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) {
|
||||
tabController.clear();
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import 'package:flutter_hbb/utils/multi_window_manager.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../mobile/widgets/dialog.dart';
|
||||
import '../../models/platform_model.dart';
|
||||
|
||||
class ConnectionTabPage extends StatefulWidget {
|
||||
final Map<String, dynamic> params;
|
||||
@@ -42,7 +42,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
label: peerId,
|
||||
selectedIcon: selectedIcon,
|
||||
unselectedIcon: unselectedIcon,
|
||||
onTabCloseButton: () => handleTabCloseButton(peerId),
|
||||
onTabCloseButton: () => tabController.closeBy(peerId),
|
||||
page: Obx(() => RemotePage(
|
||||
key: ValueKey(peerId),
|
||||
id: peerId,
|
||||
@@ -78,7 +78,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
label: id,
|
||||
selectedIcon: selectedIcon,
|
||||
unselectedIcon: unselectedIcon,
|
||||
onTabCloseButton: () => handleTabCloseButton(id),
|
||||
onTabCloseButton: () => tabController.closeBy(id),
|
||||
page: Obx(() => RemotePage(
|
||||
key: ValueKey(id),
|
||||
id: id,
|
||||
@@ -173,29 +173,21 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
return widget.params["windowId"];
|
||||
}
|
||||
|
||||
void handleTabCloseButton(String peerId) {
|
||||
final session = ffi(peerId);
|
||||
if (session.ffiModel.pi.hostname.isNotEmpty) {
|
||||
tabController.jumpBy(peerId);
|
||||
clientClose(session.dialogManager);
|
||||
} else {
|
||||
tabController.closeBy(peerId);
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> handleWindowCloseButton() async {
|
||||
final connLength = tabController.length;
|
||||
if (connLength < 1) {
|
||||
if (connLength <= 1) {
|
||||
tabController.clear();
|
||||
return true;
|
||||
} else if (connLength == 1) {
|
||||
final currentConn = tabController.state.value.tabs[0];
|
||||
handleTabCloseButton(currentConn.key);
|
||||
return false;
|
||||
} else {
|
||||
final res = await closeConfirmDialog();
|
||||
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) {
|
||||
tabController.clear();
|
||||
_update_remote_count();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user