diff --git a/flutter/lib/desktop/pages/file_manager_tab_page.dart b/flutter/lib/desktop/pages/file_manager_tab_page.dart index 1412ba059..1e349c6f0 100644 --- a/flutter/lib/desktop/pages/file_manager_tab_page.dart +++ b/flutter/lib/desktop/pages/file_manager_tab_page.dart @@ -129,7 +129,7 @@ class _FileManagerTabPageState extends State { } else { final opt = "enable-confirm-closing-tabs"; final bool res; - if (!option2bool(opt, await bind.mainGetLocalOption(key: opt))) { + if (!option2bool(opt, bind.mainGetLocalOption(key: opt))) { res = true; } else { res = await closeConfirmDialog(); diff --git a/flutter/lib/desktop/pages/remote_tab_page.dart b/flutter/lib/desktop/pages/remote_tab_page.dart index 712ded223..f2ceb9d8f 100644 --- a/flutter/lib/desktop/pages/remote_tab_page.dart +++ b/flutter/lib/desktop/pages/remote_tab_page.dart @@ -19,6 +19,8 @@ import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; import 'package:bot_toast/bot_toast.dart'; +import '../../common/widgets/dialog.dart'; +import '../../common/widgets/toolbar.dart'; import '../../models/platform_model.dart'; class _MenuTheme { @@ -45,16 +47,17 @@ class _ConnectionTabPageState extends State { static const IconData unselectedIcon = Icons.desktop_windows_outlined; late ToolbarState _toolbarState; + String? peerId; var connectionMap = RxList.empty(growable: true); _ConnectionTabPageState(Map params) { _toolbarState = ToolbarState(); RemoteCountState.init(); - final peerId = params['id']; + peerId = params['id']; final sessionId = params['session_id']; if (peerId != null) { - ConnectionTypeState.init(peerId); + ConnectionTypeState.init(peerId!); tabController.onSelected = (id) { final remotePage = tabController.widget(id); if (remotePage is RemotePage) { @@ -66,14 +69,14 @@ class _ConnectionTabPageState extends State { UnreadChatCountState.find(id).value = 0; }; tabController.add(TabInfo( - key: peerId, - label: peerId, + key: peerId!, + label: peerId!, selectedIcon: selectedIcon, unselectedIcon: unselectedIcon, onTabCloseButton: () => tabController.closeBy(peerId), page: RemotePage( key: ValueKey(peerId), - id: peerId, + id: peerId!, sessionId: sessionId == null ? null : SessionID(sessionId), password: params['password'], toolbarState: _toolbarState, @@ -213,6 +216,9 @@ class _ConnectionTabPageState extends State { } var msgFingerprint = '${translate('Fingerprint')}:\n'; var fingerprint = FingerprintState.find(key).value; + if (fingerprint.isEmpty) { + fingerprint = 'N/A'; + } if (fingerprint.length > 5 * 8) { var first = fingerprint.substring(0, 39); var second = fingerprint.substring(40); @@ -285,17 +291,6 @@ class _ConnectionTabPageState extends State { final perms = ffi.ffiModel.permissions; final sessionId = ffi.sessionId; menu.addAll([ - MenuEntryButton( - childBuilder: (TextStyle? style) => Text( - translate('Close'), - style: style, - ), - proc: () { - tabController.closeBy(key); - cancelFunc(); - }, - padding: padding, - ), MenuEntryButton( childBuilder: (TextStyle? style) => Obx(() => Text( translate( @@ -308,27 +303,8 @@ class _ConnectionTabPageState extends State { }, padding: padding, ), - MenuEntryDivider(), - RemoteMenuEntry.viewStyle( - key, - ffi, - padding, - dismissFunc: cancelFunc, - ), ]); - if (!ffi.canvasModel.cursorEmbedded && - !ffi.ffiModel.viewOnly && - !pi.is_wayland) { - menu.add(MenuEntryDivider()); - menu.add(RemoteMenuEntry.showRemoteCursor( - key, - sessionId, - padding, - dismissFunc: cancelFunc, - )); - } - if (tabController.state.value.tabs.length > 1) { final splitAction = MenuEntryButton( childBuilder: (TextStyle? style) => Text( @@ -336,8 +312,8 @@ class _ConnectionTabPageState extends State { style: style, ), proc: () async { - await DesktopMultiWindow.invokeMethod( - kMainWindowId, kWindowEventMoveTabToNewWindow, '${windowId()},$key,$sessionId'); + await DesktopMultiWindow.invokeMethod(kMainWindowId, + kWindowEventMoveTabToNewWindow, '${windowId()},$key,$sessionId'); cancelFunc(); }, padding: padding, @@ -345,31 +321,49 @@ class _ConnectionTabPageState extends State { menu.insert(1, splitAction); } - if (perms['keyboard'] != false && !ffi.ffiModel.viewOnly) { - if (perms['clipboard'] != false) { - menu.add(RemoteMenuEntry.disableClipboard(sessionId, padding, - dismissFunc: cancelFunc)); - } - - menu.add(RemoteMenuEntry.insertLock(sessionId, padding, - dismissFunc: cancelFunc)); - - if (pi.platform == kPeerPlatformLinux || pi.sasEnabled) { - menu.add(RemoteMenuEntry.insertCtrlAltDel(sessionId, padding, - dismissFunc: cancelFunc)); - } + if (perms['restart'] != false && + (pi.platform == kPeerPlatformLinux || + pi.platform == kPeerPlatformWindows || + pi.platform == kPeerPlatformMacOS)) { + menu.add(MenuEntryButton( + childBuilder: (TextStyle? style) => Text( + translate('Restart Remote Device'), + style: style, + ), + proc: () => showRestartRemoteDevice( + pi, peerId ?? '', sessionId, ffi.dialogManager), + padding: padding, + dismissOnClicked: true, + dismissCallback: cancelFunc, + )); } - menu.add(MenuEntryButton( - childBuilder: (TextStyle? style) => Text( - translate('Copy Fingerprint'), - style: style, + if (perms['keyboard'] != false && !ffi.ffiModel.viewOnly) {} + + menu.addAll([ + MenuEntryDivider(), + MenuEntryButton( + childBuilder: (TextStyle? style) => Text( + translate('Copy Fingerprint'), + style: style, + ), + proc: () => onCopyFingerprint(FingerprintState.find(key).value), + padding: padding, + dismissOnClicked: true, + dismissCallback: cancelFunc, ), - proc: () => onCopyFingerprint(FingerprintState.find(key).value), - padding: padding, - dismissOnClicked: true, - dismissCallback: cancelFunc, - )); + MenuEntryButton( + childBuilder: (TextStyle? style) => Text( + translate('Close'), + style: style, + ), + proc: () { + tabController.closeBy(key); + cancelFunc(); + }, + padding: padding, + ) + ]); return mod_menu.PopupMenu( items: menu @@ -405,7 +399,7 @@ class _ConnectionTabPageState extends State { } else { final opt = "enable-confirm-closing-tabs"; final bool res; - if (!option2bool(opt, await bind.mainGetLocalOption(key: opt))) { + if (!option2bool(opt, bind.mainGetLocalOption(key: opt))) { res = true; } else { res = await closeConfirmDialog(); diff --git a/flutter/lib/desktop/pages/server_page.dart b/flutter/lib/desktop/pages/server_page.dart index c22935f09..ce7b26b58 100644 --- a/flutter/lib/desktop/pages/server_page.dart +++ b/flutter/lib/desktop/pages/server_page.dart @@ -254,7 +254,7 @@ class ConnectionManagerState extends State { } else { final opt = "enable-confirm-closing-tabs"; final bool res; - if (!option2bool(opt, await bind.mainGetLocalOption(key: opt))) { + if (!option2bool(opt, bind.mainGetLocalOption(key: opt))) { res = true; } else { res = await closeConfirmDialog();