mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-10-15 00:09:39 +08:00
[feat] add manual signaling reconnect action
This commit is contained in:
@@ -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_);
|
||||
|
||||
@@ -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.", \
|
||||
|
||||
@@ -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<RemoteSession> props) {
|
||||
if (!props || props->closing_.exchange(true)) return;
|
||||
if (props->peer_events_) props->peer_events_->Deactivate();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -65,6 +65,7 @@ export global UiStrings {
|
||||
in-out property <string> signal-connected: "Signal server connected";
|
||||
in-out property <string> signal-disconnected: "Signal server disconnected";
|
||||
in-out property <string> tls-error: "Signal server TLS certificate error";
|
||||
in-out property <string> signal-reconnect: "Reconnect";
|
||||
in-out property <string> update-available: "A new version is available";
|
||||
in-out property <string> new-version: "New version";
|
||||
in-out property <string> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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]));
|
||||
|
||||
Reference in New Issue
Block a user