jamulus icon indicating copy to clipboard operation
jamulus copied to clipboard

#3233 UI: Common method to delete server and custom directory entries

Open AdamGLIN opened this issue 1 year ago • 8 comments

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.

Short description of changes

CHANGELOG: UI: Add "Delete Entry" button to Advanced Settings, Custom Directories

Context: Fixes an issue?

#3233

Does this change need documentation? What needs to be documented and how?

Status of this Pull Request

What is missing until this pull request can be merged?

Checklist

  • [x] I've verified that this Pull Request follows the general code principles
  • [x] I tested my code and it does what I want
  • [x] My code follows the style guide
  • [x] I waited some time after this Pull Request was opened and all GitHub checks completed without errors.
  • [x] I've filled all the content above

AdamGLIN avatar Apr 03 '24 21:04 AdamGLIN

Thanks for opening this PR. It's a draft/WIP so it needs discussion. @pljones Should be most familiar with this.

ann0see avatar Apr 03 '24 21:04 ann0see

Could you please also post your questions here? Best right in the code tab close to where the question arises.

ann0see avatar Apr 03 '24 21:04 ann0see

Hello,

It works for the main part, I mostly followed this commit.

However, I have some issues :

  • I can't figure out why the QLineEdit::editingFinished signal that we use to notify the changes, don't seems to work when I press the enter key (I read that it was supposed to). (src/clientsettingsdlg.cpp, line ~700)
  • I don't understand the use of the QComboBox::activated signal since I commented it and it changed nothing. Also I read that the signal was sent when the user clicks on an item of the list and I think that it was not a interesting behavior for this feature because the order doesn't matter. Tell me if I'm wrong. (src/clientsettingsdlg, line ~700)
  • I found out that we use the StringFiFoWithCompare method (src/util.h, line ~170) to update the list without repetition (I think) for both directories and server address lists (src/clientsettingsdlg, line ~1060). However, there is a loop introduced in this commit (src/connectdlg.cpp, line ~750) to avoid repetition, and hence it is useless. For the first change I decided just to copy the loop and not think to much about it. What do you think about it ? Did I miss something ?

I have still things to improve such as the interface (boxes are not equally spaced), but I would like your opinion to continue this way !

Thanks for your time !

AdamGLIN avatar Apr 03 '24 21:04 AdamGLIN

Thanks Adam! I started to look at your commit and questions earlier today, but got diverted onto other things. I will have a look soon, hopefully tomorrow!

softins avatar Apr 03 '24 22:04 softins

Looks good to me, now. I've kicked off the build.

Thanks for all the time you've spent on this! :)

pljones avatar Apr 16 '24 17:04 pljones

Thank you for your patience and your advices :)

AdamGLIN avatar Apr 17 '24 07:04 AdamGLIN

Just tried the Windows version from the build artifacts and it looks okay to me.

pljones avatar Apr 17 '24 16:04 pljones

This needs some squashing and rebasing, I believe. I'll look into it once I have time.

ann0see avatar Apr 17 '24 21:04 ann0see

I prefer everything neat and tidy, so if you could rebase and squash (happy to do it, too).

pljones avatar Jun 11 '24 15:06 pljones

OK, I'll rebase it onto main, which now has the Mac legacy Qt update, let it build, and then check it on my Mac.

softins avatar Jun 11 '24 16:06 softins

Yep Qt on MacOS certainly seems to come with its own UI layout peculiarities that aren't present on other platforms.

The action/focus trigger for updating the list has also been a bit hard to pin down: it works right sometimes on both Windows and Linux for me. It also works wrong sometimes, too... Or has done (it's a while since I ran Qt5 - it might be fixed in Linux/Windows Qt6).

(I'm thinking of getting the Android to Qt6 work done - to see if it helps with the other Android issues we have open. I tried it over the weekend and it mostly looks like permissions stuff... but that doesn't look trivial to fix.)

pljones avatar Jun 12 '24 08:06 pljones

I fixed the issue with Enter. The problem was that pressing Enter within the combi box was causing a button push to delete, because the default setting for autoDefault appears to be true. Having set autoDefault explicitly to false for the delete button in clientsettingsdlgbase.ui, the Enter key works correctly for just finishing editing.

Will investigate the button appearance on Mac later.

softins avatar Jun 12 '24 09:06 softins

For the delete buttons, I needed to change the horizontal size policy from "Maximum" to "Fixed", so that the buttons were definitely wide enough, but not allowed to grow. Need to check they are ok on all platforms.

softins avatar Jun 13 '24 12:06 softins

I've tried the latest build above on Mac Legacy, Windows and Pi Linux. Not current Mac though.

The button width is now fine on Mac Legacy, but it's a bit wider than ideal on Windows and Linux. Must be scaling differences. It may be acceptable, but if not, we would need to add code to adjust the width of those buttons at runtime for Mac only. Thoughts?

softins avatar Jun 13 '24 13:06 softins

Maybe set the size policy to maximum only for Mac if that's where it's needed? (Quite why Qt can't get their cross-platform UI toolkit to work for something you'd have though to be pretty obvious like that, I have no idea. Qt's meant to hide those kinds of differences...)

pljones avatar Jun 13 '24 15:06 pljones

Maybe set the size policy to maximum only for Mac if that's where it's needed?

It's the other way around. It was previously maximum only, but that allows the button to be shrunk as much as needed. But on Mac from 5.12 on, the button was shrinking right down. My guess is that it couldn't correctly calculate the size of the contained text when it was just a Unicode character for backspace, so took the text width as 0. I found I needed to specify Fixed so that both maximum and minimum were constrained.

Either way, to fix it we would need to add conditional runtime code for Mac only, as there is no way to put architecture conditionals in a .ui file. The question is, is it worth doing?

I have wondered whether it might be worth putting an image in the button instead of a Unicode character? e.g. a wastebasket or trashcan?

softins avatar Jun 13 '24 19:06 softins

A further thought: maybe merge this PR without the button width fix, since that applies to both the settings and connect dialogs? The connect dialog is arguably outside the scope of this PR. Then raise a separate PR to fix #3241 in both places for Mac?

softins avatar Jun 13 '24 19:06 softins

OK by me.

So, dropping the third commit...

pljones avatar Jun 14 '24 15:06 pljones

Ok. So this also needs new screenshots for the docs potentially.

ann0see avatar Jun 20 '24 18:06 ann0see

Linux: image

Windows: image

Translations, too? There's new "What's This?" text, IIRC.

pljones avatar Jun 21 '24 17:06 pljones

Yes. But that should show up automatically

ann0see avatar Jun 21 '24 19:06 ann0see

https://github.com/jamulussoftware/jamuluswebsite/issues/1002 raised for documentation.

pljones avatar Aug 04 '24 09:08 pljones