Move about dialog into a separate class

This commit is contained in:
LoRd_MuldeR 2010-11-11 19:37:16 +01:00
parent ec0eea9d9c
commit 88eae834d2
9 changed files with 286 additions and 148 deletions

View File

@ -289,6 +289,10 @@
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\src\Dialog_About.cpp"
>
</File>
<File
RelativePath=".\src\Dialog_MainWindow.cpp"
>
@ -359,6 +363,10 @@
RelativePath=".\src\Config.h"
>
</File>
<File
RelativePath=".\src\Dialog_About.h"
>
</File>
<File
RelativePath=".\src\Dialog_MainWindow.h"
>

View File

@ -25,7 +25,7 @@
#define VER_LAMEXP_MAJOR 4
#define VER_LAMEXP_MINOR_HI 0
#define VER_LAMEXP_MINOR_LO 0
#define VER_LAMEXP_BUILD 10
#define VER_LAMEXP_BUILD 11
#define VER_LAMEXP_SUFFIX TechPreview
/*

145
src/Dialog_About.cpp Normal file
View File

@ -0,0 +1,145 @@
///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
// Copyright (C) 2004-2010 LoRd_MuldeR <MuldeR2@GMX.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/licenses/gpl-2.0.txt
///////////////////////////////////////////////////////////////////////////////
#include "Dialog_About.h"
#include "Global.h"
#include "Resource.h"
//Qt includes
#include <QDate>
#include <QApplication>
#include <QIcon>
#include <QPushButton>
//Win32 includes
#include <Windows.h>
//Helper macros
#define LINK(URL) QString("<a href=\"%1\">%2</a>").arg(URL).arg(URL)
AboutDialog::AboutDialog(QWidget *parent)
: QMessageBox(parent)
{
QString aboutText;
aboutText += "<h2>LameXP - Audio Encoder Front-end</h2>";
aboutText += QString("<b>Copyright (C) 2004-%1 LoRd_MuldeR &lt;MuldeR2@GMX.de&gt;. Some rights reserved.</b><br>").arg(max(lamexp_version_date().year(),QDate::currentDate().year()));
aboutText += QString().sprintf("<b>Version %d.%02d %s, Build %d [%s]</b><br><br>", lamexp_version_major(), lamexp_version_minor(), lamexp_version_release(), lamexp_version_build(), lamexp_version_date().toString(Qt::ISODate).toLatin1().constData());
aboutText += "<nobr>Please visit the official web-site at ";
aboutText += LINK("http://mulder.dummwiedeutsch.de/") += " for news and updates!</nobr><br>";
aboutText += "<hr><br>";
aboutText += "<nobr><tt>This program is free software; you can redistribute it and/or<br>";
aboutText += "modify it under the terms of the GNU General Public License<br>";
aboutText += "as published by the Free Software Foundation; either version 2<br>";
aboutText += "of the License, or (at your option) any later version.<br><br>";
aboutText += "This program is distributed in the hope that it will be useful,<br>";
aboutText += "but WITHOUT ANY WARRANTY; without even the implied warranty of<br>";
aboutText += "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>";
aboutText += "GNU General Public License for more details.<br><br>";
aboutText += "You should have received a copy of the GNU General Public License<br>";
aboutText += "along with this program; if not, write to the Free Software<br>";
aboutText += "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</tt></nobr><br>";
aboutText += "<hr><br>";
aboutText += "This software uses the 'slick' icon set by Mark James &ndash; <a href=\"http://www.famfamfam.com/lab/icons/silk/\">http://www.famfamfam.com/</a>.<br>";
aboutText += "Released under the Creative Commons Attribution 2.5 License.<br>";
setText(aboutText);
setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
setWindowTitle("About LameXP");
QPushButton *firstButton = addButton("More About...", QMessageBox::AcceptRole);
firstButton->setIcon(QIcon(":/icons/information.png"));
firstButton->setMinimumWidth(120);
QPushButton *secondButton = addButton("About Qt...", QMessageBox::AcceptRole);
secondButton->setIcon(QIcon(":/images/Qt.svg"));
secondButton->setMinimumWidth(120);
QPushButton *thirdButton = addButton("Discard", QMessageBox::AcceptRole);
thirdButton->setIcon(QIcon(":/icons/cross.png"));
thirdButton->setMinimumWidth(90);
}
AboutDialog::~AboutDialog(void)
{
}
int AboutDialog::exec()
{
PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABOUT), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
while(1)
{
switch(QMessageBox::exec())
{
case 0:
showMoreAbout();
break;
case 1:
QMessageBox::aboutQt(dynamic_cast<QWidget*>(this->parent()));
break;
default:
return 0;
}
}
return 0;
}
void AboutDialog::showMoreAbout()
{
const QString li("<li style=\"margin-left:-25px\">");
QString moreAboutText;
moreAboutText += "<h3>The following third-party software is used in LameXP:</h3>";
moreAboutText += "<ul>";
moreAboutText += li + "<b>LAME - OpenSource mp3 Encoder</b><br>";
moreAboutText += "Released under the terms of the GNU Leser General Public License.<br>";
moreAboutText += LINK("http://lame.sourceforge.net/");
moreAboutText += "<br>";
moreAboutText += li + "<b>OggEnc - Ogg Vorbis Encoder</b>";
moreAboutText += "<br>Completely open and patent-free audio encoding technology.<br>";
moreAboutText += LINK("http://www.vorbis.com/");
moreAboutText += "<br>";
moreAboutText += li + "<b>Nero AAC reference MPEG-4 Encoder</b><br>";
moreAboutText += "Freeware state-of-the-art HE-AAC encoder with 2-Pass support.<br>";
moreAboutText += "(Available from vendor web-site as free download)<br>";
moreAboutText += LINK("http://www.nero.com/eng/technologies-aac-codec.html/");
moreAboutText += "<br>";
moreAboutText += li + "<b>MediaInfo - Media File Analysis Tool</b><br>";
moreAboutText += "Released under the terms of the GNU Leser General Public License.<br>";
moreAboutText += LINK("http://mediainfo.sourceforge.net/");
moreAboutText += "<br></ul>";
QMessageBox *moreAboutBox = new QMessageBox(dynamic_cast<QWidget*>(this->parent()));
moreAboutBox->setText(moreAboutText);
moreAboutBox->setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
QPushButton *closeButton = moreAboutBox->addButton("Discard", QMessageBox::AcceptRole);
closeButton->setIcon(QIcon(":/icons/cross.png"));
closeButton->setMinimumWidth(90);
moreAboutBox->setWindowTitle("About Third-party Software");
moreAboutBox->exec();
LAMEXP_DELETE(moreAboutBox);
}

36
src/Dialog_About.h Normal file
View File

@ -0,0 +1,36 @@
///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
// Copyright (C) 2004-2010 LoRd_MuldeR <MuldeR2@GMX.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/licenses/gpl-2.0.txt
///////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QMessageBox>
class AboutDialog : public QMessageBox
{
public:
AboutDialog(QWidget *parent = 0);
~AboutDialog(void);
public slots:
int exec();
private:
void AboutDialog::showMoreAbout();
};

View File

@ -26,6 +26,7 @@
#include "Resource.h"
#include "Dialog_WorkingBanner.h"
#include "Dialog_MetaInfo.h"
#include "Dialog_About.h"
#include "Thread_FileAnalyzer.h"
#include "Thread_MessageHandler.h"
#include "Model_MetaInfo.h"
@ -44,12 +45,12 @@
#include <QCleanlooksStyle>
#include <QWindowsVistaStyle>
#include <QWindowsStyle>
#include <QSysInfo>
//Win32 includes
#include <Windows.h>
//Helper macros
#define LINK(URL) QString("<a href=\"%1\">%2</a>").arg(URL).arg(URL)
#define ABORT_IF_BUSY \
if(m_banner->isVisible() || m_delayedFileTimer->isActive()) \
{ \
@ -57,6 +58,8 @@ if(m_banner->isVisible() || m_delayedFileTimer->isActive()) \
return; \
} \
#define LINK(X) ""
////////////////////////////////////////////////////////////
// Constructor
////////////////////////////////////////////////////////////
@ -147,6 +150,8 @@ MainWindow::MainWindow(QWidget *parent)
m_styleActionGroup->addAction(actionStyleWindowsXP);
m_styleActionGroup->addAction(actionStyleWindowsClassic);
actionStylePlastique->setChecked(true);
actionStyleWindowsXP->setEnabled((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) >= QSysInfo::WV_XP);
actionStyleWindowsVista->setEnabled((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) >= QSysInfo::WV_VISTA);
connect(m_styleActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(styleActionActivated(QAction*)));
//Activate help menu actions
@ -208,10 +213,37 @@ MainWindow::~MainWindow(void)
}
////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS
// PRIVATE FUNCTIONS
////////////////////////////////////////////////////////////
/*NONE*/
void MainWindow::addFiles(const QStringList &files)
{
if(files.isEmpty())
{
return;
}
tabWidget->setCurrentIndex(0);
FileAnalyzer *analyzer = new FileAnalyzer(files);
connect(analyzer, SIGNAL(fileSelected(QString)), m_banner, SLOT(setText(QString)), Qt::QueuedConnection);
connect(analyzer, SIGNAL(fileAnalyzed(AudioFileModel)), m_fileListModel, SLOT(addFile(AudioFileModel)), Qt::QueuedConnection);
m_banner->show("Adding file(s), please wait...", analyzer);
if(analyzer->filesDenied())
{
QMessageBox::warning(this, "Access Denied", QString("<nobr>%1 file(s) have been rejected, because read access was not granted!<br>This usually means the file is locked by another process.</nobr>").arg(analyzer->filesDenied()));
}
if(analyzer->filesRejected())
{
QMessageBox::warning(this, "Files Rejected", QString("<nobr>%1 file(s) have been rejected, because the file format could not be recognized!<br>This usually means the file is damaged or the file format is not supported.</nobr>").arg(analyzer->filesRejected()));
}
LAMEXP_DELETE(analyzer);
sourceFileView->scrollToBottom();
m_banner->close();
}
////////////////////////////////////////////////////////////
// EVENTS
@ -262,92 +294,8 @@ void MainWindow::windowShown(void)
void MainWindow::aboutButtonClicked(void)
{
ABORT_IF_BUSY;
QString aboutText;
aboutText += "<h2>LameXP - Audio Encoder Front-end</h2>";
aboutText += QString("<b>Copyright (C) 2004-%1 LoRd_MuldeR &lt;MuldeR2@GMX.de&gt;. Some rights reserved.</b><br>").arg(max(lamexp_version_date().year(),QDate::currentDate().year()));
aboutText += QString().sprintf("<b>Version %d.%02d %s, Build %d [%s]</b><br><br>", lamexp_version_major(), lamexp_version_minor(), lamexp_version_release(), lamexp_version_build(), lamexp_version_date().toString(Qt::ISODate).toLatin1().constData());
aboutText += "<nobr>Please visit the official web-site at ";
aboutText += LINK("http://mulder.dummwiedeutsch.de/") += " for news and updates!</nobr><br>";
aboutText += "<hr><br>";
aboutText += "<nobr><tt>This program is free software; you can redistribute it and/or<br>";
aboutText += "modify it under the terms of the GNU General Public License<br>";
aboutText += "as published by the Free Software Foundation; either version 2<br>";
aboutText += "of the License, or (at your option) any later version.<br><br>";
aboutText += "This program is distributed in the hope that it will be useful,<br>";
aboutText += "but WITHOUT ANY WARRANTY; without even the implied warranty of<br>";
aboutText += "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>";
aboutText += "GNU General Public License for more details.<br><br>";
aboutText += "You should have received a copy of the GNU General Public License<br>";
aboutText += "along with this program; if not, write to the Free Software<br>";
aboutText += "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</tt></nobr><br>";
aboutText += "<hr><br>";
aboutText += "This software uses the 'slick' icon set by Mark James &ndash; <a href=\"http://www.famfamfam.com/lab/icons/silk/\">http://www.famfamfam.com/</a>.<br>";
aboutText += "Released under the Creative Commons Attribution 2.5 License.<br>";
QMessageBox *aboutBox = new QMessageBox(this);
aboutBox->setText(aboutText);
aboutBox->setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
aboutBox->setWindowTitle("About LameXP");
QPushButton *firstButton = aboutBox->addButton("More About...", QMessageBox::AcceptRole);
firstButton->setIcon(QIcon(":/icons/information.png"));
firstButton->setMinimumWidth(120);
QPushButton *secondButton = aboutBox->addButton("About Qt...", QMessageBox::AcceptRole);
secondButton->setIcon(QIcon(":/images/Qt.svg"));
secondButton->setMinimumWidth(120);
QPushButton *thirdButton = aboutBox->addButton("Discard", QMessageBox::AcceptRole);
thirdButton->setIcon(QIcon(":/icons/cross.png"));
thirdButton->setMinimumWidth(90);
PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABOUT), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
while(1)
{
switch(aboutBox->exec())
{
case 0:
{
const QString li("<li style=\"margin-left:-25px\">");
QString moreAboutText;
moreAboutText += "<h3>The following third-party software is used in LameXP:</h3>";
moreAboutText += "<ul>";
moreAboutText += li + "<b>LAME - OpenSource mp3 Encoder</b><br>";
moreAboutText += "Released under the terms of the GNU Leser General Public License.<br>";
moreAboutText += LINK("http://lame.sourceforge.net/");
moreAboutText += "<br>";
moreAboutText += li + "<b>OggEnc - Ogg Vorbis Encoder</b>";
moreAboutText += "<br>Completely open and patent-free audio encoding technology.<br>";
moreAboutText += LINK("http://www.vorbis.com/");
moreAboutText += "<br>";
moreAboutText += li + "<b>Nero AAC reference MPEG-4 Encoder</b><br>";
moreAboutText += "Freeware state-of-the-art HE-AAC encoder with 2-Pass support.<br>";
moreAboutText += LINK("http://www.nero.com/eng/technologies-aac-codec.html/");
moreAboutText += "<br>";
moreAboutText += li + "<b>MediaInfo - Media File Analysis Tool</b><br>";
moreAboutText += "Released under the terms of the GNU Leser General Public License.<br>";
moreAboutText += LINK("http://mediainfo.sourceforge.net/");
moreAboutText += "<br></ul>";
QMessageBox *moreAboutBox = new QMessageBox(this);
moreAboutBox->setText(moreAboutText);
moreAboutBox->setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
moreAboutBox->setWindowTitle("About Third-party Software");
moreAboutBox->exec();
LAMEXP_DELETE(moreAboutBox);
break;
}
case 1:
QMessageBox::aboutQt(this);
break;
default:
return;
}
}
AboutDialog *aboutBox = new AboutDialog(this);
aboutBox->exec();
LAMEXP_DELETE(aboutBox);
}
@ -366,24 +314,8 @@ void MainWindow::encodeButtonClicked(void)
void MainWindow::addFilesButtonClicked(void)
{
ABORT_IF_BUSY;
tabWidget->setCurrentIndex(0);
QStringList selectedFiles = QFileDialog::getOpenFileNames(this, "Add file(s)", QString(), "All supported files (*.*)");
if(selectedFiles.isEmpty())
{
return;
}
FileAnalyzer *analyzer = new FileAnalyzer(selectedFiles);
connect(analyzer, SIGNAL(fileSelected(QString)), m_banner, SLOT(setText(QString)), Qt::QueuedConnection);
connect(analyzer, SIGNAL(fileAnalyzed(AudioFileModel)), m_fileListModel, SLOT(addFile(AudioFileModel)), Qt::QueuedConnection);
m_banner->show("Adding file(s), please wait...", analyzer);
LAMEXP_DELETE(analyzer);
sourceFileView->scrollToBottom();
m_banner->close();
addFiles(selectedFiles);
}
/*
@ -392,8 +324,6 @@ void MainWindow::addFilesButtonClicked(void)
void MainWindow::openFolderActionActivated(void)
{
ABORT_IF_BUSY;
tabWidget->setCurrentIndex(0);
QString selectedFolder = QFileDialog::getExistingDirectory(this, "Add folder", QDesktopServices::storageLocation(QDesktopServices::MusicLocation));
if(!selectedFolder.isEmpty())
@ -407,15 +337,7 @@ void MainWindow::openFolderActionActivated(void)
fileList << fileInfoList.takeFirst().absoluteFilePath();
}
FileAnalyzer *analyzer = new FileAnalyzer(fileList);
connect(analyzer, SIGNAL(fileSelected(QString)), m_banner, SLOT(setText(QString)), Qt::QueuedConnection);
connect(analyzer, SIGNAL(fileAnalyzed(AudioFileModel)), m_fileListModel, SLOT(addFile(AudioFileModel)), Qt::QueuedConnection);
m_banner->show("Adding folder, please wait...", analyzer);
LAMEXP_DELETE(analyzer);
sourceFileView->scrollToBottom();
m_banner->close();
addFiles(fileList);
}
}
@ -735,13 +657,5 @@ void MainWindow::handleDelayedFiles(void)
selectedFiles << QFileInfo(m_delayedFileList->takeFirst()).absoluteFilePath();
}
FileAnalyzer *analyzer = new FileAnalyzer(selectedFiles);
connect(analyzer, SIGNAL(fileSelected(QString)), m_banner, SLOT(setText(QString)), Qt::QueuedConnection);
connect(analyzer, SIGNAL(fileAnalyzed(AudioFileModel)), m_fileListModel, SLOT(addFile(AudioFileModel)), Qt::QueuedConnection);
m_banner->show("Adding file(s), please wait...", analyzer);
LAMEXP_DELETE(analyzer);
sourceFileView->scrollToBottom();
m_banner->close();
addFiles(selectedFiles);
}

View File

@ -71,6 +71,8 @@ protected:
void showEvent(QShowEvent *event);
private:
void addFiles(const QStringList &files);
FileListModel *m_fileListModel;
QFileSystemModel *m_fileSystemModel;
QActionGroup *m_tabActionGroup;

View File

@ -50,6 +50,14 @@
#include <Psapi.h>
#endif //_DEBUG
//Static build only macros
#ifdef QT_NODLL
#pragma warning(disable:4101)
#define LAMEXP_INIT_QT_STATIC_PLUGIN(X) Q_IMPORT_PLUGIN(X)
#else
#define LAMEXP_INIT_QT_STATIC_PLUGIN(X)
#endif
///////////////////////////////////////////////////////////////////////////////
// TYPES
///////////////////////////////////////////////////////////////////////////////
@ -91,6 +99,9 @@ static QSystemSemaphore *g_lamexp_semaphore_read_ptr = NULL;
static const char *g_lamexp_semaphore_write_uuid = "{60AA8D04-F6B8-497d-81EB-0F600F4A65B5}";
static QSystemSemaphore *g_lamexp_semaphore_write_ptr = NULL;
//Image formats
static const char *g_lamexp_imageformats[] = {"png", "gif", "ico", "svg", NULL};
///////////////////////////////////////////////////////////////////////////////
// GLOBAL FUNCTIONS
///////////////////////////////////////////////////////////////////////////////
@ -189,12 +200,6 @@ void lamexp_init_console(int argc, char* argv[])
}
}
/* Disable nasty warning */
#if !defined(QT_DLL) || defined(QT_NODLL)
#pragma warning(push)
#pragma warning(disable:4101)
#endif
/*
* Initialize Qt framework
*/
@ -213,7 +218,7 @@ bool lamexp_init_qt(int argc, char* argv[])
QT_REQUIRE_VERSION(argc, argv, QT_VERSION_STR);
//Check the Windows version
switch(QSysInfo::WindowsVersion)
switch(QSysInfo::windowsVersion() & QSysInfo::WV_NT_based)
{
case QSysInfo::WV_2000:
qDebug("Running on Windows 2000 (not offically supported!).\n");
@ -247,18 +252,19 @@ bool lamexp_init_qt(int argc, char* argv[])
QCoreApplication::setLibraryPaths(QStringList() << QApplication::applicationDirPath());
qDebug("Library Path:\n%s\n", QApplication::libraryPaths().first().toUtf8().constData());
//Initialize static Qt plugins
#ifndef QT_DLL
Q_IMPORT_PLUGIN(qsvg);
Q_IMPORT_PLUGIN(qico);
#endif
//Init static Qt plugins
LAMEXP_INIT_QT_STATIC_PLUGIN(qico);
LAMEXP_INIT_QT_STATIC_PLUGIN(qsvg);
//Check for supported image formats
QList<QByteArray> supportedFormats = QImageReader::supportedImageFormats();
if(!(supportedFormats.contains("png") && supportedFormats.contains("gif") && supportedFormats.contains("ico") && supportedFormats.contains("svg")))
for(int i = 0; g_lamexp_imageformats[i]; i++)
{
qFatal("Qt initialization error: At least one image format plugin is missing!");
return false;
if(!supportedFormats.contains(g_lamexp_imageformats[i]))
{
qFatal("Qt initialization error: At least one image format plugin is missing! (%s)", g_lamexp_imageformats[i]);
return false;
}
}
//Change application look
@ -269,11 +275,6 @@ bool lamexp_init_qt(int argc, char* argv[])
return true;
}
/* Re-enable the warning */
#if !defined(QT_DLL) || defined(QT_NODLL)
#pragma warning(pop)
#endif
/*
* Initialize IPC
*/

View File

@ -47,6 +47,10 @@ FileAnalyzer::FileAnalyzer(const QStringList &inputFiles)
{
qFatal("Invalid path to MediaInfo binary. Tool not initialized properly.");
}
m_filesAccepted = 0;
m_filesRejected = 0;
m_filesDenied = 0;
}
////////////////////////////////////////////////////////////
@ -56,6 +60,11 @@ FileAnalyzer::FileAnalyzer(const QStringList &inputFiles)
void FileAnalyzer::run()
{
m_bSuccess = false;
m_filesAccepted = 0;
m_filesRejected = 0;
m_filesDenied = 0;
m_inputFiles.sort();
while(!m_inputFiles.isEmpty())
@ -66,9 +75,11 @@ void FileAnalyzer::run()
AudioFileModel file = analyzeFile(currentFile);
if(file.fileName().isEmpty() || file.formatContainerType().isEmpty() || file.formatAudioType().isEmpty())
{
m_filesRejected++;
qDebug("Skipped: %s", file.filePath().toUtf8().constData());
continue;
}
m_filesAccepted++;
emit fileAnalyzed(file);
}
@ -89,6 +100,7 @@ const AudioFileModel FileAnalyzer::analyzeFile(const QString &filePath)
if(!readTest.open(QIODevice::ReadOnly))
{
qWarning("Cannot access file for reading, skipping!");
m_filesDenied++;
return audioFile;
}
else
@ -323,6 +335,20 @@ unsigned int FileAnalyzer::parseDuration(const QString &str)
return 0;
}
unsigned int FileAnalyzer::filesAccepted(void)
{
return m_filesAccepted;
}
unsigned int FileAnalyzer::filesRejected(void)
{
return m_filesRejected - m_filesDenied;
}
unsigned int FileAnalyzer::filesDenied(void)
{
return m_filesDenied;
}
////////////////////////////////////////////////////////////
// EVENTS

View File

@ -40,6 +40,9 @@ public:
FileAnalyzer(const QStringList &inputFiles);
void run();
bool getSuccess(void) { return !isRunning() && m_bSuccess; }
unsigned int filesAccepted(void);
unsigned int filesRejected(void);
unsigned int filesDenied(void);
signals:
void fileSelected(const QString &fileName);
@ -62,5 +65,8 @@ private:
QStringList m_inputFiles;
QString m_mediaInfoBin;
section_t m_currentSection;
unsigned int m_filesAccepted;
unsigned int m_filesRejected;
unsigned int m_filesDenied;
bool m_bSuccess;
};