give the selection cards their own parts instead of label blobs

This commit is contained in:
2026-08-07 18:43:23 +02:00
parent 2289277e12
commit 075e44d295
54 changed files with 1505 additions and 533 deletions

View File

@@ -0,0 +1,54 @@
#include "StatRow.h"
#include <QHBoxLayout>
#include <QLabel>
#include <QPalette>
namespace
{
// Left inset of an indented row, in device-independent pixels.
const int kIndentPx = 12;
} // namespace
StatRow::StatRow(const QString& label, QWidget* parent)
: QWidget(parent)
{
QHBoxLayout* layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(8);
m_labelLabel = new QLabel(label, this);
m_valueLabel = new QLabel(this);
m_valueLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
layout->addWidget(m_labelLabel);
layout->addStretch(1);
layout->addWidget(m_valueLabel);
}
void StatRow::setLabel(const QString& label)
{
m_labelLabel->setText(label);
}
void StatRow::setValue(const QString& value)
{
m_valueLabel->setText(value);
}
void StatRow::setValueEmphasized(bool emphasized)
{
QPalette valuePalette = m_valueLabel->palette();
valuePalette.setColor(QPalette::WindowText,
palette().color(emphasized ? QPalette::Highlight
: QPalette::WindowText));
m_valueLabel->setPalette(valuePalette);
}
void StatRow::setIndented(bool indented)
{
layout()->setContentsMargins(indented ? kIndentPx : 0, 0, 0, 0);
}