From c0692b6fc756e14b534d6952c3958d46b12bdc29 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Tue, 24 Feb 2026 07:31:55 -0500 Subject: [PATCH] refactor: remove messages::showClientError, fix mainwindow calling showandactive for non error messages --- src/lib/gui/MainWindow.cpp | 14 +++++++++++-- src/lib/gui/Messages.cpp | 37 ---------------------------------- src/lib/gui/Messages.h | 2 -- translations/deskflow_es.ts | 20 ++++++++---------- translations/deskflow_it.ts | 20 ++++++++---------- translations/deskflow_ja.ts | 20 ++++++++---------- translations/deskflow_ko.ts | 20 ++++++++---------- translations/deskflow_ru.ts | 20 ++++++++---------- translations/deskflow_zh_CN.ts | 20 ++++++++---------- 9 files changed, 60 insertions(+), 113 deletions(-) diff --git a/src/lib/gui/MainWindow.cpp b/src/lib/gui/MainWindow.cpp index 46b6d9cf2..eca80ad6a 100644 --- a/src/lib/gui/MainWindow.cpp +++ b/src/lib/gui/MainWindow.cpp @@ -1165,12 +1165,22 @@ void MainWindow::remoteHostChanged(const QString &newRemoteHost) void MainWindow::showClientError(deskflow::client::ErrorType error, const QString &address) { - if (!isVisible() || m_clientErrorVisible) + if (!isVisible() || m_clientErrorVisible || error != deskflow::client::ErrorType::AlreadyConnected) return; m_clientErrorVisible = true; + showAndActivate(); - deskflow::gui::messages::showClientConnectError(this, error, address); + + QMessageBox::warning( + this, tr("%1 Connection Error").arg(kAppName), + tr("

Failed to connect to the server '%1'.

" + "

A Client with your name is already connected to the server.

" + "Please ensure that you're using a unique name and that only a " + "single instance of the client process is running.

") + .arg(address) + ); + m_clientErrorVisible = false; } diff --git a/src/lib/gui/Messages.cpp b/src/lib/gui/Messages.cpp index 8b5e26bc7..a087d6532 100644 --- a/src/lib/gui/Messages.cpp +++ b/src/lib/gui/Messages.cpp @@ -183,43 +183,6 @@ void showFirstConnectedMessage(QWidget *parent, bool closeToTray, bool enableSer QMessageBox::information(parent, title, message); } -void showClientConnectError(QWidget *parent, deskflow::client::ErrorType error, const QString &address) -{ - using enum deskflow::client::ErrorType; - - if (error == NoError || error == GenericError || error == HostnameError) - return; - - auto message = QObject::tr("

Failed to connect to the server '%1'.

").arg(address); - - if (error == AlreadyConnected) { - message.append( - QObject::tr( // - "

A Client with your name is already connected to the server.

" - "Please ensure that you're using a unique name and that only a " - "single instance of the client process is running.

" - ) - ); - } else { - qFatal("unknown client error"); - } - - auto title = QObject::tr("%1 Connection Error").arg(kAppName); - - if (error != HostnameError) { - QMessageBox::warning(parent, title, message); - return; - } - - auto dialog = QMessageBox(parent); - dialog.setWindowTitle(title); - dialog.setText(message); - dialog.setWindowModality(Qt::ApplicationModal); - dialog.setIcon(QMessageBox::Information); - dialog.setDefaultButton(QMessageBox::Ok); - dialog.exec(); -} - bool showNewClientPrompt(QWidget *parent, const QString &clientName, bool serverRequiresPeerAuth) { if (serverRequiresPeerAuth) { diff --git a/src/lib/gui/Messages.h b/src/lib/gui/Messages.h index 7e27392c9..045db82c7 100644 --- a/src/lib/gui/Messages.h +++ b/src/lib/gui/Messages.h @@ -25,8 +25,6 @@ void showFirstConnectedMessage(QWidget *parent, bool closeToTray, bool enableSer void showCloseReminder(QWidget *parent); -void showClientConnectError(QWidget *parent, deskflow::client::ErrorType error, const QString &address); - bool showNewClientPrompt(QWidget *parent, const QString &clientName, bool serverRequiresPeerAuth = false); bool showClearSettings(QWidget *parent); diff --git a/translations/deskflow_es.ts b/translations/deskflow_es.ts index da004d674..67a5c6298 100644 --- a/translations/deskflow_es.ts +++ b/translations/deskflow_es.ts @@ -386,6 +386,10 @@ Do you want to connect to the server? stop core shortcut Ctrl+T + + <p>Failed to connect to the server '%1'.</p><p>A Client with your name is already connected to the server.</p>Please ensure that you're using a unique name and that only a single instance of the client process is running.</p> + <p>Error al conectar con el servidor '%1'.</p><p>A Client with your name is already connected to the server.</p>Please ensure that you're using a unique name and that only a single instance of the client process is running.</p> + Your current TLS key is smaller than the minimum allowed size, A new key 2048-bit key will be generated. Su clave TLS actual es más pequeña que el tamaño mínimo permitido. Se generará una nueva clave de 2048 bits. @@ -430,6 +434,10 @@ Do you want to connect to the server? Disconnect Desconectar + + %1 Connection Error + %1 Error de conexión + No IP Detected No se detectó ninguna IP @@ -610,18 +618,6 @@ Nombres válidos: %1 Connected %1 Conectado - - <p>Failed to connect to the server '%1'.</p> - <p>Error al conectar con el servidor '%1'.</p> - - - <p>A Client with your name is already connected to the server.</p>Please ensure that you're using a unique name and that only a single instance of the client process is running.</p> - <p>Ya hay un cliente conectado al servidor con su nombre.</p>Asegúrese de utilizar un nombre único y de que solo se esté ejecutando una única instancia del proceso del cliente.</p> - - - %1 Connection Error - %1 Error de conexión - %1 - New Client %1 - Nuevo cliente diff --git a/translations/deskflow_it.ts b/translations/deskflow_it.ts index 0a857a40d..381f3cd5c 100644 --- a/translations/deskflow_it.ts +++ b/translations/deskflow_it.ts @@ -374,6 +374,10 @@ Vuoi connetterti al server? stop core shortcut Ctrl+F + + <p>Failed to connect to the server '%1'.</p><p>A Client with your name is already connected to the server.</p>Please ensure that you're using a unique name and that only a single instance of the client process is running.</p> + <p>Impossibile connettersi al server "%1".</p><p>Un client con il tuo nome è già connesso al server.</p>Assicurati di utilizzare un nome univoco e che sia in esecuzione una sola istanza del processo client.</p> + Your current TLS key is smaller than the minimum allowed size, A new key 2048-bit key will be generated. La tua chiave TLS attuale è più piccola della dimensione minima consentita. Verrà generata una nuova chiave a 2048 bit. @@ -418,6 +422,10 @@ Vuoi connetterti al server? Disconnect Disconnetti + + %1 Connection Error + Errore di connessione %1 + No IP Detected Nessun IP rilevato @@ -610,18 +618,6 @@ Nomi validi: %1 Connected %1 Connesso - - <p>Failed to connect to the server '%1'.</p> - <p>Impossibile connettersi al server "%1".</p> - - - <p>A Client with your name is already connected to the server.</p>Please ensure that you're using a unique name and that only a single instance of the client process is running.</p> - <p>Un client con il tuo nome è già connesso al server.</p>Assicurati di utilizzare un nome univoco e che sia in esecuzione una sola istanza del processo client.</p> - - - %1 Connection Error - Errore di connessione %1 - %1 - New Client %1 - Nuovo Client diff --git a/translations/deskflow_ja.ts b/translations/deskflow_ja.ts index 9a8f7e068..a5e593e71 100644 --- a/translations/deskflow_ja.ts +++ b/translations/deskflow_ja.ts @@ -390,6 +390,10 @@ Do you want to connect to the server? Disconnect 切断 + + <p>Failed to connect to the server '%1'.</p><p>A Client with your name is already connected to the server.</p>Please ensure that you're using a unique name and that only a single instance of the client process is running.</p> + <p>サーバー '%1' への接続に失敗しました。</p><p>同じ名前のクライアントがサーバーに接続済です。</p><p>名前の重複がないことと、クライアントプロセスが多重起動していない事を確認してください。</p> + No IP Detected IPアドレスが見つかりません @@ -511,6 +515,10 @@ Valid names: ・_ と - ・1から255文字まで + + %1 Connection Error + %1 接続エラー + Suggested IP: 推奨IPアドレス: @@ -612,18 +620,6 @@ Valid names: %1 Connected %1 接続完了 - - <p>Failed to connect to the server '%1'.</p> - <p>サーバー '%1' への接続に失敗しました。</p> - - - <p>A Client with your name is already connected to the server.</p>Please ensure that you're using a unique name and that only a single instance of the client process is running.</p> - <p>同じ名前のクライアントがサーバーに接続済です。</p><p>名前の重複がないことと、クライアントプロセスが多重起動していない事を確認してください。</p> - - - %1 Connection Error - %1 接続エラー - %1 - New Client %1 - 新しいクライアント diff --git a/translations/deskflow_ko.ts b/translations/deskflow_ko.ts index 75d3f10b7..5a7112e21 100644 --- a/translations/deskflow_ko.ts +++ b/translations/deskflow_ko.ts @@ -390,6 +390,10 @@ Do you want to connect to the server? Disconnect 연결 해제 + + <p>Failed to connect to the server '%1'.</p><p>A Client with your name is already connected to the server.</p>Please ensure that you're using a unique name and that only a single instance of the client process is running.</p> + <p>서버 '%1'에 연결하지 못했습니다.</p><p>같은 이름의 클라이언트가 이미 서버에 연결되어 있습니다.</p><p>고유한 이름을 사용하고, 클라이언트 프로세스가 하나만 실행 중인지 확인하세요.</p> + No IP Detected IP를 감지하지 못했습니다 @@ -511,6 +515,10 @@ Valid names: • _ 또는 - 사용 가능 • 1~255자 + + %1 Connection Error + %1 연결 오류 + Suggested IP: 추천 IP: @@ -610,18 +618,6 @@ Valid names: %1 Connected %1 연결됨 - - <p>Failed to connect to the server '%1'.</p> - <p>서버 '%1'에 연결하지 못했습니다.</p> - - - <p>A Client with your name is already connected to the server.</p>Please ensure that you're using a unique name and that only a single instance of the client process is running.</p> - <p>같은 이름의 클라이언트가 이미 서버에 연결되어 있습니다.</p><p>고유한 이름을 사용하고, 클라이언트 프로세스가 하나만 실행 중인지 확인하세요.</p> - - - %1 Connection Error - %1 연결 오류 - %1 - New Client %1 - 새 클라이언트 diff --git a/translations/deskflow_ru.ts b/translations/deskflow_ru.ts index 03896f62d..2df384524 100644 --- a/translations/deskflow_ru.ts +++ b/translations/deskflow_ru.ts @@ -390,6 +390,10 @@ Do you want to connect to the server? Disconnect Отключиться + + <p>Failed to connect to the server '%1'.</p><p>A Client with your name is already connected to the server.</p>Please ensure that you're using a unique name and that only a single instance of the client process is running.</p> + <p>Не удалось подключиться к серверу '%1'.</p><p>Клиент с таким именем уже подключен к серверу.</p>Убедитесь, что вы используете уникальное имя и запущен только один процесс клиента.</p> + No IP Detected IP-адрес не обнаружен @@ -511,6 +515,10 @@ Valid names: • Можно использовать _ или - • Длина от 1 до 255 символов + + %1 Connection Error + Ошибка соединения %1 + Suggested IP: Рекомендуемый IP-адрес: @@ -610,18 +618,6 @@ Valid names: %1 Connected %1 подключено - - <p>Failed to connect to the server '%1'.</p> - <p>Не удалось подключиться к серверу '%1'.</p> - - - <p>A Client with your name is already connected to the server.</p>Please ensure that you're using a unique name and that only a single instance of the client process is running.</p> - <p>Клиент с таким именем уже подключен к серверу.</p>Убедитесь, что вы используете уникальное имя и запущен только один процесс клиента.</p> - - - %1 Connection Error - Ошибка соединения %1 - %1 - New Client %1 - Новый клиент diff --git a/translations/deskflow_zh_CN.ts b/translations/deskflow_zh_CN.ts index 2906263bb..a65384a36 100644 --- a/translations/deskflow_zh_CN.ts +++ b/translations/deskflow_zh_CN.ts @@ -390,6 +390,10 @@ Do you want to connect to the server? Disconnect 断开 + + <p>Failed to connect to the server '%1'.</p><p>A Client with your name is already connected to the server.</p>Please ensure that you're using a unique name and that only a single instance of the client process is running.</p> + <p>连接到服务器“%1”失败。</p><p>一个同名的客户端已连接到服务器。</p>请确保您使用的名称唯一,且只有一个客户端进程实例在运行。</p> + No IP Detected 未检测到 IP @@ -511,6 +515,10 @@ Valid names: • 可以使用 _ 或 - • 长度在 1 到 255 个字符之间 + + %1 Connection Error + %1 连接错误 + Suggested IP: 建议 IP: @@ -612,18 +620,6 @@ Valid names: %1 Connected %1 已连接 - - <p>Failed to connect to the server '%1'.</p> - <p>连接到服务器“%1”失败。</p> - - - <p>A Client with your name is already connected to the server.</p>Please ensure that you're using a unique name and that only a single instance of the client process is running.</p> - <p>一个同名的客户端已连接到服务器。</p>请确保您使用的名称唯一,且只有一个客户端进程实例在运行。</p> - - - %1 Connection Error - %1 连接错误 - %1 - New Client %1 - 新客户端