author | Xeli |
Thu, 14 Jul 2011 16:03:29 +0200 | |
branch | hedgeroid |
changeset 5442 | 7c1e5a5f7f34 |
parent 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> |
|
4976 | 4 |
* Copyright (c) 2009-2011 Andrey Korotaev <unC0Rr@gmail.com> |
1932 | 5 |
* |
6 |
* This program is free software; you can redistribute it and/or modify |
|
7 |
* it under the terms of the GNU General Public License as published by |
|
8 |
* the Free Software Foundation; version 2 of the License |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
18 |
*/ |
|
19 |
||
20 |
#include "togglebutton.h" |
|
21 |
||
22 |
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
|
23 |
: QPushButton(parent) |
1932 | 24 |
{ |
3061 | 25 |
setCheckable(true); |
2377 | 26 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
27 |
QPixmap pm(":/res/btnDisabled.png"); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
28 |
QPainter * painter = new QPainter(); |
1932 | 29 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
30 |
pmChecked.load(img); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
31 |
pmDisabled.load(img); |
1932 | 32 |
|
3061 | 33 |
setMaximumWidth(pmChecked.width() + 6); |
1932 | 34 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
35 |
painter->begin(&pmDisabled); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
36 |
painter->drawPixmap(pmDisabled.rect(), pm); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
37 |
painter->end(); |
1932 | 38 |
|
3061 | 39 |
setIconSize(pmDisabled.size()); |
40 |
setIcon(pmDisabled); |
|
1932 | 41 |
|
3061 | 42 |
connect(this, SIGNAL(toggled(bool)), this, SLOT(eventToggled(bool))); |
1932 | 43 |
} |
44 |
||
45 |
ToggleButtonWidget::~ToggleButtonWidget() |
|
46 |
{ |
|
47 |
} |
|
48 |
||
49 |
void ToggleButtonWidget::eventToggled(bool checked) |
|
50 |
{ |
|
3061 | 51 |
setIcon(checked ? pmChecked : pmDisabled); |
1932 | 52 |
} |