~ubuntu-branches/ubuntu/hardy/kdenetwork/hardy-backports

« back to all changes in this revision

Viewing changes to debian/patches/kubuntu_08_emoticons_editor.diff

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-10-09 11:41:23 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20071009114123-0jkarj2mns28e3yd
Tags: 4:3.5.8-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
156
156
+
157
157
 #include "appearanceconfig.moc"
158
158
 // vim: set noet ts=4 sts=4 sw=4:
159
 
diff -Nur kdenetwork-3.5.7/kopete/kopete/config/appearance/appearanceconfig.cpp.orig kdenetwork-3.5.7.new/kopete/kopete/config/appearance/appearanceconfig.cpp.orig
160
 
--- kdenetwork-3.5.7/kopete/kopete/config/appearance/appearanceconfig.cpp.orig  1970-01-01 01:00:00.000000000 +0100
161
 
+++ kdenetwork-3.5.7.new/kopete/kopete/config/appearance/appearanceconfig.cpp.orig      2007-05-26 00:55:28.000000000 +0200
162
 
@@ -0,0 +1,878 @@
163
 
+/*
164
 
+    appearanceconfig.cpp  -  Kopete Look Feel Config
165
 
+
166
 
+    Copyright (c) 2001-2002 by Duncan Mac-Vicar Prett <duncan@kde.org>
167
 
+    Copyright (c) 2005-2006 by Michaël Larouche       <michael.larouche@kdemail.net>
168
 
+
169
 
+    Kopete    (c) 2002-2006 by the Kopete developers  <kopete-devel@kde.org>
170
 
+
171
 
+    *************************************************************************
172
 
+    *                                                                       *
173
 
+    * This program is free software; you can redistribute it and/or modify  *
174
 
+    * it under the terms of the GNU General Public License as published by  *
175
 
+    * the Free Software Foundation; either version 2 of the License, or     *
176
 
+    * (at your option) any later version.                                   *
177
 
+    *                                                                       *
178
 
+    *************************************************************************
179
 
+*/
180
 
+
181
 
+#ifdef HAVE_CONFIG_H
182
 
+#include "config.h"
183
 
+#endif
184
 
+
185
 
+#include "appearanceconfig.h"
186
 
+#include "appearanceconfig_emoticons.h"
187
 
+#include "appearanceconfig_chatwindow.h"
188
 
+#include "appearanceconfig_colors.h"
189
 
+#include "appearanceconfig_contactlist.h"
190
 
+
191
 
+#include "tooltipeditdialog.h"
192
 
+
193
 
+#include <qcheckbox.h>
194
 
+#include <qdir.h>
195
 
+#include <qlayout.h>
196
 
+#include <qhbuttongroup.h>
197
 
+#include <qspinbox.h>
198
 
+#include <qslider.h>
199
 
+#include <qlabel.h>
200
 
+
201
 
+#include <kdeversion.h>
202
 
+#include <kinputdialog.h>
203
 
+
204
 
+#include <kapplication.h>
205
 
+#include <kcolorcombo.h>
206
 
+#include <kcolorbutton.h>
207
 
+#include <kconfig.h> // for KNewStuff emoticon fetching
208
 
+#include <kdebug.h>
209
 
+#include <kfontrequester.h>
210
 
+#include <kgenericfactory.h>
211
 
+#include <kio/netaccess.h>
212
 
+#include <khtmlview.h>
213
 
+#include <klineedit.h>
214
 
+#include <klocale.h>
215
 
+#include <kmessagebox.h>
216
 
+#include <kpushbutton.h>
217
 
+#include <kstandarddirs.h>
218
 
+#include <ktextedit.h>
219
 
+#include <kurl.h> // KNewStuff
220
 
+#include <kurlrequesterdlg.h>
221
 
+#include <krun.h>
222
 
+#include <kfiledialog.h>
223
 
+
224
 
+#include <knewstuff/downloaddialog.h> // knewstuff emoticon and chatwindow fetching
225
 
+#include <knewstuff/engine.h>         // "
226
 
+#include <knewstuff/entry.h>          // "
227
 
+#include <knewstuff/knewstuff.h>      // "
228
 
+#include <knewstuff/provider.h>       // "
229
 
+
230
 
+// For Kopete Chat Window Style configuration and preview.
231
 
+#include <kopetechatwindowstylemanager.h>
232
 
+#include <kopetechatwindowstyle.h>
233
 
+#include <chatmessagepart.h>
234
 
+
235
 
+// Things we fake to get the message preview to work
236
 
+#include <kopeteprotocol.h>
237
 
+#include <kopetemetacontact.h>
238
 
+#include <kopeteaccount.h>
239
 
+#include <kopetecontact.h>
240
 
+#include <kopetemessage.h>
241
 
+#include <kopetechatsession.h>
242
 
+#include <kopetechatsessionmanager.h>
243
 
+
244
 
+#include "kopeteprefs.h"
245
 
+#include "kopeteemoticons.h"
246
 
+#include "kopeteglobal.h"
247
 
+
248
 
+#include <qtabwidget.h>
249
 
+
250
 
+typedef KGenericFactory<AppearanceConfig, QWidget> KopeteAppearanceConfigFactory;
251
 
+K_EXPORT_COMPONENT_FACTORY( kcm_kopete_appearanceconfig, KopeteAppearanceConfigFactory( "kcm_kopete_appearanceconfig" ) )
252
 
+
253
 
+class FakeProtocol;
254
 
+class FakeAccount;
255
 
+class FakeContact;
256
 
+
257
 
+class AppearanceConfig::Private
258
 
+{
259
 
+public:
260
 
+       Private()
261
 
+        : mAppearanceTabCtl(0L), preview(0L), mPrfsEmoticons(0L),mPrfsChatWindow(0L),
262
 
+          mPrfsColors(0L), mPrfsContactList(0L), currentStyle(0L), loading(false),
263
 
+          styleChanged(false)
264
 
+       {}
265
 
+
266
 
+       QTabWidget *mAppearanceTabCtl;
267
 
+
268
 
+       ChatMessagePart *preview;
269
 
+       AppearanceConfig_Emoticons *mPrfsEmoticons;
270
 
+       AppearanceConfig_ChatWindow *mPrfsChatWindow;
271
 
+       AppearanceConfig_Colors *mPrfsColors;
272
 
+       AppearanceConfig_ContactList *mPrfsContactList;
273
 
+
274
 
+       // value is the style path
275
 
+       QMap<QListBoxItem*,QString> styleItemMap;
276
 
+       ChatWindowStyle::StyleVariants currentVariantMap;
277
 
+       ChatWindowStyle *currentStyle;
278
 
+       bool loading;
279
 
+       bool styleChanged;
280
 
+
281
 
+       // For style preview
282
 
+       FakeProtocol *previewProtocol;
283
 
+       FakeAccount *previewAccount;
284
 
+       Kopete::MetaContact *myselfMetaContact;
285
 
+       Kopete::MetaContact *jackMetaContact;
286
 
+       FakeContact *myself;
287
 
+       FakeContact *jack;
288
 
+       Kopete::ChatSession *previewChatSession;
289
 
+};
290
 
+
291
 
+class KopeteStyleNewStuff : public KNewStuff
292
 
