Skip to content

Commit 1fb4bb4

Browse files
committed
Show message when rescanning with no library folders or tracks
When users try to rescan the library with no folders configured, show a helpful message guiding them to add folders instead of silently doing nothing.
1 parent c78840f commit 1fb4bb4

3 files changed

Lines changed: 31 additions & 5 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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,15 @@ void MixxxMainWindow::slotLibraryScanSummaryDlg(const LibraryScanResultSummary&
12581258
QStringLiteral("<br><b>") +
12591259
tr("%n track(s) in total", nullptr, result.tracksTotal) +
12601260
QStringLiteral("</b>");
1261+
1262+
if (result.noDirectoriesConfigured) {
1263+
summary = tr("No music directories configured for scanning.") +
1264+
QStringLiteral("<br>") +
1265+
tr("Add directories in the library preferences.");
1266+
// reassign summary to avoid showing "Scan took <Empty String>"
1267+
// which is not relevant in this case - no scan was actually
1268+
// performed
1269+
}
12611270
} else {
12621271
if (result.numNewTracks != 0) {
12631272
summary += tr("%n new track(s) found", nullptr, result.numNewTracks) +

0 commit comments

Comments
 (0)