Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
KCalc
Commits
85d1c688
Commit
85d1c688
authored
Nov 06, 2021
by
Niklas Freund
Committed by
Albert Astals Cid
Nov 16, 2021
Browse files
Moved BitButton::paintEvent from kcalc_bitset.cpp to bitbutton.cpp
parent
3f2dfcd2
Pipeline
#98136
passed with stage
in 35 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
bitbutton.cpp
View file @
85d1c688
...
...
@@ -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"
...
...
kcalc_bitset.cpp
View file @
85d1c688
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment