• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • libtdegames
 

libtdegames

kchatdialog.cpp
00001 /*
00002     This file is part of the TDE games library
00003     Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.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 version 2 as published by the Free Software Foundation.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to
00016     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017     Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "kchatdialog.h"
00021 
00022 #include "kchatbase.h"
00023 
00024 #include <tdelocale.h>
00025 #include <tdefontdialog.h>
00026 
00027 #include <tqlayout.h>
00028 #include <tqlabel.h>
00029 #include <tqpushbutton.h>
00030 
00031 class KChatDialogPrivate
00032 {
00033  public:
00034     KChatDialogPrivate()
00035     {
00036         mTextPage = 0;
00037 
00038         mNamePreview = 0;
00039         mTextPreview = 0;
00040         mSystemNamePreview = 0;
00041         mSystemTextPreview = 0;
00042 
00043         mChat = 0;
00044     }
00045 
00046     TQFrame* mTextPage;
00047 
00048     TQLabel* mNamePreview;
00049     TQLabel* mTextPreview;
00050     TQLabel* mSystemNamePreview;
00051     TQLabel* mSystemTextPreview;
00052 
00053     TQLineEdit* mMaxMessages;
00054 
00055     KChatBase* mChat;
00056 };
00057 
00058 KChatDialog::KChatDialog(KChatBase* chat, TQWidget* parent, bool modal) 
00059 //  : KDialogBase(Tabbed, i18n("Configure Chat"), Ok|Default|Apply|Cancel, Ok, parent, 0, modal, true)
00060     : KDialogBase(Plain, i18n("Configure Chat"), Ok|Default|Apply|Cancel, Ok, parent, 0, modal, true)
00061 {
00062  init();
00063  plugChatWidget(chat);
00064 }
00065 
00066 KChatDialog::KChatDialog(TQWidget* parent, bool modal) 
00067 //  : KDialogBase(Tabbed, i18n("Configure Chat"), Ok|Default|Apply|Cancel, Ok, parent, 0, modal, true)
00068     : KDialogBase(Plain, i18n("Configure Chat"), Ok|Default|Apply|Cancel, Ok, parent, 0, modal, true)
00069 {
00070  init();
00071 }
00072 
00073 KChatDialog::~KChatDialog()
00074 {
00075  delete d;
00076 }
00077 
00078 void KChatDialog::init()
00079 {
00080  d = new KChatDialogPrivate;
00081 // d->mTextPage = addPage(i18n("&Messages"));// not a good name - game Messages?
00082  d->mTextPage = plainPage();
00083  TQGridLayout* layout = new TQGridLayout(d->mTextPage, 7, 2, KDialog::marginHint(), KDialog::spacingHint());
00084 
00085 // General fonts
00086  TQPushButton* nameFont = new TQPushButton(i18n("Name Font..."), d->mTextPage);
00087  connect(nameFont, TQT_SIGNAL(pressed()), this, TQT_SLOT(slotGetNameFont()));
00088  layout->addWidget(nameFont, 0, 0);
00089  TQPushButton* textFont = new TQPushButton(i18n("Text Font..."), d->mTextPage);
00090  connect(textFont, TQT_SIGNAL(pressed()), this, TQT_SLOT(slotGetTextFont()));
00091  layout->addWidget(textFont, 0, 1);
00092 
00093  TQFrame* messagePreview = new TQFrame(d->mTextPage);
00094  messagePreview->setFrameStyle(TQFrame::StyledPanel | TQFrame::Sunken);
00095  TQHBoxLayout* messageLayout = new TQHBoxLayout(messagePreview);
00096  layout->addMultiCellWidget(messagePreview, 1, 1, 0, 1);
00097 
00098  d->mNamePreview = new TQLabel(i18n("Player: "), messagePreview);
00099  messageLayout->addWidget(d->mNamePreview, 0);
00100  d->mTextPreview = new TQLabel(i18n("This is a player message"), messagePreview);
00101  messageLayout->addWidget(d->mTextPreview, 1);
00102 
00103  layout->addRowSpacing(2, 10);
00104  
00105 // System Message fonts
00106  TQLabel* systemMessages = new TQLabel(i18n("System Messages - Messages directly sent from the game"), d->mTextPage);
00107  layout->addMultiCellWidget(systemMessages, 3, 3, 0, 1);
00108  TQPushButton* systemNameFont = new TQPushButton(i18n("Name Font..."), d->mTextPage);
00109  connect(systemNameFont, TQT_SIGNAL(pressed()), this, TQT_SLOT(slotGetSystemNameFont()));
00110  layout->addWidget(systemNameFont, 4, 0);
00111  TQPushButton* systemTextFont = new TQPushButton(i18n("Text Font..."), d->mTextPage);
00112  connect(systemTextFont, TQT_SIGNAL(pressed()), this, TQT_SLOT(slotGetSystemTextFont()));
00113  layout->addWidget(systemTextFont, 4, 1);
00114 
00115  TQFrame* systemMessagePreview = new TQFrame(d->mTextPage);
00116  systemMessagePreview->setFrameStyle(TQFrame::StyledPanel | TQFrame::Sunken);
00117  TQHBoxLayout* systemMessageLayout = new TQHBoxLayout(systemMessagePreview);
00118  layout->addMultiCellWidget(systemMessagePreview, 5, 5, 0, 1);
00119  
00120  d->mSystemNamePreview = new TQLabel(i18n("--- Game: "), systemMessagePreview);
00121  systemMessageLayout->addWidget(d->mSystemNamePreview, 0);
00122  d->mSystemTextPreview = new TQLabel(i18n("This is a system message"), systemMessagePreview);
00123  systemMessageLayout->addWidget(d->mSystemTextPreview, 1);
00124 
00125 // message count
00126  TQLabel* maxMessages = new TQLabel(i18n("Maximal number of messages (-1 = unlimited):"), d->mTextPage);
00127  layout->addWidget(maxMessages, 6, 0);
00128  d->mMaxMessages = new TQLineEdit(d->mTextPage);
00129  d->mMaxMessages->setText(TQString::number(-1));
00130  layout->addWidget(d->mMaxMessages, 6, 1);
00131 }
00132 
00133 void KChatDialog::slotGetNameFont()
00134 {
00135  TQFont font = nameFont();
00136  TDEFontDialog::getFont(font);
00137  setNameFont(font);
00138 }
00139 
00140 void KChatDialog::slotGetTextFont()
00141 {
00142  TQFont font = textFont();
00143  TDEFontDialog::getFont(font);
00144  setTextFont(font);
00145 }
00146 
00147 void KChatDialog::slotGetSystemNameFont()
00148 {
00149  TQFont font = systemNameFont();
00150  TDEFontDialog::getFont(font);
00151  setSystemNameFont(font);
00152 }
00153 
00154 void KChatDialog::slotGetSystemTextFont()
00155 {
00156  TQFont font = systemTextFont();
00157  TDEFontDialog::getFont(font);
00158  setSystemTextFont(font);
00159 }
00160 
00161 TQFont KChatDialog::nameFont() const
00162 {
00163  return d->mNamePreview->font();
00164 }
00165 
00166 TQFont KChatDialog::textFont() const
00167 {
00168  return d->mTextPreview->font();
00169 }
00170 
00171 TQFont KChatDialog::systemNameFont() const
00172 {
00173  return d->mSystemNamePreview->font();
00174 }
00175 
00176 TQFont KChatDialog::systemTextFont() const
00177 {
00178  return d->mSystemTextPreview->font();
00179 }
00180 
00181 void KChatDialog::plugChatWidget(KChatBase* widget, bool applyFonts)
00182 {
00183  d->mChat = widget;
00184  if (applyFonts && d->mChat) {
00185     setNameFont(d->mChat->nameFont());
00186     setTextFont(d->mChat->messageFont());
00187     setSystemNameFont(d->mChat->systemNameFont());
00188     setSystemTextFont(d->mChat->systemMessageFont());
00189     setMaxMessages(d->mChat->maxItems());
00190  }
00191 }
00192 
00193 void KChatDialog::configureChatWidget(KChatBase* widget)
00194 {
00195  if (!widget) {
00196     return;
00197  }
00198  widget->setNameFont(nameFont());
00199  widget->setMessageFont(textFont());
00200 
00201  widget->setSystemNameFont(systemNameFont());
00202  widget->setSystemMessageFont(systemTextFont());
00203  
00204  widget->setMaxItems(maxMessages());
00205 }
00206 
00207 void KChatDialog::slotOk()
00208 {
00209  slotApply();
00210  KDialogBase::slotOk();
00211 }
00212 
00213 void KChatDialog::slotApply()
00214 {
00215  configureChatWidget(d->mChat);
00216 }
00217 
00218 void KChatDialog::setNameFont(TQFont f)
00219 {
00220  d->mNamePreview->setFont(f);
00221 }
00222 
00223 void KChatDialog::setTextFont(TQFont f)
00224 {
00225  d->mTextPreview->setFont(f);
00226 }
00227 
00228 void KChatDialog::setSystemNameFont(TQFont f)
00229 {
00230  d->mSystemNamePreview->setFont(f);
00231 }
00232 
00233 void KChatDialog::setSystemTextFont(TQFont f)
00234 {
00235  d->mSystemTextPreview->setFont(f);
00236 }
00237 
00238 void KChatDialog::setMaxMessages(int max)
00239 {
00240  d->mMaxMessages->setText(TQString::number(max));
00241 }
00242 
00243 int KChatDialog::maxMessages() const
00244 {
00245  bool ok;
00246  int max = d->mMaxMessages->text().toInt(&ok);
00247  if (!ok) {
00248     return -1; // unlimited is default
00249  }
00250  return max;
00251 }
00252 
00253 #include "kchatdialog.moc"

libtdegames

Skip menu "libtdegames"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

libtdegames

Skip menu "libtdegames"
  • libtdegames
Generated for libtdegames by doxygen 1.7.6.1
This website is maintained by Timothy Pearson.