Merge pull request #7006

f71bfef add UI help for -resetguisettings (Jonas Schnelli)
ae98388 [Qt] add startup option to reset Qt settings (Jonas Schnelli)
This commit is contained in:
Jonas Schnelli 2015-11-25 09:04:49 +01:00
commit 26af1ac7cb
No known key found for this signature in database
GPG Key ID: 29D4BCB6416F53EC
4 changed files with 13 additions and 9 deletions

View File

@ -501,6 +501,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-min", _("Start minimized")); strUsage += HelpMessageOpt("-min", _("Start minimized"));
strUsage += HelpMessageOpt("-rootcertificates=<file>", _("Set SSL root certificates for payment request (default: -system-)")); strUsage += HelpMessageOpt("-rootcertificates=<file>", _("Set SSL root certificates for payment request (default: -system-)"));
strUsage += HelpMessageOpt("-splash", _("Show splash screen on startup (default: 1)")); strUsage += HelpMessageOpt("-splash", _("Show splash screen on startup (default: 1)"));
strUsage += HelpMessageOpt("-resetguisettings", _("Reset all settings changes made over the GUI"));
if (showDebug) { if (showDebug) {
strUsage += HelpMessageOpt("-uiplatform", "Select platform to customize UI for (one of windows, macosx, other; default: platform compiled on)"); strUsage += HelpMessageOpt("-uiplatform", "Select platform to customize UI for (one of windows, macosx, other; default: platform compiled on)");
} }

View File

@ -202,7 +202,7 @@ public:
void createPaymentServer(); void createPaymentServer();
#endif #endif
/// Create options model /// Create options model
void createOptionsModel(); void createOptionsModel(bool resetSettings);
/// Create main window /// Create main window
void createWindow(const NetworkStyle *networkStyle); void createWindow(const NetworkStyle *networkStyle);
/// Create splash screen /// Create splash screen
@ -352,9 +352,9 @@ void BitcoinApplication::createPaymentServer()
} }
#endif #endif
void BitcoinApplication::createOptionsModel() void BitcoinApplication::createOptionsModel(bool resetSettings)
{ {
optionsModel = new OptionsModel(); optionsModel = new OptionsModel(NULL, resetSettings);
} }
void BitcoinApplication::createWindow(const NetworkStyle *networkStyle) void BitcoinApplication::createWindow(const NetworkStyle *networkStyle)
@ -645,7 +645,7 @@ int main(int argc, char *argv[])
qInstallMessageHandler(DebugMessageHandler); qInstallMessageHandler(DebugMessageHandler);
#endif #endif
// Load GUI settings from QSettings // Load GUI settings from QSettings
app.createOptionsModel(); app.createOptionsModel(mapArgs.count("-resetguisettings") != 0);
// Subscribe to global signals from core // Subscribe to global signals from core
uiInterface.InitMessage.connect(InitMessage); uiInterface.InitMessage.connect(InitMessage);

View File

@ -26,10 +26,10 @@
#include <QSettings> #include <QSettings>
#include <QStringList> #include <QStringList>
OptionsModel::OptionsModel(QObject *parent) : OptionsModel::OptionsModel(QObject *parent, bool resetSettings) :
QAbstractListModel(parent) QAbstractListModel(parent)
{ {
Init(); Init(resetSettings);
} }
void OptionsModel::addOverriddenOption(const std::string &option) void OptionsModel::addOverriddenOption(const std::string &option)
@ -38,8 +38,11 @@ void OptionsModel::addOverriddenOption(const std::string &option)
} }
// Writes all missing QSettings with their default values // Writes all missing QSettings with their default values
void OptionsModel::Init() void OptionsModel::Init(bool resetSettings)
{ {
if (resetSettings)
Reset();
QSettings settings; QSettings settings;
// Ensure restart flag is unset on client startup // Ensure restart flag is unset on client startup

View File

@ -24,7 +24,7 @@ class OptionsModel : public QAbstractListModel
Q_OBJECT Q_OBJECT
public: public:
explicit OptionsModel(QObject *parent = 0); explicit OptionsModel(QObject *parent = 0, bool resetSettings = false);
enum OptionID { enum OptionID {
StartAtStartup, // bool StartAtStartup, // bool
@ -48,7 +48,7 @@ public:
OptionIDRowCount, OptionIDRowCount,
}; };
void Init(); void Init(bool resetSettings = false);
void Reset(); void Reset();
int rowCount(const QModelIndex & parent = QModelIndex()) const; int rowCount(const QModelIndex & parent = QModelIndex()) const;