Skip to content

Commit

Permalink
Merge #6049: backport: merge bitcoin-core/gui#180, #203, #179, #219, #…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
PastaPastaPasta committed Jun 10, 2024
2 parents 825bba1 + ddca614 commit 8f2a460
Show file tree
Hide file tree
Showing 20 changed files with 220 additions and 112 deletions.
15 changes: 15 additions & 0 deletions contrib/debian/copyright
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ Files: src/qt/res/icons/proxy.png
Copyright: Cristian Mircea Messel
License: public-domain

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


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

License: public-domain
This work is in the public domain.

License: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
3 changes: 2 additions & 1 deletion src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,8 @@ RES_FONTS = \
qt/res/fonts/Montserrat/Montserrat-SemiBold.otf \
qt/res/fonts/Montserrat/Montserrat-SemiBoldItalic.otf \
qt/res/fonts/Montserrat/Montserrat-Thin.otf \
qt/res/fonts/Montserrat/Montserrat-ThinItalic.otf
qt/res/fonts/Montserrat/Montserrat-ThinItalic.otf \
qt/res/fonts/RobotoMono-Bold.ttf

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

Expand Down
11 changes: 6 additions & 5 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ struct CSerializedNetMsg
* connection. Aside from INBOUND, all types are initiated by us.
*
* If adding or removing types, please update CONNECTION_TYPE_DOC in
* src/rpc/net.cpp. */
* src/rpc/net.cpp and src/qt/rpcconsole.cpp, as well as the descriptions in
* src/qt/guiutil.cpp and src/bitcoin-cli.cpp::NetinfoRequestHandler. */
enum class ConnectionType {
/**
* Inbound connections are those initiated by a peer. This is the only
Expand All @@ -159,16 +160,16 @@ enum class ConnectionType {

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


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

Expand Down
44 changes: 20 additions & 24 deletions src/qt/addresstablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,42 +195,38 @@ QVariant AddressTableModel::data(const QModelIndex &index, int role) const

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

if(role == Qt::DisplayRole || role == Qt::EditRole)
{
switch(index.column())
{
const auto column = static_cast<ColumnIndex>(index.column());
if (role == Qt::DisplayRole || role == Qt::EditRole) {
switch (column) {
case Label:
if(rec->label.isEmpty() && role == Qt::DisplayRole)
{
if (rec->label.isEmpty() && role == Qt::DisplayRole) {
return tr("(no label)");
}
else
{
} else {
return rec->label;
}
case Address:
return rec->address;
}
}
else if (role == Qt::FontRole)
{
QFont font;
if(index.column() == Address)
{
font = GUIUtil::getFontNormal();
}
return font;
}
else if (role == TypeRole)
{
} // no default case, so the compiler can warn about missing cases
assert(false);
} else if (role == Qt::FontRole) {
switch (column) {
case Label:
return QFont();
case Address:
return GUIUtil::getFontNormal();
} // no default case, so the compiler can warn about missing cases
assert(false);
} else if (role == TypeRole) {
switch(rec->type)
{
case AddressTableEntry::Sending:
return Send;
case AddressTableEntry::Receiving:
return Receive;
default: break;
}
case AddressTableEntry::Hidden:
return {};
} // no default case, so the compiler can warn about missing cases
assert(false);
}
return QVariant();
}
Expand Down
15 changes: 7 additions & 8 deletions src/qt/bantablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@ bool BannedNodeLessThan::operator()(const CCombinedBan& left, const CCombinedBan
if (order == Qt::DescendingOrder)
std::swap(pLeft, pRight);

switch(column)
{
switch (static_cast<BanTableModel::ColumnIndex>(column)) {
case BanTableModel::Address:
return pLeft->subnet.ToString().compare(pRight->subnet.ToString()) < 0;
case BanTableModel::Bantime:
return pLeft->banEntry.nBanUntil < pRight->banEntry.nBanUntil;
}

return false;
} // no default case, so the compiler can warn about missing cases
assert(false);
}

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

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

const auto column = static_cast<ColumnIndex>(index.column());
if (role == Qt::DisplayRole) {
switch(index.column())
{
switch (column) {
case Address:
return QString::fromStdString(rec->subnet.ToString());
case Bantime:
QDateTime date = QDateTime::fromMSecsSinceEpoch(0);
date = date.addSecs(rec->banEntry.nBanUntil);
return QLocale::system().toString(date, QLocale::LongFormat);
}
} // no default case, so the compiler can warn about missing cases
assert(false);
}

return QVariant();
Expand Down
2 changes: 2 additions & 0 deletions src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@

#include <QApplication>
#include <QDebug>
#include <QFontDatabase>
#include <QLatin1String>
#include <QLibraryInfo>
#include <QLocale>
Expand Down Expand Up @@ -576,6 +577,7 @@ int GuiMain(int argc, char* argv[])
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

BitcoinApplication app;
QFontDatabase::addApplicationFont(":/fonts/monospace");

/// 2. Parse command-line options. We do this after qt in order to show an error if there are problems parsing these
// Command-line options take precedence:
Expand Down
3 changes: 2 additions & 1 deletion src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const NetworkStyle* networkStyle,
move(QGuiApplication::primaryScreen()->availableGeometry().center() - frameGeometry().center());
}

setContextMenuPolicy(Qt::PreventContextMenu);

#ifdef ENABLE_WALLET
enableWallet = WalletModel::isWalletEnabled();
#endif // ENABLE_WALLET
Expand Down Expand Up @@ -669,7 +671,6 @@ void BitcoinGUI::createToolBars()
{
QToolBar *toolbar = new QToolBar(tr("Tabs toolbar"));
appToolBar = toolbar;
toolbar->setContextMenuPolicy(Qt::PreventContextMenu);
toolbar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
toolbar->setToolButtonStyle(Qt::ToolButtonTextOnly);
toolbar->setMovable(false); // remove unused icon in upper left corner
Expand Down
1 change: 1 addition & 0 deletions src/qt/dash.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<file alias="Traditional">res/css/traditional.css</file>
</qresource>
<qresource prefix="/fonts">
<file alias="monospace">res/fonts/RobotoMono-Bold.ttf</file>
<file alias="Montserrat-Black">res/fonts/Montserrat/Montserrat-Black.otf</file>
<file alias="Montserrat-BlackItalic">res/fonts/Montserrat/Montserrat-BlackItalic.otf</file>
<file alias="Montserrat-Bold">res/fonts/Montserrat/Montserrat-Bold.otf</file>
Expand Down
4 changes: 2 additions & 2 deletions src/qt/forms/debugwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1028,10 +1028,10 @@
<item row="4" column="0">
<widget class="QLabel" name="peerConnectionTypeLabel">
<property name="toolTip">
<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>
<string>The direction and type of peer connection: %1</string>
</property>
<property name="text">
<string>Connection Type</string>
<string>Direction/Type</string>
</property>
</widget>
</item>
Expand Down
26 changes: 19 additions & 7 deletions src/qt/guiutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,14 @@ QString dateTimeStr(qint64 nTime)
return dateTimeStr(QDateTime::fromTime_t((qint32)nTime));
}

QFont fixedPitchFont(bool use_embedded_font)
{
if (use_embedded_font) {
return {"Roboto Mono"};
}
return QFontDatabase::systemFont(QFontDatabase::FixedFont);
}

// Just some dummy data to generate a convincing random-looking (but consistent) address
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};

Expand Down Expand Up @@ -1661,15 +1669,19 @@ QString NetworkToQString(Network net)
assert(false);
}

QString ConnectionTypeToQString(ConnectionType conn_type)
QString ConnectionTypeToQString(ConnectionType conn_type, bool prepend_direction)
{
QString prefix;
if (prepend_direction) {
prefix = (conn_type == ConnectionType::INBOUND) ? QObject::tr("Inbound") : QObject::tr("Outbound") + " ";
}
switch (conn_type) {
case ConnectionType::INBOUND: return QObject::tr("Inbound");
case ConnectionType::OUTBOUND_FULL_RELAY: return QObject::tr("Outbound Full Relay");
case ConnectionType::BLOCK_RELAY: return QObject::tr("Outbound Block Relay");
case ConnectionType::MANUAL: return QObject::tr("Outbound Manual");
case ConnectionType::FEELER: return QObject::tr("Outbound Feeler");
case ConnectionType::ADDR_FETCH: return QObject::tr("Outbound Address Fetch");
case ConnectionType::INBOUND: return prefix;
case ConnectionType::OUTBOUND_FULL_RELAY: return prefix + QObject::tr("Full Relay");
case ConnectionType::BLOCK_RELAY: return prefix + QObject::tr("Block Relay");
case ConnectionType::MANUAL: return prefix + QObject::tr("Manual");
case ConnectionType::FEELER: return prefix + QObject::tr("Feeler");
case ConnectionType::ADDR_FETCH: return prefix + QObject::tr("Address Fetch");
} // no default case, so the compiler can warn about missing cases
assert(false);
}
Expand Down
5 changes: 4 additions & 1 deletion src/qt/guiutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ namespace GUIUtil
QString dateTimeStr(const QDateTime &datetime);
QString dateTimeStr(qint64 nTime);

// Return a monospace font
QFont fixedPitchFont(bool use_embedded_font = false);

// Set up widget for address
void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent, bool fAllowURI = false);

Expand Down Expand Up @@ -398,7 +401,7 @@ namespace GUIUtil
QString NetworkToQString(Network net);

/** Convert enum ConnectionType to QString */
QString ConnectionTypeToQString(ConnectionType conn_type);
QString ConnectionTypeToQString(ConnectionType conn_type, bool prepend_direction);

/** Convert seconds into a QString with days, hours, mins, secs */
QString formatDurationStr(std::chrono::seconds dur);
Expand Down
6 changes: 3 additions & 3 deletions src/qt/intro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,12 @@ void Intro::setStatus(int status, const QString &message, quint64 bytesAvailable

void Intro::UpdateFreeSpaceLabel()
{
QString freeString = tr("%n GB of free space available", "", m_bytes_available / GB_BYTES);
QString freeString = tr("%1 GB of free space available").arg(m_bytes_available / GB_BYTES);
if (m_bytes_available < m_required_space_gb * GB_BYTES) {
freeString += " " + tr("(of %n GB needed)", "", m_required_space_gb);
freeString += " " + tr("(of %1 GB needed)").arg(m_required_space_gb);
ui->freeSpace->setStyleSheet(GUIUtil::getThemedStyleQString(GUIUtil::ThemedStyle::TS_ERROR));
} else if (m_bytes_available / GB_BYTES - m_required_space_gb < 10) {
freeString += " " + tr("(%n GB needed for full chain)", "", m_required_space_gb);
freeString += " " + tr("(%1 GB needed for full chain)").arg(m_required_space_gb);
ui->freeSpace->setStyleSheet(GUIUtil::getThemedStyleQString(GUIUtil::ThemedStyle::TS_WARNING));
} else {
ui->freeSpace->setStyleSheet("");
Expand Down
7 changes: 5 additions & 2 deletions src/qt/paymentserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,17 @@ void PaymentServer::handleURIOrFile(const QString& s)
SendCoinsRecipient recipient;
if (GUIUtil::parseBitcoinURI(s, &recipient))
{
if (!IsValidDestinationString(recipient.address.toStdString())) {
std::string error_msg;
const CTxDestination dest = DecodeDestination(recipient.address.toStdString(), error_msg);

if (!IsValidDestination(dest)) {
if (uri.hasQueryItem("r")) { // payment request
Q_EMIT message(tr("URI handling"),
tr("Cannot process payment request as BIP70 is no longer supported.")+
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."),
CClientUIInterface::ICON_WARNING);
} else {
Q_EMIT message(tr("URI handling"), tr("Invalid payment address %1").arg(recipient.address),
Q_EMIT message(tr("URI handling"), QString::fromStdString(error_msg),
CClientUIInterface::MSG_ERROR);
}
}
Expand Down
Loading

0 comments on commit 8f2a460

Please sign in to comment.