@@ -360,14 +360,16 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, CClientSettings* pNSet
360
360
// custom directories
361
361
QString strCustomDirectories = " <b>" + tr ( " Custom Directories" ) + " :</b> " +
362
362
tr ( " If you need to add additional directories to the Connect dialog Directory drop down, "
363
- " you can enter the addresses here.<br>"
364
- " To remove a value, select it, delete the text in the input box, "
365
- " then move focus out of the control." );
363
+ " you can enter the addresses here.<br>" );
366
364
367
365
lblCustomDirectories->setWhatsThis ( strCustomDirectories );
368
366
cbxCustomDirectories->setWhatsThis ( strCustomDirectories );
369
367
cbxCustomDirectories->setAccessibleName ( tr ( " Custom Directories combo box" ) );
370
368
369
+ butDeleteCustomDirectory->setAccessibleName ( tr ( " Delete custom directory button" ) );
370
+ butDeleteCustomDirectory->setWhatsThis ( " <b>" + tr ( " Delete Custom Directory" ) + " :</b> " +
371
+ tr ( " Click the button to delete the currently selected custom directory." ) );
372
+
371
373
// current connection status parameter
372
374
QString strConnStats = " <b>" + tr ( " Audio Upstream Rate" ) + " :</b> " +
373
375
tr ( " Depends on the current audio packet size and "
@@ -691,12 +693,9 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, CClientSettings* pNSet
691
693
this ,
692
694
&CClientSettingsDlg::OnMeterStyleActivated );
693
695
694
- QObject::connect ( cbxCustomDirectories->lineEdit (), &QLineEdit::editingFinished, this , &CClientSettingsDlg::OnCustomDirectoriesEditingFinished );
695
-
696
- QObject::connect ( cbxCustomDirectories,
697
- static_cast <void ( QComboBox::* ) ( int )> ( &QComboBox::activated ),
698
- this ,
699
- &CClientSettingsDlg::OnCustomDirectoriesEditingFinished );
696
+ QObject::connect ( cbxCustomDirectories->lineEdit (), &QLineEdit::editingFinished, this , [this ] {
697
+ CClientSettingsDlg::OnCustomDirectoriesChanged ( false );
698
+ } );
700
699
701
700
QObject::connect ( cbxLanguage, &CLanguageComboBox::LanguageChanged, this , &CClientSettingsDlg::OnLanguageChanged );
702
701
@@ -711,6 +710,8 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, CClientSettings* pNSet
711
710
QObject::connect ( butDriverSetup, &QPushButton::clicked, this , &CClientSettingsDlg::OnDriverSetupClicked );
712
711
#endif
713
712
713
+ QObject::connect ( butDeleteCustomDirectory, &QPushButton::clicked, this , [this ] { CClientSettingsDlg::OnCustomDirectoriesChanged ( true ); } );
714
+
714
715
// misc
715
716
// sliders
716
717
QObject::connect ( sldAudioPan, &QSlider::valueChanged, this , &CClientSettingsDlg::OnAudioPanValueChanged );
@@ -1009,29 +1010,32 @@ void CClientSettingsDlg::OnEnableOPUS64StateChanged ( int value )
1009
1010
1010
1011
void CClientSettingsDlg::OnFeedbackDetectionChanged ( int value ) { pSettings->bEnableFeedbackDetection = value == Qt::Checked; }
1011
1012
1012
- void CClientSettingsDlg::OnCustomDirectoriesEditingFinished ( )
1013
+ void CClientSettingsDlg::OnCustomDirectoriesChanged ( bool bDelete )
1013
1014
{
1014
- if ( cbxCustomDirectories->currentText ().isEmpty () && cbxCustomDirectories->currentData ().isValid () )
1015
- {
1016
- // if the user has selected an entry in the combo box list and deleted the text in the input field,
1017
- // and then focus moves off the control without selecting a new entry,
1018
- // we delete the corresponding entry in the vector
1019
- pSettings->vstrDirectoryAddress [cbxCustomDirectories->currentData ().toInt ()] = " " ;
1020
- }
1021
- else if ( cbxCustomDirectories->currentData ().isValid () && pSettings->vstrDirectoryAddress [cbxCustomDirectories->currentData ().toInt ()].compare (
1022
- NetworkUtil::FixAddress ( cbxCustomDirectories->currentText () ) ) == 0 )
1015
+ if ( bDelete )
1023
1016
{
1024
- // if the user has selected another entry in the combo box list without changing anything,
1025
- // there is no need to update any list
1026
- return ;
1017
+ if ( !cbxCustomDirectories->currentData ().isValid () )
1018
+ {
1019
+ // no selected directory to delete
1020
+ return ;
1021
+ }
1022
+ // delete the selected directory
1023
+ pSettings->vstrDirectoryAddress [cbxCustomDirectories->currentData ().toInt ()] = QString ();
1027
1024
}
1028
1025
else
1029
1026
{
1027
+
1028
+ if ( cbxCustomDirectories->currentText ().isEmpty () ||
1029
+ ( cbxCustomDirectories->currentData ().isValid () && pSettings->vstrDirectoryAddress [cbxCustomDirectories->currentData ().toInt ()].compare (
1030
+ NetworkUtil::FixAddress ( cbxCustomDirectories->currentText () ) ) == 0 ) )
1031
+ {
1032
+ // no need to add a already added directory
1033
+ return ;
1034
+ }
1030
1035
// store new address at the top of the list, if the list was already
1031
1036
// full, the last element is thrown out
1032
1037
pSettings->vstrDirectoryAddress .StringFiFoWithCompare ( NetworkUtil::FixAddress ( cbxCustomDirectories->currentText () ) );
1033
1038
}
1034
-
1035
1039
// update combo box list and inform connect dialog about the new address
1036
1040
UpdateDirectoryComboBox ();
1037
1041
emit CustomDirectoriesChanged ();
0 commit comments