Skip to content

Commit

Permalink
Fixes #1421: Add "delete server" button to connect dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
pljones committed Oct 5, 2023
1 parent 5fdd707 commit 589ee24
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/connectdlg.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ CConnectDlg::CConnectDlg ( CClientSettings* pNSetP, const bool bNewShowCompleteR
cbxServerAddr->setAccessibleName ( tr ( "Server address edit box" ) );
cbxServerAddr->setAccessibleDescription ( tr ( "Holds the current server address. It also stores old addresses in the combo box list." ) );

tbtDeleteServerAddr->setAccessibleName ( tr ( "Delete server address button" ) );
tbtDeleteServerAddr->setWhatsThis ( "<b>" + tr ( "Delete Server Address" ) + ":</b> " +
tr ( "Click the button to clear the currently selected server address "
"and delete it from the list of stored servers." ) );
tbtDeleteServerAddr->setText ( u8"\u232B" );

UpdateDirectoryComboBox();

// init server address combo box (max MAX_NUM_SERVER_ADDR_ITEMS entries)
Expand Down Expand Up @@ -179,6 +185,9 @@ CConnectDlg::CConnectDlg ( CClientSettings* pNSetP, const bool bNewShowCompleteR

QObject::connect ( butConnect, &QPushButton::clicked, this, &CConnectDlg::OnConnectClicked );

// tool buttons
QObject::connect ( tbtDeleteServerAddr, &QPushButton::clicked, this, &CConnectDlg::OnDeleteServerAddrClicked );

// timers
QObject::connect ( &TimerPing, &QTimer::timeout, this, &CConnectDlg::OnTimerPing );

Expand Down Expand Up @@ -731,6 +740,31 @@ void CConnectDlg::OnConnectClicked()
done ( QDialog::Accepted );
}

void CConnectDlg::OnDeleteServerAddrClicked()
{
if ( cbxServerAddr->currentText().isEmpty() )
{
return;
}

// move later items down one
for ( int iLEIdx = 0; iLEIdx < MAX_NUM_SERVER_ADDR_ITEMS - 1; iLEIdx++ )
{
while ( pSettings->vstrIPAddress[iLEIdx].compare ( cbxServerAddr->currentText() ) == 0 )
{
for ( int jLEIdx = iLEIdx + 1; jLEIdx < MAX_NUM_SERVER_ADDR_ITEMS; jLEIdx++ )
{
pSettings->vstrIPAddress[jLEIdx - 1] = pSettings->vstrIPAddress[jLEIdx];
}
}
}
// empty last entry
pSettings->vstrIPAddress[MAX_NUM_SERVER_ADDR_ITEMS - 1] = QString();

// redisplay to pick up updated list
showEvent ( nullptr );
}

void CConnectDlg::OnTimerPing()
{
// send ping messages to the servers in the list
Expand Down
1 change: 1 addition & 0 deletions src/connectdlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public slots:
void OnExpandAllStateChanged ( int value ) { ShowAllMusicians ( value == Qt::Checked ); }
void OnCustomDirectoriesChanged();
void OnConnectClicked();
void OnDeleteServerAddrClicked();
void OnTimerPing();
void OnTimerReRequestServList();

Expand Down
3 changes: 3 additions & 0 deletions src/connectdlgbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="tbtDeleteServerAddr"/>
</item>
</layout>
</item>
<item>
Expand Down

0 comments on commit 589ee24

Please sign in to comment.