Added progress indicator to CueSheet import thread.

This commit is contained in:
LoRd_MuldeR 2012-05-06 23:58:18 +02:00
parent e13b93f51b
commit 72e8558b5f
9 changed files with 51 additions and 26 deletions

View File

@ -384,8 +384,8 @@
<message> <message>
<location filename="../../src/Dialog_CueImport.cpp" line="111"/> <location filename="../../src/Dialog_CueImport.cpp" line="111"/>
<location filename="../../src/Dialog_CueImport.cpp" line="208"/> <location filename="../../src/Dialog_CueImport.cpp" line="208"/>
<location filename="../../src/Dialog_CueImport.cpp" line="393"/> <location filename="../../src/Dialog_CueImport.cpp" line="395"/>
<location filename="../../src/Dialog_CueImport.cpp" line="397"/> <location filename="../../src/Dialog_CueImport.cpp" line="399"/>
<source>Cue Sheet Error</source> <source>Cue Sheet Error</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -512,27 +512,27 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../../src/Dialog_CueImport.cpp" line="388"/> <location filename="../../src/Dialog_CueImport.cpp" line="390"/>
<source>Splitting file(s), please wait...</source> <source>Splitting file(s), please wait...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../../src/Dialog_CueImport.cpp" line="393"/> <location filename="../../src/Dialog_CueImport.cpp" line="395"/>
<source>Process was aborted by the user after %1 track(s)!</source> <source>Process was aborted by the user after %1 track(s)!</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../../src/Dialog_CueImport.cpp" line="397"/> <location filename="../../src/Dialog_CueImport.cpp" line="399"/>
<source>An unexpected error has occured while splitting the Cue Sheet!</source> <source>An unexpected error has occured while splitting the Cue Sheet!</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../../src/Dialog_CueImport.cpp" line="401"/> <location filename="../../src/Dialog_CueImport.cpp" line="403"/>
<source>Imported %1 track(s) from the Cue Sheet and skipped %2 track(s).</source> <source>Imported %1 track(s) from the Cue Sheet and skipped %2 track(s).</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../../src/Dialog_CueImport.cpp" line="402"/> <location filename="../../src/Dialog_CueImport.cpp" line="404"/>
<source>Cue Sheet Completed</source> <source>Cue Sheet Completed</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View File

@ -384,8 +384,8 @@
<message> <message>
<location filename="../../src/Dialog_CueImport.cpp" line="111"/> <location filename="../../src/Dialog_CueImport.cpp" line="111"/>
<location filename="../../src/Dialog_CueImport.cpp" line="208"/> <location filename="../../src/Dialog_CueImport.cpp" line="208"/>
<location filename="../../src/Dialog_CueImport.cpp" line="393"/> <location filename="../../src/Dialog_CueImport.cpp" line="395"/>
<location filename="../../src/Dialog_CueImport.cpp" line="397"/> <location filename="../../src/Dialog_CueImport.cpp" line="399"/>
<source>Cue Sheet Error</source> <source>Cue Sheet Error</source>
<translation type="unfinished">Błąd pliku Cue Sheet</translation> <translation type="unfinished">Błąd pliku Cue Sheet</translation>
</message> </message>
@ -512,27 +512,27 @@
<translation type="unfinished">Przerwij</translation> <translation type="unfinished">Przerwij</translation>
</message> </message>
<message> <message>
<location filename="../../src/Dialog_CueImport.cpp" line="388"/> <location filename="../../src/Dialog_CueImport.cpp" line="390"/>
<source>Splitting file(s), please wait...</source> <source>Splitting file(s), please wait...</source>
<translation type="unfinished">Dzielenie pliku/ów, prosze czekać...</translation> <translation type="unfinished">Dzielenie pliku/ów, prosze czekać...</translation>
</message> </message>
<message> <message>
<location filename="../../src/Dialog_CueImport.cpp" line="393"/> <location filename="../../src/Dialog_CueImport.cpp" line="395"/>
<source>Process was aborted by the user after %1 track(s)!</source> <source>Process was aborted by the user after %1 track(s)!</source>
<translation type="unfinished">Proces został przerwany przez użytkownika po imporcie %1 ścieżek!</translation> <translation type="unfinished">Proces został przerwany przez użytkownika po imporcie %1 ścieżek!</translation>
</message> </message>
<message> <message>
<location filename="../../src/Dialog_CueImport.cpp" line="397"/> <location filename="../../src/Dialog_CueImport.cpp" line="399"/>
<source>An unexpected error has occured while splitting the Cue Sheet!</source> <source>An unexpected error has occured while splitting the Cue Sheet!</source>
<translation type="unfinished">Wystąpił nieoczekiwany błąd podczas podziału pliku Cue Sheet!</translation> <translation type="unfinished">Wystąpił nieoczekiwany błąd podczas podziału pliku Cue Sheet!</translation>
</message> </message>
<message> <message>
<location filename="../../src/Dialog_CueImport.cpp" line="401"/> <location filename="../../src/Dialog_CueImport.cpp" line="403"/>
<source>Imported %1 track(s) from the Cue Sheet and skipped %2 track(s).</source> <source>Imported %1 track(s) from the Cue Sheet and skipped %2 track(s).</source>
<translation type="unfinished">Zaimportowano %1 ścieżek i opuszczono %2 ścieżek z pliku Cue Sheet.</translation> <translation type="unfinished">Zaimportowano %1 ścieżek i opuszczono %2 ścieżek z pliku Cue Sheet.</translation>
</message> </message>
<message> <message>
<location filename="../../src/Dialog_CueImport.cpp" line="402"/> <location filename="../../src/Dialog_CueImport.cpp" line="404"/>
<source>Cue Sheet Completed</source> <source>Cue Sheet Completed</source>
<translation type="unfinished">Stworzono plik Cue Sheet</translation> <translation type="unfinished">Stworzono plik Cue Sheet</translation>
</message> </message>

View File

@ -384,8 +384,8 @@
<message> <message>
<location filename="../../src/Dialog_CueImport.cpp" line="111"/> <location filename="../../src/Dialog_CueImport.cpp" line="111"/>
<location filename="../../src/Dialog_CueImport.cpp" line="208"/> <location filename="../../src/Dialog_CueImport.cpp" line="208"/>
<location filename="../../src/Dialog_CueImport.cpp" line="393"/> <location filename="../../src/Dialog_CueImport.cpp" line="395"/>
<location filename="../../src/Dialog_CueImport.cpp" line="397"/> <location filename="../../src/Dialog_CueImport.cpp" line="399"/>
<source>Cue Sheet Error</source> <source>Cue Sheet Error</source>
<translation>Cue-fel</translation> <translation>Cue-fel</translation>
</message> </message>
@ -512,27 +512,27 @@
<translation>Avbryt</translation> <translation>Avbryt</translation>
</message> </message>
<message> <message>
<location filename="../../src/Dialog_CueImport.cpp" line="388"/> <location filename="../../src/Dialog_CueImport.cpp" line="390"/>
<source>Splitting file(s), please wait...</source> <source>Splitting file(s), please wait...</source>
<translation>Delar fil(er), vänta...</translation> <translation>Delar fil(er), vänta...</translation>
</message> </message>
<message> <message>
<location filename="../../src/Dialog_CueImport.cpp" line="393"/> <location filename="../../src/Dialog_CueImport.cpp" line="395"/>
<source>Process was aborted by the user after %1 track(s)!</source> <source>Process was aborted by the user after %1 track(s)!</source>
<translation>Åtgärden avbröts av användaren efter %1 spår!</translation> <translation>Åtgärden avbröts av användaren efter %1 spår!</translation>
</message> </message>
<message> <message>
<location filename="../../src/Dialog_CueImport.cpp" line="397"/> <location filename="../../src/Dialog_CueImport.cpp" line="399"/>
<source>An unexpected error has occured while splitting the Cue Sheet!</source> <source>An unexpected error has occured while splitting the Cue Sheet!</source>
<translation>Ett oväntat fel uppstod vid delningen av cue-filen!</translation> <translation>Ett oväntat fel uppstod vid delningen av cue-filen!</translation>
</message> </message>
<message> <message>
<location filename="../../src/Dialog_CueImport.cpp" line="401"/> <location filename="../../src/Dialog_CueImport.cpp" line="403"/>
<source>Imported %1 track(s) from the Cue Sheet and skipped %2 track(s).</source> <source>Imported %1 track(s) from the Cue Sheet and skipped %2 track(s).</source>
<translation>Importerade %1 spår från cue-filen och hoppade över %2 spår.</translation> <translation>Importerade %1 spår från cue-filen och hoppade över %2 spår.</translation>
</message> </message>
<message> <message>
<location filename="../../src/Dialog_CueImport.cpp" line="402"/> <location filename="../../src/Dialog_CueImport.cpp" line="404"/>
<source>Cue Sheet Completed</source> <source>Cue Sheet Completed</source>
<translation>cue-fil färdigbearbetad</translation> <translation>cue-fil färdigbearbetad</translation>
</message> </message>

