diff --git a/apps/desktop/src/gui/application/gui_application.cpp b/apps/desktop/src/gui/application/gui_application.cpp index 1a457ed3..f2f5c506 100644 --- a/apps/desktop/src/gui/application/gui_application.cpp +++ b/apps/desktop/src/gui/application/gui_application.cpp @@ -1367,6 +1367,12 @@ void GuiApplication::BindMainCallbacks() { LOG_WARN("Copy local id failed: {}", SDL_GetError()); } }); + main->on_signal_reconnect_requested([this] { + LOG_INFO("Signal reconnect requested from the status bar"); + if (ForceSignalReconnect() != 0) { + LOG_WARN("Signal reconnect could not be started"); + } + }); main->on_toggle_password_visibility([this] { show_password_ = !show_password_; ui_->main->set_password_visible(show_password_); diff --git a/apps/desktop/src/gui/assets/localization/localization_data.h b/apps/desktop/src/gui/assets/localization/localization_data.h index e923cc5b..c70262cb 100644 --- a/apps/desktop/src/gui/assets/localization/localization_data.h +++ b/apps/desktop/src/gui/assets/localization/localization_data.h @@ -258,6 +258,7 @@ struct TranslationRow { X(signal_connected, u8"已连接服务器", "Connected", u8"Подключено к серверу") \ X(signal_disconnected, u8"未连接服务器", "Disconnected", \ u8"Нет подключения к серверу") \ + X(signal_reconnect, u8"重新连接", "Reconnect", u8"Переподключиться") \ X(signal_tls_cert_error, u8"证书验证失败,请重新安装自托管根证书", \ "Certificate verification failed. Reinstall the self-hosted root " \ "certificate.", \ diff --git a/apps/desktop/src/gui/runtime/connection_runtime.cpp b/apps/desktop/src/gui/runtime/connection_runtime.cpp index 3859f2f3..eb12ea4c 100644 --- a/apps/desktop/src/gui/runtime/connection_runtime.cpp +++ b/apps/desktop/src/gui/runtime/connection_runtime.cpp @@ -227,6 +227,14 @@ int GuiRuntime::RequestSingleDevicePresence(const std::string& remote_id, return ret; } +int GuiRuntime::ForceSignalReconnect() { + if (!peer_) { + LOG_WARN("Signal reconnect requested with no connection peer"); + return -1; + } + return ReconnectSignal(peer_); +} + void GuiRuntime::CloseRemoteSession(std::shared_ptr props) { if (!props || props->closing_.exchange(true)) return; if (props->peer_events_) props->peer_events_->Deactivate(); diff --git a/apps/desktop/src/gui/runtime/gui_runtime.h b/apps/desktop/src/gui/runtime/gui_runtime.h index 1e4e12c2..9452b488 100644 --- a/apps/desktop/src/gui/runtime/gui_runtime.h +++ b/apps/desktop/src/gui/runtime/gui_runtime.h @@ -54,6 +54,7 @@ class GuiRuntime : protected gui_detail::GuiState { bool remember_password, bool bypass_presence_check = false); int RequestSingleDevicePresence(const std::string& remote_id, const char* password, bool remember_password); + int ForceSignalReconnect(); void HandleRecentConnections(); void HandleConnectionStatusChange(); diff --git a/apps/desktop/src/gui/ui/main_window.slint b/apps/desktop/src/gui/ui/main_window.slint index 64b9769c..4fe4db7f 100644 --- a/apps/desktop/src/gui/ui/main_window.slint +++ b/apps/desktop/src/gui/ui/main_window.slint @@ -65,6 +65,7 @@ export global UiStrings { in-out property signal-connected: "Signal server connected"; in-out property signal-disconnected: "Signal server disconnected"; in-out property tls-error: "Signal server TLS certificate error"; + in-out property signal-reconnect: "Reconnect"; in-out property update-available: "A new version is available"; in-out property new-version: "New version"; in-out property check-for-updates: "Check for updates"; @@ -402,6 +403,7 @@ export component MainWindow inherits Window { callback browse-save-path; callback open-download; callback check-for-updates; + callback signal-reconnect-requested; callback connection-cancel; callback connection-acknowledge; callback connection-submit-password(string, bool); @@ -1222,6 +1224,25 @@ export component MainWindow inherits Window { font-size: ImGuiFontStyle.base; vertical-alignment: center; } + if !root.signal-connected && !root.signal-tls-error: Rectangle { + x: parent.width - self.width - 12px; + y: 3px; + height: 18px; + width: reconnect-label.preferred-width; + reconnect-label := Text { + text: UiStrings.signal-reconnect; + color: #2563eb; + font-size: ImGuiFontStyle.base; + horizontal-alignment: center; + vertical-alignment: center; + } + TouchArea { + mouse-cursor: pointer; + clicked => { + root.signal-reconnect-requested(); + } + } + } } } diff --git a/apps/desktop/src/gui/ui/ui_localization.h b/apps/desktop/src/gui/ui/ui_localization.h index 7001449a..e4754c65 100644 --- a/apps/desktop/src/gui/ui/ui_localization.h +++ b/apps/desktop/src/gui/ui/ui_localization.h @@ -110,6 +110,8 @@ inline int ApplyMainWindowStrings( strings.set_signal_disconnected( Text(localization::signal_disconnected[language])); strings.set_tls_error(Text(localization::signal_tls_cert_error[language])); + strings.set_signal_reconnect( + Text(localization::signal_reconnect[language])); strings.set_update_available( Text(localization::new_version_available[language])); strings.set_new_version(Text(localization::new_version[language]));