D17371: [KRun] when asked to open link in external browser, fall back to mimeapps.list if nothing is set in kdeglobals

Mélanie Chauvel noreply at phabricator.kde.org
Sat Dec 22 17:23:13 GMT 2018


achauvel added a comment.


  I think it’s better than what I proposed (without knowing about yours) in D17727 <https://phabricator.kde.org/D17727>.

INLINE COMMENTS

> krun.cpp:1421-1431
> +
> +        // If a default browser isn't set in kdeglobals, fall back to mimeapps.list
> +        if (d->m_externalBrowser.isEmpty()) {
> +            KSharedConfig::Ptr profile = KSharedConfig::openConfig(QStringLiteral("mimeapps.list"), KConfig::NoGlobals, QStandardPaths::GenericConfigLocation);
> +            KConfigGroup defaultApps(profile, "Default Applications");
> +
> +            d->m_externalBrowser = defaultApps.readEntry("x-scheme-handler/https");

I personally would have gone for

  // If a default browser isn't set in kdeglobals, fall back to mimeapps.list
  if (!d->m_externalBrowser.isEmpty()) {
      return;
  }
  KSharedConfig::Ptr profile = KSharedConfig::openConfig(QStringLiteral("mimeapps.list"), KConfig::NoGlobals, QStandardPaths::GenericConfigLocation);
  KConfigGroup defaultApps(profile, "Default Applications");
  
  d->m_externalBrowser = defaultApps.readEntry("x-scheme-handler/https");
  if (d->m_externalBrowser.isEmpty()) {
      d->m_externalBrowser = defaultApps.readEntry("x-scheme-handler/http");
  }

to avoid too much nesting.

REPOSITORY
  R241 KIO

REVISION DETAIL
  https://phabricator.kde.org/D17371

To: ngraham, #frameworks, broulik, cfeck, elvisangelaccio
Cc: achauvel, kde-frameworks-devel, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20181222/fa961ae2/attachment-0001.html>


More information about the Kde-frameworks-devel mailing list