+{
293
 
+public:
294
 
+       KopeteStyleNewStuff(const QString &type, QWidget *parentWidget = 0)
295
 
+        : KNewStuff( type, parentWidget)
296
 
+       {}
297
 
+
298
 
+       bool createUploadFile(const QString &)
299
 
+       {
300
 
+               return false;
301
 
+       }
302
 
+
303
 
+       bool install(const QString &styleFilename)
304
 
+       {
305
 
+               int styleInstallReturn = 0;
306
 
+               styleInstallReturn = ChatWindowStyleManager::self()->installStyle( styleFilename );
307
 
+
308
 
+               switch(styleInstallReturn)
309
 
+               {
310
 
+                       case ChatWindowStyleManager::StyleInstallOk:
311
 
+                       {
312
 
+                               KMessageBox::queuedMessageBox( this->parentWidget(), KMessageBox::Information, i18n("The Chat Window style was successfully installed."), i18n("Install successful") );
313
 
+                               return true;
314
 
+                       }
315
 
+                       case ChatWindowStyleManager::StyleCannotOpen:
316
 
+                       {
317
 
+                               KMessageBox::queuedMessageBox( this->parentWidget(), KMessageBox::Error, i18n("The specified archive cannot be opened.\nMake sure that the archive is valid ZIP or TAR archive."), i18n("Cannot open archive") );
318
 
+                               break;
319
 
+                       }
320
 
+                       case ChatWindowStyleManager::StyleNoDirectoryValid:
321
 
+                       {
322
 
+                               KMessageBox::queuedMessageBox( this->parentWidget(), KMessageBox::Error, i18n("Could not find a suitable place to install the Chat Window style in user directory."), i18n("Cannot find styles directory") );
323
 
+                               break;
324
 
+                       }
325
 
+                       case ChatWindowStyleManager::StyleNotValid:
326
 
+                       {
327
 
+                               KMessageBox::queuedMessageBox( this->parentWidget(), KMessageBox::Error, i18n("The specified archive does not contain a valid Chat Window style."), i18n("Invalid Style") );
328
 
+                               break;
329
 
+                       }
330
 
+
331
 
+                       case ChatWindowStyleManager::StyleUnknow:
332
 
+                       default:
333
 
+                       {
334
 
+                               KMessageBox::queuedMessageBox( this->parentWidget(), KMessageBox::Error, i18n("An unknow error occurred while trying to install the Chat Window style."), i18n("Unknow error") );
335
 
+                               break;
336
 
+                       }
337
 
+               }
338
 
+               return false;
339
 
+       }
340
 
+};
341
 
+
342
 
+// TODO: Someday, this configuration dialog must(not should) use KConfigXT
343
 
+AppearanceConfig::AppearanceConfig(QWidget *parent, const char* /*name*/, const QStringList &args )
344
 
+: KCModule( KopeteAppearanceConfigFactory::instance(), parent, args )
345
 
