OSDN Git Service

Make it possible to abort the operation when adding files or when scanning for direct...
authorlordmulder <mulder2@gmx.de>
Mon, 11 Apr 2011 19:57:16 +0000 (21:57 +0200)
committerlordmulder <mulder2@gmx.de>
Mon, 11 Apr 2011 19:57:16 +0000 (21:57 +0200)
src/Dialog_MainWindow.cpp
src/Thread_FileAnalyzer.cpp

index 20a38d3..c8c4866 100644 (file)
@@ -64,8 +64,8 @@
 #include <QResource>
 #include <QScrollBar>
 
-//Win32 includes
-#include <Windows.h>
+//System includes
+#include <MMSystem.h>
 
 //Helper macros
 #define ABORT_IF_BUSY if(m_banner->isVisible() || m_delayedFileTimer->isActive()) { MessageBeep(MB_ICONEXCLAMATION); return; }
@@ -472,10 +472,20 @@ void MainWindow::addFolder(const QString &path, bool recursive)
        QStringList fileList;
        
        m_banner->show(tr("Scanning folder(s) for files, please wait..."));
+       
        QApplication::processEvents();
+       GetAsyncKeyState(VK_ESCAPE);
 
        while(!folderInfoList.isEmpty())
        {
+               if(GetAsyncKeyState(VK_ESCAPE) & 0x0001)
+               {
+                       MessageBeep(MB_ICONERROR);
+                       qWarning("Operation cancelled by user!");
+                       fileList.clear();
+                       break;
+               }
+               
                QDir currentDir(folderInfoList.takeFirst().canonicalFilePath());
                QFileInfoList fileInfoList = currentDir.entryInfoList(QDir::Files);
 
@@ -652,14 +662,14 @@ void MainWindow::changeEvent(QEvent *e)
                comboBoxNeroAACProfile->setCurrentIndex(comboBoxIndex[2]);
 
                //Update the window title
-#if !defined(_DEBUG) && !defined(QT_DEBUG) && defined(NDEBUG) && defined(QT_NO_DEBUG)
-               if(lamexp_version_demo())
+               if(LAMEXP_DEBUG)
+               {
+                       setWindowTitle(QString("%1 [!!! DEBUG BUILD !!!]").arg(windowTitle()));
+               }
+               else if(lamexp_version_demo())
                {
                        setWindowTitle(QString("%1 [%2]").arg(windowTitle(), tr("DEMO VERSION")));
                }
-#else
-               setWindowTitle(QString("%1 [!!! DEBUG BUILD !!!]").arg(windowTitle()));
-#endif
 
                //Manually re-translate widgets that UIC doesn't handle
                m_dropNoteLabel->setText(QString("» %1 «").arg(tr("You can drop in audio files here!")));
index dcb4115..de2f022 100644 (file)
@@ -69,15 +69,24 @@ void FileAnalyzer::run()
        m_filesRejected = 0;
        m_filesDenied = 0;
        m_filesDummyCDDA = 0;
-
        m_inputFiles.sort();
 
+       GetAsyncKeyState(VK_ESCAPE);
+
        while(!m_inputFiles.isEmpty())
        {
+               if(GetAsyncKeyState(VK_ESCAPE) & 0x0001)
+               {
+                       MessageBeep(MB_ICONERROR);
+                       qWarning("Operation cancelled by user!");
+                       break;
+               }
+               
                QString currentFile = QDir::fromNativeSeparators(m_inputFiles.takeFirst());
                qDebug64("Analyzing: %1", currentFile);
                emit fileSelected(QFileInfo(currentFile).fileName());
                AudioFileModel file = analyzeFile(currentFile);
+               
                if(file.fileName().isEmpty() || file.formatContainerType().isEmpty() || file.formatAudioType().isEmpty())
                {
                        if(!PlaylistImporter::importPlaylist(m_inputFiles, currentFile))
@@ -87,6 +96,7 @@ void FileAnalyzer::run()
                        }
                        continue;
                }
+               
                m_filesAccepted++;
                emit fileAnalyzed(file);
        }