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

Fix #302714: make chord symbol playback settings available in Edit Style dialog #5889

Merged

Conversation

IsaacWeiss
Copy link
Contributor

@IsaacWeiss IsaacWeiss commented Mar 30, 2020

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

Screen Shot 2020-03-29 at 9 10 15 PM

As suggested by @Jojo-Schmitz in his PR #5852, this reuses voicing_select.ui from the Inspector. This creates no merge conflicts, and it will work perfectly well if merged independently, but it will look a lot nicer (as in the above screenshot) if his PR is merged first.

  • 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

@Harmoniker1
Copy link
Contributor

Harmoniker1 commented Mar 30, 2020

Tests are failing. You named the voicing widget harmonyVoicingWidget in .ui file, different than what's used in .cpp file, that's why ;-)

@IsaacWeiss
Copy link
Contributor Author

Huh, it compiled just fine on my machine. Weird. Update pushed.

@IsaacWeiss IsaacWeiss force-pushed the 302714-chord-symbol-playback-style branch from 0780eb0 to c431a3c Compare March 30, 2020 02:30
@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented Mar 30, 2020

Looks great!
Adding a horizontal spacer should improve the layout further (in line with the Formatting part of the dialog)

voicingSelectWidget->durationBox->clear();
voicingSelectWidget->durationBox->addItem(tr("Until Next Chord Symbol"), int(HDuration::UNTIL_NEXT_CHORD_SYMBOL));
voicingSelectWidget->durationBox->addItem(tr("Until End of Measure"), int(HDuration::STOP_AT_MEASURE_END));
voicingSelectWidget->durationBox->addItem(tr("Chord/Rest Duration"), int(HDuration::SEGMENT_DURATION));
Copy link
Contributor

@Jojo-Schmitz Jojo-Schmitz Mar 30, 2020

Choose a reason for hiding this comment

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

Can't you just take the strings from that ui file rather than having them here again, as duplicates?
Like replacing tr("...") with qApp->translate("VoicingSelect","..."). Would still need to be the 100% identical strings, but at least would prevent them from the need to get translated twice.
Maybe even refer to the index of those strings in that dialog rather than having the strings themselves, like voicingSelectWidget->interpretBox->itemText(i), then those won't ever go out of sync.
But maybe none of those are needed at all? Like no need for the lines 427-447 at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think they are needed, as with all the other combobox initializations just above in the same file. Without these lines, for whatever reason, the comboboxes appear empty.

Getting the index sounds like it would be ideal, but I can't seem to get it to work. Using qApp->translate() works (I'd be interested to know exactly what it does differently), so if using the index is not an option I'll switch to that.

Copy link
Contributor

Choose a reason for hiding this comment

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

It refers to translations done elsewhere (defined via context, the 1st arg)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With the index method, I could conceivably do these initializations in fewer lines by making a vector for each enum (e.g. vector<HDuration> HDurations) and then use a loop (e.g. for auto hDuration : HDurations) to add all the items.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes. Seems better anyhow, to prevent the strings from getting out of sync

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be like voicingSelectWidget->voicingBox->addItem(voicingSelectWidget->voicingBox->itemText(0), int(Voicing::AUTO));, no?

Copy link
Contributor

@Jojo-Schmitz Jojo-Schmitz Mar 30, 2020

Choose a reason for hiding this comment

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

I would guess so, yes.
Well, no. You're deleting them first
voicingSelectWidget->durationBox->clear();
The items are (or should be) there already, just not connected?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aha! Hold that thought.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I'm baffled. It appears I was mistaken earlier when I said "Without these lines, for whatever reason, the comboboxes appear empty." In fact, the comboboxes are filled automatically, but they appear empty because no option is selected. So I triedsetCurrentIndex(), but it has no effect.

Copy link
Contributor

@Jojo-Schmitz Jojo-Schmitz Mar 30, 2020

Choose a reason for hiding this comment

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

Actually these indexes (indices?) need to get set as per the current score setting.
But I guess that is what setValues() and getValue() are doing furter down?

voicingSelectWidget->voicingBox->addItem(tr("Automatic"), int(Voicing::AUTO));
voicingSelectWidget->voicingBox->addItem(tr("Root Only"), int(Voicing::ROOT_ONLY));
voicingSelectWidget->voicingBox->addItem(tr("Close"), int(Voicing::CLOSE));
voicingSelectWidget->voicingBox->addItem(tr("Drop 2"), int(Voicing::DROP_2));
Copy link
Contributor

Choose a reason for hiding this comment

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

My PR changes this to "Drop Two"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Noted, thanks


voicingSelectWidget->interpretBox->clear();
voicingSelectWidget->interpretBox->addItem(tr("Jazz"), int(0)); // two-item combobox for boolean style variant
voicingSelectWidget->interpretBox->addItem(tr("Literal"), int(1)); // true = literal
Copy link
Contributor

Choose a reason for hiding this comment

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

Why those 2 casts to int?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I started out with false and true there and wanted to be clear.

Copy link
Contributor

@Jojo-Schmitz Jojo-Schmitz Mar 30, 2020

Choose a reason for hiding this comment

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

but Jazz isn't false ;-)
0 and 1 are int already (or turned into that), so the cast seems superfluous, even more so as that method really calls for a QVariant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to @peterhieuvu it is ;-)

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yeah, Jazz and Literal should probably have been a char/boolean enum instead of true or false to improve readability

{ Sid::harmonyPlay, false, harmonyPlay, 0 },
{ Sid::harmonyVoiceLiteral, false, voicingSelectWidget->interpretBox, 0 },
{ Sid::harmonyVoicing, false, voicingSelectWidget->voicingBox, 0 },
{ Sid::harmonyDuration, false, voicingSelectWidget->durationBox, 0 },
Copy link
Contributor

@Jojo-Schmitz Jojo-Schmitz Mar 30, 2020

Choose a reason for hiding this comment

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

No reset buttons?
In Inspector at least voicingBox has a reset button
Oh, I see, that reset and set to style button applies to all 3 settings in one go

@IsaacWeiss
Copy link
Contributor Author

So, to recap: this PR tries to reuse an external widget, which is more than can be said for most of the Style dialog. Trying to use the strings provided in that widget I encounter problems of one kind or another (the closest I got was having the comboboxes appear empty with no option selected, and adding setCurrentIndex(0) had no effect at all). Filling the comboboxes afresh, as in the currently committed code, works beautifully, but it seems like it should be unnecessary. I suspect there is a way to reuse the widget in its entirety, but it has escaped me so far. Review from maintainers would be appreciated.

@Jojo-Schmitz
Copy link
Contributor

Rebase needed
Maybe rebase to 3.x branch or even separate versions for.3.x and master

@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented Aug 13, 2020

@IsaacWeiss this still needs a rebase and a 3.x version

@IsaacWeiss IsaacWeiss changed the base branch from master to 3.x August 13, 2020 14:51
@IsaacWeiss IsaacWeiss force-pushed the 302714-chord-symbol-playback-style branch from c431a3c to fec330b Compare August 13, 2020 17:29
@IsaacWeiss
Copy link
Contributor Author

This has been rebased against 3.x and passed all tests. @anatoly-os mentioned on Telegram that he could merge changes from 3.x to master, but that might be difficult with the UI file, so I am happy to take care of that with a second PR if necessary. In resolving changes to editstyle.ui I noticed a whole section of style settings in 3.x currently missing in master, with measure number position above and below. Did this fall through the cracks or is the difference on purpose?

@Jojo-Schmitz
Copy link
Contributor

It is because #6208 hasn't yet been merged to master I guess

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.

None yet

5 participants