]> git.sur5r.net Git - minitube/blob - src/thlibrary/thaction.cpp
Initial import
[minitube] / src / thlibrary / thaction.cpp
1 #include "thaction.h"
2
3 /* ============================================================================
4  *  PRIVATE Class
5  */
6 class THAction::Private {
7         public:
8                 bool isHovered;
9                 bool isChecked;
10                 QString text;
11                 QIcon icon;
12 };
13
14 /* ============================================================================
15  *  PUBLIC Constructor/Destructors
16  */
17 THAction::THAction (QObject *parent)
18         : QObject(parent), d(new THAction::Private)
19 {
20         d->isHovered = false;
21         d->isChecked = false;
22 }
23
24 THAction::THAction (const QString& text, QObject *parent) 
25         : QObject(parent), d(new THAction::Private)
26 {
27         d->isHovered = false;
28         d->isChecked = false;
29         d->text = text;
30 }
31
32 THAction::THAction (const QIcon& icon, const QString& text, QObject *parent)
33         : QObject(parent), d(new THAction::Private)
34 {
35         d->isHovered = false;
36         d->isChecked = false;
37         d->icon = icon;
38         d->text = text;
39 }
40
41 THAction::~THAction() {
42         delete d;
43 }
44
45 /* ============================================================================
46  *  PUBLIC Properties
47  */
48 bool THAction::isChecked (void) const {
49         return(d->isChecked);
50 }
51
52 bool THAction::isHovered (void) const {
53         return(d->isHovered);
54 }
55
56 QIcon THAction::icon (void) const {
57         return(d->icon);
58 }
59
60 void THAction::setIcon (const QIcon& icon) {
61         d->icon = icon;
62 }
63
64
65 QString THAction::text (void) const {
66         return(d->text);
67 }
68
69 void THAction::setText (const QString& text) {
70         d->text = text;
71 }
72
73 /* ============================================================================
74  *  PUBLIC SLOTS
75  */
76 void THAction::hover (bool isHovered) {
77         d->isHovered = isHovered;
78         if (d->isHovered) emit hovered();
79 }
80
81 void THAction::toggle (void) {
82         emit toggled(d->isChecked);
83 }
84
85 void THAction::trigger (void) {
86         emit triggered(d->isChecked);
87 }
88
89 void THAction::setChecked (bool checked) {
90         d->isChecked = checked;
91 }