Merge #9890: Add a button to open the config file in a text editor

9ab9e7d Add a button to open the config file in a text editor (Eric Shaw Jr)

Tree-SHA512: 1d13be9ac788a05a5116dbb3e1136ef65732dc2b5634547860612658109668922c9ea80b77bde4ba5beaa762d54f2a986a6064d4e34e963cdcd3d126a4eced37
This commit is contained in:
Jonas Schnelli 2017-04-10 10:45:51 +02:00
commit 1fa4ae67a3
No known key found for this signature in database
GPG Key ID: 1EB776BB03C7922D
5 changed files with 102 additions and 32 deletions

View File

@ -692,17 +692,34 @@
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_Buttons"> <layout class="QHBoxLayout" name="horizontalLayout_Buttons">
<item> <item>
<widget class="QPushButton" name="resetButton"> <layout class="QVBoxLayout" name="verticalLayout_Buttons">
<property name="toolTip"> <item>
<string>Reset all client options to default.</string> <widget class="QPushButton" name="openBitcoinConfButton">
</property> <property name="toolTip">
<property name="text"> <string>Open the %1 configuration file from the working directory.</string>
<string>&amp;Reset Options</string> </property>
</property> <property name="text">
<property name="autoDefault"> <string>Open Configuration File</string>
<bool>false</bool> </property>
</property> <property name="autoDefault">
</widget> <bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="resetButton">
<property name="toolTip">
<string>Reset all client options to default.</string>
</property>
<property name="text">
<string>&amp;Reset Options</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item> </item>
<item> <item>
<spacer name="horizontalSpacer_1"> <spacer name="horizontalSpacer_1">
@ -756,27 +773,48 @@
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QPushButton" name="okButton"> <layout class="QVBoxLayout" name="verticalLayout_4">
<property name="text"> <item>
<string>&amp;OK</string> <spacer name="verticalSpacer">
</property> <property name="orientation">
<property name="autoDefault"> <enum>Qt::Vertical</enum>
<bool>false</bool> </property>
</property> <property name="sizeHint" stdset="0">
<property name="default"> <size>
<bool>true</bool> <width>20</width>
</property> <height>40</height>
</widget> </size>
</item> </property>
<item> </spacer>
<widget class="QPushButton" name="cancelButton"> </item>
<property name="text"> <item>
<string>&amp;Cancel</string> <layout class="QHBoxLayout" name="horizontalLayout">
</property> <item>
<property name="autoDefault"> <widget class="QPushButton" name="okButton">
<bool>false</bool> <property name="text">
</property> <string>&amp;OK</string>
</widget> </property>
<property name="autoDefault">
<bool>false</bool>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>&amp;Cancel</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item> </item>
</layout> </layout>
</item> </item>

View File

@ -415,6 +415,22 @@ void openDebugLogfile()
QDesktopServices::openUrl(QUrl::fromLocalFile(boostPathToQString(pathDebug))); QDesktopServices::openUrl(QUrl::fromLocalFile(boostPathToQString(pathDebug)));
} }
bool openBitcoinConf()
{
boost::filesystem::path pathConfig = GetConfigFile(BITCOIN_CONF_FILENAME);
/* Create the file */
boost::filesystem::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) void SubstituteFonts(const QString& language)
{ {
#if defined(Q_OS_MAC) #if defined(Q_OS_MAC)

View File

@ -113,6 +113,9 @@ namespace GUIUtil
// Open debug.log // Open debug.log
void openDebugLogfile(); void openDebugLogfile();
// Open the config file
bool openBitcoinConf();
// Replace invalid default fonts with known good ones // Replace invalid default fonts with known good ones
void SubstituteFonts(const QString& language); void SubstituteFonts(const QString& language);

View File

@ -232,6 +232,18 @@ void OptionsDialog::on_resetButton_clicked()
} }
} }
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() void OptionsDialog::on_okButton_clicked()
{ {
mapper->submit(); mapper->submit();

View File

@ -47,6 +47,7 @@ private Q_SLOTS:
/* set OK button state (enabled / disabled) */ /* set OK button state (enabled / disabled) */
void setOkButtonState(bool fState); void setOkButtonState(bool fState);
void on_resetButton_clicked(); void on_resetButton_clicked();
void on_openBitcoinConfButton_clicked();
void on_okButton_clicked(); void on_okButton_clicked();
void on_cancelButton_clicked(); void on_cancelButton_clicked();