forked from PavelMr/skytechx
/
ctristatebutton.cpp
59 lines (46 loc) · 1.44 KB
/
ctristatebutton.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
#include "ctristatebutton.h"
///////////////////////////////////////////////////
CTriStateButton::CTriStateButton(QWidget *parent) :
QToolButton(parent)
///////////////////////////////////////////////////
{
m_state = 0;
connect(this, SIGNAL(clicked()), this, SLOT(slotClicked()));
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CTriStateButton::setText(const QString s1, const QPixmap p1, const QString s2, const QPixmap p2, const QString s3, const QPixmap p3)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
{
str[0] = s1;
str[1] = s2;
str[2] = s3;
pix[0] = p1;
pix[1] = p2;
pix[2] = p3;
QToolButton::setText(str[m_state]);
QToolButton::setIcon(pix[m_state]);
}
/////////////////////////////////////////
void CTriStateButton::setState(int state)
/////////////////////////////////////////
{
m_state = state;
QToolButton::setText(str[m_state]);
QToolButton::setIcon(pix[m_state]);
}
///////////////////////////////
int CTriStateButton::getState()
///////////////////////////////
{
return(m_state);
}
///////////////////////////////////
void CTriStateButton::slotClicked()
///////////////////////////////////
{
if (++m_state >= 3)
m_state = 0;
QToolButton::setText(str[m_state]);
QToolButton::setIcon(pix[m_state]);
emit sigClicked();
}