QTfrontend/AbstractPage.cpp
changeset 6038 58d9badf3e7f
child 6042 8b5345758f62
equal deleted inserted replaced
6036:727d13409891 6038:58d9badf3e7f
       
     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 "AbstractPage.h"
       
    20 
       
    21 AbstractPage::AbstractPage(QWidget* parent)
       
    22 {
       
    23     Q_UNUSED(parent);
       
    24 
       
    25     font14 = new QFont("MS Shell Dlg", 14);
       
    26 }
       
    27 
       
    28 QPushButton * AbstractPage::formattedButton(const QString & btname, bool hasIcon)
       
    29 {
       
    30     QPushButton* btn = new QPushButton(this);
       
    31 
       
    32     if (hasIcon)
       
    33     {
       
    34         const QIcon& lp=QIcon(btname);
       
    35         QSize sz = lp.actualSize(QSize(65535, 65535));
       
    36         btn->setIcon(lp);
       
    37         btn->setFixedSize(sz);
       
    38         btn->setIconSize(sz);
       
    39         btn->setFlat(true);
       
    40         btn->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
       
    41     }
       
    42     else
       
    43     {
       
    44         btn->setFont(*font14);
       
    45         btn->setText(btname);
       
    46     }
       
    47     return btn;
       
    48 }
       
    49 
       
    50 QPushButton * AbstractPage::addButton(const QString & btname, QGridLayout* grid, int wy, int wx, bool hasIcon)
       
    51 {
       
    52     QPushButton* btn = formattedButton(btname, hasIcon);
       
    53     grid->addWidget(btn, wy, wx);
       
    54     return btn;
       
    55 }
       
    56 
       
    57 QPushButton * AbstractPage::addButton(const QString & btname, QGridLayout* grid, int wy, int wx, int rowSpan, int columnSpan, bool hasIcon)
       
    58 {
       
    59     QPushButton* btn = formattedButton(btname, hasIcon);
       
    60     grid->addWidget(btn, wy, wx, rowSpan, columnSpan);
       
    61     return btn;
       
    62 }
       
    63 
       
    64 QPushButton * AbstractPage::addButton(const QString & btname, QBoxLayout* box, int where, bool hasIcon)
       
    65 {
       
    66     QPushButton* btn = formattedButton(btname, hasIcon);
       
    67     box->addWidget(btn, where);
       
    68     return btn;
       
    69 }
       
    70