Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Apr 10, 2017

Conversation

Projects
None yet
6 participants
Contributor

ericshawlinux commented Feb 28, 2017

This button was described in issue #9655

I added it to the options dialog

@fanquake fanquake added the GUI label Mar 1, 2017

Owner

laanwj commented Mar 1, 2017

Concept ACK

Member

jonasschnelli commented Mar 1, 2017

Nice.
Concept ACK. Will test soon.

Member

jonasschnelli commented Mar 1, 2017

  • I think it should create the file if bitcoin.conf does not exists (right now, there is no reaction if the file does not exists)
  • The buttons should probably aligned/distributed vertically (horizontally it will eat up a lot of space in non en_EN lang)

bildschirmfoto 2017-03-01 um 22 26 46

bildschirmfoto 2017-03-01 um 22 26 32

Contributor

ericshawlinux commented Mar 1, 2017

Contributor

ericshawlinux commented Mar 2, 2017

@jonasschnelli Is this what you had in mind for the layout? I wanted to check before pushing

button_demo

Member

jonasschnelli commented Mar 2, 2017

@ericshawlinux: I think this looks better and is more flexible.

Contributor

ericshawlinux commented Mar 2, 2017

I think so too. I amended my commit from the other day

Contributor

ericshawlinux commented Mar 2, 2017

(I just fixed a mistake I made, I accidentally misplaced a spacer while using Qt-designer. It is back where it belongs now)

Member

luke-jr commented Mar 3, 2017

I wonder if users might get configured that none of their options show up in the config file...? Not really sure how one might improve on this, though.

Member

jonasschnelli commented Mar 3, 2017

I wonder if users might get configured that none of their options show up in the config file...? Not really sure how one might improve on this, though.

Yes. We need to watch out here. The configuration levels are complex.

  1. startup arguments (-arg=val)
  2. bitcoin.conf
  3. Qt configuration (GUI)

If a user opens "the" configuration file, he might expect to see all existing configuration values (including the GUI and startup one).

We should probably label the button "open experts configuration file" or similar.

Contributor

ericshawlinux commented Mar 3, 2017

Well it says "Active command-line options override the above options" so maybe if we put the new button above that, the user will know they are different.

Member

jonasschnelli commented Mar 3, 2017

An alternative would be to first show an QMessageBox with some infos about how the bitcoin.conf works and after that alert box, open the bitcoin.conf file.

Contributor

ericshawlinux commented Mar 3, 2017

Okay. How does this sound?
"The configuration is used to specify advanced user options less any command-line or Qt options. Any command-line options will override this configuration file."

Contributor

ericshawlinux commented Mar 7, 2017

I added the information dialog

src/qt/guiutil.cpp
+ boost::filesystem::path pathConfig = GetConfigFile(BITCOIN_CONF_FILENAME);
+
+ /* Create the file */
+ std::fstream fs(pathConfig.c_str(), std::fstream::app);
@jonasschnelli

jonasschnelli Mar 17, 2017

Member

Gitian Windows Build is failing here:

qt/guiutil.cpp: In function ‘void GUIUtil::openBitcoinConf()’:
qt/guiutil.cpp:425:58: error: no matching function for call to ‘std::basic_fstream<char>::basic_fstream(const value_type*, const openmode&)’
     std::fstream fs(pathConfig.c_str(), std::fstream::app);
                                                          ^
qt/guiutil.cpp:425:58: note: candidates are:
In file included from /home/ubuntu/build/bitcoin/depends/i686-w64-mingw32/share/../include/boost/filesystem/operations.hpp:45:0,
                 from /home/ubuntu/build/bitcoin/depends/i686-w64-mingw32/share/../include/boost/filesystem.hpp:17,
                 from qt/guiutil.h:19,
                 from qt/guiutil.cpp:5:
