fix: desktop, remote toolbar, remember collapse (#8349)
Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
parent
12f7fc3d33
commit
07e0b5ac10
@ -496,6 +496,7 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
() => _ffi.ffiModel.pi.isSet.isFalse
|
() => _ffi.ffiModel.pi.isSet.isFalse
|
||||||
? Container(color: Colors.transparent)
|
? Container(color: Colors.transparent)
|
||||||
: Obx(() {
|
: Obx(() {
|
||||||
|
widget.toolbarState.initShow(sessionId);
|
||||||
_ffi.textureModel.updateCurrentDisplay(peerDisplay.value);
|
_ffi.textureModel.updateCurrentDisplay(peerDisplay.value);
|
||||||
return ImagePaint(
|
return ImagePaint(
|
||||||
id: widget.id,
|
id: widget.id,
|
||||||
|
@ -46,7 +46,6 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
|||||||
static const IconData selectedIcon = Icons.desktop_windows_sharp;
|
static const IconData selectedIcon = Icons.desktop_windows_sharp;
|
||||||
static const IconData unselectedIcon = Icons.desktop_windows_outlined;
|
static const IconData unselectedIcon = Icons.desktop_windows_outlined;
|
||||||
|
|
||||||
late ToolbarState _toolbarState;
|
|
||||||
String? peerId;
|
String? peerId;
|
||||||
bool _isScreenRectSet = false;
|
bool _isScreenRectSet = false;
|
||||||
int? _display;
|
int? _display;
|
||||||
@ -54,7 +53,6 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
|||||||
var connectionMap = RxList<Widget>.empty(growable: true);
|
var connectionMap = RxList<Widget>.empty(growable: true);
|
||||||
|
|
||||||
_ConnectionTabPageState(Map<String, dynamic> params) {
|
_ConnectionTabPageState(Map<String, dynamic> params) {
|
||||||
_toolbarState = ToolbarState();
|
|
||||||
RemoteCountState.init();
|
RemoteCountState.init();
|
||||||
peerId = params['id'];
|
peerId = params['id'];
|
||||||
final sessionId = params['session_id'];
|
final sessionId = params['session_id'];
|
||||||
@ -91,7 +89,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
|||||||
display: display,
|
display: display,
|
||||||
displays: displays?.cast<int>(),
|
displays: displays?.cast<int>(),
|
||||||
password: params['password'],
|
password: params['password'],
|
||||||
toolbarState: _toolbarState,
|
toolbarState: ToolbarState(),
|
||||||
tabController: tabController,
|
tabController: tabController,
|
||||||
switchUuid: params['switch_uuid'],
|
switchUuid: params['switch_uuid'],
|
||||||
forceRelay: params['forceRelay'],
|
forceRelay: params['forceRelay'],
|
||||||
@ -126,7 +124,6 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
|||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
_toolbarState.save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -251,15 +248,16 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
|||||||
final pi = ffi.ffiModel.pi;
|
final pi = ffi.ffiModel.pi;
|
||||||
final perms = ffi.ffiModel.permissions;
|
final perms = ffi.ffiModel.permissions;
|
||||||
final sessionId = ffi.sessionId;
|
final sessionId = ffi.sessionId;
|
||||||
|
final toolbarState = remotePage.toolbarState;
|
||||||
menu.addAll([
|
menu.addAll([
|
||||||
MenuEntryButton<String>(
|
MenuEntryButton<String>(
|
||||||
childBuilder: (TextStyle? style) => Obx(() => Text(
|
childBuilder: (TextStyle? style) => Obx(() => Text(
|
||||||
translate(
|
translate(
|
||||||
_toolbarState.show.isTrue ? 'Hide Toolbar' : 'Show Toolbar'),
|
toolbarState.show.isTrue ? 'Hide Toolbar' : 'Show Toolbar'),
|
||||||
style: style,
|
style: style,
|
||||||
)),
|
)),
|
||||||
proc: () {
|
proc: () {
|
||||||
_toolbarState.switchShow();
|
toolbarState.switchShow(sessionId);
|
||||||
cancelFunc();
|
cancelFunc();
|
||||||
},
|
},
|
||||||
padding: padding,
|
padding: padding,
|
||||||
@ -426,8 +424,6 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
ConnectionTypeState.init(id);
|
ConnectionTypeState.init(id);
|
||||||
_toolbarState.setShow(
|
|
||||||
bind.mainGetUserDefaultOption(key: kOptionCollapseToolbar) != 'Y');
|
|
||||||
tabController.add(TabInfo(
|
tabController.add(TabInfo(
|
||||||
key: id,
|
key: id,
|
||||||
label: id,
|
label: id,
|
||||||
@ -442,7 +438,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
|||||||
display: display,
|
display: display,
|
||||||
displays: displays?.cast<int>(),
|
displays: displays?.cast<int>(),
|
||||||
password: args['password'],
|
password: args['password'],
|
||||||
toolbarState: _toolbarState,
|
toolbarState: ToolbarState(),
|
||||||
tabController: tabController,
|
tabController: tabController,
|
||||||
switchUuid: switchUuid,
|
switchUuid: switchUuid,
|
||||||
forceRelay: args['forceRelay'],
|
forceRelay: args['forceRelay'],
|
||||||
|
@ -26,45 +26,42 @@ import './popup_menu.dart';
|
|||||||
import './kb_layout_type_chooser.dart';
|
import './kb_layout_type_chooser.dart';
|
||||||
|
|
||||||
class ToolbarState {
|
class ToolbarState {
|
||||||
late RxBool show;
|
|
||||||
late RxBool _pin;
|
late RxBool _pin;
|
||||||
|
|
||||||
|
bool isShowInited = false;
|
||||||
|
RxBool show = false.obs;
|
||||||
|
|
||||||
ToolbarState() {
|
ToolbarState() {
|
||||||
|
_pin = RxBool(false);
|
||||||
final s = bind.getLocalFlutterOption(k: kOptionRemoteMenubarState);
|
final s = bind.getLocalFlutterOption(k: kOptionRemoteMenubarState);
|
||||||
if (s.isEmpty) {
|
if (s.isEmpty) {
|
||||||
_initSet(false, false);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final m = jsonDecode(s);
|
final m = jsonDecode(s);
|
||||||
if (m == null) {
|
if (m != null) {
|
||||||
_initSet(false, false);
|
_pin = RxBool(m['pin'] ?? false);
|
||||||
} else {
|
|
||||||
_initSet(m['pin'] ?? false, m['pin'] ?? false);
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint('Failed to decode toolbar state ${e.toString()}');
|
debugPrint('Failed to decode toolbar state ${e.toString()}');
|
||||||
_initSet(false, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_initSet(bool s, bool p) {
|
|
||||||
// Show remubar when connection is established.
|
|
||||||
show = RxBool(
|
|
||||||
bind.mainGetUserDefaultOption(key: kOptionCollapseToolbar) != 'Y');
|
|
||||||
_pin = RxBool(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool get pin => _pin.value;
|
bool get pin => _pin.value;
|
||||||
|
|
||||||
switchShow() async {
|
switchShow(SessionID sessionId) async {
|
||||||
|
bind.sessionToggleOption(
|
||||||
|
sessionId: sessionId, value: kOptionCollapseToolbar);
|
||||||
show.value = !show.value;
|
show.value = !show.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
setShow(bool v) async {
|
initShow(SessionID sessionId) async {
|
||||||
if (show.value != v) {
|
if (!isShowInited) {
|
||||||
show.value = v;
|
show.value = !(await bind.sessionGetToggleOption(
|
||||||
|
sessionId: sessionId, arg: kOptionCollapseToolbar) ??
|
||||||
|
false);
|
||||||
|
isShowInited = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,10 +83,6 @@ class ToolbarState {
|
|||||||
bind.setLocalFlutterOption(
|
bind.setLocalFlutterOption(
|
||||||
k: kOptionRemoteMenubarState, v: jsonEncode({'pin': _pin.value}));
|
k: kOptionRemoteMenubarState, v: jsonEncode({'pin': _pin.value}));
|
||||||
}
|
}
|
||||||
|
|
||||||
save() async {
|
|
||||||
await _savePin();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ToolbarTheme {
|
class _ToolbarTheme {
|
||||||
@ -446,7 +439,7 @@ class _RemoteToolbarState extends State<RemoteToolbar> {
|
|||||||
sessionId: widget.ffi.sessionId,
|
sessionId: widget.ffi.sessionId,
|
||||||
dragging: _dragging,
|
dragging: _dragging,
|
||||||
fractionX: _fractionX,
|
fractionX: _fractionX,
|
||||||
show: show,
|
toolbarState: widget.state,
|
||||||
setFullscreen: _setFullscreen,
|
setFullscreen: _setFullscreen,
|
||||||
setMinimize: _minimize,
|
setMinimize: _minimize,
|
||||||
borderRadius: borderRadius,
|
borderRadius: borderRadius,
|
||||||
@ -2343,7 +2336,7 @@ class _DraggableShowHide extends StatefulWidget {
|
|||||||
final SessionID sessionId;
|
final SessionID sessionId;
|
||||||
final RxDouble fractionX;
|
final RxDouble fractionX;
|
||||||
final RxBool dragging;
|
final RxBool dragging;
|
||||||
final RxBool show;
|
final ToolbarState toolbarState;
|
||||||
final BorderRadius borderRadius;
|
final BorderRadius borderRadius;
|
||||||
|
|
||||||
final Function(bool) setFullscreen;
|
final Function(bool) setFullscreen;
|
||||||
@ -2354,7 +2347,7 @@ class _DraggableShowHide extends StatefulWidget {
|
|||||||
required this.sessionId,
|
required this.sessionId,
|
||||||
required this.fractionX,
|
required this.fractionX,
|
||||||
required this.dragging,
|
required this.dragging,
|
||||||
required this.show,
|
required this.toolbarState,
|
||||||
required this.setFullscreen,
|
required this.setFullscreen,
|
||||||
required this.setMinimize,
|
required this.setMinimize,
|
||||||
required this.borderRadius,
|
required this.borderRadius,
|
||||||
@ -2370,6 +2363,8 @@ class _DraggableShowHideState extends State<_DraggableShowHide> {
|
|||||||
double left = 0.0;
|
double left = 0.0;
|
||||||
double right = 1.0;
|
double right = 1.0;
|
||||||
|
|
||||||
|
RxBool get show => widget.toolbarState.show;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
initState() {
|
initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -2473,13 +2468,13 @@ class _DraggableShowHideState extends State<_DraggableShowHide> {
|
|||||||
)),
|
)),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => setState(() {
|
onPressed: () => setState(() {
|
||||||
widget.show.value = !widget.show.value;
|
widget.toolbarState.switchShow(widget.sessionId);
|
||||||
}),
|
}),
|
||||||
child: Obx((() => Tooltip(
|
child: Obx((() => Tooltip(
|
||||||
message: translate(
|
message:
|
||||||
widget.show.isTrue ? 'Hide Toolbar' : 'Show Toolbar'),
|
translate(show.isTrue ? 'Hide Toolbar' : 'Show Toolbar'),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
widget.show.isTrue ? Icons.expand_less : Icons.expand_more,
|
show.isTrue ? Icons.expand_less : Icons.expand_more,
|
||||||
size: iconSize,
|
size: iconSize,
|
||||||
),
|
),
|
||||||
))),
|
))),
|
||||||
|
@ -1284,6 +1284,7 @@ impl PeerConfig {
|
|||||||
keys::OPTION_TOUCH_MODE,
|
keys::OPTION_TOUCH_MODE,
|
||||||
keys::OPTION_I444,
|
keys::OPTION_I444,
|
||||||
keys::OPTION_SWAP_LEFT_RIGHT_MOUSE,
|
keys::OPTION_SWAP_LEFT_RIGHT_MOUSE,
|
||||||
|
keys::OPTION_COLLAPSE_TOOLBAR,
|
||||||
]
|
]
|
||||||
.map(|key| {
|
.map(|key| {
|
||||||
mp.insert(key.to_owned(), UserDefaultConfig::read(key));
|
mp.insert(key.to_owned(), UserDefaultConfig::read(key));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user