QTfrontend/pagedrawmap.cpp
changeset 5078 3527f0e7bb21
child 5204 e1a5f4d5d86a
equal deleted inserted replaced
5076:b3bb27f4ba6b 5078:3527f0e7bb21
       
     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 "pages.h"
       
    24 #include "drawmapwidget.h"
       
    25 
       
    26 PageDrawMap::PageDrawMap(QWidget* parent) : AbstractPage(parent)
       
    27 {
       
    28     QGridLayout * pageLayout = new QGridLayout(this);
       
    29 
       
    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);
       
    34 
       
    35     BtnBack = addButton(":/res/Exit.png", pageLayout, 5, 0, true);
       
    36 
       
    37     drawMapWidget = new DrawMapWidget(this);
       
    38     pageLayout->addWidget(drawMapWidget, 0, 1, 5, 1);
       
    39 
       
    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()));
       
    44 }
       
    45 
       
    46 void PageDrawMap::load()
       
    47 {
       
    48     QString fileName = QFileDialog::getOpenFileName(this, tr("Load drawn map"), ".", tr("Drawn Maps (*.hwmap);;All files (*.*)"));
       
    49 
       
    50     if(!fileName.isEmpty())
       
    51         drawMapWidget->load(fileName);
       
    52 }
       
    53 
       
    54 void PageDrawMap::save()
       
    55 {
       
    56     QString fileName = QFileDialog::getSaveFileName(this, tr("Save drawn map"), ".", tr("Drawn Maps (*.hwmap);;All files (*.*)"));
       
    57 
       
    58     if(!fileName.isEmpty())
       
    59         drawMapWidget->save(fileName);
       
    60 }