Skip to content

Commit 8f2a460

Browse files
Merge #6049: backport: merge bitcoin-core/gui#180, #203, #179, #219, #214, #166, #296, #194, #280, #325, partial bitcoin-core/gui#79 (qt backports)
ddca614 merge bitcoin-core/gui#325: Align numbers in the "Peer Id" column to the right (Kittywhiskers Van Gogh) 09a8fc1 merge bitcoin-core/gui#280: Remove user input from URI error message (Kittywhiskers Van Gogh) a3ac694 merge bitcoin-core/gui#194: Save/restore RPCConsole geometry only for window (Kittywhiskers Van Gogh) 504f834 merge bitcoin-core/gui#296: Do not use QObject::tr plural syntax for numbers with a unit symbol (Kittywhiskers Van Gogh) c33afea merge bitcoin-core/gui#166: Use enum type as switch argument in *TableModel (Kittywhiskers Van Gogh) 5a67b52 merge bitcoin-core/gui#214: Disable requests context menu actions when appropriate (Kittywhiskers Van Gogh) dc9b25e merge bitcoin-core/gui#219: Prevent the main window popup menu (Kittywhiskers Van Gogh) 7774bdb partial bitcoin-core/gui#79: Embed monospaced font (Kittywhiskers Van Gogh) 722bd8d qt: introduce GUIUtil::fixedPitchFont (Kittywhiskers Van Gogh) afd0648 merge bitcoin-core/gui#179: Add Type column to peers window, update peer details name/tooltip (Kittywhiskers Van Gogh) 57597df merge bitcoin-core/gui#203: Display plain "Inbound" in peer details (Kittywhiskers Van Gogh) 582c6ec merge bitcoin-core/gui#180: connection type follow-ups (Kittywhiskers Van Gogh) Pull request description: ## Additional Information | `develop` (d7413ff) | This PR | | ------------------------------------------------------------ | ------------------------------------------------------------ | | ![image](https://github.com/dashpay/dash/assets/63189531/3baec578-e878-44b6-9d98-a20af82d6111) | ![image](https://github.com/dashpay/dash/assets/63189531/258f9de4-e4dd-41d8-bdae-65bd095d811b) | ## Breaking Changes None expected, changes are limited to refactoring, cleanup and refinement. ## Checklist: - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas **(note: N/A)** - [x] I have added or updated relevant unit/integration/functional/e2e tests **(note: N/A)** - [x] I have made corresponding changes to the documentation **(note: N/A)** - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: PastaPastaPasta: utACK ddca614 Tree-SHA512: 8b07c6261c5e111f6db06be528aab7d3862bb31cf23e7df84a1e211ae1e1b5d52a51a520b24ed1b058ac19f845204fe458f16ba5920db9c1b1d1939a1fff6711
2 parents 825bba1 + ddca614 commit 8f2a460

20 files changed

+220
-112
lines changed

contrib/debian/copyright

+15
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ Files: src/qt/res/icons/proxy.png
3131
Copyright: Cristian Mircea Messel
3232
License: public-domain
3333

34+
Files: src/qt/fonts/RobotoMono-Bold.ttf
35+
License: Apache-2.0
36+
Comment: Site: https://fonts.google.com/specimen/Roboto+Mono
37+
3438

3539
License: Expat
3640
Permission is hereby granted, free of charge, to any person obtaining a
@@ -88,3 +92,14 @@ Comment:
8892

8993
License: public-domain
9094
This work is in the public domain.
95+
96+
License: Apache-2.0
97+
Licensed under the Apache License, Version 2.0 (the "License");
98+
you may not use this file except in compliance with the License.
99+
You may obtain a copy of the License at
100+
http://www.apache.org/licenses/LICENSE-2.0
101+
Unless required by applicable law or agreed to in writing, software
102+
distributed under the License is distributed on an "AS IS" BASIS,
103+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
104+
See the License for the specific language governing permissions and
105+
limitations under the License.

src/Makefile.qt.include

+2-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,8 @@ RES_FONTS = \
352352
qt/res/fonts/Montserrat/Montserrat-SemiBold.otf \
353353
qt/res/fonts/Montserrat/Montserrat-SemiBoldItalic.otf \
354354
qt/res/fonts/Montserrat/Montserrat-Thin.otf \
355-
qt/res/fonts/Montserrat/Montserrat-ThinItalic.otf
355+
qt/res/fonts/Montserrat/Montserrat-ThinItalic.otf \
356+
qt/res/fonts/RobotoMono-Bold.ttf
356357

357358
RES_ANIMATION = $(wildcard $(srcdir)/qt/res/animation/spinner-*.png)
358359

src/net.h

+6-5
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ struct CSerializedNetMsg
148148
* connection. Aside from INBOUND, all types are initiated by us.
149149
*
150150
* If adding or removing types, please update CONNECTION_TYPE_DOC in
151-
* src/rpc/net.cpp. */
151+
* src/rpc/net.cpp and src/qt/rpcconsole.cpp, as well as the descriptions in
152+
* src/qt/guiutil.cpp and src/bitcoin-cli.cpp::NetinfoRequestHandler. */
152153
enum class ConnectionType {
153154
/**
154155
* Inbound connections are those initiated by a peer. This is the only
@@ -159,16 +160,16 @@ enum class ConnectionType {
159160

160161
/**
161162
* These are the default connections that we use to connect with the
162-
* network. There is no restriction on what is relayed- by default we relay
163+
* network. There is no restriction on what is relayed; by default we relay
163164
* blocks, addresses & transactions. We automatically attempt to open
164165
* MAX_OUTBOUND_FULL_RELAY_CONNECTIONS using addresses from our AddrMan.
165166
*/
166167
OUTBOUND_FULL_RELAY,
167168

168169

169170
/**
170-
* We open manual connections to addresses that users explicitly inputted
171-
* via the addnode RPC, or the -connect command line argument. Even if a
171+
* We open manual connections to addresses that users explicitly requested
172+
* via the addnode RPC or the -addnode/-connect configuration options. Even if a
172173
* manual connection is misbehaving, we do not automatically disconnect or
173174
* add it to our discouragement filter.
174175
*/
@@ -187,7 +188,7 @@ enum class ConnectionType {
187188
* although in our codebase feeler connections encompass test-before-evict as well.
188189
* We make these connections approximately every FEELER_INTERVAL:
189190
* first we resolve previously found collisions if they exist (test-before-evict),
190-
* otherwise connect to a node from the new table.
191+
* otherwise we connect to a node from the new table.
191192
*/
192193
FEELER,
193194

src/qt/addresstablemodel.cpp

+20-24
Original file line numberDiff line numberDiff line change
@@ -195,42 +195,38 @@ QVariant AddressTableModel::data(const QModelIndex &index, int role) const
195195

196196
AddressTableEntry *rec = static_cast<AddressTableEntry*>(index.internalPointer());
197197

198-
if(role == Qt::DisplayRole || role == Qt::EditRole)
199-
{
200-
switch(index.column())
201-
{
198+
const auto column = static_cast<ColumnIndex>(index.column());
199+
if (role == Qt::DisplayRole || role == Qt::EditRole) {
200+
switch (column) {
202201
case Label:
203-
if(rec->label.isEmpty() && role == Qt::DisplayRole)
204-
{
202+
if (rec->label.isEmpty() && role == Qt::DisplayRole) {
205203
return tr("(no label)");
206-
}
207-
else
208-
{
204+
} else {
209205
return rec->label;
210206
}
211207
case Address:
212208
return rec->address;
213-
}
214-
}
215-
else if (role == Qt::FontRole)
216-
{
217-
QFont font;
218-
if(index.column() == Address)
219-
{
220-
font = GUIUtil::getFontNormal();
221-
}
222-
return font;
223-
}
224-
else if (role == TypeRole)
225-
{
209+
} // no default case, so the compiler can warn about missing cases
210+
assert(false);
211+
} else if (role == Qt::FontRole) {
212+
switch (column) {
213+
case Label:
214+
return QFont();
215+
case Address:
216+
return GUIUtil::getFontNormal();
217+
} // no default case, so the compiler can warn about missing cases
218+
assert(false);
219+
} else if (role == TypeRole) {
226220
switch(rec->type)
227221
{
228222
case AddressTableEntry::Sending:
229223
return Send;
230224
case AddressTableEntry::Receiving:
231225
return Receive;
232-
default: break;
233-
}
226+
case AddressTableEntry::Hidden:
227+
return {};
228+
} // no default case, so the compiler can warn about missing cases
229+
assert(false);
234230
}
235231
return QVariant();
236232
}

src/qt/bantablemodel.cpp

+7-8
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,13 @@ bool BannedNodeLessThan::operator()(const CCombinedBan& left, const CCombinedBan
2323
if (order == Qt::DescendingOrder)
2424
std::swap(pLeft, pRight);
2525

26-
switch(column)
27-
{
26+
switch (static_cast<BanTableModel::ColumnIndex>(column)) {
2827
case BanTableModel::Address:
2928
return pLeft->subnet.ToString().compare(pRight->subnet.ToString()) < 0;
3029
case BanTableModel::Bantime:
3130
return pLeft->banEntry.nBanUntil < pRight->banEntry.nBanUntil;
32-
}
33-
34-
return false;
31+
} // no default case, so the compiler can warn about missing cases
32+
assert(false);
3533
}
3634

3735
// private implementation
@@ -119,16 +117,17 @@ QVariant BanTableModel::data(const QModelIndex &index, int role) const
119117

120118
CCombinedBan *rec = static_cast<CCombinedBan*>(index.internalPointer());
121119

120+
const auto column = static_cast<ColumnIndex>(index.column());
122121
if (role == Qt::DisplayRole) {
123-
switch(index.column())
124-
{
122+
switch (column) {
125123
case Address:
126124
return QString::fromStdString(rec->subnet.ToString());
127125
case Bantime:
128126
QDateTime date = QDateTime::fromMSecsSinceEpoch(0);
129127
date = date.addSecs(rec->banEntry.nBanUntil);
130128
return QLocale::system().toString(date, QLocale::LongFormat);
131-
}
129+
} // no default case, so the compiler can warn about missing cases
130+
assert(false);
132131
}
133132

134133
return QVariant();

src/qt/bitcoin.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747

4848
#include <QApplication>
4949
#include <QDebug>
50+
#include <QFontDatabase>
5051
#include <QLatin1String>
5152
#include <QLibraryInfo>
5253
#include <QLocale>
@@ -576,6 +577,7 @@ int GuiMain(int argc, char* argv[])
576577
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
577578

578579
BitcoinApplication app;
580+
QFontDatabase::addApplicationFont(":/fonts/monospace");
579581

580582
/// 2. Parse command-line options. We do this after qt in order to show an error if there are problems parsing these
581583
// Command-line options take precedence:

src/qt/bitcoingui.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const NetworkStyle* networkStyle,
9595
move(QGuiApplication::primaryScreen()->availableGeometry().center() - frameGeometry().center());
9696
}
9797

98+
setContextMenuPolicy(Qt::PreventContextMenu);
99+
98100
#ifdef ENABLE_WALLET
99101
enableWallet = WalletModel::isWalletEnabled();
100102
#endif // ENABLE_WALLET
@@ -669,7 +671,6 @@ void BitcoinGUI::createToolBars()
669671
{
670672
QToolBar *toolbar = new QToolBar(tr("Tabs toolbar"));
671673
appToolBar = toolbar;
672-
toolbar->setContextMenuPolicy(Qt::PreventContextMenu);
673674
toolbar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
674675
toolbar->setToolButtonStyle(Qt::ToolButtonTextOnly);
675676
toolbar->setMovable(false); // remove unused icon in upper left corner

src/qt/dash.qrc

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
<file alias="Traditional">res/css/traditional.css</file>
3737
</qresource>
3838
<qresource prefix="/fonts">
39+
<file alias="monospace">res/fonts/RobotoMono-Bold.ttf</file>
3940
<file alias="Montserrat-Black">res/fonts/Montserrat/Montserrat-Black.otf</file>
4041
<file alias="Montserrat-BlackItalic">res/fonts/Montserrat/Montserrat-BlackItalic.otf</file>
4142
<file alias="Montserrat-Bold">res/fonts/Montserrat/Montserrat-Bold.otf</file>

src/qt/forms/debugwindow.ui

+2-2
Original file line numberDiff line numberDiff line change
@@ -1028,10 +1028,10 @@
10281028
<item row="4" column="0">
10291029
<widget class="QLabel" name="peerConnectionTypeLabel">
10301030
<property name="toolTip">
1031-
<string>The type of peer connection:&lt;ul&gt;&lt;li&gt;Inbound: initiated by peer&lt;/li&gt;&lt;li&gt;Outbound Full Relay: default&lt;/li&gt;&lt;li&gt;Outbound Block Relay: does not relay transactions or addresses&lt;/li&gt;&lt;li&gt;Outbound Manual: added using RPC %1 or %2/%3 configuration options&lt;/li&gt;&lt;li&gt;Outbound Feeler: short-lived, for testing addresses&lt;/li&gt;&lt;li&gt;Outbound Address Fetch: short-lived, for soliciting addresses&lt;/li&gt;&lt;/ul&gt;</string>
1031+
<string>The direction and type of peer connection: %1</string>
10321032
</property>
10331033
<property name="text">
1034-
<string>Connection Type</string>
1034+
<string>Direction/Type</string>
10351035
</property>
10361036
</widget>
10371037
</item>

src/qt/guiutil.cpp

+19-7
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,14 @@ QString dateTimeStr(qint64 nTime)
260260
return dateTimeStr(QDateTime::fromTime_t((qint32)nTime));
261261
}
262262

263+
QFont fixedPitchFont(bool use_embedded_font)
264+
{
265+
if (use_embedded_font) {
266+
return {"Roboto Mono"};
267+
}
268+
return QFontDatabase::systemFont(QFontDatabase::FixedFont);
269+
}
270+
263271
// Just some dummy data to generate a convincing random-looking (but consistent) address
264272
static const uint8_t dummydata[] = {0xeb,0x15,0x23,0x1d,0xfc,0xeb,0x60,0x92,0x58,0x86,0xb6,0x7d,0x06,0x52,0x99,0x92,0x59,0x15,0xae,0xb1,0x72,0xc0,0x66,0x47};
265273

@@ -1661,15 +1669,19 @@ QString NetworkToQString(Network net)
16611669
assert(false);
16621670
}
16631671

