Respect users prefered text editor for shared text
ClosedPublic

Authored by nicolasfella on Sep 28 2018, 1:07 PM.

Details

Summary

A user may have Kate installed but another editor set as default for text/plain. Respect that.

Also add .txt extension to the temp file name to make mime-type detection easier.

BUG: 399174

Test Plan

Set default text editor to Kate -> Text opens in Kate
Set default text editor to Atom -> Text opens in Atom

Diff Detail

Repository
R224 KDE Connect
Branch
editor2
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 3298
Build 3316: arc lint + arc unit
nicolasfella created this revision.Sep 28 2018, 1:07 PM
Restricted Application added a project: KDE Connect. · View Herald TranscriptSep 28 2018, 1:07 PM
Restricted Application added a subscriber: kdeconnect. · View Herald Transcript
nicolasfella requested review of this revision.Sep 28 2018, 1:07 PM

-1 I liked that using Kate didn't require writing to a temporary file.
How about asking KMimeTypeTrader for preferred service for text/plain being Kate? (KWrite also supports --stdin btw which is more common on default installs iirc)

+1 on the file template part

Check if Kate or KWrite is default and use --stdin then

  • Whitespace--
apol accepted this revision.Sep 28 2018, 2:01 PM
This revision is now accepted and ready to land.Sep 28 2018, 2:01 PM
broulik added inline comments.Sep 28 2018, 2:01 PM
plugins/share/shareplugin.cpp
115

preferredService can return null

116

Compare with QLatin1String

120

You can use QString::section

  • Use QString::section
  • Use QLatin1String
  • Check preferredService for null
nicolasfella marked 3 inline comments as done.Sep 28 2018, 2:12 PM
apol requested changes to this revision.Sep 28 2018, 2:13 PM
apol added inline comments.
plugins/share/shareplugin.cpp
120

Ugh yeah, no. Extract the executable name from the server, not from the id. They may be different!

This revision now requires changes to proceed.Sep 28 2018, 2:13 PM
broulik accepted this revision.Sep 28 2018, 2:14 PM
broulik added inline comments.
plugins/share/shareplugin.cpp
115

I think that & should go, given you may also assign temporary QString() to it

120

I was about to suggest parsing Exec but this is complicated and might have additional incompatbile arguments, and it can only be "kate" and "kwrite" at this point given the if above. Could probably use the first part of Exec but imho this way is fine'ish.

  • Remove &
  • Use service->exec()
broulik added inline comments.Sep 28 2018, 2:24 PM
plugins/share/shareplugin.cpp
118

Remove debug

120

Doesn't that contain stuff like %U or is that already resolved in KService?

nicolasfella added inline comments.Sep 28 2018, 2:26 PM
plugins/share/shareplugin.cpp
120

It does contain %U, but it doesn't seem to hurt

nicolasfella added inline comments.Sep 28 2018, 2:28 PM
plugins/share/shareplugin.cpp
120

It does for KWrite...

  • Revert to splitting the id, which is IMHO fine as it will only be Kate or KWrite
broulik accepted this revision.Sep 28 2018, 2:31 PM
apol added a comment.Sep 29 2018, 12:38 AM
  • Revert to splitting the id, which is IMHO fine as it will only be Kate or KWrite

You can do the same you did for Purpose Telegram...

apol accepted this revision.Feb 8 2019, 10:22 PM
This revision is now accepted and ready to land.Feb 8 2019, 10:22 PM
This revision was automatically updated to reflect the committed changes.