Skip to content

Commit e462529

Browse files
authored
Merge pull request #3159 from pljones/feature/1421-delete-saved-servers
Fixes #1421: Add "delete server" button to connect dialog
2 parents 79d3284 + d5d1ab0 commit e462529

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

src/connectdlg.cpp

100644100755
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ CConnectDlg::CConnectDlg ( CClientSettings* pNSetP, const bool bNewShowCompleteR
9696
cbxServerAddr->setAccessibleName ( tr ( "Server address edit box" ) );
9797
cbxServerAddr->setAccessibleDescription ( tr ( "Holds the current server address. It also stores old addresses in the combo box list." ) );
9898

99+
butDeleteServerAddr->setAccessibleName ( tr ( "Delete server address button" ) );
100+
butDeleteServerAddr->setWhatsThis ( "<b>" + tr ( "Delete Server Address" ) + ":</b> " +
101+
tr ( "Click the button to clear the currently selected server address "
102+
"and delete it from the list of stored servers." ) );
103+
99104
UpdateDirectoryComboBox();
100105

101106
// init server address combo box (max MAX_NUM_SERVER_ADDR_ITEMS entries)
@@ -179,6 +184,9 @@ CConnectDlg::CConnectDlg ( CClientSettings* pNSetP, const bool bNewShowCompleteR
179184

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

187+
// tool buttons
188+
QObject::connect ( butDeleteServerAddr, &QPushButton::clicked, this, &CConnectDlg::OnDeleteServerAddrClicked );
189+
182190
// timers
183191
QObject::connect ( &TimerPing, &QTimer::timeout, this, &CConnectDlg::OnTimerPing );
184192

@@ -731,6 +739,31 @@ void CConnectDlg::OnConnectClicked()
731739
done ( QDialog::Accepted );
732740
}
733741

742+
void CConnectDlg::OnDeleteServerAddrClicked()
743+
{
744+
if ( cbxServerAddr->currentText().isEmpty() )
745+
{
746+
return;
747+
}
748+
749+
// move later items down one
750+
for ( int iLEIdx = 0; iLEIdx < MAX_NUM_SERVER_ADDR_ITEMS - 1; iLEIdx++ )
751+
{
752+
while ( pSettings->vstrIPAddress[iLEIdx].compare ( cbxServerAddr->currentText() ) == 0 )
753+
{
754+
for ( int jLEIdx = iLEIdx + 1; jLEIdx < MAX_NUM_SERVER_ADDR_ITEMS; jLEIdx++ )
755+
{
756+
pSettings->vstrIPAddress[jLEIdx - 1] = pSettings->vstrIPAddress[jLEIdx];
757+
}
758+
}
759+
}
760+
// empty last entry
761+
pSettings->vstrIPAddress[MAX_NUM_SERVER_ADDR_ITEMS - 1] = QString();
762+
763+
// redisplay to pick up updated list
764+
showEvent ( nullptr );
765+
}
766+
734767
void CConnectDlg::OnTimerPing()
735768
{
736769
// send ping messages to the servers in the list

src/connectdlg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ public slots:
101101
void OnExpandAllStateChanged ( int value ) { ShowAllMusicians ( value == Qt::Checked ); }
102102
void OnCustomDirectoriesChanged();
103103
void OnConnectClicked();
104+
void OnDeleteServerAddrClicked();
104105
void OnTimerPing();
105106
void OnTimerReRequestServList();
106107

src/connectdlgbase.ui

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,30 @@
107107
</property>
108108
</widget>
109109
</item>
110+
<item>
111+
<widget class="QPushButton" name="butDeleteServerAddr">
112+
<property name="sizePolicy">
113+
<sizepolicy hsizetype="Maximum" vsizetype="Ignored">
114+
<horstretch>0</horstretch>
115+
<verstretch>0</verstretch>
116+
</sizepolicy>
117+
</property>
118+
<property name="maximumSize">
119+
<size>
120+
<width>24</width>
121+
<height>16777215</height>
122+
</size>
123+
</property>
124+
<property name="font">
125+
<font>
126+
<bold>true</bold>
127+
</font>
128+
</property>
129+
<property name="text">
130+
<string notr="true">⌫</string>
131+
</property>
132+
</widget>
133+
</item>
110134
</layout>
111135
</item>
112136
<item>

0 commit comments

Comments
 (0)