fix syninfo, add ab two menutiems: sync ab with recent sessions and sort tags
This commit is contained in:
parent
c711084807
commit
8b8f50ed0f
@ -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/peers_view.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 'package:get/get.dart';
|
||||
|
||||
@ -70,30 +71,30 @@ class _AddressBookState extends State<AddressBook> {
|
||||
return Row(
|
||||
children: [
|
||||
Offstage(
|
||||
offstage: hideAbTagsPanel.value,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border:
|
||||
Border.all(color: Theme.of(context).colorScheme.background)),
|
||||
child: Container(
|
||||
width: 150,
|
||||
height: double.infinity,
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
children: [
|
||||
_buildTagHeader().marginOnly(left: 8.0, right: 0),
|
||||
Expanded(
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
child: _buildTags(),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
).marginOnly(right: 12.0)),
|
||||
offstage: hideAbTagsPanel.value,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: Theme.of(context).colorScheme.background)),
|
||||
child: Container(
|
||||
width: 150,
|
||||
height: double.infinity,
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
children: [
|
||||
_buildTagHeader().marginOnly(left: 8.0, right: 0),
|
||||
Expanded(
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
child: _buildTags(),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
).marginOnly(right: 12.0)),
|
||||
_buildPeersViews()
|
||||
],
|
||||
);
|
||||
@ -144,9 +145,16 @@ class _AddressBookState extends State<AddressBook> {
|
||||
}
|
||||
|
||||
Widget _buildTags() {
|
||||
return Obx(
|
||||
() => Wrap(
|
||||
children: gFFI.abModel.tags
|
||||
return Obx(() {
|
||||
final List 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(
|
||||
name: e,
|
||||
tags: gFFI.abModel.selectedTags,
|
||||
@ -158,8 +166,8 @@ class _AddressBookState extends State<AddressBook> {
|
||||
}
|
||||
}))
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
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) {
|
||||
final items = [
|
||||
getEntry(translate("Add ID"), abAddId),
|
||||
getEntry(translate("Add Tag"), abAddTag),
|
||||
getEntry(translate("Unselect all tags"), gFFI.abModel.unsetSelectedTags),
|
||||
sortMenuItem(),
|
||||
syncMenuItem(),
|
||||
];
|
||||
|
||||
mod_menu.showMenu(
|
||||
@ -458,7 +499,6 @@ MenuEntryButton<String> getEntry(String title, VoidCallback proc) {
|
||||
style: style,
|
||||
),
|
||||
proc: proc,
|
||||
padding: kDesktopMenuPadding,
|
||||
dismissOnClicked: true,
|
||||
);
|
||||
}
|
||||
|
@ -10,11 +10,22 @@ import 'package:http/http.dart' as http;
|
||||
|
||||
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 {
|
||||
final abLoading = false.obs;
|
||||
final abError = "".obs;
|
||||
final tags = [].obs;
|
||||
final peers = List<Peer>.empty(growable: true).obs;
|
||||
final sortTags = shouldSortTags().obs;
|
||||
|
||||
final selectedTags = List<String>.empty(growable: true).obs;
|
||||
var initialized = false;
|
||||
|
@ -327,7 +327,7 @@ packages:
|
||||
description:
|
||||
path: "."
|
||||
ref: HEAD
|
||||
resolved-ref: 6c4181330f4ed80c1cb5670bd61aa75115f9f748
|
||||
resolved-ref: "6c4181330f4ed80c1cb5670bd61aa75115f9f748"
|
||||
url: "https://github.com/rustdesk-org/rustdesk_desktop_multi_window"
|
||||
source: git
|
||||
version: "0.1.0"
|
||||
|
@ -1,2 +1,3 @@
|
||||
#! /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
|
||||
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};
|
||||
let system = System::new_all();
|
||||
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 cpu_name = cpus.first().map(|x| x.brand()).unwrap_or_default();
|
||||
let cpu_name = cpu_name.trim_end();
|
||||
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_pcpus = num_cpus::get_physical();
|
||||
let os = system.distribution_id();
|
||||
let os = format!("{} / {}", os, system.long_os_version().unwrap_or_default());
|
||||
let hostname = system.host_name();
|
||||
let mut os = system.distribution_id();
|
||||
os = format!("{} / {}", os, system.long_os_version().unwrap_or_default());
|
||||
#[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!({
|
||||
"cpu": format!("{cpu_name}, {cpu_freq}MHz, {num_cpus}/{num_pcpus} cores"),
|
||||
"cpu": format!("{cpu}{num_cpus}/{num_pcpus} cores"),
|
||||
"memory": format!("{memory}GB"),
|
||||
"os": os,
|
||||
"hostname": hostname,
|
||||
|
Loading…
x
Reference in New Issue
Block a user