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

[MU3] Fix #313195: enable the synalepha shortcut in lyrics edit mode #7105

Merged
merged 1 commit into from
Dec 19, 2020

Conversation

Asmatzaile
Copy link
Contributor

@Asmatzaile Asmatzaile commented Dec 16, 2020

Resolves: https://musescore.org/en/node/313195

Having PR #6928 been merged for 3.6 Beta, I tried using the introduced shortcut and it failed.
I think that this PR solves that problem, because the needed key wasn't Qt::Key_hyphen but Qt::Key_Minus.
Although I yet don't know how to use cmake properly and get errors when trying to compile, I'll test the artifacts when they are generated.
This will conflict with #7099, so maybe a rebase will be needed (would that be done with git checkout <my-branch-name> and git rebase 3.x?).
editlyrics.cpp was also changed because, as it was, pressing ctrl ignored the commands from textedit.cpp

  • I signed CLA
  • I made sure the code in the PR follows the coding rules
  • I made sure the code compiles on my machine
  • I made sure there are no unnecessary changes in the code
  • I made sure the title of the PR reflects the core meaning of the issue you are solving
  • I made sure the commit message(s) contain a description and answer the question "Why do those changes fix that particular issue?" or "Why are those changes really necessary as improvements?"
  • I made sure the commit message title starts with "fix #424242:" if there is a related issue
  • I created the test (mtest, vtest, script test) to verify the changes I made

@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented Dec 16, 2020

It should not conflict with #7099, it changes code at a sufficientlly different spot (the diffs don't overlap).

