Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 39 additions & 9 deletions src/connectdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ bool CMappedTreeWidgetItem::operator<( const QTreeWidgetItem& other ) const

CConnectDlg::CConnectDlg ( CClientSettings* pNSetP, const bool bNewShowCompleteRegList, const bool bNEnableIPv6, QWidget* parent ) :
CBaseDlg ( parent, Qt::Dialog ),
savedServer ( nullptr ),
pSettings ( pNSetP ),
strSelectedAddress ( "" ),
strSelectedServerName ( "" ),
Expand Down Expand Up @@ -205,6 +206,10 @@ CConnectDlg::CConnectDlg ( CClientSettings* pNSetP, const bool bNewShowCompleteR
cbxServerAddr->setMaxCount ( MAX_NUM_SERVER_ADDR_ITEMS );
cbxServerAddr->setInsertPolicy ( QComboBox::NoInsert );

// 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)
#ifdef ANDROID
Expand Down Expand Up @@ -276,10 +281,11 @@ CConnectDlg::CConnectDlg ( CClientSettings* pNSetP, const bool bNewShowCompleteR
QObject::connect ( edtFilter, &QLineEdit::textEdited, this, &CConnectDlg::OnFilterTextEdited );

// combo boxes
QObject::connect ( cbxServerAddr, &QComboBox::editTextChanged, this, &CConnectDlg::OnServerAddrEditTextChanged );

QObject::connect ( cbxDirectory, static_cast<void ( QComboBox::* ) ( int )> ( &QComboBox::activated ), this, &CConnectDlg::OnDirectoryChanged );

// connect when pressing Enter in the Server Address box
QObject::connect ( cbxServerAddr->lineEdit(), &QLineEdit::returnPressed, this, &CConnectDlg::OnConnectClicked );

// check boxes
QObject::connect ( chbExpandAll, &QCheckBox::stateChanged, this, &CConnectDlg::OnExpandAllStateChanged );

Expand Down Expand Up @@ -332,6 +338,7 @@ void CConnectDlg::RequestServerList()
strSelectedServerName = "";

// clear server list view
savedServer = nullptr;
lvwServers->clear();

// update list combo box (disable events to avoid a signal)
Expand Down Expand Up @@ -443,6 +450,7 @@ void CConnectDlg::SetServerList ( const CHostAddress& InetAddr, const CVector<CS
}

// first clear list
savedServer = nullptr;
lvwServers->clear();

// add list item for each server in the server list
Expand Down Expand Up @@ -661,13 +669,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()
{

Expand Down Expand Up @@ -1187,3 +1188,32 @@ 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 )
{
// check for a selected server before clearing the selection in the list
QList<QTreeWidgetItem*> 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 );
}
4 changes: 3 additions & 1 deletion src/connectdlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ class CConnectDlg : public CBaseDlg, private Ui_CConnectDlgBase
void EmitCLServerListPingMes ( const CHostAddress& haServerAddress, const bool bNeedVersion );
void UpdateDirectoryComboBox();

bool eventFilter ( QObject* obj, QEvent* event ) override;
CMappedTreeWidgetItem* savedServer;

CClientSettings* pSettings;

QTimer TimerPing;
Expand All @@ -145,7 +148,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 ); }
Expand Down
3 changes: 0 additions & 3 deletions src/connectdlgbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="tabKeyNavigation">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>Server Name</string>
Expand Down