fix 40241: Recent scores menu doesn't show imported files
This commit is contained in:
parent
e835aa54f1
commit
c87cfae38c
6 changed files with 23 additions and 27 deletions
|
@ -550,7 +550,7 @@ QString Page::replaceTextMacros(const QString& s) const
|
|||
d += _score->rootScore()->name();
|
||||
break;
|
||||
case 'F':
|
||||
d += _score->rootScore()->absoluteFilePath();
|
||||
d += _score->rootScore()->fileInfo()->absoluteFilePath();
|
||||
break;
|
||||
case 'd':
|
||||
d += QDate::currentDate().toString(Qt::DefaultLocaleShortDate);
|
||||
|
|
|
@ -666,10 +666,7 @@ class Score : public QObject {
|
|||
int fileDivision(int t) const { return (t * MScore::division + _fileDivision/2) / _fileDivision; }
|
||||
bool saveFile();
|
||||
|
||||
QString filePath() const { return info.filePath(); }
|
||||
QString absoluteFilePath() const { return info.absoluteFilePath(); }
|
||||
QFileInfo* fileInfo() { return &info; }
|
||||
|
||||
QString name() const { return info.completeBaseName(); }
|
||||
void setName(QString s);
|
||||
|
||||
|
|
|
@ -1244,7 +1244,7 @@ void Score::print(QPainter* painter, int pageNo)
|
|||
|
||||
QByteArray Score::readCompressedToBuffer()
|
||||
{
|
||||
MQZipReader uz(filePath());
|
||||
MQZipReader uz(info.filePath());
|
||||
if (!uz.exists()) {
|
||||
qDebug("Score::readCompressedToBuffer: cannot read zip file");
|
||||
return QByteArray();
|
||||
|
@ -1261,7 +1261,7 @@ QByteArray Score::readCompressedToBuffer()
|
|||
}
|
||||
|
||||
if (rootfile.isEmpty()) {
|
||||
qDebug("=can't find rootfile in: %s", qPrintable(filePath()));
|
||||
qDebug("=can't find rootfile in: %s", qPrintable(info.filePath()));
|
||||
return QByteArray();
|
||||
}
|
||||
return uz.fileData(rootfile);
|
||||
|
@ -1280,7 +1280,7 @@ QByteArray Score::readToBuffer()
|
|||
ba = readCompressedToBuffer();
|
||||
}
|
||||
if (cs.toLower() == "msc" || cs.toLower() == "mscx") {
|
||||
QFile f(filePath());
|
||||
QFile f(info.filePath());
|
||||
if (f.open(QIODevice::ReadOnly)) {
|
||||
ba = f.readAll();
|
||||
f.close();
|
||||
|
|
|
@ -294,7 +294,6 @@ Score* MuseScore::openScore(const QString& fn)
|
|||
Score* score = readScore(fn);
|
||||
if (score) {
|
||||
setCurrentScoreView(appendScore(score));
|
||||
updateRecentScores(score);
|
||||
writeSessionFile(false);
|
||||
}
|
||||
return score;
|
||||
|
@ -329,6 +328,7 @@ Score* MuseScore::readScore(const QString& name)
|
|||
score = 0;
|
||||
}
|
||||
allowShowMidiPanel(name);
|
||||
addRecentScore(score);
|
||||
return score;
|
||||
}
|
||||
|
||||
|
@ -391,7 +391,7 @@ bool MuseScore::saveFile(Score* score)
|
|||
QMessageBox::critical(mscore, tr("MuseScore: Save File"), MScore::lastError);
|
||||
return false;
|
||||
}
|
||||
updateRecentScores(score);
|
||||
addRecentScore(score);
|
||||
score->setCreated(false);
|
||||
writeSessionFile(false);
|
||||
}
|
||||
|
@ -1726,7 +1726,7 @@ bool MuseScore::saveAs(Score* cs, bool saveCopy, const QString& path, const QStr
|
|||
rv = true;
|
||||
// store new file and path into score fileInfo
|
||||
// to have it accessible to resources
|
||||
QString originalScoreFName(cs->absoluteFilePath());
|
||||
QString originalScoreFName(cs->fileInfo()->canonicalFilePath());
|
||||
cs->fileInfo()->setFile(fn);
|
||||
try {
|
||||
if (ext == "mscz")
|
||||
|
@ -1746,7 +1746,7 @@ bool MuseScore::saveAs(Score* cs, bool saveCopy, const QString& path, const QStr
|
|||
cs->undo()->setClean();
|
||||
dirtyChanged(cs);
|
||||
cs->setCreated(false);
|
||||
updateRecentScores(cs);
|
||||
addRecentScore(cs);
|
||||
writeSessionFile(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1106,10 +1106,10 @@ void MuseScore::selectScore(QAction* action)
|
|||
_recentScores.clear();
|
||||
}
|
||||
else {
|
||||
Score* score = readScore(a);
|
||||
Score* score = readScore(a);
|
||||
if (score) {
|
||||
setCurrentScoreView(appendScore(score));
|
||||
updateRecentScores(score);
|
||||
addRecentScore(score);
|
||||
writeSessionFile(false);
|
||||
}
|
||||
}
|
||||
|
@ -1165,7 +1165,7 @@ int MuseScore::appendScore(Score* score)
|
|||
for (int i = 0; i < scoreList.size(); ++i) {
|
||||
if ((!score->importedFilePath().isEmpty()
|
||||
&& scoreList[i]->importedFilePath() == score->importedFilePath())
|
||||
|| (scoreList[i]->filePath() == score->filePath() && score->fileInfo()->exists())) {
|
||||
|| (scoreList[i]->fileInfo()->canonicalFilePath() == score->fileInfo()->canonicalFilePath() && score->fileInfo()->exists())) {
|
||||
removeTab(i);
|
||||
index = i;
|
||||
break;
|
||||
|
@ -1185,30 +1185,27 @@ int MuseScore::appendScore(Score* score)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// updateRecentScores
|
||||
// addRecentScore
|
||||
//---------------------------------------------------------
|
||||
|
||||
void MuseScore::updateRecentScores(Score* score)
|
||||
void MuseScore::addRecentScore(Score* score)
|
||||
{
|
||||
QString path = score->importedFilePath(); // defined for scores imported from e.g. MIDI files
|
||||
addRecentScore(path);
|
||||
path = score->fileInfo()->canonicalFilePath();
|
||||
addRecentScore(path);
|
||||
if (startcenter)
|
||||
startcenter->updateRecentScores();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// addRecentScore
|
||||
//---------------------------------------------------------
|
||||
void MuseScore::addRecentScore(const QString& scorePath)
|
||||
{
|
||||
if (scorePath.isEmpty() || _recentScores.first() == scorePath)
|
||||
if (scorePath.isEmpty())
|
||||
return;
|
||||
_recentScores.removeAll(scorePath);
|
||||
_recentScores.prepend(scorePath);
|
||||
if (_recentScores.size() > RECENT_LIST_SIZE)
|
||||
_recentScores.removeLast();
|
||||
if (startcenter)
|
||||
startcenter->updateRecentScores();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -1542,7 +1539,7 @@ void MuseScore::dropEvent(QDropEvent* event)
|
|||
Score* score = readScore(file);
|
||||
if (score) {
|
||||
view = appendScore(score);
|
||||
updateRecentScores(score);
|
||||
addRecentScore(score);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2038,7 +2035,7 @@ static void loadScores(const QStringList& argv)
|
|||
mscore->appendScore(score);
|
||||
scoresOnCommandline = true;
|
||||
if(!MScore::noGui) {
|
||||
mscore->updateRecentScores(score);
|
||||
mscore->addRecentScore(score);
|
||||
mscore->writeSessionFile(false);
|
||||
}
|
||||
}
|
||||
|
@ -3018,7 +3015,7 @@ void MuseScore::handleMessage(const QString& message)
|
|||
Score* score = readScore(message);
|
||||
if (score) {
|
||||
setCurrentScoreView(appendScore(score));
|
||||
updateRecentScores(score);
|
||||
addRecentScore(score);
|
||||
writeSessionFile(false);
|
||||
}
|
||||
}
|
||||
|
@ -4465,6 +4462,8 @@ QQmlEngine* MuseScore::qml() { return 0; }
|
|||
|
||||
//---------------------------------------------------------
|
||||
// recentScores
|
||||
// return a list of recent scores
|
||||
// omit loaded scores
|
||||
//---------------------------------------------------------
|
||||
|
||||
QFileInfoList MuseScore::recentScores() const
|
||||
|
@ -4478,7 +4477,7 @@ QFileInfoList MuseScore::recentScores() const
|
|||
bool alreadyLoaded = false;
|
||||
QString fp = fi.canonicalFilePath();
|
||||
for (Score* s : mscore->scores()) {
|
||||
if (s->fileInfo()->canonicalFilePath() == fp) {
|
||||
if ((s->fileInfo()->canonicalFilePath() == fp) || (s->importedFilePath() == fp)) {
|
||||
alreadyLoaded = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -521,7 +521,7 @@ class MuseScore : public QMainWindow, public MuseScoreCore {
|
|||
void updateTabNames();
|
||||
QProgressBar* showProgressBar();
|
||||
void hideProgressBar();
|
||||
void updateRecentScores(Score*);
|
||||
void addRecentScore(Score*);
|
||||
QFileDialog* saveAsDialog();
|
||||
QFileDialog* saveCopyDialog();
|
||||
|
||||
|
|
Loading…
Reference in a new issue