2
* Hedgewars, a free turn based strategy game
3
* Copyright (c) 2006-2011 Andrey Korotaev <unC0Rr@gmail.com>
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
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.
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
19
#include <QGridLayout>
20
#include <QPushButton>
21
#include <QFileDialog>
23
#include "pagedrawmap.h"
24
#include "drawmapwidget.h"
26
PageDrawMap::PageDrawMap(QWidget* parent) : AbstractPage(parent)
28
QGridLayout * pageLayout = new QGridLayout(this);
30
QPushButton * pbUndo = addButton(tr("Undo"), pageLayout, 0, 0);
31
QPushButton * pbClear = addButton(tr("Clear"), pageLayout, 1, 0);
32
QPushButton * pbLoad = addButton(tr("Load"), pageLayout, 2, 0);
33
QPushButton * pbSave = addButton(tr("Save"), pageLayout, 3, 0);
35
BtnBack = addButton(":/res/Exit.png", pageLayout, 5, 0, true);
37
drawMapWidget = new DrawMapWidget(this);
38
pageLayout->addWidget(drawMapWidget, 0, 1, 5, 1);
40
connect(pbUndo, SIGNAL(clicked()), drawMapWidget, SLOT(undo()));
41
connect(pbClear, SIGNAL(clicked()), drawMapWidget, SLOT(clear()));
42
connect(pbLoad, SIGNAL(clicked()), this, SLOT(load()));
43
connect(pbSave, SIGNAL(clicked()), this, SLOT(save()));
46
void PageDrawMap::load()
48
QString fileName = QFileDialog::getOpenFileName(NULL, tr("Load drawn map"), ".", tr("Drawn Maps") + " (*.hwmap);;" + tr("All files") + " (*)");
50
if(!fileName.isEmpty())
51
drawMapWidget->load(fileName);
54
void PageDrawMap::save()
56
QString fileName = QFileDialog::getSaveFileName(NULL, tr("Save drawn map"), ".", tr("Drawn Maps") + " (*.hwmap);;" + tr("All files") + " (*)");
58
if(!fileName.isEmpty())
59
drawMapWidget->save(fileName);