-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlcdentry.cpp
63 lines (57 loc) · 1.31 KB
/
lcdentry.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "lcdentry.h"
LCDEntry::LCDEntry(int size, int num)
:original(0,0,0)
{
this->size = size;
int length = QString::number(size).length();
display(num);
setSegmentStyle(QLCDNumber::Flat);
setNumDigits(length);
}
void LCDEntry::display(int num)
{
this->num = num;
this->QLCDNumber::display(num);
if(num!=0)
locked = true;
else
locked = false;
}
void LCDEntry::lockedDisplay(int num)
{
if(locked)
return;
this->num = num;
this->QLCDNumber::display(num);
}
void LCDEntry::mouseDoubleClickEvent(QMouseEvent *)
{
emit doubleclickedevent();
}
void LCDEntry::wheelEvent(QWheelEvent* event)
{
if(locked)
return;
int move = event->delta();
move = (move>0)?1:-1;
int value = intValue();
if(value+move>size)
lockedDisplay(0);
else if(value+move<0)
lockedDisplay(size);
else
lockedDisplay(value+move);
}
void LCDEntry::enterEvent(QEvent*)
{
QPalette p = this->palette();
original = p.color(QPalette::WindowText);
p.setColor(QPalette::WindowText, QColor(255,0,0));
setPalette(p);
}
void LCDEntry::leaveEvent(QEvent*)
{
QPalette p = this->palette();
p.setColor(QPalette::WindowText, original);
setPalette(p);
}