diff --git a/autotests/kmimeassociationstest.cpp b/autotests/kmimeassociationstest.cpp --- a/autotests/kmimeassociationstest.cpp +++ b/autotests/kmimeassociationstest.cpp @@ -190,20 +190,23 @@ m_mimeAppsFileContents = "[Added Associations]\n" "image/jpeg=fakejpegapplication.desktop;\n" "text/html=fakehtmlapplication.desktop;fakehtmlapplicationpfx.desktop;\n" - "text/plain=faketextapplication.desktop;fakepfx-faketextapplicationpfx.desktop;gvim.desktop;wine.desktop;idontexist.desktop;\n" + "text/plain=fakepfx-faketextapplicationpfx.desktop;gvim.desktop;wine.desktop;idontexist.desktop;\n" // test alias resolution "application/x-pdf=fakejpegapplication.desktop;\n" // test x-scheme-handler (#358159) (missing trailing ';' as per xdg-mime bug...) "x-scheme-handler/mailto=faketextapplication.desktop\n" "[Added KParts/ReadOnlyPart Associations]\n" "text/plain=katepart.desktop;\n" "[Removed Associations]\n" "image/jpeg=firefox.desktop;\n" - "text/html=gvim.desktop;abiword.desktop;\n"; + "text/html=gvim.desktop;abiword.desktop;\n" + "[Default Applications]\n" + "text/plain=faketextapplication.desktop;second-faketextapplicationpfx.desktop\n"; // Expected results preferredApps[QStringLiteral("image/jpeg")] << QStringLiteral("fakejpegapplication.desktop"); preferredApps[QStringLiteral("application/pdf")] << QStringLiteral("fakejpegapplication.desktop"); preferredApps[QStringLiteral("text/plain")] << QStringLiteral("faketextapplication.desktop") + << QStringLiteral("second-faketextapplicationpfx.desktop") << QStringLiteral("fakepfx-faketextapplicationpfx.desktop") << QStringLiteral("gvim.desktop"); preferredApps[QStringLiteral("text/x-csrc")] << QStringLiteral("faketextapplication.desktop") diff --git a/src/kdeinit/ktoolinvocation_x11.cpp b/src/kdeinit/ktoolinvocation_x11.cpp --- a/src/kdeinit/ktoolinvocation_x11.cpp +++ b/src/kdeinit/ktoolinvocation_x11.cpp @@ -125,18 +125,11 @@ if (!isMainThreadActive()) { return; } - - KConfig config(QStringLiteral("emaildefaults")); - KConfigGroup defaultsGrp(&config, "Defaults"); - - QString group = defaultsGrp.readEntry("Profile", "Default"); - - KConfigGroup profileGrp(&config, QStringLiteral("PROFILE_%1").arg(group)); - QString command = profileGrp.readPathEntry("EmailClient", QString()); + KService::Ptr emailClient = KMimeTypeTrader::self()->preferredService(QStringLiteral("x-scheme-handler/mailto")); + auto command = emailClient->exec(); QString to, cc, bcc; - if (command.isEmpty() || command == QLatin1String("kmail") - || command.endsWith(QLatin1String("/kmail"))) { + if (emailClient->storageId() == QStringLiteral("org.kde.kmail2.desktop")) { command = QStringLiteral("kmail --composer -s %s -c %c -b %b --body %B --attach %A -- %t"); if (!_to.isEmpty()) { QUrl url; @@ -165,11 +158,11 @@ } } - if (profileGrp.readEntry("TerminalClient", false)) { - KConfigGroup confGroup(KSharedConfig::openConfig(), "General"); - QString preferredTerminal = confGroup.readPathEntry("TerminalApplication", QStringLiteral("konsole")); - command = preferredTerminal + QLatin1String(" -e ") + command; - } + if (emailClient->terminal()) { + KConfigGroup confGroup(KSharedConfig::openConfig(), "General"); + QString preferredTerminal = confGroup.readPathEntry("TerminalApplication", QStringLiteral("konsole")); + command = preferredTerminal + QLatin1String(" -e ") + command; + } QStringList cmdTokens = KShell::splitArgs(command); QString cmd = cmdTokens.takeFirst(); diff --git a/src/sycoca/kmimeassociations.cpp b/src/sycoca/kmimeassociations.cpp --- a/src/sycoca/kmimeassociations.cpp +++ b/src/sycoca/kmimeassociations.cpp @@ -42,11 +42,13 @@ Example file: [Added Associations] -text/plain=kate.desktop; +text/plain=gnome-gedit.desktop;gnu-emacs.desktop; [Removed Associations] text/plain=gnome-gedit.desktop;gnu-emacs.desktop; +[Default Applications] +text/plain=kate.desktop; */ void KMimeAssociations::parseAllMimeAppsList() @@ -97,9 +99,9 @@ parseRemovedAssociations(KConfigGroup(&profile, "Removed KDE Service Associations"), file); } - // TODO "Default Applications" is a separate query and a separate algorithm, says the spec. - // For now this is better than nothing though. - parseAddedAssociations(KConfigGroup(&profile, "Default Applications"), file, basePreference); + // Default Applications is preferred over Added Associations. + // Other than that, they work the same... + parseAddedAssociations(KConfigGroup(&profile, "Default Applications"), file, basePreference + 25); } void KMimeAssociations::parseAddedAssociations(const KConfigGroup &group, const QString &file, int basePreference)