• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdenetwork
  • Sitemap
  • Contact Us
 

kopete/kopete

behaviorconfig.cpp

Go to the documentation of this file.
00001 /*
00002     behaviorconfig.cpp  -  Kopete Look Feel Config
00003 
00004     Kopete    (c) 2002-2005 by the Kopete developers  <kopete-devel@kde.org>
00005 
00006     *************************************************************************
00007     *                                                                       *
00008     * This program is free software; you can redistribute it and/or modify  *
00009     * it under the terms of the GNU General Public License as published by  *
00010     * the Free Software Foundation; either version 2 of the License, or     *
00011     * (at your option) any later version.                                   *
00012     *                                                                       *
00013     *************************************************************************
00014 */
00015 
00016 #include "behaviorconfig.h"
00017 #include "behaviorconfig_general.h"
00018 #include "behaviorconfig_events.h"
00019 #include "behaviorconfig_chat.h"
00020 #include "behaviorconfig_away.h"
00021 
00022 #include <qcheckbox.h>
00023 #include <qradiobutton.h>
00024 #include <qlayout.h>
00025 #include <qlabel.h>
00026 #include <qspinbox.h>
00027 #include <qcombobox.h>
00028 #include <QVBoxLayout>
00029 
00030 #include <kdebug.h>
00031 #include <kplugininfo.h>
00032 #include <klocale.h>
00033 #include <kpushbutton.h>
00034 #include <kgenericfactory.h>
00035 #include <kconfig.h>
00036 #include <klineedit.h>
00037 
00038 #include "kopetebehaviorsettings.h"
00039 #include "kopetepluginmanager.h"
00040 
00041 #include <qtabwidget.h>
00042 
00043 K_PLUGIN_FACTORY( KopeteBehaviorConfigFactory,
00044         registerPlugin<BehaviorConfig>(); )
00045 K_EXPORT_PLUGIN( KopeteBehaviorConfigFactory("kcm_kopete_behaviorconfig") )
00046 
00047 BehaviorConfig::BehaviorConfig(QWidget *parent, const QVariantList &args) :
00048         KCModule( KopeteBehaviorConfigFactory::componentData(), parent, args )
00049 {
00050     QVBoxLayout *layout = new QVBoxLayout(this);
00051     // since KSetting::Dialog has margins here, we don't need our own.
00052     layout->setContentsMargins( 0, 0, 0, 0);
00053     
00054     mBehaviorTabCtl = new QTabWidget(this);
00055     mBehaviorTabCtl->setObjectName("mBehaviorTabCtl");
00056     layout->addWidget( mBehaviorTabCtl );
00057 
00058     // "General" TAB ============================================================
00059     mPrfsGeneral = new BehaviorConfig_General(mBehaviorTabCtl);
00060     addConfig( Kopete::BehaviorSettings::self(), mPrfsGeneral );
00061     mBehaviorTabCtl->addTab(mPrfsGeneral, i18n("&General"));
00062 
00063     // "Events" TAB ============================================================
00064     mPrfsEvents = new BehaviorConfig_Events(mBehaviorTabCtl);
00065     addConfig( Kopete::BehaviorSettings::self(), mPrfsEvents );
00066     mBehaviorTabCtl->addTab(mPrfsEvents, i18n("&Events"));
00067 
00068     // "Away" TAB ===============================================================
00069     mPrfsAway = new BehaviorConfig_Away(mBehaviorTabCtl);
00070     addConfig( Kopete::BehaviorSettings::self(), mPrfsAway );
00071     mBehaviorTabCtl->addTab(mPrfsAway, i18n("A&way Settings"));
00072 
00073     // "Chat" TAB ===============================================================
00074     mPrfsChat = new BehaviorConfig_Chat(mBehaviorTabCtl);
00075     addConfig( Kopete::BehaviorSettings::self(), mPrfsChat );
00076     mBehaviorTabCtl->addTab(mPrfsChat, i18n("Cha&t"));
00077 
00078     Kopete::PluginManager *pluginManager = Kopete::PluginManager::self();
00079     viewPlugins = pluginManager->availablePlugins("Views");
00080 
00081     load();
00082 
00083     // "Chat" TAB ===============================================================
00084     connect( mPrfsChat->viewPlugin, SIGNAL(activated(int)),
00085          this, SLOT(slotValueChanged(int)));
00086 
00087     // "Away" TAB ===============================================================
00088     connect( mPrfsAway->mAutoAwayTimeout, SIGNAL(valueChanged(int)),
00089         this, SLOT(slotValueChanged(int)));;
00090     connect( mPrfsAway->mAutoAwayCustomMessage, SIGNAL(textChanged()),
00091              this, SLOT(slotTextChanged()) );
00092 }
00093 
00094 void BehaviorConfig::save()
00095 {
00096 //  kDebug(14000);
00097 
00098     KCModule::save();
00099 
00100     // "Away" TAB ===============================================================
00101     Kopete::BehaviorSettings::self()->setAutoAwayTimeout( mPrfsAway->mAutoAwayTimeout->value() * 60 );
00102     Kopete::BehaviorSettings::self()->setAutoAwayCustomMessage( mPrfsAway->mAutoAwayCustomMessage->toPlainText() );
00103 
00104     // "Chat" TAB ===============================================================
00105     if ( viewPlugins.size() > 0 )
00106     {
00107         Kopete::BehaviorSettings::self()->setViewPlugin(viewPlugins[mPrfsChat->viewPlugin->currentIndex()].pluginName() );
00108     }
00109 
00110     Kopete::BehaviorSettings::self()->writeConfig();
00111 
00112     load();
00113 }
00114 
00115 void BehaviorConfig::load()
00116 {
00117     KCModule::load();
00118     // "General" TAB ===============================================================
00119     if(!mPrfsGeneral->kcfg_useMessageQueue->isChecked() && !mPrfsGeneral->kcfg_useMessageStack->isChecked()) {
00120         mPrfsGeneral->mInstantMessageOpeningChk->setChecked(true);
00121     }
00122 
00123     // "Away" TAB ===============================================================
00124     mPrfsAway->mAutoAwayTimeout->setValue( Kopete::BehaviorSettings::self()->autoAwayTimeout() / 60 );
00125     mPrfsAway->mAutoAwayCustomMessage->setPlainText( Kopete::BehaviorSettings::self()->autoAwayCustomMessage() );
00126 
00127     // "Chat" TAB ===============================================================
00128     mPrfsChat->viewPlugin->clear();
00129     int selectedIdx = 0, i = 0;
00130     for(  QList<KPluginInfo>::iterator it = viewPlugins.begin(); it != viewPlugins.end(); ++it )
00131     {
00132         if( it->pluginName() == Kopete::BehaviorSettings::self()->viewPlugin() )
00133             selectedIdx = i;
00134         mPrfsChat->viewPlugin->insertItem( i++, it->name() );
00135     }
00136 
00137     mPrfsChat->viewPlugin->setCurrentIndex(selectedIdx);
00138 }
00139 
00140 void BehaviorConfig::slotSettingsChanged(bool)
00141 {
00142     emit changed(true);
00143 }
00144 
00145 void BehaviorConfig::slotValueChanged(int)
00146 {
00147     emit changed( true );
00148 }
00149 
00150 void BehaviorConfig::slotTextChanged()
00151 {
00152     emit changed( true );
00153 }
00154 
00155 #include "behaviorconfig.moc"
00156 // vim: set noet ts=4 sts=4 sw=4:

kopete/kopete

Skip menu "kopete/kopete"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdenetwork

Skip menu "kdenetwork"
  • kget
  • kopete
  •   kopete
  •   libkopete
  •       libpapillon
  • krfb
Generated for kdenetwork by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal