diff --git a/src/connectdlg.cpp b/src/connectdlg.cpp index 468296205d..96daebf30a 100644 --- a/src/connectdlg.cpp +++ b/src/connectdlg.cpp @@ -205,6 +205,9 @@ CConnectDlg::CConnectDlg ( CClient* pNCliP, CClientSettings* pNSetP, const bool cbxServerAddr->setMaxCount ( MAX_NUM_SERVER_ADDR_ITEMS ); cbxServerAddr->setInsertPolicy ( QComboBox::NoInsert ); + // install event filter to catch FocusIn + cbxServerAddr->installEventFilter ( this ); + // set up list view for connected clients (note that the last column size // must not be specified since this column takes all the remaining space) #ifdef ANDROID @@ -276,8 +279,6 @@ CConnectDlg::CConnectDlg ( CClient* pNCliP, CClientSettings* pNSetP, const bool QObject::connect ( edtFilter, &QLineEdit::textEdited, this, &CConnectDlg::OnFilterTextEdited ); // combo boxes - QObject::connect ( cbxServerAddr, &QComboBox::editTextChanged, this, &CConnectDlg::OnServerAddrEditTextChanged ); - QObject::connect ( cbxDirectory, static_cast ( &QComboBox::activated ), this, &CConnectDlg::OnDirectoryChanged ); // check boxes @@ -661,13 +662,6 @@ void CConnectDlg::OnServerListItemDoubleClicked ( QTreeWidgetItem* Item, int ) } } -void CConnectDlg::OnServerAddrEditTextChanged ( const QString& ) -{ - // in the server address combo box, a text was changed, remove selection - // in the server list (if any) - lvwServers->clearSelection(); -} - void CConnectDlg::OnCustomDirectoriesChanged() { @@ -1195,3 +1189,14 @@ void CConnectDlg::OnCurrentServerItemChanged ( QTreeWidgetItem* current, QTreeWi QAccessible::updateAccessibility ( new QAccessibleAnnouncementEvent ( lvwServers, announcement ) ); #endif } + +bool CConnectDlg::eventFilter ( QObject* obj, QEvent* event ) +{ + if ( obj == cbxServerAddr && event->type() == QEvent::FocusIn ) + { + // remove selection in the server list (if any) + lvwServers->clearSelection(); + } + + return QDialog::eventFilter ( obj, event ); +} diff --git a/src/connectdlg.h b/src/connectdlg.h index 2d82a8c454..0272c295be 100644 --- a/src/connectdlg.h +++ b/src/connectdlg.h @@ -127,6 +127,8 @@ class CConnectDlg : public CBaseDlg, private Ui_CConnectDlgBase void EmitCLServerListPingMes ( const CHostAddress& haServerAddress, const bool bNeedVersion ); void UpdateDirectoryComboBox(); + bool eventFilter ( QObject* obj, QEvent* event ); + CClient* pClient; CClientSettings* pSettings; @@ -145,7 +147,6 @@ class CConnectDlg : public CBaseDlg, private Ui_CConnectDlgBase public slots: void OnServerListItemDoubleClicked ( QTreeWidgetItem* Item, int ); - void OnServerAddrEditTextChanged ( const QString& ); void OnDirectoryChanged ( int iTypeIdx ); void OnFilterTextEdited ( const QString& ) { UpdateListFilter(); } void OnExpandAllStateChanged ( int value ) { ShowAllMusicians ( value == Qt::Checked ); }