give the selection cards their own parts instead of label blobs
This commit is contained in:
54
src/ui/selection/StatRow.cpp
Normal file
54
src/ui/selection/StatRow.cpp
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user