From: lordmulder Date: Mon, 11 Apr 2011 19:57:16 +0000 (+0200) Subject: Make it possible to abort the operation when adding files or when scanning for direct... X-Git-Tag: Release_403~242 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=fa2a5a3754c692eb5f879e31314fcfe1b6604276;p=lamexp%2FLameXP.git Make it possible to abort the operation when adding files or when scanning for directories. Press "ESC" key to abort! --- diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index 20a38d3c..c8c48667 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -64,8 +64,8 @@ #include #include -//Win32 includes -#include +//System includes +#include //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!"))); diff --git a/src/Thread_FileAnalyzer.cpp b/src/Thread_FileAnalyzer.cpp index dcb41153..de2f0227 100644 --- a/src/Thread_FileAnalyzer.cpp +++ b/src/Thread_FileAnalyzer.cpp @@ -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); }