From 45615af26fe374fa996c116984a05f0a632a0e79 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Tue, 10 Jun 2014 16:02:46 +0200 Subject: [PATCH] Add 'about' information to `-version` output Adds a copyright and attribution message to the `-version` output (the same as shown in the About dialog in the GUI). Move the message to a function LicenseInfo in init.cpp. --- src/bitcoind.cpp | 6 +++- src/init.cpp | 13 ++++++- src/init.h | 3 ++ src/qt/forms/aboutdialog.ui | 70 +++---------------------------------- src/qt/utilitydialog.cpp | 20 +++++++---- 5 files changed, 38 insertions(+), 74 deletions(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 99dc9d726..b7d8ee7f9 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -87,7 +87,11 @@ bool AppInit(int argc, char* argv[]) { std::string strUsage = _("Bitcoin Core Daemon") + " " + _("version") + " " + FormatFullVersion() + "\n"; - if (!mapArgs.count("-version")) + if (mapArgs.count("-version")) + { + strUsage += LicenseInfo(); + } + else { strUsage += "\n" + _("Usage:") + "\n" + " bitcoind [options] " + _("Start Bitcoin Core Daemon") + "\n" + diff --git a/src/init.cpp b/src/init.cpp index 528c3df06..39453da9c 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -195,7 +195,6 @@ bool static Bind(const CService &addr, unsigned int flags) { return true; } -// Core-specific options shared between UI, daemon and RPC client std::string HelpMessage(HelpMessageMode hmm) { string strUsage = _("Options:") + "\n"; @@ -330,6 +329,18 @@ std::string HelpMessage(HelpMessageMode hmm) return strUsage; } +std::string LicenseInfo() +{ + return FormatParagraph(strprintf(_("Copyright (C) 2009-%i The Bitcoin Core Developers"), COPYRIGHT_YEAR)) + "\n" + + "\n" + + FormatParagraph(_("This is experimental software.")) + "\n" + + "\n" + + FormatParagraph(_("Distributed under the MIT/X11 software license, see the accompanying file COPYING or .")) + "\n" + + "\n" + + FormatParagraph(_("This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit and cryptographic software written by Eric Young and UPnP software written by Thomas Bernard.")) + + "\n"; +} + struct CImportingNow { CImportingNow() { diff --git a/src/init.h b/src/init.h index 4a967bea3..52daa4761 100644 --- a/src/init.h +++ b/src/init.h @@ -28,6 +28,9 @@ enum HelpMessageMode HMM_BITCOIN_QT }; +/** Help for options shared between UI and daemon (for -help) */ std::string HelpMessage(HelpMessageMode mode); +/** Returns licensing information (for -version) */ +std::string LicenseInfo(); #endif diff --git a/src/qt/forms/aboutdialog.ui b/src/qt/forms/aboutdialog.ui index fec63f737..51dabf2c3 100644 --- a/src/qt/forms/aboutdialog.ui +++ b/src/qt/forms/aboutdialog.ui @@ -43,76 +43,14 @@ - - - - - IBeamCursor - - - <b>Bitcoin Core</b> version - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - IBeamCursor - - - 0.3.666-beta - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - IBeamCursor - - - Copyright &copy; 2009-YYYY The Bitcoin Core developers - - - Qt::RichText - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - + IBeamCursor - -This is experimental software. - -Distributed under the MIT/X11 software license, see the accompanying file COPYING or <a href="http://www.opensource.org/licenses/mit-license.php">http://www.opensource.org/licenses/mit-license.php</a>. - -This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (<a href="https://www.openssl.org/">https://www.openssl.org/</a>) and cryptographic software written by Eric Young (<a href="mailto:eay@cryptsoft.com">eay@cryptsoft.com</a>) and UPnP software written by Thomas Bernard. + +(placeholder for version message) + Qt::RichText diff --git a/src/qt/utilitydialog.cpp b/src/qt/utilitydialog.cpp index 435c6a436..a34ebd3a3 100644 --- a/src/qt/utilitydialog.cpp +++ b/src/qt/utilitydialog.cpp @@ -16,6 +16,7 @@ #include "util.h" #include +#include #include /** "About" dialog box */ @@ -24,16 +25,13 @@ AboutDialog::AboutDialog(QWidget *parent) : ui(new Ui::AboutDialog) { ui->setupUi(this); - - // Set current copyright year - ui->copyrightLabel->setText(tr("Copyright") + QString(" © 2009-%1 ").arg(COPYRIGHT_YEAR) + tr("The Bitcoin Core developers")); } void AboutDialog::setModel(ClientModel *model) { if(model) { - QString version = model->formatFullVersion(); + QString version = tr("Bitcoin Core") + " " + tr("version") + " " + model->formatFullVersion(); /* On x86 add a bit specifier to the version so that users can distinguish between * 32 and 64 bit builds. On other architectures, 32/64 bit may be more ambigious. */ @@ -42,7 +40,17 @@ void AboutDialog::setModel(ClientModel *model) #elif defined(__i386__ ) version += " " + tr("(%1-bit)").arg(32); #endif - ui->versionLabel->setText(version); + + /// HTML-format the license message from the core + QString licenseInfo = QString::fromStdString(LicenseInfo()); + // Make URLs clickable + QRegExp uri("<(.*)>", Qt::CaseSensitive, QRegExp::RegExp2); + uri.setMinimal(true); // use non-greedy matching + licenseInfo = licenseInfo.replace(uri, "\\1"); + // Replace newlines with HTML breaks + licenseInfo = licenseInfo.replace("\n\n", "

"); + + ui->versionLabel->setText(version + "

" + licenseInfo); } } @@ -81,7 +89,7 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool versionOnly) : // Set help message text if(versionOnly) - ui->helpMessageLabel->setText(version); + ui->helpMessageLabel->setText(version + "\n" + QString::fromStdString(LicenseInfo())); else ui->helpMessageLabel->setText(version + "\n" + header + "\n" + coreOptions + "\n" + uiOptions); }