QTfrontend/pageselectweapon.cpp
changeset 6060 fdfc01419815
parent 6059 ddf020d0941a
child 6061 15b4b485a1c5
equal deleted inserted replaced
6059:ddf020d0941a 6060:fdfc01419815
     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 <QHBoxLayout>
       
    21 #include <QPushButton>
       
    22 #include <QComboBox>
       
    23 
       
    24 #include "pageselectweapon.h"
       
    25 #include "hwconsts.h"
       
    26 #include "selectWeapon.h"
       
    27 
       
    28 QLayout * PageSelectWeapon::bodyLayoutDefinition()
       
    29 {
       
    30     QGridLayout * pageLayout = new QGridLayout();
       
    31 
       
    32     pWeapons = new SelWeaponWidget(cAmmoNumber, this);
       
    33     pageLayout->addWidget(pWeapons);
       
    34 
       
    35     return pageLayout;
       
    36 }
       
    37 
       
    38 QLayout * PageSelectWeapon::footerLayoutDefinition()
       
    39 {
       
    40     QGridLayout * bottomLayout = new QGridLayout();
       
    41 
       
    42     selectWeaponSet = new QComboBox(this);
       
    43     bottomLayout->addWidget(selectWeaponSet, 0, 0, 2, 1);
       
    44 
       
    45     // first row
       
    46     BtnNew = addButton(tr("New"), bottomLayout, 0, 1);
       
    47     BtnDefault = addButton(tr("Default"), bottomLayout, 0, 2);
       
    48 
       
    49     // second row
       
    50     BtnCopy = addButton(tr("Copy"), bottomLayout, 1, 1);
       
    51     BtnDelete = addButton(tr("Delete"), bottomLayout, 1, 2);
       
    52 
       
    53     bottomLayout->setColumnStretch(1,1);
       
    54     bottomLayout->setColumnStretch(2,1);
       
    55 
       
    56     btnSave = addButton(":/res/Save.png", bottomLayout, 0, 3, 2, 1, true);
       
    57     btnSave->setStyleSheet("QPushButton{margin: 24px 0 0 0;}");
       
    58     bottomLayout->setAlignment(btnSave, Qt::AlignRight | Qt::AlignBottom);
       
    59 
       
    60     return bottomLayout;
       
    61 }
       
    62 
       
    63 void PageSelectWeapon::connectSignals()
       
    64 {
       
    65     connect(BtnDefault, SIGNAL(clicked()), pWeapons, SLOT(setDefault()));
       
    66     connect(btnSave, SIGNAL(clicked()), pWeapons, SLOT(save()));
       
    67     connect(BtnNew, SIGNAL(clicked()), pWeapons, SLOT(newWeaponsName()));
       
    68     connect(BtnCopy, SIGNAL(clicked()), pWeapons, SLOT(copy()));
       
    69     connect(selectWeaponSet, SIGNAL(currentIndexChanged(const QString&)), pWeapons, SLOT(setWeaponsName(const QString&)));
       
    70 }
       
    71 
       
    72 PageSelectWeapon::PageSelectWeapon(QWidget* parent) :  AbstractPage(parent)
       
    73 {
       
    74     initPage();
       
    75 }