Browse Source

[Qt] add startup option to reset Qt settings

pull/1/head
Jonas Schnelli 7 years ago
parent
commit
ae98388b22
No known key found for this signature in database
GPG Key ID: 29D4BCB6416F53EC
  1. 8
      src/qt/bitcoin.cpp
  2. 9
      src/qt/optionsmodel.cpp
  3. 4
      src/qt/optionsmodel.h

8
src/qt/bitcoin.cpp

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

9
src/qt/optionsmodel.cpp

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

4
src/qt/optionsmodel.h

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

Loading…
Cancel
Save