diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui --- a/src/qt/forms/optionsdialog.ui +++ b/src/qt/forms/optionsdialog.ui @@ -692,17 +692,34 @@ - - - Reset all client options to default. - - - &Reset Options - - - false - - + + + + + Open the %1 configuration file from the working directory. + + + Open Configuration File + + + false + + + + + + + Reset all client options to default. + + + &Reset Options + + + false + + + + @@ -756,27 +773,48 @@ - - - &OK - - - false - - - true - - - - - - - &Cancel - - - false - - + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + &OK + + + false + + + true + + + + + + + &Cancel + + + false + + + + + + diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -146,6 +146,9 @@ // Open debug.log void openDebugLogfile(); +// Open the config file +bool openBitcoinConf(); + // Replace invalid default fonts with known good ones void SubstituteFonts(const QString &language); diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -426,6 +426,23 @@ } } +bool openBitcoinConf() { + fs::path pathConfig = GetConfigFile(BITCOIN_CONF_FILENAME); + + /* Create the file */ + fs::ofstream configFile(pathConfig, std::ios_base::app); + + if (!configFile.good()) { + return false; + } + + configFile.close(); + + /* Open bitcoin.conf with the associated application */ + return QDesktopServices::openUrl( + QUrl::fromLocalFile(boostPathToQString(pathConfig))); +} + void SubstituteFonts(const QString &language) { #if defined(Q_OS_MAC) // Background: diff --git a/src/qt/optionsdialog.h b/src/qt/optionsdialog.h --- a/src/qt/optionsdialog.h +++ b/src/qt/optionsdialog.h @@ -44,6 +44,7 @@ /* set OK button state (enabled / disabled) */ void setOkButtonState(bool fState); void on_resetButton_clicked(); + void on_openBitcoinConfButton_clicked(); void on_okButton_clicked(); void on_cancelButton_clicked(); diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -229,6 +229,22 @@ } } +void OptionsDialog::on_openBitcoinConfButton_clicked() { + /* explain the purpose of the config file */ + QMessageBox::information( + this, tr("Configuration options"), + tr("The configuration file is used to specify advanced user options " + "which override GUI settings. Additionally, any command-line " + "options will override this configuration file.")); + + /* show an error if there was some problem opening the file */ + if (!GUIUtil::openBitcoinConf()) { + QMessageBox::critical( + this, tr("Error"), + tr("The configuration file could not be opened.")); + } +} + void OptionsDialog::on_okButton_clicked() { mapper->submit(); accept();