-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuttonstate.h
39 lines (28 loc) · 968 Bytes
/
buttonstate.h
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
#ifndef BUTTONSTATE_H
#define BUTTONSTATE_H
//#include <QObject>
#include <QMetaType>
#include <QPainter>
#include <QIcon>
class ButtonState //: public QObject
{
//Q_OBJECT
public:
enum EditMode { Editable, ReadOnly };
ButtonState();
ButtonState(QString iconName);
ButtonState(QString iconName, QString icondisabled);
ButtonState(QString iconnormal, QString iconactive, QString icondisabled, QString iconselected);
void paint(QPainter *painter, const QRect &rect,
const QPalette &palette, EditMode mode) const;
QIcon::Mode IconMode() const { return icomode; }
void setIconMode( QIcon::Mode newMode ) { if (newMode == QIcon::Disabled) { oldmode = icomode; } icomode = newMode; }
void restore() { icomode = oldmode; }
QSize sizeHint() const { return QSize(16, 16); }
private:
QIcon ico;
QIcon::Mode icomode;
QIcon::Mode oldmode;
};
Q_DECLARE_METATYPE(ButtonState)
#endif // BUTTONSTATE_H