diff --git a/src/coreservices.cpp b/src/coreservices.cpp index d7d08299321..863ee5eaf62 100644 --- a/src/coreservices.cpp +++ b/src/coreservices.cpp @@ -452,7 +452,7 @@ void CoreServices::initialize(QApplication* pApp) { // Scan the library directory. Do this after the skinloader has // loaded a skin, see issue #6625 if (rescan || musicDirAdded || m_pSettingsManager->shouldRescanLibrary()) { - m_pTrackCollectionManager->startLibraryScanNoReport(); + m_pTrackCollectionManager->startLibraryAutoScan(); } // This has to be done before m_pSoundManager->setupDevices() diff --git a/src/library/library_decl.h b/src/library/library_decl.h index 503c3b09b33..97c2b47317f 100644 --- a/src/library/library_decl.h +++ b/src/library/library_decl.h @@ -22,6 +22,7 @@ enum class FocusWidget { struct LibraryScanResultSummary { QString durationString; + bool autoscan; int numNewTracks; int numMovedTracks; int numMissingTracks; diff --git a/src/library/scanner/libraryscanner.cpp b/src/library/scanner/libraryscanner.cpp index 5651c9d6458..a6a2b07d8f9 100644 --- a/src/library/scanner/libraryscanner.cpp +++ b/src/library/scanner/libraryscanner.cpp @@ -103,7 +103,7 @@ LibraryScanner::LibraryScanner( m_trackDao(m_cueDao, m_playlistDao, m_analysisDao, m_libraryHashDao, pConfig), m_stateSema(1), // only one transaction is possible at a time m_state(IDLE), - m_emitSummaryReport(true) { + m_manualScan(true) { // Move LibraryScanner to its own thread so that our signals/slots will // queue to our event loop. moveToThread(this); @@ -473,20 +473,19 @@ void LibraryScanner::slotFinishUnhashedScan() { result.numMissingTracks = numMissingTracks; result.numRediscoveredTracks = numRediscoveredTracks; result.tracksTotal = tracksTotal; + result.autoscan = m_manualScan; m_scannerGlobal.clear(); changeScannerState(FINISHED); // now we may accept new scan commands emit scanFinished(); - if (m_emitSummaryReport) { - emit scanSummary(result); - } + emit scanSummary(result); } -void LibraryScanner::scan(bool requestSummaryReport) { +void LibraryScanner::scan(bool autoscan) { if (changeScannerState(STARTING)) { - m_emitSummaryReport = requestSummaryReport; + m_manualScan = autoscan; emit startScan(); } } diff --git a/src/library/scanner/libraryscanner.h b/src/library/scanner/libraryscanner.h index 6d8fb1bd311..b0a8281a3e2 100644 --- a/src/library/scanner/libraryscanner.h +++ b/src/library/scanner/libraryscanner.h @@ -35,9 +35,10 @@ class LibraryScanner : public QThread { public slots: // Call from any thread to start a scan. Does nothing if a scan is already // in progress. - // Optionally omit summary report. Purpose is to not show the summary dialog - // during startup when being called by CoreServices::initialize. - void scan(bool requestSummaryReport = true); + // The autoscan flag is used for the summary report. Receivers of scanSummary() + // can use this to decide whether to show the summary dialog, for example hide + // it for the automatic scan during startup. + void scan(bool autoscan = false); // Call from any thread to cancel the scan. void slotCancel(); @@ -129,5 +130,5 @@ class LibraryScanner : public QThread { QList m_libraryRootDirs; QScopedPointer m_pProgressDlg; - bool m_emitSummaryReport; + bool m_manualScan; }; diff --git a/src/library/trackcollectionmanager.cpp b/src/library/trackcollectionmanager.cpp index 5aa5ecafecb..9fbac0527cb 100644 --- a/src/library/trackcollectionmanager.cpp +++ b/src/library/trackcollectionmanager.cpp @@ -172,11 +172,11 @@ TrackCollectionManager::~TrackCollectionManager() { GlobalTrackCache::destroyInstance(); } -void TrackCollectionManager::startLibraryScanNoReport() { +void TrackCollectionManager::startLibraryAutoScan() { VERIFY_OR_DEBUG_ASSERT(m_pScanner) { return; } - m_pScanner->scan(false); + m_pScanner->scan(true); } void TrackCollectionManager::startLibraryScan() { diff --git a/src/library/trackcollectionmanager.h b/src/library/trackcollectionmanager.h index 674c3bff9dc..8f88f571f78 100644 --- a/src/library/trackcollectionmanager.h +++ b/src/library/trackcollectionmanager.h @@ -93,7 +93,7 @@ class TrackCollectionManager: public QObject, }; SaveTrackResult saveTrack(const TrackPointer& pTrack) const; // Same as startLibraryScan() but don't emit the scan summary. - void startLibraryScanNoReport(); + void startLibraryAutoScan(); signals: void libraryScanStarted(); diff --git a/src/mixxxmainwindow.cpp b/src/mixxxmainwindow.cpp index 87f647ba286..a97ef5d86e5 100644 --- a/src/mixxxmainwindow.cpp +++ b/src/mixxxmainwindow.cpp @@ -1147,11 +1147,17 @@ void MixxxMainWindow::slotHelpAbout() { } void MixxxMainWindow::slotLibraryScanSummaryDlg(const LibraryScanResultSummary& result) { + // Don't show the report dialog when the sacn is run during startup and no + // noteworthy changes have been detected. + if (result.autoscan && + result.numNewMissingTracks == 0 && + result.numRediscoveredTracks == 0) { + return; + } + QString summary = tr("Scan took %1.").arg(result.durationString) + QStringLiteral("

"); - if (result.numNewTracks == 0 && - result.numMovedTracks == 0 && - result.numNewMissingTracks == 0) { + if (result.numNewTracks == 0 && result.numMovedTracks == 0 && result.numNewMissingTracks == 0) { summary += tr("No changes detected.") + QStringLiteral("
") + tr("%1 tracks in total").arg(result.tracksTotal) +