Commit 85d1c688 authored by Niklas Freund's avatar Niklas Freund Committed by Albert Astals Cid
Browse files

Moved BitButton::paintEvent from kcalc_bitset.cpp to bitbutton.cpp

parent 3f2dfcd2
Pipeline #98136 passed with stage
in 35 seconds
......@@ -7,6 +7,7 @@
#include "bitbutton.h"
#include <QApplication>
#include <QPainter>
//------------------------------------------------------------------------------
// Name: BitButton
......@@ -32,6 +33,33 @@ BitButton::BitButton(QWidget *parent)
this->setAttribute(Qt::WA_Hover, true);
}
//------------------------------------------------------------------------------
// Name: paintEvent
// Desc: draws the button
//------------------------------------------------------------------------------
void BitButton::paintEvent(QPaintEvent *)
{
uint8_t alpha = 0x60;
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing, true);
QPen pen(palette().text(), 1);
pen.setJoinStyle(Qt::MiterJoin);
painter.setPen(pen);
if (on_) {
painter.setBrush(palette().text());
alpha = 0xB0;
} else {
painter.setBrush(palette().base());
}
if (over_) {
painter.setBrush(QColor(palette().text().color().red(), palette().text().color().green(), palette().text().color().blue(), alpha));
}
painter.drawRect(rect().adjusted(1, 1, -1, -1));
}
//------------------------------------------------------------------------------
// Name: isOn
// Desc: returns true if this bit-button is "on"
......
......@@ -13,39 +13,11 @@
#include <QGridLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QPainter>
// TODO: I think it would actually be appropriate to use a std::bitset<64>
// for the internal representation of this class perhaps
// the only real caveat is the conversion to/from quint64
//------------------------------------------------------------------------------
// Name: paintEvent
// Desc: draws the button
//------------------------------------------------------------------------------
void BitButton::paintEvent(QPaintEvent *)
{
uint8_t alpha = 0x60;
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing, true);
QPen pen(palette().text(), 1);
pen.setJoinStyle(Qt::MiterJoin);
painter.setPen(pen);
if (on_) {
painter.setBrush(palette().text());
alpha = 0xB0;
} else {
painter.setBrush(palette().base());
}
if (over_) {
painter.setBrush(QColor(palette().text().color().red(), palette().text().color().green(), palette().text().color().blue(), alpha));
}
painter.drawRect(rect().adjusted(1, 1, -1, -1));
}
//------------------------------------------------------------------------------
// Name: KCalcBitset
// Desc: constructor
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment