enable rust default option

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2022-11-17 18:52:27 +08:00
parent 7bb39f5607
commit 75d8168070
9 changed files with 162 additions and 82 deletions

View File

@@ -246,13 +246,12 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
dismissOnClicked: true,
),
],
curOptionGetter: () async {
return await bind.sessionGetOption(id: key, arg: 'view-style') ??
'adaptive';
},
curOptionGetter: () async =>
// null means peer id is not found, which there's no need to care about
await bind.sessionGetViewStyle(id: key) ?? '',
optionSetter: (String oldValue, String newValue) async {
await bind.sessionPeerOption(
id: key, name: "view-style", value: newValue);
await bind.sessionSetViewStyle(
id: key, value: newValue);
ffi.canvasModel.updateViewStyle();
cancelFunc();
},

View File

@@ -22,7 +22,7 @@ import './popup_menu.dart';
import './material_mod_popup_menu.dart' as mod_menu;
class MenubarState {
final kStoreKey = "remoteMenubarState";
final kStoreKey = 'remoteMenubarState';
late RxBool show;
late RxBool _pin;
@@ -195,7 +195,7 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
}
_updateScreen() async {
final v = await DesktopMultiWindow.invokeMethod(0, "get_window_info", "");
final v = await DesktopMultiWindow.invokeMethod(0, 'get_window_info', '');
final String valueStr = v;
if (valueStr.isEmpty) {
_screen = null;
@@ -322,7 +322,7 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
child: Obx(() {
RxInt display = CurrentDisplayState.find(widget.id);
return Text(
"${display.value + 1}/${pi.displays.length}",
'${display.value + 1}/${pi.displays.length}',
style: const TextStyle(
color: _MenubarTheme.commonColor, fontSize: 8),
);
@@ -595,10 +595,10 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
));
}
}
if (perms["restart"] != false &&
(pi.platform == "Linux" ||
pi.platform == "Windows" ||
pi.platform == "Mac OS")) {
if (perms['restart'] != false &&
(pi.platform == 'Linux' ||
pi.platform == 'Windows' ||
pi.platform == 'Mac OS')) {
displayMenu.add(MenuEntryButton<String>(
childBuilder: (TextStyle? style) => Text(
translate('Restart Remote Device'),
@@ -629,14 +629,14 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
displayMenu.add(MenuEntryButton<String>(
childBuilder: (TextStyle? style) => Obx(() => Text(
translate(
'${BlockInputState.find(widget.id).value ? "Unb" : "B"}lock user input'),
'${BlockInputState.find(widget.id).value ? 'Unb' : 'B'}lock user input'),
style: style,
)),
proc: () {
RxBool blockInput = BlockInputState.find(widget.id);
bind.sessionToggleOption(
id: widget.id,
value: '${blockInput.value ? "un" : ""}block-input');
value: '${blockInput.value ? 'un' : ''}block-input');
blockInput.value = !blockInput.value;
},
padding: padding,
@@ -671,7 +671,7 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
// ClipboardData? data =
// await Clipboard.getData(Clipboard.kTextPlain);
// if (data != null && data.text != null) {
// bind.sessionInputString(id: widget.id, value: data.text ?? "");
// bind.sessionInputString(id: widget.id, value: data.text ?? '');
// }
// }();
// },
@@ -679,18 +679,6 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
// dismissOnClicked: true,
// ));
// }
displayMenu.add(MenuEntryButton<String>(
childBuilder: (TextStyle? style) => Text(
translate('Reset canvas'),
style: style,
),
proc: () {
widget.ffi.cursorModel.reset();
},
padding: padding,
dismissOnClicked: true,
));
}
return displayMenu;
@@ -740,14 +728,11 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
dismissOnClicked: true,
),
],
curOptionGetter: () async {
return await bind.sessionGetOption(
id: widget.id, arg: 'view-style') ??
'adaptive';
},
curOptionGetter: () async =>
// null means peer id is not found, which there's no need to care about
await bind.sessionGetViewStyle(id: widget.id) ?? '',
optionSetter: (String oldValue, String newValue) async {
await bind.sessionPeerOption(
id: widget.id, name: "view-style", value: newValue);
await bind.sessionSetViewStyle(id: widget.id, value: newValue);
widget.ffi.canvasModel.updateViewStyle();
},
padding: padding,
@@ -768,14 +753,11 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
dismissOnClicked: true,
),
],
curOptionGetter: () async {
return await bind.sessionGetOption(
id: widget.id, arg: 'scroll-style') ??
'';
},
curOptionGetter: () async =>
// null means peer id is not found, which there's no need to care about
await bind.sessionGetScrollStyle(id: widget.id) ?? '',
optionSetter: (String oldValue, String newValue) async {
await bind.sessionPeerOption(
id: widget.id, name: "scroll-style", value: newValue);
await bind.sessionSetScrollStyle(id: widget.id, value: newValue);
widget.ffi.canvasModel.updateScrollStyle();
},
padding: padding,
@@ -805,12 +787,9 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
value: 'custom',
dismissOnClicked: true),
],
curOptionGetter: () async {
String quality =
await bind.sessionGetImageQuality(id: widget.id) ?? 'balanced';
if (quality == '') quality = 'balanced';
return quality;
},
curOptionGetter: () async =>
// null means peer id is not found, which there's no need to care about
await bind.sessionGetImageQuality(id: widget.id) ?? '',
optionSetter: (String oldValue, String newValue) async {
if (oldValue != newValue) {
await bind.sessionSetImageQuality(id: widget.id, value: newValue);
@@ -1075,14 +1054,14 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
}
return list;
},
curOptionGetter: () async {
return await bind.sessionGetOption(
id: widget.id, arg: 'codec-preference') ??
'auto';
},
curOptionGetter: () async =>
// null means peer id is not found, which there's no need to care about
await bind.sessionGetOption(
id: widget.id, arg: 'codec-preference') ??
'',
optionSetter: (String oldValue, String newValue) async {
await bind.sessionPeerOption(
id: widget.id, name: "codec-preference", value: newValue);
id: widget.id, name: 'codec-preference', value: newValue);
bind.sessionChangePreferCodec(id: widget.id);
},
padding: padding,
@@ -1195,9 +1174,8 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
MenuEntryRadioOption(text: translate('Legacy mode'), value: 'legacy'),
MenuEntryRadioOption(text: translate('Map mode'), value: 'map'),
],
curOptionGetter: () async {
return await bind.sessionGetKeyboardName(id: widget.id);
},
curOptionGetter: () async =>
await bind.sessionGetKeyboardName(id: widget.id),
optionSetter: (String oldValue, String newValue) async {
await bind.sessionSetKeyboardMode(
id: widget.id, keyboardMode: newValue);
@@ -1229,16 +1207,16 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
void showSetOSPassword(
String id, bool login, OverlayDialogManager dialogManager) async {
final controller = TextEditingController();
var password = await bind.sessionGetOption(id: id, arg: "os-password") ?? "";
var autoLogin = await bind.sessionGetOption(id: id, arg: "auto-login") != "";
var password = await bind.sessionGetOption(id: id, arg: 'os-password') ?? '';
var autoLogin = await bind.sessionGetOption(id: id, arg: 'auto-login') != '';
controller.text = password;
dialogManager.show((setState, close) {
submit() {
var text = controller.text.trim();
bind.sessionPeerOption(id: id, name: "os-password", value: text);
bind.sessionPeerOption(id: id, name: 'os-password', value: text);
bind.sessionPeerOption(
id: id, name: "auto-login", value: autoLogin ? 'Y' : '');
if (text != "" && login) {
id: id, name: 'auto-login', value: autoLogin ? 'Y' : '');
if (text != '' && login) {
bind.sessionInputOsPassword(id: id, value: text);
}
close();
@@ -1285,7 +1263,7 @@ void showAuditDialog(String id, dialogManager) async {
dialogManager.show((setState, close) {
submit() {
var text = controller.text.trim();
if (text != "") {
if (text != '') {
bind.sessionSendNote(id: id, note: text);
}
close();
@@ -1324,11 +1302,11 @@ void showAuditDialog(String id, dialogManager) async {
keyboardType: TextInputType.multiline,
textInputAction: TextInputAction.newline,
decoration: const InputDecoration.collapsed(
hintText: "input note here",
hintText: 'input note here',
),
// inputFormatters: [
// LengthLimitingTextInputFormatter(16),
// // FilteringTextInputFormatter(RegExp(r"[a-zA-z][a-zA-z0-9\_]*"), allow: true)
// // FilteringTextInputFormatter(RegExp(r'[a-zA-z][a-zA-z0-9\_]*'), allow: true)
// ],
maxLines: null,
maxLength: 256,

View File

@@ -474,7 +474,7 @@ class _RemotePageState extends State<RemotePage> {
},
onTwoFingerScaleEnd: (d) {
_scale = 1;
bind.sessionPeerOption(id: widget.id, name: "view-style", value: "");
bind.sessionSetViewStyle(id: widget.id, value: "");
},
onThreeFingerVerticalDragUpdate: gFFI.ffiModel.isPeerAndroid
? null
@@ -1001,7 +1001,7 @@ void showOptions(
setState(() {
viewStyle = value;
bind
.sessionPeerOption(id: id, name: "view-style", value: value)
.sessionSetViewStyle(id: id, value: value)
.then((_) => gFFI.canvasModel.updateViewStyle());
});
}

View File

@@ -413,7 +413,7 @@ class ImageModel with ChangeNotifier {
await initializeCursorAndCanvas(parent.target!);
}
if (parent.target?.ffiModel.isPeerAndroid ?? false) {
bind.sessionPeerOption(id: id, name: 'view-style', value: 'adaptive');
bind.sessionSetViewStyle(id: id, value: 'adaptive');
parent.target?.canvasModel.updateViewStyle();
}
}
@@ -535,7 +535,7 @@ class CanvasModel with ChangeNotifier {
double get scrollY => _scrollY;
updateViewStyle() async {
final style = await bind.sessionGetOption(id: id, arg: 'view-style');
final style = await bind.sessionGetViewStyle(id: id);
if (style == null) {
return;
}
@@ -561,7 +561,7 @@ class CanvasModel with ChangeNotifier {
}
updateScrollStyle() async {
final style = await bind.sessionGetOption(id: id, arg: 'scroll-style');
final style = await bind.sessionGetScrollStyle(id: id);
if (style == 'scrollbar') {
_scrollStyle = ScrollStyle.scrollbar;
_scrollX = 0.0;