+{
346
 
+       d = new Private;
347
 
+
348
 
+       (new QVBoxLayout(this))->setAutoAdd(true);
349
 
+       d->mAppearanceTabCtl = new QTabWidget(this, "mAppearanceTabCtl");
350
 
+
351
 
+       KConfig *config = KGlobal::config();
352
 
+       config->setGroup( "ChatWindowSettings" );
353
 
+
354
 
+       // "Emoticons" TAB ==========================================================
355
 
+       d->mPrfsEmoticons = new AppearanceConfig_Emoticons(d->mAppearanceTabCtl);
356
 
+       connect(d->mPrfsEmoticons->chkUseEmoticons, SIGNAL(toggled(bool)),
357
 
+               this, SLOT(emitChanged()));
358
 
+       connect(d->mPrfsEmoticons->chkRequireSpaces, SIGNAL(toggled(bool)),
359
 
+                       this, SLOT(emitChanged()));
360
 
+       connect(d->mPrfsEmoticons->icon_theme_list, SIGNAL(selectionChanged()),
361
 
+               this, SLOT(slotSelectedEmoticonsThemeChanged()));
362
 
+       connect(d->mPrfsEmoticons->btnInstallTheme, SIGNAL(clicked()),
363
 
+               this, SLOT(installEmoticonTheme()));
364
 
+
365
 
+       connect(d->mPrfsEmoticons->btnGetThemes, SIGNAL(clicked()),
366
 
+               this, SLOT(slotGetEmoticonThemes()));
367
 
+       connect(d->mPrfsEmoticons->btnRemoveTheme, SIGNAL(clicked()),
368
 
+               this, SLOT(removeSelectedEmoticonTheme()));
369
 
+
370
 
+       d->mAppearanceTabCtl->addTab(d->mPrfsEmoticons, i18n("&Emoticons"));
371
 
+
372
 
+       // "Chat Window" TAB ========================================================
373
 
+       d->mPrfsChatWindow = new AppearanceConfig_ChatWindow(d->mAppearanceTabCtl);
374
 
+
375
 
+       connect(d->mPrfsChatWindow->styleList, SIGNAL(selectionChanged(QListBoxItem *)),
376
 
+               this, SLOT(slotChatStyleSelected()));
377
 
+       connect(d->mPrfsChatWindow->variantList, SIGNAL(activated(const QString&)),
378
 
+               this, SLOT(slotChatStyleVariantSelected(const QString &)));
379
 
+       connect(d->mPrfsChatWindow->deleteButton, SIGNAL(clicked()),
380
 
+               this, SLOT(slotDeleteChatStyle()));
381
 
+       connect(d->mPrfsChatWindow->installButton, SIGNAL(clicked()),
382
 
+               this, SLOT(slotInstallChatStyle()));
383
 
+       connect(d->mPrfsChatWindow->btnGetStyles, SIGNAL(clicked()),
384
 
+               this, SLOT(slotGetChatStyles()));
385
 
+       connect(d->mPrfsChatWindow->groupConsecutiveMessages, SIGNAL(toggled(bool)),
386
 
+               this, SLOT(emitChanged()));
387
 
+       // Show the available styles when the Manager has finish to load the styles.
388
 
+       connect(ChatWindowStyleManager::self(), SIGNAL(loadStylesFinished()), this, SLOT(slotLoadChatStyles()));
389
 
+
390
 
+       d->mPrfsChatWindow->htmlFrame->setFrameStyle(QFrame::WinPanel | QFrame::Sunken);
391
 
+       // Create the fake Chat Session
392
 
+       createPreviewChatSession();
393
 
+       QVBoxLayout *l = new QVBoxLayout(d->mPrfsChatWindow->htmlFrame);
394
 
+       d->preview = new ChatMessagePart(d->previewChatSession, d->mPrfsChatWindow->htmlFrame, "preview");
395
 
+       d->preview->setJScriptEnabled(false);
396
 
+       d->preview->setJavaEnabled(false);
397
 
+       d->preview->setPluginsEnabled(false);
398
 
+       d->preview->setMetaRefreshEnabled(false);
399
 
+       KHTMLView *htmlWidget = d->preview->view();
400
 
+       htmlWidget->setMarginWidth(4);
401
 
+       htmlWidget->setMarginHeight(4);
402
 
+       htmlWidget->setFocusPolicy(NoFocus);
403
 
+       htmlWidget->setSizePolicy(
404
 
+               QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
405
 
+       l->addWidget(htmlWidget);
406
 
+       // Add the preview message to the ChatMessagePart
407
 
+       createPreviewMessages();
408
 
+
409
 
+       d->mAppearanceTabCtl->addTab( d->mPrfsChatWindow, i18n("Chat Window") );
410
 
+
411
 
+       // "Contact List" TAB =======================================================
412
 
+       d->mPrfsContactList = new AppearanceConfig_ContactList(d->mAppearanceTabCtl);
413
 
+       connect(d->mPrfsContactList->mTreeContactList, SIGNAL(toggled(bool)),
414
 
+               this, SLOT(emitChanged()));
415
 
+       connect(d->mPrfsContactList->mSortByGroup, SIGNAL(toggled(bool)),
416
 
+               this, SLOT(emitChanged()));
417
 
+       connect(d->mPrfsContactList->mEditTooltips, SIGNAL(clicked()),
418
 
+               this, SLOT(slotEditTooltips()));
419
 
+       connect(d->mPrfsContactList->mIndentContacts, SIGNAL(toggled(bool)),
420
 
+               this, SLOT(emitChanged()));
421
 
+       connect(d->mPrfsContactList->mHideVerticalScrollBar, SIGNAL(toggled(bool)),
422
 
+               this, SLOT(emitChanged()) );
423
 
+       connect(d->mPrfsContactList->mDisplayMode, SIGNAL(clicked(int)),
424
 
+               this, SLOT(emitChanged()));
425
 
+       connect(d->mPrfsContactList->mIconMode, SIGNAL(toggled(bool)),
426
 
+               this, SLOT(emitChanged()));
427
 
+       connect(d->mPrfsContactList->mAnimateChanges, SIGNAL(toggled(bool)),
428
 
+               this, SLOT(emitChanged()));
429
 
+       connect(d->mPrfsContactList->mFadeVisibility, SIGNAL(toggled(bool)),
430
 
+               this, SLOT(emitChanged()));
431
 
+       connect(d->mPrfsContactList->mFoldVisibility, SIGNAL(toggled(bool)),
432
 
+               this, SLOT(emitChanged()));
433
 
+       connect(d->mPrfsContactList->mAutoHide, SIGNAL(toggled(bool)),
434
 
+               this, SLOT(emitChanged()));
435
 
+       connect(d->mPrfsContactList->mAutoHideVScroll, SIGNAL(toggled(bool)),
436
 
+               this, SLOT(emitChanged()));
437
 
+       connect(d->mPrfsContactList->mAutoHideTimeout, SIGNAL(valueChanged(int)),
438
 
+               this, SLOT(emitChanged()));
439
 
+
440
 
+       // don't enable the checkbox if XRender is not available
441
 
+       #ifdef HAVE_XRENDER
442
 
+       d->mPrfsContactList->mFadeVisibility->setEnabled(true);
443
 
+       #else
444
 
+       d->mPrfsContactList->mFadeVisibility->setEnabled(false);
445
 
+       #endif
446
 
+
447
 
+       d->mAppearanceTabCtl->addTab(d->mPrfsContactList, i18n("Contact List"));
448
 
+
449
 
+       // "Colors and Fonts" TAB ===================================================
450
 
+       d->mPrfsColors = new AppearanceConfig_Colors(d->mAppearanceTabCtl);
451
 
+       connect(d->mPrfsColors->foregroundColor, SIGNAL(changed(const QColor &)),
452
 
+               this, SLOT(slotHighlightChanged()));
453
 
+       connect(d->mPrfsColors->backgroundColor, SIGNAL(changed(const QColor &)),
454
 
+               this, SLOT(slotHighlightChanged()));
455
 
+       connect(d->mPrfsColors->fontFace, SIGNAL(fontSelected(const QFont &)),
456
 
+               this, SLOT(slotChangeFont()));
457
 
+       connect(d->mPrfsColors->textColor, SIGNAL(changed(const QColor &)),
458
 
+               this, SLOT(slotUpdateChatPreview()));
459
 
+       connect(d->mPrfsColors->bgColor, SIGNAL(changed(const QColor &)),
460
 
+               this, SLOT(slotUpdateChatPreview()));
461
 
+       connect(d->mPrfsColors->linkColor, SIGNAL(changed(const QColor &)),
462
 
+               this, SLOT(slotUpdateChatPreview()));
463
 
+       connect(d->mPrfsColors->mGreyIdleMetaContacts, SIGNAL(toggled(bool)),
464
 
+               this, SLOT(emitChanged()));
465
 
+       connect(d->mPrfsColors->idleContactColor, SIGNAL(changed(const QColor &)),
466
 
+               this, SLOT(emitChanged()));
467
 
+       connect(d->mPrfsColors->mUseCustomFonts, SIGNAL(toggled(bool)),
468
 
+               this, SLOT(emitChanged()));
469
 
+       connect(d->mPrfsColors->mSmallFont, SIGNAL(fontSelected(const QFont &)),
470
 
+               this, SLOT(emitChanged()));
471
 
+       connect(d->mPrfsColors->mNormalFont, SIGNAL(fontSelected(const QFont &)),
472
 
+               this, SLOT(emitChanged()));
473
 
+       connect(d->mPrfsColors->mGroupNameColor, SIGNAL(changed(const QColor &)),
474
 
+               this, SLOT(emitChanged()));
475
 
+
476
 
+       connect(d->mPrfsColors->mBgOverride, SIGNAL(toggled(bool)),
477
 
+               this, SLOT(emitChanged()));
478
 
+       connect(d->mPrfsColors->mFgOverride, SIGNAL(toggled(bool)),
479
 
+               this, SLOT(emitChanged()));
480
 
+       connect(d->mPrfsColors->mRtfOverride, SIGNAL(toggled(bool)),
481
 
+               this, SLOT(emitChanged()));
482
 
+
483
 
+       d->mAppearanceTabCtl->addTab(d->mPrfsColors, i18n("Colors && Fonts"));
484
 
+
485
 
+       // ==========================================================================
486
 
+
487
 
+       load();
488
 
+}
489
 
+
490
 
+AppearanceConfig::~AppearanceConfig()
491
 
+{
492
 
+       delete d;
493
 
+}
494
 
+
495
 
+void AppearanceConfig::updateEmoticonsButton(bool _b)
496
 
+{
497
 
+    QString themeName = d->mPrfsEmoticons->icon_theme_list->currentText();
498
 
+    QFileInfo fileInf(KGlobal::dirs()->findResource("emoticons", themeName+"/"));
499
 
+    d->mPrfsEmoticons->btnRemoveTheme->setEnabled( _b && fileInf.isWritable());
500
 
+    d->mPrfsEmoticons->btnGetThemes->setEnabled( false );
501
 
+}
502
 
+
503
 
+void AppearanceConfig::save()
504
 
+{
505
 
+//     kdDebug(14000) << k_funcinfo << "called." << endl;
506
 
+       KopetePrefs *p = KopetePrefs::prefs();
507
 
+
508
 
+       // "Emoticons" TAB ==========================================================
509
 
+       p->setIconTheme( d->mPrfsEmoticons->icon_theme_list->currentText() );
510
 
+       p->setUseEmoticons ( d->mPrfsEmoticons->chkUseEmoticons->isChecked() );
511
 
+       p->setEmoticonsRequireSpaces( d->mPrfsEmoticons->chkRequireSpaces->isChecked() );
512
 
+
513
 
+       // "Chat Window" TAB ========================================================
514
 
+       p->setGroupConsecutiveMessages( d->mPrfsChatWindow->groupConsecutiveMessages->isChecked() );
515
 
+
516
 
+       // Get the stylePath
517
 
+       if(d->currentStyle)
518
 
+       {
519
 
+               kdDebug(14000) << k_funcinfo << d->currentStyle->getStylePath() << endl;
520
 
+               p->setStylePath(d->currentStyle->getStylePath());
521
 
+       }
522
 
+       // Get and save the styleVariant
523
 
+       if( !d->currentVariantMap.empty() )
524
 
+       {
525
 
+               kdDebug(14000) << k_funcinfo << d->currentVariantMap[ d->mPrfsChatWindow->variantList->currentText()] << endl;
526
 
+               p->setStyleVariant(d->currentVariantMap[ d->mPrfsChatWindow->variantList->currentText()]);
527
 
+       }
528
 
+
529
 
+       // "Contact List" TAB =======================================================
530
 
+       p->setTreeView(d->mPrfsContactList->mTreeContactList->isChecked());
531
 
+       p->setSortByGroup(d->mPrfsContactList->mSortByGroup->isChecked());
532
 
+       p->setContactListIndentContacts(d->mPrfsContactList->mIndentContacts->isChecked());
533
 
+       p->setContactListHideVerticalScrollBar(d->mPrfsContactList->mHideVerticalScrollBar->isChecked());
534
 
+       p->setContactListDisplayMode(KopetePrefs::ContactDisplayMode(d->mPrfsContactList->mDisplayMode->selectedId()));
535
 
+       p->setContactListIconMode(KopetePrefs::IconDisplayMode((d->mPrfsContactList->mIconMode->isChecked()) ? KopetePrefs::PhotoPic : KopetePrefs::IconPic));
536
 
+       p->setContactListAnimation(d->mPrfsContactList->mAnimateChanges->isChecked());
537
 
+       p->setContactListFading(d->mPrfsContactList->mFadeVisibility->isChecked());
538
 
+       p->setContactListFolding(d->mPrfsContactList->mFoldVisibility->isChecked());
539
 
+
540
 
+       // "Colors & Fonts" TAB =====================================================
541
 
+       p->setHighlightBackground(d->mPrfsColors->backgroundColor->color());
542
 
+       p->setHighlightForeground(d->mPrfsColors->foregroundColor->color());
543
 
+       p->setBgColor(d->mPrfsColors->bgColor->color());
544
 
+       p->setTextColor(d->mPrfsColors->textColor->color());
545
 
+       p->setLinkColor(d->mPrfsColors->linkColor->color());
546
 
+       p->setFontFace(d->mPrfsColors->fontFace->font());
547
 
+       p->setIdleContactColor(d->mPrfsColors->idleContactColor->color());
548
 
+       p->setGreyIdleMetaContacts(d->mPrfsColors->mGreyIdleMetaContacts->isChecked());
549
 
+       p->setContactListUseCustomFonts(d->mPrfsColors->mUseCustomFonts->isChecked());
550
 
+       p->setContactListCustomSmallFont(d->mPrfsColors->mSmallFont->font());
551
 
+       p->setContactListCustomNormalFont(d->mPrfsColors->mNormalFont->font());
552
 
+       p->setContactListGroupNameColor(d->mPrfsColors->mGroupNameColor->color());
553
 
+       p->setContactListAutoHide(d->mPrfsContactList->mAutoHide->isChecked());
554
 
+       p->setContactListAutoHideVScroll(d->mPrfsContactList->mAutoHideVScroll->isChecked());
555
 
+       p->setContactListAutoHideTimeout(d->mPrfsContactList->mAutoHideTimeout->value());
556
 
+
557
 
+       p->setBgOverride( d->mPrfsColors->mBgOverride->isChecked() );
558
 
+       p->setFgOverride( d->mPrfsColors->mFgOverride->isChecked() );
559
 
+       p->setRtfOverride( d->mPrfsColors->mRtfOverride->isChecked() );
560
 
+
561
 
+       p->save();
562
 
+       d->styleChanged = false;
563
 
+}
564
 
+
565
 
+void AppearanceConfig::load()
566
 
+{
567
 
+       //we will change the state of somme controls, which will call some signals.
568
 
+       //so to don't refresh everything several times, we memorize we are loading.
569
 
+       d->loading=true;
570
 
+
571
 
+//     kdDebug(14000) << k_funcinfo << "called" << endl;
572
 
+       KopetePrefs *p = KopetePrefs::prefs();
573
 
+
574
 
+       // "Emoticons" TAB ==========================================================
575
 
+       updateEmoticonlist();
576
 
+       d->mPrfsEmoticons->chkUseEmoticons->setChecked( p->useEmoticons() );
577
 
+       d->mPrfsEmoticons->chkRequireSpaces->setChecked( p->emoticonsRequireSpaces() );
578
 
+
579
 
+       // "Chat Window" TAB ========================================================
580
 
+       d->mPrfsChatWindow->groupConsecutiveMessages->setChecked( p->groupConsecutiveMessages() );
581
 
+       // Look for avaiable chat window styles.
582
 
+       slotLoadChatStyles();
583
 
+
584
 
+       // "Contact List" TAB =======================================================
585
 
+       d->mPrfsContactList->mTreeContactList->setChecked( p->treeView() );
586
 
+       d->mPrfsContactList->mSortByGroup->setChecked( p->sortByGroup() );
587
 
+       d->mPrfsContactList->mIndentContacts->setChecked( p->contactListIndentContacts() );
588
 
+       d->mPrfsContactList->mHideVerticalScrollBar->setChecked( p->contactListHideVerticalScrollBar() );
589
 
+
590
 
+        // convert old single value display mode to dual display/icon modes
591
 
+        if (p->contactListDisplayMode() == KopetePrefs::Yagami) {
592
 
+               p->setContactListDisplayMode( KopetePrefs::Detailed);
593
 
+               p->setContactListIconMode( KopetePrefs::PhotoPic );
594
 
+        }
595
 
+
596
 
+       d->mPrfsContactList->mDisplayMode->setButton( p->contactListDisplayMode() );
597
 
+       d->mPrfsContactList->mIconMode->setChecked( p->contactListIconMode() == KopetePrefs::PhotoPic);
598
 
+
599
 
+
600
 
+       d->mPrfsContactList->mAnimateChanges->setChecked( p->contactListAnimation() );
601
 
+#ifdef HAVE_XRENDER
602
 
+       d->mPrfsContactList->mFadeVisibility->setChecked( p->contactListFading() );
603
 
+#else
604
 
+       d->mPrfsContactList->mFadeVisibility->setChecked( false );
605
 
+#endif
606
 
+       d->mPrfsContactList->mFoldVisibility->setChecked( p->contactListFolding() );
607
 
+       d->mPrfsContactList->mAutoHide->setChecked( p->contactListAutoHide() );
608
 
+       d->mPrfsContactList->mAutoHideVScroll->setChecked( p->contactListAutoHideVScroll() );
609
 
+       d->mPrfsContactList->mAutoHideTimeout->setValue( p->contactListAutoHideTimeout() );
610
 
+
611
 
+       // "Colors & Fonts" TAB =====================================================
612
 
+       d->mPrfsColors->foregroundColor->setColor(p->highlightForeground());
613
 
+       d->mPrfsColors->backgroundColor->setColor(p->highlightBackground());
614
 
+       d->mPrfsColors->textColor->setColor(p->textColor());
615
 
+       d->mPrfsColors->linkColor->setColor(p->linkColor());
616
 
+       d->mPrfsColors->bgColor->setColor(p->bgColor());
617
 
+       d->mPrfsColors->fontFace->setFont(p->fontFace());
618
 
+       d->mPrfsColors->mGreyIdleMetaContacts->setChecked(p->greyIdleMetaContacts());
619
 
+       d->mPrfsColors->idleContactColor->setColor(p->idleContactColor());
620
 
+       d->mPrfsColors->mUseCustomFonts->setChecked(p->contactListUseCustomFonts());
621
 
+       d->mPrfsColors->mSmallFont->setFont(p->contactListCustomSmallFont());
622
 
+       d->mPrfsColors->mNormalFont->setFont(p->contactListCustomNormalFont());
623
 
+       d->mPrfsColors->mGroupNameColor->setColor(p->contactListGroupNameColor());
624
 
+
625
 
+       d->mPrfsColors->mBgOverride->setChecked( p->bgOverride() );
626
 
+       d->mPrfsColors->mFgOverride->setChecked( p->fgOverride() );
627
 
+       d->mPrfsColors->mRtfOverride->setChecked( p->rtfOverride() );
628
 
+
629
 
+       d->loading=false;
630
 
+       slotUpdateChatPreview();
631
 
+}
632
 
+
633
 
+void AppearanceConfig::slotLoadChatStyles()
634
 
+{
635
 
+       d->mPrfsChatWindow->styleList->clear();
636
 
+       d->styleItemMap.clear();
637
 
+
638
 
+       ChatWindowStyleManager::StyleList availableStyles;
639
 
+       availableStyles = ChatWindowStyleManager::self()->getAvailableStyles();
640
 
+       if( availableStyles.empty() )
641
 
+               kdDebug(14000) << k_funcinfo << "Warning, available styles is empty !" << endl;
642
 
+
643
 
+       ChatWindowStyleManager::StyleList::ConstIterator it, itEnd = availableStyles.constEnd();
644
 
+       for(it = availableStyles.constBegin(); it != itEnd; ++it)
645
 
+       {
646
 
+               // Insert style name into the listbox
647
 
+               d->mPrfsChatWindow->styleList->insertItem( it.key(), 0 );
648
 
+               // Insert the style class into the internal map for futher acces.
649
 
+               d->styleItemMap.insert( d->mPrfsChatWindow->styleList->firstItem(), it.data() );
650
 
+
651
 
+               if( it.data() == KopetePrefs::prefs()->stylePath() )
652
 
+               {
653
 
+                       kdDebug(14000) << k_funcinfo << "Restoring saved style: " << it.key() << endl;
654
 
+
655
 
+                       d->mPrfsChatWindow->styleList->setSelected( d->mPrfsChatWindow->styleList->firstItem(), true );
656
 
+               }
657
 
+       }
658
 
+
659
 
+       d->mPrfsChatWindow->styleList->sort();
660
 
+}
661
 
+
662
 
+void AppearanceConfig::updateEmoticonlist()
663
 
+{
664
 
+       KopetePrefs *p = KopetePrefs::prefs();
665
 
+       KStandardDirs dir;
666
 
+
667
 
+       d->mPrfsEmoticons->icon_theme_list->clear(); // Wipe out old list
668
 
+       // Get a list of directories in our icon theme dir
669
 
+       QStringList themeDirs = KGlobal::dirs()->findDirs("emoticons", "");
670
 
+       // loop adding themes from all dirs into theme-list
671
 
+       for(unsigned int x = 0;x < themeDirs.count();x++)
672
 
+       {
673
 
+               QDir themeQDir(themeDirs[x]);
674
 
+               themeQDir.setFilter( QDir::Dirs ); // only scan for subdirs
675
 
+               themeQDir.setSorting( QDir::Name ); // I guess name is as good as any
676
 
+               for(unsigned int y = 0; y < themeQDir.count(); y++)
677
 
+               {
678
 
+                       QStringList themes = themeQDir.entryList(QDir::Dirs, QDir::Name);
679
 
+                       // We don't care for '.' and '..'
680
 
+                       if ( themeQDir[y] != "." && themeQDir[y] != ".." )
681
 
+                       {
682
 
+                               // Add ourselves to the list, using our directory name  FIXME:  use the first emoticon of the theme.
683
 
+                               QPixmap previewPixmap = QPixmap(locate("emoticons", themeQDir[y]+"/smile.png"));
684
 
+                               d->mPrfsEmoticons->icon_theme_list->insertItem(previewPixmap,themeQDir[y]);
685
 
+                       }
686
 
+               }
687
 
+       }
688
 
+
689
 
+       // Where is that theme in our big-list-o-themes?
690
 
+       QListBoxItem *item = d->mPrfsEmoticons->icon_theme_list->findItem( p->iconTheme() );
691
 
+
692
 
+       if (item) // found it... make it the currently selected theme
693
 
+               d->mPrfsEmoticons->icon_theme_list->setCurrentItem( item );
694
 
+       else // Er, it's not there... select the current item
695
 
+               d->mPrfsEmoticons->icon_theme_list->setCurrentItem( 0 );
696
 
+}
697
 
+
698
 
+void AppearanceConfig::slotSelectedEmoticonsThemeChanged()
699
 
+{
700
 
+       QString themeName = d->mPrfsEmoticons->icon_theme_list->currentText();
701
 
+       QFileInfo fileInf(KGlobal::dirs()->findResource("emoticons", themeName+"/"));
702
 
+       d->mPrfsEmoticons->btnRemoveTheme->setEnabled( fileInf.isWritable() );
703
 
+
704
 
+       Kopete::Emoticons emoticons( themeName );
705
 
+       QStringList smileys = emoticons.emoticonAndPicList().keys();
706
 
+       QString newContentText = "<qt>";
707
 
+
708
 
+       for(QStringList::Iterator it = smileys.begin(); it != smileys.end(); ++it )
709
 
+               newContentText += QString::fromLatin1("<img src=\"%1\"> ").arg(*it);
710
 
+
711
 
+       newContentText += QString::fromLatin1("</qt>");
712
 
+       d->mPrfsEmoticons->icon_theme_preview->setText(newContentText);
713
 
+       emitChanged();
714
 
+}
715
 
+
716
 
+void AppearanceConfig::slotHighlightChanged()
717
 
+{
718
 
+//     bool value = mPrfsChatWindow->highlightEnabled->isChecked();
719
 
+//     mPrfsChatWindow->foregroundColor->setEnabled ( value );
720
 
+//     mPrfsChatWindow->backgroundColor->setEnabled ( value );
721
 
+       slotUpdateChatPreview();
722
 
+}
723
 
+
724
 
+void AppearanceConfig::slotChangeFont()
725
 
+{
726
 
+       slotUpdateChatPreview();
727
 
+       emitChanged();
728
 
+}
729
 
+
730
 
+void AppearanceConfig::slotChatStyleSelected()
731
 
+{
732
 
+       // Retrieve variant list.
733
 
+       QString stylePath = d->styleItemMap[d->mPrfsChatWindow->styleList->selectedItem()];
734
 
+       d->currentStyle = ChatWindowStyleManager::self()->getStyleFromPool( stylePath );
735
 
+
736
 
+       if(d->currentStyle)
737
 
+       {
738
 
+               d->currentVariantMap = d->currentStyle->getVariants();
739
 
+               kdDebug(14000) << k_funcinfo << "Loading style: " << d->currentStyle->getStylePath() << endl;
740
 
+
741
 
+               // Update the variant list based on current style.
742
 
+               d->mPrfsChatWindow->variantList->clear();
743
 
+
744
 
+               // Add the no variant item to the list
745
 
+               // TODO: Use default name variant from Info.plist
746
 
+               // TODO: Select default variant from Info.plist
747
 
+               d->mPrfsChatWindow->variantList->insertItem( i18n("(No Variant)") );
748
 
+
749
 
+               ChatWindowStyle::StyleVariants::ConstIterator it, itEnd = d->currentVariantMap.constEnd();
750
 
+               int currentIndex = 0;
751
 
+               for(it = d->currentVariantMap.constBegin(); it != itEnd; ++it)
752
 
+               {
753
 
+                       // Insert variant name into the combobox.
754
 
+                       d->mPrfsChatWindow->variantList->insertItem( it.key() );
755
 
+
756
 
+                       if( it.data() == KopetePrefs::prefs()->styleVariant() )
757
 
+                               d->mPrfsChatWindow->variantList->setCurrentItem(currentIndex+1);
758
 
+
759
 
+                       currentIndex++;
760
 
+               }
761
 
+
762
 
+               // Update the preview
763
 
+               slotUpdateChatPreview();
764
 
+               // Get the first variant to preview
765
 
+               // Check if the current style has variants.
766
 
+               if( !d->currentVariantMap.empty() )
767
 
+                       d->preview->setStyleVariant(d->currentVariantMap[0]);
768
 
+
769
 
+               emitChanged();
770
 
+       }
771
 
+}
772
 
+
773
 
+void AppearanceConfig::slotChatStyleVariantSelected(const QString &variantName)
774
 
+{
775
 
+//     kdDebug(14000) << k_funcinfo << variantName << endl;
776
 
+//     kdDebug(14000) << k_funcinfo << d->currentVariantMap[variantName] << endl;
777
 
+
778
 
+       // Update the preview
779
 
+       d->preview->setStyleVariant(d->currentVariantMap[variantName]);
780
 
+       emitChanged();
781
 
+}
782
 
+
783
 
+void AppearanceConfig::slotInstallChatStyle()
784
 
+{
785
 
+       KURL styleToInstall = KFileDialog::getOpenURL( QString::null, QString::fromUtf8("application/x-zip application/x-tgz application/x-tbz"), this, i18n("Choose Chat Window style to install.") );
786
 
+
787
 
+       if( !styleToInstall.isEmpty() )
788
 
+       {
789
 
+               QString stylePath;
790
 
+               if( KIO::NetAccess::download( styleToInstall, stylePath, this ) )
791
 
+               {
792
 
+                       int styleInstallReturn = 0;
793
 
+                       styleInstallReturn = ChatWindowStyleManager::self()->installStyle( stylePath );
794
 
+                       switch(styleInstallReturn)
795
 
+                       {
796
 
+                               case ChatWindowStyleManager::StyleCannotOpen:
797
 
+                               {
798
 
+                                       KMessageBox::queuedMessageBox( this, KMessageBox::Error, i18n("The specified archive cannot be opened.\nMake sure that the archive is valid ZIP or TAR archive."), i18n("Can't open archive") );
799
 
+                                       break;
800
 
+                               }
801
 
+                               case ChatWindowStyleManager::StyleNoDirectoryValid:
802
 
+                               {
803
 
+                                       KMessageBox::queuedMessageBox( this, KMessageBox::Error, i18n("Could not find a suitable place to install the Chat Window style in user directory."), i18n("Can't find styles directory") );
804
 
+                                       break;
805
 
+                               }
806
 
+                               case ChatWindowStyleManager::StyleNotValid:
807
 
+                                       KMessageBox::queuedMessageBox( this, KMessageBox::Error, i18n("The specified archive does not contain a valid Chat Window style."), i18n("Invalid Style") );
808
 
+                                       break;
809
 
+                               case ChatWindowStyleManager::StyleInstallOk:
810
 
+                               {
811
 
+                                       KMessageBox::queuedMessageBox( this, KMessageBox::Information, i18n("The Chat Window style was successfully installed."), i18n("Install successful") );
812
 
+                                       break;
813
 
+                               }
814
 
+                               case ChatWindowStyleManager::StyleUnknow:
815
 
+                               default:
816
 
+                               {
817
 
+                                       KMessageBox::queuedMessageBox( this, KMessageBox::Error, i18n("An unknow error occurred while trying to install the Chat Window style."), i18n("Unknow error") );
818
 
+                                       break;
819
 
+                               }
820
 
+                       }
821
 
+
822
 
+                       // removeTempFile check if the file is a temp file, so it's ok for local files.
823
 
+                       KIO::NetAccess::removeTempFile( stylePath );
824
 
+               }
825
 
+       }
826
 
+}
827
 
+
828
 
+void AppearanceConfig::slotDeleteChatStyle()
829
 
+{
830
 
+       QString styleName = d->mPrfsChatWindow->styleList->selectedItem()->text();
831
 
+       QString stylePathToDelete = d->styleItemMap[d->mPrfsChatWindow->styleList->selectedItem()];
832
 
+       if( ChatWindowStyleManager::self()->removeStyle(stylePathToDelete) )
833
 
+       {
834
 
+               KMessageBox::queuedMessageBox(this, KMessageBox::Information, i18n("It's the deleted style name", "The style %1 was successfully deleted.").arg(styleName));
835
 
+
836
 
+               // Get the first item in the stye List.
837
 
+               QString stylePath = (*d->styleItemMap.begin());
838
 
+               d->currentStyle = ChatWindowStyleManager::self()->getStyleFromPool(stylePath);
839
 
+               emitChanged();
840
 
+       }
841
 
+       else
842
 
+       {
843
 
+               KMessageBox::queuedMessageBox(this, KMessageBox::Information, i18n("It's the deleted style name", "An error occurred while trying to delete %1 style.").arg(styleName));
844
 
+       }
845
 
+}
846
 
+
847
 
+void AppearanceConfig::slotGetChatStyles()
848
 
+{
849
 
+       // we need this because KNewStuffGeneric's install function isn't clever enough
850
 
+       KopeteStyleNewStuff *kopeteNewStuff = new KopeteStyleNewStuff( "kopete/chatstyle", this );
851
 
+       KNS::Engine *engine = new KNS::Engine( kopeteNewStuff, "kopete/chatstyle", this );
852
 
+       KNS::DownloadDialog *downloadDialog = new KNS::DownloadDialog( engine, this );
853
 
+       downloadDialog->setType( "kopete/chatstyle" );
854
 
+       // you have to do this by hand when providing your own Engine
855
 
+       KNS::ProviderLoader *provider = new KNS::ProviderLoader( this );
856
 
+       QObject::connect( provider, SIGNAL( providersLoaded(Provider::List*) ), downloadDialog, SLOT( slotProviders (Provider::List *) ) );
857
 
+       provider->load( "kopete/chatstyle", "http://download.kde.org/khotnewstuff/kopetestyles12-providers.xml" );
858
 
+       downloadDialog->exec();
859
 
+}
860
 
+
861
 
+// Reimplement Kopete::Contact and its abstract method
862
 
+// This is for style preview.
863
 
+class FakeContact : public Kopete::Contact
864
 
+{
865
 
+public:
866
 
+       FakeContact (Kopete::Account *account, const QString &id, Kopete::MetaContact *mc ) : Kopete::Contact( account, id, mc ) {}
867
 
+       virtual Kopete::ChatSession *manager(Kopete::Contact::CanCreateFlags /*c*/) { return 0L; }
868
 
+       virtual void slotUserInfo() {};
869
 
+};
870
 
+
871
 
+// This is for style preview.
872
 
+class FakeProtocol : public Kopete::Protocol
873
 
+{
874
 
+public:
875
 
+FakeProtocol( KInstance *instance, QObject *parent, const char *name ) : Kopete::Protocol(instance, parent, name){}
876
 
+Kopete::Account* createNewAccount( const QString &/*accountId*/ ){return 0L;}
877
 
+AddContactPage* createAddContactWidget( QWidget */*parent*/, Kopete::Account */*account*/){return 0L;}
878
 
+KopeteEditAccountWidget* createEditAccountWidget( Kopete::Account */*account*/, QWidget */*parent */){return 0L;}
879
 
+};
880
 
+
881
 
+// This is for style preview.
882
 
+class FakeAccount : public Kopete::Account
883
 
+{
884
 
+public:
885
 
+FakeAccount(Kopete::Protocol *parent, const QString &accountID, const char *name) : Kopete::Account(parent, accountID, name){}
886
 
+~FakeAccount()
887
 
+{}
888
 
+bool createContact( const QString &/*contactId*/, Kopete::MetaContact */*parentContact*/ ){return true;}
889
 
+void connect( const Kopete::OnlineStatus& /*initialStatus*/){}
890
 
+void disconnect(){}
891
 
+void setOnlineStatus( const Kopete::OnlineStatus& /*status*/ , const QString &/*reason*/){}
892
 
+};
893
 
+
894
 
+void AppearanceConfig::createPreviewChatSession()
895
 
+{
896
 
+       d->previewProtocol = new FakeProtocol( new KInstance(QCString("kopete-preview-chatwindowstyle")), 0L, "kopete-preview-chatwindowstyle");
897
 
+       d->previewAccount = new FakeAccount(d->previewProtocol, QString("previewaccount"), 0);
898
 
+
899
 
+       // Create fake meta/contacts
900
 
+       d->myselfMetaContact = new Kopete::MetaContact();
901
 
+       d->myself = new FakeContact(d->previewAccount, i18n("This is the myself preview contact id", "myself@preview"), d->myselfMetaContact);
902
 
+       d->myself->setNickName(i18n("This is the myself preview contact nickname", "Myself"));
903
 
+       d->jackMetaContact = new Kopete::MetaContact();
904
 
+       d->jack = new FakeContact(d->previewAccount, i18n("This is the other preview contact id", "jack@preview"), d->jackMetaContact);
905
 
+       d->jack->setNickName(i18n("This is the other preview contact nickname", "Jack"));
906
 
+       d->myselfMetaContact->setDisplayName(i18n("Myself"));
907
 
+       d->myselfMetaContact->setDisplayNameSource(Kopete::MetaContact::SourceCustom);
908
 
+       d->jackMetaContact->setDisplayName(i18n("Jack"));
909
 
+       d->jackMetaContact->setDisplayNameSource(Kopete::MetaContact::SourceCustom);
910
 
+
911
 
+       Kopete::ContactPtrList contactList;
912
 
+       contactList.append(d->jack);
913
 
+       // Create fakeChatSession
914
 
+       d->previewChatSession = Kopete::ChatSessionManager::self()->create(d->myself, contactList, 0);
915
 
+       d->previewChatSession->setDisplayName("Preview Session");
916
 
+}
917
 
+
918
 
+void AppearanceConfig::createPreviewMessages()
919
 
+{
920
 
+       Kopete::Message msgIn( d->jack,d->myself, i18n( "Hello, this is an incoming message :-)" ), Kopete::Message::Inbound );
921
 
+       Kopete::Message msgIn2( d->jack, d->myself, i18n( "Hello, this is an incoming consecutive message." ), Kopete::Message::Inbound );
922
 
+
923
 
+       Kopete::Message msgOut( d->myself, d->jack, i18n( "Ok, this is an outgoing message" ), Kopete::Message::Outbound );
924
 
+       Kopete::Message msgOut2( d->myself, d->jack, i18n( "Ok, a outgoing consecutive message." ), Kopete::Message::Outbound );
925
 
+
926
 
+       Kopete::Message msgCol( d->jack, d->myself, i18n( "Here is an incoming colored message" ), Kopete::Message::Inbound );
927
 
+       msgCol.setFg( QColor( "DodgerBlue" ) );
928
 
+       msgCol.setBg( QColor( "LightSteelBlue" ) );
929
 
+       Kopete::Message msgInt( d->jack, d->myself, i18n( "This is an internal message" ), Kopete::Message::Internal );
930
 
+       Kopete::Message msgAct( d->jack, d->myself, i18n( "performed an action" ), Kopete::Message::Inbound,
931
 
+                                 Kopete::Message::PlainText, QString::null, Kopete::Message::TypeAction );
932
 
+       Kopete::Message msgHigh( d->jack, d->myself, i18n( "This is a highlighted message" ), Kopete::Message::Inbound );
933
 
+       msgHigh.setImportance( Kopete::Message::Highlight );
934
 
+       // This is a UTF-8 string btw.
935
 
+       Kopete::Message msgRightToLeft(d->myself, d->jack, i18n("This special UTF-8 string is to test if the style support Right-to-Left language display.", "הודעות טקסט"), Kopete::Message::Outbound);
936
 
+       Kopete::Message msgExplanation( d->myself, d->jack, i18n( "That message was in a Right-to-Left language, which Kopete also supports." ), Kopete::Message::Outbound );
937
 
+       Kopete::Message msgBye ( d->myself, d->jack,   i18n( "Bye" ), Kopete::Message::Outbound );
938
 
+
939
 
+       // Add the messages to ChatMessagePart
940
 
+       d->preview->appendMessage(msgIn);
941
 
+       d->preview->appendMessage(msgIn2);
942
 
+       d->preview->appendMessage(msgOut);
943
 
+       d->preview->appendMessage(msgOut2);
944
 
+       d->preview->appendMessage(msgCol);
945
 
+       d->preview->appendMessage(msgInt);
946
 
+       d->preview->appendMessage(msgAct);
947
 
+       d->preview->appendMessage(msgHigh);
948
 
+       d->preview->appendMessage(msgRightToLeft);
949
 
+       d->preview->appendMessage(msgExplanation);
950
 
+       d->preview->appendMessage(msgBye);
951
 
+}
952
 
+
953
 
+void AppearanceConfig::slotUpdateChatPreview()
954
 
+{
955
 
+       if(d->loading || !d->currentStyle)
956
 
+               return;
957
 
+
958
 
+       // Update the preview
959
 
+       d->preview->setStyle(d->currentStyle);
960
 
+
961
 
+       emitChanged();
962
 
+}
963
 
+
964
 
+void AppearanceConfig::emitChanged()
965
 
+{
966
 
+       emit changed( true );
967
 
+}
968
 
+
969
 
+void AppearanceConfig::installEmoticonTheme()
970
 
+{
971
 
+       KURL themeURL = KURLRequesterDlg::getURL(QString::null, this,
972
 
+                       i18n("Drag or Type Emoticon Theme URL"));
973
 
+       if ( themeURL.isEmpty() )
974
 
+               return;
975
 
+
976
 
+       //TODO: support remote theme files!
977
 
+       if ( !themeURL.isLocalFile() )
978
 
+       {
979
 
+               KMessageBox::queuedMessageBox( this, KMessageBox::Error, i18n("Sorry, emoticon themes must be installed from local files."),
980
 
+                                              i18n("Could Not Install Emoticon Theme") );
981
 
+               return;
982
 
+       }
983
 
+
984
 
+       Kopete::Global::installEmoticonTheme( themeURL.path() );
985
 
+       updateEmoticonlist();
986
 
+}
987
 
+
988
 
+void AppearanceConfig::removeSelectedEmoticonTheme()
989
 
+{
990
 
+       QListBoxItem *selected = d->mPrfsEmoticons->icon_theme_list->selectedItem();
991
 
+       if(selected==0)
992
 
+               return;
993
 
+
994
 
+       QString themeName = selected->text();
995
 
+
996
 
+       QString question=i18n("<qt>Are you sure you want to remove the "
997
 
+                       "<strong>%1</strong> emoticon theme?<br>"
998
 
+                       "<br>"
999
 
+                       "This will delete the files installed by this theme.</qt>").
1000
 
+               arg(themeName);
1001
 
+
1002
 
+        int res = KMessageBox::warningContinueCancel(this, question, i18n("Confirmation"),KStdGuiItem::del());
1003
 
+       if (res!=KMessageBox::Continue)
1004
 
+               return;
1005
 
+
1006
 
+       KURL themeUrl(KGlobal::dirs()->findResource("emoticons", themeName+"/"));
1007
 
+       KIO::NetAccess::del(themeUrl, this);
1008
 
+
1009
 
+       updateEmoticonlist();
1010
 
+}
1011
 
+
1012
 
+void AppearanceConfig::slotGetEmoticonThemes()
1013
 
+{
1014
 
+       KConfig* config = KGlobal::config();
1015
 
+       config->setGroup( "KNewStuff" );
1016
 
+       config->writeEntry( "ProvidersUrl",
1017
 
+                                               "http://download.kde.org/khotnewstuff/emoticons-providers.xml" );
1018
 
+       config->writeEntry( "StandardResource", "emoticons" );
1019
 
+       config->writeEntry( "Uncompress", "application/x-gzip" );
1020
 
+       config->sync();
1021
 
+
1022
 
+#if ( KDE_IS_VERSION(3,3,90) )
1023
 
+       KNS::DownloadDialog::open( "emoticons", i18n( "Get New Emoticons") );
1024
 
+#else
1025
 
+       KNS::DownloadDialog::open( i18n( "Get New Emoticons" ) );
1026
 
+#endif
1027
 
+
1028
 
+       updateEmoticonlist();
1029
 
+}
1030
 
+
1031
 
+void AppearanceConfig::slotEditTooltips()
1032
 
+{
1033
 
+       TooltipEditDialog *dlg = new TooltipEditDialog(this);
1034
 
+       connect(dlg, SIGNAL(changed(bool)), this, SIGNAL(changed(bool)));
1035
 
+       dlg->exec();
1036
 
+       delete dlg;
1037
 
+}
1038
 
+
1039
 
+#include "appearanceconfig.moc"
1040
 
+// vim: set noet ts=4 sts=4 sw=4:
1041
159
diff -Nur kdenetwork-3.5.7/kopete/kopete/config/appearance/appearanceconfig_emoticons.ui kdenetwork-3.5.7.new/kopete/kopete/config/appearance/appearanceconfig_emoticons.ui
1042
160
--- kdenetwork-3.5.7/kopete/kopete/config/appearance/appearanceconfig_emoticons.ui      2007-05-22 18:07:21.000000000 +0200
1043
161
+++ kdenetwork-3.5.7.new/kopete/kopete/config/appearance/appearanceconfig_emoticons.ui  2007-05-26 01:00:52.000000000 +0200
1535
653
 
1536
654
 
1537
655
 private:
1538
 
diff -Nur kdenetwork-3.5.7/kopete/libkopete/private/kopeteemoticons.h.orig kdenetwork-3.5.7.new/kopete/libkopete/private/kopeteemoticons.h.orig
1539
 
--- kdenetwork-3.5.7/kopete/libkopete/private/kopeteemoticons.h.orig    1970-01-01 01:00:00.000000000 +0100
1540
 
+++ kdenetwork-3.5.7.new/kopete/libkopete/private/kopeteemoticons.h.orig        2007-05-22 18:07:21.000000000 +0200
1541
 
@@ -0,0 +1,184 @@
1542
 
+/*
1543
 
+    kopeteemoticons.cpp - Kopete Preferences Container-Class
1544
 
+
1545
 
+    Copyright (c) 2002-2003 by Stefan Gehn            <metz AT gehn.net>
1546
 
+    Kopete    (c) 2002-2004 by the Kopete developers  <kopete-devel@kde.org>
1547
 
+    Copyright (c) 2005      by Engin AYDOGAN         <engin @ bzzzt.biz>
1548
 
+
1549
 
+    *************************************************************************
1550
 
+    *                                                                       *
1551
 
+    * This library is free software; you can redistribute it and/or         *
1552
 
+    * modify it under the terms of the GNU Lesser General Public            *
1553
 
+    * License as published by the Free Software Foundation; either          *
1554
 
+    * version 2 of the License, or (at your option) any later version.      *
1555
 
+    *                                                                       *
1556
 
+    *************************************************************************
1557
 
+*/
1558
 
+
1559
 
+#ifndef kopeteemoticons_h__
1560
 
+#define kopeteemoticons_h__
1561
 
+
1562
 
+#include <qobject.h>
1563
 
+#include <qvaluelist.h>
1564
 
+#include <qregexp.h>
1565
 
+
1566
 
+#include "kopete_export.h"
1567
 
+
1568
 
+namespace Kopete {
1569
 
+
1570
 
+class KOPETE_EXPORT Emoticons : public QObject
1571
 
+{
1572
 
+       Q_OBJECT
1573
 
+public:
1574
 
+       /**
1575
 
+        * Constructor: DON'T use it if you want to use the emoticon theme
1576
 
+        * chosen by the user.
1577
 
+        * Instead, use @ref Kopete::Emoticons::self()
1578
 
+        **/
1579
 
+       Emoticons( const QString &theme = QString::null );
1580
 
+
1581
 
+       ~Emoticons(  );
1582
 
+
1583
 
+       /**
1584
 
+        * The emoticons container-class by default is a singleton object.
1585
 
+        * Use this method to retrieve the instance.
1586
 
+        */
1587
 
+       static Emoticons *self();
1588
 
+
1589
 
+       /**
1590
 
+        * The possible parse modes
1591
 
+        */
1592
 
+       enum ParseMode {  DefaultParseMode = 0x0 ,  /**  Use strict or relaxed according the config  */
1593
 
+                       StrictParse = 0x1,                      /** Strict parsing requires a space between each emoticon */
1594
 
+                       RelaxedParse = 0x4,         /** Parse mode where all possible emoticon matches are allowed */
1595
 
+                       SkipHTML = 0x2                          /** Skip emoticons within HTML */
1596
 
+                };
1597
 
+
1598
 
+       /**
1599
 
+        * Use it to parse emoticons in a text.
1600
 
+        * You don't need to use this for chat windows,
1601
 
+        * There is a special class that abstract a chat view
1602
 
+        * and uses emoticons parser.
1603
 
+        * This function will use the selected emoticon theme.
1604
 
+        * If nicks is provided, they will not be parsed if they 
1605
 
+        * exist in message.
1606
 
+        */
1607
 
+       static QString parseEmoticons( const QString &message, ParseMode = SkipHTML ) ;
1608
 
+
1609
 
+       
1610
 
+       QString parse( const QString &message, ParseMode = SkipHTML );
1611
 
+
1612
 
+       /**
1613
 
+        * TokenType, a token might be an image ( emoticon ) or text.
1614
 
+        */
1615
 
+       enum TokenType { Undefined, /** Undefined, for completeness only */
1616
 
+                                        Image,         /** Token contains a path to an image */
1617
 
+                                        Text           /** Token contains test */
1618
 
+                                  };
1619
 
+       
1620
 
+       /**
1621
 
+        * A token consists of a QString text which is either a regular text
1622
 
+        * or a path to image depending on the type.
1623
 
+        * If type is Image the text refers to an image path.
1624
 
+        * If type is Text the text refers to a regular text.
1625
 
+        */
1626
 
+       struct Token {
1627
 
+               Token() : type( Undefined ) {}
1628
 
+               Token( TokenType t, const QString &m ) : type( t ), text(m) {}
1629
 
+               Token( TokenType t, const QString &m, const QString &p, const QString &html )
1630
 
+                : type( t ), text( m ), picPath( p ), picHTMLCode( html ) {}
1631
 
+               TokenType       type;
1632
 
+               QString         text;
1633
 
+               QString         picPath;
1634
 
+               QString         picHTMLCode;
1635
 
+       };
1636
 
+       
1637
 
+
1638
 
+       /**
1639
 
+        * Static function which will call tokenize
1640
 
+        * @see tokenize( const QString& )
1641
 
+        */
1642
 
+       static QValueList<Token> tokenizeEmoticons( const QString &message, ParseMode mode = DefaultParseMode );
1643
 
+
1644
 
+       /**
1645
 
+        * Tokenizes an message.
1646
 
+        * For example;
1647
 
+        * Assume :], (H), :-x are three emoticons.
1648
 
+        * A text "(H)(H) foo bar john :] :-x" would be tokenized as follows (not strict):
1649
 
+        * 1- /path/to/shades.png
1650
 
+        * 2- /path/to/shades.png
1651
 
+        * 3- " foo bar john "
1652
 
+        * 4- /path/to/bat.png
1653
 
+        * 5- " "
1654
 
+        * 6- /path/to/kiss.png
1655
 
+        *
1656
 
+        * Strict tokenization (require spaces around emoticons):
1657
 
+        * 1- "(H)(H) foo bar john "
1658
 
+        * 2- /path/to/bat.png
1659
 
+        * 3- " "
1660
 
+        * 4- /path/to/kiss.png
1661
 
+        * Note: quotation marks are used to emphasize white spaces.
1662
 
+        * @param message is the message to tokenize
1663
 
+        * @param mode is a bitmask of ParseMode enum
1664
 
+        * @return a QValueList which consiste of ordered tokens of the text.
1665
 
+        * @author Engin AYDOGAN < engin@bzzzt.biz >
1666
 
+        * @since 23-03-05
1667
 
+        */
1668
 
+       QValueList<Token> tokenize( const QString &message, uint mode = DefaultParseMode );
1669
 
+       
1670
 
+       /**
1671
 
+        * Return all emoticons and the corresponding icon.
1672
 
+        * (only one emoticon per image)
1673
 
+        */
1674
 
+       QMap<QString, QStringList> emoticonAndPicList();
1675
 
+
1676
 
+
1677
 
+private:
1678
 
+       /**
1679
 
+        * Our instance
1680
 
+        **/
1681
 
+       static Emoticons *s_self;
1682
 
+
1683
 
+       /**
1684
 
+        * add an emoticon to our mapping if
1685
 
+        * an animation/pixmap has been found for it
1686
 
+        **/
1687
 
+       void addIfPossible( const QString& filenameNoExt, const QStringList &emoticons );
1688
 
+       
1689
 
+       /**
1690
 
+        * uses the kopete's emoticons.xml  for the theme
1691
 
+        * @see initEmoticons
1692
 
+        */
1693
 
+       void initEmoticon_emoticonsxml( const QString & filename);
1694
 
+       
1695
 
+       /**
1696
 
+        * uses the JEP-0038 xml description for the theme
1697
 
+        * @see initEmoticons
1698
 
+        */
1699
 
+       void initEmoticon_JEP0038( const QString & filename);
1700
 
+       
1701
 
+       /**
1702
 
+        * sorts emoticons for convenient parsing, which yields greedy matching on
1703
 
+        * matchText
1704
 
+        */
1705
 
+       void sortEmoticons();
1706
 
+
1707
 
+
1708
 
+       struct Emoticon;
1709
 
+       struct EmoticonNode;
1710
 
+       class Private;
1711
 
+       Private *d;
1712
 
+private slots:
1713
 
+
1714
 
+       /**
1715
 
+        * Fills the map with paths and emoticons
1716
 
+        * This needs to be done on every emoticon-theme change
1717
 
+        **/
1718
 
+       void initEmoticons ( const QString &theme = QString::null );
1719
 
+};
1720
 
+
1721
 
+
1722
 
+} //END namespace Kopete
1723
 
+
1724
 
+#endif
1725
 
+// vim: set noet ts=4 sts=4 sw=4: