author | nemo |
Fri, 25 Sep 2015 23:31:16 -0400 | |
changeset 11193 | 283b6e6cf7ea |
parent 11046 | 47a8c19ecb60 |
child 13159 | 6f189da00c25 |
permissions | -rw-r--r-- |
1932 | 1 |
/* |
2 |
* Hedgewars, a free turn based strategy game |
|
3 |
* Copyright (c) 2009 Kristian Lehmann <email@thexception.net> |
|
11046 | 4 |
* Copyright (c) 2004-2015 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 |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
9998
diff
changeset
|
17 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
1932 | 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 |
} |