# # # patch "NEWS" # from [49516b1791031fe122df5aacb068924c3e7d96da] # to [c8b848ec9e98e49c9edfe873756526c8564f005f] # # patch "res/forms/preferences.ui" # from [182c4b2a6f2f3ae5c7b31a0de50b5ee97200ace9] # to [0d11100970f4e76902c87bc53331a28b5f0cd993] # # patch "src/util/DebugLog.cpp" # from [319ef1250e361a48383b70c7cd52d614b63ef794] # to [48dfa3b27d18db58e4c43658638b5f7d743a7310] # # patch "src/util/DebugLog.h" # from [dc63b4ee3fb60f00c62c32e7c4634e75bc6eae98] # to [18c30e48c09f79bda5a7b5718ea4c486eb5622da] # # patch "src/util/Settings.cpp" # from [7fe33df35ead425818ac4cbd35444dbb82de072f] # to [6ae8dc50c2d2a70c5467149d5311180dbad82221] # # patch "src/util/Settings.h" # from [19b198d8e78259744a90bb47f052b0699a668913] # to [82ecbfc330968be9bd7974ed450ada6e81327dbb] # # patch "src/view/dialogs/Preferences.cpp" # from [6da852bb8c13dcefc4495883dd4e066580a3b9d7] # to [1e3bc13f16b3a04e84f5fc8ce2add567a35db359] # # patch "src/view/dialogs/Preferences.h" # from [65877554b3a3c1cb86cfb0ee59a2e704590325a4] # to [1f94546a76f71723b8a95a8823fc45ad570b6832] # ============================================================ --- NEWS 49516b1791031fe122df5aacb068924c3e7d96da +++ NEWS c8b848ec9e98e49c9edfe873756526c8564f005f @@ -24,6 +24,7 @@ - new: an installer for win32 which takes care of needed libraries and proper uninstallation - new: colors for diff views can now be configured in the preferences + - new: settings can now be reset to their defaults in the preferences dialog - improved: startup dialog slightly changed - now contains the possibility to edit the preferences, open recent databases and workspaces. Removed this functionality from the initialization phase of the application which was ============================================================ --- res/forms/preferences.ui 182c4b2a6f2f3ae5c7b31a0de50b5ee97200ace9 +++ res/forms/preferences.ui 0d11100970f4e76902c87bc53331a28b5f0cd993 @@ -16,7 +16,7 @@ Preferences - + :/icons/guitone.png:/icons/guitone.png @@ -25,12 +25,24 @@ true - + + + + + + QTabWidget::North + + + QTabWidget::Rounded + 0 + + false + @@ -274,8 +286,8 @@ Miscellaneous - - + + check for updates on application launch @@ -285,7 +297,7 @@ - + read workspace incrementally (faster for big directory trees) @@ -295,7 +307,7 @@ - + disable auto-completion in commit dialog @@ -305,7 +317,7 @@ - + ask before opening executable files and files with @@ -316,10 +328,30 @@ the following extensions (comma-separate - - + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + - + Qt::Vertical @@ -339,6 +371,13 @@ the following extensions (comma-separate + + + Reset Settings + + + + Qt::Horizontal @@ -387,7 +426,7 @@ the following extensions (comma-separate cancelButton - + ============================================================ --- src/util/DebugLog.cpp 319ef1250e361a48383b70c7cd52d614b63ef794 +++ src/util/DebugLog.cpp 48dfa3b27d18db58e4c43658638b5f7d743a7310 @@ -39,8 +39,8 @@ DebugLog::DebugLog() DebugLog::DebugLog() { - consoleLogging = Settings::getConsoleLogEnabled(); - fileLogging = Settings::getFileLogEnabled(); + consoleLogging = Settings::getBool("ConsoleLogEnabled", true); + fileLogging = Settings::getBool("FileLogEnabled", false); int level = Settings::getLogLevel(); if (level >= Fatal && level <= Debug) logLevel = static_cast(level); @@ -164,14 +164,8 @@ void DebugLog::setConsoleLogEnabled(bool { DebugLog * log = singleton(); log->consoleLogging = enabled; - Settings::setConsoleLogEnabled(enabled); } -bool DebugLog::getConsoleLogEnabled() -{ - return singleton()->consoleLogging; -} - void DebugLog::setFileLogEnabled(bool enabled) { DebugLog * log = singleton(); @@ -189,26 +183,14 @@ void DebugLog::setFileLogEnabled(bool en } } log->fileLogging = enabled; - Settings::setFileLogEnabled(enabled); } -bool DebugLog::getFileLogEnabled() -{ - return singleton()->fileLogging; -} - void DebugLog::setLogLevel(int level) { if (level < Fatal || level > Debug) return; singleton()->logLevel = static_cast(level); - Settings::setLogLevel(level); } -int DebugLog::getLogLevel() -{ - return static_cast(singleton()->logLevel); -} - QString DebugLog::logFilePath() { QString path(QDir::homePath()); ============================================================ --- src/util/DebugLog.h dc63b4ee3fb60f00c62c32e7c4634e75bc6eae98 +++ src/util/DebugLog.h 18c30e48c09f79bda5a7b5718ea4c486eb5622da @@ -37,10 +37,6 @@ public: static void setConsoleLogEnabled(bool); static void setLogLevel(int); - static bool getFileLogEnabled(); - static bool getConsoleLogEnabled(); - static int getLogLevel(); - static QString logFilePath(); static void info(QString); ============================================================ --- src/util/Settings.cpp 7fe33df35ead425818ac4cbd35444dbb82de072f +++ src/util/Settings.cpp 6ae8dc50c2d2a70c5467149d5311180dbad82221 @@ -81,6 +81,11 @@ void Settings::sync() singleton()->QSettings::sync(); } +void Settings::clear() +{ + singleton()->QSettings::clear(); +} + QString Settings::getMtnBinaryPath() { return singleton()->value("MtnExePath", "mtn").toString(); @@ -91,26 +96,6 @@ void Settings::setMtnBinaryPath(const QS singleton()->setValue("MtnExePath", path); } -bool Settings::getConsoleLogEnabled() -{ - return singleton()->value("ConsoleLogEnabled", true).toBool(); -} - -void Settings::setConsoleLogEnabled(bool enabled) -{ - singleton()->setValue("ConsoleLogEnabled", enabled); -} - -bool Settings::getFileLogEnabled() -{ - return singleton()->value("FileLogEnabled", false).toBool(); -} - -void Settings::setFileLogEnabled(bool enabled) -{ - singleton()->setValue("FileLogEnabled", enabled); -} - int Settings::getLogLevel() { // 4 is debug, see DebugLog.h @@ -119,6 +104,7 @@ void Settings::setLogLevel(int verbosity void Settings::setLogLevel(int verbosity) { + I(verbosity >= 1 && verbosity <= 5); singleton()->setValue("LogLevel", verbosity); } ============================================================ --- src/util/Settings.h 19b198d8e78259744a90bb47f052b0699a668913 +++ src/util/Settings.h 82ecbfc330968be9bd7974ed450ada6e81327dbb @@ -44,10 +44,6 @@ public: static QString getMtnBinaryPath(); static void setMtnBinaryPath(const QString &); - static bool getConsoleLogEnabled(); - static void setConsoleLogEnabled(bool); - static bool getFileLogEnabled(); - static void setFileLogEnabled(bool); static int getLogLevel(); static void setLogLevel(int); @@ -57,6 +53,7 @@ public: static QByteArray getSplitterState(const QString &); static void setSplitterState(const QByteArray &, const QString &); + static void clear(); static void sync(); private: ============================================================ --- src/view/dialogs/Preferences.cpp 6da852bb8c13dcefc4495883dd4e066580a3b9d7 +++ src/view/dialogs/Preferences.cpp 1e3bc13f16b3a04e84f5fc8ce2add567a35db359 @@ -31,21 +31,52 @@ Preferences::Preferences(QWidget * paren setupUi(this); Dialog::init(); + // init the values before connecting the signals, otherwise + // the user might be notified of something which we did + // programmatically + init(); + + connect( + selectMtnExecutable, SIGNAL(clicked()), + this, SLOT(openFileBrowser()) + ); + + connect( + relaxedVersionCheck, SIGNAL(toggled(bool)), + this, SLOT(warnAboutRelaxedVersionChecking(bool)) + ); + + connect( + resetSettings, SIGNAL(clicked()), + this, SLOT(resetAllSettings()) + ); +} + +Preferences::~Preferences() {} + +void Preferences::init() +{ mtnExecutablePath->setText(Settings::getMtnBinaryPath()); - enableConsoleLog->setCheckState(DebugLog::getConsoleLogEnabled() ? - Qt::Checked : Qt::Unchecked); - enableFileLog->setCheckState(DebugLog::getFileLogEnabled() ? - Qt::Checked : Qt::Unchecked); + enableConsoleLog->setCheckState( + Settings::getBool("ConsoleLogEnabled", true) ? + Qt::Checked : Qt::Unchecked + ); + enableFileLog->setCheckState( + Settings::getBool("FileLogEnabled", false) ? + Qt::Checked : Qt::Unchecked + ); + enableFileLog->setText(enableFileLog->text().arg(DebugLog::logFilePath())); + logLevel->clear(); logLevel->addItem(tr("Very low (only fatal)"), 1); logLevel->addItem(tr("Low (critical)"), 2); logLevel->addItem(tr("Medium (warnings)"), 3); logLevel->addItem(tr("High (info messages)"), 4); - int lvl = DebugLog::getLogLevel(); + int lvl = Settings::getLogLevel(); #ifndef QT_NO_DEBUG logLevel->addItem(tr("Very high (debug messages)"), 5); #else @@ -76,12 +107,6 @@ Preferences::Preferences(QWidget * paren colorPickerRemovedLines->setSelectedColor( QColor(Settings::getString("DiffColorRemovedLines", "red")) ); - - connect( - selectMtnExecutable, SIGNAL(clicked()), - this, SLOT(openFileBrowser()) - ); - relaxedVersionCheck->setCheckState( Settings::getBool("RelaxedVersionCheck", false) ? Qt::Checked : Qt::Unchecked @@ -100,15 +125,8 @@ Preferences::Preferences(QWidget * paren Settings::getBool("ReadWorkspaceIncrementally", false) ? Qt::Checked : Qt::Unchecked ); - - connect( - relaxedVersionCheck, SIGNAL(toggled(bool)), - this, SLOT(warnAboutRelaxedVersionChecking(bool)) - ); } -Preferences::~Preferences() {} - void Preferences::accept() { QString oldPath = Settings::getMtnBinaryPath(); @@ -157,6 +175,10 @@ void Preferences::accept() DebugLog::setFileLogEnabled(fileEnabled); DebugLog::setLogLevel(level); + Settings::setBool("ConsoleLogEnabled", consoleEnabled); + Settings::setBool("FileLogEnabled", fileEnabled); + Settings::setLogLevel(level); + Settings::setBool("CheckForUpdates", checkForUpdates->isChecked()); Settings::setBool("RelaxedVersionCheck", relaxedVersionCheck->isChecked()); Settings::setBool("AskFileOpen", askFileOpen->isChecked()); @@ -211,3 +233,18 @@ void Preferences::warnAboutRelaxedVersio ); } +void Preferences::resetAllSettings() +{ + if (QMessageBox::question( + this, + tr("Warning"), + tr("Do you really want to reset all settings to their defaults?"), + QMessageBox::Yes | QMessageBox::No) == + QMessageBox::Yes) + { + Settings::clear(); + Settings::sync(); + init(); + } +} + ============================================================ --- src/view/dialogs/Preferences.h 65877554b3a3c1cb86cfb0ee59a2e704590325a4 +++ src/view/dialogs/Preferences.h 1f94546a76f71723b8a95a8823fc45ad570b6832 @@ -33,6 +33,10 @@ private slots: void openFileBrowser(); void accept(); void warnAboutRelaxedVersionChecking(bool); + void resetAllSettings(); + +private: + void init(); }; #endif