remove custom resolution
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
c4cefdb54b
commit
d339fd178b
@ -29,10 +29,6 @@ const _kKeyLegacyMode = 'legacy';
|
|||||||
const _kKeyMapMode = 'map';
|
const _kKeyMapMode = 'map';
|
||||||
const _kKeyTranslateMode = 'translate';
|
const _kKeyTranslateMode = 'translate';
|
||||||
|
|
||||||
const _kResolutionOrigin = 'Origin';
|
|
||||||
const _kResolutionCustom = 'Custom';
|
|
||||||
const _kResolutionFitLocal = 'FitLocal';
|
|
||||||
|
|
||||||
class MenubarState {
|
class MenubarState {
|
||||||
final kStoreKey = 'remoteMenubarState';
|
final kStoreKey = 'remoteMenubarState';
|
||||||
late RxBool show;
|
late RxBool show;
|
||||||
@ -1002,10 +998,6 @@ class _ResolutionsMenu extends StatefulWidget {
|
|||||||
class _ResolutionsMenuState extends State<_ResolutionsMenu> {
|
class _ResolutionsMenuState extends State<_ResolutionsMenu> {
|
||||||
String _groupValue = '';
|
String _groupValue = '';
|
||||||
Resolution? _localResolution;
|
Resolution? _localResolution;
|
||||||
late final _customWidth =
|
|
||||||
TextEditingController(text: display.width.toString());
|
|
||||||
late final _customHeight =
|
|
||||||
TextEditingController(text: display.height.toString());
|
|
||||||
|
|
||||||
PeerInfo get pi => widget.ffi.ffiModel.pi;
|
PeerInfo get pi => widget.ffi.ffiModel.pi;
|
||||||
FfiModel get ffiModel => widget.ffi.ffiModel;
|
FfiModel get ffiModel => widget.ffi.ffiModel;
|
||||||
@ -1020,8 +1012,9 @@ class _ResolutionsMenuState extends State<_ResolutionsMenu> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final isVirtualDisplay = display.isVirtualDisplayResolution;
|
final isVirtualDisplay = display.isVirtualDisplayResolution;
|
||||||
final visible =
|
// final visible =
|
||||||
ffiModel.keyboard && (isVirtualDisplay || resolutions.length > 1);
|
// ffiModel.keyboard && (isVirtualDisplay || resolutions.length > 1);
|
||||||
|
final visible = ffiModel.keyboard && resolutions.length > 1;
|
||||||
if (!visible) return Offstage();
|
if (!visible) return Offstage();
|
||||||
_groupValue = '${display.width}x${display.height}';
|
_groupValue = '${display.width}x${display.height}';
|
||||||
_getLocalResolution();
|
_getLocalResolution();
|
||||||
@ -1034,12 +1027,22 @@ class _ResolutionsMenuState extends State<_ResolutionsMenu> {
|
|||||||
menuChildren: <Widget>[
|
menuChildren: <Widget>[
|
||||||
_OriginalResolutionMenuButton(showOriginalBtn),
|
_OriginalResolutionMenuButton(showOriginalBtn),
|
||||||
_FitLocalResolutionMenuButton(showFitLocalBtn),
|
_FitLocalResolutionMenuButton(showFitLocalBtn),
|
||||||
_customResolutionMenuButton(isVirtualDisplay),
|
// _customResolutionMenuButton(isVirtualDisplay),
|
||||||
|
_menuDivider(showOriginalBtn, showFitLocalBtn, isVirtualDisplay),
|
||||||
] +
|
] +
|
||||||
_supportedResolutionMenuButtons(),
|
_supportedResolutionMenuButtons(),
|
||||||
child: Text(translate("Resolution")));
|
child: Text(translate("Resolution")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_menuDivider(
|
||||||
|
bool showOriginalBtn, bool showFitLocalBtn, bool isVirtualDisplay) {
|
||||||
|
return Offstage(
|
||||||
|
// offstage: !(showOriginalBtn || showFitLocalBtn || isVirtualDisplay),
|
||||||
|
offstage: !(showOriginalBtn || showFitLocalBtn),
|
||||||
|
child: Divider(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
_getLocalResolution() {
|
_getLocalResolution() {
|
||||||
_localResolution = null;
|
_localResolution = null;
|
||||||
final String currentDisplay = bind.mainGetCurrentDisplay();
|
final String currentDisplay = bind.mainGetCurrentDisplay();
|
||||||
@ -1057,30 +1060,17 @@ class _ResolutionsMenuState extends State<_ResolutionsMenu> {
|
|||||||
|
|
||||||
_onChanged(String? value) async {
|
_onChanged(String? value) async {
|
||||||
if (value == null) return;
|
if (value == null) return;
|
||||||
|
|
||||||
int? w;
|
|
||||||
int? h;
|
|
||||||
if (value == _kResolutionOrigin) {
|
|
||||||
w = display.originalWidth;
|
|
||||||
h = display.originalHeight;
|
|
||||||
} else if (value == _kResolutionFitLocal) {
|
|
||||||
final resolution = _getBestFitResolution();
|
|
||||||
if (resolution != null) {
|
|
||||||
w = resolution.width;
|
|
||||||
h = resolution.height;
|
|
||||||
}
|
|
||||||
} else if (value == _kResolutionCustom) {
|
|
||||||
w = int.tryParse(_customWidth.value as String);
|
|
||||||
h = int.tryParse(_customHeight.value as String);
|
|
||||||
} else {
|
|
||||||
final list = value.split('x');
|
final list = value.split('x');
|
||||||
if (list.length == 2) {
|
if (list.length == 2) {
|
||||||
w = int.tryParse(list[0]);
|
final w = int.tryParse(list[0]);
|
||||||
h = int.tryParse(list[1]);
|
final h = int.tryParse(list[1]);
|
||||||
|
if (w != null && h != null) {
|
||||||
|
await _changeResolution(w, h);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w != null && h != null) {
|
_changeResolution(int w, int h) async {
|
||||||
await bind.sessionChangeResolution(
|
await bind.sessionChangeResolution(
|
||||||
id: widget.id,
|
id: widget.id,
|
||||||
width: w,
|
width: w,
|
||||||
@ -1095,15 +1085,13 @@ class _ResolutionsMenuState extends State<_ResolutionsMenu> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Widget _OriginalResolutionMenuButton(bool showOriginalBtn) {
|
Widget _OriginalResolutionMenuButton(bool showOriginalBtn) {
|
||||||
return Offstage(
|
return Offstage(
|
||||||
offstage: !showOriginalBtn,
|
offstage: !showOriginalBtn,
|
||||||
child: RdoMenuButton(
|
child: MenuButton(
|
||||||
value: _kResolutionOrigin,
|
onPressed: () =>
|
||||||
groupValue: _groupValue,
|
_changeResolution(display.originalWidth, display.originalHeight),
|
||||||
onChanged: _onChanged,
|
|
||||||
ffi: widget.ffi,
|
ffi: widget.ffi,
|
||||||
child: Text(
|
child: Text(
|
||||||
'${translate('Original')} ${display.originalWidth}x${display.originalHeight}'),
|
'${translate('Original')} ${display.originalWidth}x${display.originalHeight}'),
|
||||||
@ -1114,10 +1102,13 @@ class _ResolutionsMenuState extends State<_ResolutionsMenu> {
|
|||||||
Widget _FitLocalResolutionMenuButton(bool showFitLocalBtn) {
|
Widget _FitLocalResolutionMenuButton(bool showFitLocalBtn) {
|
||||||
return Offstage(
|
return Offstage(
|
||||||
offstage: !showFitLocalBtn,
|
offstage: !showFitLocalBtn,
|
||||||
child: RdoMenuButton(
|
child: MenuButton(
|
||||||
value: _kResolutionFitLocal,
|
onPressed: () {
|
||||||
groupValue: _groupValue,
|
final resolution = _getBestFitResolution();
|
||||||
onChanged: _onChanged,
|
if (resolution != null) {
|
||||||
|
_changeResolution(resolution.width, resolution.height);
|
||||||
|
}
|
||||||
|
},
|
||||||
ffi: widget.ffi,
|
ffi: widget.ffi,
|
||||||
child: Text(
|
child: Text(
|
||||||
'${translate('Fit Local')} ${_localResolution?.width ?? 0}x${_localResolution?.height ?? 0}'),
|
'${translate('Fit Local')} ${_localResolution?.width ?? 0}x${_localResolution?.height ?? 0}'),
|
||||||
@ -1137,50 +1128,61 @@ class _ResolutionsMenuState extends State<_ResolutionsMenu> {
|
|||||||
Widget _customResolutionMenuButton(bool showCustomBtn) {
|
Widget _customResolutionMenuButton(bool showCustomBtn) {
|
||||||
return Offstage(
|
return Offstage(
|
||||||
offstage: !showCustomBtn,
|
offstage: !showCustomBtn,
|
||||||
child: RdoMenuButton(
|
child: MenuButton(
|
||||||
value: _kResolutionCustom,
|
onPressed: () => _customResolutionDialog(),
|
||||||
groupValue: _groupValue,
|
|
||||||
onChanged: _onChanged,
|
|
||||||
ffi: widget.ffi,
|
ffi: widget.ffi,
|
||||||
child: _customResolutionWidget(),
|
child:
|
||||||
|
Text('${translate('Custom')} ${display.width}x${display.height}'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _customResolutionWidget() {
|
_customResolutionDialog() async {
|
||||||
return Column(
|
OverlayDialogManager dialogManager = widget.ffi.dialogManager;
|
||||||
|
dialogManager.dismissAll();
|
||||||
|
dialogManager.show((setState, close, context) {
|
||||||
|
cancel() {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return CustomAlertDialog(
|
||||||
|
title: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Text(translate('Custom')),
|
Icon(Icons.password_rounded, color: MyTheme.accent),
|
||||||
Container(
|
Text(translate('Custom width x height')).paddingOnly(left: 10),
|
||||||
width: 5,
|
|
||||||
),
|
|
||||||
// _resolutionInput(_customWidth),
|
|
||||||
Container(
|
|
||||||
width: 3,
|
|
||||||
),
|
|
||||||
Text('x'),
|
|
||||||
Container(
|
|
||||||
width: 3,
|
|
||||||
),
|
|
||||||
// _resolutionInput(_customHeight),
|
|
||||||
],
|
],
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
TextField _resolutionInput(TextEditingController controller) {
|
|
||||||
return TextField(
|
|
||||||
decoration: InputDecoration(
|
|
||||||
border: InputBorder.none,
|
|
||||||
isDense: true,
|
|
||||||
),
|
),
|
||||||
keyboardType: TextInputType.number,
|
content: Column(
|
||||||
inputFormatters: <TextInputFormatter>[
|
mainAxisSize: MainAxisSize.min,
|
||||||
FilteringTextInputFormatter.digitsOnly,
|
children: [
|
||||||
LengthLimitingTextInputFormatter(4),
|
Slider(
|
||||||
FilteringTextInputFormatter.allow(RegExp(r'[0-9]')),
|
value: display.width.toDouble(),
|
||||||
|
min: 256,
|
||||||
|
max: 8192,
|
||||||
|
divisions: 1,
|
||||||
|
onChanged: (double value) {},
|
||||||
|
),
|
||||||
|
Slider(
|
||||||
|
value: display.height.toDouble(),
|
||||||
|
min: 256,
|
||||||
|
max: 8192,
|
||||||
|
divisions: 1,
|
||||||
|
onChanged: (double value) {},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
controller: controller,
|
),
|
||||||
|
actions: [
|
||||||
|
dialogButton(
|
||||||
|
'Cancel',
|
||||||
|
icon: Icon(Icons.close_rounded),
|
||||||
|
onPressed: cancel,
|
||||||
|
isOutline: true,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
onCancel: cancel,
|
||||||
);
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Resolution? _getBestFitResolution() {
|
Resolution? _getBestFitResolution() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user