QTfrontend/pages.cpp
changeset 4586 4ba4f021070f
parent 4576 d85062310790
child 4594 5645462cc78f
equal deleted inserted replaced
4584:66bc6e45be83 4586:4ba4f021070f
    38 #include <QAction>
    38 #include <QAction>
    39 #include <QMenu>
    39 #include <QMenu>
    40 #include <QDataWidgetMapper>
    40 #include <QDataWidgetMapper>
    41 #include <QTime>
    41 #include <QTime>
    42 #include <QSlider>
    42 #include <QSlider>
       
    43 #include <QFileDialog>
    43 
    44 
    44 #include "ammoSchemeModel.h"
    45 #include "ammoSchemeModel.h"
    45 #include "pages.h"
    46 #include "pages.h"
    46 #include "sdlkeys.h"
    47 #include "sdlkeys.h"
    47 #include "hwconsts.h"
    48 #include "hwconsts.h"
  2015 
  2016 
  2016 PageDrawMap::PageDrawMap(QWidget* parent) : AbstractPage(parent)
  2017 PageDrawMap::PageDrawMap(QWidget* parent) : AbstractPage(parent)
  2017 {
  2018 {
  2018     QGridLayout * pageLayout = new QGridLayout(this);
  2019     QGridLayout * pageLayout = new QGridLayout(this);
  2019 
  2020 
  2020     BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, true);
  2021     QPushButton * pbUndo = addButton(tr("Undo"), pageLayout, 0, 0);
       
  2022     QPushButton * pbClear = addButton(tr("Clear"), pageLayout, 1, 0);
       
  2023     QPushButton * pbLoad = addButton(tr("Load"), pageLayout, 2, 0);
       
  2024     QPushButton * pbSave = addButton(tr("Save"), pageLayout, 3, 0);
       
  2025 
       
  2026     BtnBack = addButton(":/res/Exit.png", pageLayout, 5, 0, true);
  2021 
  2027 
  2022     drawMapWidget = new DrawMapWidget(this);
  2028     drawMapWidget = new DrawMapWidget(this);
  2023     pageLayout->addWidget(drawMapWidget, 0, 0, 1, 2);
  2029     pageLayout->addWidget(drawMapWidget, 0, 1, 5, 1);
  2024 }
  2030 
       
  2031     connect(pbUndo, SIGNAL(clicked()), drawMapWidget, SLOT(undo()));
       
  2032     connect(pbClear, SIGNAL(clicked()), drawMapWidget, SLOT(clear()));
       
  2033     connect(pbLoad, SIGNAL(clicked()), this, SLOT(load()));
       
  2034     connect(pbSave, SIGNAL(clicked()), this, SLOT(save()));
       
  2035 }
       
  2036 
       
  2037 void PageDrawMap::load()
       
  2038 {
       
  2039     QString fileName = QFileDialog::getOpenFileName(this, tr("Load drawn map"), ".", tr("Drawn Maps (*.hwmap);;All files (*.*)"));
       
  2040 
       
  2041     if(!fileName.isEmpty())
       
  2042         drawMapWidget->load(fileName);
       
  2043 }
       
  2044 
       
  2045 void PageDrawMap::save()
       
  2046 {
       
  2047     QString fileName = QFileDialog::getSaveFileName(this, tr("Save drawn map"), ".", tr("Drawn Maps (*.hwmap);;All files (*.*)"));
       
  2048 
       
  2049     if(!fileName.isEmpty())
       
  2050         drawMapWidget->save(fileName);
       
  2051 }