2010-11-12 19:02:01 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// LameXP - Audio Encoder Front-End
|
2012-01-02 00:52:27 +01:00
|
|
|
// Copyright (C) 2004-2012 LoRd_MuldeR <MuldeR2@GMX.de>
|
2010-11-12 19:02:01 +01:00
|
|
|
//
|
|
|
|
// 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 "Model_Settings.h"
|
|
|
|
|
|
|
|
#include "Global.h"
|
|
|
|
|
|
|
|
#include <QSettings>
|
|
|
|
#include <QDesktopServices>
|
|
|
|
#include <QApplication>
|
2010-11-20 02:14:22 +01:00
|
|
|
#include <QString>
|
|
|
|
#include <QFileInfo>
|
2011-01-24 00:04:07 +01:00
|
|
|
#include <QDir>
|
2010-12-30 16:12:21 +01:00
|
|
|
#include <QStringList>
|
2011-01-02 20:47:26 +01:00
|
|
|
#include <QLocale>
|
2011-03-05 17:43:57 +01:00
|
|
|
#include <QRegExp>
|
2010-11-12 19:02:01 +01:00
|
|
|
|
2011-01-21 19:14:11 +01:00
|
|
|
|
2011-02-10 16:08:03 +01:00
|
|
|
////////////////////////////////////////////////////////////
|
2010-11-21 21:51:22 +01:00
|
|
|
//Macros
|
2011-02-10 16:08:03 +01:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
2011-05-03 14:28:06 +02:00
|
|
|
#define LAMEXP_MAKE_OPTION_I(OPT,DEF) \
|
2010-11-21 21:51:22 +01:00
|
|
|
int SettingsModel::OPT(void) { return m_settings->value(g_settingsId_##OPT, DEF).toInt(); } \
|
2011-01-23 02:19:18 +01:00
|
|
|
void SettingsModel::OPT(int value) { m_settings->setValue(g_settingsId_##OPT, value); } \
|
|
|
|
int SettingsModel::OPT##Default(void) { return DEF; }
|
2010-11-12 19:02:01 +01:00
|
|
|
|
2011-05-03 14:28:06 +02:00
|
|
|
#define LAMEXP_MAKE_OPTION_S(OPT,DEF) \
|
2010-11-21 21:51:22 +01:00
|
|
|
QString SettingsModel::OPT(void) { return m_settings->value(g_settingsId_##OPT, DEF).toString().trimmed(); } \
|
2011-01-23 02:19:18 +01:00
|
|
|
void SettingsModel::OPT(const QString &value) { m_settings->setValue(g_settingsId_##OPT, value); } \
|
|
|
|
QString SettingsModel::OPT##Default(void) { return DEF; }
|
2010-11-21 21:51:22 +01:00
|
|
|
|
2011-05-03 14:28:06 +02:00
|
|
|
#define LAMEXP_MAKE_OPTION_B(OPT,DEF) \
|
2010-11-21 21:51:22 +01:00
|
|
|
bool SettingsModel::OPT(void) { return m_settings->value(g_settingsId_##OPT, DEF).toBool(); } \
|
2011-01-23 02:19:18 +01:00
|
|
|
void SettingsModel::OPT(bool value) { m_settings->setValue(g_settingsId_##OPT, value); } \
|
|
|
|
bool SettingsModel::OPT##Default(void) { return DEF; }
|
2010-11-21 21:51:22 +01:00
|
|
|
|
2011-05-03 14:28:06 +02:00
|
|
|
#define LAMEXP_MAKE_OPTION_U(OPT,DEF) \
|
2011-02-10 16:08:03 +01:00
|
|
|
unsigned int SettingsModel::OPT(void) { return m_settings->value(g_settingsId_##OPT, DEF).toUInt(); } \
|
|
|
|
void SettingsModel::OPT(unsigned int value) { m_settings->setValue(g_settingsId_##OPT, value); } \
|
|
|
|
unsigned int SettingsModel::OPT##Default(void) { return DEF; }
|
|
|
|
|
2011-05-03 14:28:06 +02:00
|
|
|
#define LAMEXP_MAKE_ID(DEC,STR) static const char *g_settingsId_##DEC = STR
|
2011-03-05 17:43:57 +01:00
|
|
|
#define REMOVE_GROUP(OBJ,ID) OBJ->beginGroup(ID); OBJ->remove(""); OBJ->endGroup();
|
2011-02-10 16:08:03 +01:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
//Constants
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
//Setting ID's
|
2011-05-03 14:28:06 +02:00
|
|
|
LAMEXP_MAKE_ID(versionNumber, "VersionNumber");
|
|
|
|
LAMEXP_MAKE_ID(licenseAccepted, "LicenseAccepted");
|
|
|
|
LAMEXP_MAKE_ID(interfaceStyle, "InterfaceStyle");
|
|
|
|
LAMEXP_MAKE_ID(compressionEncoder, "Compression/Encoder");
|
|
|
|
LAMEXP_MAKE_ID(compressionRCMode, "Compression/RCMode");
|
|
|
|
LAMEXP_MAKE_ID(compressionBitrate, "Compression/Bitrate");
|
|
|
|
LAMEXP_MAKE_ID(outputDir, "OutputDirectory/SelectedPath");
|
|
|
|
LAMEXP_MAKE_ID(outputToSourceDir, "OutputDirectory/OutputToSourceFolder");
|
|
|
|
LAMEXP_MAKE_ID(prependRelativeSourcePath, "OutputDirectory/PrependRelativeSourcePath");
|
2011-08-08 20:26:30 +02:00
|
|
|
LAMEXP_MAKE_ID(favoriteOutputFolders, "OutputDirectory/Favorites");
|
2011-08-23 18:48:16 +02:00
|
|
|
LAMEXP_MAKE_ID(mostRecentInputPath, "InputDirectory/MostRecentPath");
|
2011-05-03 14:28:06 +02:00
|
|
|
LAMEXP_MAKE_ID(writeMetaTags, "Flags/WriteMetaTags");
|
|
|
|
LAMEXP_MAKE_ID(createPlaylist, "Flags/AutoCreatePlaylist");
|
|
|
|
LAMEXP_MAKE_ID(autoUpdateLastCheck, "AutoUpdate/LastCheck");
|
|
|
|
LAMEXP_MAKE_ID(autoUpdateEnabled, "AutoUpdate/Enabled");
|
|
|
|
LAMEXP_MAKE_ID(autoUpdateCheckBeta, "AutoUpdate/CheckForBetaVersions");
|
|
|
|
LAMEXP_MAKE_ID(soundsEnabled, "Flags/EnableSounds");
|
|
|
|
LAMEXP_MAKE_ID(neroAacNotificationsEnabled, "Flags/EnableNeroAacNotifications");
|
2011-06-24 18:17:04 +02:00
|
|
|
LAMEXP_MAKE_ID(antivirNotificationsEnabled, "Flags/EnableAntivirusNotifications");
|
2011-05-03 14:28:06 +02:00
|
|
|
LAMEXP_MAKE_ID(dropBoxWidgetEnabled, "Flags/EnableDropBoxWidget");
|
|
|
|
LAMEXP_MAKE_ID(shellIntegrationEnabled, "Flags/EnableShellIntegration");
|
|
|
|
LAMEXP_MAKE_ID(currentLanguage, "Localization/Language");
|
2012-10-14 22:21:57 +02:00
|
|
|
LAMEXP_MAKE_ID(currentLanguageFile, "Localization/UseQMFile");
|
2011-05-03 14:28:06 +02:00
|
|
|
LAMEXP_MAKE_ID(lameAlgoQuality, "AdvancedOptions/LAME/AlgorithmQuality");
|
|
|
|
LAMEXP_MAKE_ID(lameChannelMode, "AdvancedOptions/LAME/ChannelMode");
|
2011-08-05 21:52:43 +02:00
|
|
|
LAMEXP_MAKE_ID(forceStereoDownmix, "AdvancedOptions/StereoDownmix/Force");
|
2011-05-03 14:28:06 +02:00
|
|
|
LAMEXP_MAKE_ID(bitrateManagementEnabled, "AdvancedOptions/BitrateManagement/Enabled");
|
|
|
|
LAMEXP_MAKE_ID(bitrateManagementMinRate, "AdvancedOptions/BitrateManagement/MinRate");
|
|
|
|
LAMEXP_MAKE_ID(bitrateManagementMaxRate, "AdvancedOptions/BitrateManagement/MaxRate");
|
2011-05-07 00:50:18 +02:00
|
|
|
LAMEXP_MAKE_ID(aftenAudioCodingMode, "AdvancedOptions/Aften/AudioCodingMode");
|
|
|
|
LAMEXP_MAKE_ID(aftenDynamicRangeCompression, "AdvancedOptions/Aften/DynamicRangeCompression");
|
|
|
|
LAMEXP_MAKE_ID(aftenFastBitAllocation, "AdvancedOptions/Aften/FastBitAllocation");
|
|
|
|
LAMEXP_MAKE_ID(aftenExponentSearchSize, "AdvancedOptions/Aften/ExponentSearchSize");
|
2011-05-03 14:28:06 +02:00
|
|
|
LAMEXP_MAKE_ID(samplingRate, "AdvancedOptions/Common/Resampling");
|
2011-08-21 14:43:18 +02:00
|
|
|
LAMEXP_MAKE_ID(neroAACEnable2Pass, "AdvancedOptions/AACEnc/Enable2Pass");
|
|
|
|
LAMEXP_MAKE_ID(aacEncProfile, "AdvancedOptions/AACEnc/ForceProfile");
|
2012-07-21 19:16:12 +02:00
|
|
|
LAMEXP_MAKE_ID(opusOptimizeFor, "AdvancedOptions/Opus/OptimizeForSignalType");
|
|
|
|
LAMEXP_MAKE_ID(opusComplexity, "AdvancedOptions/Opus/EncodingComplexity");
|
|
|
|
LAMEXP_MAKE_ID(opusFramesize, "AdvancedOptions/Opus/FrameSize");
|
2011-05-03 14:28:06 +02:00
|
|
|
LAMEXP_MAKE_ID(normalizationFilterEnabled, "AdvancedOptions/VolumeNormalization/Enabled");
|
|
|
|
LAMEXP_MAKE_ID(normalizationFilterMaxVolume, "AdvancedOptions/VolumeNormalization/MaxVolume");
|
2011-10-06 23:55:42 +02:00
|
|
|
LAMEXP_MAKE_ID(normalizationFilterEqualizationMode, "AdvancedOptions/VolumeNormalization/EqualizationMode");
|
2011-05-03 14:28:06 +02:00
|
|
|
LAMEXP_MAKE_ID(toneAdjustBass, "AdvancedOptions/ToneAdjustment/Bass");
|
|
|
|
LAMEXP_MAKE_ID(toneAdjustTreble, "AdvancedOptions/ToneAdjustment/Treble");
|
|
|
|
LAMEXP_MAKE_ID(customParametersLAME, "AdvancedOptions/CustomParameters/LAME");
|
|
|
|
LAMEXP_MAKE_ID(customParametersOggEnc, "AdvancedOptions/CustomParameters/OggEnc");
|
2011-08-21 14:43:18 +02:00
|
|
|
LAMEXP_MAKE_ID(customParametersAacEnc, "AdvancedOptions/CustomParameters/AacEnc");
|
2011-05-05 12:27:25 +02:00
|
|
|
LAMEXP_MAKE_ID(customParametersAften, "AdvancedOptions/CustomParameters/Aften");
|
2011-05-03 14:28:06 +02:00
|
|
|
LAMEXP_MAKE_ID(customParametersFLAC, "AdvancedOptions/CustomParameters/FLAC");
|
2012-07-29 22:55:02 +02:00
|
|
|
LAMEXP_MAKE_ID(customParametersOpus, "AdvancedOptions/CustomParameters/OpusEnc");
|
2011-08-04 23:26:38 +02:00
|
|
|
LAMEXP_MAKE_ID(renameOutputFilesEnabled, "AdvancedOptions/RenameOutputFiles/Enabled");
|
|
|
|
LAMEXP_MAKE_ID(renameOutputFilesPattern, "AdvancedOptions/RenameOutputFiles/Pattern");
|
2012-11-08 00:42:55 +01:00
|
|
|
LAMEXP_MAKE_ID(overwriteMode, "AdvancedOptions/OverwriteMode");
|
2011-10-22 01:13:28 +02:00
|
|
|
LAMEXP_MAKE_ID(hibernateComputer, "AdvancedOptions/HibernateComputerOnShutdown");
|
2011-05-03 14:28:06 +02:00
|
|
|
LAMEXP_MAKE_ID(metaInfoPosition, "MetaInformation/PlaylistPosition");
|
|
|
|
LAMEXP_MAKE_ID(maximumInstances, "AdvancedOptions/Threading/MaximumInstances");
|
|
|
|
LAMEXP_MAKE_ID(customTempPath, "AdvancedOptions/TempDirectory/CustomPath");
|
|
|
|
LAMEXP_MAKE_ID(customTempPathEnabled, "AdvancedOptions/TempDirectory/UseCustomPath");
|
2011-06-24 18:17:04 +02:00
|
|
|
LAMEXP_MAKE_ID(slowStartup, "Flags/SlowStartupDetected");
|
2011-02-10 16:08:03 +01:00
|
|
|
|
2010-11-21 21:51:22 +01:00
|
|
|
//LUT
|
2010-11-15 21:07:58 +01:00
|
|
|
const int SettingsModel::mp3Bitrates[15] = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, -1};
|
2011-05-05 12:27:25 +02:00
|
|
|
const int SettingsModel::ac3Bitrates[20] = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 512, 576, 640, -1};
|
2011-01-23 02:19:18 +01:00
|
|
|
const int SettingsModel::samplingRates[8] = {0, 16000, 22050, 24000, 32000, 44100, 48000, -1};
|
2010-11-15 21:07:58 +01:00
|
|
|
|
2010-11-12 19:02:01 +01:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// Constructor
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
SettingsModel::SettingsModel(void)
|
2011-01-02 01:09:05 +01:00
|
|
|
:
|
|
|
|
m_defaultLanguage(NULL)
|
2010-11-12 19:02:01 +01:00
|
|
|
{
|
2011-08-26 16:32:25 +02:00
|
|
|
QString configPath = "LameXP.ini";
|
2011-01-24 00:04:07 +01:00
|
|
|
|
|
|
|
if(!lamexp_portable_mode())
|
|
|
|
{
|
2011-08-26 16:32:25 +02:00
|
|
|
QString dataPath = initDirectory(QDesktopServices::storageLocation(QDesktopServices::DataLocation));
|
|
|
|
if(!dataPath.isEmpty())
|
|
|
|
{
|
|
|
|
configPath = QString("%1/config.ini").arg(QDir(dataPath).canonicalPath());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qWarning("SettingsModel: DataLocation could not be initialized!");
|
|
|
|
dataPath = initDirectory(QDesktopServices::storageLocation(QDesktopServices::HomeLocation));
|
|
|
|
if(!dataPath.isEmpty())
|
|
|
|
{
|
|
|
|
configPath = QString("%1/LameXP.ini").arg(QDir(dataPath).canonicalPath());
|
|
|
|
}
|
|
|
|
}
|
2011-01-24 00:04:07 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug("LameXP is running in \"portable\" mode -> config in application dir!\n");
|
|
|
|
QString appPath = QFileInfo(QApplication::applicationFilePath()).canonicalFilePath();
|
2011-08-26 16:32:25 +02:00
|
|
|
if(appPath.isEmpty())
|
|
|
|
{
|
|
|
|
appPath = QFileInfo(QApplication::applicationFilePath()).absoluteFilePath();
|
|
|
|
}
|
|
|
|
if(QFileInfo(appPath).exists() && QFileInfo(appPath).isFile())
|
|
|
|
{
|
|
|
|
configPath = QString("%1/%2.ini").arg(QFileInfo(appPath).absolutePath(), QFileInfo(appPath).completeBaseName());
|
|
|
|
}
|
2011-01-24 00:04:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
m_settings = new QSettings(configPath, QSettings::IniFormat);
|
2011-03-05 17:43:57 +01:00
|
|
|
const QString groupKey = QString().sprintf("LameXP_%u%02u%05u", lamexp_version_major(), lamexp_version_minor(), lamexp_version_build());
|
|
|
|
QStringList childGroups = m_settings->childGroups();
|
|
|
|
|
|
|
|
while(!childGroups.isEmpty())
|
|
|
|
{
|
|
|
|
QString current = childGroups.takeFirst();
|
|
|
|
QRegExp filter("^LameXP_(\\d+)(\\d\\d)(\\d\\d\\d\\d\\d)$");
|
|
|
|
if(filter.indexIn(current) >= 0)
|
|
|
|
{
|
|
|
|
bool ok = false;
|
|
|
|
unsigned int temp = filter.cap(3).toUInt(&ok) + 10;
|
|
|
|
if(ok && (temp >= lamexp_version_build()))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
qWarning("Deleting obsolete group from config: %s", current.toUtf8().constData());
|
|
|
|
REMOVE_GROUP(m_settings, current);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_settings->beginGroup(groupKey);
|
2010-11-15 04:42:06 +01:00
|
|
|
m_settings->setValue(g_settingsId_versionNumber, QApplication::applicationVersion());
|
2010-11-12 19:02:01 +01:00
|
|
|
m_settings->sync();
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// Destructor
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
SettingsModel::~SettingsModel(void)
|
|
|
|
{
|
|
|
|
LAMEXP_DELETE(m_settings);
|
2011-01-02 01:09:05 +01:00
|
|
|
LAMEXP_DELETE(m_defaultLanguage);
|
2010-11-12 19:02:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// Public Functions
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
2010-11-15 04:42:06 +01:00
|
|
|
void SettingsModel::validate(void)
|
|
|
|
{
|
|
|
|
if(this->compressionEncoder() < SettingsModel::MP3Encoder || this->compressionEncoder() > SettingsModel::PCMEncoder)
|
|
|
|
{
|
|
|
|
this->compressionEncoder(SettingsModel::MP3Encoder);
|
|
|
|
}
|
2010-12-30 16:12:21 +01:00
|
|
|
|
2010-11-15 04:42:06 +01:00
|
|
|
if(this->compressionRCMode() < SettingsModel::VBRMode || this->compressionRCMode() > SettingsModel::CBRMode)
|
|
|
|
{
|
|
|
|
this->compressionEncoder(SettingsModel::VBRMode);
|
|
|
|
}
|
2010-12-30 16:12:21 +01:00
|
|
|
|
2010-11-15 04:42:06 +01:00
|
|
|
if(!(lamexp_check_tool("neroAacEnc.exe") && lamexp_check_tool("neroAacDec.exe") && lamexp_check_tool("neroAacTag.exe")))
|
|
|
|
{
|
2011-08-19 19:25:01 +02:00
|
|
|
if(!(lamexp_check_tool("fhgaacenc.exe") && lamexp_check_tool("enc_fhgaac.dll")))
|
2010-12-03 23:01:17 +01:00
|
|
|
{
|
2011-11-22 23:48:54 +01:00
|
|
|
if(!(lamexp_check_tool("qaac.exe") && lamexp_check_tool("libsoxrate.dll")))
|
2011-08-19 19:25:01 +02:00
|
|
|
{
|
2011-11-21 01:22:41 +01:00
|
|
|
if(this->compressionEncoder() == SettingsModel::AACEncoder)
|
|
|
|
{
|
|
|
|
qWarning("AAC encoder selected, but not available any more. Reverting to MP3!");
|
|
|
|
this->compressionEncoder(SettingsModel::MP3Encoder);
|
|
|
|
}
|
2011-08-19 19:25:01 +02:00
|
|
|
}
|
2010-12-03 23:01:17 +01:00
|
|
|
}
|
2010-11-15 04:42:06 +01:00
|
|
|
}
|
2010-12-30 16:12:21 +01:00
|
|
|
|
2010-11-20 02:14:22 +01:00
|
|
|
if(this->outputDir().isEmpty() || !QFileInfo(this->outputDir()).isDir())
|
|
|
|
{
|
2011-08-23 18:48:16 +02:00
|
|
|
QString musicLocation = QDesktopServices::storageLocation(QDesktopServices::MusicLocation);
|
|
|
|
this->outputDir(musicLocation.isEmpty() ? QDesktopServices::storageLocation(QDesktopServices::HomeLocation) : musicLocation);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(this->mostRecentInputPath().isEmpty() || !QFileInfo(this->mostRecentInputPath()).isDir())
|
|
|
|
{
|
|
|
|
QString musicLocation = QDesktopServices::storageLocation(QDesktopServices::MusicLocation);
|
|
|
|
this->outputDir(musicLocation.isEmpty() ? QDesktopServices::storageLocation(QDesktopServices::HomeLocation) : musicLocation);
|
2010-11-20 02:14:22 +01:00
|
|
|
}
|
2010-12-30 16:12:21 +01:00
|
|
|
|
2012-10-14 22:21:57 +02:00
|
|
|
if(!this->currentLanguageFile().isEmpty())
|
|
|
|
{
|
|
|
|
const QString qmPath = QFileInfo(this->currentLanguageFile()).canonicalFilePath();
|
2012-10-15 00:41:38 +02:00
|
|
|
if(qmPath.isEmpty() || (!(QFileInfo(qmPath).exists() && QFileInfo(qmPath).isFile() && (QFileInfo(qmPath).suffix().compare("qm", Qt::CaseInsensitive) == 0))))
|
2012-10-14 22:21:57 +02:00
|
|
|
{
|
2012-10-15 00:41:38 +02:00
|
|
|
qWarning("Current language file missing, reverting to built-in translator!");
|
2012-10-14 22:21:57 +02:00
|
|
|
this->currentLanguageFile(QString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-30 16:12:21 +01:00
|
|
|
if(!lamexp_query_translations().contains(this->currentLanguage(), Qt::CaseInsensitive))
|
|
|
|
{
|
2011-01-02 20:47:26 +01:00
|
|
|
qWarning("Current language \"%s\" is unknown, reverting to default language!", this->currentLanguage().toLatin1().constData());
|
2011-08-29 15:57:17 +02:00
|
|
|
this->currentLanguage(defaultLanguage());
|
2010-12-30 16:12:21 +01:00
|
|
|
}
|
2011-10-22 01:34:24 +02:00
|
|
|
|
|
|
|
if(this->hibernateComputer())
|
|
|
|
{
|
|
|
|
if(!lamexp_is_hibernation_supported())
|
|
|
|
{
|
|
|
|
this->hibernateComputer(false);
|
|
|
|
}
|
|
|
|
}
|
2012-11-08 00:42:55 +01:00
|
|
|
|
|
|
|
if(this->overwriteMode() < SettingsModel::Overwrite_KeepBoth || this->overwriteMode() > SettingsModel::Overwrite_Replaces)
|
|
|
|
{
|
|
|
|
this->overwriteMode(SettingsModel::Overwrite_KeepBoth);
|
|
|
|
}
|
|
|
|
|
2010-11-15 04:42:06 +01:00
|
|
|
}
|
|
|
|
|
2012-10-10 23:01:58 +02:00
|
|
|
void SettingsModel::syncNow(void)
|
|
|
|
{
|
|
|
|
m_settings->sync();
|
|
|
|
}
|
|
|
|
|
2011-01-02 01:09:05 +01:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// Private Functions
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
QString SettingsModel::defaultLanguage(void)
|
|
|
|
{
|
|
|
|
if(m_defaultLanguage)
|
|
|
|
{
|
|
|
|
return *m_defaultLanguage;
|
|
|
|
}
|
|
|
|
|
2011-12-19 17:26:20 +01:00
|
|
|
//Detect system langauge
|
2011-01-02 20:47:26 +01:00
|
|
|
QLocale systemLanguage= QLocale::system();
|
2011-12-19 17:26:20 +01:00
|
|
|
qDebug("[Locale]");
|
|
|
|
qDebug("Language: %s (%d)", QLocale::languageToString(systemLanguage.language()).toUtf8().constData(), systemLanguage.language());
|
|
|
|
qDebug("Country is: %s (%d)", QLocale::countryToString(systemLanguage.country()).toUtf8().constData(), systemLanguage.country());
|
|
|
|
qDebug("Script is: %s (%d)\n", QLocale::scriptToString(systemLanguage.script()).toUtf8().constData(), systemLanguage.script());
|
|
|
|
|
|
|
|
//Check if we can use the default translation
|
2011-12-19 15:48:50 +01:00
|
|
|
if(systemLanguage.language() == QLocale::English /*|| systemLanguage.language() == QLocale::C*/)
|
2011-01-02 01:09:05 +01:00
|
|
|
{
|
|
|
|
m_defaultLanguage = new QString(LAMEXP_DEFAULT_LANGID);
|
|
|
|
return LAMEXP_DEFAULT_LANGID;
|
|
|
|
}
|
|
|
|
|
2011-12-19 17:26:20 +01:00
|
|
|
//Try to find a suitable translation for the user's system language *and* country
|
2011-01-02 01:09:05 +01:00
|
|
|
QStringList languages = lamexp_query_translations();
|
|
|
|
while(!languages.isEmpty())
|
|
|
|
{
|
|
|
|
QString currentLangId = languages.takeFirst();
|
2011-01-02 20:47:26 +01:00
|
|
|
if(lamexp_translation_sysid(currentLangId) == systemLanguage.language())
|
2011-01-02 01:09:05 +01:00
|
|
|
{
|
2011-12-19 17:26:20 +01:00
|
|
|
if(lamexp_translation_country(currentLangId) == systemLanguage.country())
|
2011-12-19 15:48:50 +01:00
|
|
|
{
|
|
|
|
m_defaultLanguage = new QString(currentLangId);
|
|
|
|
return currentLangId;
|
|
|
|
}
|
2011-01-02 01:09:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-19 17:26:20 +01:00
|
|
|
//Try to find a suitable translation for the user's system language
|
|
|
|
languages = lamexp_query_translations();
|
|
|
|
while(!languages.isEmpty())
|
|
|
|
{
|
|
|
|
QString currentLangId = languages.takeFirst();
|
|
|
|
if(lamexp_translation_sysid(currentLangId) == systemLanguage.language())
|
|
|
|
{
|
|
|
|
m_defaultLanguage = new QString(currentLangId);
|
|
|
|
return currentLangId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-02 01:09:05 +01:00
|
|
|
//Fall back to the default translation
|
|
|
|
m_defaultLanguage = new QString(LAMEXP_DEFAULT_LANGID);
|
|
|
|
return LAMEXP_DEFAULT_LANGID;
|
|
|
|
}
|
|
|
|
|
2011-08-26 16:32:25 +02:00
|
|
|
QString SettingsModel::initDirectory(const QString &path)
|
|
|
|
{
|
|
|
|
if(path.isEmpty())
|
|
|
|
{
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!QDir(path).exists())
|
|
|
|
{
|
|
|
|
for(int i = 0; i < 32; i++)
|
|
|
|
{
|
|
|
|
if(QDir(path).mkpath(".")) break;
|
|
|
|
Sleep(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!QDir(path).exists())
|
|
|
|
{
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
|
|
|
return QDir(path).canonicalPath();
|
|
|
|
}
|
|
|
|
|
2010-11-15 04:42:06 +01:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// Getter and Setter
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
2011-05-03 14:28:06 +02:00
|
|
|
LAMEXP_MAKE_OPTION_I(licenseAccepted, 0)
|
|
|
|
LAMEXP_MAKE_OPTION_I(interfaceStyle, 0)
|
|
|
|
LAMEXP_MAKE_OPTION_I(compressionEncoder, 0)
|
|
|
|
LAMEXP_MAKE_OPTION_I(compressionRCMode, 0)
|
|
|
|
LAMEXP_MAKE_OPTION_I(compressionBitrate, 7)
|
2011-08-23 18:48:16 +02:00
|
|
|
LAMEXP_MAKE_OPTION_S(outputDir, QDesktopServices::storageLocation(QDesktopServices::MusicLocation))
|
2011-05-03 14:28:06 +02:00
|
|
|
LAMEXP_MAKE_OPTION_B(outputToSourceDir, false)
|
|
|
|
LAMEXP_MAKE_OPTION_B(prependRelativeSourcePath, false)
|
2011-08-08 20:26:30 +02:00
|
|
|
LAMEXP_MAKE_OPTION_S(favoriteOutputFolders, QString());
|
2011-05-03 14:28:06 +02:00
|
|
|
LAMEXP_MAKE_OPTION_B(writeMetaTags, true)
|
|
|
|
LAMEXP_MAKE_OPTION_B(createPlaylist, true)
|
|
|
|
LAMEXP_MAKE_OPTION_S(autoUpdateLastCheck, "Never")
|
|
|
|
LAMEXP_MAKE_OPTION_B(autoUpdateEnabled, true)
|
|
|
|
LAMEXP_MAKE_OPTION_B(autoUpdateCheckBeta, false)
|
|
|
|
LAMEXP_MAKE_OPTION_B(soundsEnabled, true)
|
|
|
|
LAMEXP_MAKE_OPTION_B(neroAacNotificationsEnabled, true)
|
2011-06-24 18:17:04 +02:00
|
|
|
LAMEXP_MAKE_OPTION_B(antivirNotificationsEnabled, true)
|
2011-05-03 14:28:06 +02:00
|
|
|
LAMEXP_MAKE_OPTION_B(dropBoxWidgetEnabled, true)
|
|
|
|
LAMEXP_MAKE_OPTION_B(shellIntegrationEnabled, !lamexp_portable_mode())
|
|
|
|
LAMEXP_MAKE_OPTION_S(currentLanguage, defaultLanguage())
|
2012-10-14 22:21:57 +02:00
|
|
|
LAMEXP_MAKE_OPTION_S(currentLanguageFile, QString())
|
2011-05-03 14:28:06 +02:00
|
|
|
LAMEXP_MAKE_OPTION_I(lameAlgoQuality, 3)
|
2011-08-05 21:52:43 +02:00
|
|
|
LAMEXP_MAKE_OPTION_I(lameChannelMode, 0)
|
|
|
|
LAMEXP_MAKE_OPTION_B(forceStereoDownmix, false)
|
2011-05-03 14:28:06 +02:00
|
|
|
LAMEXP_MAKE_OPTION_B(bitrateManagementEnabled, false)
|
|
|
|
LAMEXP_MAKE_OPTION_I(bitrateManagementMinRate, 32)
|
|
|
|
LAMEXP_MAKE_OPTION_I(bitrateManagementMaxRate, 500)
|
|
|
|
LAMEXP_MAKE_OPTION_I(samplingRate, 0)
|
|
|
|
LAMEXP_MAKE_OPTION_B(neroAACEnable2Pass, true)
|
2011-08-21 14:43:18 +02:00
|
|
|
LAMEXP_MAKE_OPTION_I(aacEncProfile, 0)
|
2011-05-07 00:50:18 +02:00
|
|
|
LAMEXP_MAKE_OPTION_I(aftenAudioCodingMode, 0);
|
|
|
|
LAMEXP_MAKE_OPTION_I(aftenDynamicRangeCompression, 5);
|
|
|
|
LAMEXP_MAKE_OPTION_B(aftenFastBitAllocation, false);
|
|
|
|
LAMEXP_MAKE_OPTION_I(aftenExponentSearchSize, 8);
|
2012-07-21 19:16:12 +02:00
|
|
|
LAMEXP_MAKE_OPTION_I(opusOptimizeFor, 0);
|
|
|
|
LAMEXP_MAKE_OPTION_I(opusComplexity, 10);
|
|
|
|
LAMEXP_MAKE_OPTION_I(opusFramesize, 3);
|
2011-05-03 14:28:06 +02:00
|
|
|
LAMEXP_MAKE_OPTION_B(normalizationFilterEnabled, false)
|
|
|
|
LAMEXP_MAKE_OPTION_I(normalizationFilterMaxVolume, -50)
|
2011-10-06 23:55:42 +02:00
|
|
|
LAMEXP_MAKE_OPTION_I(normalizationFilterEqualizationMode, 0);
|
2011-05-03 14:28:06 +02:00
|
|
|
LAMEXP_MAKE_OPTION_I(toneAdjustBass, 0)
|
|
|
|
LAMEXP_MAKE_OPTION_I(toneAdjustTreble, 0)
|
|
|
|
LAMEXP_MAKE_OPTION_S(customParametersLAME, QString());
|
|
|
|
LAMEXP_MAKE_OPTION_S(customParametersOggEnc, QString());
|
2011-08-21 14:43:18 +02:00
|
|
|
LAMEXP_MAKE_OPTION_S(customParametersAacEnc, QString());
|
2011-05-05 12:27:25 +02:00
|
|
|
LAMEXP_MAKE_OPTION_S(customParametersAften, QString());
|
2011-05-03 14:28:06 +02:00
|
|
|
LAMEXP_MAKE_OPTION_S(customParametersFLAC, QString());
|
2012-07-29 22:55:02 +02:00
|
|
|
LAMEXP_MAKE_OPTION_S(customParametersOpus, QString());
|
2011-08-04 23:26:38 +02:00
|
|
|
LAMEXP_MAKE_OPTION_B(renameOutputFilesEnabled, false);
|
|
|
|
LAMEXP_MAKE_OPTION_S(renameOutputFilesPattern, "[<TrackNo>] <Artist> - <Title>");
|
2012-11-08 00:42:55 +01:00
|
|
|
LAMEXP_MAKE_OPTION_I(overwriteMode, Overwrite_KeepBoth);
|
2011-05-03 14:28:06 +02:00
|
|
|
LAMEXP_MAKE_OPTION_U(metaInfoPosition, UINT_MAX);
|
|
|
|
LAMEXP_MAKE_OPTION_U(maximumInstances, 0);
|
|
|
|
LAMEXP_MAKE_OPTION_S(customTempPath, QDesktopServices::storageLocation(QDesktopServices::TempLocation));
|
|
|
|
LAMEXP_MAKE_OPTION_B(customTempPathEnabled, false);
|
2011-06-24 18:17:04 +02:00
|
|
|
LAMEXP_MAKE_OPTION_B(slowStartup, false);
|
2011-08-23 18:48:16 +02:00
|
|
|
LAMEXP_MAKE_OPTION_S(mostRecentInputPath, QDesktopServices::storageLocation(QDesktopServices::MusicLocation));
|
2011-10-22 01:13:28 +02:00
|
|
|
LAMEXP_MAKE_OPTION_B(hibernateComputer, false);
|