Make it possible to abort the operation when adding files or when scanning for directories. Press "ESC" key to abort!

This commit is contained in:
LoRd_MuldeR 2011-04-11 21:57:16 +02:00
parent 8977e0073f
commit fa2a5a3754
2 changed files with 28 additions and 8 deletions

View 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!")));

View 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);
}