author | nemo |
Sun, 30 Jan 2011 17:54:02 -0500 | |
changeset 4889 | f71e30eb1d37 |
parent 4560 | 5d6c7f88db73 |
child 4976 | 088d40d8aba2 |
permissions | -rw-r--r-- |
1932 | 1 |
/* |
2 |
* Hedgewars, a free turn based strategy game |
|
3 |
* Copyright (c) 2009 Kristian Lehmann <email@thexception.net> |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*/ |
|
18 |
||
19 |
#include "togglebutton.h" |
|
20 |
||
21 |
ToggleButtonWidget::ToggleButtonWidget(QWidget * parent, QString img) |
|
4560
5d6c7f88db73
- Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents:
3061
diff
changeset
|
22 |
: QPushButton(parent) |
1932 | 23 |
{ |
3061 | 24 |
setCheckable(true); |
2377 | 25 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
26 |
QPixmap pm(":/res/btnDisabled.png"); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
27 |
QPainter * painter = new QPainter(); |
1932 | 28 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
29 |
pmChecked.load(img); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
30 |
pmDisabled.load(img); |
1932 | 31 |
|
3061 | 32 |
setMaximumWidth(pmChecked.width() + 6); |
1932 | 33 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
34 |
painter->begin(&pmDisabled); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
35 |
painter->drawPixmap(pmDisabled.rect(), pm); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
36 |
painter->end(); |
1932 | 37 |
|
3061 | 38 |
setIconSize(pmDisabled.size()); |
39 |
setIcon(pmDisabled); |
|
1932 | 40 |
|
3061 | 41 |
connect(this, SIGNAL(toggled(bool)), this, SLOT(eventToggled(bool))); |
1932 | 42 |
} |
43 |
||
44 |
ToggleButtonWidget::~ToggleButtonWidget() |
|
45 |
{ |
|
46 |
} |
|
47 |
||
48 |
void ToggleButtonWidget::eventToggled(bool checked) |
|
49 |
{ |
|
3061 | 50 |
setIcon(checked ? pmChecked : pmDisabled); |
1932 | 51 |
} |