Merge #16044: qt: fix opening bitcoin.conf via Preferences on macOS

6e6494b3fb qt: fix opening bitcoin.conf via Preferences on macOS; see #15409 (shannon1916)

Pull request description:

  Fix #15409. The QT wallet fail to open the configuration file on Mac, when these is no default application for `*.conf` files.

  Here is a feasible way to solve this bug. When `QDesktopServices::openUrl` fails to open `file:///path/bitcoin.conf` with its default application, use `QProcess::startDetached` to run `open -t /path/bitcoin.conf` command instead, so as to open the configuration file with system's default text editor.

ACKs for commit 6e6494:
  hebasto:
    re-ACK 6e6494b3fb
  fanquake:
    tACK 6e6494b3fb on macOS 10.14.x

Tree-SHA512: 60e898f4cb77cfd7b8adbc8d33fbebf46bac2a801bdcf40cae15e24b78ad56b1f32358b1879b670623d9f8651dea93961d34269358cea18f4e15b089a8ffcfbf
This commit is contained in:
Wladimir J. van der Laan 2019-06-03 23:19:53 +02:00
commit 6520330087
No known key found for this signature in database
GPG key ID: 1E4AED62986CD25D

View file

@ -60,6 +60,7 @@
#include <objc/objc-runtime.h>
#include <CoreServices/CoreServices.h>
#include <QProcess>
#endif
namespace GUIUtil {
@ -399,7 +400,15 @@ bool openBitcoinConf()
configFile.close();
/* Open bitcoin.conf with the associated application */
return QDesktopServices::openUrl(QUrl::fromLocalFile(boostPathToQString(pathConfig)));
bool res = QDesktopServices::openUrl(QUrl::fromLocalFile(boostPathToQString(pathConfig)));
#ifdef Q_OS_MAC
// Workaround for macOS-specific behavior; see #15409.
if (!res) {
res = QProcess::startDetached("/usr/bin/open", QStringList{"-t", boostPathToQString(pathConfig)});
}
#endif
return res;
}
ToolTipToRichTextFilter::ToolTipToRichTextFilter(int _size_threshold, QObject *parent) :