refactor: Remove need for NetworkMonitor::getSuggestedIpAddress. Its always first if there is data

This commit is contained in:
sithlord48 2026-01-02 16:12:53 -05:00 committed by Chris Rizzitello
parent ae9ca35448
commit 844ebf5216
3 changed files with 3 additions and 17 deletions

View file

@ -431,7 +431,7 @@ void MainWindow::startCore()
// Save current IP state when server starts // Save current IP state when server starts
if (m_coreProcess.mode() == CoreMode::Server) { if (m_coreProcess.mode() == CoreMode::Server) {
m_serverStartIPs = m_networkMonitor->getAvailableIPv4Addresses(); m_serverStartIPs = m_networkMonitor->getAvailableIPv4Addresses();
m_serverStartSuggestedIP = m_networkMonitor->getSuggestedIPv4Address(); m_serverStartSuggestedIP = m_serverStartIPs.isEmpty() ? "" : m_serverStartIPs.first();
} }
m_coreProcess.start(); m_coreProcess.start();
@ -1304,8 +1304,8 @@ void MainWindow::updateIpLabel(const QStringList &addresses)
} }
} else { } else {
// Server is not running - update normally // Server is not running - update normally
m_currentIpAddress = m_networkMonitor->getSuggestedIPv4Address(); m_currentIpAddress = ipList.first();
labelText.append(m_currentIpAddress.isEmpty() ? m_currentIpAddress : ipList.first()); labelText.append(m_currentIpAddress);
} }
if (ipList.count() < 2) { if (ipList.count() < 2) {

View file

@ -117,14 +117,6 @@ QStringList NetworkMonitor::getAvailableIPv4Addresses() const
return ipList; return ipList;
} }
QString NetworkMonitor::getSuggestedIPv4Address() const
{
const auto addresses = getAvailableIPv4Addresses();
if (addresses.isEmpty())
return {};
return addresses.first();
}
void NetworkMonitor::setIpAddresses(const QStringList &newAddresses) void NetworkMonitor::setIpAddresses(const QStringList &newAddresses)
{ {
if (newAddresses == m_lastAddresses) if (newAddresses == m_lastAddresses)

View file

@ -52,12 +52,6 @@ public:
*/ */
QStringList getAvailableIPv4Addresses() const; QStringList getAvailableIPv4Addresses() const;
/**
* @brief Get recommended IP address (RFC-1918 addresses preferred)
* @return Recommended IP address, returns null if none available
*/
QString getSuggestedIPv4Address() const;
Q_SIGNALS: Q_SIGNALS:
/** /**
* @brief Emitted when IP addresses change * @brief Emitted when IP addresses change