1664-
QString ConnectionTypeToQString(ConnectionType conn_type)
1672+
QString ConnectionTypeToQString(ConnectionType conn_type, bool prepend_direction)
16651673
{
1674+
QString prefix;
1675+
if (prepend_direction) {
1676+
prefix = (conn_type == ConnectionType::INBOUND) ? QObject::tr("Inbound") : QObject::tr("Outbound") + " ";
1677+
}
16661678
switch (conn_type) {
1667-
case ConnectionType::INBOUND: return QObject::tr("Inbound");
1668-
case ConnectionType::OUTBOUND_FULL_RELAY: return QObject::tr("Outbound Full Relay");
1669-
case ConnectionType::BLOCK_RELAY: return QObject::tr("Outbound Block Relay");
1670-
case ConnectionType::MANUAL: return QObject::tr("Outbound Manual");
1671-
case ConnectionType::FEELER: return QObject::tr("Outbound Feeler");
1672-
case ConnectionType::ADDR_FETCH: return QObject::tr("Outbound Address Fetch");
1679+
case ConnectionType::INBOUND: return prefix;
1680+
case ConnectionType::OUTBOUND_FULL_RELAY: return prefix + QObject::tr("Full Relay");
1681+
case ConnectionType::BLOCK_RELAY: return prefix + QObject::tr("Block Relay");
1682+
case ConnectionType::MANUAL: return prefix + QObject::tr("Manual");
1683+
case ConnectionType::FEELER: return prefix + QObject::tr("Feeler");
1684+
case ConnectionType::ADDR_FETCH: return prefix + QObject::tr("Address Fetch");
16731685
} // no default case, so the compiler can warn about missing cases
16741686
assert(false);
16751687
}

src/qt/guiutil.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ namespace GUIUtil
126126
QString dateTimeStr(const QDateTime &datetime);
127127
QString dateTimeStr(qint64 nTime);
128128

129+
// Return a monospace font
130+
QFont fixedPitchFont(bool use_embedded_font = false);
131+
129132
// Set up widget for address
130133
void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent, bool fAllowURI = false);
131134

@@ -398,7 +401,7 @@ namespace GUIUtil
398401
QString NetworkToQString(Network net);
399402

400403
/** Convert enum ConnectionType to QString */
401-
QString ConnectionTypeToQString(ConnectionType conn_type);
404+
QString ConnectionTypeToQString(ConnectionType conn_type, bool prepend_direction);
402405

403406
/** Convert seconds into a QString with days, hours, mins, secs */
404407
QString formatDurationStr(std::chrono::seconds dur);

src/qt/intro.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,12 @@ void Intro::setStatus(int status, const QString &message, quint64 bytesAvailable
304304

305305
void Intro::UpdateFreeSpaceLabel()
306306
{
307-
QString freeString = tr("%n GB of free space available", "", m_bytes_available / GB_BYTES);
307+
QString freeString = tr("%1 GB of free space available").arg(m_bytes_available / GB_BYTES);
308308
if (m_bytes_available < m_required_space_gb * GB_BYTES) {
309-
freeString += " " + tr("(of %n GB needed)", "", m_required_space_gb);
309+
freeString += " " + tr("(of %1 GB needed)").arg(m_required_space_gb);
310310
ui->freeSpace->setStyleSheet(GUIUtil::getThemedStyleQString(GUIUtil::ThemedStyle::TS_ERROR));
311311
} else if (m_bytes_available / GB_BYTES - m_required_space_gb < 10) {
312-
freeString += " " + tr("(%n GB needed for full chain)", "", m_required_space_gb);
312+
freeString += " " + tr("(%1 GB needed for full chain)").arg(m_required_space_gb);
313313
ui->freeSpace->setStyleSheet(GUIUtil::getThemedStyleQString(GUIUtil::ThemedStyle::TS_WARNING));
314314
} else {
315315
ui->freeSpace->setStyleSheet("");

src/qt/paymentserver.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -233,14 +233,17 @@ void PaymentServer::handleURIOrFile(const QString& s)
233233
SendCoinsRecipient recipient;
234234
if (GUIUtil::parseBitcoinURI(s, &recipient))
235235
{
236-
if (!IsValidDestinationString(recipient.address.toStdString())) {
236+
std::string error_msg;
237+
const CTxDestination dest = DecodeDestination(recipient.address.toStdString(), error_msg);
238+
239+
if (!IsValidDestination(dest)) {
237240
if (uri.hasQueryItem("r")) { // payment request
238241
Q_EMIT message(tr("URI handling"),
239242
tr("Cannot process payment request as BIP70 is no longer supported.")+
240243
tr("Due to discontinued support, you should request the merchant to provide you with a BIP21 compatible URI or use a wallet that does continue to support BIP70."),
241244
CClientUIInterface::ICON_WARNING);
242245
} else {
243-
Q_EMIT message(tr("URI handling"), tr("Invalid payment address %1").arg(recipient.address),
246+
Q_EMIT message(tr("URI handling"), QString::fromStdString(error_msg),
244247
CClientUIInterface::MSG_ERROR);
245248
}
246249
}

0 commit comments

Comments
 (0)