fix syninfo, add ab two menutiems: sync ab with recent sessions and sort tags

This commit is contained in:
rustdesk 2023-07-26 19:53:57 +08:00
parent c711084807
commit 8b8f50ed0f
5 changed files with 99 additions and 37 deletions

@ -3,7 +3,8 @@ import 'package:flutter_hbb/common/formatter/id_formatter.dart';
import 'package:flutter_hbb/common/widgets/peer_card.dart'; import 'package:flutter_hbb/common/widgets/peer_card.dart';
import 'package:flutter_hbb/common/widgets/peers_view.dart'; import 'package:flutter_hbb/common/widgets/peers_view.dart';
import 'package:flutter_hbb/desktop/widgets/popup_menu.dart'; import 'package:flutter_hbb/desktop/widgets/popup_menu.dart';
import '../../consts.dart'; import 'package:flutter_hbb/models/ab_model.dart';
import 'package:flutter_hbb/models/platform_model.dart';
import '../../desktop/widgets/material_mod_popup_menu.dart' as mod_menu; import '../../desktop/widgets/material_mod_popup_menu.dart' as mod_menu;
import 'package:get/get.dart'; import 'package:get/get.dart';
@ -74,8 +75,8 @@ class _AddressBookState extends State<AddressBook> {
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
border: border: Border.all(
Border.all(color: Theme.of(context).colorScheme.background)), color: Theme.of(context).colorScheme.background)),
child: Container( child: Container(
width: 150, width: 150,
height: double.infinity, height: double.infinity,
@ -144,9 +145,16 @@ class _AddressBookState extends State<AddressBook> {
} }
Widget _buildTags() { Widget _buildTags() {
return Obx( return Obx(() {
() => Wrap( final List tags;
children: gFFI.abModel.tags if (gFFI.abModel.sortTags.value) {
tags = gFFI.abModel.tags.toList();
tags.sort();
} else {
tags = gFFI.abModel.tags;
}
return Wrap(
children: tags
.map((e) => AddressBookTag( .map((e) => AddressBookTag(
name: e, name: e,
tags: gFFI.abModel.selectedTags, tags: gFFI.abModel.selectedTags,
@ -158,8 +166,8 @@ class _AddressBookState extends State<AddressBook> {
} }
})) }))
.toList(), .toList(),
),
); );
});
} }
Widget _buildPeersViews() { Widget _buildPeersViews() {
@ -174,11 +182,44 @@ class _AddressBookState extends State<AddressBook> {
); );
} }
@protected
MenuEntryBase<String> syncMenuItem() {
return MenuEntrySwitch<String>(
switchType: SwitchType.scheckbox,
text: translate('Sync with recent sessions'),
getter: () async {
return shouldSyncAb();
},
setter: (bool v) async {
bind.mainSetLocalOption(key: syncAbOption, value: v ? 'Y' : '');
},
dismissOnClicked: true,
);
}
@protected
MenuEntryBase<String> sortMenuItem() {
return MenuEntrySwitch<String>(
switchType: SwitchType.scheckbox,
text: translate('Sort tags'),
getter: () async {
return shouldSortTags();
},
setter: (bool v) async {
bind.mainSetLocalOption(key: sortAbTagsOption, value: v ? 'Y' : '');
gFFI.abModel.sortTags.value = v;
},
dismissOnClicked: true,
);
}
void _showMenu(RelativeRect pos) { void _showMenu(RelativeRect pos) {
final items = [ final items = [
getEntry(translate("Add ID"), abAddId), getEntry(translate("Add ID"), abAddId),
getEntry(translate("Add Tag"), abAddTag), getEntry(translate("Add Tag"), abAddTag),
getEntry(translate("Unselect all tags"), gFFI.abModel.unsetSelectedTags), getEntry(translate("Unselect all tags"), gFFI.abModel.unsetSelectedTags),
sortMenuItem(),
syncMenuItem(),
]; ];
mod_menu.showMenu( mod_menu.showMenu(
@ -458,7 +499,6 @@ MenuEntryButton<String> getEntry(String title, VoidCallback proc) {
style: style, style: style,
), ),
proc: proc, proc: proc,
padding: kDesktopMenuPadding,
dismissOnClicked: true, dismissOnClicked: true,
); );
} }

