refactor: Messages::showClientConnectError

slight reword for Already Connected error
 use QString::append to add to the message
 create a QMessageBox::warning style box for these errors
 enable translations
This commit is contained in:
sithlord48 2025-06-06 22:44:30 -04:00 committed by Nick Bolton
parent 8bb6056469
commit b8835a8a5a

View file

@ -185,31 +185,34 @@ void showClientConnectError(QWidget *parent, ClientError error, const QString &a
{ {
using enum ClientError; using enum ClientError;
auto message = QString("<p>The connection to server '%1' didn't work.</p>").arg(address); auto message = QObject::tr("<p>Failed to connect to the server '%1'.</p>").arg(address);
if (error == AlreadyConnected) { if (error == AlreadyConnected) {
message += // message.append(
"<p>Two of your client computers have the same name or there are " QObject::tr( //
"two instances of the client process running.</p>" "<p>A Client with your name is already connected to the server.</p>"
"<p>Please ensure that you're using a unique name and that only a " "Please ensure that you're using a unique name and that only a "
"single client process is running.</p>"; "single instance of the client process is running.</p>"
)
);
} else if (error == HostnameError) { } else if (error == HostnameError) {
message += // message.append(
"<p>Please try to connect to the server using the server IP address " QObject::tr( //
"instead of the hostname. </p>" "<p>Please try to connect to the server using the server IP address "
"<p>If that doesn't work, please check your TLS and " "instead of the hostname. </p>"
"firewall settings.</p>"; "<p>If that doesn't work, please check your TLS and "
"firewall settings.</p>"
)
);
} else if (error == GenericError) { } else if (error == GenericError) {
message += // message.append(QObject::tr("<p>Please check your TLS and firewall settings.</p>"));
"<p>Please check your TLS and firewall settings.</p>";
} else { } else {
qFatal("unknown client error"); qFatal("unknown client error");
} }
QMessageBox dialog(parent); auto title = QObject::tr("%1 Connection Error").arg(kAppName);
dialog.addButton(QObject::tr("Close"), QMessageBox::RejectRole);
dialog.setText(message); QMessageBox::warning(parent, title, message);
dialog.exec();
} }
NewClientPromptResult showNewClientPrompt(QWidget *parent, const QString &clientName, bool serverRequiresPeerAuth) NewClientPromptResult showNewClientPrompt(QWidget *parent, const QString &clientName, bool serverRequiresPeerAuth)