Browse Source

Add a button to open the config file in a text editor

0.15
Eric Shaw Jr 8 years ago
parent
commit
9ab9e7d1b3
  1. 38
      src/qt/forms/optionsdialog.ui
  2. 16
      src/qt/guiutil.cpp
  3. 3
      src/qt/guiutil.h
  4. 12
      src/qt/optionsdialog.cpp
  5. 1
      src/qt/optionsdialog.h

38
src/qt/forms/optionsdialog.ui

@ -691,6 +691,21 @@
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_Buttons"> <layout class="QHBoxLayout" name="horizontalLayout_Buttons">
<item>
<layout class="QVBoxLayout" name="verticalLayout_Buttons">
<item>
<widget class="QPushButton" name="openBitcoinConfButton">
<property name="toolTip">
<string>Open the %1 configuration file from the working directory.</string>
</property>
<property name="text">
<string>Open Configuration File</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="resetButton"> <widget class="QPushButton" name="resetButton">
<property name="toolTip"> <property name="toolTip">
@ -704,6 +719,8 @@
</property> </property>
</widget> </widget>
</item> </item>
</layout>
</item>
<item> <item>
<spacer name="horizontalSpacer_1"> <spacer name="horizontalSpacer_1">
<property name="orientation"> <property name="orientation">
@ -755,6 +772,23 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QPushButton" name="okButton"> <widget class="QPushButton" name="okButton">
<property name="text"> <property name="text">
@ -781,6 +815,10 @@
</layout> </layout>
</item> </item>
</layout> </layout>
</item>
</layout>
</item>
</layout>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>

16
src/qt/guiutil.cpp

@ -417,6 +417,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)

3
src/qt/guiutil.h

@ -114,6 +114,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);

12
src/qt/optionsdialog.cpp

@ -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();

1
src/qt/optionsdialog.h

@ -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();

Loading…
Cancel
Save