diff --git a/src/lib/gui/MainWindow.cpp b/src/lib/gui/MainWindow.cpp index 2130eb306..9189a4583 100644 --- a/src/lib/gui/MainWindow.cpp +++ b/src/lib/gui/MainWindow.cpp @@ -429,7 +429,7 @@ void MainWindow::coreProcessError(CoreProcess::Error error) void MainWindow::startCore() { // Save current IP state when server starts - if (m_coreProcess.mode() == CoreMode::Server) { + if (m_coreProcess.mode() == CoreMode::Server && Settings::value(Settings::Core::Interface).isNull()) { m_serverStartIPs = m_networkMonitor->getAvailableIPv4Addresses(); m_serverStartSuggestedIP = m_serverStartIPs.isEmpty() ? "" : m_serverStartIPs.first(); } @@ -707,6 +707,11 @@ void MainWindow::applyConfig() updateLocalFingerprint(); setTrayIcon(); + if (const auto ip = Settings::value(Settings::Core::Interface).toString(); !ip.isEmpty()) { + m_serverStartIPs = {ip}; + m_serverStartSuggestedIP = ip; + } + const auto coreMode = Settings::value(Settings::Core::CoreMode).value(); if (coreMode == Settings::CoreMode::None) @@ -1250,46 +1255,25 @@ void MainWindow::updateIpLabel(const QStringList &addresses) static const auto colorText = QStringLiteral(R"(%2)"); const bool serverStarted = m_coreProcess.isStarted(); + const bool fixedIP = !Settings::value(Settings::Core::Interface).isNull(); - if (addresses.isEmpty() && !serverStarted || (serverStarted && m_serverStartSuggestedIP.isEmpty())) { + if (!fixedIP && addresses.isEmpty() && !serverStarted || (serverStarted && m_serverStartSuggestedIP.isEmpty())) { ui->lblIpAddresses->setText(colorText.arg(palette().linkVisited().color().name(), tr("No IP Detected"))); ui->lblIpAddresses->setToolTip(tr("Unable to detect an IP address. Check your network connection is active.")); return; } - QString labelText; - QString toolTipText; - - // If we have a fixed IP we will use it - if (const auto ip = Settings::value(Settings::Core::Interface).toString(); !ip.isEmpty()) { - labelText = tr("Using IP: "); - toolTipText = tr("Selected as the interface in settings."); - if (addresses.contains(ip, Qt::CaseInsensitive)) { - labelText.append(ip); - } else { - labelText.append(colorText.arg(palette().linkVisited().color().name(), ip)); - toolTipText.append(tr("\nInterface is not active. Unable to start server.")); - } - ui->lblIpAddresses->setText(labelText); - ui->lblIpAddresses->setToolTip(toolTipText); - return; - } - - labelText = tr("Suggested IP: "); - toolTipText = tr("

If connecting via the hostname fails, try %1

"); + QString labelText = fixedIP ? tr("Using IP: ") : tr("Suggested IP: "); + QString toolTipText = tr("

If connecting via the hostname fails, try %1

"); // Get all available IPs for tooltip - QStringList ipList = addresses; + const bool filterIpList = (serverStarted || fixedIP); + const QRegularExpression ipListFilter(filterIpList ? QStringLiteral("(%1)").arg(m_serverStartIPs.join("|")) : ""); + const QStringList ipList = addresses.filter(ipListFilter); - // Determine which IP to show and tooltip based on server state bool IPValid = true; - if (serverStarted) { - // ipList should only include valid ip from servers start - const QRegularExpression ipListFilter(QStringLiteral("(%1)").arg(m_serverStartIPs.join("|"))); - ipList = addresses.filter(ipListFilter); - if ((m_serverStartSuggestedIP != m_currentIpAddress) || !ipList.contains(m_serverStartSuggestedIP)) { - IPValid = !ipList.isEmpty(); - } + if (filterIpList && (m_serverStartSuggestedIP != m_currentIpAddress) || !ipList.contains(m_serverStartSuggestedIP)) { + IPValid = !ipList.isEmpty(); } if (IPValid) { @@ -1300,7 +1284,7 @@ void MainWindow::updateIpLabel(const QStringList &addresses) toolTipText.append(tr("\nA bound IP is now invalid, you may need to restart the server.")); } - if (ipList.count() < 2) { + if (ipList.count() < 2 || fixedIP) { toolTipText = toolTipText.arg(tr("the suggested IP.")); } else { toolTipText = toolTipText.arg(tr("one of the following IPs:
%1").arg(ipList.join("
"))); diff --git a/translations/deskflow_es.ts b/translations/deskflow_es.ts index 5f0dd175f..14a53d035 100644 --- a/translations/deskflow_es.ts +++ b/translations/deskflow_es.ts @@ -423,10 +423,6 @@ Do you want to connect to the server? Using IP: Usando IP: - - Selected as the interface in settings. - Seleccionado como la interfaz en la configuración. - Suggested IP: IP sugerida: @@ -473,12 +469,6 @@ La dirección IP asignada ahora no es válida; es posible que deba reiniciar el invalid certificate, generating a new one certificado no válido, generando uno nuevo - - -Interface is not active. Unable to start server. - -La interfaz no está activa. No se puede iniciar el servidor. - %1 will retry in a moment... %1 lo intentará nuevamente en un momento... diff --git a/translations/deskflow_it.ts b/translations/deskflow_it.ts index 85a4fd859..1c5ba2255 100644 --- a/translations/deskflow_it.ts +++ b/translations/deskflow_it.ts @@ -411,10 +411,6 @@ Vuoi connetterti al server? Using IP: Utilizzo dell'indirizzo IP: - - Selected as the interface in settings. - Selezionata come interfaccia nelle impostazioni. - Suggested IP: IP suggerito: @@ -481,12 +477,6 @@ Nomi validi: invalid certificate, generating a new one certificato non valido, ne viene generato uno nuovo - - -Interface is not active. Unable to start server. - -L'interfaccia non è attiva. Impossibile avviare il server. - %1 will retry in a moment... %1 riproverà tra un momento... diff --git a/translations/deskflow_ja.ts b/translations/deskflow_ja.ts index 90dff3231..8a0a6f2cd 100644 --- a/translations/deskflow_ja.ts +++ b/translations/deskflow_ja.ts @@ -375,10 +375,6 @@ Do you want to connect to the server? Using IP: IPアドレスを使用する: - - Selected as the interface in settings. - 設定でインターフェースとして選択されています。 - <p>If connecting via the hostname fails, try %1</p> <p>ホスト名での接続が失敗する場合は %1 を試してください。</p> @@ -540,12 +536,6 @@ Valid names: %1 クライアント: %1 - - - -Interface is not active. Unable to start server. - -インターフェースがアクティブではありません。サーバーを起動できません。 Suggested IP: diff --git a/translations/deskflow_ru.ts b/translations/deskflow_ru.ts index 2e9d31c37..ff48d169e 100644 --- a/translations/deskflow_ru.ts +++ b/translations/deskflow_ru.ts @@ -377,10 +377,6 @@ Do you want to connect to the server? Using IP: Использование IP-адреса: - - Selected as the interface in settings. - Выбран в качестве интерфейса в настройках. - <p>If connecting via the hostname fails, try %1</p> <p>Если подключение по имени хоста не получается, попробуй %1</p> @@ -544,12 +540,6 @@ Valid names: %1 Клиент: %1 - - - -Interface is not active. Unable to start server. - -Интерфейс неактивен. Невозможно запустить сервер. Suggested IP: diff --git a/translations/deskflow_zh_CN.ts b/translations/deskflow_zh_CN.ts index 9b1d9fc58..7e03d6123 100644 --- a/translations/deskflow_zh_CN.ts +++ b/translations/deskflow_zh_CN.ts @@ -375,10 +375,6 @@ Do you want to connect to the server? Using IP: 使用IP地址: - - Selected as the interface in settings. - 在设置中选择为接口。 - <p>If connecting via the hostname fails, try %1</p> <p>如果通过主机名连接失败,请尝试 %1</p> @@ -540,12 +536,6 @@ Valid names: %1 客户端: %1 - - - -Interface is not active. Unable to start server. - -接口未激活。无法启动服务器。 Suggested IP: