diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index a9a9b39bf43..40dd7e02dcb 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -593,7 +593,8 @@ int GuiMain(int argc, char* argv[]) // Show help message immediately after parsing command-line options (for "-lang") and setting locale, // but before showing splash screen. if (HelpRequested(gArgs) || gArgs.IsArgSet("-version")) { - HelpMessageDialog help(nullptr, gArgs.IsArgSet("-version")); + bool about = gArgs.IsArgSet("-version"); + HelpMessageDialog help(nullptr, about ? HelpMessageDialog::AboutMode : HelpMessageDialog::CommandLineOptionsMode); help.showOrPrint(); return EXIT_SUCCESS; } diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index fd71938b606..185e1cf1de7 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -103,7 +103,7 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty updateWindowTitle(); rpcConsole = new RPCConsole(node, _platformStyle, nullptr); - helpMessageDialog = new HelpMessageDialog(this, false); + helpMessageDialog = new HelpMessageDialog(this, HelpMessageDialog::CommandLineOptionsMode); #ifdef ENABLE_WALLET if(enableWallet) { @@ -911,7 +911,7 @@ void BitcoinGUI::aboutClicked() if(!clientModel) return; - auto dlg = new HelpMessageDialog(this, /*about=*/true); + auto dlg = new HelpMessageDialog(this, HelpMessageDialog::AboutMode); GUIUtil::ShowModalDialogAsynchronously(dlg); } diff --git a/src/qt/utilitydialog.cpp b/src/qt/utilitydialog.cpp index f43b9936284..9e592556301 100644 --- a/src/qt/utilitydialog.cpp +++ b/src/qt/utilitydialog.cpp @@ -29,34 +29,39 @@ #include /** "Help message" or "About" dialog box */ -HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) : +HelpMessageDialog::HelpMessageDialog(QWidget *parent, Mode _mode) : QDialog(parent, GUIUtil::dialog_flags), - ui(new Ui::HelpMessageDialog) + ui(new Ui::HelpMessageDialog), + mode(_mode) { ui->setupUi(this); QString version = QString{PACKAGE_NAME} + " " + tr("version") + " " + QString::fromStdString(FormatFullVersion()); - if (about) + switch(mode) { - setWindowTitle(tr("About %1").arg(PACKAGE_NAME)); - - std::string licenseInfo = LicenseInfo(); - /// HTML-format the license message from the core - QString licenseInfoHTML = QString::fromStdString(LicenseInfo()); - // Make URLs clickable - QRegularExpression uri(QStringLiteral("<(.*)>"), QRegularExpression::InvertedGreedinessOption); - licenseInfoHTML.replace(uri, QStringLiteral("\\1")); - // Replace newlines with HTML breaks - licenseInfoHTML.replace("\n", "
"); - - ui->aboutMessage->setTextFormat(Qt::RichText); - ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - text = version + "\n" + QString::fromStdString(FormatParagraph(licenseInfo)); - ui->aboutMessage->setText(version + "

" + licenseInfoHTML); - ui->aboutMessage->setWordWrap(true); - ui->helpMessage->setVisible(false); - } else { + case AboutMode: + { + setWindowTitle(tr("About %1").arg(PACKAGE_NAME)); + + std::string licenseInfo = LicenseInfo(); + /// HTML-format the license message from the core + QString licenseInfoHTML = QString::fromStdString(LicenseInfo()); + // Make URLs clickable + QRegularExpression uri(QStringLiteral("<(.*)>"), QRegularExpression::InvertedGreedinessOption); + licenseInfoHTML.replace(uri, QStringLiteral("\\1")); + // Replace newlines with HTML breaks + licenseInfoHTML.replace("\n", "
"); + + ui->aboutMessage->setTextFormat(Qt::RichText); + ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + text = version + "\n" + QString::fromStdString(FormatParagraph(licenseInfo)); + ui->aboutMessage->setText(version + "

" + licenseInfoHTML); + ui->aboutMessage->setWordWrap(true); + ui->helpMessage->setVisible(false); + break; + } + case CommandLineOptionsMode: setWindowTitle(tr("Command-line options")); QString header = "Usage: bitcoin-qt [command-line options] \n"; QTextCursor cursor(ui->helpMessage->document()); @@ -103,6 +108,7 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) : ui->helpMessage->moveCursor(QTextCursor::Start); ui->scrollArea->setVisible(false); ui->aboutLogo->setVisible(false); + break; } GUIUtil::handleCloseWindowShortcut(this); diff --git a/src/qt/utilitydialog.h b/src/qt/utilitydialog.h index d2a5d5f67f2..44397538eea 100644 --- a/src/qt/utilitydialog.h +++ b/src/qt/utilitydialog.h @@ -22,7 +22,12 @@ class HelpMessageDialog : public QDialog Q_OBJECT public: - explicit HelpMessageDialog(QWidget *parent, bool about); + enum Mode { + AboutMode, + CommandLineOptionsMode + }; + + explicit HelpMessageDialog(QWidget *parent, Mode _mode); ~HelpMessageDialog(); void printToConsole(); @@ -31,6 +36,7 @@ class HelpMessageDialog : public QDialog private: Ui::HelpMessageDialog *ui; QString text; + Mode mode; private Q_SLOTS: void on_okButton_accepted();