-
Notifications
You must be signed in to change notification settings - Fork 81
Fix #448 and also allow to change a muted note to a real note #557
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e273781
Fix #448 and also allow to change a muted note to a real note
sbonaime 950a1e4
Update source/app/powertabeditor.cpp
sbonaime ba890c2
Update source/app/powertabeditor.cpp
sbonaime d6feb33
Update source/app/powertabeditor.cpp
sbonaime 020bcab
undo ba890c20fb56f429a502dbdbeb0fdb6f378ff894
sbonaime cd8db5f
Merge branch 'powertab:master' into master
sbonaime 2ca448f
Macos CMAKE CMAKE_OSX_DEPLOYMENT_TARGET
sbonaime 5524976
Match cmake formatting style
cameronwhite File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2076,9 +2076,12 @@ bool PowerTabEditor::eventFilter(QObject *object, QEvent *event) | |
| if (scorearea && event->type() == QEvent::KeyPress) | ||
| { | ||
| QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); | ||
| if (keyEvent->key() >= Qt::Key_0 && keyEvent->key() <= Qt::Key_9) | ||
| // x for a muted note | ||
| const bool isMutedKey = (keyEvent->key() == Qt::Key_X); | ||
| if ((keyEvent->key() >= Qt::Key_0 && keyEvent->key() <= Qt::Key_9) || | ||
| isMutedKey) | ||
| { | ||
| const int number = keyEvent->key() - Qt::Key_0; | ||
| const int number = isMutedKey ? 0 : (keyEvent->key() - Qt::Key_0); | ||
| ScoreLocation &location = getLocation(); | ||
|
|
||
| // Add a space if the user is attempting to add a note at the end of | ||
|
|
@@ -2093,42 +2096,75 @@ bool PowerTabEditor::eventFilter(QObject *object, QEvent *event) | |
| // unless it's the first position of the system. | ||
| if (!location.getBarline() || location.getPositionIndex() == 0) | ||
| { | ||
| // Update the existing note if possible. | ||
| if (location.getNote()) | ||
| { | ||
| myUndoManager->push(new EditTabNumber(location, number), | ||
| location.getSystemIndex()); | ||
| } | ||
| else | ||
| if (isMutedKey && !location.getNote()) | ||
| { | ||
| // Directly insert a new muted note without requiring a | ||
| // number to be entered first. | ||
| Note mutedNote(location.getString(), 0); | ||
| mutedNote.setProperty(Note::Muted); | ||
| myUndoManager->push( | ||
| new AddNote(location, | ||
| Note(location.getString(), number), | ||
| myActiveDurationType), | ||
| location.getSystemIndex()); | ||
| new AddNote(location, mutedNote, myActiveDurationType), | ||
| location.getSystemIndex()); | ||
| return true; | ||
| } | ||
|
|
||
| if (mySettingsManager->getReadHandle()->get( | ||
| Settings::PlayNotesWhileEditing)) | ||
| if (!isMutedKey) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My only comment here is that the logic is a bit tricker to follow now:
|
||
| { | ||
| const ScoreLocation &location = getLocation(); | ||
| // Generate the midi data and then transfer it to the midi | ||
| // thread. | ||
| MidiFile midi_data = MidiPlayer::generateSingleNote( | ||
| location, *mySettingsManager); | ||
| MidiPlaybackSettings initial_settings(100, | ||
| location.getScore()); | ||
|
|
||
| QMetaObject::invokeMethod( | ||
| myMidiPlayer, | ||
| [=, this, midi_data = std::move(midi_data)]() mutable { | ||
| myMidiPlayer->playSingleNote(midi_data, location, | ||
| initial_settings); | ||
| }, | ||
| Qt::QueuedConnection); | ||
| } | ||
| // Update the existing note if possible. | ||
| if (location.getNote()) | ||
| { | ||
| const Note *note = location.getNote(); | ||
| if (note->hasProperty(Note::Muted)) | ||
| { | ||
| // Remove the muted property and set the fret number | ||
| // as a single undoable action. | ||
| myUndoManager->beginMacro(tr("Edit Tab Number")); | ||
| myUndoManager->push( | ||
| new RemoveNoteProperty(location, Note::Muted, | ||
|
sbonaime marked this conversation as resolved.
|
||
| tr("Muted")), | ||
| location.getSystemIndex()); | ||
| myUndoManager->push( | ||
| new EditTabNumber(location, number), | ||
| location.getSystemIndex()); | ||
| myUndoManager->endMacro(); | ||
| } | ||
| else | ||
| { | ||
| myUndoManager->push( | ||
| new EditTabNumber(location, number), | ||
| location.getSystemIndex()); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| myUndoManager->push( | ||
| new AddNote(location, | ||
| Note(location.getString(), number), | ||
| myActiveDurationType), | ||
| location.getSystemIndex()); | ||
| } | ||
|
|
||
| return true; | ||
| if (mySettingsManager->getReadHandle()->get( | ||
| Settings::PlayNotesWhileEditing)) | ||
| { | ||
| // Generate the midi data and then transfer it to the midi | ||
| // thread. | ||
| MidiFile midi_data = MidiPlayer::generateSingleNote( | ||
| location, *mySettingsManager); | ||
| MidiPlaybackSettings initial_settings(100, | ||
| location.getScore()); | ||
|
|
||
| QMetaObject::invokeMethod( | ||
| myMidiPlayer, | ||
| [=, this, midi_data = std::move(midi_data)]() mutable { | ||
| myMidiPlayer->playSingleNote(midi_data, location, | ||
| initial_settings); | ||
| }, | ||
| Qt::QueuedConnection); | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.