OSDN Git Service

Switched the method of how the Designer UI file is used in the DropBox class to ...
[lamexp/LameXP.git] / src / Model_Settings.cpp
index b135fce..b1403a8 100644 (file)
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 // LameXP - Audio Encoder Front-End
-// Copyright (C) 2004-2011 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2012 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
@@ -88,6 +88,7 @@ LAMEXP_MAKE_ID(antivirNotificationsEnabled, "Flags/EnableAntivirusNotifications"
 LAMEXP_MAKE_ID(dropBoxWidgetEnabled, "Flags/EnableDropBoxWidget");
 LAMEXP_MAKE_ID(shellIntegrationEnabled, "Flags/EnableShellIntegration");
 LAMEXP_MAKE_ID(currentLanguage, "Localization/Language");
+LAMEXP_MAKE_ID(currentLanguageFile, "Localization/UseQMFile");
 LAMEXP_MAKE_ID(lameAlgoQuality, "AdvancedOptions/LAME/AlgorithmQuality");
 LAMEXP_MAKE_ID(lameChannelMode, "AdvancedOptions/LAME/ChannelMode");
 LAMEXP_MAKE_ID(forceStereoDownmix, "AdvancedOptions/StereoDownmix/Force");
@@ -101,6 +102,9 @@ LAMEXP_MAKE_ID(aftenExponentSearchSize, "AdvancedOptions/Aften/ExponentSearchSiz
 LAMEXP_MAKE_ID(samplingRate, "AdvancedOptions/Common/Resampling");
 LAMEXP_MAKE_ID(neroAACEnable2Pass, "AdvancedOptions/AACEnc/Enable2Pass");
 LAMEXP_MAKE_ID(aacEncProfile, "AdvancedOptions/AACEnc/ForceProfile");
+LAMEXP_MAKE_ID(opusOptimizeFor, "AdvancedOptions/Opus/OptimizeForSignalType");
+LAMEXP_MAKE_ID(opusComplexity, "AdvancedOptions/Opus/EncodingComplexity");
+LAMEXP_MAKE_ID(opusFramesize, "AdvancedOptions/Opus/FrameSize");
 LAMEXP_MAKE_ID(normalizationFilterEnabled, "AdvancedOptions/VolumeNormalization/Enabled");
 LAMEXP_MAKE_ID(normalizationFilterMaxVolume, "AdvancedOptions/VolumeNormalization/MaxVolume");
 LAMEXP_MAKE_ID(normalizationFilterEqualizationMode, "AdvancedOptions/VolumeNormalization/EqualizationMode");
@@ -111,8 +115,10 @@ LAMEXP_MAKE_ID(customParametersOggEnc, "AdvancedOptions/CustomParameters/OggEnc"
 LAMEXP_MAKE_ID(customParametersAacEnc, "AdvancedOptions/CustomParameters/AacEnc");
 LAMEXP_MAKE_ID(customParametersAften, "AdvancedOptions/CustomParameters/Aften");
 LAMEXP_MAKE_ID(customParametersFLAC, "AdvancedOptions/CustomParameters/FLAC");
+LAMEXP_MAKE_ID(customParametersOpus, "AdvancedOptions/CustomParameters/OpusEnc");
 LAMEXP_MAKE_ID(renameOutputFilesEnabled, "AdvancedOptions/RenameOutputFiles/Enabled");
 LAMEXP_MAKE_ID(renameOutputFilesPattern, "AdvancedOptions/RenameOutputFiles/Pattern");
+LAMEXP_MAKE_ID(overwriteMode, "AdvancedOptions/OverwriteMode");
 LAMEXP_MAKE_ID(hibernateComputer, "AdvancedOptions/HibernateComputerOnShutdown");
 LAMEXP_MAKE_ID(metaInfoPosition, "MetaInformation/PlaylistPosition");
 LAMEXP_MAKE_ID(maximumInstances, "AdvancedOptions/Threading/MaximumInstances");
@@ -222,10 +228,13 @@ void SettingsModel::validate(void)
        {
                if(!(lamexp_check_tool("fhgaacenc.exe") && lamexp_check_tool("enc_fhgaac.dll")))
                {
-                       if(this->compressionEncoder() == SettingsModel::AACEncoder)
+                       if(!(lamexp_check_tool("qaac.exe") && lamexp_check_tool("libsoxrate.dll")))
                        {
-                               qWarning("AAC encoder selected, but not available any more. Reverting to MP3!");
-                               this->compressionEncoder(SettingsModel::MP3Encoder);
+                               if(this->compressionEncoder() == SettingsModel::AACEncoder)
+                               {
+                                       qWarning("AAC encoder selected, but not available any more. Reverting to MP3!");
+                                       this->compressionEncoder(SettingsModel::MP3Encoder);
+                               }
                        }
                }
        }
@@ -242,6 +251,16 @@ void SettingsModel::validate(void)
                this->outputDir(musicLocation.isEmpty() ? QDesktopServices::storageLocation(QDesktopServices::HomeLocation) : musicLocation);
        }
 
+       if(!this->currentLanguageFile().isEmpty())
+       {
+               const QString qmPath = QFileInfo(this->currentLanguageFile()).canonicalFilePath();
+               if(qmPath.isEmpty() || (!(QFileInfo(qmPath).exists() && QFileInfo(qmPath).isFile() && (QFileInfo(qmPath).suffix().compare("qm", Qt::CaseInsensitive) == 0))))
+               {
+                       qWarning("Current language file missing, reverting to built-in translator!");
+                       this->currentLanguageFile(QString());
+               }
+       }
+
        if(!lamexp_query_translations().contains(this->currentLanguage(), Qt::CaseInsensitive))
        {
                qWarning("Current language \"%s\" is unknown, reverting to default language!", this->currentLanguage().toLatin1().constData());
@@ -255,6 +274,17 @@ void SettingsModel::validate(void)
                        this->hibernateComputer(false);
                }
        }
+
+       if(this->overwriteMode() < SettingsModel::Overwrite_KeepBoth || this->overwriteMode() > SettingsModel::Overwrite_Replaces)
+       {
+               this->overwriteMode(SettingsModel::Overwrite_KeepBoth);
+       }
+
+}
+
+void SettingsModel::syncNow(void)
+{
+       m_settings->sync();
 }
 
 ////////////////////////////////////////////////////////////
@@ -268,21 +298,42 @@ QString SettingsModel::defaultLanguage(void)
                return *m_defaultLanguage;
        }
        
-       //Check if we can use the default translation
+       //Detect system langauge
        QLocale systemLanguage= QLocale::system();
-       if(systemLanguage.language() == QLocale::English || systemLanguage.language() == QLocale::C)
+       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
+       if(systemLanguage.language() == QLocale::English /*|| systemLanguage.language() == QLocale::C*/)
        {
                m_defaultLanguage = new QString(LAMEXP_DEFAULT_LANGID);
                return LAMEXP_DEFAULT_LANGID;
        }
 
-       //Try to find a suitable translation for the user's system language
+       //Try to find a suitable translation for the user's system language *and* country
        QStringList languages = lamexp_query_translations();
        while(!languages.isEmpty())
        {
                QString currentLangId = languages.takeFirst();
                if(lamexp_translation_sysid(currentLangId) == systemLanguage.language())
                {
+                       if(lamexp_translation_country(currentLangId) == systemLanguage.country())
+                       {
+                               m_defaultLanguage = new QString(currentLangId);
+                               return currentLangId;
+                       }
+               }
+       }
+
+       //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;
                }
@@ -341,6 +392,7 @@ LAMEXP_MAKE_OPTION_B(antivirNotificationsEnabled, true)
 LAMEXP_MAKE_OPTION_B(dropBoxWidgetEnabled, true)
 LAMEXP_MAKE_OPTION_B(shellIntegrationEnabled, !lamexp_portable_mode())
 LAMEXP_MAKE_OPTION_S(currentLanguage, defaultLanguage())
+LAMEXP_MAKE_OPTION_S(currentLanguageFile, QString())
 LAMEXP_MAKE_OPTION_I(lameAlgoQuality, 3)
 LAMEXP_MAKE_OPTION_I(lameChannelMode, 0)
 LAMEXP_MAKE_OPTION_B(forceStereoDownmix, false)
@@ -354,6 +406,9 @@ LAMEXP_MAKE_OPTION_I(aftenAudioCodingMode, 0);
 LAMEXP_MAKE_OPTION_I(aftenDynamicRangeCompression, 5);
 LAMEXP_MAKE_OPTION_B(aftenFastBitAllocation, false);
 LAMEXP_MAKE_OPTION_I(aftenExponentSearchSize, 8);
+LAMEXP_MAKE_OPTION_I(opusOptimizeFor, 0);
+LAMEXP_MAKE_OPTION_I(opusComplexity, 10);
+LAMEXP_MAKE_OPTION_I(opusFramesize, 3);
 LAMEXP_MAKE_OPTION_B(normalizationFilterEnabled, false)
 LAMEXP_MAKE_OPTION_I(normalizationFilterMaxVolume, -50)
 LAMEXP_MAKE_OPTION_I(normalizationFilterEqualizationMode, 0);
@@ -364,8 +419,10 @@ LAMEXP_MAKE_OPTION_S(customParametersOggEnc, QString());
 LAMEXP_MAKE_OPTION_S(customParametersAacEnc, QString());
 LAMEXP_MAKE_OPTION_S(customParametersAften, QString());
 LAMEXP_MAKE_OPTION_S(customParametersFLAC, QString());
+LAMEXP_MAKE_OPTION_S(customParametersOpus, QString());
 LAMEXP_MAKE_OPTION_B(renameOutputFilesEnabled, false);
 LAMEXP_MAKE_OPTION_S(renameOutputFilesPattern, "[<TrackNo>] <Artist> - <Title>");
+LAMEXP_MAKE_OPTION_I(overwriteMode, Overwrite_KeepBoth);
 LAMEXP_MAKE_OPTION_U(metaInfoPosition, UINT_MAX);
 LAMEXP_MAKE_OPTION_U(maximumInstances, 0);
 LAMEXP_MAKE_OPTION_S(customTempPath, QDesktopServices::storageLocation(QDesktopServices::TempLocation));