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

use fixedfont
pull/26157/head
Dean Lee 3 years ago committed by GitHub
parent a927d7b0ea
commit 3fae3b3660
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      tools/cabana/binaryview.cc
  2. 2
      tools/cabana/binaryview.h

@ -1,6 +1,7 @@
#include "tools/cabana/binaryview.h" #include "tools/cabana/binaryview.h"
#include <QApplication> #include <QApplication>
#include <QFontDatabase>
#include <QHeaderView> #include <QHeaderView>
#include <QPainter> #include <QPainter>
@ -157,7 +158,8 @@ void BinarySelectionModel::select(const QItemSelection &selection, QItemSelectio
BinaryItemDelegate::BinaryItemDelegate(QObject *parent) : QStyledItemDelegate(parent) { BinaryItemDelegate::BinaryItemDelegate(QObject *parent) : QStyledItemDelegate(parent) {
// cache fonts and color // cache fonts and color
small_font.setPointSize(6); 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); 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 // TODO: highlight signal cells on mouse over
painter->fillRect(option.rect, option.state & QStyle::State_Selected ? highlight_color : item->bg_color); painter->fillRect(option.rect, option.state & QStyle::State_Selected ? highlight_color : item->bg_color);
if (index.column() == 8) { if (index.column() == 8) {
painter->setFont(bold_font); painter->setFont(hex_font);
} }
painter->drawText(option.rect, Qt::AlignCenter, item->val); painter->drawText(option.rect, Qt::AlignCenter, item->val);
if (item->is_msb || item->is_lsb) { if (item->is_msb || item->is_lsb) {

@ -14,7 +14,7 @@ public:
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
private: private:
QFont small_font, bold_font; QFont small_font, hex_font;
QColor highlight_color; QColor highlight_color;
}; };

Loading…
Cancel
Save