@ -10,11 +10,22 @@ import 'package:http/http.dart' as http;
import '../common.dart'; import '../common.dart';
final syncAbOption = 'sync-ab-with-recent-sessions';
bool shouldSyncAb() {
return bind.mainGetLocalOption(key: syncAbOption).isNotEmpty;
}
final sortAbTagsOption = 'sync-ab-tags';
bool shouldSortTags() {
return bind.mainGetLocalOption(key: sortAbTagsOption).isNotEmpty;
}
class AbModel { class AbModel {
final abLoading = false.obs; final abLoading = false.obs;
final abError = "".obs; final abError = "".obs;
final tags = [].obs; final tags = [].obs;
final peers = List<Peer>.empty(growable: true).obs; final peers = List<Peer>.empty(growable: true).obs;
final sortTags = shouldSortTags().obs;
final selectedTags = List<String>.empty(growable: true).obs; final selectedTags = List<String>.empty(growable: true).obs;
var initialized = false; var initialized = false;

@ -327,7 +327,7 @@ packages:
description: description:
path: "." path: "."
ref: HEAD ref: HEAD
resolved-ref: 6c4181330f4ed80c1cb5670bd61aa75115f9f748 resolved-ref: "6c4181330f4ed80c1cb5670bd61aa75115f9f748"
url: "https://github.com/rustdesk-org/rustdesk_desktop_multi_window" url: "https://github.com/rustdesk-org/rustdesk_desktop_multi_window"
source: git source: git
version: "0.1.0" version: "0.1.0"

@ -1,2 +1,3 @@
#! /usr/bin/env bash #! /usr/bin/env bash
sed -i "s/$1/$2/g" res/*spec res/PKGBUILD flutter/pubspec.yaml Cargo.toml .github/workflows/*yml flatpak/*json appimage/*yml sed -i "s/$1/$2/g" res/*spec res/PKGBUILD flutter/pubspec.yaml Cargo.toml .github/workflows/*yml flatpak/*json appimage/*yml
cargo run # to bump version in cargo lock

@ -754,18 +754,28 @@ pub fn get_sysinfo() -> serde_json::Value {
use hbb_common::sysinfo::{CpuExt, System, SystemExt}; use hbb_common::sysinfo::{CpuExt, System, SystemExt};
let system = System::new_all(); let system = System::new_all();
let memory = system.total_memory(); let memory = system.total_memory();
let memory = (memory as f64 / 1024. / 1024. / 1024. * 100 as f64).round() / 100.; let memory = (memory as f64 / 1024. / 1024. / 1024. * 100.).round() / 100.;
let cpus = system.cpus(); let cpus = system.cpus();
let cpu_name = cpus.first().map(|x| x.brand()).unwrap_or_default(); let cpu_name = cpus.first().map(|x| x.brand()).unwrap_or_default();
let cpu_name = cpu_name.trim_end(); let cpu_name = cpu_name.trim_end();
let cpu_freq = cpus.first().map(|x| x.frequency()).unwrap_or_default(); let cpu_freq = cpus.first().map(|x| x.frequency()).unwrap_or_default();
let cpu_freq = (cpu_freq as f64 / 1024. * 100.).round() / 100.;
let cpu = if cpu_freq > 0. {
format!("{}, {}GHz, ", cpu_name, cpu_freq)
} else {
"".to_owned() // android
};
let num_cpus = num_cpus::get(); let num_cpus = num_cpus::get();
let num_pcpus = num_cpus::get_physical(); let num_pcpus = num_cpus::get_physical();
let os = system.distribution_id(); let mut os = system.distribution_id();
let os = format!("{} / {}", os, system.long_os_version().unwrap_or_default()); os = format!("{} / {}", os, system.long_os_version().unwrap_or_default());
let hostname = system.host_name(); #[cfg(windows)]
{
os = format!("{os} - {}", system.os_version().unwrap_or_default());
}
let hostname = hostname(); // sys.hostname() return localhost on android in my test
serde_json::json!({ serde_json::json!({
"cpu": format!("{cpu_name}, {cpu_freq}MHz, {num_cpus}/{num_pcpus} cores"), "cpu": format!("{cpu}{num_cpus}/{num_pcpus} cores"),
"memory": format!("{memory}GB"), "memory": format!("{memory}GB"),
"os": os, "os": os,
"hostname": hostname, "hostname": hostname,