View File

@ -30,7 +30,7 @@
#define VER_LAMEXP_MINOR_LO 5 #define VER_LAMEXP_MINOR_LO 5
#define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_TYPE Alpha
#define VER_LAMEXP_PATCH 1 #define VER_LAMEXP_PATCH 1
#define VER_LAMEXP_BUILD 1013 #define VER_LAMEXP_BUILD 1016
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Tool versions (minimum expected versions!) // Tool versions (minimum expected versions!)

View File

@ -383,6 +383,8 @@ void CueImportDialog::splitFiles(void)
connect(splitter, SIGNAL(fileSelected(QString)), progress, SLOT(setText(QString)), Qt::QueuedConnection); connect(splitter, SIGNAL(fileSelected(QString)), progress, SLOT(setText(QString)), Qt::QueuedConnection);
connect(splitter, SIGNAL(fileSplit(AudioFileModel)), m_fileList, SLOT(addFile(AudioFileModel)), Qt::QueuedConnection); connect(splitter, SIGNAL(fileSplit(AudioFileModel)), m_fileList, SLOT(addFile(AudioFileModel)), Qt::QueuedConnection);
connect(splitter, SIGNAL(progressValChanged(unsigned int)), progress, SLOT(setProgressVal(unsigned int)), Qt::QueuedConnection);
connect(splitter, SIGNAL(progressMaxChanged(unsigned int)), progress, SLOT(setProgressMax(unsigned int)), Qt::QueuedConnection);
connect(progress, SIGNAL(userAbort()), splitter, SLOT(abortProcess()), Qt::DirectConnection); connect(progress, SIGNAL(userAbort()), splitter, SLOT(abortProcess()), Qt::DirectConnection);
progress->show(tr("Splitting file(s), please wait..."), splitter); progress->show(tr("Splitting file(s), please wait..."), splitter);

View File

@ -56,7 +56,7 @@
#include <QWindowsStyle> #include <QWindowsStyle>
#include <QSysInfo> #include <QSysInfo>
#include <QDragEnterEvent> #include <QDragEnterEvent>
#include <QMimeData> //#include <QWindowsMime> #include <QMimeData>
#include <QProcess> #include <QProcess>
#include <QUuid> #include <QUuid>
#include <QProcessEnvironment> #include <QProcessEnvironment>

View File

@ -63,13 +63,13 @@ WorkingBanner::WorkingBanner(QWidget *parent)
//Set font size //Set font size
QFont font = m_progress->font(); QFont font = m_progress->font();
font.setPointSize(5); font.setPointSize(6);
m_progress->setFont(font); m_progress->setFont(font);
//Set font color //Set font color
QPalette color = m_progress->palette(); QPalette color = m_progress->palette();
color.setColor(QPalette::Text, QColor::fromRgb(0x36, 0x36, 0x36)); color.setColor(QPalette::Text, QColor::fromRgb(0x33, 0x33, 0x33));
color.setColor(QPalette::WindowText, QColor::fromRgb(0x36, 0x36, 0x36)); color.setColor(QPalette::WindowText, QColor::fromRgb(0x33, 0x33, 0x33));
m_progress->setPalette(color); m_progress->setPalette(color);
//Set wait cursor //Set wait cursor

View File

@ -102,6 +102,9 @@ void CueSplitter::run()
QStringList inputFileList = m_inputFilesInfo.keys(); QStringList inputFileList = m_inputFilesInfo.keys();
int nInputFiles = inputFileList.count(); int nInputFiles = inputFileList.count();
emit progressMaxChanged(nInputFiles);
emit progressValChanged(0);
//Decompress all input files //Decompress all input files
for(int i = 0; i < nInputFiles; i++) for(int i = 0; i < nInputFiles; i++)
{ {
@ -112,9 +115,13 @@ void CueSplitter::run()
if(decoder) if(decoder)
{ {
m_activeFile = shortName(QFileInfo(inputFileList.at(i)).fileName()); m_activeFile = shortName(QFileInfo(inputFileList.at(i)).fileName());
emit fileSelected(m_activeFile); emit fileSelected(m_activeFile);
emit progressValChanged(i+1);
QString tempFile = QString("%1/~%2.wav").arg(m_outputDir, lamexp_rand_str()); QString tempFile = QString("%1/~%2.wav").arg(m_outputDir, lamexp_rand_str());
connect(decoder, SIGNAL(statusUpdated(int)), this, SLOT(handleUpdate(int)), Qt::DirectConnection); connect(decoder, SIGNAL(statusUpdated(int)), this, SLOT(handleUpdate(int)), Qt::DirectConnection);
if(decoder->decode(inputFileList.at(i), tempFile, &m_abortFlag)) if(decoder->decode(inputFileList.at(i), tempFile, &m_abortFlag))
{ {
m_decompressedFiles.insert(inputFileList.at(i), tempFile); m_decompressedFiles.insert(inputFileList.at(i), tempFile);
@ -125,6 +132,7 @@ void CueSplitter::run()
qWarning("Failed to decompress file: <%s>", inputFileList.at(i).toLatin1().constData()); qWarning("Failed to decompress file: <%s>", inputFileList.at(i).toLatin1().constData());
lamexp_remove_file(tempFile); lamexp_remove_file(tempFile);
} }
m_activeFile.clear(); m_activeFile.clear();
LAMEXP_DELETE(decoder); LAMEXP_DELETE(decoder);
} }
@ -137,6 +145,7 @@ void CueSplitter::run()
{ {
m_decompressedFiles.insert(inputFileList.at(i), inputFileList.at(i)); m_decompressedFiles.insert(inputFileList.at(i), inputFileList.at(i));
} }
if(m_abortFlag) if(m_abortFlag)
{ {
m_bAborted = true; m_bAborted = true;
@ -146,6 +155,17 @@ void CueSplitter::run()
} }
int nFiles = m_model->getFileCount(); int nFiles = m_model->getFileCount();
int nTracksTotal = 0;
int nTracksComplete = 0;
for(int i = 0; i < nFiles; i++)
{
nTracksTotal += m_model->getTrackCount(i);
}
emit progressMaxChanged(nTracksTotal);
emit progressValChanged(0);
QString albumPerformer = m_model->getAlbumPerformer(); QString albumPerformer = m_model->getAlbumPerformer();
QString albumTitle = m_model->getAlbumTitle(); QString albumTitle = m_model->getAlbumTitle();
QString albumGenre = m_model->getAlbumGenre(); QString albumGenre = m_model->getAlbumGenre();
@ -161,6 +181,7 @@ void CueSplitter::run()
//Process all tracks //Process all tracks
for(int j = 0; j < nTracks; j++) for(int j = 0; j < nTracks; j++)
{ {
emit progressValChanged(++nTracksComplete);
int trackNo = m_model->getTrackNo(i, j); int trackNo = m_model->getTrackNo(i, j);
double trackOffset = std::numeric_limits<double>::quiet_NaN(); double trackOffset = std::numeric_limits<double>::quiet_NaN();
double trackLength = std::numeric_limits<double>::quiet_NaN(); double trackLength = std::numeric_limits<double>::quiet_NaN();

View File

@ -52,6 +52,8 @@ public:
signals: signals:
void fileSelected(const QString &fileName); void fileSelected(const QString &fileName);
void fileSplit(const AudioFileModel &file); void fileSplit(const AudioFileModel &file);
void progressValChanged(unsigned int);
void progressMaxChanged(unsigned int);
private slots: private slots:
void handleUpdate(int progress); void handleUpdate(int progress);