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