QTfrontend/pagedrawmap.cpp
branchhedgeroid
changeset 6224 42b256eca362
parent 6055 88cfcd9161d3
parent 6223 cc3eb9b7230f
child 6226 3106add9a5bf
equal deleted inserted replaced
6055:88cfcd9161d3 6224:42b256eca362
     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 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 
       
    36     BtnBack = addButton(":/res/Exit.png", pageLayout, 5, 0, true);
       
    37     connect(BtnBack, SIGNAL(clicked()), this, SIGNAL(goBack()));
       
    38 
       
    39 
       
    40     drawMapWidget = new DrawMapWidget(this);
       
    41     pageLayout->addWidget(drawMapWidget, 0, 1, 5, 1);
       
    42 
       
    43     connect(pbUndo, SIGNAL(clicked()), drawMapWidget, SLOT(undo()));
       
    44     connect(pbClear, SIGNAL(clicked()), drawMapWidget, SLOT(clear()));
       
    45     connect(pbLoad, SIGNAL(clicked()), this, SLOT(load()));
       
    46     connect(pbSave, SIGNAL(clicked()), this, SLOT(save()));
       
    47 }
       
    48 
       
    49 void PageDrawMap::load()
       
    50 {
       
    51     QString fileName = QFileDialog::getOpenFileName(NULL, tr("Load drawn map"), ".", tr("Drawn Maps") + " (*.hwmap);;" + tr("All files") + " (*)");
       
    52 
       
    53     if(!fileName.isEmpty())
       
    54         drawMapWidget->load(fileName);
       
    55 }
       
    56 
       
    57 void PageDrawMap::save()
       
    58 {
       
    59     QString fileName = QFileDialog::getSaveFileName(NULL, tr("Save drawn map"), ".", tr("Drawn Maps") + " (*.hwmap);;" + tr("All files") + " (*)");
       
    60 
       
    61     if(!fileName.isEmpty())
       
    62         drawMapWidget->save(fileName);
       
    63 }