From 31b89833281bbf327453c8a8abf687a81f78ffb3 Mon Sep 17 00:00:00 2001 From: dijunkun Date: Thu, 23 Jul 2026 11:10:02 +0800 Subject: [PATCH] fix: gray out unavailable hardware codec setting --- src/gui/application/gui_application.cpp | 4 ++-- src/gui/ui/common.slint | 2 +- src/gui/ui/main_window.slint | 8 +++++--- tests/slint_ui_smoke_test.cpp | 2 ++ xmake/targets.lua | 3 +++ 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/gui/application/gui_application.cpp b/src/gui/application/gui_application.cpp index 26eaf4a..3896f59 100644 --- a/src/gui/application/gui_application.cpp +++ b/src/gui/application/gui_application.cpp @@ -1782,9 +1782,9 @@ void GuiApplication::SyncMainWindow() { #if (((defined(_WIN32) || defined(__linux__)) && !defined(__aarch64__) && \ !defined(__arm__) && USE_CUDA) || \ defined(__APPLE__)) - ui_->main->set_hardware_codec_visible(true); + ui_->main->set_hardware_codec_available(true); #else - ui_->main->set_hardware_codec_visible(false); + ui_->main->set_hardware_codec_available(false); #endif if (show_offline_warning_window_) { diff --git a/src/gui/ui/common.slint b/src/gui/ui/common.slint index ded42ac..876acf1 100644 --- a/src/gui/ui/common.slint +++ b/src/gui/ui/common.slint @@ -295,7 +295,7 @@ export component ImGuiCheckBox inherits Rectangle { border-radius: 4px; if root.checked: Text { text: FontAwesomeIcons.check; - color: #2e86de; + color: root.enabled ? #2e86de : #8b8f95; font-family: "Font Awesome 6 Free"; font-weight: 900; font-size: 16px; diff --git a/src/gui/ui/main_window.slint b/src/gui/ui/main_window.slint index 21777f5..5f6a6df 100644 --- a/src/gui/ui/main_window.slint +++ b/src/gui/ui/main_window.slint @@ -242,7 +242,9 @@ export component MainWindow inherits Window { in-out property server-port: ""; in-out property coturn-port: ""; in property settings-session-active: false; - in property hardware-codec-visible: true; + // Keep the setting visible on every platform. Unsupported builds expose it + // as disabled so the fixed settings layout never turns into a blank row. + in property hardware-codec-available: true; callback copy-local-id; callback toggle-password-visibility; @@ -1218,8 +1220,8 @@ export component MainWindow inherits Window { CompactComboBox { x: root.compact-language ? 120px : 188px; y: 120px; enabled: !root.settings-session-active; model: [UiStrings.codec-h264, UiStrings.codec-av1]; current-index <=> root.codec-index; } Rectangle { x: 7px; y: 147px; width: parent.width - 14px; height: 1px; background: ImGuiLineStyle.separator; } - if root.hardware-codec-visible: Text { x: 8px; y: 151px; width: root.compact-language ? 155px : 225px; height: 24px; text: UiStrings.hardware-codec; font-size: ImGuiFontStyle.body; overflow: elide; vertical-alignment: center; } - if root.hardware-codec-visible: ImGuiCheckBox { x: root.compact-language ? 171px : 238px; y: 151px; checked <=> root.hardware-codec-enabled; enabled: !root.settings-session-active; } + Text { x: 8px; y: 151px; width: root.compact-language ? 155px : 225px; height: 24px; text: UiStrings.hardware-codec; color: root.hardware-codec-available ? #202124 : #8b8f95; font-size: ImGuiFontStyle.body; overflow: elide; vertical-alignment: center; } + ImGuiCheckBox { x: root.compact-language ? 171px : 238px; y: 151px; checked <=> root.hardware-codec-enabled; enabled: root.hardware-codec-available && !root.settings-session-active; } Rectangle { x: 7px; y: 177px; width: parent.width - 14px; height: 1px; background: ImGuiLineStyle.separator; } Text { x: 8px; y: 181px; width: root.compact-language ? 155px : 225px; height: 24px; text: UiStrings.turn-relay; font-size: ImGuiFontStyle.body; overflow: elide; vertical-alignment: center; } diff --git a/tests/slint_ui_smoke_test.cpp b/tests/slint_ui_smoke_test.cpp index 12a4a0a..5c3cbba 100644 --- a/tests/slint_ui_smoke_test.cpp +++ b/tests/slint_ui_smoke_test.cpp @@ -14,11 +14,13 @@ int main() { window->set_connection_dialog_open(true); window->set_connection_password_required(true); window->set_settings_session_active(true); + window->set_hardware_codec_available(false); window->set_portable_service_settings_visible(true); assert(std::string(window->get_local_id()) == "123 456 789"); assert(window->get_connection_dialog_open()); assert(window->get_connection_password_required()); assert(window->get_settings_session_active()); + assert(!window->get_hardware_codec_available()); assert(window->get_portable_service_settings_visible()); window->set_settings_open(true); window->set_about_open(true); diff --git a/xmake/targets.lua b/xmake/targets.lua index ff2884f..131d34d 100644 --- a/xmake/targets.lua +++ b/xmake/targets.lua @@ -87,6 +87,9 @@ function setup_targets() set_kind("binary") set_languages("c++20") set_default(false) + if is_os("windows") then + add_cxxflags("/bigobj") + end add_packages("slint") add_rules("slint") add_files("src/gui/ui/crossdesk_ui.slint")