• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

kontact

  • sources
  • kde-4.14
  • kdepim
  • kontact
  • src
kcmkontact.cpp
Go to the documentation of this file.
1 /*
2  This file is part of KDE Kontact.
3 
4  Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License along
17  with this program; if not, write to the Free Software Foundation, Inc.,
18  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 
20  As a special exception, permission is given to link this program
21  with any edition of Qt, and distribute the resulting executable,
22  without including the source code for Qt in the source distribution.
23 */
24 
25 #include "kcmkontact.h"
26 #include "prefs.h"
27 using namespace Kontact;
28 
29 #include <KontactInterface/Plugin>
30 
31 #include <KAboutData>
32 #include <KComboBox>
33 #include <KServiceTypeTrader>
34 
35 #include <QCheckBox>
36 #include <QHBoxLayout>
37 #include <QVBoxLayout>
38 
39 extern "C"
40 {
41 KDE_EXPORT KCModule *create_kontactconfig( QWidget *parent, const char * )
42 {
43  KComponentData inst( "kcmkontact" );
44  return new KcmKontact( inst, parent );
45 }
46 }
47 
48 KcmKontact::KcmKontact( const KComponentData &inst, QWidget *parent )
49  : KPrefsModule( Prefs::self(), inst, parent )
50 {
51  QBoxLayout *topLayout = new QVBoxLayout( this );
52  QBoxLayout *pluginStartupLayout = new QHBoxLayout();
53  topLayout->addItem( pluginStartupLayout );
54  topLayout->addStretch();
55 
56  KPrefsWidBool *forceStartupPlugin =
57  addWidBool( Prefs::self()->forceStartupPluginItem(), this );
58  pluginStartupLayout->addWidget( forceStartupPlugin->checkBox() );
59 
60  PluginSelection *selection =
61  new PluginSelection( Prefs::self()->forcedStartupPluginItem(), this );
62  addWid( selection );
63 
64  pluginStartupLayout->addWidget( selection->comboBox() );
65  selection->comboBox()->setEnabled( false );
66 
67  pluginStartupLayout->addStretch( 1 );
68 
69  connect( forceStartupPlugin->checkBox(), SIGNAL(toggled(bool)),
70  selection->comboBox(), SLOT(setEnabled(bool)) );
71  load();
72 }
73 
74 const KAboutData *KcmKontact::aboutData() const
75 {
76  KAboutData *about = new KAboutData(
77  "kontactconfig", 0,
78  ki18nc( "@title", "KDE Kontact" ),
79  0,
80  KLocalizedString(),
81  KAboutData::License_GPL,
82  ki18nc( "@info:credit", "(c), 2003 Cornelius Schumacher" ) );
83 
84  about->addAuthor( ki18nc( "@info:credit", "Cornelius Schumacher" ),
85  ki18nc( "@info:credit", "Developer" ),
86  "schumacher@kde.org" );
87  about->addAuthor( ki18nc( "@info:credit", "Tobias Koenig" ),
88  ki18nc( "@info:credit", "Developer" ),
89  "tokoe@kde.org" );
90 
91  return about;
92 }
93 
94 PluginSelection::PluginSelection( KConfigSkeleton::ItemString *item, QWidget *parent )
95 {
96  mItem = item;
97  mPluginCombo = new KComboBox( parent );
98  mPluginCombo->setToolTip(
99  i18nc( "@info:tooltip", "Select the initial plugin to use on each start" ) );
100  mPluginCombo->setWhatsThis(
101  i18nc( "@info:whatsthis",
102  "Select the plugin from this drop down list to be used as the "
103  "initial plugin each time Kontact is started. Otherwise, Kontact "
104  "will restore the last active plugin from the previous usage." ) );
105  connect( mPluginCombo, SIGNAL(currentIndexChanged(int)), SIGNAL(changed()) );
106 }
107 
108 PluginSelection::~PluginSelection()
109 {
110 }
111 
112 void PluginSelection::readConfig()
113 {
114  const KService::List offers = KServiceTypeTrader::self()->query(
115  QString::fromLatin1( "Kontact/Plugin" ),
116  QString::fromLatin1( "[X-KDE-KontactPluginVersion] == %1" ).arg( KONTACT_PLUGIN_VERSION ) );
117 
118  int activeComponent = 0;
119  mPluginCombo->clear();
120  mPluginList.clear();
121  KService::List::ConstIterator end( offers.end() );
122  for ( KService::List::ConstIterator it = offers.begin(); it != end; ++it ) {
123  KService::Ptr service = *it;
124  // skip summary only plugins
125  QVariant var = service->property( QLatin1String("X-KDE-KontactPluginHasPart") );
126  if ( var.isValid() && var.toBool() == false ) {
127  continue;
128  }
129  mPluginCombo->addItem( service->name() );
130  mPluginList.append( service );
131 
132  if ( service->property( QLatin1String("X-KDE-PluginInfo-Name") ).toString() == mItem->value() ) {
133  activeComponent = mPluginList.count() - 1;
134  }
135  }
136 
137  mPluginCombo->setCurrentIndex( activeComponent );
138 }
139 
140 void PluginSelection::writeConfig()
141 {
142  KService::Ptr ptr = mPluginList.at( mPluginCombo->currentIndex() );
143  mItem->setValue( ptr->property( QLatin1String("X-KDE-PluginInfo-Name") ).toString() );
144 }
145 
146 QList<QWidget *> PluginSelection::widgets() const
147 {
148  QList<QWidget *> widgets;
149  widgets.append( mPluginCombo );
150 
151  return widgets;
152 }
KPIM::KPrefsModule::load
void load()
QWidget
kcmkontact.h
Kontact::KcmKontact::aboutData
virtual const KAboutData * aboutData() const
Definition: kcmkontact.cpp:74
KPIM::KPrefsWidBool::checkBox
QCheckBox * checkBox()
QHBoxLayout
Kontact::PluginSelection::widgets
QList< QWidget * > widgets() const
Definition: kcmkontact.cpp:146
Kontact::PluginSelection
Definition: kcmkontact.h:45
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
QList::append
void append(const T &value)
KPIM::KPrefsWidBool
Kontact::PluginSelection::readConfig
void readConfig()
Definition: kcmkontact.cpp:112
QBoxLayout::addItem
virtual void addItem(QLayoutItem *item)
KPIM::KPrefsModule
QVBoxLayout
KPIM::KPrefsWid::changed
void changed()
QList
KPIM::KPrefsModule::addWid
virtual void addWid(KPrefsWid *)
Kontact::PluginSelection::~PluginSelection
~PluginSelection()
Definition: kcmkontact.cpp:108
Kontact::KcmKontact
Definition: kcmkontact.h:35
create_kontactconfig
KCModule * create_kontactconfig(QWidget *parent, const char *)
Definition: kcmkontact.cpp:41
QLatin1String
QBoxLayout::addStretch
void addStretch(int stretch)
KComboBox
QVariant::toBool
bool toBool() const
QString::fromLatin1
QString fromLatin1(const char *str, int size)
QVariant::isValid
bool isValid() const
Kontact::PluginSelection::comboBox
KComboBox * comboBox() const
Definition: kcmkontact.h:57
Kontact::PluginSelection::PluginSelection
PluginSelection(KConfigSkeleton::ItemString *item, QWidget *parent)
Definition: kcmkontact.cpp:94
Kontact::PluginSelection::writeConfig
void writeConfig()
Definition: kcmkontact.cpp:140
Kontact::KcmKontact::KcmKontact
KcmKontact(const KComponentData &inst, QWidget *parent=0)
Definition: kcmkontact.cpp:48
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QBoxLayout
KCModule
QVariant
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:11 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kontact

Skip menu "kontact"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal