From 5624cf25f1519c9f094ae139e346315c9209a266 Mon Sep 17 00:00:00 2001 From: Tony Mountifield Date: Mon, 3 Aug 2026 16:02:02 +0100 Subject: [PATCH 1/3] Deselect server in list when clicking on address box --- src/connectdlg.cpp | 14 ++++++++++++++ src/connectdlg.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/src/connectdlg.cpp b/src/connectdlg.cpp index 468296205d..f78b4441d9 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 @@ -1195,3 +1198,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..46f8ab486f 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; From fc0cf14a7b9b4791f6049a70b5bebc98cf152c98 Mon Sep 17 00:00:00 2001 From: Tony Mountifield Date: Mon, 3 Aug 2026 16:07:32 +0100 Subject: [PATCH 2/3] No longer need handler for server addr edit text changed --- src/connectdlg.cpp | 9 --------- src/connectdlg.h | 1 - 2 files changed, 10 deletions(-) diff --git a/src/connectdlg.cpp b/src/connectdlg.cpp index f78b4441d9..96daebf30a 100644 --- a/src/connectdlg.cpp +++ b/src/connectdlg.cpp @@ -279,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 @@ -664,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() { diff --git a/src/connectdlg.h b/src/connectdlg.h index 46f8ab486f..0272c295be 100644 --- a/src/connectdlg.h +++ b/src/connectdlg.h @@ -147,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 ); } From 7b5600ed6ae956a72e32d7eb0476abc12f72e5a8 Mon Sep 17 00:00:00 2001 From: Tony Mountifield Date: Wed, 5 Aug 2026 17:08:18 +0100 Subject: [PATCH 3/3] Save current server item and restore on regaining focus --- src/connectdlg.cpp | 20 ++++++++++++++++++++ src/connectdlg.h | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/connectdlg.cpp b/src/connectdlg.cpp index 96daebf30a..c119809bec 100644 --- a/src/connectdlg.cpp +++ b/src/connectdlg.cpp @@ -207,6 +207,7 @@ CConnectDlg::CConnectDlg ( CClient* pNCliP, CClientSettings* pNSetP, const bool // install event filter to catch FocusIn cbxServerAddr->installEventFilter ( this ); + lvwServers->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) @@ -334,6 +335,7 @@ void CConnectDlg::RequestServerList() // clear server list view lvwServers->clear(); + savedServer = nullptr; // update list combo box (disable events to avoid a signal) cbxDirectory->blockSignals ( true ); @@ -1194,9 +1196,27 @@ bool CConnectDlg::eventFilter ( QObject* obj, QEvent* event ) { if ( obj == cbxServerAddr && event->type() == QEvent::FocusIn ) { + // check for a selected server before clearing the selection in the list + QList CurSelListItemList = lvwServers->selectedItems(); + + if ( CurSelListItemList.count() > 0 ) + { + // there was a selected item - save it before deselecting + savedServer = GetParentListViewItem ( CurSelListItemList[0] ); + } // remove selection in the server list (if any) lvwServers->clearSelection(); } + if ( obj == lvwServers && event->type() == QEvent::FocusIn ) + { + if ( savedServer ) + { + // re-select any previously-selected server on regaining focus + lvwServers->setCurrentItem ( savedServer ); + savedServer = nullptr; + } + } + return QDialog::eventFilter ( obj, event ); } diff --git a/src/connectdlg.h b/src/connectdlg.h index 0272c295be..ad283a3a35 100644 --- a/src/connectdlg.h +++ b/src/connectdlg.h @@ -127,7 +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 ); + bool eventFilter ( QObject* obj, QEvent* event ) override; + CMappedTreeWidgetItem* savedServer; CClient* pClient; CClientSettings* pSettings;