mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33:25 -08:00
- Set the sizes the stylesheets carried with setPixelSize() rather than setPointSize(): home buttons (34), banner (24), home group box (20), the placeholder labels (14), the analytics drag handle (10), the EDHREC navigation buttons (24), the user info popup (11/14/11/10/11) and the game overlays (14/16/12). Points at 96 DPI were ~33% larger. - The drag/total counters and tally columns keep the monospace family the stylesheets set, so digit widths stop changing as counts tick and white-space: pre stays aligned. - applyDeckListFont() drops the cached tally rows before re-measuring, so previewing a larger DeckList font no longer leaves the tally clipped. - Tally labels and the constructor/fontsChanged pairs in the shared-deck preview, quick setup, analytics panel, home box and public decks build their font once in a local lambda instead of twice.
107 lines
3.6 KiB
C++
107 lines
3.6 KiB
C++
#include "quick_setup_panel.h"
|
||
|
||
#include "../theme_manager.h"
|
||
#include "color_button.h"
|
||
|
||
#include <QApplication>
|
||
#include <QFont>
|
||
#include <QHBoxLayout>
|
||
#include <QLabel>
|
||
#include <QPalette>
|
||
#include <QSlider>
|
||
#include <QString>
|
||
#include <qnamespace.h>
|
||
|
||
QuickSetupPanel::QuickSetupPanel(QWidget *parent) : QWidget(parent)
|
||
{
|
||
layout = new QHBoxLayout(this);
|
||
layout->setContentsMargins(12, 8, 12, 8);
|
||
layout->setSpacing(10);
|
||
|
||
heading = new QLabel(this);
|
||
heading->setTextFormat(Qt::RichText);
|
||
|
||
accentLabel = new QLabel(this);
|
||
accentButton = new ColorButton(this);
|
||
accentButton->setColor(QColor(20, 140, 60));
|
||
|
||
intensityLabel = new QLabel(this);
|
||
|
||
labelLow = new QLabel(this);
|
||
labelHigh = new QLabel(this);
|
||
// Family comes from the InterfaceDefault theme role; the *0.82 size stays caller-side.
|
||
auto applySmallFont = [this]() {
|
||
QFont small = themeManager->appFont(AppFont::InterfaceDefault);
|
||
small.setPointSizeF(small.pointSizeF() * 0.82);
|
||
labelLow->setFont(small);
|
||
labelHigh->setFont(small);
|
||
};
|
||
applySmallFont();
|
||
connect(themeManager, &ThemeManager::fontsChanged, this, applySmallFont);
|
||
QPalette dimmed = labelLow->palette();
|
||
dimmed.setColor(QPalette::WindowText, qApp->palette().color(QPalette::Mid));
|
||
labelLow->setPalette(dimmed);
|
||
labelHigh->setPalette(dimmed);
|
||
|
||
intensitySlider = new QSlider(Qt::Horizontal, this);
|
||
intensitySlider->setRange(0, 100);
|
||
intensitySlider->setValue(70);
|
||
intensitySlider->setFixedWidth(160);
|
||
|
||
intensityPercentageLabel = new QLabel(this);
|
||
intensityPercentageLabel->setFixedWidth(34);
|
||
intensityPercentageLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||
|
||
layout->addWidget(heading);
|
||
layout->addSpacing(6);
|
||
layout->addWidget(accentLabel);
|
||
layout->addWidget(accentButton);
|
||
layout->addSpacing(12);
|
||
layout->addWidget(intensityLabel);
|
||
layout->addWidget(labelLow);
|
||
layout->addWidget(intensitySlider);
|
||
layout->addWidget(labelHigh);
|
||
layout->addWidget(intensityPercentageLabel);
|
||
layout->addStretch();
|
||
|
||
connect(intensitySlider, &QSlider::valueChanged, this, [this](int v) {
|
||
intensityPercentageLabel->setText(tr("%1%").arg(v));
|
||
emit valueChanged(accentButton->getColor(), v);
|
||
});
|
||
connect(accentButton, &ColorButton::colorChanged, this,
|
||
[this](const QColor &c) { emit valueChanged(c, intensitySlider->value()); });
|
||
retranslateUi();
|
||
}
|
||
|
||
void QuickSetupPanel::retranslateUi()
|
||
{
|
||
heading->setText(tr("<b>Quick Setup</b>"));
|
||
heading->setToolTip(tr("Generate all palette roles automatically from a single accent colour"));
|
||
accentLabel->setText(tr("Accent:"));
|
||
accentButton->setToolTip(tr("Primary hue. Used directly for highlights and links.\n"
|
||
"At high intensity it also tints buttons and backgrounds."));
|
||
intensityLabel->setText(tr("Intensity:"));
|
||
labelLow->setText(tr("Subtle"));
|
||
labelHigh->setText(tr("Full colour"));
|
||
intensitySlider->setToolTip(tr("0–30 Subtle tint — only highlights and links change hue\n"
|
||
"30–70 Accented — buttons, tooltips, and borders join in\n"
|
||
"70–100 Full colour — backgrounds, everything"));
|
||
intensityPercentageLabel->setText(tr("70%"));
|
||
}
|
||
|
||
QColor QuickSetupPanel::accentColor() const
|
||
{
|
||
return accentButton->getColor();
|
||
}
|
||
|
||
int QuickSetupPanel::intensity() const
|
||
{
|
||
return intensitySlider->value();
|
||
}
|
||
|
||
void QuickSetupPanel::setAccentColor(const QColor &c)
|
||
{
|
||
accentButton->blockSignals(true);
|
||
accentButton->setColor(c);
|
||
accentButton->blockSignals(false);
|
||
}
|