-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Keyboard shortcuts to preview/add sounds from sidebar #5427
Conversation
🤖 Hey, I'm @LmmsBot from github.com/lmms/bot and I made downloads for this pull request, click me to make them magically appear! 🎩
Linux
Windows
macOS🤖{"platform_name_to_artifacts": {"Linux": [{"artifact": {"title": {"title": "(AppImage)", "platform_name": "Linux"}, "link": {"link": "https://9239-15778896-gh.circle-artifacts.com/0/lmms-1.2.3-736%2Bgebe30f8-linux-x86_64.AppImage"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/9239?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}], "Windows": [{"artifact": {"title": {"title": "32-bit", "platform_name": "Windows"}, "link": {"link": "https://9240-15778896-gh.circle-artifacts.com/0/lmms-1.2.3-736%2Bgebe30f88f-mingw-win32.exe"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/9240?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}, {"artifact": {"title": {"title": "64-bit", "platform_name": "Windows"}, "link": {"link": "https://9242-15778896-gh.circle-artifacts.com/0/lmms-1.2.3-736%2Bgebe30f88f-mingw-win64.exe"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/9242?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}, {"artifact": {"title": {"title": "32-bit", "platform_name": "Windows"}, "link": {"link": "https://ci.appveyor.com/api/buildjobs/rm3ukilko9fvn74l/artifacts/build/lmms-1.2.2-msvc2017-win32.exe"}}, "build_link": "https://ci.appveyor.com/project/Lukas-W/lmms/builds/35551388"}, {"artifact": {"title": {"title": "64-bit", "platform_name": "Windows"}, "link": {"link": "https://ci.appveyor.com/api/buildjobs/f5fudlp3mrbvncep/artifacts/build/lmms-1.2.2-msvc2017-win64.exe"}}, "build_link": "https://ci.appveyor.com/project/Lukas-W/lmms/builds/35551388"}], "macOS": [{"artifact": {"title": {"title": "", "platform_name": "macOS"}, "link": {"link": "https://9243-15778896-gh.circle-artifacts.com/0/lmms-1.2.3-736%2Bgebe30f88f-mac10.13.dmg"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/9243?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}]}, "commit_sha": "9d60c0ea58f99493b255d9a5e3232281b755a581"} |
7aab491
to
e0e1f1c
Compare
IMHO this should close #5671. The proposal there isn't an improvement as far as I'm concerned, and with this merged it makes even less sense. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The nullptr
comment scopes across the whole review.
FYI, CircleCI mac failure looks unrelated (it fails to fetch homebrew). |
The latest commit is a bit of a shot in the dark, the overhead from locking/unlocking more often and changing
If this commit works, I'll add comments clarifying that access to |
Testing doesn't reveal any apparent difference, which isn't surprising. In hindsight it's pretty obvious that making the preview lock in FileBrowser available slightly faster wouldn't help, but it was an easy thing to check. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding m_pphMutex
, couldn't it be removed altogether? From what I can tell, it's only ever locked from the UI thread, so there's nothing for it to protect against.
My understanding is that it prevents several calls created via UI input from interfering with each other. Is this not necessary? For example, if you very quickly tap the spacebar, couldn't this happen without locks?
Also, as far as I can tell C++ makes no guarantees that a variable is in a valid state when read in unsynchronized code. Isn't this alone a good reason to avoid concurrent access? |
Ah wait, you mean that all the modifications to the play handle originate from UI events and thus run on the UI thread, so there's no concurrency happening. That makes sense, but to me it raises the issue that perhaps some of this work should actually happen outside the UI thread. |
True - it would definitely be nice to load samples (and presets too, I guess) asynchronously. Let's leave it in for now. |
Thanks for the review, @DomClark! Recent commits should address the issues you brought up. I also tried replacing the preview mutex with a QThreadPool, but
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only other thing I see is no whitespace between parenthesis and curly brace in if (){ .. }
.
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recall somewhere about having 4 newlines between functions, but I don't know if we care to keep doing that? I say because this hunk is unrelated to PR, and more a formatting update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to keep FileBrowserTreeWidget's spacing a bit more consistent since it varied before, but I can undo this if you'd like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, I don't like the four newlines. (I'm generally in favour of anything that uses less vertical space.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also prefer a single newline between functions of the same class, but I've generally stuck with four in order to have some semblance of consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah - I don't think it should be changed here, but it might be a candidate for the reformatting if others agree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be a thing for the clang-tidy/format PR.
Thanks for the review @Veratil! I've fixed the event handler visibility and spacing in if statements, and also fixed some inconsistent spacing between FileBrowserTreeWidget's methods. I can revert the spacing changes if you'd like, but figured if they're going to be there they should be consistent. |
Any objections to me merging this? There are technically no approving reviews, I suppose, but I've fixed the issues brought up in review and no one has mentioned new ones so far. |
{ | ||
s->setDoneMayReturnTrue( true ); | ||
m_previewPlayHandle = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this removed line(m_previewPlayHandle = NULL;
) is the key of #5736. Mixer
will cleanup the play handle later, and we won't stop previewing in this case.
- Extract file item preview start and end into new methods `previewFileItem` and `stopPreview`. - Add event handlers: - `keyPressEvent` to allow auto preview (on up/down arrow navigation), manual preview (space), and send to editors (enter) - `keyReleaseEvent` to end previews when preview key is released - `hideEvent` to end previews when switching sidebar tab or hiding sidebar - Functions that operate on a `FileItem` now take it as an argument instead of using a member variable - `getContextActions` provides menu items for sending clips to the song editor and BB editor with minimal duplicate code - Some formatting changes in affected code - Replace many instances of `NULL` with `nullptr`
Now ready for testing and review
The file browser now behaves as follows:
Todo:Sustained presets shouldn't play indefinitely. Only play presets while left arrow held?DoneShift + right arrow to add a sample to a new (empty) sample track in song editorDoneCtrl + shift + right arrow to add a sample to a new (empty) sample track in BB editorNot feasible, nor particularly useful.Code quality is iffy at best right now, among other things I did some questionable refactoring in the context menu code.The commit "DRY up code and ..." vastly improves this