cabana: use monospaced font for hex in BinaryView (#26153)

use fixedfont
old-commit-hash: 3fae3b3660
This commit is contained in:
Dean Lee
2022-10-19 23:03:14 +08:00
committed by GitHub
parent c62b6478a0
commit b2939b5fd2
2 changed files with 5 additions and 3 deletions
+4 -2
View File
@@ -1,6 +1,7 @@
#include "tools/cabana/binaryview.h"
#include <QApplication>
#include <QFontDatabase>
#include <QHeaderView>
#include <QPainter>
@@ -157,7 +158,8 @@ void BinarySelectionModel::select(const QItemSelection &selection, QItemSelectio
BinaryItemDelegate::BinaryItemDelegate(QObject *parent) : QStyledItemDelegate(parent) {
// cache fonts and color
small_font.setPointSize(6);
bold_font.setBold(true);
hex_font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
hex_font.setBold(true);
highlight_color = QApplication::style()->standardPalette().color(QPalette::Active, QPalette::Highlight);
}
@@ -172,7 +174,7 @@ void BinaryItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
// TODO: highlight signal cells on mouse over
painter->fillRect(option.rect, option.state & QStyle::State_Selected ? highlight_color : item->bg_color);
if (index.column() == 8) {
painter->setFont(bold_font);
painter->setFont(hex_font);
}
painter->drawText(option.rect, Qt::AlignCenter, item->val);
if (item->is_msb || item->is_lsb) {
+1 -1
View File
@@ -14,7 +14,7 @@ public:
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
private:
QFont small_font, bold_font;
QFont small_font, hex_font;
QColor highlight_color;
};