kopete/kopete
behaviorconfig.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
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
00052 layout->setContentsMargins( 0, 0, 0, 0);
00053
00054 mBehaviorTabCtl = new QTabWidget(this);
00055 mBehaviorTabCtl->setObjectName("mBehaviorTabCtl");
00056 layout->addWidget( mBehaviorTabCtl );
00057
00058
00059 mPrfsGeneral = new BehaviorConfig_General(mBehaviorTabCtl);
00060 addConfig( Kopete::BehaviorSettings::self(), mPrfsGeneral );
00061 mBehaviorTabCtl->addTab(mPrfsGeneral, i18n("&General"));
00062
00063
00064 mPrfsEvents = new BehaviorConfig_Events(mBehaviorTabCtl);
00065 addConfig( Kopete::BehaviorSettings::self(), mPrfsEvents );
00066 mBehaviorTabCtl->addTab(mPrfsEvents, i18n("&Events"));
00067
00068
00069 mPrfsAway = new BehaviorConfig_Away(mBehaviorTabCtl);
00070 addConfig( Kopete::BehaviorSettings::self(), mPrfsAway );
00071 mBehaviorTabCtl->addTab(mPrfsAway, i18n("A&way Settings"));
00072
00073
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
00084 connect( mPrfsChat->viewPlugin, SIGNAL(activated(int)),
00085 this, SLOT(slotValueChanged(int)));
00086
00087
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
00097
00098 KCModule::save();
00099
00100
00101 Kopete::BehaviorSettings::self()->setAutoAwayTimeout( mPrfsAway->mAutoAwayTimeout->value() * 60 );
00102 Kopete::BehaviorSettings::self()->setAutoAwayCustomMessage( mPrfsAway->mAutoAwayCustomMessage->toPlainText() );
00103
00104
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
00119 if(!mPrfsGeneral->kcfg_useMessageQueue->isChecked() && !mPrfsGeneral->kcfg_useMessageStack->isChecked()) {
00120 mPrfsGeneral->mInstantMessageOpeningChk->setChecked(true);
00121 }
00122
00123
00124 mPrfsAway->mAutoAwayTimeout->setValue( Kopete::BehaviorSettings::self()->autoAwayTimeout() / 60 );
00125 mPrfsAway->mAutoAwayCustomMessage->setPlainText( Kopete::BehaviorSettings::self()->autoAwayCustomMessage() );
00126
00127
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