Filename filter for supported types in "Add file(s)" dialog.

This commit is contained in:
LoRd_MuldeR 2010-12-20 22:13:01 +01:00
parent 6c139ab640
commit 658efda273
24 changed files with 99 additions and 11 deletions

View File

@ -109,6 +109,7 @@ IDR_WAVE_ABOUT WAVE "res\\sounds\\uuaarrgh.wav"
IDR_WAVE_SUCCESS WAVE "res\\sounds\\success.wav" IDR_WAVE_SUCCESS WAVE "res\\sounds\\success.wav"
IDR_WAVE_ERROR WAVE "res\\sounds\\error.wav" IDR_WAVE_ERROR WAVE "res\\sounds\\error.wav"
IDR_WAVE_ABORTED WAVE "res\\sounds\\aborted.wav" IDR_WAVE_ABORTED WAVE "res\\sounds\\aborted.wav"
IDR_WAVE_WHAMMY WAVE "res\\sounds\\whammy.wav"
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //

View File

@ -1660,10 +1660,6 @@
/> />
</FileConfiguration> </FileConfiguration>
</File> </File>
<File
RelativePath=".\res\sounds\uuaarrgh.wav"
>
</File>
</Filter> </Filter>
<Filter <Filter
Name="Dialogs" Name="Dialogs"

BIN
res/sounds/whammy.wav Normal file

Binary file not shown.

View File

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

View File

