Skip to content

Commit

Permalink
third commit to resolve jamulussoftware#3233
Browse files Browse the repository at this point in the history
I used flags to allow the use of only one function for the delete button and the list itself, I deleted a ":" in
the label (other labels didn't use ":") and I added a tabstop for the button
  • Loading branch information
AdamGLIN committed Apr 7, 2024
1 parent 37d4c74 commit 08f40dd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 50 deletions.
58 changes: 11 additions & 47 deletions src/clientsettingsdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, CClientSettings* pNSet

butDeleteCustomDirectory->setAccessibleName ( tr ( "Delete custom directory button" ) );
butDeleteCustomDirectory->setWhatsThis ( "<b>" + tr ( "Delete Custom Directory" ) + ":</b> " +
tr ( "Click the button to delete the currently selected custom directory." ) );
tr ( "Click the button to delete the currently selected custom directory." ) );

// current connection status parameter
QString strConnStats = "<b>" + tr ( "Audio Upstream Rate" ) + ":</b> " +
Expand Down Expand Up @@ -693,17 +693,9 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, CClientSettings* pNSet
this,
&CClientSettingsDlg::OnMeterStyleActivated );

QObject::connect ( cbxCustomDirectories->lineEdit(), &QLineEdit::editingFinished, this, &CClientSettingsDlg::OnCustomDirectoriesEditingFinished );

// QObject::connect ( cbxCustomDirectories->lineEdit(), &QLineEdit::returnPressed, this, &CClientSettingsDlg::OnCustomDirectoriesEditingFinished
// );

// QObject::connect ( cbxCustomDirectories,
// static_cast<void ( QComboBox::* ) ( int )> ( &QComboBox::activated ),
// this,
// &CClientSettingsDlg::OnCustomDirectoriesEditingFinished );

QObject::connect ( butDeleteCustomDirectory, &QPushButton::clicked, this, &CClientSettingsDlg::OnDeleteCustomDirectoriesClicked );
QObject::connect ( cbxCustomDirectories->lineEdit(), &QLineEdit::editingFinished, this, [this] {
CClientSettingsDlg::OnCustomDirectoriesChanged ( false );
} );

QObject::connect ( cbxLanguage, &CLanguageComboBox::LanguageChanged, this, &CClientSettingsDlg::OnLanguageChanged );

Expand All @@ -718,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 );
Expand Down Expand Up @@ -1016,49 +1010,19 @@ void CClientSettingsDlg::OnEnableOPUS64StateChanged ( int value )

void CClientSettingsDlg::OnFeedbackDetectionChanged ( int value ) { pSettings->bEnableFeedbackDetection = value == Qt::Checked; }

void CClientSettingsDlg::OnDeleteCustomDirectoriesClicked()
{
if ( cbxCustomDirectories->currentText().isEmpty() && cbxCustomDirectories->currentData().isValid() )
{
return;
}

// move later items down one
for ( int iLEIdx = 0; iLEIdx < MAX_NUM_SERVER_ADDR_ITEMS - 1; iLEIdx++ )
{
while ( pSettings->vstrDirectoryAddress[iLEIdx].compare ( NetworkUtil::FixAddress ( cbxCustomDirectories->currentText() ) ) == 0 )
{
for ( int jLEIdx = iLEIdx + 1; jLEIdx < MAX_NUM_SERVER_ADDR_ITEMS; jLEIdx++ )
{
pSettings->vstrDirectoryAddress[jLEIdx - 1] = pSettings->vstrDirectoryAddress[jLEIdx];
}
}
}
// empty last entry
pSettings->vstrDirectoryAddress[MAX_NUM_SERVER_ADDR_ITEMS - 1] = QString();

// redisplay to pick up updated list
UpdateDisplay();
UpdateDirectoryComboBox();
emit CustomDirectoriesChanged();
}

void CClientSettingsDlg::OnCustomDirectoriesEditingFinished()
void CClientSettingsDlg::OnCustomDirectoriesChanged ( bool bDelete )
{
if ( cbxCustomDirectories->currentData().isValid() && pSettings->vstrDirectoryAddress[cbxCustomDirectories->currentData().toInt()].compare (
NetworkUtil::FixAddress ( cbxCustomDirectories->currentText() ) ) == 0 )
if ( bDelete && cbxCustomDirectories->currentData().isValid() )
{
// if the user has selected another entry in the combo box list without changing anything,
// there is no need to update any list
return;
// delete the selected directory
pSettings->vstrDirectoryAddress[cbxCustomDirectories->currentData().toInt()] = QString();
}
else
else if ( !cbxCustomDirectories->currentText().isEmpty() )
{
// 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();
Expand Down
3 changes: 1 addition & 2 deletions src/clientsettingsdlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ public slots:
void OnAutoJitBufStateChanged ( int value );
void OnEnableOPUS64StateChanged ( int value );
void OnFeedbackDetectionChanged ( int value );
void OnCustomDirectoriesEditingFinished();
void OnDeleteCustomDirectoriesClicked();
void OnCustomDirectoriesChanged ( bool bDelete );
void OnNewClientLevelEditingFinished() { pSettings->iNewClientFaderLevel = edtNewClientLevel->text().toInt(); }
void OnInputBoostChanged();
void OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* button );
Expand Down
3 changes: 2 additions & 1 deletion src/clientsettingsdlgbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@
<item>
<widget class="QLabel" name="lblCustomDirectories">
<property name="text">
<string>Custom Directories:</string>
<string>Custom Directories</string>
</property>
<property name="buddy">
<cstring>cbxCustomDirectories</cstring>
Expand Down Expand Up @@ -1396,6 +1396,7 @@
<tabstop>sldNetBufServer</tabstop>
<tabstop>chbSmallNetworkBuffers</tabstop>
<tabstop>cbxCustomDirectories</tabstop>
<tabstop>butDeleteCustomDirectory</tabstop>
<tabstop>edtNewClientLevel</tabstop>
<tabstop>cbxInputBoost</tabstop>
<tabstop>chbDetectFeedback</tabstop>
Expand Down

0 comments on commit 08f40dd

Please sign in to comment.