From 042e879f43d81025750d18851eaf8c54b203feab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Sun, 17 May 2026 09:12:17 +0200 Subject: [PATCH] Longer variable names. Took 10 minutes Took 5 seconds --- .../interface/palette_editor/color_button.cpp | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/cockatrice/src/interface/palette_editor/color_button.cpp b/cockatrice/src/interface/palette_editor/color_button.cpp index a0ca72f3b..e1a490d20 100644 --- a/cockatrice/src/interface/palette_editor/color_button.cpp +++ b/cockatrice/src/interface/palette_editor/color_button.cpp @@ -31,41 +31,42 @@ void ColorButton::pickColor() void ColorButton::updateSwatch() { - QPixmap pm(size() * devicePixelRatioF()); - pm.setDevicePixelRatio(devicePixelRatioF()); - pm.fill(Qt::transparent); - QPainter p(&pm); - p.setRenderHint(QPainter::Antialiasing); + QPixmap pixmap(size() * devicePixelRatioF()); + pixmap.setDevicePixelRatio(devicePixelRatioF()); + pixmap.fill(Qt::transparent); + QPainter painter(&pixmap); + painter.setRenderHint(QPainter::Antialiasing); // Checkerboard for alpha - const int cs = 4; - for (int y = 0; y < height(); y += cs) { - for (int x = 0; x < width(); x += cs) { - p.fillRect(x, y, cs, cs, ((x / cs + y / cs) % 2) ? QColor(180, 180, 180) : Qt::white); + const int cellSize = 4; + for (int y = 0; y < height(); y += cellSize) { + for (int x = 0; x < width(); x += cellSize) { + painter.fillRect(x, y, cellSize, cellSize, + ((x / cellSize + y / cellSize) % 2) ? QColor(180, 180, 180) : Qt::white); } } // Color fill - p.setPen(Qt::NoPen); - p.setBrush(color); - p.drawRoundedRect(QRectF(0.5, 0.5, width() - 1, height() - 1), 3, 3); + painter.setPen(Qt::NoPen); + painter.setBrush(color); + painter.drawRoundedRect(QRectF(0.5, 0.5, width() - 1, height() - 1), 3, 3); // Border QColor border = palette().color(QPalette::Shadow); border.setAlpha(180); - p.setPen(QPen(border, 1)); - p.setBrush(Qt::NoBrush); - p.drawRoundedRect(QRectF(0.5, 0.5, width() - 1, height() - 1), 3, 3); + painter.setPen(QPen(border, 1)); + painter.setBrush(Qt::NoBrush); + painter.drawRoundedRect(QRectF(0.5, 0.5, width() - 1, height() - 1), 3, 3); // Hex label — black or white for contrast int luma = 0.299 * color.red() + 0.587 * color.green() + 0.114 * color.blue(); - p.setPen((luma > 128 && color.alpha() > 80) ? QColor(0, 0, 0, 180) : QColor(255, 255, 255, 200)); + painter.setPen((luma > 128 && color.alpha() > 80) ? QColor(0, 0, 0, 180) : QColor(255, 255, 255, 200)); QFont f = font(); f.setPixelSize(8); - p.setFont(f); - p.drawText(rect(), Qt::AlignCenter, color.name().toUpper()); + painter.setFont(f); + painter.drawText(rect(), Qt::AlignCenter, color.name().toUpper()); - setIcon(QIcon(pm)); + setIcon(QIcon(pixmap)); setIconSize(size()); setText({}); } \ No newline at end of file