diff --git a/src/clientdlg.cpp b/src/clientdlg.cpp index 99b9fa6433..3d08378f51 100644 --- a/src/clientdlg.cpp +++ b/src/clientdlg.cpp @@ -805,8 +805,11 @@ void CClientDlg::OnVersionAndOSReceived ( COSUtil::EOpSystemType, QString strVer #endif } -void CClientDlg::OnCLVersionAndOSReceived ( CHostAddress, COSUtil::EOpSystemType, QString strVersion ) +void CClientDlg::OnCLVersionAndOSReceived ( CHostAddress InetAddr, COSUtil::EOpSystemType, QString strVersion ) { + // display version in connect dialog + ConnectDlg.SetServerVersionResult ( InetAddr, strVersion ); + // update check #if ( QT_VERSION >= QT_VERSION_CHECK( 5, 6, 0 ) ) && !defined( DISABLE_VERSION_CHECK ) int mySuffixIndex; diff --git a/src/connectdlg.cpp b/src/connectdlg.cpp index 9bb5104fb0..9b9c6310c9 100644 --- a/src/connectdlg.cpp +++ b/src/connectdlg.cpp @@ -113,12 +113,12 @@ CConnectDlg::CConnectDlg ( CClientSettings* pNSetP, const bool bNewShowCompleteR #ifdef ANDROID // for Android we need larger numbers because of the default font size lvwServers->setColumnWidth ( 0, 200 ); - lvwServers->setColumnWidth ( 1, 130 ); + lvwServers->setColumnWidth ( 1, 110 ); lvwServers->setColumnWidth ( 2, 130 ); lvwServers->setColumnWidth ( 3, 100 ); #else lvwServers->setColumnWidth ( 0, 180 ); - lvwServers->setColumnWidth ( 1, 75 ); + lvwServers->setColumnWidth ( 1, 65 ); lvwServers->setColumnWidth ( 2, 75 ); lvwServers->setColumnWidth ( 3, 70 ); lvwServers->setColumnWidth ( 4, 220 ); @@ -775,26 +775,29 @@ void CConnectDlg::OnTimerPing() for ( int iIdx = 0; iIdx < iServerListLen; iIdx++ ) { + QTreeWidgetItem* pCurListViewItem = lvwServers->topLevelItem ( iIdx ); + + // we need to ask for the server version only if we have not received it + const bool bNeedVersion = pCurListViewItem->text ( 1 ).isEmpty(); + CHostAddress haServerAddress; // try to parse host address string which is stored as user data // in the server list item GUI control element - if ( NetworkUtil().ParseNetworkAddress ( lvwServers->topLevelItem ( iIdx )->data ( 0, Qt::UserRole ).toString(), - haServerAddress, - bEnableIPv6 ) ) + if ( NetworkUtil().ParseNetworkAddress ( pCurListViewItem->data ( 0, Qt::UserRole ).toString(), haServerAddress, bEnableIPv6 ) ) { // if address is valid, send ping message using a new thread #if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) - QFuture f = QtConcurrent::run ( &CConnectDlg::EmitCLServerListPingMes, this, haServerAddress ); + QFuture f = QtConcurrent::run ( &CConnectDlg::EmitCLServerListPingMes, this, haServerAddress, bNeedVersion ); Q_UNUSED ( f ); #else - QtConcurrent::run ( this, &CConnectDlg::EmitCLServerListPingMes, haServerAddress ); + QtConcurrent::run ( this, &CConnectDlg::EmitCLServerListPingMes, haServerAddress, bNeedVersion ); #endif } } } -void CConnectDlg::EmitCLServerListPingMes ( const CHostAddress& haServerAddress ) +void CConnectDlg::EmitCLServerListPingMes ( const CHostAddress& haServerAddress, const bool bNeedVersion ) { // The ping time messages for all servers should not be sent all in a very // short time since it showed that this leads to errors in the ping time @@ -804,6 +807,12 @@ void CConnectDlg::EmitCLServerListPingMes ( const CHostAddress& haServerAddress QThread::msleep ( 11 ); emit CreateCLServerListPingMes ( haServerAddress ); + + // also request the server version if we have not already received it + if ( bNeedVersion ) + { + emit CreateCLServerListReqVerAndOSMes ( haServerAddress ); + } } void CConnectDlg::SetPingTimeAndNumClientsResult ( const CHostAddress& InetAddr, const int iPingTime, const int iNumClients ) @@ -937,6 +946,17 @@ void CConnectDlg::SetPingTimeAndNumClientsResult ( const CHostAddress& InetAddr, UpdateListFilter(); } +void CConnectDlg::SetServerVersionResult ( const CHostAddress& InetAddr, const QString& strVersion ) +{ + // apply the received ping time to the correct server list entry + QTreeWidgetItem* pCurListViewItem = FindListViewItem ( InetAddr ); + + if ( pCurListViewItem ) + { + pCurListViewItem->setText ( 1, strVersion ); + } +} + QTreeWidgetItem* CConnectDlg::FindListViewItem ( const CHostAddress& InetAddr ) { const int iServerListLen = lvwServers->topLevelItemCount(); diff --git a/src/connectdlg.h b/src/connectdlg.h index 71c79ddb1f..2a9aa6a3e5 100644 --- a/src/connectdlg.h +++ b/src/connectdlg.h @@ -59,6 +59,7 @@ class CConnectDlg : public CBaseDlg, private Ui_CConnectDlgBase void SetConnClientsList ( const CHostAddress& InetAddr, const CVector& vecChanInfo ); void SetPingTimeAndNumClientsResult ( const CHostAddress& InetAddr, const int iPingTime, const int iNumClients ); + void SetServerVersionResult ( const CHostAddress& InetAddr, const QString& strVersion ); bool GetServerListItemWasChosen() const { return bServerListItemWasChosen; } QString GetSelectedAddress() const { return strSelectedAddress; } @@ -74,7 +75,7 @@ class CConnectDlg : public CBaseDlg, private Ui_CConnectDlgBase void UpdateListFilter(); void ShowAllMusicians ( const bool bState ); void RequestServerList(); - void EmitCLServerListPingMes ( const CHostAddress& haServerAddress ); + void EmitCLServerListPingMes ( const CHostAddress& haServerAddress, const bool bNeedVersion ); void UpdateDirectoryComboBox(); CClientSettings* pSettings;