From 10c5931f5b714996a1282d207259cc854b9aa678 Mon Sep 17 00:00:00 2001 From: Peter L Jones Date: Mon, 28 Aug 2023 12:37:50 +0100 Subject: [PATCH] Fixes #1421: Add "delete server" button to connect dialog --- src/connectdlg.cpp | 33 +++++++++++++++++++++++++++++++++ src/connectdlg.h | 1 + src/connectdlgbase.ui | 19 +++++++++++++++++++ 3 files changed, 53 insertions(+) mode change 100644 => 100755 src/connectdlg.cpp diff --git a/src/connectdlg.cpp b/src/connectdlg.cpp old mode 100644 new mode 100755 index 9df63d5623..f588818c56 --- a/src/connectdlg.cpp +++ b/src/connectdlg.cpp @@ -96,6 +96,11 @@ 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." ) ); + butDeleteServerAddr->setAccessibleName ( tr ( "Delete server address button" ) ); + butDeleteServerAddr->setWhatsThis ( "" + tr ( "Delete Server Address" ) + ": " + + tr ( "Click the button to clear the currently selected server address " + "and delete it from the list of stored servers." ) ); + UpdateDirectoryComboBox(); // init server address combo box (max MAX_NUM_SERVER_ADDR_ITEMS entries) @@ -179,6 +184,9 @@ CConnectDlg::CConnectDlg ( CClientSettings* pNSetP, const bool bNewShowCompleteR QObject::connect ( butConnect, &QPushButton::clicked, this, &CConnectDlg::OnConnectClicked ); + // tool buttons + QObject::connect ( butDeleteServerAddr, &QPushButton::clicked, this, &CConnectDlg::OnDeleteServerAddrClicked ); + // timers QObject::connect ( &TimerPing, &QTimer::timeout, this, &CConnectDlg::OnTimerPing ); @@ -731,6 +739,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 diff --git a/src/connectdlg.h b/src/connectdlg.h index 078d9ba2ee..13f9ca81e1 100644 --- a/src/connectdlg.h +++ b/src/connectdlg.h @@ -101,6 +101,7 @@ public slots: void OnExpandAllStateChanged ( int value ) { ShowAllMusicians ( value == Qt::Checked ); } void OnCustomDirectoriesChanged(); void OnConnectClicked(); + void OnDeleteServerAddrClicked(); void OnTimerPing(); void OnTimerReRequestServList(); diff --git a/src/connectdlgbase.ui b/src/connectdlgbase.ui index 021d1663e5..b2f4d8d9e2 100644 --- a/src/connectdlgbase.ui +++ b/src/connectdlgbase.ui @@ -107,6 +107,25 @@ + + + + + 0 + 0 + + + + + 32 + 16777215 + + + + + + +