/usr/include/c++/4.8/fstream:831:7: note: std::basic_fstream<_CharT, _Traits>::basic_fstream(const string&, std::ios_base::openmode) [with _CharT = char; _Traits = std::char_traits<char>; std::string = std::basic_string<char>; std::ios_base::openmode = std::_Ios_Openmode]
       basic_fstream(const std::string& __s,
@ericshawlinux

ericshawlinux Mar 18, 2017

Contributor

ok, I can look at it on monday

Member

jonasschnelli commented Mar 17, 2017

Currently the build is failing on Windows (over Gitian):
https://bitcoin.jonasschnelli.ch/build/53

Otherwise this works fine. Tested on OSX and Ubuntu.

bildschirmfoto 2017-03-17 um 16 09 09

bildschirmfoto 2017-03-17 um 16 09 13

bildschirmfoto 2017-03-17 um 16 17 40

bildschirmfoto 2017-03-17 um 16 17 32

Contributor

ericshawlinux commented Mar 20, 2017

okay, I had an issue with git for a few minutes, but I think I fixed it now.

as for the code, I changed the mode from std::fstream::app to std::ios_base::app that builds okay with linux, and I think with windows, since I read the error message you sent me.

Member

jonasschnelli commented Mar 20, 2017

Thanks... started again a gitian build: https://bitcoin.jonasschnelli.ch/build/60

Contributor

ericshawlinux commented Mar 20, 2017

Still didn't work. I guess I didn't look closely enough at the error before. Now, I think I need to call path.native() instead of path.c_str() based on the constructor declaration.

I will push that soon

Owner

laanwj commented Mar 20, 2017

Please use qstringToBoostPath and boostPathToQString from GUIUtil to convert between QString and boost::filesystem. They avoid UTF-8 issues that will arise when using other methods.

Contributor

ericshawlinux commented Mar 20, 2017

ok

Contributor

ericshawlinux commented Mar 20, 2017

thanks, I figured it out using boost and didn't need to convert the path there. It should build on windows now

Contributor

ericshawlinux commented Mar 20, 2017

@jonasschnelli could you do the gitian build on your site again? I am pretty confident it will work this time after Laan advised me, I changed it to use boost path and not a c string.

Owner

laanwj commented Mar 20, 2017

Code looks good to me now, although I wonder about error handling: what happens if the config file is not writable?

Contributor

ericshawlinux commented Mar 20, 2017

When I change the permissions, It asks me how I want to open the file, which doesn't make sense. I can add some logic and show a QMessageBox::critical() dialog if it fails to open the file.

Contributor

ericshawlinux commented Mar 21, 2017

Now an error appears when the file cannot be opened.

error2

Member

fanquake commented Mar 22, 2017

Testing 541f8d8 on OS X.
Appearance in the GUI:
screen shot 1
Pre opening message:
screen shot 2
Unable to open file error message:
screen shot 4

I'm wondering if we can word the pre-opening message any better. Could we use Core rather than qt, or is that more confusing?

Member

MarcoFalke commented Mar 23, 2017

Maybe replace 'qt options' with 'gui settings'?

Owner

laanwj commented Mar 23, 2017

Some comments on messages:

  • Agree with @MarcoFalke , "Qt options" should be "GUI settings". Except when directly referring to the widget toolkit we avoid referring to Qt, as that's an implementation detail.
  • "config file" in the error message should be "configuration file" (as the button) or just the filename, "bitcoin.conf". There's no reason to shorten here, and it could make it more difficult for translators.
  • Instead of "less any..." I'd use "except any...". Seems more common English (at least to me as non-native speaker.)
Contributor

ericshawlinux commented Mar 23, 2017

I agree, saying "less any..." is not common, but to make it more descriptive and clear I reworded the whole message the best that I could. How is this?
"The configuration file is used to specify advanced user options which override GUI settings. Additionally, any command-line options will override this configuration file."

@jonasschnelli jonasschnelli merged commit 9ab9e7d into bitcoin:master Apr 10, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

jonasschnelli added a commit that referenced this pull request Apr 10, 2017

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

luke-jr added a commit to bitcoinknots/bitcoin that referenced this pull request Apr 21, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment