aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Zander <thomas@thomaszander.se>2014-12-29 00:25:18 +0100
committerThomas Zander <thomas@thomaszander.se>2015-01-05 21:17:45 +0100
commite179eb3d9bfec7e67908242c71c87b716a41c97c (patch)
treed6ddc1348c12f009559ab104fddfad134b05c62e /src
parente5153095ea410dd07770c0327447856488bfd137 (diff)
downloadbitcoin-e179eb3d9bfec7e67908242c71c87b716a41c97c.tar.xz
Make the command-line-args dialog better
Instead of using a fixed-width font in a label, which virtually guarentees a horizontal scrollbar, use a proper text-document that can re-layout based on user input.
Diffstat (limited to 'src')
-rw-r--r--src/qt/forms/helpmessagedialog.ui20
-rw-r--r--src/qt/utilitydialog.cpp88
2 files changed, 87 insertions, 21 deletions
diff --git a/src/qt/forms/helpmessagedialog.ui b/src/qt/forms/helpmessagedialog.ui
index 81dbd90b12..9ace9afd79 100644
--- a/src/qt/forms/helpmessagedialog.ui
+++ b/src/qt/forms/helpmessagedialog.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>800</width>
- <height>400</height>
+ <width>585</width>
+ <height>225</height>
</rect>
</property>
<property name="font">
@@ -35,6 +35,13 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
+ <widget class="QTextEdit" name="helpMessage">
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QScrollArea" name="scrollArea">
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
@@ -47,19 +54,22 @@
<rect>
<x>0</x>
<y>0</y>
- <width>659</width>
- <height>348</height>
+ <width>447</width>
+ <height>68</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
- <widget class="QLabel" name="helpMessageLabel">
+ <widget class="QLabel" name="aboutMessage">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
diff --git a/src/qt/utilitydialog.cpp b/src/qt/utilitydialog.cpp
index e6cec8173e..9ee408179d 100644
--- a/src/qt/utilitydialog.cpp
+++ b/src/qt/utilitydialog.cpp
@@ -18,6 +18,8 @@
#include <QCloseEvent>
#include <QLabel>
#include <QRegExp>
+#include <QTextTable>
+#include <QTextCursor>
#include <QVBoxLayout>
/** "Help message" or "About" dialog box */
@@ -52,28 +54,82 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) :
// Replace newlines with HTML breaks
licenseInfoHTML.replace("\n\n", "<br><br>");
- ui->helpMessageLabel->setTextFormat(Qt::RichText);
+ ui->aboutMessage->setTextFormat(Qt::RichText);
ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
text = version + "\n" + licenseInfo;
- ui->helpMessageLabel->setText(version + "<br><br>" + licenseInfoHTML);
- ui->helpMessageLabel->setWordWrap(true);
+ ui->aboutMessage->setText(version + "<br><br>" + licenseInfoHTML);
+ ui->aboutMessage->setWordWrap(true);
+ ui->helpMessage->setVisible(false);
} else {
setWindowTitle(tr("Command-line options"));
- QString header = tr("Usage:") + "\n" +
- " bitcoin-qt [" + tr("command-line options") + "] " + "\n";
+ QTextCursor cursor(ui->helpMessage->document());
+ cursor.insertText(version);
+ cursor.insertBlock();
+ cursor.insertText(tr("Usage:") + '\n' +
+ " bitcoin-qt [" + tr("command-line options") + "]\n");
+
+ cursor.insertBlock();
+ QTextTableFormat tf;
+ tf.setBorderStyle(QTextFrameFormat::BorderStyle_None);
+ tf.setCellPadding(2);
+ QVector<QTextLength> widths;
+ widths << QTextLength(QTextLength::PercentageLength, 20);
+ widths << QTextLength(QTextLength::PercentageLength, 80);
+ tf.setColumnWidthConstraints(widths);
+ QTextTable *table = cursor.insertTable(2, 2, tf);
QString coreOptions = QString::fromStdString(HelpMessage(HMM_BITCOIN_QT));
-
- 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" +
- " -rootcertificates=<file> " + tr("Set SSL root certificates for payment request (default: -system-)") + "\n" +
- " -splash " + tr("Show splash screen on startup (default: 1)");
-
- ui->helpMessageLabel->setFont(GUIUtil::bitcoinAddressFont());
- text = version + "\n" + header + "\n" + coreOptions + "\n" + uiOptions;
- ui->helpMessageLabel->setText(text);
+ bool first = true;
+ QTextCharFormat bold;
+ bold.setFontWeight(QFont::Bold);
+ // note that coreOptions is not translated.
+ foreach (const QString &line, coreOptions.split('\n')) {
+ if (!first) {
+ table->appendRows(1);
+ cursor.movePosition(QTextCursor::NextRow);
+ }
+ first = false;
+
+ if (line.startsWith(" ")) {
+ int index = line.indexOf(' ', 3);
+ if (index > 0) {
+ cursor.insertText(line.left(index).trimmed());
+ cursor.movePosition(QTextCursor::NextCell);
+ cursor.insertText(line.mid(index).trimmed());
+ continue;
+ }
+ }
+ cursor.movePosition(QTextCursor::NextCell, QTextCursor::KeepAnchor);
+ table->mergeCells(cursor);
+ cursor.insertText(line.trimmed(), bold);
+ }
+
+ table->appendRows(6);
+ cursor.movePosition(QTextCursor::NextRow);
+ cursor.insertText(tr("UI options") + ":", bold);
+ cursor.movePosition(QTextCursor::NextRow);
+ cursor.insertText("-choosedatadir");
+ cursor.movePosition(QTextCursor::NextCell);
+ cursor.insertText(tr("Choose data directory on startup (default: 0)"));
+ cursor.movePosition(QTextCursor::NextCell);
+ cursor.insertText("-lang=<lang>");
+ cursor.movePosition(QTextCursor::NextCell);
+ cursor.insertText(tr("Set language, for example \"de_DE\" (default: system locale)"));
+ cursor.movePosition(QTextCursor::NextCell);
+ cursor.insertText("-min");
+ cursor.movePosition(QTextCursor::NextCell);
+ cursor.insertText(tr("Start minimized"));
+ cursor.movePosition(QTextCursor::NextCell);
+ cursor.insertText("-rootcertificates=<file>");
+ cursor.movePosition(QTextCursor::NextCell);
+ cursor.insertText(tr("Set SSL root certificates for payment request (default: -system-)"));
+ cursor.movePosition(QTextCursor::NextCell);
+ cursor.insertText("-splash");
+ cursor.movePosition(QTextCursor::NextCell);
+ cursor.insertText(tr("Show splash screen on startup (default: 1)"));
+
+ ui->helpMessage->moveCursor(QTextCursor::Start);
+ ui->scrollArea->setVisible(false);
}
}