clipboard
This commit is contained in:
parent
4d4d7673de
commit
6a5454f72a
@ -1,4 +1,5 @@
|
|||||||
import 'package:ffi/ffi.dart';
|
import 'package:ffi/ffi.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:device_info/device_info.dart';
|
import 'package:device_info/device_info.dart';
|
||||||
@ -61,6 +62,10 @@ class FfiModel with ChangeNotifier {
|
|||||||
_display = Display();
|
_display = Display();
|
||||||
_decoding = false;
|
_decoding = false;
|
||||||
_waitForImage = false;
|
_waitForImage = false;
|
||||||
|
clearPermissions();
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearPermissions() {
|
||||||
_permissions.clear();
|
_permissions.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,6 +91,8 @@ class FfiModel with ChangeNotifier {
|
|||||||
FFI.cursorModel.updateCursorId(evt);
|
FFI.cursorModel.updateCursorId(evt);
|
||||||
} else if (name == 'cursor_position') {
|
} else if (name == 'cursor_position') {
|
||||||
pos = evt;
|
pos = evt;
|
||||||
|
} else if (name == 'clipboard') {
|
||||||
|
Clipboard.setData(ClipboardData(text: evt['content']));
|
||||||
} else if (name == 'permission') {
|
} else if (name == 'permission') {
|
||||||
FFI.ffiModel.updatePermission(evt);
|
FFI.ffiModel.updatePermission(evt);
|
||||||
}
|
}
|
||||||
@ -438,6 +445,11 @@ class FFI {
|
|||||||
json.encode(modify({'type': 'wheel', 'y': y2.toString()})));
|
json.encode(modify({'type': 'wheel', 'y': y2.toString()})));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void reconnect() {
|
||||||
|
setByName('reconnect');
|
||||||
|
FFI.ffiModel.clearPermissions();
|
||||||
|
}
|
||||||
|
|
||||||
static void resetModifiers() {
|
static void resetModifiers() {
|
||||||
shift = ctrl = alt = command = false;
|
shift = ctrl = alt = command = false;
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
if (hasRetry) {
|
if (hasRetry) {
|
||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
_timer = Timer(Duration(seconds: _reconnects), () {
|
_timer = Timer(Duration(seconds: _reconnects), () {
|
||||||
FFI.setByName('reconnect');
|
FFI.reconnect();
|
||||||
showLoading('Connecting...', context);
|
showLoading('Connecting...', context);
|
||||||
});
|
});
|
||||||
_reconnects *= 2;
|
_reconnects *= 2;
|
||||||
@ -718,31 +718,39 @@ void showActions(BuildContext context) {
|
|||||||
final size = MediaQuery.of(context).size;
|
final size = MediaQuery.of(context).size;
|
||||||
final x = 120.0;
|
final x = 120.0;
|
||||||
final y = size.height;
|
final y = size.height;
|
||||||
|
var more = <Widget>[];
|
||||||
|
if (FFI.ffiModel.pi.version.isNotEmpty) {
|
||||||
|
more.add(PopupMenuItem<String>(child: Text('Refresh'), value: 'refresh'));
|
||||||
|
}
|
||||||
|
if (FFI.ffiModel.permissions['keyboard'] != false &&
|
||||||
|
FFI.ffiModel.permissions['clipboard'] != false) {
|
||||||
|
more.add(PopupMenuItem<String>(child: Text('Paste'), value: 'paste'));
|
||||||
|
}
|
||||||
() async {
|
() async {
|
||||||
var value = await showMenu(
|
var value = await showMenu(
|
||||||
context: context,
|
context: context,
|
||||||
position: RelativeRect.fromLTRB(x, y, x, y),
|
position: RelativeRect.fromLTRB(x, y, x, y),
|
||||||
items: [
|
items: <Widget>[
|
||||||
PopupMenuItem<String>(
|
PopupMenuItem<String>(
|
||||||
child: Text('Insert Ctrl + Alt + Del'), value: 'cad'),
|
child: Text('Insert Ctrl + Alt + Del'), value: 'cad'),
|
||||||
PopupMenuItem<String>(child: Text('Insert Lock'), value: 'lock'),
|
PopupMenuItem<String>(child: Text('Insert Lock'), value: 'lock'),
|
||||||
] +
|
] +
|
||||||
(FFI.ffiModel.pi.version.isEmpty
|
more,
|
||||||
? []
|
|
||||||
: [
|
|
||||||
PopupMenuItem<String>(
|
|
||||||
child: Text('Refresh'), value: 'refresh'),
|
|
||||||
]),
|
|
||||||
elevation: 8,
|
elevation: 8,
|
||||||
);
|
);
|
||||||
if (value == 'cad') {
|
if (value == 'cad') {
|
||||||
FFI.setByName('ctrl_alt_del');
|
FFI.setByName('ctrl_alt_del');
|
||||||
}
|
} else if (value == 'lock') {
|
||||||
if (value == 'lock') {
|
|
||||||
FFI.setByName('lock_screen');
|
FFI.setByName('lock_screen');
|
||||||
}
|
} else if (value == 'refresh') {
|
||||||
if (value == 'refresh') {
|
|
||||||
FFI.setByName('refresh');
|
FFI.setByName('refresh');
|
||||||
|
} else if (value == 'paste') {
|
||||||
|
() async {
|
||||||
|
ClipboardData data = await Clipboard.getData(Clipboard.kTextPlain);
|
||||||
|
if (data.text != null) {
|
||||||
|
FFI.setByName('input_string', '${data.text}');
|
||||||
|
}
|
||||||
|
}();
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user