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

libtdegames

  • libtdegames
kchatdialog.cpp
1/*
2 This file is part of the TDE games library
3 Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation.
8
9 This library 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 GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#include "kchatdialog.h"
21
22#include "kchatbase.h"
23
24#include <tdelocale.h>
25#include <tdefontdialog.h>
26
27#include <tqlayout.h>
28#include <tqlabel.h>
29#include <tqpushbutton.h>
30
31class KChatDialogPrivate
32{
33 public:
34 KChatDialogPrivate()
35 {
36 mTextPage = 0;
37
38 mNamePreview = 0;
39 mTextPreview = 0;
40 mSystemNamePreview = 0;
41 mSystemTextPreview = 0;
42
43 mChat = 0;
44 }
45
46 TQFrame* mTextPage;
47
48 TQLabel* mNamePreview;
49 TQLabel* mTextPreview;
50 TQLabel* mSystemNamePreview;
51 TQLabel* mSystemTextPreview;
52
53 TQLineEdit* mMaxMessages;
54
55 KChatBase* mChat;
56};
57
58KChatDialog::KChatDialog(KChatBase* chat, TQWidget* parent, bool modal)
59// : KDialogBase(Tabbed, i18n("Configure Chat"), Ok|Default|Apply|Cancel, Ok, parent, 0, modal, true)
60 : KDialogBase(Plain, i18n("Configure Chat"), Ok|Default|Apply|Cancel, Ok, parent, 0, modal, true)
61{
62 init();
63 plugChatWidget(chat);
64}
65
66KChatDialog::KChatDialog(TQWidget* parent, bool modal)
67// : KDialogBase(Tabbed, i18n("Configure Chat"), Ok|Default|Apply|Cancel, Ok, parent, 0, modal, true)
68 : KDialogBase(Plain, i18n("Configure Chat"), Ok|Default|Apply|Cancel, Ok, parent, 0, modal, true)
69{
70 init();
71}
72
73KChatDialog::~KChatDialog()
74{
75 delete d;
76}
77
78void KChatDialog::init()
79{
80 d = new KChatDialogPrivate;
81// d->mTextPage = addPage(i18n("&Messages"));// not a good name - game Messages?
82 d->mTextPage = plainPage();
83 TQGridLayout* layout = new TQGridLayout(d->mTextPage, 7, 2, KDialog::marginHint(), KDialog::spacingHint());
84
85// General fonts
86 TQPushButton* nameFont = new TQPushButton(i18n("Name Font..."), d->mTextPage);
87 connect(nameFont, TQ_SIGNAL(pressed()), this, TQ_SLOT(slotGetNameFont()));
88 layout->addWidget(nameFont, 0, 0);
89 TQPushButton* textFont = new TQPushButton(i18n("Text Font..."), d->mTextPage);
90 connect(textFont, TQ_SIGNAL(pressed()), this, TQ_SLOT(slotGetTextFont()));
91 layout->addWidget(textFont, 0, 1);
92
93 TQFrame* messagePreview = new TQFrame(d->mTextPage);
94 messagePreview->setFrameStyle(TQFrame::StyledPanel | TQFrame::Sunken);
95 TQHBoxLayout* messageLayout = new TQHBoxLayout(messagePreview);
96 layout->addMultiCellWidget(messagePreview, 1, 1, 0, 1);
97
98 d->mNamePreview = new TQLabel(i18n("Player: "), messagePreview);
99 messageLayout->addWidget(d->mNamePreview, 0);
100 d->mTextPreview = new TQLabel(i18n("This is a player message"), messagePreview);
101 messageLayout->addWidget(d->mTextPreview, 1);
102
103 layout->addRowSpacing(2, 10);
104
105// System Message fonts
106 TQLabel* systemMessages = new TQLabel(i18n("System Messages - Messages directly sent from the game"), d->mTextPage);
107 layout->addMultiCellWidget(systemMessages, 3, 3, 0, 1);
108 TQPushButton* systemNameFont = new TQPushButton(i18n("Name Font..."), d->mTextPage);
109 connect(systemNameFont, TQ_SIGNAL(pressed()), this, TQ_SLOT(slotGetSystemNameFont()));
110 layout->addWidget(systemNameFont, 4, 0);
111 TQPushButton* systemTextFont = new TQPushButton(i18n("Text Font..."), d->mTextPage);
112 connect(systemTextFont, TQ_SIGNAL(pressed()), this, TQ_SLOT(slotGetSystemTextFont()));
113 layout->addWidget(systemTextFont, 4, 1);
114
115 TQFrame* systemMessagePreview = new TQFrame(d->mTextPage);
116 systemMessagePreview->setFrameStyle(TQFrame::StyledPanel | TQFrame::Sunken);
117 TQHBoxLayout* systemMessageLayout = new TQHBoxLayout(systemMessagePreview);
118 layout->addMultiCellWidget(systemMessagePreview, 5, 5, 0, 1);
119
120 d->mSystemNamePreview = new TQLabel(i18n("--- Game: "), systemMessagePreview);
121 systemMessageLayout->addWidget(d->mSystemNamePreview, 0);
122 d->mSystemTextPreview = new TQLabel(i18n("This is a system message"), systemMessagePreview);
123 systemMessageLayout->addWidget(d->mSystemTextPreview, 1);
124
125// message count
126 TQLabel* maxMessages = new TQLabel(i18n("Maximal number of messages (-1 = unlimited):"), d->mTextPage);
127 layout->addWidget(maxMessages, 6, 0);
128 d->mMaxMessages = new TQLineEdit(d->mTextPage);
129 d->mMaxMessages->setText(TQString::number(-1));
130 layout->addWidget(d->mMaxMessages, 6, 1);
131}
132
133void KChatDialog::slotGetNameFont()
134{
135 TQFont font = nameFont();
136 TDEFontDialog::getFont(font);
137 setNameFont(font);
138}
139
140void KChatDialog::slotGetTextFont()
141{
142 TQFont font = textFont();
143 TDEFontDialog::getFont(font);
144 setTextFont(font);
145}
146
147void KChatDialog::slotGetSystemNameFont()
148{
149 TQFont font = systemNameFont();
150 TDEFontDialog::getFont(font);
151 setSystemNameFont(font);
152}
153
154void KChatDialog::slotGetSystemTextFont()
155{
156 TQFont font = systemTextFont();
157 TDEFontDialog::getFont(font);
158 setSystemTextFont(font);
159}
160
161TQFont KChatDialog::nameFont() const
162{
163 return d->mNamePreview->font();
164}
165
166TQFont KChatDialog::textFont() const
167{
168 return d->mTextPreview->font();
169}
170
171TQFont KChatDialog::systemNameFont() const
172{
173 return d->mSystemNamePreview->font();
174}
175
176TQFont KChatDialog::systemTextFont() const
177{
178 return d->mSystemTextPreview->font();
179}
180
181void KChatDialog::plugChatWidget(KChatBase* widget, bool applyFonts)
182{
183 d->mChat = widget;
184 if (applyFonts && d->mChat) {
185 setNameFont(d->mChat->nameFont());
186 setTextFont(d->mChat->messageFont());
187 setSystemNameFont(d->mChat->systemNameFont());
188 setSystemTextFont(d->mChat->systemMessageFont());
189 setMaxMessages(d->mChat->maxItems());
190 }
191}
192
193void KChatDialog::configureChatWidget(KChatBase* widget)
194{
195 if (!widget) {
196 return;
197 }
198 widget->setNameFont(nameFont());
199 widget->setMessageFont(textFont());
200
201 widget->setSystemNameFont(systemNameFont());
202 widget->setSystemMessageFont(systemTextFont());
203
204 widget->setMaxItems(maxMessages());
205}
206
207void KChatDialog::slotOk()
208{
209 slotApply();
210 KDialogBase::slotOk();
211}
212
213void KChatDialog::slotApply()
214{
215 configureChatWidget(d->mChat);
216}
217
218void KChatDialog::setNameFont(TQFont f)
219{
220 d->mNamePreview->setFont(f);
221}
222
223void KChatDialog::setTextFont(TQFont f)
224{
225 d->mTextPreview->setFont(f);
226}
227
228void KChatDialog::setSystemNameFont(TQFont f)
229{
230 d->mSystemNamePreview->setFont(f);
231}
232
233void KChatDialog::setSystemTextFont(TQFont f)
234{
235 d->mSystemTextPreview->setFont(f);
236}
237
238void KChatDialog::setMaxMessages(int max)
239{
240 d->mMaxMessages->setText(TQString::number(max));
241}
242
243int KChatDialog::maxMessages() const
244{
245 bool ok;
246 int max = d->mMaxMessages->text().toInt(&ok);
247 if (!ok) {
248 return -1; // unlimited is default
249 }
250 return max;
251}
252
253#include "kchatdialog.moc"
KChatBase
The base class for chat widgets.
Definition: kchatbase.h:185
KChatBase::setSystemNameFont
void setSystemNameFont(const TQFont &font)
Same as setNameFont but applies only to system messages.
Definition: kchatbase.cpp:444
KChatBase::setSystemMessageFont
void setSystemMessageFont(const TQFont &font)
Same as setMessageFont but applies only to system messages.
Definition: kchatbase.cpp:450
KChatBase::setNameFont
void setNameFont(const TQFont &font)
Set the font that used used for the name part of a message.
Definition: kchatbase.cpp:420
KChatBase::setMessageFont
void setMessageFont(const TQFont &font)
Set the font that used used for the message part of a message.
Definition: kchatbase.cpp:426
KChatBase::setMaxItems
void setMaxItems(int maxItems)
Set the maximum number of items in the list.
Definition: kchatbase.cpp:513

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.9.4
This website is maintained by Timothy Pearson.