@ -117,9 +117,10 @@ bool AACDecoder::isFormatSupported(const QString &containerType, const QString &
{ {
if(formatType.compare("AAC", Qt::CaseInsensitive) == 0) if(formatType.compare("AAC", Qt::CaseInsensitive) == 0)
{ {
if(formatProfile.compare("LC", Qt::CaseInsensitive) == 0 || formatProfile.compare("HE", Qt::CaseInsensitive) == 0) QStringList profileParts = formatProfile.split(" ", QString::SkipEmptyParts);
if(profileParts.contains("LC", Qt::CaseInsensitive) || profileParts.contains("HE-AAC", Qt::CaseInsensitive) || profileParts.contains("HE-AACv2", Qt::CaseInsensitive))
{ {
if(formatVersion.compare("Version 2", Qt::CaseInsensitive) == 0 || formatVersion.compare("Version 4", Qt::CaseInsensitive) == 0) if(formatVersion.compare("Version 2", Qt::CaseInsensitive) == 0 || formatVersion.compare("Version 4", Qt::CaseInsensitive) == 0 || formatVersion.isEmpty())
{ {
return true; return true;
} }
@ -130,3 +131,7 @@ bool AACDecoder::isFormatSupported(const QString &containerType, const QString &
return false; return false;
} }
QStringList AACDecoder::supportedTypes(void)
{
return QStringList() << "Advanced Audio Coding (*.aac *.mp4)";
}

View File

@ -31,6 +31,7 @@ public:
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static QStringList supportedTypes(void);
private: private:
const QString m_binary; const QString m_binary;

View File

@ -138,3 +138,8 @@ bool AC3Decoder::isFormatSupported(const QString &containerType, const QString &
return false; return false;
} }
QStringList AC3Decoder::supportedTypes(void)
{
return QStringList() << "AC-3 aka ATSC A/52 (*.ac3)" << "Digital Theater System (*.dts)";
}

View File

@ -31,6 +31,7 @@ public:
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static QStringList supportedTypes(void);
private: private:
const QString m_binary; const QString m_binary;

View File

@ -21,6 +21,8 @@
#include "Decoder_Abstract.h" #include "Decoder_Abstract.h"
#include <QStringList>
AbstractDecoder::AbstractDecoder(void) AbstractDecoder::AbstractDecoder(void)
{ {
} }
@ -42,3 +44,8 @@ bool AbstractDecoder::isDecoderAvailable(void)
{ {
return true; return true;
} }
QStringList AbstractDecoder::supportedTypes(void)
{
return QStringList();
}

View File

@ -35,5 +35,6 @@ public:
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag) = 0; virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag) = 0;
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static bool isDecoderAvailable(void); static bool isDecoderAvailable(void);
static QStringList supportedTypes(void);
}; };

View File

@ -114,7 +114,7 @@ bool FLACDecoder::decode(const QString &sourceFile, const QString &outputFile, v
bool FLACDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion) bool FLACDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
{ {
if(containerType.compare("FLAC", Qt::CaseInsensitive) == 0) if(containerType.compare("FLAC", Qt::CaseInsensitive) == 0 || containerType.compare("OGG", Qt::CaseInsensitive) == 0)
{ {
if(formatType.compare("FLAC", Qt::CaseInsensitive) == 0) if(formatType.compare("FLAC", Qt::CaseInsensitive) == 0)
{ {
@ -125,3 +125,7 @@ bool FLACDecoder::isFormatSupported(const QString &containerType, const QString
return false; return false;
} }
QStringList FLACDecoder::supportedTypes(void)
{
return QStringList() << "Free Lossless Audio Codec (*.flac *.fla)";
}

View File

@ -31,6 +31,7 @@ public:
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static QStringList supportedTypes(void);
private: private:
const QString m_binary; const QString m_binary;

View File

@ -140,3 +140,8 @@ bool MP3Decoder::isFormatSupported(const QString &containerType, const QString &
return false; return false;
} }
QStringList MP3Decoder::supportedTypes(void)
{
return QStringList() << "MPEG Audio Layer III (*.mp3 *.mpa)" << "MPEG Audio Layer II (*.mp2 *.mpa)" << "MPEG Audio Layer I ( *.mp1 *.mpa)";
}

View File

@ -31,6 +31,7 @@ public:
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static QStringList supportedTypes(void);
private: private:
const QString m_binary; const QString m_binary;

View File

@ -124,3 +124,7 @@ bool VorbisDecoder::isFormatSupported(const QString &containerType, const QStrin
return false; return false;
} }
QStringList VorbisDecoder::supportedTypes(void)
{
return QStringList() << "Ogg Vorbis (*.ogg *.ogm)";
}

View File

@ -31,6 +31,7 @@ public:
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static QStringList supportedTypes(void);
private: private:
const QString m_binary; const QString m_binary;

View File

@ -137,3 +137,8 @@ bool WMADecoder::isDecoderAvailable(void)
{ {
return lamexp_check_tool("wmawav.exe"); return lamexp_check_tool("wmawav.exe");
} }
QStringList WMADecoder::supportedTypes(void)
{
return QStringList() << "Windows Media Audio (*.wma)";
}

View File

@ -34,6 +34,7 @@ public:
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static bool isDecoderAvailable(void); static bool isDecoderAvailable(void);
static QStringList supportedTypes(void);
private: private:
const QString m_binary; const QString m_binary;

View File

@ -86,3 +86,7 @@ bool WaveDecoder::isFormatSupported(const QString &containerType, const QString
return false; return false;
} }
QStringList WaveDecoder::supportedTypes(void)
{
return QStringList() << "Waveform Audio File (*.wav)";
}

View File

@ -31,4 +31,5 @@ public:
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static QStringList supportedTypes(void);
}; };

View File

@ -35,6 +35,7 @@
#include "Model_FileList.h" #include "Model_FileList.h"
#include "Model_FileSystem.h" #include "Model_FileSystem.h"
#include "WinSevenTaskbar.h" #include "WinSevenTaskbar.h"
#include "Registry_Decoder.h"
//Qt includes //Qt includes
#include <QMessageBox> #include <QMessageBox>
@ -469,6 +470,7 @@ void MainWindow::windowShown(void)
if(iAccepted <= 0) if(iAccepted <= 0)
{ {
m_settings->licenseAccepted(-1); m_settings->licenseAccepted(-1);
PlaySound(MAKEINTRESOURCE(IDR_WAVE_WHAMMY), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
QMessageBox::critical(this, "License Declined", "You have declined the license. Consequently the application will exit now!"); QMessageBox::critical(this, "License Declined", "You have declined the license. Consequently the application will exit now!");
QApplication::quit(); QApplication::quit();
return; return;
@ -484,6 +486,7 @@ void MainWindow::windowShown(void)
if(QDate::currentDate() >= expireDate) if(QDate::currentDate() >= expireDate)
{ {
qWarning("Binary has expired !!!"); qWarning("Binary has expired !!!");
PlaySound(MAKEINTRESOURCE(IDR_WAVE_WHAMMY), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
if(QMessageBox::warning(this, "LameXP - Expired", QString("This demo (pre-release) version of LameXP has expired at %1.\nLameXP is free software and release versions won't expire.").arg(expireDate.toString(Qt::ISODate)), "Check for Updates", "Exit Program") == 0) if(QMessageBox::warning(this, "LameXP - Expired", QString("This demo (pre-release) version of LameXP has expired at %1.\nLameXP is free software and release versions won't expire.").arg(expireDate.toString(Qt::ISODate)), "Check for Updates", "Exit Program") == 0)
{ {
checkUpdatesActionActivated(); checkUpdatesActionActivated();
@ -540,8 +543,8 @@ void MainWindow::windowShown(void)
QString messageText; QString messageText;
messageText += "<nobr>The Nero AAC encoder could not be found. AAC encoding support will be disabled.<br>"; messageText += "<nobr>The Nero AAC encoder could not be found. AAC encoding support will be disabled.<br>";
messageText += "Please put 'neroAacEnc.exe', 'neroAacDec.exe' and 'neroAacTag.exe' into the LameXP directory!<br><br>"; messageText += "Please put 'neroAacEnc.exe', 'neroAacDec.exe' and 'neroAacTag.exe' into the LameXP directory!<br><br>";
messageText += "Your LameXP directory is as follows:<br>"; messageText += "Your LameXP directory is located here:<br>";
messageText += "<i><nobr>" + QDir::toNativeSeparators(QCoreApplication::applicationDirPath()) + "</nobr></i><br><br>"; messageText += QString("<i><nobr><a href=\"file:///%1\">%1</a></nobr></i><br><br>").arg(QDir::toNativeSeparators(QCoreApplication::applicationDirPath()));
messageText += "You can download the Nero AAC encoder for free from the official Nero website at:<br>"; messageText += "You can download the Nero AAC encoder for free from the official Nero website at:<br>";
messageText += "<b>" + LINK(AboutDialog::neroAacUrl) + "</b><br></nobr>"; messageText += "<b>" + LINK(AboutDialog::neroAacUrl) + "</b><br></nobr>";
QMessageBox::information(this, "AAC Support Disabled", messageText); QMessageBox::information(this, "AAC Support Disabled", messageText);
@ -612,6 +615,7 @@ void MainWindow::encodeButtonClicked(void)
{ {
QStringList tempFolderParts = lamexp_temp_folder().split("/", QString::SkipEmptyParts, Qt::CaseInsensitive); QStringList tempFolderParts = lamexp_temp_folder().split("/", QString::SkipEmptyParts, Qt::CaseInsensitive);
tempFolderParts.takeLast(); tempFolderParts.takeLast();
if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_WHAMMY), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
switch(QMessageBox::warning(this, "Low Diskspace Warning", QString("<nobr>There are less than %1 GB of free diskspace available on your system's TEMP folder.</nobr><br><nobr>It is highly recommend to free up more diskspace before proceeding with the encode!.</nobr><br><br>Your TEMP folder is located at:<br><nobr><i><a href=\"file:///%3\">%3</a></i></nobr><br>").arg(QString::number(minimumFreeDiskspaceMultiplier), tempFolderParts.join("\\")), "Abort Encoding Process", "Clean Disk Now", "Ignore")) switch(QMessageBox::warning(this, "Low Diskspace Warning", QString("<nobr>There are less than %1 GB of free diskspace available on your system's TEMP folder.</nobr><br><nobr>It is highly recommend to free up more diskspace before proceeding with the encode!.</nobr><br><br>Your TEMP folder is located at:<br><nobr><i><a href=\"file:///%3\">%3</a></i></nobr><br>").arg(QString::number(minimumFreeDiskspaceMultiplier), tempFolderParts.join("\\")), "Abort Encoding Process", "Clean Disk Now", "Ignore"))
{ {
case 1: case 1:
@ -674,7 +678,8 @@ void MainWindow::closeButtonClicked(void)
void MainWindow::addFilesButtonClicked(void) void MainWindow::addFilesButtonClicked(void)
{ {
ABORT_IF_BUSY; ABORT_IF_BUSY;
QStringList selectedFiles = QFileDialog::getOpenFileNames(this, "Add file(s)", QString(), "All supported files (*.*)"); QStringList fileTypeFilters = DecoderRegistry::getSupportedTypes();
QStringList selectedFiles = QFileDialog::getOpenFileNames(this, "Add file(s)", QString(), fileTypeFilters.join(";;"));
addFiles(selectedFiles); addFiles(selectedFiles);
} }

View File

@ -30,8 +30,11 @@
#include "Decoder_Wave.h" #include "Decoder_Wave.h"
#include <QString> #include <QString>
#include <QStringList>
#include <QRegExp>
#define PROBE_DECODER(DEC) if(DEC::isDecoderAvailable() && DEC::isFormatSupported(containerType, containerProfile, formatType, formatProfile, formatVersion)) { return new DEC(); } #define PROBE_DECODER(DEC) if(DEC::isDecoderAvailable() && DEC::isFormatSupported(containerType, containerProfile, formatType, formatProfile, formatVersion)) { return new DEC(); }
#define GET_FILETYPES(DEC) (DEC::isDecoderAvailable() ? DEC::supportedTypes() : QStringList())
AbstractDecoder *DecoderRegistry::lookup(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion) AbstractDecoder *DecoderRegistry::lookup(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
{ {
@ -45,3 +48,36 @@ AbstractDecoder *DecoderRegistry::lookup(const QString &containerType, const QSt
return NULL; return NULL;
} }
QStringList DecoderRegistry::getSupportedTypes(void)
{
QStringList types;
types << GET_FILETYPES(WaveDecoder);
types << GET_FILETYPES(MP3Decoder);
types << GET_FILETYPES(VorbisDecoder);
types << GET_FILETYPES(AACDecoder);
types << GET_FILETYPES(AC3Decoder);
types << GET_FILETYPES(FLACDecoder);
types << GET_FILETYPES(WMADecoder);
QStringList extensions;
QRegExp regExp("\\((.+)\\)", Qt::CaseInsensitive);
for(int i = 0; i < types.count(); i++)
{
if(regExp.lastIndexIn(types.at(i)) >= 0)
{
extensions << regExp.cap(1).split(" ", QString::SkipEmptyParts);
}
}
if(!extensions.empty())
{
extensions.removeDuplicates();
extensions.sort();
types.prepend(QString("All supported types (%1)").arg(extensions.join(" ")));
}
types << "All files (*.*)";
return types;
}

View File

@ -22,10 +22,12 @@
#pragma once #pragma once
class QString; class QString;
class QStringList;
class AbstractDecoder; class AbstractDecoder;
class DecoderRegistry class DecoderRegistry
{ {
public: public:
static AbstractDecoder *lookup(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static AbstractDecoder *lookup(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static QStringList DecoderRegistry::getSupportedTypes(void);
}; };

View File

@ -29,6 +29,7 @@
#define IDR_WAVE_SUCCESS 667 #define IDR_WAVE_SUCCESS 667
#define IDR_WAVE_ERROR 668 #define IDR_WAVE_ERROR 668
#define IDR_WAVE_ABORTED 669 #define IDR_WAVE_ABORTED 669
#define IDR_WAVE_WHAMMY 670
/* /*
* Next default values for new objects * Next default values for new objects