chatdlg.cpp

Go to the documentation of this file.
00001 /*
00002    This file is part of the KDE games kwin4 program
00003    Copyright (c) 2006 Martin Heni <kde@heni-online.de>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018    Boston, MA 02110-1301, USA.
00019 */
00020 
00021 // include files for QT
00022 #include <QPushButton>
00023 #include <QLayout>
00024 #include <QGroupBox>
00025 
00026 // include files for KDE
00027 #include <klocale.h>
00028 #include <kdebug.h>
00029 #include <kchatdialog.h>
00030 #include <kgamechat.h>
00031 #include <dialogs/kgamedialog.h>
00032 
00033 
00034 // application specific includes
00035 #include "chatdlg.h"
00036 #include "kwin4player.h"
00037 
00038 
00039 // Constructor for the chat widget. This widget
00040 // is derived from the libkdegames chat widget
00041 ChatDlg::ChatDlg(KGame *game,QWidget *parent)
00042        : KDialog(parent),mChat(0), mChatDlg(0)
00043 {
00044   setCaption(i18n("Chat Dlg"));
00045   setButtons(Ok);
00046   setDefaultButton(Ok);
00047   showButtonSeparator(true);
00048   setModal(false);
00049   setMinimumSize(QSize(200,200));
00050   
00051   QFrame* frame            = new QFrame(this);
00052   QGridLayout* mGridLayout = new QGridLayout(frame);
00053   QGroupBox* b             = new QGroupBox(i18n("Chat"), frame);
00054   QVBoxLayout* gboxLay     = new QVBoxLayout(b);
00055   mChat                    = new KGameChat(game, 10000, b);
00056   gboxLay->addWidget(mChat);
00057   mGridLayout->addWidget(b,0,0);
00058   
00059   QPushButton *mButton     = new QPushButton(i18n("Configure..."),frame);
00060   mGridLayout->addWidget(mButton,1,1);
00061   
00062   setMainWidget(frame);
00063   
00064   adjustSize();
00065   
00066   mChatDlg                 = new KChatDialog(mChat,frame,true);
00067   connect(mButton,SIGNAL(clicked()),mChatDlg,SLOT(show()));
00068 }
00069 
00070 // Set the player in who does the chat. This should be the local player.
00071 void ChatDlg::setPlayer(KWin4Player* p)
00072 {
00073   if (!mChat)
00074   {
00075     kError() << "ChatDlg::setPlayer::Chat not defined can't set player" << endl;
00076     return ;
00077   }
00078   if (!p)
00079   {
00080     kError() << "ChatDlg::setPlayer::Player not defined can't set player" << endl;
00081     return ;
00082   }
00083   mChat->setFromPlayer(p);
00084 }
00085 
00086 #include "chatdlg.moc"

Generated on Sun Mar 4 10:56:43 2007 for KWin4 by  doxygen 1.4.6