Skip to content

Commit 28313b8

Browse files
author
MarcoFalke
committed
[qt] Use fixed pitch font for the rpc console
Also: * Preserve white space * Make fixed font as large as default font
1 parent 8daffe2 commit 28313b8

File tree

7 files changed

+18
-11
lines changed

7 files changed

+18
-11
lines changed

src/qt/addresstablemodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ QVariant AddressTableModel::data(const QModelIndex &index, int role) const
218218
QFont font;
219219
if(index.column() == Address)
220220
{
221-
font = GUIUtil::bitcoinAddressFont();
221+
font = GUIUtil::fixedPitchFont();
222222
}
223223
return font;
224224
}

src/qt/guiutil.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ QString dateTimeStr(qint64 nTime)
8888
return dateTimeStr(QDateTime::fromTime_t((qint32)nTime));
8989
}
9090

91-
QFont bitcoinAddressFont()
91+
QFont fixedPitchFont()
9292
{
9393
QFont font("Monospace");
9494
#if QT_VERSION >= 0x040800
@@ -103,7 +103,7 @@ void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent)
103103
{
104104
parent->setFocusProxy(widget);
105105

106-
widget->setFont(bitcoinAddressFont());
106+
widget->setFont(fixedPitchFont());
107107
#if QT_VERSION >= 0x040700
108108
// We don't want translators to use own addresses in translations
109109
// and this is the only place, where this address is supplied.

src/qt/guiutil.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ namespace GUIUtil
3737
QString dateTimeStr(const QDateTime &datetime);
3838
QString dateTimeStr(qint64 nTime);
3939

40-
// Render Bitcoin addresses in monospace font
41-
QFont bitcoinAddressFont();
40+
// Return a monospace font
41+
QFont fixedPitchFont();
4242

4343
// Set up widgets for address and amounts
4444
void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent);

src/qt/rpcconsole.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -462,13 +462,19 @@ void RPCConsole::clear()
462462
}
463463

464464
// Set default style sheet
465+
QFontInfo fixedFontInfo(GUIUtil::fixedPitchFont());
466+
// Try to make font equally large on different OS.
467+
QString ptSize = QString("%1pt").arg(QFontInfo(QFont()).pointSize());
465468
ui->messagesWidget->document()->setDefaultStyleSheet(
469+
QString(
466470
"table { }"
467471
"td.time { color: #808080; padding-top: 3px; } "
472+
"td.message { font-family: %1; font-size: %2; white-space:pre-wrap; } "
468473
"td.cmd-request { color: #006060; } "
469474
"td.cmd-error { color: red; } "
470475
"b { color: #006060; } "
471-
);
476+
).arg(fixedFontInfo.family(), ptSize)
477+
);
472478

473479
message(CMD_REPLY, (tr("Welcome to the Bitcoin Core RPC console.") + "<br>" +
474480
tr("Use up and down arrows to navigate history, and <b>Ctrl-L</b> to clear screen.") + "<br>" +
@@ -494,7 +500,7 @@ void RPCConsole::message(int category, const QString &message, bool html)
494500
if(html)
495501
out += message;
496502
else
497-
out += GUIUtil::HtmlEscape(message, true);
503+
out += GUIUtil::HtmlEscape(message, false);
498504
out += "</td></tr></table>";
499505
ui->messagesWidget->append(out);
500506
}
@@ -849,4 +855,4 @@ void RPCConsole::showOrHideBanTableIfRequired()
849855
bool visible = clientModel->getBanTableModel()->shouldShow();
850856
ui->banlistWidget->setVisible(visible);
851857
ui->banHeading->setVisible(visible);
852-
}
858+
}

src/qt/rpcconsole.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ private Q_SLOTS:
7171

7272
public Q_SLOTS:
7373
void clear();
74+
/** Append the message to the message widget */
7475
void message(int category, const QString &message, bool html = false);
7576
/** Set number of connections shown in the UI */
7677
void setNumConnections(int count);

src/qt/sendcoinsentry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ SendCoinsEntry::SendCoinsEntry(const PlatformStyle *platformStyle, QWidget *pare
4040
// normal bitcoin address field
4141
GUIUtil::setupAddressWidget(ui->payTo, this);
4242
// just a label for displaying bitcoin address(es)
43-
ui->payTo_is->setFont(GUIUtil::bitcoinAddressFont());
43+
ui->payTo_is->setFont(GUIUtil::fixedPitchFont());
4444

4545
// Connect signals
4646
connect(ui->payAmount, SIGNAL(valueChanged()), this, SIGNAL(payAmountChanged()));

src/qt/signverifymessagedialog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ SignVerifyMessageDialog::SignVerifyMessageDialog(const PlatformStyle *platformSt
5151
ui->messageIn_VM->installEventFilter(this);
5252
ui->signatureIn_VM->installEventFilter(this);
5353

54-
ui->signatureOut_SM->setFont(GUIUtil::bitcoinAddressFont());
55-
ui->signatureIn_VM->setFont(GUIUtil::bitcoinAddressFont());
54+
ui->signatureOut_SM->setFont(GUIUtil::fixedPitchFont());
55+
ui->signatureIn_VM->setFont(GUIUtil::fixedPitchFont());
5656
}
5757

5858
SignVerifyMessageDialog::~SignVerifyMessageDialog()

0 commit comments

Comments
 (0)