diff --git a/gui/MainWindow.ui b/gui/MainWindow.ui
index 679524b1..936b37f7 100644
--- a/gui/MainWindow.ui
+++ b/gui/MainWindow.ui
@@ -713,11 +713,14 @@
-
- 4
+ 0
50
+
+ 1
+
24
@@ -734,12 +737,12 @@
QSlider::TicksBelow
- 5
+ 1
-
-
+
Minimum
@@ -749,7 +752,7 @@
-
-
+
Maximum
@@ -760,9 +763,55 @@
-
+
+
+
+
+
+
+ 0
+ 0
+ 255
+
+
+
+
+
+
+
+
+ 0
+ 0
+ 255
+
+
+
+
+
+
+
+
+ 120
+ 120
+ 120
+
+
+
+
+
+
+
+
+ 75
+ true
+
+
(VALUE)
+
+ Qt::RichText
+
Qt::AlignHCenter|Qt::AlignTop
@@ -1289,6 +1338,12 @@
+
+
+
+
+
+
diff --git a/res/Tools.qrc b/res/Tools.qrc
index 3b19bf8f..df16360d 100644
--- a/res/Tools.qrc
+++ b/res/Tools.qrc
@@ -1,28 +1,27 @@
-
- tools/alac.exe
- tools/faad.exe
- tools/flac.exe
- tools/gpgv.exe
- tools/lame.exe
- tools/MAC.exe
- tools/mediainfo_icl11.exe
-
- tools/mpcdec.exe
- tools/mpg123.exe
- tools/oggdec.exe
- tools/oggenc2_gen.exe
- tools/oggenc2_p4.exe
- tools/selfdelete.exe
- tools/shorten.exe
- tools/speexdec.exe
- tools/takc.exe
- tools/ttaenc.exe
- tools/valdec.exe
- tools/volumax.exe
- tools/wget.exe
- tools/wupdate.exe
- tools/wvunpack.exe
-
+
+ tools/alac.exe
+ tools/faad.exe
+ tools/flac.exe
+ tools/gpgv.exe
+ tools/lame.exe
+ tools/MAC.exe
+ tools/mediainfo_icl11.exe
+ tools/mpcdec.exe
+ tools/mpg123.exe
+ tools/oggdec.exe
+ tools/oggenc2_gen.exe
+ tools/oggenc2_p4.exe
+ tools/selfdelete.exe
+ tools/shorten.exe
+ tools/speexdec.exe
+ tools/takc.exe
+ tools/ttaenc.exe
+ tools/valdec.exe
+ tools/volumax.exe
+ tools/wget.exe
+ tools/wupdate.exe
+ tools/wvunpack.exe
+
diff --git a/src/Config.h b/src/Config.h
index 35a43cb9..367596f6 100644
--- a/src/Config.h
+++ b/src/Config.h
@@ -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 13
+#define VER_LAMEXP_BUILD 20
#define VER_LAMEXP_SUFFIX TechPreview
/*
diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp
index c2e4df52..e0329fd0 100644
--- a/src/Dialog_MainWindow.cpp
+++ b/src/Dialog_MainWindow.cpp
@@ -49,6 +49,8 @@
#include
#include
#include
+#include
+#include
//Win32 includes
#include
@@ -81,6 +83,7 @@ MainWindow::MainWindow(QWidget *parent)
{
//Init the dialog, from the .ui file
setupUi(this);
+ setWindowFlags(windowFlags() ^ Qt::WindowMaximizeButtonHint);
//Register meta types
qRegisterMetaType("AudioFileModel");
@@ -93,6 +96,7 @@ MainWindow::MainWindow(QWidget *parent)
//Load configuration
m_settings = new SettingsModel();
+ m_settings->validate();
//Enabled main buttons
connect(buttonAbout, SIGNAL(clicked()), this, SLOT(aboutButtonClicked()));
@@ -145,9 +149,29 @@ MainWindow::MainWindow(QWidget *parent)
connect(buttonClearMeta, SIGNAL(clicked()), this, SLOT(clearMetaButtonClicked()));
//Setup "Compression" tab
- sliderBitrate->setValue(24);
+ m_encoderButtonGroup = new QButtonGroup(this);
+ m_encoderButtonGroup->addButton(radioButtonEncoderMP3, SettingsModel::MP3Encoder);
+ m_encoderButtonGroup->addButton(radioButtonEncoderVorbis, SettingsModel::VorbisEncoder);
+ m_encoderButtonGroup->addButton(radioButtonEncoderAAC, SettingsModel::AACEncoder);
+ m_encoderButtonGroup->addButton(radioButtonEncoderFLAC, SettingsModel::FLACEncoder);
+ m_encoderButtonGroup->addButton(radioButtonEncoderPCM, SettingsModel::PCMEncoder);
+ m_modeButtonGroup = new QButtonGroup(this);
+ m_modeButtonGroup->addButton(radioButtonModeQuality, SettingsModel::VBRMode);
+ m_modeButtonGroup->addButton(radioButtonModeAverageBitrate, SettingsModel::ABRMode);
+ m_modeButtonGroup->addButton(radioButtonConstBitrate, SettingsModel::CBRMode);
+ radioButtonEncoderMP3->setChecked(m_settings->compressionEncoder() == SettingsModel::MP3Encoder);
+ radioButtonEncoderVorbis->setChecked(m_settings->compressionEncoder() == SettingsModel::VorbisEncoder);
+ radioButtonEncoderAAC->setChecked(m_settings->compressionEncoder() == SettingsModel::AACEncoder);
+ radioButtonEncoderFLAC->setChecked(m_settings->compressionEncoder() == SettingsModel::FLACEncoder);
+ radioButtonEncoderPCM->setChecked(m_settings->compressionEncoder() == SettingsModel::PCMEncoder);
+ radioButtonModeQuality->setChecked(m_settings->compressionRCMode() == SettingsModel::VBRMode);
+ radioButtonModeAverageBitrate->setChecked(m_settings->compressionRCMode() == SettingsModel::ABRMode);
+ radioButtonConstBitrate->setChecked(m_settings->compressionRCMode() == SettingsModel::CBRMode);
+ sliderBitrate->setValue(m_settings->compressionBitrate());
+ connect(m_encoderButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(updateEncoder(int)));
+ connect(m_modeButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(updateRCMode(int)));
connect(sliderBitrate, SIGNAL(valueChanged(int)), this, SLOT(updateBitrate(int)));
- updateBitrate(sliderBitrate->value());
+ updateEncoder(m_encoderButtonGroup->checkedId());
//Activate file menu actions
connect(actionOpenFolder, SIGNAL(triggered()), this, SLOT(openFolderActionActivated()));
@@ -245,6 +269,7 @@ MainWindow::~MainWindow(void)
LAMEXP_DELETE(m_metaData);
LAMEXP_DELETE(m_metaInfoModel);
LAMEXP_DELETE(m_settings);
+ LAMEXP_DELETE(m_encoderButtonGroup);
}
////////////////////////////////////////////////////////////
@@ -355,17 +380,17 @@ void MainWindow::windowShown(void)
if(iAccepted <= 0)
{
- m_settings->setLicenseAccepted(-1);
+ m_settings->licenseAccepted(-1);
QMessageBox::critical(this, "License Declined", "You have declined the license. Consequently the application will exit now!");
QApplication::quit();
return;
}
- m_settings->setLicenseAccepted(1);
+ m_settings->licenseAccepted(1);
}
//Check for AAC support
- if(lamexp_check_tool("neroAacEnc.exe") && lamexp_check_tool("neroAacDec.exe") && lamexp_check_tool("neroAacTag.exe"))
+ if(radioButtonEncoderAAC->isEnabled())
{
if(lamexp_tool_version("neroAacEnc.exe") < lamexp_toolver_neroaac())
{
@@ -376,7 +401,6 @@ void MainWindow::windowShown(void)
messageText += "" + LINK(AboutDialog::neroAacUrl) + "
";
QMessageBox::information(this, "AAC Encoder Outdated", messageText);
}
- radioButtonEncoderAAC->setEnabled(true);
}
else
{
@@ -386,7 +410,6 @@ void MainWindow::windowShown(void)
messageText += "You can download the Nero AAC encoder for free from the official Nero website at:
";
messageText += "" + LINK(AboutDialog::neroAacUrl) + "
";
QMessageBox::information(this, "AAC Support Disabled", messageText);
- radioButtonEncoderAAC->setEnabled(false);
}
//Add files from the command-line
@@ -573,7 +596,7 @@ void MainWindow::styleActionActivated(QAction *action)
{
if(action && action->userData(0))
{
- m_settings->setInterfaceStyle(dynamic_cast(action->userData(0))->value());
+ m_settings->interfaceStyle(dynamic_cast(action->userData(0))->value());
}
switch(m_settings->interfaceStyle())
@@ -801,10 +824,178 @@ void MainWindow::handleDelayedFiles(void)
addFiles(selectedFiles);
}
+/*
+ * Update encoder
+ */
+void MainWindow::updateEncoder(int id)
+{
+ m_settings->compressionEncoder(id);
+
+ switch(m_settings->compressionEncoder())
+ {
+ case SettingsModel::VorbisEncoder:
+ radioButtonModeQuality->setEnabled(true);
+ radioButtonModeAverageBitrate->setEnabled(true);
+ radioButtonConstBitrate->setEnabled(false);
+ if(radioButtonConstBitrate->isChecked()) radioButtonModeQuality->setChecked(true);
+ sliderBitrate->setEnabled(true);
+ break;
+ case SettingsModel::FLACEncoder:
+ radioButtonModeQuality->setEnabled(false);
+ radioButtonModeQuality->setChecked(true);
+ radioButtonModeAverageBitrate->setEnabled(false);
+ radioButtonConstBitrate->setEnabled(false);
+ sliderBitrate->setEnabled(true);
+ break;
+ case SettingsModel::PCMEncoder:
+ radioButtonModeQuality->setEnabled(false);
+ radioButtonModeQuality->setChecked(true);
+ radioButtonModeAverageBitrate->setEnabled(false);
+ radioButtonConstBitrate->setEnabled(false);
+ sliderBitrate->setEnabled(false);
+ break;
+ default:
+ radioButtonModeQuality->setEnabled(true);
+ radioButtonModeAverageBitrate->setEnabled(true);
+ radioButtonConstBitrate->setEnabled(true);
+ sliderBitrate->setEnabled(true);
+ break;
+ }
+
+ updateRCMode(m_modeButtonGroup->checkedId());
+}
+
+/*
+ * Update rate-control mode
+ */
+void MainWindow::updateRCMode(int id)
+{
+ m_settings->compressionRCMode(id);
+
+ switch(m_settings->compressionEncoder())
+ {
+ case SettingsModel::MP3Encoder:
+ switch(m_settings->compressionRCMode())
+ {
+ case SettingsModel::VBRMode:
+ sliderBitrate->setMinimum(0);
+ sliderBitrate->setMaximum(9);
+ break;
+ default:
+ sliderBitrate->setMinimum(2);
+ sliderBitrate->setMaximum(20);
+ break;
+ }
+ break;
+ case SettingsModel::VorbisEncoder:
+ switch(m_settings->compressionRCMode())
+ {
+ case SettingsModel::VBRMode:
+ sliderBitrate->setMinimum(-2);
+ sliderBitrate->setMaximum(10);
+ break;
+ default:
+ sliderBitrate->setMinimum(4);
+ sliderBitrate->setMaximum(63);
+ break;
+ }
+ break;
+ case SettingsModel::AACEncoder:
+ switch(m_settings->compressionRCMode())
+ {
+ case SettingsModel::VBRMode:
+ sliderBitrate->setMinimum(0);
+ sliderBitrate->setMaximum(20);
+ break;
+ default:
+ sliderBitrate->setMinimum(4);
+ sliderBitrate->setMaximum(63);
+ break;
+ }
+ break;
+ case SettingsModel::FLACEncoder:
+ sliderBitrate->setMinimum(0);
+ sliderBitrate->setMaximum(8);
+ break;
+ case SettingsModel::PCMEncoder:
+ sliderBitrate->setMinimum(0);
+ sliderBitrate->setMaximum(2);
+ sliderBitrate->setValue(1);
+ break;
+ default:
+ sliderBitrate->setMinimum(0);
+ sliderBitrate->setMaximum(0);
+ break;
+ }
+
+ updateBitrate(sliderBitrate->value());
+}
+
/*
* Update bitrate
*/
void MainWindow::updateBitrate(int value)
{
- labelBitrate->setText(QString("%1 kbps").arg(value * 8));
+ m_settings->compressionBitrate(value);
+
+ switch(m_settings->compressionRCMode())
+ {
+ case SettingsModel::VBRMode:
+ switch(m_settings->compressionEncoder())
+ {
+ case SettingsModel::MP3Encoder:
+ labelBitrate->setText(QString("Quality Level %1").arg(9 - value));
+ break;
+ case SettingsModel::VorbisEncoder:
+ labelBitrate->setText(QString("Quality Level %1").arg(value));
+ break;
+ case SettingsModel::AACEncoder:
+ labelBitrate->setText(QString("Quality Level %1").arg(QString().sprintf("%.2f", static_cast(value * 5) / 100.0)));
+ break;
+ case SettingsModel::FLACEncoder:
+ labelBitrate->setText(QString("Compression %1").arg(value));
+ break;
+ case SettingsModel::PCMEncoder:
+ labelBitrate->setText("Uncompressed");
+ break;
+ default:
+ labelBitrate->setText(QString::number(value));
+ break;
+ }
+ break;
+ case SettingsModel::ABRMode:
+ switch(m_settings->compressionEncoder())
+ {
+ case SettingsModel::MP3Encoder:
+ labelBitrate->setText(QString("≈ %1 kbps").arg(value * 16));
+ break;
+ case SettingsModel::FLACEncoder:
+ labelBitrate->setText(QString("Compression %1").arg(value));
+ break;
+ case SettingsModel::PCMEncoder:
+ labelBitrate->setText("Uncompressed");
+ break;
+ default:
+ labelBitrate->setText(QString("≈ %1 kbps").arg(min(500, value * 8)));
+ break;
+ }
+ break;
+ default:
+ switch(m_settings->compressionEncoder())
+ {
+ case SettingsModel::MP3Encoder:
+ labelBitrate->setText(QString("%1 kbps").arg(value * 16));
+ break;
+ case SettingsModel::FLACEncoder:
+ labelBitrate->setText(QString("Compression %1").arg(value));
+ break;
+ case SettingsModel::PCMEncoder:
+ labelBitrate->setText("Uncompressed");
+ break;
+ default:
+ labelBitrate->setText(QString("%1 kbps").arg(min(500, value * 8)));
+ break;
+ }
+ break;
+ }
}
diff --git a/src/Dialog_MainWindow.h b/src/Dialog_MainWindow.h
index 0837c089..809a53e7 100644
--- a/src/Dialog_MainWindow.h
+++ b/src/Dialog_MainWindow.h
@@ -32,6 +32,7 @@ class MessageHandlerThread;
class AudioFileModel;
class MetaInfoModel;
class SettingsModel;
+class QButtonGroup;
class MainWindow: public QMainWindow, private Ui::MainWindow
{
@@ -67,6 +68,8 @@ private slots:
void handleDelayedFiles(void);
void editMetaButtonClicked(void);
void clearMetaButtonClicked(void);
+ void updateEncoder(int id);
+ void updateRCMode(int id);
void updateBitrate(int value);
protected:
@@ -81,6 +84,8 @@ private:
QFileSystemModel *m_fileSystemModel;
QActionGroup *m_tabActionGroup;
QActionGroup *m_styleActionGroup;
+ QButtonGroup *m_encoderButtonGroup;
+ QButtonGroup *m_modeButtonGroup;
WorkingBanner *m_banner;
MessageHandlerThread *m_messageHandler;
QStringList *m_delayedFileList;
diff --git a/src/Global.cpp b/src/Global.cpp
index 2fe8a921..5ba9d28e 100644
--- a/src/Global.cpp
+++ b/src/Global.cpp
@@ -44,6 +44,7 @@
#include
#include
#include
+#include
//Debug only includes
#ifdef _DEBUG
@@ -121,7 +122,8 @@ unsigned int lamexp_toolver_neroaac(void) { return g_lamexp_toolver_neroaac; }
bool lamexp_version_demo(void)
{
- return !(strstr(g_lamexp_version_release, "Final") || strstr(g_lamexp_version_release, "Hotfix"));
+
+ return LAMEXP_DEBUG || !(strstr(g_lamexp_version_release, "Final") || strstr(g_lamexp_version_release, "Hotfix"));
}
/*
@@ -205,6 +207,66 @@ void lamexp_init_console(int argc, char* argv[])
}
}
+/*
+ * Detect CPU features
+ */
+lamexp_cpu_t lamexp_detect_cpu_features(void)
+{
+ lamexp_cpu_t features;
+ memset(&features, 0, sizeof(lamexp_cpu_t));
+
+ int CPUInfo[4] = {-1};
+
+ __cpuid(CPUInfo, 0);
+ if(CPUInfo[0] >= 1)
+ {
+ __cpuid(CPUInfo, 1);
+ features.mmx = (CPUInfo[3] & 0x800000) || false;
+ features.sse = (CPUInfo[3] & 0x2000000) || false;
+ features.sse2 = (CPUInfo[3] & 0x4000000) || false;
+ features.ssse3 = (CPUInfo[2] & 0x200) || false;
+ features.sse3 = (CPUInfo[2] & 0x1) || false;
+ features.ssse3 = (CPUInfo[2] & 0x200) || false;
+ features.stepping = CPUInfo[0] & 0xf;
+ features.model = ((CPUInfo[0] >> 4) & 0xf) + (((CPUInfo[0] >> 16) & 0xf) << 4);
+ features.family = ((CPUInfo[0] >> 8) & 0xf) + ((CPUInfo[0] >> 20) & 0xff);
+ }
+
+ char CPUBrandString[0x40];
+ memset(CPUBrandString, 0, sizeof(CPUBrandString));
+ __cpuid(CPUInfo, 0x80000000);
+ int nExIds = CPUInfo[0];
+
+ for(int i = 0x80000000; i <= nExIds; ++i)
+ {
+ __cpuid(CPUInfo, i);
+ if(i == 0x80000002) memcpy(CPUBrandString, CPUInfo, sizeof(CPUInfo));
+ else if(i == 0x80000003) memcpy(CPUBrandString + 16, CPUInfo, sizeof(CPUInfo));
+ else if(i == 0x80000004) memcpy(CPUBrandString + 32, CPUInfo, sizeof(CPUInfo));
+ }
+
+ strcpy_s(features.brand, 0x40, CPUBrandString);
+ return features;
+}
+
+/*
+ * Check for debugger
+ */
+void WINAPI debugThreadProc(__in LPVOID lpParameter)
+{
+ BOOL remoteDebuggerPresent = FALSE;
+ CheckRemoteDebuggerPresent(GetCurrentProcess, &remoteDebuggerPresent);
+
+ while(!IsDebuggerPresent() && !remoteDebuggerPresent)
+ {
+ Sleep(333);
+ CheckRemoteDebuggerPresent(GetCurrentProcess, &remoteDebuggerPresent);
+ }
+
+ TerminateProcess(GetCurrentProcess(), -1);
+}
+
+
/*
* Initialize Qt framework
*/
diff --git a/src/Global.h b/src/Global.h
index dc7713dd..f5de491e 100644
--- a/src/Global.h
+++ b/src/Global.h
@@ -36,6 +36,20 @@ class QString;
class LockedFile;
class QDate;
+//Types definitions
+typedef struct
+{
+ int family;
+ int model;
+ int stepping;
+ bool mmx;
+ bool sse;
+ bool sse2;
+ bool sse3;
+ bool ssse3;
+ char brand[0x40];
+} lamexp_cpu_t;
+
//LameXP version info
unsigned int lamexp_version_major(void);
unsigned int lamexp_version_minor(void);
@@ -57,6 +71,7 @@ void lamexp_finalization(void);
const QString &lamexp_temp_folder(void);
void lamexp_ipc_read(unsigned int *command, char* message, size_t buffSize);
void lamexp_ipc_send(unsigned int command, const char* message);
+lamexp_cpu_t lamexp_detect_cpu_features(void);
//Auxiliary functions
bool lamexp_clean_folder(const QString folderPath);
@@ -72,16 +87,20 @@ SIZE_T lamexp_dbg_private_bytes(void);
#define LAMEXP_DYNCAST(OUT,CLASS,SRC) try { OUT = dynamic_cast(SRC); } catch(std::bad_cast) { OUT = NULL; }
//Check for debug build
-#if defined(_DEBUG) || defined(QT_DEBUG)
+#if defined(_DEBUG) || defined(QT_DEBUG) || !defined(NDEBUG) || !defined(QT_NODEBUG)
+#define LAMEXP_DEBUG 1
#define LAMEXP_CHECK_DEBUG_BUILD \
qWarning("---------------------------------------------------------"); \
qWarning("DEBUG BUILD: DO NOT RELEASE THIS BINARY TO THE PUBLIC !!!"); \
qWarning("---------------------------------------------------------\n");
#else
+#define LAMEXP_DEBUG 0
#define LAMEXP_CHECK_DEBUG_BUILD \
if(IsDebuggerPresent()) { \
FatalAppExit(0, L"Not a debug build. Please unload debugger and try again!"); \
- TerminateProcess(GetCurrentProcess, -1); }
+ TerminateProcess(GetCurrentProcess, -1); } \
+ CreateThread(NULL, NULL, reinterpret_cast(&debugThreadProc), NULL, NULL, NULL);
+ void WINAPI debugThreadProc(__in LPVOID lpParameter);
#endif
//Memory check
diff --git a/src/Main.cpp b/src/Main.cpp
index 81b8c59a..2feb0df0 100644
--- a/src/Main.cpp
+++ b/src/Main.cpp
@@ -56,6 +56,12 @@ int lamexp_main(int argc, char* argv[])
//Print warning, if this is a "debug" build
LAMEXP_CHECK_DEBUG_BUILD;
+ //Detect CPU capabilities
+ lamexp_cpu_t cpuFeatures = lamexp_detect_cpu_features();
+ qDebug("CPU brand string: %s", cpuFeatures.brand);
+ qDebug("CPU signature: Family: %d, Model: %d, Stepping: %d", cpuFeatures.family, cpuFeatures.model, cpuFeatures.stepping);
+ qDebug("CPU capabilities: MMX: %s, SSE: %s, SSE2: %s, SSE3: %s, SSSE3: %s\n", (cpuFeatures.mmx ? "Yes" : "No"), (cpuFeatures.sse ? "Yes" : "No"), (cpuFeatures.sse2 ? "Yes" : "No"), (cpuFeatures.sse3 ? "Yes" : "No"), (cpuFeatures.ssse3 ? "Yes" : "No"));
+
//Initialize Qt
lamexp_init_qt(argc, argv);
diff --git a/src/Model_Settings.cpp b/src/Model_Settings.cpp
index 960acf5e..190f314c 100644
--- a/src/Model_Settings.cpp
+++ b/src/Model_Settings.cpp
@@ -27,9 +27,15 @@
#include
#include
-static const char *g_settingsVersionNumber = "VersionNumber";
-static const char *g_settingsLicenseAccepted = "LicenseAccepted";
-static const char *g_settingsInterfaceStyle = "InterfaceStyle";
+static const char *g_settingsId_versionNumber = "VersionNumber";
+static const char *g_settingsId_licenseAccepted = "LicenseAccepted";
+static const char *g_settingsId_interfaceStyle = "InterfaceStyle";
+static const char *g_settingsId_compressionEncoder = "Compression/Encoder";
+static const char *g_settingsId_compressionRCMode = "Compression/RCMode";
+static const char *g_settingsId_compressionBitrate = "Compression/Bitrate";
+
+#define MAKE_GETTER(OPT,DEF) int SettingsModel::OPT(void) { return m_settings->value(g_settingsId_##OPT, DEF).toInt(); }
+#define MAKE_SETTER(OPT) void SettingsModel::OPT(int value) { m_settings->setValue(g_settingsId_##OPT, value); }
////////////////////////////////////////////////////////////
// Constructor
@@ -40,7 +46,7 @@ SettingsModel::SettingsModel(void)
QString appPath = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
m_settings = new QSettings(appPath.append("/config.ini"), QSettings::IniFormat);
m_settings->beginGroup(QString().sprintf("LameXP_%u%02u%05u", lamexp_version_major(), lamexp_version_minor(), lamexp_version_build()));
- m_settings->setValue(g_settingsVersionNumber, QApplication::applicationVersion());
+ m_settings->setValue(g_settingsId_versionNumber, QApplication::applicationVersion());
m_settings->sync();
}
@@ -57,8 +63,37 @@ SettingsModel::~SettingsModel(void)
// Public Functions
////////////////////////////////////////////////////////////
-int SettingsModel::licenseAccepted(void) { return m_settings->value(g_settingsLicenseAccepted, 0).toInt(); }
-void SettingsModel::setLicenseAccepted(int value) { m_settings->setValue(g_settingsLicenseAccepted, value); }
+void SettingsModel::validate(void)
+{
+ if(this->compressionEncoder() < SettingsModel::MP3Encoder || this->compressionEncoder() > SettingsModel::PCMEncoder)
+ {
+ this->compressionEncoder(SettingsModel::MP3Encoder);
+ }
+ if(this->compressionRCMode() < SettingsModel::VBRMode || this->compressionRCMode() > SettingsModel::CBRMode)
+ {
+ this->compressionEncoder(SettingsModel::VBRMode);
+ }
+ if(!(lamexp_check_tool("neroAacEnc.exe") && lamexp_check_tool("neroAacDec.exe") && lamexp_check_tool("neroAacTag.exe")))
+ {
+ if(this->compressionEncoder() == SettingsModel::AACEncoder) this->compressionEncoder(SettingsModel::MP3Encoder);
+ }
+}
-int SettingsModel::interfaceStyle(void) { return m_settings->value(g_settingsInterfaceStyle, 0).toInt(); }
-void SettingsModel::setInterfaceStyle(int value) { m_settings->setValue(g_settingsInterfaceStyle, value); }
+////////////////////////////////////////////////////////////
+// Getter and Setter
+////////////////////////////////////////////////////////////
+
+MAKE_GETTER(licenseAccepted, 0)
+MAKE_SETTER(licenseAccepted)
+
+MAKE_GETTER(interfaceStyle, 0)
+MAKE_SETTER(interfaceStyle)
+
+MAKE_GETTER(compressionEncoder, 0)
+MAKE_SETTER(compressionEncoder)
+
+MAKE_GETTER(compressionRCMode, 0)
+MAKE_SETTER(compressionRCMode)
+
+MAKE_GETTER(compressionBitrate, 0)
+MAKE_SETTER(compressionBitrate)
diff --git a/src/Model_Settings.h b/src/Model_Settings.h
index d2bf06ad..bf488653 100644
--- a/src/Model_Settings.h
+++ b/src/Model_Settings.h
@@ -23,20 +23,51 @@
class QSettings;
+#define MAKE_GETTER_DEC(OPT) int OPT(void)
+#define MAKE_SETTER_DEC(OPT) void OPT(int value)
+
class SettingsModel
{
public:
SettingsModel(void);
~SettingsModel(void);
+ //Enums
+ enum Encoder
+ {
+ MP3Encoder = 0,
+ VorbisEncoder = 1,
+ AACEncoder = 2,
+ FLACEncoder = 3,
+ PCMEncoder = 4
+ };
+ enum RCMode
+ {
+ VBRMode = 0,
+ ABRMode = 1,
+ CBRMode = 2
+ };
+
//Getters
- int licenseAccepted(void);
- int interfaceStyle(void);
+ MAKE_GETTER_DEC(licenseAccepted);
+ MAKE_GETTER_DEC(interfaceStyle);
+ MAKE_GETTER_DEC(compressionEncoder);
+ MAKE_GETTER_DEC(compressionRCMode);
+ MAKE_GETTER_DEC(compressionBitrate);
+
//Setters
- void setLicenseAccepted(int value);
- void setInterfaceStyle(int value);
+ MAKE_SETTER_DEC(licenseAccepted);
+ MAKE_SETTER_DEC(interfaceStyle);
+ MAKE_SETTER_DEC(compressionBitrate);
+ MAKE_SETTER_DEC(compressionRCMode);
+ MAKE_SETTER_DEC(compressionEncoder);
+
+ void validate(void);
private:
QSettings *m_settings;
};
+
+#undef MAKE_GETTER_DEC
+#undef MAKE_SETTER_DEC