diff options
Diffstat (limited to 'src/study/NumberFrame.cpp')
-rw-r--r-- | src/study/NumberFrame.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
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);
+}
|