From 19c8ba719af300235db1910ad2552c49c5f3dc72 Mon Sep 17 00:00:00 2001 From: fufesou Date: Sat, 29 Jul 2023 15:45:16 +0800 Subject: [PATCH] refact, linux headless option, ui Signed-off-by: fufesou --- .../desktop/pages/desktop_setting_page.dart | 30 +++++++++++-------- libs/hbb_common/src/config.rs | 2 +- src/flutter_ffi.rs | 9 ++++++ 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/flutter/lib/desktop/pages/desktop_setting_page.dart b/flutter/lib/desktop/pages/desktop_setting_page.dart index b89929ad9..81cd2af7d 100644 --- a/flutter/lib/desktop/pages/desktop_setting_page.dart +++ b/flutter/lib/desktop/pages/desktop_setting_page.dart @@ -312,20 +312,26 @@ class _GeneralState extends State<_General> { } Widget other() { - return _Card(title: 'Other', children: [ + final children = [ _OptionCheckBox(context, 'Confirm before closing multiple tabs', 'enable-confirm-closing-tabs'), - _OptionCheckBox(context, 'Adaptive Bitrate', 'enable-abr'), - if (Platform.isLinux) - Tooltip( - message: translate('software_render_tip'), - child: _OptionCheckBox( - context, - "Always use software rendering", - 'allow-always-software-render', - ), - ) - ]); + _OptionCheckBox(context, 'Adaptive Bitrate', 'enable-abr') + ]; + if (Platform.isLinux) { + children.add(Tooltip( + message: translate('software_render_tip'), + child: _OptionCheckBox( + context, + "Always use software rendering", + 'allow-always-software-render', + ), + )); + } + if (bind.mainShowOption(key: 'allow-linux-headless')) { + children.add(_OptionCheckBox( + context, 'Allow linux headless', 'allow-linux-headless')); + } + return _Card(title: 'Other', children: children); } Widget hwcodec() { diff --git a/libs/hbb_common/src/config.rs b/libs/hbb_common/src/config.rs index 19730e630..ce041e75c 100644 --- a/libs/hbb_common/src/config.rs +++ b/libs/hbb_common/src/config.rs @@ -33,7 +33,7 @@ const SERIAL: i32 = 3; const PASSWORD_ENC_VERSION: &str = "00"; // config2 options -#[cfg(all(target_os = "linux"))] +#[cfg(target_os = "linux")] pub const CONFIG_OPTION_ALLOW_LINUX_HEADLESS: &str = "allow-linux-headless"; #[cfg(target_os = "macos")] diff --git a/src/flutter_ffi.rs b/src/flutter_ffi.rs index c25ac78b0..67fc286e6 100644 --- a/src/flutter_ffi.rs +++ b/src/flutter_ffi.rs @@ -614,6 +614,15 @@ pub fn main_get_error() -> String { get_error() } +pub fn main_show_option(key: String) -> SyncReturn { + if key.eq(config::CONFIG_OPTION_ALLOW_LINUX_HEADLESS) { + #[cfg(all(target_os = "linux", feature = "linux_headless"))] + #[cfg(not(any(feature = "flatpak", feature = "appimage")))] + return SyncReturn(true) + } + SyncReturn(false) +} + pub fn main_set_option(key: String, value: String) { if key.eq("custom-rendezvous-server") { set_option(key, value);