4 #include "contactactionssettings.h"
9 #include <QtCore/QFile>
11 class ContactActionsSettingsHelper
14 ContactActionsSettingsHelper() : q(0) {}
15 ~ContactActionsSettingsHelper() {
delete q; }
16 ContactActionsSettings *q;
18 K_GLOBAL_STATIC(ContactActionsSettingsHelper, s_globalContactActionsSettings)
19 ContactActionsSettings *ContactActionsSettings::self()
21 if (!s_globalContactActionsSettings->q) {
22 new ContactActionsSettings;
23 s_globalContactActionsSettings->q->readConfig();
26 return s_globalContactActionsSettings->q;
29 ContactActionsSettings::ContactActionsSettings( )
30 : KConfigSkeleton( QLatin1String(
"akonadi_contactrc" ) )
32 Q_ASSERT(!s_globalContactActionsSettings->q);
33 s_globalContactActionsSettings->q =
this;
34 setCurrentGroup( QLatin1String(
"Show Address Settings" ) );
36 QList<KConfigSkeleton::ItemEnum::Choice2> valuesShowAddressAction;
38 KConfigSkeleton::ItemEnum::Choice2 choice;
39 choice.name = QLatin1String(
"UseBrowser");
40 valuesShowAddressAction.append( choice );
43 KConfigSkeleton::ItemEnum::Choice2 choice;
44 choice.name = QLatin1String(
"UseExternalAddressApplication");
45 valuesShowAddressAction.append( choice );
48 KConfigSkeleton::ItemEnum::Choice2 choice;
49 choice.name = QLatin1String(
"UseGooglemap");
50 valuesShowAddressAction.append( choice );
53 KConfigSkeleton::ItemEnum::Choice2 choice;
54 choice.name = QLatin1String(
"UseMapquest");
55 valuesShowAddressAction.append( choice );
57 mShowAddressActionItem =
new KConfigSkeleton::ItemEnum( currentGroup(), QLatin1String(
"ShowAddressAction" ), mShowAddressAction, valuesShowAddressAction, UseBrowser );
58 mShowAddressActionItem->setLabel( i18n(
"ShowAddressAction") );
59 mShowAddressActionItem->setWhatsThis( i18n(
"Defines which application shall be used to show the postal address of a contact on a map. If 'Web Browser' is selected, an URL can be defined with placeholders for the single address parts. If 'External Application' is selected, a command with placeholders can be defined.") );
60 addItem( mShowAddressActionItem, QLatin1String(
"ShowAddressAction" ) );
61 mAddressUrlItem =
new KConfigSkeleton::ItemString( currentGroup(), QLatin1String(
"AddressUrl" ), mAddressUrl, QLatin1String(
"http://open.mapquestapi.com/nominatim/v1/search.php?q=%s,+%l,+%c" ) );
62 mAddressUrlItem->setLabel( i18n(
"AddressUrl") );
63 mAddressUrlItem->setToolTip( i18n(
"The following placeholders can be used in the URL:\n"
68 " %c: Country ISO Code") );
69 mAddressUrlItem->setWhatsThis( i18n(
"This URL defines the website that shall be used to show a contact's postal address.") );
70 addItem( mAddressUrlItem, QLatin1String(
"AddressUrl" ) );
71 mAddressCommandItem =
new KConfigSkeleton::ItemString( currentGroup(), QLatin1String(
"AddressCommand" ), mAddressCommand );
72 mAddressCommandItem->setLabel( i18n(
"Address Command") );
73 mAddressCommandItem->setToolTip( i18n(
"The following placeholders can be used in the command:\n"
78 " %c: Country ISO Code") );
79 mAddressCommandItem->setWhatsThis( i18n(
"This command defines the application that shall be executed to show a contact's postal address.") );
80 addItem( mAddressCommandItem, QLatin1String(
"AddressCommand" ) );
82 setCurrentGroup( QLatin1String(
"Phone Dial Settings" ) );
84 QList<KConfigSkeleton::ItemEnum::Choice2> valuesDialPhoneNumberAction;
86 KConfigSkeleton::ItemEnum::Choice2 choice;
87 choice.name = QLatin1String(
"UseSkype");
88 valuesDialPhoneNumberAction.append( choice );
91 KConfigSkeleton::ItemEnum::Choice2 choice;
92 choice.name = QLatin1String(
"UseExternalPhoneApplication");
93 valuesDialPhoneNumberAction.append( choice );
96 KConfigSkeleton::ItemEnum::Choice2 choice;
97 choice.name = QLatin1String(
"UseWinCE");
98 valuesDialPhoneNumberAction.append( choice );
101 KConfigSkeleton::ItemEnum::Choice2 choice;
102 choice.name = QLatin1String(
"UseSflPhone");
103 valuesDialPhoneNumberAction.append( choice );
106 KConfigSkeleton::ItemEnum::Choice2 choice;
107 choice.name = QLatin1String(
"UseEkiga");
108 valuesDialPhoneNumberAction.append( choice );
110 mDialPhoneNumberActionItem =
new KConfigSkeleton::ItemEnum( currentGroup(), QLatin1String(
"DialPhoneNumberAction" ), mDialPhoneNumberAction, valuesDialPhoneNumberAction, UseSkype );
111 mDialPhoneNumberActionItem->setLabel( i18n(
"DialPhoneNumberAction") );
112 mDialPhoneNumberActionItem->setWhatsThis( i18n(
"Defines which application shall be used to dial the phone number of a contact. If 'Skype' is selected the Skype application will be started (if installed on the computer) and the number is dialed. If 'External Application' is selected, a command with placeholders can be defined.") );
113 addItem( mDialPhoneNumberActionItem, QLatin1String(
"DialPhoneNumberAction" ) );
114 mPhoneCommandItem =
new KConfigSkeleton::ItemString( currentGroup(), QLatin1String(
"PhoneCommand" ), mPhoneCommand );
115 mPhoneCommandItem->setLabel( i18n(
"Phone Command") );
116 mPhoneCommandItem->setToolTip( i18n(
"The following placeholders can be used in the command:\n"
117 " %N: The raw number as stored in the address book.\n"
118 " %n: The normalized number with all non-digit characters removed.") );
119 mPhoneCommandItem->setWhatsThis( i18n(
"This command defines the application that shall be executed to dial a contact's phone number.") );
120 addItem( mPhoneCommandItem, QLatin1String(
"PhoneCommand" ) );
122 setCurrentGroup( QLatin1String(
"Send SMS Settings" ) );
124 QList<KConfigSkeleton::ItemEnum::Choice2> valuesSendSmsAction;
126 KConfigSkeleton::ItemEnum::Choice2 choice;
127 choice.name = QLatin1String(
"UseSkypeSms");
128 valuesSendSmsAction.append( choice );
131 KConfigSkeleton::ItemEnum::Choice2 choice;
132 choice.name = QLatin1String(
"UseExternalSmsApplication");
133 valuesSendSmsAction.append( choice );
136 KConfigSkeleton::ItemEnum::Choice2 choice;
137 choice.name = QLatin1String(
"UseWinCESms");
138 valuesSendSmsAction.append( choice );
141 KConfigSkeleton::ItemEnum::Choice2 choice;
142 choice.name = QLatin1String(
"UseSflPhoneSms");
143 valuesSendSmsAction.append( choice );
145 mSendSmsActionItem =
new KConfigSkeleton::ItemEnum( currentGroup(), QLatin1String(
"SendSmsAction" ), mSendSmsAction, valuesSendSmsAction, UseSkypeSms );
146 mSendSmsActionItem->setLabel( i18n(
"SendSmsAction") );
147 mSendSmsActionItem->setWhatsThis( i18n(
"Defines which application shall be used to send an SMS to the phone number of a contact. If 'Skype' is selected the Skype application will be started (if installed on the computer) and the SMS is sent via Skype. If 'External Application' is selected, a command with placeholders can be defined.") );
148 addItem( mSendSmsActionItem, QLatin1String(
"SendSmsAction" ) );
149 mSmsCommandItem =
new KConfigSkeleton::ItemString( currentGroup(), QLatin1String(
"SmsCommand" ), mSmsCommand );
150 mSmsCommandItem->setLabel( i18n(
"SMS Command") );
151 mSmsCommandItem->setToolTip( i18n(
"The following placeholders can be used in the command:\n"
152 " %N: The raw number as stored in the address book.\n"
153 " %n: The normalized number with all non-digit characters removed.\n"
155 mSmsCommandItem->setWhatsThis( i18n(
"This command defines the application that shall be executed to send an SMS to a contact's phone number.") );
156 addItem( mSmsCommandItem, QLatin1String(
"SmsCommand" ) );
159 ContactActionsSettings::~ContactActionsSettings()
161 if (!s_globalContactActionsSettings.isDestroyed()) {
162 s_globalContactActionsSettings->q = 0;