aboutsummaryrefslogtreecommitdiff
path: root/src/qt
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-06-03 16:12:19 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2014-06-11 14:22:50 +0200
commit96b733e99694e74dcd38b16112655f7e1ea2d43b (patch)
tree348d0303f312fd56ef39b413d3849ea6ae7ed122 /src/qt
parent9c8d2f6df0d748152d858cfea09e4463758c8df6 (diff)
Add `-version` option to get just the version
Adds a `-version` or `--version` option to print just the version of the program for bitcoind, bitcoin-cli and bitcoin-qt. Also make it that `-help` can be used to display the help (as well as existing `--help`). Up to now, `-help` was the only option that didn't work with either one or two dashes.
Diffstat (limited to 'src/qt')
-rw-r--r--src/qt/bitcoin.cpp4
-rw-r--r--src/qt/bitcoingui.cpp2
-rw-r--r--src/qt/utilitydialog.cpp19
-rw-r--r--src/qt/utilitydialog.h5
4 files changed, 14 insertions, 16 deletions
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index 2be8191eb5..387f6ede4b 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -503,9 +503,9 @@ int main(int argc, char *argv[])
// Show help message immediately after parsing command-line options (for "-lang") and setting locale,
// but before showing splash screen.
- if (mapArgs.count("-?") || mapArgs.count("--help"))
+ if (mapArgs.count("-?") || mapArgs.count("-help") || mapArgs.count("-version"))
{
- HelpMessageDialog help(NULL);
+ HelpMessageDialog help(NULL, mapArgs.count("-version"));
help.showOrPrint();
return 1;
}
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index 3469f990ac..847a3ab8f1 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -556,7 +556,7 @@ void BitcoinGUI::aboutClicked()
void BitcoinGUI::showHelpMessageClicked()
{
- HelpMessageDialog *help = new HelpMessageDialog(this);
+ HelpMessageDialog *help = new HelpMessageDialog(this, false);
help->setAttribute(Qt::WA_DeleteOnClose);
help->show();
}
diff --git a/src/qt/utilitydialog.cpp b/src/qt/utilitydialog.cpp
index 01b710e876..435c6a4368 100644
--- a/src/qt/utilitydialog.cpp
+++ b/src/qt/utilitydialog.cpp
@@ -57,21 +57,20 @@ void AboutDialog::on_buttonBox_accepted()
}
/** "Help message" dialog box */
-HelpMessageDialog::HelpMessageDialog(QWidget *parent) :
+HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool versionOnly) :
QDialog(parent),
ui(new Ui::HelpMessageDialog)
{
ui->setupUi(this);
GUIUtil::restoreWindowGeometry("nHelpMessageDialogWindow", this->size(), this);
- header = tr("Bitcoin Core") + " " + tr("version") + " " +
- QString::fromStdString(FormatFullVersion()) + "\n\n" +
- tr("Usage:") + "\n" +
+ QString version = tr("Bitcoin Core") + " " + tr("version") + " " + QString::fromStdString(FormatFullVersion());
+ QString header = tr("Usage:") + "\n" +
" bitcoin-qt [" + tr("command-line options") + "] " + "\n";
- coreOptions = QString::fromStdString(HelpMessage(HMM_BITCOIN_QT));
+ QString coreOptions = QString::fromStdString(HelpMessage(HMM_BITCOIN_QT));
- uiOptions = tr("UI options") + ":\n" +
+ QString uiOptions = tr("UI options") + ":\n" +
" -choosedatadir " + tr("Choose data directory on startup (default: 0)") + "\n" +
" -lang=<lang> " + tr("Set language, for example \"de_DE\" (default: system locale)") + "\n" +
" -min " + tr("Start minimized") + "\n" +
@@ -81,7 +80,10 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent) :
ui->helpMessageLabel->setFont(GUIUtil::bitcoinAddressFont());
// Set help message text
- ui->helpMessageLabel->setText(header + "\n" + coreOptions + "\n" + uiOptions);
+ if(versionOnly)
+ ui->helpMessageLabel->setText(version);
+ else
+ ui->helpMessageLabel->setText(version + "\n" + header + "\n" + coreOptions + "\n" + uiOptions);
}
HelpMessageDialog::~HelpMessageDialog()
@@ -93,8 +95,7 @@ HelpMessageDialog::~HelpMessageDialog()
void HelpMessageDialog::printToConsole()
{
// On other operating systems, the expected action is to print the message to the console.
- QString strUsage = header + "\n" + coreOptions + "\n" + uiOptions + "\n";
- fprintf(stdout, "%s", strUsage.toStdString().c_str());
+ fprintf(stdout, "%s\n", qPrintable(ui->helpMessageLabel->text()));
}
void HelpMessageDialog::showOrPrint()
diff --git a/src/qt/utilitydialog.h b/src/qt/utilitydialog.h
index 874daf6a7f..cc23420169 100644
--- a/src/qt/utilitydialog.h
+++ b/src/qt/utilitydialog.h
@@ -40,7 +40,7 @@ class HelpMessageDialog : public QDialog
Q_OBJECT
public:
- explicit HelpMessageDialog(QWidget *parent);
+ explicit HelpMessageDialog(QWidget *parent, bool versionOnly);
~HelpMessageDialog();
void printToConsole();
@@ -48,9 +48,6 @@ public:
private:
Ui::HelpMessageDialog *ui;
- QString header;
- QString coreOptions;
- QString uiOptions;
private slots:
void on_okButton_accepted();