add confirm before closing multiple tabs

This commit is contained in:
csf 2022-10-13 21:19:05 +09:00
parent da18e69258
commit 67a5cf9771
27 changed files with 108 additions and 50 deletions

View File

@ -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'),
]);
}

View File

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

View File

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

View File

@ -456,8 +456,15 @@ class WindowActionPanel extends StatelessWidget {
}
Future<bool> closeConfirmDialog() async {
var confirm = true;
final res = await gFFI.dialogManager.show<bool>((setState, close) {
submit() => close(true);
submit() {
final opt = "enable-confirm-closing-tabs";
String value = bool2option(opt, confirm);
bind.mainSetOption(key: opt, value: value);
close(true);
}
return CustomAlertDialog(
title: Row(children: [
const Icon(Icons.warning_amber_sharp,
@ -465,7 +472,25 @@ Future<bool> closeConfirmDialog() async {
const SizedBox(width: 10),
Text(translate("Warning")),
]),
content: Text(translate("Disconnect all devices?")),
content: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(translate("Disconnect all devices?")),
CheckboxListTile(
contentPadding: const EdgeInsets.all(0),
dense: true,
controlAffinity: ListTileControlAffinity.leading,
title: Text(
translate("Confirm before closing multiple tabs"),
),
value: confirm,
onChanged: (v) {
if (v == null) return;
setState(() => confirm = v);
},
)
]), // confirm checkbox
actions: [
TextButton(onPressed: close, child: Text(translate("Cancel"))),
ElevatedButton(onPressed: submit, child: Text(translate("OK"))),

View File

@ -371,5 +371,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("uac_warning", "暂时无法访问远端设备因为远端设备正在请求用户账户权限请等待对方关闭UAC窗口。为避免这个问题建议在远端设备上安装或者以管理员权限运行本软件。"),
("elevated_foreground_window_warning", "暂时无法使用鼠标键盘,因为远端桌面的当前窗口需要更高的权限才能操作, 可以请求对方最小化当前窗口。为避免这个问题,建议在远端设备上安装或者以管理员权限运行本软件。"),
("Disconnected", "会话已结束"),
("Other", "其他"),
("Confirm before closing multiple tabs", "关闭多个标签页时向您确认"),
].iter().cloned().collect();
}

View File

@ -371,5 +371,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("uac_warning", ""),
("elevated_foreground_window_warning", ""),
("Disconnected", ""),
("Other", ""),
("Confirm before closing multiple tabs", ""),
].iter().cloned().collect();
}

View File

@ -371,5 +371,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("uac_warning", ""),
("elevated_foreground_window_warning", ""),
("Disconnected", "Afbrudt"),
("Other", ""),
("Confirm before closing multiple tabs", ""),
].iter().cloned().collect();
}

View File

@ -371,5 +371,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("uac_warning", ""),
("elevated_foreground_window_warning", ""),
("Disconnected", ""),
("Other", ""),
("Confirm before closing multiple tabs", ""),
].iter().cloned().collect();
}

View File

@ -371,5 +371,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("uac_warning", ""),
("elevated_foreground_window_warning", ""),
("Disconnected", ""),
("Other", ""),
("Confirm before closing multiple tabs", ""),
].iter().cloned().collect();
}

View File

@ -371,5 +371,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("uac_warning", ""),
("elevated_foreground_window_warning", ""),
("Disconnected", ""),
("Other", ""),
("Confirm before closing multiple tabs", ""),
].iter().cloned().collect();
}

View File

@ -193,7 +193,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Reboot required", "Redémarrage pour prendre effet"),
("Unsupported display server ", "Le serveur d'affichage actuel n'est pas pris en charge"),
("x11 expected", "Veuillez passer à x11"),
("Port", ""),
("Port", "Port"),
("Settings", "Paramètres"),
("Username", " Nom d'utilisateur"),
("Invalid port", "Port invalide"),
@ -274,7 +274,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("android_stop_service_tip", "La fermeture du service fermera automatiquement toutes les connexions établies."),
("android_version_audio_tip", "La version actuelle d'Android ne prend pas en charge la capture audio, veuillez passer à Android 10 ou supérieur."),
("android_start_service_tip", "Appuyez sur [Démarrer le service] ou sur l'autorisation OUVRIR [Capture d'écran] pour démarrer le service de partage d'écran."),
("Account", ""),
("Account", "Compte"),
("Overwrite", "Écraser"),
("This file exists, skip or overwrite this file?", "Ce fichier existe, ignorer ou écraser ce fichier ?"),
("Quit", "Quitter"),
@ -371,5 +371,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("uac_warning", ""),
("elevated_foreground_window_warning", ""),
("Disconnected", ""),
("Other", ""),
("Confirm before closing multiple tabs", ""),
].iter().cloned().collect();
}

View File

@ -371,5 +371,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("uac_warning", ""),
("elevated_foreground_window_warning", ""),
("Disconnected", ""),
("Other", ""),
("Confirm before closing multiple tabs", ""),
].iter().cloned().collect();
}

View File

@ -371,5 +371,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("uac_warning", ""),
("elevated_foreground_window_warning", ""),
("Disconnected", ""),
("Other", ""),
("Confirm before closing multiple tabs", ""),
].iter().cloned().collect();
}

View File

@ -371,5 +371,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("uac_warning", ""),
("elevated_foreground_window_warning", ""),
("Disconnected", ""),
("Other", ""),
("Confirm before closing multiple tabs", ""),
].iter().cloned().collect();
}

