@@ -360,14 +360,16 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, CClientSettings* pNSet
360360 // custom directories
361361 QString strCustomDirectories = " <b>" + tr ( " Custom Directories" ) + " :</b> " +
362362 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>" );
366364
367365 lblCustomDirectories->setWhatsThis ( strCustomDirectories );
368366 cbxCustomDirectories->setWhatsThis ( strCustomDirectories );
369367 cbxCustomDirectories->setAccessibleName ( tr ( " Custom Directories combo box" ) );
370368
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+
371373 // current connection status parameter
372374 QString strConnStats = " <b>" + tr ( " Audio Upstream Rate" ) + " :</b> " +
373375 tr ( " Depends on the current audio packet size and "
@@ -691,12 +693,9 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, CClientSettings* pNSet
691693 this ,
692694 &CClientSettingsDlg::OnMeterStyleActivated );
693695
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+ } );
700699
701700 QObject::connect ( cbxLanguage, &CLanguageComboBox::LanguageChanged, this , &CClientSettingsDlg::OnLanguageChanged );
702701
@@ -711,6 +710,8 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, CClientSettings* pNSet
711710 QObject::connect ( butDriverSetup, &QPushButton::clicked, this , &CClientSettingsDlg::OnDriverSetupClicked );
712711#endif
713712
713+ QObject::connect ( butDeleteCustomDirectory, &QPushButton::clicked, this , [this ] { CClientSettingsDlg::OnCustomDirectoriesChanged ( true ); } );
714+
714715 // misc
715716 // sliders
716717 QObject::connect ( sldAudioPan, &QSlider::valueChanged, this , &CClientSettingsDlg::OnAudioPanValueChanged );
@@ -1009,29 +1010,32 @@ void CClientSettingsDlg::OnEnableOPUS64StateChanged ( int value )
10091010
10101011void CClientSettingsDlg::OnFeedbackDetectionChanged ( int value ) { pSettings->bEnableFeedbackDetection = value == Qt::Checked; }
10111012
1012- void CClientSettingsDlg::OnCustomDirectoriesEditingFinished ( )
1013+ void CClientSettingsDlg::OnCustomDirectoriesChanged ( bool bDelete )
10131014{
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 )
10231016 {
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 ();
10271024 }
10281025 else
10291026 {
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+ }
10301035 // store new address at the top of the list, if the list was already
10311036 // full, the last element is thrown out
10321037 pSettings->vstrDirectoryAddress .StringFiFoWithCompare ( NetworkUtil::FixAddress ( cbxCustomDirectories->currentText () ) );
10331038 }
1034-
10351039 // update combo box list and inform connect dialog about the new address
10361040 UpdateDirectoryComboBox ();
10371041 emit CustomDirectoriesChanged ();
0 commit comments