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.
This commit is contained in:
Wladimir J. van der Laan 2014-06-10 16:02:46 +02:00
parent 97789d374c
commit 45615af26f
5 changed files with 38 additions and 74 deletions

View file

@ -87,7 +87,11 @@ bool AppInit(int argc, char* argv[])
{ {
std::string strUsage = _("Bitcoin Core Daemon") + " " + _("version") + " " + FormatFullVersion() + "\n"; std::string strUsage = _("Bitcoin Core Daemon") + " " + _("version") + " " + FormatFullVersion() + "\n";
if (!mapArgs.count("-version")) if (mapArgs.count("-version"))
{
strUsage += LicenseInfo();
}
else
{ {
strUsage += "\n" + _("Usage:") + "\n" + strUsage += "\n" + _("Usage:") + "\n" +
" bitcoind [options] " + _("Start Bitcoin Core Daemon") + "\n" + " bitcoind [options] " + _("Start Bitcoin Core Daemon") + "\n" +

View file

@ -195,7 +195,6 @@ bool static Bind(const CService &addr, unsigned int flags) {
return true; return true;
} }
// Core-specific options shared between UI, daemon and RPC client
std::string HelpMessage(HelpMessageMode hmm) std::string HelpMessage(HelpMessageMode hmm)
{ {
string strUsage = _("Options:") + "\n"; string strUsage = _("Options:") + "\n";
@ -330,6 +329,18 @@ std::string HelpMessage(HelpMessageMode hmm)
return strUsage; 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 <http://www.opensource.org/licenses/mit-license.php>.")) + "\n" +
"\n" +
FormatParagraph(_("This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit <https://www.openssl.org/> and cryptographic software written by Eric Young and UPnP software written by Thomas Bernard.")) +
"\n";
}
struct CImportingNow struct CImportingNow
{ {
CImportingNow() { CImportingNow() {

View file

@ -28,6 +28,9 @@ enum HelpMessageMode
HMM_BITCOIN_QT HMM_BITCOIN_QT
}; };
/** Help for options shared between UI and daemon (for -help) */
std::string HelpMessage(HelpMessageMode mode); std::string HelpMessage(HelpMessageMode mode);
/** Returns licensing information (for -version) */
std::string LicenseInfo();
#endif #endif

View file

@ -42,77 +42,15 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="text">
<string>&lt;b&gt;Bitcoin Core&lt;/b&gt; version</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item> <item>
<widget class="QLabel" name="versionLabel"> <widget class="QLabel" name="versionLabel">
<property name="cursor"> <property name="cursor">
<cursorShape>IBeamCursor</cursorShape> <cursorShape>IBeamCursor</cursorShape>
</property> </property>
<property name="text"> <property name="text">
<string notr="true">0.3.666-beta</string> <string notr="true">
</property> (placeholder for version message)
<property name="textInteractionFlags"> </string>
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="copyrightLabel">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="text">
<string notr="true">Copyright &amp;copy; 2009-YYYY The Bitcoin Core developers</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="text">
<string>
This is experimental software.
Distributed under the MIT/X11 software license, see the accompanying file COPYING or &lt;a href=&quot;http://www.opensource.org/licenses/mit-license.php&quot;&gt;http://www.opensource.org/licenses/mit-license.php&lt;/a&gt;.
This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (&lt;a href=&quot;https://www.openssl.org/&quot;&gt;https://www.openssl.org/&lt;/a&gt;) and cryptographic software written by Eric Young (&lt;a href=&quot;mailto:eay@cryptsoft.com&quot;&gt;eay@cryptsoft.com&lt;/a&gt;) and UPnP software written by Thomas Bernard.</string>
</property> </property>
<property name="textFormat"> <property name="textFormat">
<enum>Qt::RichText</enum> <enum>Qt::RichText</enum>

View file

@ -16,6 +16,7 @@
#include "util.h" #include "util.h"
#include <QLabel> #include <QLabel>
#include <QRegExp>
#include <QVBoxLayout> #include <QVBoxLayout>
/** "About" dialog box */ /** "About" dialog box */
@ -24,16 +25,13 @@ AboutDialog::AboutDialog(QWidget *parent) :
ui(new Ui::AboutDialog) ui(new Ui::AboutDialog)
{ {
ui->setupUi(this); ui->setupUi(this);
// Set current copyright year
ui->copyrightLabel->setText(tr("Copyright") + QString(" &copy; 2009-%1 ").arg(COPYRIGHT_YEAR) + tr("The Bitcoin Core developers"));
} }
void AboutDialog::setModel(ClientModel *model) void AboutDialog::setModel(ClientModel *model)
{ {
if(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 /* 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. * 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__ ) #elif defined(__i386__ )
version += " " + tr("(%1-bit)").arg(32); version += " " + tr("(%1-bit)").arg(32);
#endif #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, "<a href=\"\\1\">\\1</a>");
// Replace newlines with HTML breaks
licenseInfo = licenseInfo.replace("\n\n", "<br><br>");
ui->versionLabel->setText(version + "<br><br>" + licenseInfo);
} }
} }
@ -81,7 +89,7 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool versionOnly) :
// Set help message text // Set help message text
if(versionOnly) if(versionOnly)
ui->helpMessageLabel->setText(version); ui->helpMessageLabel->setText(version + "\n" + QString::fromStdString(LicenseInfo()));
else else
ui->helpMessageLabel->setText(version + "\n" + header + "\n" + coreOptions + "\n" + uiOptions); ui->helpMessageLabel->setText(version + "\n" + header + "\n" + coreOptions + "\n" + uiOptions);
} }