View File

@ -371,5 +371,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("uac_warning", ""),
("elevated_foreground_window_warning", ""),
("Disconnected", ""),
("Other", "他の"),
("Confirm before closing multiple tabs", "同時に複数のタブを閉じる前に確認する"),
].iter().cloned().collect();
}

View File

@ -371,5 +371,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("uac_warning", ""),
("elevated_foreground_window_warning", ""),
("Disconnected", ""),
("Other", ""),
("Confirm before closing multiple tabs", ""),
].iter().cloned().collect();
}

View File

@ -371,5 +371,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("uac_warning", ""),
("elevated_foreground_window_warning", ""),
("Disconnected", ""),
("Other", ""),
("Confirm before closing multiple tabs", ""),
].iter().cloned().collect();
}

View File

@ -371,5 +371,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("uac_warning", "Ostrzeżenie UAC"),
("elevated_foreground_window_warning", "Pierwszoplanowe okno ostrzeżenia o podwyższeniu uprawnień"),
("Disconnected", ""),
("Other", ""),
("Confirm before closing multiple tabs", ""),
].iter().cloned().collect();
}

View File

@ -371,5 +371,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("uac_warning", ""),
("elevated_foreground_window_warning", ""),
("Disconnected", ""),
("Other", ""),
("Confirm before closing multiple tabs", ""),
].iter().cloned().collect();
}

View File

@ -371,5 +371,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("uac_warning", ""),
("elevated_foreground_window_warning", ""),
("Disconnected", ""),
("Other", ""),
("Confirm before closing multiple tabs", ""),
].iter().cloned().collect();
}

View File

@ -371,5 +371,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("uac_warning", ""),
("elevated_foreground_window_warning", ""),
("Disconnected", ""),
("Other", ""),
("Confirm before closing multiple tabs", ""),
].iter().cloned().collect();
}

View File

@ -371,5 +371,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("uac_warning", ""),
("elevated_foreground_window_warning", ""),
("Disconnected", ""),
("Other", ""),
("Confirm before closing multiple tabs", ""),
].iter().cloned().collect();
}

View File

@ -371,5 +371,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("uac_warning", ""),
("elevated_foreground_window_warning", ""),
("Disconnected", ""),
("Other", ""),
("Confirm before closing multiple tabs", ""),
].iter().cloned().collect();
}

View File

@ -371,5 +371,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("uac_warning", ""),
("elevated_foreground_window_warning", ""),
("Disconnected", ""),
("Other", ""),
("Confirm before closing multiple tabs", ""),
].iter().cloned().collect();
}

View File

@ -371,5 +371,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("uac_warning", "暂时无法访问远端设备因为远端设备正在请求用户账户权限请等待对方关闭UAC窗口。为避免这个问题建议在远端设备上安装或者以管理员权限运行本软件。"),
("elevated_foreground_window_warning", "暫時無法使用鼠標鍵盤,因為遠端桌面的當前窗口需要更高的權限才能操作, 可以請求對方最小化當前窗口。為避免這個問題,建議在遠端設備上安裝或者以管理員權限運行本軟件。"),
("Disconnected", "會話已結束"),
("Other", "其他"),
("Confirm before closing multiple tabs", "關閉多個分頁前跟我確認"),
].iter().cloned().collect();
}

View File

@ -191,9 +191,9 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Warning", "Попередження"),
("Login screen using Wayland is not supported", "Вхід у систему з використанням Wayland не підтримується"),
("Reboot required", "Потрібне перезавантаження"),
("Unsupported display server", "Непідтримуваний сервер дисплея"),
("Unsupported display server ", ""),
("x11 expected", "Очікується X11"),
("Port", ""),
("Port", "Порт"),
("Settings", "Налаштування"),
("Username", "Ім'я користувача"),
("Invalid port", "Неправильний порт"),
@ -274,7 +274,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("android_stop_service_tip", "Закриття служби автоматично закриє всі встановлені з'єднання."),
("android_version_audio_tip", "Поточна версія Android не підтримує захоплення звуку, оновіть її до Android 10 або вище."),
("android_start_service_tip", "Натисніть [Запуск проміжного сервера] або ВІДКРИТИ роздільну здатність [Захоплення екрана], щоб запустити службу демонстрації екрана."),
("Account", ""),
("Account", "Акаунт"),
("Overwrite", "Перезаписати"),
("This file exists, skip or overwrite this file?", "Цей файл існує, пропустити або перезаписати файл?"),
("Quit", "Вийти"),
@ -298,7 +298,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Connection not allowed", "Підключення не дозволено"),
("Legacy mode", ""),
("Map mode", ""),
("Режим перекладу", ""),
("Translate mode", ""),
("Use temporary password", "Використовувати тимчасовий пароль"),
("Use permanent password", "Використовувати постійний пароль"),
("Use both passwords", "Використовувати обидва паролі"),
@ -371,5 +371,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("uac_warning", ""),
("elevated_foreground_window_warning", ""),
("Disconnected", ""),
("Other", ""),
("Confirm before closing multiple tabs", ""),
].iter().cloned().collect();
}

View File

@ -371,5 +371,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("uac_warning", ""),
("elevated_foreground_window_warning", ""),
("Disconnected", ""),
("Other", ""),
("Confirm before closing multiple tabs", ""),
].iter().cloned().collect();
}