55 QPainter painter(
this);
56 painter.setRenderHint(QPainter::Antialiasing);
62 overlayColor.setAlpha(220);
63 painter.fillRect(rect(), overlayColor);
67 QStringList categories = mgr.getCategories();
75 std::map<QString, std::vector<Entry>> grouped;
76 for (
const auto& cat : categories)
78 auto actions = mgr.getActionsByCategory(cat);
79 for (
const auto& action : actions)
81 if (action.currentShortcut.isEmpty())
83 grouped[cat].push_back(
84 {action.currentShortcut.toString(QKeySequence::NativeText), action.label});
89 int columnCount = qMin(
static_cast<int>(grouped.size()), 3);
95 int contentWidth = width() - padding * 2;
96 int columnWidth = (contentWidth - columnGap * (columnCount - 1)) / columnCount;
100 titleFont.setPointSize(themeManager_->scaledFontSize(18));
101 titleFont.setBold(
true);
102 painter.setFont(titleFont);
105 QString title =
"Keyboard Shortcuts";
106 QRect titleRect(0, padding, width(), 40);
107 painter.drawText(titleRect, Qt::AlignHCenter | Qt::AlignVCenter, title);
111 subtitleFont.setPointSize(themeManager_->scaledFontSize(10));
112 painter.setFont(subtitleFont);
114 QRect subtitleRect(0, padding + 40, width(), 20);
115 painter.drawText(subtitleRect, Qt::AlignHCenter | Qt::AlignVCenter,
116 "Press any key or click to dismiss");
120 categoryFont.setPointSize(themeManager_->scaledFontSize(12));
121 categoryFont.setBold(
true);
124 shortcutFont.setPointSize(themeManager_->scaledFontSize(10));
125 shortcutFont.setBold(
true);
128 labelFont.setPointSize(themeManager_->scaledFontSize(10));
130 int startY = padding + 80;
133 for (
const auto& cat : categories)
135 auto it = grouped.find(cat);
136 if (it == grouped.end() || it->second.empty())
139 int x = padding + col * (columnWidth + columnGap);
143 painter.setFont(categoryFont);
145 painter.drawText(x, y, columnWidth, 24, Qt::AlignLeft | Qt::AlignVCenter, cat);
149 painter.setPen(QPen(c.
border, 1));
150 painter.drawLine(x, y, x + columnWidth, y);
154 for (
const auto& entry : it->second)
157 painter.setFont(shortcutFont);
158 QFontMetrics sfm(shortcutFont);
159 int badgeWidth = sfm.horizontalAdvance(entry.shortcut) + 16;
160 int badgeHeight = 24;
162 QRect badgeRect(x, y, badgeWidth, badgeHeight);
163 QPainterPath badgePath;
164 badgePath.addRoundedRect(badgeRect, 4, 4);
165 painter.setPen(Qt::NoPen);
167 painter.drawPath(badgePath);
170 painter.drawText(badgeRect, Qt::AlignCenter, entry.shortcut);
173 painter.setFont(labelFont);
175 int labelX = x + badgeWidth + 12;
176 painter.drawText(labelX, y, columnWidth - badgeWidth - 12, badgeHeight,
177 Qt::AlignLeft | Qt::AlignVCenter, entry.label);
179 y += badgeHeight + 8;
183 if (col >= columnCount)