diff options
author | Jon Atack <jon@atack.com> | 2020-12-24 12:35:37 +0100 |
---|---|---|
committer | Jon Atack <jon@atack.com> | 2021-01-08 15:24:31 +0100 |
commit | 7e2beab2d28d8ab039d9554744a11592a7d7dc76 (patch) | |
tree | 5542229036810594b9a47362fee45f687ddc8d60 /src | |
parent | 9158d6f34153dc937e109d0e7486e956a26f20aa (diff) |
gui: create GUIUtil::ConnectionTypeToQString utility function
Diffstat (limited to 'src')
-rw-r--r-- | src/qt/guiutil.cpp | 13 | ||||
-rw-r--r-- | src/qt/guiutil.h | 6 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 8205b0506c..430ecd322f 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -764,6 +764,19 @@ QString NetworkToQString(Network net) assert(false); } +QString ConnectionTypeToQString(ConnectionType conn_type) +{ + 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"); + } // no default case, so the compiler can warn about missing cases + assert(false); +} + QString formatDurationStr(int secs) { QStringList strList; diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 4bef13efb5..c471b888f7 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -7,17 +7,18 @@ #include <amount.h> #include <fs.h> +#include <net.h> #include <netaddress.h> #include <QEvent> #include <QHeaderView> #include <QItemDelegate> +#include <QLabel> #include <QMessageBox> #include <QObject> #include <QProgressBar> #include <QString> #include <QTableView> -#include <QLabel> class QValidatedLineEdit; class SendCoinsRecipient; @@ -228,6 +229,9 @@ namespace GUIUtil /** Convert enum Network to QString */ QString NetworkToQString(Network net); + /** Convert enum ConnectionType to QString */ + QString ConnectionTypeToQString(ConnectionType conn_type); + /** Convert seconds into a QString with days, hours, mins, secs */ QString formatDurationStr(int secs); |