leocad/common/lc_keyframewidget.cpp

39 lines
956 B
C++
Raw Normal View History

2024-01-15 02:41:01 +01:00
#include "lc_global.h"
#include "lc_keyframewidget.h"
lcKeyFrameWidget::lcKeyFrameWidget(QWidget* Parent)
2024-01-21 21:53:18 +01:00
: QCheckBox(Parent)
2024-01-15 02:41:01 +01:00
{
2024-01-15 03:46:07 +01:00
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
setCheckable(true);
}
void lcKeyFrameWidget::paintEvent(QPaintEvent* PaintEvent)
{
Q_UNUSED(PaintEvent);
QPainter Painter(this);
QRect Rect = rect();
Painter.fillRect(Rect, palette().brush(QPalette::Window));
2024-01-21 21:53:18 +01:00
Qt::CheckState State = checkState();
2024-01-15 03:46:07 +01:00
Painter.setPen(hasFocus() ? palette().color(QPalette::Highlight) : palette().color(QPalette::Shadow));
2024-01-21 21:53:18 +01:00
if (State != Qt::PartiallyChecked)
Painter.setBrush(palette().color(QPalette::Text));
Rect = (State != Qt::Unchecked) ? QRect(1, 1, 13, 13) : QRect(4, 4, 7, 7);
const QPoint Center = Rect.center();
2024-01-15 03:46:07 +01:00
QPoint Points[4] =
{
QPoint(Rect.left(), Center.y()),
QPoint(Center.x(), Rect.bottom()),
QPoint(Rect.right(), Center.y()),
QPoint(Center.x(), Rect.top())
};
Painter.drawPolygon(Points, 4);
2024-01-15 02:41:01 +01:00
}