diff --git a/src/clientsettingsdlg.cpp b/src/clientsettingsdlg.cpp index d31ca03b7e..f4437603be 100644 --- a/src/clientsettingsdlg.cpp +++ b/src/clientsettingsdlg.cpp @@ -360,14 +360,16 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, CClientSettings* pNSet // custom directories QString strCustomDirectories = "" + tr ( "Custom Directories" ) + ": " + tr ( "If you need to add additional directories to the Connect dialog Directory drop down, " - "you can enter the addresses here.
" - "To remove a value, select it, delete the text in the input box, " - "then move focus out of the control." ); + "you can enter the addresses here.
" ); lblCustomDirectories->setWhatsThis ( strCustomDirectories ); cbxCustomDirectories->setWhatsThis ( strCustomDirectories ); cbxCustomDirectories->setAccessibleName ( tr ( "Custom Directories combo box" ) ); + butDeleteCustomDirectory->setAccessibleName ( tr ( "Delete custom directory button" ) ); + butDeleteCustomDirectory->setWhatsThis ( "" + tr ( "Delete Custom Directory" ) + ": " + + tr ( "Click the button to delete the currently selected custom directory." ) ); + // current connection status parameter QString strConnStats = "" + tr ( "Audio Upstream Rate" ) + ": " + tr ( "Depends on the current audio packet size and " @@ -691,12 +693,9 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, CClientSettings* pNSet this, &CClientSettingsDlg::OnMeterStyleActivated ); - QObject::connect ( cbxCustomDirectories->lineEdit(), &QLineEdit::editingFinished, this, &CClientSettingsDlg::OnCustomDirectoriesEditingFinished ); - - QObject::connect ( cbxCustomDirectories, - static_cast ( &QComboBox::activated ), - this, - &CClientSettingsDlg::OnCustomDirectoriesEditingFinished ); + QObject::connect ( cbxCustomDirectories->lineEdit(), &QLineEdit::editingFinished, this, [this] { + CClientSettingsDlg::OnCustomDirectoriesChanged ( false ); + } ); QObject::connect ( cbxLanguage, &CLanguageComboBox::LanguageChanged, this, &CClientSettingsDlg::OnLanguageChanged ); @@ -711,6 +710,8 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, CClientSettings* pNSet QObject::connect ( butDriverSetup, &QPushButton::clicked, this, &CClientSettingsDlg::OnDriverSetupClicked ); #endif + QObject::connect ( butDeleteCustomDirectory, &QPushButton::clicked, this, [this] { CClientSettingsDlg::OnCustomDirectoriesChanged ( true ); } ); + // misc // sliders QObject::connect ( sldAudioPan, &QSlider::valueChanged, this, &CClientSettingsDlg::OnAudioPanValueChanged ); @@ -1009,29 +1010,32 @@ void CClientSettingsDlg::OnEnableOPUS64StateChanged ( int value ) void CClientSettingsDlg::OnFeedbackDetectionChanged ( int value ) { pSettings->bEnableFeedbackDetection = value == Qt::Checked; } -void CClientSettingsDlg::OnCustomDirectoriesEditingFinished() +void CClientSettingsDlg::OnCustomDirectoriesChanged ( bool bDelete ) { - if ( cbxCustomDirectories->currentText().isEmpty() && cbxCustomDirectories->currentData().isValid() ) - { - // if the user has selected an entry in the combo box list and deleted the text in the input field, - // and then focus moves off the control without selecting a new entry, - // we delete the corresponding entry in the vector - pSettings->vstrDirectoryAddress[cbxCustomDirectories->currentData().toInt()] = ""; - } - else if ( cbxCustomDirectories->currentData().isValid() && pSettings->vstrDirectoryAddress[cbxCustomDirectories->currentData().toInt()].compare ( - NetworkUtil::FixAddress ( cbxCustomDirectories->currentText() ) ) == 0 ) + if ( bDelete ) { - // if the user has selected another entry in the combo box list without changing anything, - // there is no need to update any list - return; + if ( !cbxCustomDirectories->currentData().isValid() ) + { + // no selected directory to delete + return; + } + // delete the selected directory + pSettings->vstrDirectoryAddress[cbxCustomDirectories->currentData().toInt()] = QString(); } else { + + if ( cbxCustomDirectories->currentText().isEmpty() || + ( cbxCustomDirectories->currentData().isValid() && pSettings->vstrDirectoryAddress[cbxCustomDirectories->currentData().toInt()].compare ( + NetworkUtil::FixAddress ( cbxCustomDirectories->currentText() ) ) == 0 ) ) + { + // no need to add a already added directory + return; + } // store new address at the top of the list, if the list was already // full, the last element is thrown out pSettings->vstrDirectoryAddress.StringFiFoWithCompare ( NetworkUtil::FixAddress ( cbxCustomDirectories->currentText() ) ); } - // update combo box list and inform connect dialog about the new address UpdateDirectoryComboBox(); emit CustomDirectoriesChanged(); diff --git a/src/clientsettingsdlg.h b/src/clientsettingsdlg.h index db6fa97798..4678aeb32f 100644 --- a/src/clientsettingsdlg.h +++ b/src/clientsettingsdlg.h @@ -83,7 +83,7 @@ public slots: void OnAutoJitBufStateChanged ( int value ); void OnEnableOPUS64StateChanged ( int value ); void OnFeedbackDetectionChanged ( int value ); - void OnCustomDirectoriesEditingFinished(); + void OnCustomDirectoriesChanged ( bool bDelete ); void OnNewClientLevelEditingFinished() { pSettings->iNewClientFaderLevel = edtNewClientLevel->text().toInt(); } void OnInputBoostChanged(); void OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* button ); diff --git a/src/clientsettingsdlgbase.ui b/src/clientsettingsdlgbase.ui index 06273311e6..404ff39ecc 100644 --- a/src/clientsettingsdlgbase.ui +++ b/src/clientsettingsdlgbase.ui @@ -1039,11 +1039,43 @@ - - - true - - + + + + + true + + + + + + + + 0 + 0 + + + + + 24 + 16777215 + + + + + 75 + true + + + + + + + false + + + + @@ -1053,7 +1085,7 @@ 20 - 13 + 40 @@ -1367,6 +1399,7 @@ sldNetBufServer chbSmallNetworkBuffers cbxCustomDirectories + butDeleteCustomDirectory edtNewClientLevel cbxInputBoost chbDetectFeedback