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
164
+ appearanceconfig.cpp - Kopete Look Feel Config
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>
169
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
171
+ *************************************************************************
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. *
178
+ *************************************************************************
181
+#ifdef HAVE_CONFIG_H
185
+#include "appearanceconfig.h"
186
+#include "appearanceconfig_emoticons.h"
187
+#include "appearanceconfig_chatwindow.h"
188
+#include "appearanceconfig_colors.h"
189
+#include "appearanceconfig_contactlist.h"
191
+#include "tooltipeditdialog.h"
193
+#include <qcheckbox.h>
195
+#include <qlayout.h>
196
+#include <qhbuttongroup.h>
197
+#include <qspinbox.h>
198
+#include <qslider.h>
201
+#include <kdeversion.h>
202
+#include <kinputdialog.h>
204
+#include <kapplication.h>
205
+#include <kcolorcombo.h>
206
+#include <kcolorbutton.h>
207
+#include <kconfig.h> // for KNewStuff emoticon fetching
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>
222
+#include <kfiledialog.h>
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> // "
230
+// For Kopete Chat Window Style configuration and preview.
231
+#include <kopetechatwindowstylemanager.h>
232
+#include <kopetechatwindowstyle.h>
233
+#include <chatmessagepart.h>
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>
244
+#include "kopeteprefs.h"
245
+#include "kopeteemoticons.h"
246
+#include "kopeteglobal.h"
248
+#include <qtabwidget.h>
250
+typedef KGenericFactory<AppearanceConfig, QWidget> KopeteAppearanceConfigFactory;
251
+K_EXPORT_COMPONENT_FACTORY( kcm_kopete_appearanceconfig, KopeteAppearanceConfigFactory( "kcm_kopete_appearanceconfig" ) )
257
+class AppearanceConfig::Private
261
+ : mAppearanceTabCtl(0L), preview(0L), mPrfsEmoticons(0L),mPrfsChatWindow(0L),
262
+ mPrfsColors(0L), mPrfsContactList(0L), currentStyle(0L), loading(false),
263
+ styleChanged(false)
266
+ QTabWidget *mAppearanceTabCtl;
268
+ ChatMessagePart *preview;
269
+ AppearanceConfig_Emoticons *mPrfsEmoticons;
270
+ AppearanceConfig_ChatWindow *mPrfsChatWindow;
271
+ AppearanceConfig_Colors *mPrfsColors;
272
+ AppearanceConfig_ContactList *mPrfsContactList;
274
+ // value is the style path
275
+ QMap<QListBoxItem*,QString> styleItemMap;
276
+ ChatWindowStyle::StyleVariants currentVariantMap;
277
+ ChatWindowStyle *currentStyle;
281
+ // For style preview
282
+ FakeProtocol *previewProtocol;
283
+ FakeAccount *previewAccount;
284
+ Kopete::MetaContact *myselfMetaContact;
285
+ Kopete::MetaContact *jackMetaContact;
286
+ FakeContact *myself;
288
+ Kopete::ChatSession *previewChatSession;
291
+class KopeteStyleNewStuff : public KNewStuff
294
+ KopeteStyleNewStuff(const QString &type, QWidget *parentWidget = 0)
295
+ : KNewStuff( type, parentWidget)
298
+ bool createUploadFile(const QString &)
303
+ bool install(const QString &styleFilename)
305
+ int styleInstallReturn = 0;
306
+ styleInstallReturn = ChatWindowStyleManager::self()->installStyle( styleFilename );
308
+ switch(styleInstallReturn)
310
+ case ChatWindowStyleManager::StyleInstallOk:
312
+ KMessageBox::queuedMessageBox( this->parentWidget(), KMessageBox::Information, i18n("The Chat Window style was successfully installed."), i18n("Install successful") );
315
+ case ChatWindowStyleManager::StyleCannotOpen:
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") );
320
+ case ChatWindowStyleManager::StyleNoDirectoryValid:
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") );
325
+ case ChatWindowStyleManager::StyleNotValid:
327
+ KMessageBox::queuedMessageBox( this->parentWidget(), KMessageBox::Error, i18n("The specified archive does not contain a valid Chat Window style."), i18n("Invalid Style") );
331
+ case ChatWindowStyleManager::StyleUnknow:
334
+ KMessageBox::queuedMessageBox( this->parentWidget(), KMessageBox::Error, i18n("An unknow error occurred while trying to install the Chat Window style."), i18n("Unknow error") );
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 )
348
+ (new QVBoxLayout(this))->setAutoAdd(true);
349
+ d->mAppearanceTabCtl = new QTabWidget(this, "mAppearanceTabCtl");
351
+ KConfig *config = KGlobal::config();
352
+ config->setGroup( "ChatWindowSettings" );
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()));
365
+ connect(d->mPrfsEmoticons->btnGetThemes, SIGNAL(clicked()),
366
+ this, SLOT(slotGetEmoticonThemes()));
367
+ connect(d->mPrfsEmoticons->btnRemoveTheme, SIGNAL(clicked()),
368
+ this, SLOT(removeSelectedEmoticonTheme()));
370
+ d->mAppearanceTabCtl->addTab(d->mPrfsEmoticons, i18n("&Emoticons"));
372
+ // "Chat Window" TAB ========================================================
373
+ d->mPrfsChatWindow = new AppearanceConfig_ChatWindow(d->mAppearanceTabCtl);
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()));
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();
409
+ d->mAppearanceTabCtl->addTab( d->mPrfsChatWindow, i18n("Chat Window") );
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()));
440
+ // don't enable the checkbox if XRender is not available
441
+ #ifdef HAVE_XRENDER
442
+ d->mPrfsContactList->mFadeVisibility->setEnabled(true);
444
+ d->mPrfsContactList->mFadeVisibility->setEnabled(false);
447
+ d->mAppearanceTabCtl->addTab(d->mPrfsContactList, i18n("Contact List"));
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()));
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()));
483
+ d->mAppearanceTabCtl->addTab(d->mPrfsColors, i18n("Colors && Fonts"));
485
+ // ==========================================================================
490
+AppearanceConfig::~AppearanceConfig()
495
+void AppearanceConfig::updateEmoticonsButton(bool _b)
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 );
503
+void AppearanceConfig::save()
505
+// kdDebug(14000) << k_funcinfo << "called." << endl;
506
+ KopetePrefs *p = KopetePrefs::prefs();
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() );
513
+ // "Chat Window" TAB ========================================================
514
+ p->setGroupConsecutiveMessages( d->mPrfsChatWindow->groupConsecutiveMessages->isChecked() );
516
+ // Get the stylePath
517
+ if(d->currentStyle)
519
+ kdDebug(14000) << k_funcinfo << d->currentStyle->getStylePath() << endl;
520
+ p->setStylePath(d->currentStyle->getStylePath());
522
+ // Get and save the styleVariant
523
+ if( !d->currentVariantMap.empty() )
525
+ kdDebug(14000) << k_funcinfo << d->currentVariantMap[ d->mPrfsChatWindow->variantList->currentText()] << endl;
526
+ p->setStyleVariant(d->currentVariantMap[ d->mPrfsChatWindow->variantList->currentText()]);
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());
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());
557
+ p->setBgOverride( d->mPrfsColors->mBgOverride->isChecked() );
558
+ p->setFgOverride( d->mPrfsColors->mFgOverride->isChecked() );
559
+ p->setRtfOverride( d->mPrfsColors->mRtfOverride->isChecked() );
562
+ d->styleChanged = false;
565
+void AppearanceConfig::load()
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.
571
+// kdDebug(14000) << k_funcinfo << "called" << endl;
572
+ KopetePrefs *p = KopetePrefs::prefs();
574
+ // "Emoticons" TAB ==========================================================
575
+ updateEmoticonlist();
576
+ d->mPrfsEmoticons->chkUseEmoticons->setChecked( p->useEmoticons() );
577
+ d->mPrfsEmoticons->chkRequireSpaces->setChecked( p->emoticonsRequireSpaces() );
579
+ // "Chat Window" TAB ========================================================
580
+ d->mPrfsChatWindow->groupConsecutiveMessages->setChecked( p->groupConsecutiveMessages() );
581
+ // Look for avaiable chat window styles.
582
+ slotLoadChatStyles();
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() );
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 );
596
+ d->mPrfsContactList->mDisplayMode->setButton( p->contactListDisplayMode() );
597
+ d->mPrfsContactList->mIconMode->setChecked( p->contactListIconMode() == KopetePrefs::PhotoPic);
600
+ d->mPrfsContactList->mAnimateChanges->setChecked( p->contactListAnimation() );
602
+ d->mPrfsContactList->mFadeVisibility->setChecked( p->contactListFading() );
604
+ d->mPrfsContactList->mFadeVisibility->setChecked( false );
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() );
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());
625
+ d->mPrfsColors->mBgOverride->setChecked( p->bgOverride() );
626
+ d->mPrfsColors->mFgOverride->setChecked( p->fgOverride() );
627
+ d->mPrfsColors->mRtfOverride->setChecked( p->rtfOverride() );
630
+ slotUpdateChatPreview();
633
+void AppearanceConfig::slotLoadChatStyles()
635
+ d->mPrfsChatWindow->styleList->clear();
636
+ d->styleItemMap.clear();
638
+ ChatWindowStyleManager::StyleList availableStyles;
639
+ availableStyles = ChatWindowStyleManager::self()->getAvailableStyles();
640
+ if( availableStyles.empty() )
641
+ kdDebug(14000) << k_funcinfo << "Warning, available styles is empty !" << endl;
643
+ ChatWindowStyleManager::StyleList::ConstIterator it, itEnd = availableStyles.constEnd();
644
+ for(it = availableStyles.constBegin(); it != itEnd; ++it)
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() );
651
+ if( it.data() == KopetePrefs::prefs()->stylePath() )
653
+ kdDebug(14000) << k_funcinfo << "Restoring saved style: " << it.key() << endl;
655
+ d->mPrfsChatWindow->styleList->setSelected( d->mPrfsChatWindow->styleList->firstItem(), true );
659
+ d->mPrfsChatWindow->styleList->sort();
662
+void AppearanceConfig::updateEmoticonlist()
664
+ KopetePrefs *p = KopetePrefs::prefs();
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++)
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++)
678
+ QStringList themes = themeQDir.entryList(QDir::Dirs, QDir::Name);
679
+ // We don't care for '.' and '..'
680
+ if ( themeQDir[y] != "." && themeQDir[y] != ".." )
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]);
689
+ // Where is that theme in our big-list-o-themes?
690
+ QListBoxItem *item = d->mPrfsEmoticons->icon_theme_list->findItem( p->iconTheme() );
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 );
698
+void AppearanceConfig::slotSelectedEmoticonsThemeChanged()
700
+ QString themeName = d->mPrfsEmoticons->icon_theme_list->currentText();
701
+ QFileInfo fileInf(KGlobal::dirs()->findResource("emoticons", themeName+"/"));
702
+ d->mPrfsEmoticons->btnRemoveTheme->setEnabled( fileInf.isWritable() );
704
+ Kopete::Emoticons emoticons( themeName );
705
+ QStringList smileys = emoticons.emoticonAndPicList().keys();
706
+ QString newContentText = "<qt>";
708
+ for(QStringList::Iterator it = smileys.begin(); it != smileys.end(); ++it )
709
+ newContentText += QString::fromLatin1("<img src=\"%1\"> ").arg(*it);
711
+ newContentText += QString::fromLatin1("</qt>");
712
+ d->mPrfsEmoticons->icon_theme_preview->setText(newContentText);
716
+void AppearanceConfig::slotHighlightChanged()
718
+// bool value = mPrfsChatWindow->highlightEnabled->isChecked();
719
+// mPrfsChatWindow->foregroundColor->setEnabled ( value );
720
+// mPrfsChatWindow->backgroundColor->setEnabled ( value );
721
+ slotUpdateChatPreview();
724
+void AppearanceConfig::slotChangeFont()
726
+ slotUpdateChatPreview();
730
+void AppearanceConfig::slotChatStyleSelected()
732
+ // Retrieve variant list.
733
+ QString stylePath = d->styleItemMap[d->mPrfsChatWindow->styleList->selectedItem()];
734
+ d->currentStyle = ChatWindowStyleManager::self()->getStyleFromPool( stylePath );
736
+ if(d->currentStyle)
738
+ d->currentVariantMap = d->currentStyle->getVariants();
739
+ kdDebug(14000) << k_funcinfo << "Loading style: " << d->currentStyle->getStylePath() << endl;
741
+ // Update the variant list based on current style.
742
+ d->mPrfsChatWindow->variantList->clear();
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)") );
749
+ ChatWindowStyle::StyleVariants::ConstIterator it, itEnd = d->currentVariantMap.constEnd();
750
+ int currentIndex = 0;
751
+ for(it = d->currentVariantMap.constBegin(); it != itEnd; ++it)
753
+ // Insert variant name into the combobox.
754
+ d->mPrfsChatWindow->variantList->insertItem( it.key() );
756
+ if( it.data() == KopetePrefs::prefs()->styleVariant() )
757
+ d->mPrfsChatWindow->variantList->setCurrentItem(currentIndex+1);
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]);
773
+void AppearanceConfig::slotChatStyleVariantSelected(const QString &variantName)
775
+// kdDebug(14000) << k_funcinfo << variantName << endl;
776
+// kdDebug(14000) << k_funcinfo << d->currentVariantMap[variantName] << endl;
778
+ // Update the preview
779
+ d->preview->setStyleVariant(d->currentVariantMap[variantName]);
783
+void AppearanceConfig::slotInstallChatStyle()
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.") );
787
+ if( !styleToInstall.isEmpty() )
790
+ if( KIO::NetAccess::download( styleToInstall, stylePath, this ) )
792
+ int styleInstallReturn = 0;
793
+ styleInstallReturn = ChatWindowStyleManager::self()->installStyle( stylePath );
794
+ switch(styleInstallReturn)
796
+ case ChatWindowStyleManager::StyleCannotOpen:
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") );
801
+ case ChatWindowStyleManager::StyleNoDirectoryValid:
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") );
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") );
809
+ case ChatWindowStyleManager::StyleInstallOk:
811
+ KMessageBox::queuedMessageBox( this, KMessageBox::Information, i18n("The Chat Window style was successfully installed."), i18n("Install successful") );
814
+ case ChatWindowStyleManager::StyleUnknow:
817
+ KMessageBox::queuedMessageBox( this, KMessageBox::Error, i18n("An unknow error occurred while trying to install the Chat Window style."), i18n("Unknow error") );
822
+ // removeTempFile check if the file is a temp file, so it's ok for local files.
823
+ KIO::NetAccess::removeTempFile( stylePath );
828
+void AppearanceConfig::slotDeleteChatStyle()
830
+ QString styleName = d->mPrfsChatWindow->styleList->selectedItem()->text();
831
+ QString stylePathToDelete = d->styleItemMap[d->mPrfsChatWindow->styleList->selectedItem()];
832
+ if( ChatWindowStyleManager::self()->removeStyle(stylePathToDelete) )
834
+ KMessageBox::queuedMessageBox(this, KMessageBox::Information, i18n("It's the deleted style name", "The style %1 was successfully deleted.").arg(styleName));
836
+ // Get the first item in the stye List.
837
+ QString stylePath = (*d->styleItemMap.begin());
838
+ d->currentStyle = ChatWindowStyleManager::self()->getStyleFromPool(stylePath);
843
+ KMessageBox::queuedMessageBox(this, KMessageBox::Information, i18n("It's the deleted style name", "An error occurred while trying to delete %1 style.").arg(styleName));
847
+void AppearanceConfig::slotGetChatStyles()
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();
861
+// Reimplement Kopete::Contact and its abstract method
862
+// This is for style preview.
863
+class FakeContact : public Kopete::Contact
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() {};
871
+// This is for style preview.
872
+class FakeProtocol : public Kopete::Protocol
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;}
881
+// This is for style preview.
882
+class FakeAccount : public Kopete::Account
885
+FakeAccount(Kopete::Protocol *parent, const QString &accountID, const char *name) : Kopete::Account(parent, accountID, name){}
888
+bool createContact( const QString &/*contactId*/, Kopete::MetaContact */*parentContact*/ ){return true;}
889
+void connect( const Kopete::OnlineStatus& /*initialStatus*/){}
891
+void setOnlineStatus( const Kopete::OnlineStatus& /*status*/ , const QString &/*reason*/){}
894
+void AppearanceConfig::createPreviewChatSession()
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);
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);
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");
918
+void AppearanceConfig::createPreviewMessages()
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 );
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 );
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 );
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);
953
+void AppearanceConfig::slotUpdateChatPreview()
955
+ if(d->loading || !d->currentStyle)
958
+ // Update the preview
959
+ d->preview->setStyle(d->currentStyle);
964
+void AppearanceConfig::emitChanged()
966
+ emit changed( true );
969
+void AppearanceConfig::installEmoticonTheme()
971
+ KURL themeURL = KURLRequesterDlg::getURL(QString::null, this,
972
+ i18n("Drag or Type Emoticon Theme URL"));
973
+ if ( themeURL.isEmpty() )
976
+ //TODO: support remote theme files!
977
+ if ( !themeURL.isLocalFile() )
979
+ KMessageBox::queuedMessageBox( this, KMessageBox::Error, i18n("Sorry, emoticon themes must be installed from local files."),
980
+ i18n("Could Not Install Emoticon Theme") );
984
+ Kopete::Global::installEmoticonTheme( themeURL.path() );
985
+ updateEmoticonlist();
988
+void AppearanceConfig::removeSelectedEmoticonTheme()
990
+ QListBoxItem *selected = d->mPrfsEmoticons->icon_theme_list->selectedItem();
994
+ QString themeName = selected->text();
996
+ QString question=i18n("<qt>Are you sure you want to remove the "
997
+ "<strong>%1</strong> emoticon theme?<br>"
999
+ "This will delete the files installed by this theme.</qt>").
1002
+ int res = KMessageBox::warningContinueCancel(this, question, i18n("Confirmation"),KStdGuiItem::del());
1003
+ if (res!=KMessageBox::Continue)
1006
+ KURL themeUrl(KGlobal::dirs()->findResource("emoticons", themeName+"/"));
1007
+ KIO::NetAccess::del(themeUrl, this);
1009
+ updateEmoticonlist();
1012
+void AppearanceConfig::slotGetEmoticonThemes()
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" );
1022
+#if ( KDE_IS_VERSION(3,3,90) )
1023
+ KNS::DownloadDialog::open( "emoticons", i18n( "Get New Emoticons") );
1025
+ KNS::DownloadDialog::open( i18n( "Get New Emoticons" ) );
1028
+ updateEmoticonlist();
1031
+void AppearanceConfig::slotEditTooltips()
1033
+ TooltipEditDialog *dlg = new TooltipEditDialog(this);
1034
+ connect(dlg, SIGNAL(changed(bool)), this, SIGNAL(changed(bool)));
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