23 #include "kcmakonadicontactactions.h"
25 #include "contactactionssettings.h"
27 #include <QVBoxLayout>
29 #include <kaboutdata.h>
30 #include <kcomponentdata.h>
31 #include <kconfigdialogmanager.h>
32 #include <kpluginfactory.h>
33 #include <klocalizedstring.h>
35 Q_DECLARE_METATYPE(ContactActionsSettings::EnumDialPhoneNumberAction)
37 K_PLUGIN_FACTORY( KCMAkonadiContactActionsFactory, registerPlugin<KCMAkonadiContactActions>(); )
38 K_EXPORT_PLUGIN( KCMAkonadiContactActionsFactory( "kcm_akonadicontact_actions" ) )
40 KCMAkonadiContactActions::KCMAkonadiContactActions( QWidget *parent, const QVariantList& )
41 : KCModule( KCMAkonadiContactActionsFactory::componentData(), parent )
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" ) );
48 about->addAuthor( ki18n(
"Tobias Koenig" ), KLocalizedString(),
"tokoe@kde.org" );
50 setAboutData( about );
52 QVBoxLayout *layout =
new QVBoxLayout(
this );
53 QWidget *wdg =
new QWidget;
54 layout->addWidget( wdg );
58 mConfigManager = addConfig( ContactActionsSettings::self(), wdg );
60 ui.DialPhoneNumberAction->addItem(i18n(
"Skype"), ContactActionsSettings::UseSkype);
61 ui.DialPhoneNumberAction->addItem(i18n(
"Ekiga"), ContactActionsSettings::UseEkiga);
62 ui.DialPhoneNumberAction->addItem(i18n(
"SflPhone"), ContactActionsSettings::UseSflPhone);
64 ui.DialPhoneNumberAction->addItem(i18n(
"WinCE"), ContactActionsSettings::UseWinCE);
66 ui.DialPhoneNumberAction->addItem(i18n(
"External Application"), ContactActionsSettings::UseExternalPhoneApplication);
68 connect(ui.DialPhoneNumberAction, SIGNAL(currentIndexChanged(
int)), SLOT(slotDialPhoneNumberActionChanged(
int)));
70 ui.SendSmsAction->addItem(i18n(
"Skype"), ContactActionsSettings::UseSkypeSms);
71 ui.SendSmsAction->addItem(i18n(
"SflPhone"), ContactActionsSettings::UseSflPhoneSms);
73 ui.SendSmsAction->addItem(i18n(
"WinCE"), ContactActionsSettings::UseWinCESms);
75 ui.SendSmsAction->addItem(i18n(
"External Application"), ContactActionsSettings::UseExternalSmsApplication);
76 connect(ui.SendSmsAction, SIGNAL(currentIndexChanged(
int)), SLOT(slotSmsPhoneNumberActionChanged(
int)));
80 void KCMAkonadiContactActions::slotSmsPhoneNumberActionChanged(
int value)
82 ContactActionsSettings::EnumSendSmsAction enumValue =
static_cast<ContactActionsSettings::EnumSendSmsAction
>(ui.SendSmsAction->itemData(value).toInt());
83 if (enumValue == ContactActionsSettings::UseExternalSmsApplication) {
84 ui.stackedWidget_3->setCurrentIndex(1);
86 ui.stackedWidget_3->setCurrentIndex(0);
91 void KCMAkonadiContactActions::slotDialPhoneNumberActionChanged(
int value)
93 ContactActionsSettings::EnumDialPhoneNumberAction enumValue =
static_cast<ContactActionsSettings::EnumDialPhoneNumberAction
>(ui.DialPhoneNumberAction->itemData(value).toInt());
94 if (enumValue == ContactActionsSettings::UseExternalPhoneApplication) {
95 ui.stackedWidget_2->setCurrentIndex(1);
97 ui.stackedWidget_2->setCurrentIndex(0);
102 void KCMAkonadiContactActions::load()
104 mConfigManager->updateWidgets();
105 ContactActionsSettings::EnumDialPhoneNumberAction enumValue =
static_cast<ContactActionsSettings::EnumDialPhoneNumberAction
>(ContactActionsSettings::self()->dialPhoneNumberAction());
106 const int index = ui.DialPhoneNumberAction->findData(enumValue);
107 ui.DialPhoneNumberAction->setCurrentIndex(index);
109 ContactActionsSettings::EnumSendSmsAction enumValueSms =
static_cast<ContactActionsSettings::EnumSendSmsAction
>(ContactActionsSettings::self()->sendSmsAction());
110 const int indexSms = ui.SendSmsAction->findData(enumValueSms);
111 ui.SendSmsAction->setCurrentIndex(indexSms);
115 void KCMAkonadiContactActions::save()
117 mConfigManager->updateSettings();
118 ContactActionsSettings::EnumDialPhoneNumberAction enumValue =
static_cast<ContactActionsSettings::EnumDialPhoneNumberAction
>(ui.DialPhoneNumberAction->itemData(ui.DialPhoneNumberAction->currentIndex()).toInt());
119 ContactActionsSettings::self()->setDialPhoneNumberAction(enumValue);
121 ContactActionsSettings::EnumSendSmsAction enumValueSms =
static_cast<ContactActionsSettings::EnumSendSmsAction
>(ui.SendSmsAction->itemData(ui.SendSmsAction->currentIndex()).toInt());
122 ContactActionsSettings::self()->setSendSmsAction(enumValueSms);
123 ContactActionsSettings::self()->writeConfig();
126 void KCMAkonadiContactActions::defaults()
128 mConfigManager->updateWidgetsDefault();
129 const bool bUseDefaults = ContactActionsSettings::self()->useDefaults(
true );
130 ui.DialPhoneNumberAction->setCurrentIndex(ContactActionsSettings::self()->dialPhoneNumberAction());
131 ui.SendSmsAction->setCurrentIndex(ContactActionsSettings::self()->sendSmsAction());
132 ContactActionsSettings::self()->useDefaults( bUseDefaults );