mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
fix dialog res bug ; add desktop restart remote device
This commit is contained in:
@@ -92,7 +92,7 @@ typedef DialogBuilder = CustomAlertDialog Function(
|
||||
|
||||
class Dialog<T> {
|
||||
OverlayEntry? entry;
|
||||
Completer<T?> completer = Completer<T>();
|
||||
Completer<T?> completer = Completer<T?>();
|
||||
|
||||
Dialog();
|
||||
|
||||
@@ -101,9 +101,10 @@ class Dialog<T> {
|
||||
if (!completer.isCompleted) {
|
||||
completer.complete(res);
|
||||
}
|
||||
entry?.remove();
|
||||
} catch (e) {
|
||||
debugPrint("Dialog complete catch error: $e");
|
||||
} finally {
|
||||
entry?.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -589,11 +589,10 @@ class _RemotePageState extends State<RemotePage>
|
||||
more.add(PopupMenuItem<String>(
|
||||
child: Row(
|
||||
children: ([
|
||||
Container(width: 100.0, child: Text(translate('OS Password'))),
|
||||
Text(translate('OS Password')),
|
||||
TextButton(
|
||||
style: flatButtonStyle,
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
showSetOSPassword(widget.id, false, _ffi.dialogManager);
|
||||
},
|
||||
child: Icon(Icons.edit, color: MyTheme.accent),
|
||||
@@ -625,6 +624,13 @@ class _RemotePageState extends State<RemotePage>
|
||||
value: 'block-input'));
|
||||
}
|
||||
}
|
||||
if (gFFI.ffiModel.permissions["restart"] != false &&
|
||||
(pi.platform == "Linux" ||
|
||||
pi.platform == "Windows" ||
|
||||
pi.platform == "Mac OS")) {
|
||||
more.add(PopupMenuItem<String>(
|
||||
child: Text(translate('Restart Remote Device')), value: 'restart'));
|
||||
}
|
||||
() async {
|
||||
var value = await showMenu(
|
||||
context: context,
|
||||
@@ -652,6 +658,7 @@ class _RemotePageState extends State<RemotePage>
|
||||
}();
|
||||
} else if (value == 'enter_os_password') {
|
||||
// FIXME:
|
||||
// TODO icon diff
|
||||
// null means no session of id
|
||||
// empty string means no password
|
||||
var password = await bind.getSessionOption(id: id, arg: "os-password");
|
||||
@@ -662,6 +669,8 @@ class _RemotePageState extends State<RemotePage>
|
||||
}
|
||||
} else if (value == 'reset_canvas') {
|
||||
_ffi.cursorModel.reset();
|
||||
} else if (value == 'restart') {
|
||||
showRestartRemoteDevice(pi, widget.id, gFFI.dialogManager);
|
||||
}
|
||||
}();
|
||||
}
|
||||
|
||||
@@ -670,7 +670,6 @@ class _RemotePageState extends State<RemotePage> {
|
||||
TextButton(
|
||||
style: flatButtonStyle,
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
showSetOSPassword(id, false, gFFI.dialogManager);
|
||||
},
|
||||
child: Icon(Icons.edit, color: MyTheme.accent),
|
||||
@@ -1110,28 +1109,6 @@ void showOptions(String id, OverlayDialogManager dialogManager) async {
|
||||
}, clickMaskDismiss: true, backDismiss: true);
|
||||
}
|
||||
|
||||
void showRestartRemoteDevice(
|
||||
PeerInfo pi, String id, OverlayDialogManager dialogManager) async {
|
||||
final res =
|
||||
await dialogManager.show<bool>((setState, close) => CustomAlertDialog(
|
||||
title: Row(children: [
|
||||
Icon(Icons.warning_amber_sharp,
|
||||
color: Colors.redAccent, size: 28),
|
||||
SizedBox(width: 10),
|
||||
Text(translate("Restart Remote Device")),
|
||||
]),
|
||||
content: Text(
|
||||
"${translate('Are you sure you want to restart')} \n${pi.username}@${pi.hostname}($id) ?"),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => close(), child: Text(translate("Cancel"))),
|
||||
ElevatedButton(
|
||||
onPressed: () => close(true), child: Text(translate("OK"))),
|
||||
],
|
||||
));
|
||||
if (res == true) bind.sessionRestartRemoteDevice(id: id);
|
||||
}
|
||||
|
||||
void showSetOSPassword(
|
||||
String id, bool login, OverlayDialogManager dialogManager) async {
|
||||
final controller = TextEditingController();
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../common.dart';
|
||||
import '../../models/model.dart';
|
||||
import '../../models/platform_model.dart';
|
||||
|
||||
void clientClose(OverlayDialogManager dialogManager) {
|
||||
@@ -16,6 +17,28 @@ void showError() {
|
||||
showToast(translate("Error"));
|
||||
}
|
||||
|
||||
void showRestartRemoteDevice(
|
||||
PeerInfo pi, String id, OverlayDialogManager dialogManager) async {
|
||||
final res =
|
||||
await dialogManager.show<bool>((setState, close) => CustomAlertDialog(
|
||||
title: Row(children: [
|
||||
Icon(Icons.warning_amber_sharp,
|
||||
color: Colors.redAccent, size: 28),
|
||||
SizedBox(width: 10),
|
||||
Text(translate("Restart Remote Device")),
|
||||
]),
|
||||
content: Text(
|
||||
"${translate('Are you sure you want to restart')} \n${pi.username}@${pi.hostname}($id) ?"),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => close(), child: Text(translate("Cancel"))),
|
||||
ElevatedButton(
|
||||
onPressed: () => close(true), child: Text(translate("OK"))),
|
||||
],
|
||||
));
|
||||
if (res == true) bind.sessionRestartRemoteDevice(id: id);
|
||||
}
|
||||
|
||||
void setPermanentPasswordDialog(OverlayDialogManager dialogManager) async {
|
||||
final pw = await bind.mainGetPermanentPassword();
|
||||
final p0 = TextEditingController(text: pw);
|
||||
|
||||
@@ -1050,7 +1050,6 @@ class FFI {
|
||||
await for (final message in stream) {
|
||||
if (message is Event) {
|
||||
try {
|
||||
debugPrint("event:${message.field0}");
|
||||
Map<String, dynamic> event = json.decode(message.field0);
|
||||
cb(event);
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user