|
1 /* |
|
2 * Hedgewars, a free turn based strategy game |
|
3 * Copyright (c) 2006-2011 Andrey Korotaev <unC0Rr@gmail.com> |
|
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 <QGridLayout> |
|
20 #include <QPushButton> |
|
21 #include <QFileDialog> |
|
22 |
|
23 #include "pagedrawmap.h" |
|
24 #include "drawmapwidget.h" |
|
25 |
|
26 |
|
27 QLayout * PageDrawMap::bodyLayoutDefinition() |
|
28 { |
|
29 QGridLayout * pageLayout = new QGridLayout(); |
|
30 |
|
31 pbUndo = addButton(tr("Undo"), pageLayout, 0, 0); |
|
32 pbClear = addButton(tr("Clear"), pageLayout, 1, 0); |
|
33 pbLoad = addButton(tr("Load"), pageLayout, 2, 0); |
|
34 pbSave = addButton(tr("Save"), pageLayout, 3, 0); |
|
35 |
|
36 drawMapWidget = new DrawMapWidget(this); |
|
37 pageLayout->addWidget(drawMapWidget, 0, 1, 5, 1); |
|
38 |
|
39 return pageLayout; |
|
40 } |
|
41 |
|
42 void PageDrawMap::connectSignals() |
|
43 { |
|
44 connect(pbUndo, SIGNAL(clicked()), drawMapWidget, SLOT(undo())); |
|
45 connect(pbClear, SIGNAL(clicked()), drawMapWidget, SLOT(clear())); |
|
46 connect(pbLoad, SIGNAL(clicked()), this, SLOT(load())); |
|
47 connect(pbSave, SIGNAL(clicked()), this, SLOT(save())); |
|
48 } |
|
49 |
|
50 PageDrawMap::PageDrawMap(QWidget* parent) : AbstractPage(parent) |
|
51 { |
|
52 initPage(); |
|
53 } |
|
54 |
|
55 void PageDrawMap::load() |
|
56 { |
|
57 QString fileName = QFileDialog::getOpenFileName(NULL, tr("Load drawn map"), ".", tr("Drawn Maps") + " (*.hwmap);;" + tr("All files") + " (*)"); |
|
58 |
|
59 if(!fileName.isEmpty()) |
|
60 drawMapWidget->load(fileName); |
|
61 } |
|
62 |
|
63 void PageDrawMap::save() |
|
64 { |
|
65 QString fileName = QFileDialog::getSaveFileName(NULL, tr("Save drawn map"), ".", tr("Drawn Maps") + " (*.hwmap);;" + tr("All files") + " (*)"); |
|
66 |
|
67 if(!fileName.isEmpty()) |
|
68 drawMapWidget->save(fileName); |
|
69 } |