Skip to content

Commit 1fa4ae6

Browse files
committed
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
2 parents 64962ae + 9ab9e7d commit 1fa4ae6

File tree

5 files changed

+102
-32
lines changed

5 files changed

+102
-32
lines changed

src/qt/forms/optionsdialog.ui

Lines changed: 70 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -692,17 +692,34 @@
692692
<item>
693693
<layout class="QHBoxLayout" name="horizontalLayout_Buttons">
694694
<item>
695-
<widget class="QPushButton" name="resetButton">
696-
<property name="toolTip">
697-
<string>Reset all client options to default.</string>
698-
</property>
699-
<property name="text">
700-
<string>&amp;Reset Options</string>
701-
</property>
702-
<property name="autoDefault">
703-
<bool>false</bool>
704-
</property>
705-
</widget>
695+
<layout class="QVBoxLayout" name="verticalLayout_Buttons">
696+
<item>
697+
<widget class="QPushButton" name="openBitcoinConfButton">
698+
<property name="toolTip">
699+
<string>Open the %1 configuration file from the working directory.</string>
700+
</property>
701+
<property name="text">
702+
<string>Open Configuration File</string>
703+
</property>
704+
<property name="autoDefault">
705+
<bool>false</bool>
706+
</property>
707+
</widget>
708+
</item>
709+
<item>
710+
<widget class="QPushButton" name="resetButton">
711+
<property name="toolTip">
712+
<string>Reset all client options to default.</string>
713+
</property>
714+
<property name="text">
715+
<string>&amp;Reset Options</string>
716+
</property>
717+
<property name="autoDefault">
718+
<bool>false</bool>
719+
</property>
720+
</widget>
721+
</item>
722+
</layout>
706723
</item>
707724
<item>
708725
<spacer name="horizontalSpacer_1">
@@ -756,27 +773,48 @@
756773
</spacer>
757774
</item>
758775
<item>
759-
<widget class="QPushButton" name="okButton">
760-
<property name="text">
761-
<string>&amp;OK</string>
762-
</property>
763-
<property name="autoDefault">
764-
<bool>false</bool>
765-
</property>
766-
<property name="default">
767-
<bool>true</bool>
768-
</property>
769-
</widget>
770-
</item>
771-
<item>
772-
<widget class="QPushButton" name="cancelButton">
773-
<property name="text">
774-
<string>&amp;Cancel</string>
775-
</property>
776-
<property name="autoDefault">
777-
<bool>false</bool>
778-
</property>
779-
</widget>
776+
<layout class="QVBoxLayout" name="verticalLayout_4">
777+
<item>
778+
<spacer name="verticalSpacer">
779+
<property name="orientation">
780+
<enum>Qt::Vertical</enum>
781+
</property>
782+
<property name="sizeHint" stdset="0">
783+
<size>
784+
<width>20</width>
785+
<height>40</height>
786+
</size>
787+
</property>
788+
</spacer>
789+
</item>
790+
<item>
791+
<layout class="QHBoxLayout" name="horizontalLayout">
792+
<item>
793+
<widget class="QPushButton" name="okButton">
794+
<property name="text">
795+
<string>&amp;OK</string>
796+
</property>
797+
<property name="autoDefault">
798+
<bool>false</bool>
799+
</property>
800+
<property name="default">
801+
<bool>true</bool>
802+
</property>
803+
</widget>
804+
</item>
805+
<item>
806+
<widget class="QPushButton" name="cancelButton">
807+
<property name="text">
808+
<string>&amp;Cancel</string>
809+
</property>
810+
<property name="autoDefault">
811+
<bool>false</bool>
812+
</property>
813+
</widget>
814+
</item>
815+
</layout>
816+
</item>
817+
</layout>
780818
</item>
781819
</layout>
782820
</item>

src/qt/guiutil.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,22 @@ void openDebugLogfile()
415415
QDesktopServices::openUrl(QUrl::fromLocalFile(boostPathToQString(pathDebug)));
416416
}
417417

418+
bool openBitcoinConf()
419+
{
420+
boost::filesystem::path pathConfig = GetConfigFile(BITCOIN_CONF_FILENAME);
421+
422+
/* Create the file */
423+
boost::filesystem::ofstream configFile(pathConfig, std::ios_base::app);
424+
425+
if (!configFile.good())
426+
return false;
427+
428+
configFile.close();
429+
430+
/* Open bitcoin.conf with the associated application */
431+
return QDesktopServices::openUrl(QUrl::fromLocalFile(boostPathToQString(pathConfig)));
432+
}
433+
418434
void SubstituteFonts(const QString& language)
419435
{
420436
#if defined(Q_OS_MAC)

src/qt/guiutil.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ namespace GUIUtil
113113
// Open debug.log
114114
void openDebugLogfile();
115115

116+
// Open the config file
117+
bool openBitcoinConf();
118+
116119
// Replace invalid default fonts with known good ones
117120
void SubstituteFonts(const QString& language);
118121

src/qt/optionsdialog.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,18 @@ void OptionsDialog::on_resetButton_clicked()
232232
}
233233
}
234234

235+
void OptionsDialog::on_openBitcoinConfButton_clicked()
236+
{
237+
/* explain the purpose of the config file */
238+
QMessageBox::information(this, tr("Configuration options"),
239+
tr("The configuration file is used to specify advanced user options which override GUI settings. "
240+
"Additionally, any command-line options will override this configuration file."));
241+
242+
/* show an error if there was some problem opening the file */
243+
if (!GUIUtil::openBitcoinConf())
244+
QMessageBox::critical(this, tr("Error"), tr("The configuration file could not be opened."));
245+
}
246+
235247
void OptionsDialog::on_okButton_clicked()
236248
{
237249
mapper->submit();

src/qt/optionsdialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ private Q_SLOTS:
4747
/* set OK button state (enabled / disabled) */
4848
void setOkButtonState(bool fState);
4949
void on_resetButton_clicked();
50+
void on_openBitcoinConfButton_clicked();
5051
void on_okButton_clicked();
5152
void on_cancelButton_clicked();
5253

0 commit comments

Comments
 (0)