Implemented progress indicator for the working banner.

This commit is contained in:
LoRd_MuldeR 2012-05-06 04:57:00 +02:00
parent a7a776ed82
commit e13b93f51b
16 changed files with 769 additions and 695 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@
</font>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<property name="usesScrollButtons">
<bool>false</bool>
@ -4101,6 +4101,7 @@
<include location="../res/Icons.qrc"/>
<include location="../res/Icons.qrc"/>
<include location="../res/Icons.qrc"/>
<include location="../res/Icons.qrc"/>
</resources>
<connections>
<connection>

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>480</width>
<height>53</height>
<height>51</height>
</rect>
</property>
<property name="minimumSize">
@ -96,14 +96,14 @@
<widget class="QLabel" name="labelWorking">
<property name="minimumSize">
<size>
<width>36</width>
<height>0</height>
<width>31</width>
<height>31</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>36</width>
<height>16777215</height>
<width>31</width>
<height>31</height>
</size>
</property>
<property name="text">
@ -143,6 +143,7 @@
<include location="../res/Images.qrc"/>
<include location="../res/Images.qrc"/>
<include location="../res/Images.qrc"/>
<include location="../res/Images.qrc"/>
</resources>
<connections/>
</ui>

View File

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

View File

@ -424,6 +424,7 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S
connect(m_fileListModel, SIGNAL(modelReset()), m_dropBox, SLOT(modelChanged()));
connect(m_fileListModel, SIGNAL(rowsInserted(QModelIndex,int,int)), m_dropBox, SLOT(modelChanged()));
connect(m_fileListModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), m_dropBox, SLOT(modelChanged()));
connect(m_fileListModel, SIGNAL(rowAppended()), m_dropBox, SLOT(modelChanged()));
//Create message handler thread
m_messageHandler = new MessageHandlerThread();
@ -516,6 +517,8 @@ void MainWindow::addFiles(const QStringList &files)
FileAnalyzer *analyzer = new FileAnalyzer(files);
connect(analyzer, SIGNAL(fileSelected(QString)), m_banner, SLOT(setText(QString)), Qt::QueuedConnection);
connect(analyzer, SIGNAL(progressValChanged(unsigned int)), m_banner, SLOT(setProgressVal(unsigned int)), Qt::QueuedConnection);
connect(analyzer, SIGNAL(progressMaxChanged(unsigned int)), m_banner, SLOT(setProgressMax(unsigned int)), Qt::QueuedConnection);
connect(analyzer, SIGNAL(fileAnalyzed(AudioFileModel)), m_fileListModel, SLOT(addFile(AudioFileModel)), Qt::QueuedConnection);
connect(m_banner, SIGNAL(userAbort()), analyzer, SLOT(abortProcess()), Qt::DirectConnection);

View File

@ -42,7 +42,8 @@
WorkingBanner::WorkingBanner(QWidget *parent)
:
QDialog(parent, Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint)
QDialog(parent, Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint),
m_progressMax(0), m_progressVal(0)
{
//Init the dialog, from the .ui file
setupUi(this);
@ -54,6 +55,23 @@ WorkingBanner::WorkingBanner(QWidget *parent)
labelWorking->setMovie(m_working);
m_working->start();
//Create progress indicator
m_progress = new QLabel(labelWorking);
m_progress->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
m_progress->move(0, 0);
m_progress->resize(labelWorking->size());
//Set font size
QFont font = m_progress->font();
font.setPointSize(5);
m_progress->setFont(font);
//Set font color
QPalette color = m_progress->palette();
color.setColor(QPalette::Text, QColor::fromRgb(0x36, 0x36, 0x36));
color.setColor(QPalette::WindowText, QColor::fromRgb(0x36, 0x36, 0x36));
m_progress->setPalette(color);
//Set wait cursor
setCursor(Qt::WaitCursor);
}
@ -70,6 +88,8 @@ WorkingBanner::~WorkingBanner(void)
delete m_working;
m_working = NULL;
}
LAMEXP_DELETE(m_progress);
}
////////////////////////////////////////////////////////////
@ -82,6 +102,9 @@ void WorkingBanner::show(const QString &text)
QDialog::show();
setFixedSize(size());
setText(text);
m_progress->setText(QString());
QApplication::processEvents();
}
@ -205,3 +228,18 @@ void WorkingBanner::setText(const QString &text)
}
*/
}
void WorkingBanner::setProgressMax(unsigned int max)
{
m_progressMax = max;
}
void WorkingBanner::setProgressVal(unsigned int val)
{
m_progressVal = val;
if(m_progressMax > 0)
{
int progress = qRound(qBound(0.0, static_cast<double>(m_progressVal) / static_cast<double>(m_progressMax), 1.0) * 100.0);
m_progress->setText(QString::number(progress));
}
}

View File

@ -45,6 +45,8 @@ private:
public slots:
void setText(const QString &text);
void setProgressMax(unsigned int max);
void setProgressVal(unsigned int val);
bool close(void);
signals:
@ -55,4 +57,8 @@ protected:
void keyReleaseEvent(QKeyEvent *event);
void closeEvent(QCloseEvent *event);
bool winEvent(MSG *message, long *result);
QLabel *m_progress;
unsigned int m_progressMax;
unsigned int m_progressVal;
};

