MCPcopy Create free account
hub / github.com/aethersdr/AetherSDR / paintEvent

Method paintEvent

src/gui/KeyboardMapWidget.cpp:224–316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222// ─── Painting ───────────────────────────────────────────────────────────────
223
224void KeyboardMapWidget::paintEvent(QPaintEvent*)
225{
226 QPainter p(this);
227 p.setRenderHint(QPainter::Antialiasing);
228 p.fillRect(rect(), AetherSDR::ThemeManager::instance().color("color.background.0"));
229
230 // Compute key unit size to fit the layout (23 key units wide for main + numpad)
231 constexpr float totalKeysW = 23.5f;
232 constexpr float totalKeysH = 6.5f;
233 constexpr float gap = 0.08f;
234
235 float availW = width() - 20;
236 float availH = height() - 20;
237 float unitFromW = availW / (totalKeysW * (1 + gap));
238 float unitFromH = availH / (totalKeysH * (1 + gap));
239 m_keyUnit = std::min(unitFromW, unitFromH);
240 m_originX = 10;
241 m_originY = 10;
242
243 QFont keyFont;
244 keyFont.setPixelSize(std::max(8, static_cast<int>(m_keyUnit * 0.28f)));
245 keyFont.setBold(true);
246
247 QFont actionFont;
248 actionFont.setPixelSize(std::max(6, static_cast<int>(m_keyUnit * 0.18f)));
249
250 for (int i = 0; i < m_keys.size(); ++i) {
251 const auto& k = m_keys[i];
252 QRectF r = keyRect(k);
253
254 // Look up bound action
255 QKeySequence seq(k.qtKey);
256 const auto* act = m_mgr->actionForKey(seq);
257
258 // Determine colors
259 QColor fill = kUnboundFill();
260 QColor border = kUnboundBorder();
261 if (act) {
262 fill = categoryColor(act->category);
263 border = fill.lighter(140);
264 }
265
266 // Hover highlight
267 if (i == m_hoverIdx) {
268 fill = fill.lighter(130);
269 border = border.lighter(130);
270 }
271
272 // Selected highlight
273 if (i == m_selectedIdx) {
274 border = AetherSDR::ThemeManager::instance().color("color.accent");
275 fill = fill.lighter(150);
276 }
277
278 // Keyboard focus ring (shown when widget has focus)
279 if (i == m_focusIdx && hasFocus()) {
280 border = QColor(0xff, 0xff, 0x00); // yellow focus ring
281 }

Callers

nothing calls this directly

Calls 7

kUnboundFillFunction · 0.85
kUnboundBorderFunction · 0.85
actionForKeyMethod · 0.80
drawTextMethod · 0.80
colorMethod · 0.45
sizeMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected