QTfrontend/pageadmin.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 <QLabel>
       
    21 #include <QLineEdit>
       
    22 #include <QSpinBox>
       
    23 #include <QPushButton>
       
    24 #include <QTextBrowser>
       
    25 
       
    26 #include "pageadmin.h"
       
    27 #include "chatwidget.h"
       
    28 
       
    29 PageAdmin::PageAdmin(QWidget* parent) :
       
    30     AbstractPage(parent)
       
    31 {
       
    32     QGridLayout * pageLayout = new QGridLayout(this);
       
    33 
       
    34     // 0
       
    35     pbAsk = addButton(tr("Fetch data"), pageLayout, 0, 0, 1, 3);
       
    36     connect(pbAsk, SIGNAL(clicked()), this, SIGNAL(askServerVars()));
       
    37     
       
    38     // 1
       
    39     QLabel * lblSMN = new QLabel(this);
       
    40     lblSMN->setText(tr("Server message for latest version:"));
       
    41     pageLayout->addWidget(lblSMN, 1, 0);
       
    42 
       
    43     leServerMessageNew = new QLineEdit(this);
       
    44     pageLayout->addWidget(leServerMessageNew, 1, 1);
       
    45 
       
    46     // 2
       
    47     QLabel * lblSMO = new QLabel(this);
       
    48     lblSMO->setText(tr("Server message for previous versions:"));
       
    49     pageLayout->addWidget(lblSMO, 2, 0);
       
    50 
       
    51     leServerMessageOld = new QLineEdit(this);
       
    52     pageLayout->addWidget(leServerMessageOld, 2, 1);
       
    53 
       
    54     // 3
       
    55     QLabel * lblP = new QLabel(this);
       
    56     lblP->setText(tr("Latest version protocol number:"));
       
    57     pageLayout->addWidget(lblP, 3, 0);
       
    58 
       
    59     sbProtocol = new QSpinBox(this);
       
    60     pageLayout->addWidget(sbProtocol, 3, 1);
       
    61 
       
    62     // 4
       
    63     QLabel * lblPreview = new QLabel(this);
       
    64     lblPreview->setText(tr("MOTD preview:"));
       
    65     pageLayout->addWidget(lblPreview, 4, 0);
       
    66 
       
    67     tb = new QTextBrowser(this);
       
    68     tb->setOpenExternalLinks(true);
       
    69     tb->document()->setDefaultStyleSheet(HWChatWidget::STYLE);
       
    70     pageLayout->addWidget(tb, 4, 1, 1, 2);
       
    71     connect(leServerMessageNew, SIGNAL(textEdited(const QString &)), tb, SLOT(setHtml(const QString &)));
       
    72     connect(leServerMessageOld, SIGNAL(textEdited(const QString &)), tb, SLOT(setHtml(const QString &)));
       
    73     
       
    74     // 5
       
    75     pbClearAccountsCache = addButton(tr("Clear Accounts Cache"), pageLayout, 5, 0);
       
    76     connect(pbClearAccountsCache, SIGNAL(clicked()), this, SIGNAL(clearAccountsCache()));
       
    77     
       
    78     // 6
       
    79     pbSetSM = addButton(tr("Set data"), pageLayout, 6, 0, 1, 3);
       
    80     connect(pbSetSM, SIGNAL(clicked()), this, SLOT(smChanged()));
       
    81 
       
    82 
       
    83     // 7
       
    84     BtnBack = addButton(":/res/Exit.png", pageLayout, 7, 0, true);
       
    85     connect(BtnBack, SIGNAL(clicked()), this, SIGNAL(goBack()));
       
    86 }
       
    87 
       
    88 void PageAdmin::smChanged()
       
    89 {
       
    90     emit setServerMessageNew(leServerMessageNew->text());
       
    91     emit setServerMessageOld(leServerMessageOld->text());
       
    92     emit setProtocol(sbProtocol->value());
       
    93 }
       
    94 
       
    95 void PageAdmin::serverMessageNew(const QString & str)
       
    96 {
       
    97     leServerMessageNew->setText(str);
       
    98 }
       
    99 
       
   100 void PageAdmin::serverMessageOld(const QString & str)
       
   101 {
       
   102     leServerMessageOld->setText(str);
       
   103 }
       
   104 void PageAdmin::protocol(int proto)
       
   105 {
       
   106     sbProtocol->setValue(proto);
       
   107 }