Changeset View
Changeset View
Standalone View
Standalone View
src/akonadi-contacts/actions/dialphonenumberaction.cpp
Show All 26 Lines | |||||
27 | #include "qskypedialer.h" | 27 | #include "qskypedialer.h" | ||
28 | #include "qekigadialer.h" | 28 | #include "qekigadialer.h" | ||
29 | 29 | | |||
30 | #include <kcontacts/phonenumber.h> | 30 | #include <kcontacts/phonenumber.h> | ||
31 | #include <KLocalizedString> | 31 | #include <KLocalizedString> | ||
32 | #include <KMessageBox> | 32 | #include <KMessageBox> | ||
33 | #include <krun.h> | 33 | #include <krun.h> | ||
34 | 34 | | |||
35 | #include <QDesktopServices> | ||||
36 | | ||||
35 | using namespace Akonadi; | 37 | using namespace Akonadi; | ||
36 | 38 | | |||
37 | static QString strippedDialNumber(const QString &number) | 39 | static QString strippedDialNumber(const QString &number) | ||
38 | { | 40 | { | ||
39 | QString result; | 41 | QString result; | ||
40 | 42 | | |||
41 | const int numberLength(number.length()); | 43 | const int numberLength(number.length()); | ||
42 | for (int i = 0; i < numberLength; ++i) { | 44 | for (int i = 0; i < numberLength; ++i) { | ||
Show All 23 Lines | 55 | { | |||
66 | if (dialer) { | 68 | if (dialer) { | ||
67 | if (!dialer->dialNumber(strippedDialNumber(number.number().trimmed()))) { | 69 | if (!dialer->dialNumber(strippedDialNumber(number.number().trimmed()))) { | ||
68 | KMessageBox::sorry(nullptr, dialer->errorMessage()); | 70 | KMessageBox::sorry(nullptr, dialer->errorMessage()); | ||
69 | } | 71 | } | ||
70 | delete dialer; | 72 | delete dialer; | ||
71 | return; | 73 | return; | ||
72 | } | 74 | } | ||
73 | 75 | | |||
74 | QString command = ContactActionsSettings::self()->phoneCommand(); | 76 | if (ContactActionsSettings::self()->dialPhoneNumberAction() == ContactActionsSettings::UseSystemDefault) { | ||
77 | QUrl url; | ||||
78 | url.setScheme(QStringLiteral("tel")); | ||||
79 | url.setPath(strippedDialNumber(number.number())); | ||||
80 | QDesktopServices::openUrl(url); | ||||
81 | return; | ||||
82 | } | ||||
75 | 83 | | |||
84 | QString command = ContactActionsSettings::self()->phoneCommand(); | ||||
76 | if (command.isEmpty()) { | 85 | if (command.isEmpty()) { | ||
77 | KMessageBox::sorry(nullptr, i18n("There is no application set which could be executed.\nPlease go to the settings dialog and configure one.")); | 86 | KMessageBox::sorry(nullptr, i18n("There is no application set which could be executed.\nPlease go to the settings dialog and configure one.")); | ||
78 | return; | 87 | return; | ||
79 | } | 88 | } | ||
80 | 89 | | |||
81 | /* | 90 | /* | ||
82 | * %N the raw number | 91 | * %N the raw number | ||
83 | * %n the number with all additional non-number characters removed | 92 | * %n the number with all additional non-number characters removed | ||
84 | */ | 93 | */ | ||
85 | command = command.replace(QLatin1String("%N"), number.number()); | 94 | command = command.replace(QLatin1String("%N"), number.number()); | ||
86 | command = command.replace(QLatin1String("%n"), strippedDialNumber(number.number().trimmed())); | 95 | command = command.replace(QLatin1String("%n"), strippedDialNumber(number.number().trimmed())); | ||
87 | 96 | | |||
88 | KRun::runCommand(command, nullptr); | 97 | KRun::runCommand(command, nullptr); | ||
89 | } | 98 | } |