Skip to content

Commit

Permalink
first commit to resolve the issue jamulussoftware#3233
Browse files Browse the repository at this point in the history
I added a horizontal box layout which include the box and the delete button. I wrote a fonction to implement the delete button.

It works well when we change the focus with the mouse to add a new directory but I can't make the enter key work : it delete the input and nothing happend.
I tried to add the QLineEdit::returnPressed signal but it changed nothing.
I struggle to understand the former use of the QComboBox::activated signal since I commented it and nothing seems to have changed.

TODO :
Allowing to add directory via enter key.
Improve spacers in the ui.
  • Loading branch information
AdamGLIN committed Apr 3, 2024
1 parent e12cb71 commit 2780a48
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 15 deletions.
57 changes: 42 additions & 15 deletions src/clientsettingsdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,14 +360,17 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, CClientSettings* pNSet
// custom directories
QString strCustomDirectories = "<b>" + tr ( "Custom Directories" ) + ":</b> " +
tr ( "If you need to add additional directories to the Connect dialog Directory drop down, "
"you can enter the addresses here.<br>"
"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.<br>" );

lblCustomDirectories->setWhatsThis ( strCustomDirectories );
cbxCustomDirectories->setWhatsThis ( strCustomDirectories );
cbxCustomDirectories->setAccessibleName ( tr ( "Custom Directories combo box" ) );

butDeleteCustomDirectories->setAccessibleName ( tr ( "Delete custom directory button" ) );
butDeleteCustomDirectories->setWhatsThis ( "<b>" + tr ( "Delete Custom Directory" ) + ":</b> " +
tr ( "Click the button to clear the currently selected custom directory "
"and delete it from the list of stored custom directories." ) );

// current connection status parameter
QString strConnStats = "<b>" + tr ( "Audio Upstream Rate" ) + ":</b> " +
tr ( "Depends on the current audio packet size and "
Expand Down Expand Up @@ -691,12 +694,16 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, CClientSettings* pNSet
this,
&CClientSettingsDlg::OnMeterStyleActivated );

QObject::connect ( butDeleteCustomDirectories, &QPushButton::clicked, this, &CClientSettingsDlg::OnDeleteCustomDirectoriesClicked );

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

QObject::connect ( cbxCustomDirectories,
static_cast<void ( QComboBox::* ) ( int )> ( &QComboBox::activated ),
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 ( cbxLanguage, &CLanguageComboBox::LanguageChanged, this, &CClientSettingsDlg::OnLanguageChanged );

Expand Down Expand Up @@ -1009,17 +1016,37 @@ void CClientSettingsDlg::OnEnableOPUS64StateChanged ( int value )

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

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

// move later items down one
for ( int iLEIdx = 0; iLEIdx < MAX_NUM_SERVER_ADDR_ITEMS - 1; iLEIdx++ )
{
// 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()] = "";
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];
}
}
}
else if ( cbxCustomDirectories->currentData().isValid() && pSettings->vstrDirectoryAddress[cbxCustomDirectories->currentData().toInt()].compare (
NetworkUtil::FixAddress ( cbxCustomDirectories->currentText() ) ) == 0 )
// 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()
{
if ( cbxCustomDirectories->currentData().isValid() && pSettings->vstrDirectoryAddress[cbxCustomDirectories->currentData().toInt()].compare (
NetworkUtil::FixAddress ( cbxCustomDirectories->currentText() ) ) == 0 )
{
// if the user has selected another entry in the combo box list without changing anything,
// there is no need to update any list
Expand Down
1 change: 1 addition & 0 deletions src/clientsettingsdlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public slots:
void OnEnableOPUS64StateChanged ( int value );
void OnFeedbackDetectionChanged ( int value );
void OnCustomDirectoriesEditingFinished();
void OnDeleteCustomDirectoriesClicked();
void OnNewClientLevelEditingFinished() { pSettings->iNewClientFaderLevel = edtNewClientLevel->text().toInt(); }
void OnInputBoostChanged();
void OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* button );
Expand Down
28 changes: 28 additions & 0 deletions src/clientsettingsdlgbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1038,13 +1038,41 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QComboBox" name="cbxCustomDirectories">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="butDeleteCustomDirectories">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">⌫</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
Expand Down

0 comments on commit 2780a48

Please sign in to comment.