From 5d57bc1fb0d17c7d2b850cac58a029dc6079208a Mon Sep 17 00:00:00 2001 From: Luc Menut <lmenut@mageia.org> Date: Mon, 6 Oct 2014 00:38:06 +0200 Subject: [PATCH 1/3] Save the default application into the group [Default Applications] as per mime-apps-spec http://standards.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.1.html#default --- kio/kfile/kopenwithdialog.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kio/kfile/kopenwithdialog.cpp b/kio/kfile/kopenwithdialog.cpp index 9c1ace8..62706c5 100644 --- a/kio/kfile/kopenwithdialog.cpp +++ b/kio/kfile/kopenwithdialog.cpp @@ -773,12 +773,18 @@ static QString simplifiedExecLineFromService(const QString& fullExec) void KOpenWithDialogPrivate::addToMimeAppsList(const QString& serviceId /*menu id or storage id*/) { KSharedConfig::Ptr profile = KSharedConfig::openConfig("mimeapps.list", KConfig::NoGlobals, "xdgdata-apps"); + + // Save the default application according to mime-apps-spec 1.0 + KConfigGroup defaultApp(profile, "Default Applications"); + defaultApp.writeXdgListEntry(qMimeType, QStringList(serviceId)); + KConfigGroup addedApps(profile, "Added Associations"); QStringList apps = addedApps.readXdgListEntry(qMimeType); apps.removeAll(serviceId); apps.prepend(serviceId); // make it the preferred app addedApps.writeXdgListEntry(qMimeType, apps); - addedApps.sync(); + + profile->sync(); // Also make sure the "auto embed" setting for this mimetype is off KSharedConfig::Ptr fileTypesConfig = KSharedConfig::openConfig("filetypesrc", KConfig::NoGlobals); -- 2.1.2