From d24f813f3f2a05c112e803e4256b53535895fc98 Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Wed, 14 Jul 2021 11:49:10 +1200 Subject: Initial mirror commit --- src/study/NumberFrame.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/study/NumberFrame.cpp (limited to 'src/study/NumberFrame.cpp') diff --git a/src/study/NumberFrame.cpp b/src/study/NumberFrame.cpp new file mode 100644 index 0000000..1d2a2e1 --- /dev/null +++ b/src/study/NumberFrame.cpp @@ -0,0 +1,40 @@ +#include "NumberFrame.h" + +NumberFrame::NumberFrame(QWidget* parent): + QLabel(parent) +{ + init(); +} + +void NumberFrame::init() +{ + setMinimumSize(MinWidth, MinHeight); + setAlignment(Qt::AlignCenter); + setFrameShape(QFrame::NoFrame); +} + +void NumberFrame::setColor(const QColor& color) +{ + setPalette(QPalette(color)); +} + +void NumberFrame::setValue(int value) +{ + setMinimumWidth(value >= 100? MinWidth100: MinWidth); + setVisible(value > 0); + setText(QString::number(value)); +} + +void NumberFrame::paintEvent(QPaintEvent* event) +{ + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing); + + QPen pen("#7c7c7c"); + pen.setWidthF(0.5); + painter.setPen(pen); + painter.setBrush(QBrush(palette().color(QPalette::Button))); + painter.drawRoundedRect(rect().adjusted(1, 1, -1, -1), Radius, Radius); + + QLabel::paintEvent(event); +} -- cgit