-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathqalarmvaluebutton.cpp
53 lines (42 loc) · 1.38 KB
/
qalarmvaluebutton.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
#include "qalarmvaluebutton.h"
#include <QMaemo5Style>
#include <QStylePainter>
QAlarmValueButton::QAlarmValueButton(QWidget *parent) :
QMaemo5ValueButton(parent)
{
setValueLayout(QMaemo5ValueButton::ValueBesideText);
}
void QAlarmValueButton::paintEvent(QPaintEvent *e)
{
Q_UNUSED(e);
QStylePainter p(this);
/* Push button bevel */
QStyleOptionButton button;
initStyleOption(&button);
p.drawControl(QStyle::CE_PushButtonBevel, button);
/* Contents */
QStyleOptionMaemo5ValueButton option;
initStyleOption(&option);
option.styles = valueLayout() == ValueBesideText ?
QStyleOptionMaemo5ValueButton::ValueBesideText :
QStyleOptionMaemo5ValueButton::ValueUnderText;
option.styles |= QStyleOptionMaemo5ValueButton::PickButton;
QRect r = style()->subElementRect(QStyle::SE_PushButtonContents, &button,
this);
r.setLeft(20); /* why 20? nobody knows */
option.rect = r;
if (valueLayout() == ValueBesideText)
{
/* text */
option.value = QString();
p.drawControl(QStyle::CE_PushButtonLabel, option);
/* valueText */
r.setLeft(170);
option.rect = r;
option.value = valueText();
option.text = QString();
}
else
option.value = valueText();
p.drawControl(QStyle::CE_PushButtonLabel, option);
}