Skip to content

Commit

Permalink
Merge #325: Align numbers in the "Peer Id" column to the right
Browse files Browse the repository at this point in the history
69b8b5d qt: Align numbers in the "Peer Id" column to the right (Hennadii Stepanov)

Pull request description:

  On master (6b49d88):
  ![Screenshot from 2021-05-12 21-53-52](https://user-images.githubusercontent.com/32963518/118029170-9013f900-b36c-11eb-9e27-36140cbd618e.png)

  With this PR:
  ![Screenshot from 2021-05-12 21-48-19](https://user-images.githubusercontent.com/32963518/118028803-2a277180-b36c-11eb-83ae-77d3e8cdd343.png)

ACKs for top commit:
  jarolrod:
    ACK 69b8b5d
  jonatack:
    ACK 69b8b5d happy to re-ack with more separation or center-aligned
  kristapsk:
    ACK 69b8b5d

Tree-SHA512: 3279522745a0fe6db1ec9be723a2640a37983947ed1af4aad56f22ce4780cc943a25b2d774529a9eeb3b00309f0204cfbc3f38b7db2c52865d05bf6a7c87e747
  • Loading branch information
hebasto committed Jun 5, 2021
2 parents 898dd9e + 69b8b5d commit 38ab7d0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/qt/peertablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
} else if (role == Qt::TextAlignmentRole) {
switch (column) {
case NetNodeId:
return QVariant(Qt::AlignRight | Qt::AlignVCenter);
case Address:
return {};
case ConnectionType:
Expand Down
20 changes: 19 additions & 1 deletion src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,19 @@
#include <QDateTime>
#include <QFont>
#include <QKeyEvent>
#include <QLatin1String>
#include <QLocale>
#include <QMenu>
#include <QMessageBox>
#include <QScreen>
#include <QScrollBar>
#include <QSettings>
#include <QString>
#include <QStringList>
#include <QStyledItemDelegate>
#include <QTime>
#include <QTimer>

#include <QVariant>

const int CONSOLE_HISTORY = 50;
const int INITIAL_TRAFFIC_GRAPH_MINS = 30;
Expand Down Expand Up @@ -128,6 +131,20 @@ class QtRPCTimerInterface: public RPCTimerInterface
}
};

class PeerIdViewDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
explicit PeerIdViewDelegate(QObject* parent = nullptr)
: QStyledItemDelegate(parent) {}

QString displayText(const QVariant& value, const QLocale& locale) const override
{
// Additional spaces should visually separate right-aligned content
// from the next column to the right.
return value.toString() + QLatin1String(" ");
}
};

#include <qt/rpcconsole.moc>

Expand Down Expand Up @@ -644,6 +661,7 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_
ui->peerWidget->setColumnWidth(PeerTableModel::Subversion, SUBVERSION_COLUMN_WIDTH);
ui->peerWidget->setColumnWidth(PeerTableModel::Ping, PING_COLUMN_WIDTH);
ui->peerWidget->horizontalHeader()->setStretchLastSection(true);
ui->peerWidget->setItemDelegateForColumn(PeerTableModel::NetNodeId, new PeerIdViewDelegate(this));

// create peer table context menu
peersTableContextMenu = new QMenu(this);
Expand Down

0 comments on commit 38ab7d0

Please sign in to comment.