View File

@ -147,6 +147,7 @@ void FileListModel::addFile(const QString &filePath)
m_fileStore.insert(key, AudioFileModel(fileInfo.canonicalFilePath(), fileInfo.baseName()));
m_fileList.append(key);
if(flag) endInsertRows();
emit rowAppended();
}
}
@ -161,6 +162,7 @@ void FileListModel::addFile(const AudioFileModel &file)
m_fileStore.insert(key, file);
m_fileList.append(key);
if(flag) endInsertRows();
emit rowAppended();
}
}

View File

@ -76,6 +76,9 @@ public slots:
void addFile(const QString &filePath);
void addFile(const AudioFileModel &file);
signals:
void rowAppended(void);
private:
bool m_blockUpdates;
QList<QString> m_fileList;

View File

@ -23,7 +23,7 @@
#include <QUuid>
#define MAX_DISPLAY_ITEMS 50
#define MAX_DISPLAY_ITEMS 32
ProgressModel::ProgressModel(void)
:

View File

@ -108,11 +108,17 @@ const char *FileAnalyzer::g_tags_aud[] =
void FileAnalyzer::run()
{
m_bSuccess = false;
m_abortFlag = false;
m_bAborted = false;
m_bSuccess = false;
int nFiles = m_inputFiles.count();
emit progressMaxChanged(nFiles);
emit progressValChanged(0);
m_inputFiles.sort();
m_abortFlag = false;
if(!m_templateFile)
{
@ -125,7 +131,8 @@ void FileAnalyzer::run()
AnalyzeTask::reset();
QThreadPool *pool = new QThreadPool();
QThread::msleep(333);
if(pool->maxThreadCount() < 2)
{
pool->setMaxThreadCount(2);
@ -139,13 +146,15 @@ void FileAnalyzer::run()
AnalyzeTask *task = new AnalyzeTask(currentFile, m_templateFile->filePath(), &m_abortFlag);
connect(task, SIGNAL(fileSelected(QString)), this, SIGNAL(fileSelected(QString)), Qt::DirectConnection);
connect(task, SIGNAL(progressValChanged(unsigned int)), this, SIGNAL(progressValChanged(unsigned int)), Qt::DirectConnection);
connect(task, SIGNAL(progressMaxChanged(unsigned int)), this, SIGNAL(progressMaxChanged(unsigned int)), Qt::DirectConnection);
connect(task, SIGNAL(fileAnalyzed(AudioFileModel)), this, SIGNAL(fileAnalyzed(AudioFileModel)), Qt::DirectConnection);
while(!pool->tryStart(task))
{
if(!AnalyzeTask::waitForOneThread(1250))
{
qWarning("FileAnalyzer::run() -> Timeout !!!");
qWarning("FileAnalyzer: Timeout, retrying!");
}
if(m_abortFlag)
@ -162,8 +171,10 @@ void FileAnalyzer::run()
MessageBeep(MB_ICONERROR);
m_bAborted = true;
}
QThread::yieldCurrentThread();
else
{
QThread::msleep(5);
}
}
//One of the Analyze tasks may have gathered additional files from a playlist!
@ -171,6 +182,8 @@ void FileAnalyzer::run()
{
pool->waitForDone();
AnalyzeTask::getAdditionalFiles(m_inputFiles);
nFiles += m_inputFiles.count();
emit progressMaxChanged(nFiles);
}
}

View File

@ -55,6 +55,8 @@ public:
signals:
void fileSelected(const QString &fileName);
void fileAnalyzed(const AudioFileModel &file);
void progressValChanged(unsigned int);
void progressMaxChanged(unsigned int);
public slots:
void abortProcess(void) { m_abortFlag = true; }

View File

@ -109,9 +109,12 @@ void AnalyzeTask::run_ex(void)
int fileType = fileTypeNormal;
QString currentFile = QDir::fromNativeSeparators(m_inputFile);
qDebug("Analyzing: %s", currentFile.toUtf8().constData());
emit fileSelected(QFileInfo(currentFile).fileName());
emit progressValChanged(m_threadIdx + 1);
AudioFileModel file = analyzeFile(currentFile, &fileType);
if(*m_abortFlag)
{
qWarning("Operation cancelled by user!");
@ -725,7 +728,7 @@ void AnalyzeTask::waitForPreviousThreads(void)
if(!AnalyzeTask::waitForOneThread(1250))
{
qWarning("AnalyzeTask::waitForPreviousThreads -> Timeout !!!");
qWarning("FileAnalyzerTask: Timeout, retrying!");
}
}
}

View File

@ -66,6 +66,8 @@ public:
signals:
void fileSelected(const QString &fileName);
void fileAnalyzed(const AudioFileModel &file);
void progressValChanged(unsigned int);
void progressMaxChanged(unsigned int);
protected:
void run(void);