mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-07 18:43:26 -08:00
[Fonts] Migrate DeckList and InterfaceDefault surfaces to theme roles
This commit is contained in:
parent
a7e151d871
commit
d26a7b213f
44 changed files with 391 additions and 74 deletions
|
|
@ -1,5 +1,7 @@
|
|||
#include "color_button.h"
|
||||
|
||||
#include "../theme_manager.h"
|
||||
|
||||
#include <QBrush>
|
||||
#include <QColorDialog>
|
||||
#include <QFont>
|
||||
|
|
@ -21,6 +23,7 @@ ColorButton::ColorButton(QWidget *parent) : QToolButton(parent)
|
|||
setCursor(Qt::PointingHandCursor);
|
||||
setToolTip(tr("Click to pick a color"));
|
||||
connect(this, &QToolButton::clicked, this, &ColorButton::pickColor);
|
||||
connect(themeManager, &ThemeManager::fontsChanged, this, &ColorButton::updateSwatch);
|
||||
}
|
||||
|
||||
void ColorButton::setColor(const QColor &c)
|
||||
|
|
@ -73,7 +76,8 @@ void ColorButton::updateSwatch()
|
|||
// Hex label — black or white for contrast
|
||||
int luma = 0.299 * color.red() + 0.587 * color.green() + 0.114 * color.blue();
|
||||
painter.setPen((luma > 128 && color.alpha() > 80) ? QColor(0, 0, 0, 180) : QColor(255, 255, 255, 200));
|
||||
QFont f = font();
|
||||
// Family comes from the InterfaceDefault theme role; the 8px size stays caller-side.
|
||||
QFont f = themeManager->appFont(AppFont::InterfaceDefault);
|
||||
f.setPixelSize(8);
|
||||
painter.setFont(f);
|
||||
painter.drawText(rect(), Qt::AlignCenter, color.name().toUpper());
|
||||
|
|
|
|||
|
|
@ -76,6 +76,18 @@ PaletteGridWidget::PaletteGridWidget(QWidget *parent) : QWidget(parent)
|
|||
|
||||
layout = QtUtils::makeLayout<QVBoxLayout>(this);
|
||||
layout->addWidget(scroll);
|
||||
|
||||
connect(themeManager, &ThemeManager::fontsChanged, this, &PaletteGridWidget::applyInterfaceDefaultFont);
|
||||
}
|
||||
|
||||
void PaletteGridWidget::applyInterfaceDefaultFont()
|
||||
{
|
||||
// The editor's own chrome follows the InterfaceDefault theme role; bold stays caller-side.
|
||||
for (auto *label : headerLabels) {
|
||||
QFont headerFont = themeManager->appFont(AppFont::InterfaceDefault);
|
||||
headerFont.setBold(true);
|
||||
label->setFont(headerFont);
|
||||
}
|
||||
}
|
||||
|
||||
void PaletteGridWidget::buildGrid(QWidget *host)
|
||||
|
|
@ -101,7 +113,8 @@ void PaletteGridWidget::buildGrid(QWidget *host)
|
|||
auto *label = new QLabel(groupHeaders[col], host);
|
||||
label->setAlignment(Qt::AlignCenter);
|
||||
label->setToolTip(groupTips[col]);
|
||||
label->setFont(QtUtils::boldFont(label->font()));
|
||||
// Family comes from the InterfaceDefault theme role; bold stays caller-side.
|
||||
label->setFont(QtUtils::boldFont(themeManager->appFont(AppFont::InterfaceDefault)));
|
||||
label->setAutoFillBackground(true);
|
||||
label->setContentsMargins(4, 4, 4, 4);
|
||||
grid->addWidget(label, 0, col + 1);
|
||||
|
|
@ -146,7 +159,7 @@ void PaletteGridWidget::buildGrid(QWidget *host)
|
|||
|
||||
auto *appHeader = new QLabel(tr("App colors"), host);
|
||||
appHeader->setToolTip(tr("Application-specific colors layered on top of the Qt palette"));
|
||||
appHeader->setFont(QtUtils::boldFont(appHeader->font()));
|
||||
appHeader->setFont(QtUtils::boldFont(themeManager->appFont(AppFont::InterfaceDefault)));
|
||||
appHeader->setAutoFillBackground(true);
|
||||
appHeader->setContentsMargins(4, 4, 4, 4);
|
||||
grid->addWidget(appHeader, appHeaderRow, 0, 1, 4);
|
||||
|
|
|
|||
|
|
@ -34,6 +34,10 @@ private:
|
|||
void changeEvent(QEvent *e);
|
||||
void refreshChromePalettes();
|
||||
|
||||
private slots:
|
||||
void applyInterfaceDefaultFont();
|
||||
|
||||
private:
|
||||
QMap<QPalette::ColorGroup, QMap<QPalette::ColorRole, ColorButton *>> colorButtons;
|
||||
QMap<AppColor::Role, ColorButton *> appColorButtons;
|
||||
QScrollArea *scroll;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "quick_setup_panel.h"
|
||||
|
||||
#include "../theme_manager.h"
|
||||
#include "color_button.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
|
@ -28,10 +29,17 @@ QuickSetupPanel::QuickSetupPanel(QWidget *parent) : QWidget(parent)
|
|||
|
||||
labelLow = new QLabel(this);
|
||||
labelHigh = new QLabel(this);
|
||||
QFont small = labelLow->font();
|
||||
// Family comes from the InterfaceDefault theme role; the *0.82 size stays caller-side.
|
||||
QFont small = themeManager->appFont(AppFont::InterfaceDefault);
|
||||
small.setPointSizeF(small.pointSizeF() * 0.82);
|
||||
labelLow->setFont(small);
|
||||
labelHigh->setFont(small);
|
||||
connect(themeManager, &ThemeManager::fontsChanged, this, [this]() {
|
||||
QFont refreshedSmall = themeManager->appFont(AppFont::InterfaceDefault);
|
||||
refreshedSmall.setPointSizeF(refreshedSmall.pointSizeF() * 0.82);
|
||||
labelLow->setFont(refreshedSmall);
|
||||
labelHigh->setFont(refreshedSmall);
|
||||
});
|
||||
QPalette dimmed = labelLow->palette();
|
||||
dimmed.setColor(QPalette::WindowText, qApp->palette().color(QPalette::Mid));
|
||||
labelLow->setPalette(dimmed);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue