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

[MU4] [WIP] GSoC 2020: Albums #6145

Closed
wants to merge 72 commits into from
Closed

Conversation

SKefalidis
Copy link
Contributor

@SKefalidis SKefalidis commented May 29, 2020

Resolves: Albums missing :-)

  • 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

@SKefalidis SKefalidis marked this pull request as draft May 29, 2020 10:15
@SKefalidis SKefalidis marked this pull request as ready for review May 29, 2020 10:16
libmscore/layout.cpp Outdated Show resolved Hide resolved
if (!page || curPage >= score->npages()) {
page = new Page(score);
score->pages().push_back(page);
if (!page || curPage >= dominantScore->npages()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is based on master, better to start using the new coding standard?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done :-)

// append systems to the page until you find a page break
// or run out of Movements (MasterScores)
//
// called after LayoutContext::getNextPage()
Copy link
Contributor

Choose a reason for hiding this comment

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

Good to see this kind of comments! Makes it more clear.

Copy link
Contributor

Choose a reason for hiding this comment

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

These comments are so good that you should prefix them with /// (three slashes) to expose them to Doxygen. Don't use three slashes before the function name (// collectPage) or lines with dashes (//-----------).

}
if (breakPage) {
qreal dist = qMax(prevSystem->minBottom(), prevSystem->spacerDistance(false));
dist = qMax(dist, slb);
layoutPage(page, ey - (y + dist));
// if we collected a system we cannot fit onto this page,
// we need to collect next page in order to correctly set system positions
if (collected)
if (collected) { // έχει γίνει κατάχρηση της collected
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, my Greek is not good enough to read this ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😆 the comments in Greek are my notes, they will be removed. This one says that I've abused collected.

@@ -4579,14 +4619,18 @@ void Score::doLayoutRange(const Fraction& st, const Fraction& et)
void LayoutContext::layout()
{
MeasureBase* lmb;
dominantScore = static_cast<MasterScore*>(score); // set the first score (masterscore = movement) as the dominant
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't you use toScore(score) instead of this cast?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

toScore seems to return a Score* not a MasterScore*

Copy link
Contributor

Choose a reason for hiding this comment

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

And there is no toMasterScore() (unless you add it in libmscore/scoreElement.h 😉). In general we try to prevent these kind of casts.

@@ -0,0 +1,55 @@
#include "albummanagerdialog.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

Standard header missing (copyright etc.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I will add it :-)

@@ -0,0 +1,29 @@
#ifndef ALBUMMANAGERDIALOG_H
Copy link
Contributor

Choose a reason for hiding this comment

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

Standard header missing.

mscore/file.cpp Outdated
@@ -298,7 +299,8 @@ void MuseScore::openFiles(bool switchTab, bool singleFile)
<< tr("Bagpipe Music Writer Files (experimental)") + " (*.bww)"
<< tr("Guitar Pro Files") + " (*.gtp *.gp3 *.gp4 *.gp5 *.gpx *.gp)"
<< tr("Power Tab Editor Files (experimental)") + " (*.ptb)"
<< tr("MuseScore Backup Files") + " (*.mscz, *.mscx,)";
<< tr("MuseScore Backup Files") + " (*.mscz, *.mscx,)"
<< tr("MuseScore Album Files") + " (*.msca *.album)";
Copy link
Contributor

Choose a reason for hiding this comment

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

Are both .msca and .album identical? Or is one of them a compressed file?

Copy link
Contributor Author

@SKefalidis SKefalidis May 29, 2020

Choose a reason for hiding this comment

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

.msca is the new albums file.
.album is the MuseScore2 album type.

They are same-ish, the new one has more information and is (in my opinion) more fitting. .album could be anything.

@@ -1 +1 @@
3543170
e122e7c
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this file supposed to check-in???

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ooops, I'll remove that.

Copy link
Contributor

@Jojo-Schmitz Jojo-Schmitz May 31, 2020

Choose a reason for hiding this comment

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

Better install that hook to prevent this. Check https://musescore.org/en/handbook/developers-handbook/finding-your-way-around/git-workflow#Summary step 4:

In your clone directory, copy the file build/git/hooks/post-checkout to the directory .git/hooks in order for mscore/revision.h to be maintained automatically by git. See build/git/hooks/README for details. Note that the .git directory is hidden.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I'll do that tomorrow.

Copy link
Contributor Author

@SKefalidis SKefalidis Jun 1, 2020

Choose a reason for hiding this comment

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

Done. Do I need to squash my commits for this to take effect?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I think so

<name>My Album</name>
<Score>
<alias>Piano1</alias>
<path>/home/boop/Documents/GSoC_2020/mscore/MuseScore/mtest/mscore/albums/Piano1.mscx</path>
Copy link
Contributor

Choose a reason for hiding this comment

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

Having these absolute path makes it difficult to transfer albums.
Is it planned to have albums as compressed folders, containing all scores etc., just like the mscz file is a compressed folder containing the score plus some other files?

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 am planning to have both absolute and relative paths (if one does not work, the other might save the day).

Copy link
Contributor

Choose a reason for hiding this comment

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

How about a compressed file containing all the score of the album, together with the new msca file? But that can be done after the albums itself are finalized.

@SKefalidis SKefalidis force-pushed the albums branch 2 times, most recently from 3a52d10 to e8edc65 Compare May 29, 2020 20:10
@Jojo-Schmitz
Copy link
Contributor

Once more a rebase seems needed. And the Travis fails is not fixed, see https://travis-ci.org/github/musescore/MuseScore/jobs/692713789#L3927-L3929, it is missing ui_albummanager.h

QTableWidgetItem* listItem { nullptr };
QTableWidgetItem* listDurationItem { nullptr };
QTableWidgetItem* listItem { nullptr }; // αυτά δεν πρεπει να ειναι εδω
QTableWidgetItem* listDurationItem { nullptr }; // και αυτο
Copy link
Contributor

@Jojo-Schmitz Jojo-Schmitz May 31, 2020

Choose a reason for hiding this comment

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

While I can understand that this a) is Work In Progress and b) Greek is your native language and as such more comfortable to you, I'd still prefer comments in English, as soon as it gets published here on GitHub

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 will take care of that tomorrow :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented Jun 1, 2020

Now there are linker errors and some compiler warnings too on AppVeyor and mtest fails on Travis

@Jojo-Schmitz
Copy link
Contributor

rebase needed...

@SKefalidis
Copy link
Contributor Author

Rebased and updated relative file path code.

tempScore = _items.at(0)->albumItem->score->clone(); // TODO: clone breaks editing sync for the 1st movement
tempScore = _items.at(0)->albumItem->score->clone(); // clone breaks editing sync for the 1st movement
while (tempScore->systems().size() > 1) { // remove the measures of the cloned masterscore, that way editing is synced
for(auto x : tempScore->systems().last()->measures()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

space between forand (

Comment on lines 27 to 78
//---------------------------------------------------------
//---------------------------------------------------------
//
// AlbumItem
//
//---------------------------------------------------------
//---------------------------------------------------------
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need a comment chunk so large...

//---------------------------------------------------------
//   AlbumItem
//---------------------------------------------------------

is good already.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If it isn't too much of a problem, I would like to keep it like that until I the PR is ready.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK


AlbumItem::AlbumItem(Album* album)
{
this->album = album;
Copy link
Contributor

Choose a reason for hiding this comment

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

Make class variables prefixed with m_, as stated in the new code guideline. Then we don't need this-> here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, I'll take care of it

this->album = album;
}

AlbumItem::AlbumItem(Album* album, MasterScore *score, bool enabled) : AlbumItem(album)
Copy link
Contributor

Choose a reason for hiding this comment

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

It's best to take : AlbumItem(album) down a new line.

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 agree. I have ignored the line width limits in multiple places. I will take care of that in my next refactor.


AlbumItem::AlbumItem(Album* album, MasterScore *score, bool enabled) : AlbumItem(album)
{
std::cout << "New album item..." << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

Use qDebug.

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 will probably delete it when I reach an acceptable level of stability.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you use qDebug you probably won't have to delete them :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm no, final qDebugs don't need these details. So fine, you can use std::couts and delete them when they aren't needed anymore.

@SKefalidis
Copy link
Contributor Author

SKefalidis commented Jun 9, 2020

Ignore the latest commits, I am reworking them (pushed to see the changes in a better interface).

@SKefalidis SKefalidis force-pushed the albums branch 2 times, most recently from 21a84a4 to 5bc6443 Compare June 9, 2020 16:05
@SKefalidis
Copy link
Contributor Author

SKefalidis commented Jun 11, 2020

In this file I will be writing down bugs, issues and thoughts so that both you and I can see/remember what I am working on.
https://github.com/SKefalidis/MuseScore/blob/albums/albums_readme.md

Copy link
Contributor

@jthistle jthistle left a comment

Choose a reason for hiding this comment

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

Some very promising work here! I have a few comments. I've tried to keep style stuff to a minimum, but there's still a few things I thought I should pick up. But really, this is great work! Keep it up 🚀

void Album::addScore(MasterScore *score, bool enabled)
{
if (!score) {
std::cout << "There is no score to add to album..." << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

We tend to use qDebug for messages like this, which also lets us know where the message is coming from if it appears in console, iirc.

edit: although I see Howard has already mentioned this

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'll remove that soon enough.

return nullptr;
}

MasterScore* Album::removeScore(int index)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why have this return a MasterScore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No reason at all, a mistake that was causing me trouble. I'll change that.

// getDominant
//---------------------------------------------------------

MasterScore *Album::getDominant()
Copy link
Contributor

Choose a reason for hiding this comment

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

Style :)

MasterScore * -> MasterScore*

// loadFromFile
//---------------------------------------------------------

bool Ms::Album::loadFromFile(const QString &path)
Copy link
Contributor

Choose a reason for hiding this comment

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

Style, again:

const QString &path -> const QString& path

I won't mention any more things like this, because I think running uncrustify should be enough to fix it.

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 would think so too, those were from before I found out how to edit my QtCreator settings :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

And where did you find that out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Marr11317 QtCreator Menubar -> Tools -> Options -> C++, then:

  1. Select the built-in Qt style.
  2. Press Copy... (because you can't edit the built-in style.
  3. Press Edit...
  4. Go to Pointers and References.
  5. Deselect Identifier and select Type name (and maybe left const/volatile?).

virtual bool isMaster() const override { return true; }
virtual ElementType type() const override { return ElementType::SCORE; } // TODO: if I change it to MasterScore scores are not drawn in album-mode

virtual bool isMaster() const override { return true; } // TODO: should this be removed?
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO: should this be removed?

Probably not! I get 60 results across the codebase.

Copy link
Contributor Author

@SKefalidis SKefalidis Jun 18, 2020

Choose a reason for hiding this comment

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

This could be replaced by is MasterScore (and probably will be in the future if those classes are rewritten) but as of right now a MasterScore needs to have ElementType::SCORE (otherwise nothing gets drawn on the screenview). So right now toMasterScore/isMasterScore are useless.

Q_OBJECT

public:
// can I convert these to references?
Copy link
Contributor

Choose a reason for hiding this comment

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

Well, will they ever have a nullptr value as pointers? If the answer to that question is 'yes', then the answer is no, you can't convert these to references. That's simply because there's no such thing as a null reference.

break;
case QDialogButtonBox::Ok:
apply();
// intentional ??
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems so. 'OK' has the behaviour of hiding the window, whereas 'Apply' does not, by convention.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just copy pasted that (comment included) from the prefsDialog.cpp.

midi.setMinChunkSize(10);

if (!heartBeatTimer->isActive()) {
heartBeatTimer->start(20); // msec
Copy link
Contributor

Choose a reason for hiding this comment

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

Where does this magic number come from?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy-paste from Seq::setScoreView.

}

midi = MidiRenderer(cs);
midi.setMinChunkSize(10);
Copy link
Contributor

Choose a reason for hiding this comment

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

Another magic number?

<name>My Album</name>
<Score>
<alias></alias>
<path>/home/boop/Documents/GSoC_2020/mscore/MuseScore/mtest/mscore/albums/Piano1.mscx</path>
Copy link
Contributor

Choose a reason for hiding this comment

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

will /home/boop work when this is being run by Travis? I'd guess no.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, fixing the paths of the tests is on my ToDo list :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

Would be good to avoid absolute paths where possible to avoid leaking information about the user.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Especially, in this case, absolute paths would need a very smart workaround to not fail. I was thinking to give the users the ability to select whether they want both relative and absolute paths when saving/exporting.

@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented Jun 20, 2020

Travis still doesn't like it. Here it shows yellow, in progress, but really it is read, failed, and in the mtests. Several address sanitizer failures, but also other, including tst_albums

@SKefalidis
Copy link
Contributor Author

SKefalidis commented Jun 20, 2020

Travis still doesn't like it. Here it shows yellow, in progress, but really it is read, failed, and in the mtests. Several address sanitizer failures, but also other, including tst_albums

@Jojo-Schmitz

4 of the failures are basically the same problem. I've been working on that for a couple of days (I believe that I will solve this today). The tst_albums one is probably a simple fix and I will address it together with @shoogle's and @jthistle's feedback about absolute paths (works locally). The tst_tools failure is not present locally so that will be the last one that I tackle.

@SKefalidis
Copy link
Contributor Author

Only the album test remains :^)

void currentScoreChanged(int);
void itemChanged(QListWidgetItem*); // score name in list is edited
void buttonBoxClicked(QAbstractButton*);
void addClicked(bool throwaway = false);
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't have to give these throwaway parameters a name. This is valid syntax:

void addClicked(bool = false);

Doing this avoids compiler warnings that appear when you give something a name and never actually use it.

See this comment for an alterative solution using Q_UNUSED(throwaway) in the .cpp file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in the latest push.

@SKefalidis
Copy link
Contributor Author

Front-cover related code is hard-coded (for now) for demonstration purposes.

@SKefalidis
Copy link
Contributor Author

I fixed the inspector, hope I didn't break anything :-)

@jthistle
Copy link
Contributor

Some comments after having tested this: https://gist.github.com/jthistle/1cffc1393ecddd2841e1f5424340c5a6

All in all, this works very well so far! I was genuinely surprised by how functional it already is. Obviously there are bugs and problems, but that's completely normal, and you have ample time to fix them.

@@ -238,17 +241,11 @@ void AlbumManager::albumNameChanged(const QString& text)
t->setPlainText("");
} else if (t->tid() == Tid::COMPOSER) {
t->setSize(16);
t->setPlainText("Sergios - Anestis Kefalidis\nJames Thistlewood\nJoachim Schmitz");
// t->setAlign(Align::CENTER);
t->setPlainText(m_album->composers().join("\n"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure, might better be a comma separated list

} else if (t->tid() == Tid::POET) {
t->setSize(16);
// t->setAlign(Align::CENTER);
t->setPlainText(m_album->lyricists().join("\n"));
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

@igorkorsukov igorkorsukov changed the title [WIP] GSoC 2020: Albums [MU4] [WIP] GSoC 2020: Albums Feb 5, 2021
@lyrra lyrra mentioned this pull request Sep 9, 2022
@RomanPudashkin RomanPudashkin added the archived PRs that have gone stale but could potentially be revived in the future label Dec 20, 2022
@RomanPudashkin
Copy link
Contributor

Albums will be reimplemented for 4.x. This PR cannot be merged because it is based on 3.x code, which no longer exists

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
archived PRs that have gone stale but could potentially be revived in the future
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants