Three follow-ups to #163:
- return relay type for inbound peers
- improve markup handling in the tooltip to facilitate translations
- update ConnectionType doxygen documentation

471 | + "<li>Outbound Full Relay: default</li>" 472 | + "<li>Outbound Block Relay: does not relay transactions or addresses</li>" 473 | + "<li>Outbound Manual: added using RPC %1 or %2/%3 configuration options</li>" 474 | + "<li>Outbound Feeler: short-lived, for testing addresses</li>" 475 | + "<li>Outbound Address Fetch: short-lived, for soliciting addresses</li>" 476 | + "</ul>")
I'm not sure if the markup should be replaced by placeholders here or not. I see inline *.cpp markup like tr("<b>abc</b>") elsewhere in the GUI codebase.
resolved
474 | + "<li>Outbound Feeler: short-lived, for testing addresses</li>" 475 | + "<li>Outbound Address Fetch: short-lived, for soliciting addresses</li>" 476 | + "</ul>") 477 | + .arg("addnode") 478 | + .arg(QString(nonbreaking_hyphen) + "addnode") 479 | + .arg(QString(nonbreaking_hyphen) + "connect")));
How about
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -463,19 +463,19 @@ RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle *_platformSty
ui->dataDir->setToolTip(ui->dataDir->toolTip().arg(QString(nonbreaking_hyphen) + "datadir"));
ui->blocksDir->setToolTip(ui->blocksDir->toolTip().arg(QString(nonbreaking_hyphen) + "blocksdir"));
ui->openDebugLogfileButton->setToolTip(ui->openDebugLogfileButton->toolTip().arg(PACKAGE_NAME));
- ui->peerConnectionTypeLabel->setToolTip(
- ui->peerConnectionTypeLabel->toolTip()
- .arg(tr("<ul>"
- "<li>Inbound Relay: initiated by peer</li>"
- "<li>Outbound Full Relay: default</li>"
- "<li>Outbound Block Relay: does not relay transactions or addresses</li>"
- "<li>Outbound Manual: added using RPC %1 or %2/%3 configuration options</li>"
- "<li>Outbound Feeler: short-lived, for testing addresses</li>"
- "<li>Outbound Address Fetch: short-lived, for soliciting addresses</li>"
- "</ul>")
- .arg("addnode")
- .arg(QString(nonbreaking_hyphen) + "addnode")
- .arg(QString(nonbreaking_hyphen) + "connect")));
+
+ const std::vector<QString> list_items{
+ tr("Inbound Relay: initiated by peer"),
+ tr("Outbound Full Relay: default"),
+ tr("Outbound Block Relay: does not relay transactions or addresses"),
+ tr("Outbound Manual: added using RPC %1 or %2/%3 configuration options")
+ .arg("addnode")
+ .arg(QString(nonbreaking_hyphen) + "addnode")
+ .arg(QString(nonbreaking_hyphen) + "connect"),
+ tr("Outbound Feeler: short-lived, for testing addresses"),
+ tr("Outbound Address Fetch: short-lived, for soliciting addresses")};
+ const QString list = "<ul><li>" + Join(list_items, QString("</li><li>")) + "</li></ul>";
+ ui->peerConnectionTypeLabel->setToolTip(ui->peerConnectionTypeLabel->toolTip().arg(list));
if (platformStyle->getImagesOnButtons()) {
ui->openDebugLogfileButton->setIcon(platformStyle->SingleColorIcon(":/icons/export"));
?
(and #include ~<string.h>~ <util/string.h> )
Nice, thanks! We were thinking in the same direction. Adapted it and added your name to the commit.
44 | @@ -45,6 +45,7 @@ 45 | #include <QTime> 46 | #include <QTimer> 47 | 48 | +#include <string>
My bad, I meant #include <util/string.h> for the Join template function.
Oops, fixed
459 | @@ -459,11 +460,22 @@ RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle *_platformSty 460 | 461 | ui->splitter->restoreState(settings.value("PeersTabSplitterSizes").toByteArray()); 462 | 463 | - QChar nonbreaking_hyphen(8209); 464 | + const QChar nonbreaking_hyphen(8209); 465 | + const std::vector<QString> CONNECTION_TYPE_DOC{
Named it CONNECTION_TYPE_DOC to show up in git grep with the constant of the same name in rpc/net.cpp and updated the net.h documentation
763 | @@ -764,10 +764,10 @@ QString NetworkToQString(Network net) 764 | assert(false); 765 | } 766 | 767 | -QString ConnectionTypeToQString(ConnectionType conn_type) 768 | +QString ConnectionTypeToQString(ConnectionType conn_type, bool relay_txes) 769 | { 770 | switch (conn_type) { 771 | - case ConnectionType::INBOUND: return QObject::tr("Inbound"); 772 | + case ConnectionType::INBOUND: return QObject::tr(relay_txes ? "Inbound Full Relay" : "Inbound Block Relay");
df5fb7ed64f5e47cad66c2fe3582c66a7896f818, for correct work of translation mechanics
case ConnectionType::INBOUND: return relay_txes ? QObject::tr("Inbound Full Relay") : QObject::tr("Inbound Block Relay");
It seems equivalent? Anyway, done--thank you for looking!
It is not equivalent for the lupdate tool:
When Qt's translation tool, lupdate, is used to process a set of source files, the text wrapped in
tr()calls is stored in a section of the translation file that corresponds to its translation context.
Approach ACK 1a297a7ea08c3ca5c591ba4942a5a12bc90a210d.
110 | @@ -111,7 +111,8 @@ struct CSerializedNetMsg 111 | * connection. Aside from INBOUND, all types are initiated by us. 112 | * 113 | * If adding or removing types, please update CONNECTION_TYPE_DOC in 114 | - * src/rpc/net.cpp. */ 115 | + * src/rpc/net.cpp and src/qt/rpcconsole.cpp, as well as the descriptions in 116 | + * src/qt/guiutil.cpp and src/bitcoin-cli.cpp::NetinfoRequestHandler. */
nit: A compiler will care of all switch statements in src/qt/guiutil.cpp :)
True. Nevertheless, per element of least surprise, if we list the sites to update we may as well list all of them and save developer time.
763 | @@ -764,10 +764,10 @@ QString NetworkToQString(Network net) 764 | assert(false); 765 | } 766 | 767 | -QString ConnectionTypeToQString(ConnectionType conn_type) 768 | +QString ConnectionTypeToQString(ConnectionType conn_type, bool relay_txes) 769 | { 770 | switch (conn_type) { 771 | - case ConnectionType::INBOUND: return QObject::tr("Inbound"); 772 | + case ConnectionType::INBOUND: return relay_txes ? QObject::tr("Inbound Full Relay") : QObject::tr("Inbound Block Relay");
nit: Is a tooltip update required (see the screenshot)?
Updated to Inbound Full/Block Relay
SPV (light-wallet) peers are not "inbound block relay" peers
good point, fixing
444 | @@ -444,7 +445,7 @@ void RPCExecutor::request(const QString &command, const WalletModel* wallet_mode 445 | } 446 | } 447 | 448 | -RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle *_platformStyle, QWidget *parent) : 449 | +RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle* _platformStyle, QWidget* parent) :
nit: This change is unrelated to this PR :)
removed (clang-format did it ;)
459 | @@ -459,11 +460,22 @@ RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle *_platformSty 460 | 461 | ui->splitter->restoreState(settings.value("PeersTabSplitterSizes").toByteArray()); 462 | 463 | - QChar nonbreaking_hyphen(8209); 464 | + const QChar nonbreaking_hyphen(8209);
nit:
constexpr QChar nonbreaking_hyphen(8209);
done, thanks
ACK e711200759c4e772e029c5014863791d23597516, tested on Linux Mint 20.1 (Qt 5.12.8):

Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
Thanks @hebasto! Updated.
<details><summary><code>git diff e711200 79a2576</code></summary><p>
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index 4fdc74c48..44addeeda 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -445,7 +445,7 @@ void RPCExecutor::request(const QString &command, const WalletModel* wallet_mode
}
}
-RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle* _platformStyle, QWidget* parent) :
+RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle *_platformStyle, QWidget *parent) :
QWidget(parent),
m_node(node),
ui(new Ui::RPCConsole),
@@ -460,9 +460,9 @@ RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle* _platformSty
ui->splitter->restoreState(settings.value("PeersTabSplitterSizes").toByteArray());
- const QChar nonbreaking_hyphen(8209);
+ constexpr QChar nonbreaking_hyphen(8209);
const std::vector<QString> CONNECTION_TYPE_DOC{
- tr("Inbound: initiated by peer"),
+ tr("Inbound Full/Block Relay: initiated by peer"),
tr("Outbound Full Relay: default"),
tr("Outbound Block Relay: does not relay transactions or addresses"),
tr("Outbound Manual: added using RPC %1 or %2/%3 configuration options")
</p></details>

1078 | @@ -1079,7 +1079,7 @@ 1079 | <item row="1" column="0"> 1080 | <widget class="QLabel" name="peerConnectionTypeLabel"> 1081 | <property name="toolTip"> 1082 | - <string>The type of peer connection:<ul><li>Inbound Full/Block Relay: initiated by peer</li><li>Outbound Full Relay: default</li><li>Outbound Block Relay: does not relay transactions or addresses</li><li>Outbound Manual: added using RPC %1 or %2/%3 configuration options</li><li>Outbound Feeler: short-lived, for testing addresses</li><li>Outbound Address Fetch: short-lived, for soliciting addresses</li></ul></string> 1083 | + <string>The type of peer connection: %1</string>
f3153dc08fa16aa3bbca52f67833e5c9fbe8e095
Just move the whole tooltip? Why have a bit here?
Why have a bit here?
In Qt Designer it makes obvious a tooltip presence.
Just move the whole tooltip? Why have a bit here?
That's what I started with in #163, see #163 (comment)
There have been a few iterations on this tooltip 😄
I see, still not fond of the approach. Being a dynamic tooltip I think it's fine to not be in the .ui file. If someone adds a tooltip in the designer then it will be obvious that it's being replaced at runtime. Reading this code makes you check what is in the .ui, and you still have to check this code if you change what's in the .ui. At the end anyone that wants to change this still has to check both places.
I think that a good rule of thumb is to leave all static/constant stuff for .ui.
Not saying that this is incorrect or that it doesn't work, just my opinion. It's fine if it's merged as is.
I don't have a strong opinion and saw other tooltips with html markup completely in the .cpp file, but I also don't have Qt or Qt Designer experience. I'm happy to keep it as-is or move it, either way.
Concept ACK.
ACK 79a2576af1e499102943aa4e1d98994ee8a9c6b5, tested on macOS 11.1 with Qt 5.15.2
<img width="522" alt="Screen Shot 2021-01-15 at 3 08 51 PM" src="https://user-images.githubusercontent.com/23396902/104773831-a8b82d80-5743-11eb-8800-3353882d8c5f.png">
I don't believe this much information should be displayed in a mouse over event. Attaching a click event to a UILabel (or a question mark image) would be a better approach (imo). The click event could trigger a modal view that gives a more detailed explanation of the information contained in the entire panel.
This pull doesn't add the tooltip. It makes these follow-ups to #163:
(Feel free to open a pull to propose your approach.)
Code review ACK 79a2576af1e499102943aa4e1d98994ee8a9c6b5
Thanks!