Once you got it working, please make sure to also submit a PR for master (or just let me know and I'll add it to my #7100)

@Asmatzaile
Copy link
Contributor Author

It should not conflict with #7099, it changes code at a sufficientlly different spot (the diffs don't overlap).

Once you got it working, please make sure to also submit a PR for master

Oh, that's nice. Will do!

@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented Dec 16, 2020

Also make sure to have your commit title starting with "Fix #313195: " (as I've just reopened that issue as it is not fixed)

Copy link
Contributor

@Jojo-Schmitz Jojo-Schmitz left a comment

Choose a reason for hiding this comment

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

This code change does work for me, prior it did not.

@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented Dec 16, 2020

Actually I've just added it to #7100 now (so for master)

@Asmatzaile Asmatzaile force-pushed the synalepha-shortcut-fix branch from 5299cf3 to d299b67 Compare December 16, 2020 17:13
@Asmatzaile
Copy link
Contributor Author

Asmatzaile commented Dec 16, 2020

Unfortunately, although now the shortcut does work in text edit mode, it doesn't in lyrics edit mode, where it would be most helpful. Anyway, it's a step forward towards the solution...

@Jojo-Schmitz
Copy link
Contributor

Oh, darn, I guess in lyrics mode the Ctrl - is used differently and the added Alt doesn't change that

@Jojo-Schmitz
Copy link
Contributor

It might help if you'd join the Developers' chat on Telegram https://t.me/musescoreeditorchat

@Asmatzaile
Copy link
Contributor Author

Oh, darn, I guess in lyrics mode the Ctrl - is used differently and the added Alt doesn't change that

Ahhh... So I suppose I should find where the code for adding this symbol (-) is and add a conditional statement or something like that

@Asmatzaile Asmatzaile force-pushed the synalepha-shortcut-fix branch from 20a2160 to d299b67 Compare December 16, 2020 17:40
@Asmatzaile Asmatzaile marked this pull request as draft December 16, 2020 17:40
@Asmatzaile
Copy link
Contributor Author

Asmatzaile commented Dec 16, 2020

Maybe, in editlyrics.cpp, line 87...

case Qt::Key_Minus: if (Qt::ControlModifier & Qt::AltModifier) { insertSym(ed, SymId::lyricsElision); return true; } else if (editData.control(textEditing)) { // change into normal minus editData.modifiers &= ~CONTROL_MODIFIER; return false; } else lyricsMinus(); break;

but insertSym and ed should be defined/declarated/whatever

@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented Dec 16, 2020

rather line 67
Instead if ed use editData, for insertSym() you need #include "libmscore/textbase.h", but is a protected member of that class.

@Asmatzaile
Copy link
Contributor Author

Asmatzaile commented Dec 16, 2020

rather line 67
Instead if ed use editData, for insertSym() you need #include "libmscore/textbase.h", but is a protected member of that class.

What does that mean? Should I move insertSym() to public?

@Asmatzaile Asmatzaile force-pushed the synalepha-shortcut-fix branch from 5dc3484 to b58d717 Compare December 16, 2020 19:29
editData.modifiers &= ~CONTROL_MODIFIER;
return false;
}
if (Qt::ControlModifier & Qt::AltModifier) {
Copy link
Contributor

@Jojo-Schmitz Jojo-Schmitz Dec 16, 2020

Choose a reason for hiding this comment

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

rather if (editDate.modifier & Qt::ControlModifier & Qt::AltModifier) I think
Or if ( editData.control(textEditing) && (editDate.modifier & Qt::AltModifier))

@Asmatzaile Asmatzaile force-pushed the synalepha-shortcut-fix branch 2 times, most recently from 050cb28 to 42547f8 Compare December 16, 2020 22:11
@Asmatzaile Asmatzaile changed the title Fix for synalepha shortcut [MU3] Fix for synalepha shortcut Dec 16, 2020
@Asmatzaile Asmatzaile changed the title [MU3] Fix for synalepha shortcut [MU3] Fix #313195: enable the synalepha shortcut in lyrics edit mode Dec 16, 2020
@Asmatzaile
Copy link
Contributor Author

Asmatzaile commented Dec 16, 2020

In function Ms::ScoreView::editKeyLyrics(): /home/runner/work/MuseScore/MuseScore/mscore/editlyrics.cpp:72: undefined reference to Ms::insertSym(Ms::EditData&, Ms::MSQE_SymId::SymId)

@@ -30,6 +31,8 @@ bool ScoreView::editKeyLyrics()
{
Q_ASSERT(editData.element->isLyrics());

void insertSym(EditData& ed, SymId id);
Copy link
Contributor

Choose a reason for hiding this comment

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

Adding the prototype here doesn't make a protected member visible to a foreign class

@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented Dec 17, 2020

How about just this:

diff --git a/libmscore/textedit.cpp b/libmscore/textedit.cpp
index 03e01d43e..dc7522c06 100644
--- a/libmscore/textedit.cpp
+++ b/libmscore/textedit.cpp
@@ -458,7 +458,7 @@ bool TextBase::edit(EditData& ed)
                         }
                   }
             if (ctrlPressed && altPressed) {
-                  if (ed.key == Qt::Key_hyphen) {
+                  if (ed.key == Qt::Key_Minus) {
                         insertSym(ed, SymId::lyricsElision);
                         return true;
                         }
diff --git a/mscore/editlyrics.cpp b/mscore/editlyrics.cpp
index c7b951ddf..0f4e247a1 100644
--- a/mscore/editlyrics.cpp
+++ b/mscore/editlyrics.cpp
@@ -66,6 +66,8 @@ bool ScoreView::editKeyLyrics()

             case Qt::Key_Minus:
                   if (editData.control(textEditing)) {
+                        if ((editData.modifiers & Qt::AltModifier) && editData.element->edit(editData))
+                              break;
                         // change into normal minus
                         editData.modifiers &= ~CONTROL_MODIFIER;
                         return false;

Seems to work just fine and doesn't need a protected method to get made public and avoids code duplication. win-win-win ;-)

@Asmatzaile Asmatzaile force-pushed the synalepha-shortcut-fix branch from db18795 to 9bcd3a9 Compare December 17, 2020 10:31
@Asmatzaile
Copy link
Contributor Author

How about just this:
[...]
Seems to work just fine and doesn't need a protected method to get made public and avoids code duplication. win-win-win ;-)

Yes! It works! Many thanks Jojo :))

@Asmatzaile Asmatzaile marked this pull request as ready for review December 17, 2020 10:54
@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented Dec 17, 2020

Actually better add a _score->update(); before that break; (and add the braces)

@Asmatzaile
Copy link
Contributor Author

Asmatzaile commented Dec 17, 2020

Actually better add a _score->update(); before that break; (and add the braces)

Should the ending brace be before or after the break:?
Also at line 54 the if statement that includes a _score->update(): doesn't have any braces

@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented Dec 17, 2020

                        if ((editData.modifiers & Qt::AltModifier) && editData.element->edit(editData)) {
                              _score->update();
                              break;
                              }

In line 54 it is the only statement in the block, so the braces are not strictly needed (they are for master though, required by the new coding style)

@Jojo-Schmitz
Copy link
Contributor

The mtest failures seem to not be your fault...

@Asmatzaile Asmatzaile force-pushed the synalepha-shortcut-fix branch from 6f7d65e to 2da6cc4 Compare December 17, 2020 11:11
@vpereverzev vpereverzev merged commit 1a8433b into musescore:3.x Dec 19, 2020
@Asmatzaile Asmatzaile deleted the synalepha-shortcut-fix branch December 19, 2020 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants