MCPcopy Index your code
hub / github.com/DreamSourceLab/DSView / paintEvent

Method paintEvent

DSView/pv/view/viewstatus.cpp:58–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58void ViewStatus::paintEvent(QPaintEvent *)
59{
60 QStyleOption opt;
61 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
62 opt.initFrom(this);
63 #else
64 opt.init(this);
65 #endif
66
67 QPainter p(this);
68 style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
69 QColor fore(QWidget::palette().color(QWidget::foregroundRole()));
70
71 QFont font = p.font();
72 float fSize = AppConfig::Instance().appOptions.fontSize;
73 if (fSize > 10)
74 fSize = 10;
75 font.setPointSizeF(fSize);
76 p.setFont(font);
77
78 int mode = _session->get_device()->get_work_mode();
79
80 if (mode == LOGIC) {
81 fore.setAlpha(View::ForeAlpha);
82 p.setPen(fore);
83 p.drawText(this->rect(), Qt::AlignLeft | Qt::AlignVCenter, _rle_depth);
84 p.drawText(this->rect(), Qt::AlignRight | Qt::AlignVCenter, _trig_time);
85
86 p.setPen(Qt::NoPen);
87 p.setBrush(View::Blue);
88 p.drawRect(this->rect().left(), this->rect().bottom() - 3,
89 _session->get_repeat_hold() * this->rect().width() / 100, 3);
90
91 p.setPen(View::Blue);
92 p.drawText(this->rect(), Qt::AlignCenter | Qt::AlignVCenter, _capture_status);
93 }
94 else if (mode == DSO) {
95 fore.setAlpha(View::BackAlpha);
96
97 for(size_t i = 0; i < _mrects.size(); i++) {
98 int sig_index = std::get<1>(_mrects[i]);
99 view::DsoSignal *dsoSig = NULL;
100
101 for(auto s : _session->get_signals()) {
102 if (s->signal_type() == SR_CHANNEL_DSO && s->enabled()) {
103 dsoSig = (view::DsoSignal*)s;
104 if (sig_index == dsoSig->get_index())
105 break;
106 else
107 dsoSig = NULL;
108 }
109 }
110
111 bool active = dsoSig && dsoSig->enabled();
112 const QRect rect = std::get<0>(_mrects[i]);
113 p.setPen(Qt::NoPen);
114 p.setBrush(active ? dsoSig->get_colour() : fore);
115 p.drawRect(QRect(rect.topLeft(), QSize(10, rect.height())));

Callers

nothing calls this directly

Calls 12

colorMethod · 0.80
get_work_modeMethod · 0.80
get_deviceMethod · 0.80
get_repeat_holdMethod · 0.80
sizeMethod · 0.80
signal_typeMethod · 0.80
get_colourMethod · 0.80
QRectClass · 0.70
initMethod · 0.45
enabledMethod · 0.45
get_indexMethod · 0.45
get_measureMethod · 0.45

Tested by

no test coverage detected