Skip to content

Commit 1844f0d

Browse files
authored
Merge pull request #15972 from Swarnadip-Kar/fix-10209-no-directories-message
Fix #10209: Show message when rescanning with no library folders
2 parents 8837b44 + 92010de commit 1844f0d

3 files changed

Lines changed: 35 additions & 8 deletions

File tree

src/library/library_decl.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@ enum class FocusWidget {
2121
};
2222

2323
struct LibraryScanResultSummary {
24+
LibraryScanResultSummary()
25+
: autoscan(false),
26+
numNewTracks(0),
27+
numMovedTracks(0),
28+
numMissingTracks(0),
29+
numNewMissingTracks(0),
30+
numRediscoveredTracks(0),
31+
tracksTotal(0),
32+
noDirectoriesConfigured(false) {
33+
}
34+
2435
QString durationString;
2536
bool autoscan;
2637
int numNewTracks;
@@ -29,4 +40,5 @@ struct LibraryScanResultSummary {
2940
int numNewMissingTracks;
3041
int numRediscoveredTracks;
3142
int tracksTotal;
43+
bool noDirectoriesConfigured;
3244
};

src/library/scanner/libraryscanner.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,20 @@ void LibraryScanner::slotStartScan() {
193193

194194
// Recursively scan each directory in the directories table.
195195
m_libraryRootDirs = m_directoryDao.loadAllDirectories();
196-
// If there are no directories then we have nothing to do. Cleanup and
197-
// finish the scan immediately.
198-
if (m_libraryRootDirs.isEmpty()) {
196+
// If there are no directories then we still have to scan independently added tracks.
197+
QSet<QString> trackLocations = m_trackDao.getAllTrackLocations();
198+
199+
if (m_libraryRootDirs.isEmpty() && trackLocations.isEmpty()) {
200+
// Nothing to do. noDirectoriesConfigured == true will show the "no dirs" message.
201+
LibraryScanResultSummary result;
202+
result.autoscan = m_manualScan;
203+
result.noDirectoriesConfigured = true;
204+
199205
changeScannerState(IDLE);
206+
emit scanSummary(result);
200207
return;
201208
}
202209
changeScannerState(SCANNING);
203-
204-
QSet<QString> trackLocations = m_trackDao.getAllTrackLocations();
205210
// Store number of existing tracks so we can calculate the number
206211
// of missing tracks in slotFinishUnhashedScan().
207212
m_previouslyMissingTracks = m_trackDao.getAllMissingTrackLocations();

src/mixxxmainwindow.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,18 @@ void MixxxMainWindow::slotLibraryScanSummaryDlg(const LibraryScanResultSummary&
12481248
return;
12491249
}
12501250

1251+
QMessageBox* pMsg = new QMessageBox();
1252+
pMsg->setTextFormat(Qt::RichText); // required to get bold text with <b> tags
1253+
pMsg->setWindowTitle(tr("Library scan finished"));
1254+
1255+
if (result.noDirectoriesConfigured) {
1256+
pMsg->setText(tr("No music directories configured for scanning.") +
1257+
QStringLiteral("<br>") +
1258+
tr("Add directories in the library preferences."));
1259+
pMsg->show();
1260+
return;
1261+
}
1262+
12511263
QString summary =
12521264
tr("Scan took %1").arg(result.durationString) + QStringLiteral("<br><br>");
12531265
if (result.numNewTracks == 0 &&
@@ -1282,9 +1294,7 @@ void MixxxMainWindow::slotLibraryScanSummaryDlg(const LibraryScanResultSummary&
12821294
tr("%n track(s) in total", nullptr, result.tracksTotal) +
12831295
QStringLiteral("</b>");
12841296
}
1285-
QMessageBox* pMsg = new QMessageBox();
1286-
pMsg->setTextFormat(Qt::RichText); // required to get bold text with <b> tags
1287-
pMsg->setWindowTitle(tr("Library scan finished"));
1297+
12881298
pMsg->setText(summary);
12891299
pMsg->show();
12901300
}

0 commit comments

Comments
 (0)