win_fix_multi_tab: win clipboard refactor

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2022-10-27 10:56:14 +08:00
parent 702c81cafe
commit db99eccbe0
10 changed files with 66 additions and 27 deletions

View File

@@ -43,7 +43,7 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
void initState() {
super.initState();
tabController.onRemove = (_, id) => onRemoveId(id);
tabController.onRemoved = (_, id) => onRemoveId(id);
rustDeskWinManager.setMethodHandler((call, fromWindowId) async {
print(

View File

@@ -46,7 +46,7 @@ class _PortForwardTabPageState extends State<PortForwardTabPage> {
void initState() {
super.initState();
tabController.onRemove = (_, id) => onRemoveId(id);
tabController.onRemoved = (_, id) => onRemoveId(id);
rustDeskWinManager.setMethodHandler((call, fromWindowId) async {
debugPrint(

View File

@@ -59,11 +59,12 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
void initState() {
super.initState();
tabController.onRemove = (_, id) => onRemoveId(id);
tabController.onRemoved = (_, id) => onRemoveId(id);
tabController.onSelected = (_, id) => onSelectId(id);
rustDeskWinManager.setMethodHandler((call, fromWindowId) async {
print(
"call ${call.method} with args ${call.arguments} from window ${fromWindowId}");
"call ${call.method} with args ${call.arguments} from window $fromWindowId");
final RxBool fullscreen = Get.find(tag: 'fullscreen');
// for simplify, just replace connectionId
@@ -174,6 +175,10 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
_update_remote_count();
}
void onSelectId(String id) {
bind.setCurSessionId(id: id);
}
int windowId() {
return widget.params["windowId"];
}

View File

@@ -30,7 +30,7 @@ class _DesktopServerPageState extends State<DesktopServerPage>
void initState() {
gFFI.ffiModel.updateEventListener("");
windowManager.addListener(this);
tabController.onRemove = (_, id) => onRemoveId(id);
tabController.onRemoved = (_, id) => onRemoveId(id);
super.initState();
}
@@ -99,7 +99,7 @@ class ConnectionManagerState extends State<ConnectionManager> {
@override
void initState() {
gFFI.serverModel.updateClientState();
gFFI.serverModel.tabController.onSelected = (index) =>
gFFI.serverModel.tabController.onSelected = (index, _) =>
gFFI.chatModel.changeCurrentID(gFFI.serverModel.clients[index].id);
super.initState();
}

View File

@@ -70,10 +70,11 @@ class DesktopTabController {
final DesktopTabType tabType;
/// index, key
Function(int, String)? onRemove;
Function(int)? onSelected;
Function(int, String)? onRemoved;
Function(int, String)? onSelected;
DesktopTabController({required this.tabType});
DesktopTabController(
{required this.tabType, this.onRemoved, this.onSelected});
int get length => state.value.tabs.length;
@@ -114,7 +115,7 @@ class DesktopTabController {
state.value.tabs.removeAt(index);
state.value.scrollController.itemCount = state.value.tabs.length;
jumpTo(toIndex);
onRemove?.call(index, key);
onRemoved?.call(index, key);
}
void jumpTo(int index) {
@@ -134,7 +135,8 @@ class DesktopTabController {
}));
});
if (state.value.tabs.length > index) {
onSelected?.call(index);
final key = state.value.tabs[index].key;
onSelected?.call(index, key);
}
}
@@ -146,7 +148,7 @@ class DesktopTabController {
void closeBy(String? key) {
if (!isDesktop) return;
assert(onRemove != null);
assert(onRemoved != null);
if (key == null) {
if (state.value.selected < state.value.tabs.length) {
remove(state.value.selected);