Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1421: Add "delete server" button to connect dialog #3159

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/connectdlg.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ CConnectDlg::CConnectDlg ( CClientSettings* pNSetP, const bool bNewShowCompleteR
cbxServerAddr->setAccessibleName ( tr ( "Server address edit box" ) );
cbxServerAddr->setAccessibleDescription ( tr ( "Holds the current server address. It also stores old addresses in the combo box list." ) );

butDeleteServerAddr->setAccessibleName ( tr ( "Delete server address button" ) );
butDeleteServerAddr->setWhatsThis ( "<b>" + tr ( "Delete Server Address" ) + ":</b> " +
tr ( "Click the button to clear the currently selected server address "
"and delete it from the list of stored servers." ) );

UpdateDirectoryComboBox();

// init server address combo box (max MAX_NUM_SERVER_ADDR_ITEMS entries)
Expand Down Expand Up @@ -179,6 +184,9 @@ CConnectDlg::CConnectDlg ( CClientSettings* pNSetP, const bool bNewShowCompleteR

QObject::connect ( butConnect, &QPushButton::clicked, this, &CConnectDlg::OnConnectClicked );

// tool buttons
QObject::connect ( butDeleteServerAddr, &QPushButton::clicked, this, &CConnectDlg::OnDeleteServerAddrClicked );

// timers
QObject::connect ( &TimerPing, &QTimer::timeout, this, &CConnectDlg::OnTimerPing );

Expand Down Expand Up @@ -731,6 +739,31 @@ void CConnectDlg::OnConnectClicked()
done ( QDialog::Accepted );
}

void CConnectDlg::OnDeleteServerAddrClicked()
{
if ( cbxServerAddr->currentText().isEmpty() )
{
return;
}

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

// redisplay to pick up updated list
showEvent ( nullptr );
}

void CConnectDlg::OnTimerPing()
{
// send ping messages to the servers in the list
Expand Down
1 change: 1 addition & 0 deletions src/connectdlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public slots:
void OnExpandAllStateChanged ( int value ) { ShowAllMusicians ( value == Qt::Checked ); }
void OnCustomDirectoriesChanged();
void OnConnectClicked();
void OnDeleteServerAddrClicked();
void OnTimerPing();
void OnTimerReRequestServList();

Expand Down
24 changes: 24 additions & 0 deletions src/connectdlgbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,30 @@
</property>
</widget>
</item>
<item>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The button looks a bit odd on macOS
macOS connect dialog with backspace deletion button,

can you use another one, like the cancel button?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've looked through the Qt options and didn't find anything else.

Copy link
Member

@ann0see ann0see Oct 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you can't just use the same button, is cancel added differently?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, now you've lost me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The question is why we cannot use the same button design as the Cancel button there. I believe it should be visible in Qt Creator.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems as if nothing changed on macOS

Copy link
Collaborator Author

@pljones pljones Oct 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you post another screenshot, please? (Ideally with the language set to English.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ann0see if you get a chance to look at this, the screenshot would help me understand what you're seeing on MacOS.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, but it looks basically the same:
Jamulus delete button screenshot

Copy link
Collaborator Author

@pljones pljones Oct 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, at least it's centred vertically... I can try dropping the vertical max size.

       <property name="sizePolicy">
        <sizepolicy hsizetype="Maximum" vsizetype="Ignored">
         <horstretch>0</horstretch>
         <verstretch>0</verstretch>
        </sizepolicy>
       </property>
       <property name="maximumSize">
        <size>
         <width>32</width>
         <height>16777215</height>
        </size>

<sizepolicy hsizetype="Maximum" vsizetype="Ignored"> to <sizepolicy hsizetype="Maximum" vsizetype="Maximum"> and <height>16777215</height> to <height>24</height>.

(I really just want to tell it "no smaller than the glyph, fill the height of the line that's already there". But nothing I've read tells me how to do that.)

<widget class="QPushButton" name="butDeleteServerAddr">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Ignored">
<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>
Expand Down
Loading