From 3fc7ba295fc721425be8babe4e98c39c403bcb20 Mon Sep 17 00:00:00 2001 From: Ouchihao Date: Sun, 6 Sep 2026 18:09:01 +0800 Subject: [PATCH] feat(server): show translations in horizontal candidate windows --- server/assets/config/config.toml | 2 +- server/src/ipc/event_listener.cpp | 6 +-- server/src/window/candidate_presenter.cpp | 2 +- .../candwnd/horizontal_candidate_window.html | 9 +++- ui/src/Controls.cpp | 29 +++++++---- ui/tests/src/test_layout.cpp | 51 +++++++++++++++++++ 6 files changed, 81 insertions(+), 18 deletions(-) diff --git a/server/assets/config/config.toml b/server/assets/config/config.toml index 75f1f0d2..3b53dbed 100644 --- a/server/assets/config/config.toml +++ b/server/assets/config/config.toml @@ -52,7 +52,7 @@ cloud_candidates = true clean_mode = false # -# 腾讯云机器翻译(竖排候选项本地词库未命中时的补全) +# 腾讯云机器翻译(候选项本地词库未命中时的补全) # [tencent_tmt] enabled = true diff --git a/server/src/ipc/event_listener.cpp b/server/src/ipc/event_listener.cpp index c02eae52..1de63533 100644 --- a/server/src/ipc/event_listener.cpp +++ b/server/src/ipc/event_listener.cpp @@ -961,8 +961,7 @@ std::string BuildCurrentCandidatePage() void PrepareCandidateTranslationRequest() { const bool japanese = g_inputSession && g_inputSession->current_scheme_type() == SchemeType::JapaneseRomaji; - const bool enabled = GetConfiguredCandidateTranslationsEnabled() && - GetConfiguredCandidateWindowLayout() == "vertical" && !IsUiLessMode() && !japanese; + const bool enabled = GetConfiguredCandidateTranslationsEnabled() && !IsUiLessMode() && !japanese; auto &ui = Global::candidate_ui; if (!enabled || ui.items.empty()) { @@ -3420,8 +3419,7 @@ void ApplyEnglishCandidates(std::vector candidates, const std::string void ApplyCandidateTranslations(std::vector results, uint64_t generation, bool merge) { if (!EnglishIme::IsTranslationCurrent(generation) || !GetConfiguredCandidateTranslationsEnabled() || - GetConfiguredCandidateWindowLayout() != "vertical" || IsUiLessMode() || - g_candidate_translation_signature.empty() || + IsUiLessMode() || g_candidate_translation_signature.empty() || (g_inputSession && g_inputSession->current_scheme_type() == SchemeType::JapaneseRomaji)) return; diff --git a/server/src/window/candidate_presenter.cpp b/server/src/window/candidate_presenter.cpp index 7379de12..3eddd153 100644 --- a/server/src/window/candidate_presenter.cpp +++ b/server/src/window/candidate_presenter.cpp @@ -487,7 +487,7 @@ void CandidatePresenter::FillItemsFromUi() item.label = std::to_wstring(i + 1); item.text = string_to_wstring(view.text + view.badge); item.annotation = string_to_wstring(view.annotation); - if (GetConfiguredCandidateTranslationsEnabled() && GetConfiguredCandidateWindowLayout() == "vertical") + if (GetConfiguredCandidateTranslationsEnabled()) item.translation = string_to_wstring(view.translation); items.push_back(std::move(item)); } diff --git a/ui-html/webview2/candwnd/horizontal_candidate_window.html b/ui-html/webview2/candwnd/horizontal_candidate_window.html index 78009120..e30a20f8 100644 --- a/ui-html/webview2/candwnd/horizontal_candidate_window.html +++ b/ui-html/webview2/candwnd/horizontal_candidate_window.html @@ -11,6 +11,11 @@ (IME)horizontalCandidateWindow +