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

akonadi

  • sources
  • kde-4.14
  • kdepimlibs
  • akonadi
  • contact
  • kcm
kcmakonadicontactactions.cpp
1 /*
2  This file is part of Akonadi Contact.
3 
4  Copyright (c) 2013 Laurent Montel <montel@kde.org>
5  Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
6 
7  This library is free software; you can redistribute it and/or modify it
8  under the terms of the GNU Library General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version.
11 
12  This library is distributed in the hope that it will be useful, but WITHOUT
13  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
15  License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to the
19  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20  02110-1301, USA.
21 */
22 
23 #include "kcmakonadicontactactions.h"
24 
25 #include "contactactionssettings.h"
26 
27 #include <QVBoxLayout>
28 
29 #include <kaboutdata.h>
30 #include <kcomponentdata.h>
31 #include <kconfigdialogmanager.h>
32 #include <kpluginfactory.h>
33 #include <klocalizedstring.h>
34 
35 Q_DECLARE_METATYPE(ContactActionsSettings::EnumDialPhoneNumberAction)
36 
37 K_PLUGIN_FACTORY(KCMAkonadiContactActionsFactory, registerPlugin<KCMAkonadiContactActions>();)
38 K_EXPORT_PLUGIN(KCMAkonadiContactActionsFactory("kcm_akonadicontact_actions"))
39 
40 KCMAkonadiContactActions::KCMAkonadiContactActions(QWidget *parent, const QVariantList &args)
41  : KCModule(KCMAkonadiContactActionsFactory::componentData(), parent)
42 {
43  KAboutData *about = new KAboutData(I18N_NOOP("kcmakonadicontactactions"), 0,
44  ki18n("Contact Actions Settings"),
45  0, KLocalizedString(), KAboutData::License_LGPL,
46  ki18n("(c) 2009 Tobias Koenig"));
47 
48  about->addAuthor(ki18n("Tobias Koenig"), KLocalizedString(), "tokoe@kde.org");
49 
50  setAboutData(about);
51 
52  QVBoxLayout *layout = new QVBoxLayout(this);
53  QWidget *wdg = new QWidget;
54  layout->addWidget(wdg);
55 
56  ui.setupUi(wdg);
57 
58  mConfigManager = addConfig(ContactActionsSettings::self(), wdg);
59 
60  ui.DialPhoneNumberAction->addItem(i18n("Skype"), ContactActionsSettings::UseSkype);
61  ui.DialPhoneNumberAction->addItem(i18n("Ekiga"), ContactActionsSettings::UseEkiga);
62  ui.DialPhoneNumberAction->addItem(i18n("SflPhone"), ContactActionsSettings::UseSflPhone);
63  ui.DialPhoneNumberAction->addItem(i18n("External Application"), ContactActionsSettings::UseExternalPhoneApplication);
64 
65  connect(ui.DialPhoneNumberAction, SIGNAL(currentIndexChanged(int)), SLOT(slotDialPhoneNumberActionChanged(int)));
66 
67  ui.SendSmsAction->addItem(i18n("Skype"), ContactActionsSettings::UseSkypeSms);
68  ui.SendSmsAction->addItem(i18n("SflPhone"), ContactActionsSettings::UseSflPhoneSms);
69  ui.SendSmsAction->addItem(i18n("External Application"), ContactActionsSettings::UseExternalSmsApplication);
70  connect(ui.SendSmsAction, SIGNAL(currentIndexChanged(int)), SLOT(slotSmsPhoneNumberActionChanged(int)));
71 
72  ui.ShowAddressAction->addItem(i18n("Web Browser"), ContactActionsSettings::UseBrowser);
73  ui.ShowAddressAction->addItem(i18n("External Application"), ContactActionsSettings::UseExternalAddressApplication);
74  ui.ShowAddressAction->addItem(i18n("Google map"), ContactActionsSettings::UseGooglemap);
75  ui.ShowAddressAction->addItem(i18n("Map quest"), ContactActionsSettings::UseMapquest);
76 
77  connect(ui.ShowAddressAction, SIGNAL(currentIndexChanged(int)), SLOT(slotShowAddressActionChanged(int)));
78 
79  load();
80 }
81 
82 void KCMAkonadiContactActions::slotShowAddressActionChanged(int value)
83 {
84  ContactActionsSettings::EnumShowAddressAction enumValue = static_cast<ContactActionsSettings::EnumShowAddressAction>(ui.ShowAddressAction->itemData(value).toInt());
85  if (enumValue == ContactActionsSettings::UseBrowser) {
86  ui.stackedWidget->setCurrentIndex(0);
87  } else if (enumValue == ContactActionsSettings::UseExternalAddressApplication) {
88  ui.stackedWidget->setCurrentIndex(1);
89  } else {
90  ui.stackedWidget->setCurrentIndex(2);
91  }
92  emit changed(true);
93 }
94 
95 void KCMAkonadiContactActions::slotSmsPhoneNumberActionChanged(int value)
96 {
97  ContactActionsSettings::EnumSendSmsAction enumValue = static_cast<ContactActionsSettings::EnumSendSmsAction>(ui.SendSmsAction->itemData(value).toInt());
98  if (enumValue == ContactActionsSettings::UseExternalSmsApplication) {
99  ui.stackedWidget_3->setCurrentIndex(1);
100  } else {
101  ui.stackedWidget_3->setCurrentIndex(0);
102  }
103  emit changed(true);
104 }
105 
106 void KCMAkonadiContactActions::slotDialPhoneNumberActionChanged(int value)
107 {
108  ContactActionsSettings::EnumDialPhoneNumberAction enumValue = static_cast<ContactActionsSettings::EnumDialPhoneNumberAction>(ui.DialPhoneNumberAction->itemData(value).toInt());
109  if (enumValue == ContactActionsSettings::UseExternalPhoneApplication) {
110  ui.stackedWidget_2->setCurrentIndex(1);
111  } else {
112  ui.stackedWidget_2->setCurrentIndex(0);
113  }
114  emit changed(true);
115 }
116 
117 void KCMAkonadiContactActions::load()
118 {
119  mConfigManager->updateWidgets();
120 
121  ContactActionsSettings::EnumShowAddressAction enumValueAddress = static_cast<ContactActionsSettings::EnumShowAddressAction>(ContactActionsSettings::self()->showAddressAction());
122  const int indexAddress = ui.ShowAddressAction->findData(enumValueAddress);
123  ui.ShowAddressAction->setCurrentIndex(indexAddress);
124 
125  ContactActionsSettings::EnumDialPhoneNumberAction enumValue = static_cast<ContactActionsSettings::EnumDialPhoneNumberAction>(ContactActionsSettings::self()->dialPhoneNumberAction());
126  const int index = ui.DialPhoneNumberAction->findData(enumValue);
127  ui.DialPhoneNumberAction->setCurrentIndex(index);
128 
129  ContactActionsSettings::EnumSendSmsAction enumValueSms = static_cast<ContactActionsSettings::EnumSendSmsAction>(ContactActionsSettings::self()->sendSmsAction());
130  const int indexSms = ui.SendSmsAction->findData(enumValueSms);
131  ui.SendSmsAction->setCurrentIndex(indexSms);
132 
133 }
134 
135 void KCMAkonadiContactActions::save()
136 {
137  mConfigManager->updateSettings();
138  ContactActionsSettings::EnumShowAddressAction enumValueAddress = static_cast<ContactActionsSettings::EnumShowAddressAction>(ui.ShowAddressAction->itemData(ui.ShowAddressAction->currentIndex()).toInt());
139  ContactActionsSettings::self()->setShowAddressAction(enumValueAddress);
140 
141  ContactActionsSettings::EnumDialPhoneNumberAction enumValue = static_cast<ContactActionsSettings::EnumDialPhoneNumberAction>(ui.DialPhoneNumberAction->itemData(ui.DialPhoneNumberAction->currentIndex()).toInt());
142  ContactActionsSettings::self()->setDialPhoneNumberAction(enumValue);
143 
144  ContactActionsSettings::EnumSendSmsAction enumValueSms = static_cast<ContactActionsSettings::EnumSendSmsAction>(ui.SendSmsAction->itemData(ui.SendSmsAction->currentIndex()).toInt());
145  ContactActionsSettings::self()->setSendSmsAction(enumValueSms);
146  ContactActionsSettings::self()->writeConfig();
147 }
148 
149 void KCMAkonadiContactActions::defaults()
150 {
151  mConfigManager->updateWidgetsDefault();
152  const bool bUseDefaults = ContactActionsSettings::self()->useDefaults(true);
153  ui.DialPhoneNumberAction->setCurrentIndex(ContactActionsSettings::self()->dialPhoneNumberAction());
154  ui.SendSmsAction->setCurrentIndex(ContactActionsSettings::self()->sendSmsAction());
155  ui.ShowAddressAction->setCurrentIndex(ContactActionsSettings::self()->showAddressAction());
156  ContactActionsSettings::self()->useDefaults(bUseDefaults);
157 }
QWidget
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
QVBoxLayout
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:38:03 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2

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