diff --git a/src/Config.h b/src/Config.h index 63dc37c2..b8ed9009 100644 --- a/src/Config.h +++ b/src/Config.h @@ -33,8 +33,8 @@ #define VER_LAMEXP_MINOR_HI 0 #define VER_LAMEXP_MINOR_LO 8 #define VER_LAMEXP_TYPE Alpha -#define VER_LAMEXP_PATCH 5 -#define VER_LAMEXP_BUILD 1310 +#define VER_LAMEXP_PATCH 6 +#define VER_LAMEXP_BUILD 1312 #define VER_LAMEXP_CONFG 1288 /////////////////////////////////////////////////////////////////////////////// diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index db9e4c49..aa0acd25 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -152,9 +152,9 @@ while(0) #define WITH_BLOCKED_SIGNALS(WIDGET, CMD, ...) do \ { \ - (WIDGET)->blockSignals(true); \ + const bool _flag = (WIDGET)->blockSignals(true); \ (WIDGET)->CMD(__VA_ARGS__); \ - (WIDGET)->blockSignals(false); \ + if(!(_flag)) { (WIDGET)->blockSignals(false); } \ } \ while(0) diff --git a/src/Model_Settings.cpp b/src/Model_Settings.cpp index 23d9244b..966ef329 100644 --- a/src/Model_Settings.cpp +++ b/src/Model_Settings.cpp @@ -63,6 +63,8 @@ unsigned int SettingsModel::OPT##Default(void) { return DEF; } #define LAMEXP_MAKE_ID(DEC,STR) static const char *g_settingsId_##DEC = STR #define REMOVE_GROUP(OBJ,ID) OBJ->beginGroup(ID); OBJ->remove(""); OBJ->endGroup(); +#define DIR_EXISTS(PATH) (QFileInfo(PATH).exists() && QFileInfo(PATH).isDir()) + //////////////////////////////////////////////////////////// //Constants //////////////////////////////////////////////////////////// @@ -274,17 +276,16 @@ void SettingsModel::validate(void) } } - if(this->outputDir().isEmpty() || !QFileInfo(this->outputDir()).isDir()) + if(this->outputDir().isEmpty() || (!DIR_EXISTS(this->outputDir()))) { - qWarning("Output directory not set yet or does NOT exist anymore -> Resetting to QDesktopServices::MusicLocation"); - QString musicLocation = QDesktopServices::storageLocation(QDesktopServices::MusicLocation); - this->outputDir(musicLocation.isEmpty() ? QDesktopServices::storageLocation(QDesktopServices::HomeLocation) : musicLocation); + qWarning("Output directory not set yet or does NOT exist anymore -> Resetting"); + this->outputDir(defaultDirectory()); } - if(this->mostRecentInputPath().isEmpty() || !QFileInfo(this->mostRecentInputPath()).isDir()) + if(this->mostRecentInputPath().isEmpty() || (!DIR_EXISTS(this->mostRecentInputPath()))) { - QString musicLocation = QDesktopServices::storageLocation(QDesktopServices::MusicLocation); - this->outputDir(musicLocation.isEmpty() ? QDesktopServices::storageLocation(QDesktopServices::HomeLocation) : musicLocation); + qWarning("Most recent input directory not set yet or does NOT exist anymore -> Resetting"); + this->mostRecentInputPath(defaultDirectory()); } if(!this->currentLanguageFile().isEmpty()) @@ -388,7 +389,24 @@ QString SettingsModel::defaultLanguage(void) const return LAMEXP_DEFAULT_LANGID; } -QString SettingsModel::initDirectory(const QString &path) +QString SettingsModel::defaultDirectory(void) const +{ + QString defaultLocation = initDirectory(QDesktopServices::storageLocation(QDesktopServices::MusicLocation)); + + if(defaultLocation.isEmpty()) + { + defaultLocation = initDirectory(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); + + if(defaultLocation.isEmpty()) + { + defaultLocation = initDirectory(QDir::currentPath()); + } + } + + return defaultLocation; +} + +QString SettingsModel::initDirectory(const QString &path) const { if(path.isEmpty()) { @@ -466,7 +484,7 @@ LAMEXP_MAKE_OPTION_I(lameChannelMode, 0) LAMEXP_MAKE_OPTION_I(licenseAccepted, 0) LAMEXP_MAKE_OPTION_U(maximumInstances, 0) LAMEXP_MAKE_OPTION_U(metaInfoPosition, UINT_MAX) -LAMEXP_MAKE_OPTION_S(mostRecentInputPath, QDesktopServices::storageLocation(QDesktopServices::MusicLocation)) +LAMEXP_MAKE_OPTION_S(mostRecentInputPath, defaultDirectory()) LAMEXP_MAKE_OPTION_B(neroAACEnable2Pass, true) LAMEXP_MAKE_OPTION_B(neroAacNotificationsEnabled, true) LAMEXP_MAKE_OPTION_B(normalizationFilterEnabled, false) @@ -476,7 +494,7 @@ LAMEXP_MAKE_OPTION_I(opusComplexity, 10) LAMEXP_MAKE_OPTION_B(opusDisableResample, false) LAMEXP_MAKE_OPTION_I(opusFramesize, 3) LAMEXP_MAKE_OPTION_I(opusOptimizeFor, 0) -LAMEXP_MAKE_OPTION_S(outputDir, QDesktopServices::storageLocation(QDesktopServices::MusicLocation)) +LAMEXP_MAKE_OPTION_S(outputDir, defaultDirectory()) LAMEXP_MAKE_OPTION_B(outputToSourceDir, false) LAMEXP_MAKE_OPTION_I(overwriteMode, Overwrite_KeepBoth) LAMEXP_MAKE_OPTION_B(prependRelativeSourcePath, false) diff --git a/src/Model_Settings.h b/src/Model_Settings.h index fc756d8d..89a79c5f 100644 --- a/src/Model_Settings.h +++ b/src/Model_Settings.h @@ -169,9 +169,10 @@ public: private: QSettings *m_settings; - QString initDirectory(const QString &path); static QString *m_defaultLanguage; + QString initDirectory(const QString &path) const; QString defaultLanguage(void) const; + QString defaultDirectory(void) const; }; ///////////////////////////////////////////////////////////////////////////////