7 #if defined(HAVE_CONFIG_H)
13 #include "ui_helpmessagedialog.h"
26 #include <QCloseEvent>
30 #include <QTextCursor>
31 #include <QVBoxLayout>
38 if (parent) this->setStyleSheet(parent->styleSheet());
44 connect(
ui->pushButtonOk, &QPushButton::clicked,
this, &HelpMessageDialog::close);
49 QString licenseInfo = QString::fromStdString(
LicenseInfo());
50 QString licenseInfoHTML = licenseInfo;
53 QRegExp uri(
"<(.*)>", Qt::CaseSensitive, QRegExp::RegExp2);
55 licenseInfoHTML.replace(uri,
"<a style='color: #b088ff;text-decoration:none' href=\"\\1\">\\1</a>");
57 licenseInfoHTML.replace(
"\n\n",
"<br><br>");
59 ui->aboutMessage->setTextFormat(Qt::RichText);
60 ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
61 text = version +
"\n" + licenseInfo;
62 ui->aboutMessage->setText(version +
"<br><br>" + licenseInfoHTML);
63 ui->aboutMessage->setWordWrap(
true);
64 ui->helpMessage->setVisible(
false);
66 setWindowTitle(tr(
"Command-line options"));
67 QString header =
"Usage: pivx-qt [command-line options] \n";
68 QTextCursor cursor(
ui->helpMessage->document());
69 cursor.insertText(version);
71 cursor.insertText(header);
76 strUsage +=
HelpMessageOpt(
"-choosedatadir",
strprintf(
"Choose data directory on startup (default: %u)", DEFAULT_CHOOSE_DATADIR));
77 strUsage +=
HelpMessageOpt(
"-lang=<lang>",
"Set language, for example \"de_DE\" (default: system locale)");
79 strUsage +=
HelpMessageOpt(
"-splash",
strprintf(
"Show splash screen on startup (default: %u)", DEFAULT_SPLASHSCREEN));
81 QString coreOptions = QString::fromStdString(strUsage);
82 text = version +
"\n\n" + header +
"\n" + coreOptions;
85 tf.setBorderStyle(QTextFrameFormat::BorderStyle_None);
87 QVector<QTextLength> widths;
88 widths << QTextLength(QTextLength::PercentageLength, 35);
89 widths << QTextLength(QTextLength::PercentageLength, 65);
90 tf.setColumnWidthConstraints(widths);
93 bold.setFontWeight(QFont::Bold);
95 for (
const QString &line : coreOptions.split(
"\n")) {
96 if (line.startsWith(
" -"))
98 cursor.currentTable()->appendRows(1);
99 cursor.movePosition(QTextCursor::PreviousCell);
100 cursor.movePosition(QTextCursor::NextRow);
101 cursor.insertText(line.trimmed());
102 cursor.movePosition(QTextCursor::NextCell);
103 }
else if (line.startsWith(
" ")) {
104 cursor.insertText(line.trimmed()+
' ');
105 }
else if (line.size() > 0) {
107 if (cursor.currentTable())
108 cursor.currentTable()->appendRows(1);
109 cursor.movePosition(QTextCursor::Down);
110 cursor.insertText(line.trimmed(), bold);
111 cursor.insertTable(1, 2, tf);
115 ui->helpMessage->moveCursor(QTextCursor::Start);
116 ui->scrollArea->setVisible(
false);
129 fprintf(stdout,
"%s\n", qPrintable(
text));
147 QVBoxLayout* layout =
new QVBoxLayout();
148 layout->addWidget(
new QLabel(
149 tr(
"%1 is shutting down...").arg(
PACKAGE_NAME) +
"<br /><br />" +
150 tr(
"Do not shut down the computer until this window disappears.")));
163 shutdownWindow->setAttribute(Qt::WA_DeleteOnClose);
164 shutdownWindow->setWindowTitle(window->windowTitle());
167 const QPoint global = window->mapToGlobal(window->rect().center());
168 shutdownWindow->move(global.x() - shutdownWindow->width() / 2, global.y() - shutdownWindow->height() / 2);
169 shutdownWindow->show();
"Help message" dialog box
HelpMessageDialog(QWidget *parent, bool about)
"Help message" or "About" dialog box
Ui::HelpMessageDialog * ui
static void showShutdownWindow(QMainWindow *window)
ShutdownWindow(QWidget *parent=nullptr, Qt::WindowFlags f=Qt::Widget)
"Shutdown" window
void closeEvent(QCloseEvent *event)
std::string FormatFullVersion()
std::string HelpMessage(HelpMessageMode mode)
Help for options shared between UI and daemon (for -help)
std::string LicenseInfo()
Returns licensing information (for -version)
void saveWindowGeometry(const QString &strSetting, QWidget *parent)
Save window size and position.
void restoreWindowGeometry(const QString &strSetting, const QSize &defaultSize, QWidget *parent)
Restore window size and position.
void setCssBtnPrimary(QPushButton *btn, bool forceUpdate)
std::string HelpMessageGroup(const std::string &message)
Format a string to be used as group of options in help messages.
std::string HelpMessageOpt(const std::string &option, const std::string &message)
Format a string to be used as option description in help messages.