Prompt to install kipi-plugins when the share button is clicked
ClosedPublic

Authored by faridb on May 29 2018, 2:08 PM.

Details

Summary

When 'kipi-plugins' is not installed, the 'Share' menu shows 'No Plugin Found'. With this patch it will present a link to install the missing plugins instead (Similarly to what the 'Plugins' menu does).

BUG: 386753

Test Plan

Without the kipi-plugins package installed, click on Share in the Gwenview toolbar.
It should display a menu action 'Install Plugins' which triggers the AppStream URL (appstream://photolayoutseditor.desktop).

Diff Detail

Repository
R260 Gwenview
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
faridb requested review of this revision.May 29 2018, 2:08 PM
faridb created this revision.
nicolasfella added inline comments.
app/kipiexportaction.cpp
116 ↗(On Diff #35116)

This won't work when the user has a non-english language set. Use GwenviewConfig::defaultExportPluginText() instead of the hard-coded string

faridb added inline comments.May 29 2018, 4:40 PM
app/kipiexportaction.cpp
116 ↗(On Diff #35116)

Using GwenviewConfig::defaultExportPluginText() will break the default plugin functionality when kipi-plugins is installed because it takes the value of last used plugin.
To take account of the system language I changed the hard-coded string to i18nc("@item:inmenu", "Install Plugins").

However, I discovered another problem: when 'Install Plugins' is clicked in the Share menu, the action text is 'Install Plugins' whereas in the Plugins menu it has the action text '&Install Plugins' which causes the bug shown in the 3rd screenshot to happen when 'Install Plugins' is used from the Plugins menu but not when used from the Share menu.

faridb updated this revision to Diff 35149.May 29 2018, 9:11 PM

Use an internationalised string instead of a hard-coded one

ngraham requested changes to this revision.May 30 2018, 3:46 AM

Thanks for this! Works great, exactly as I would expect. Also I couldn't actually get your bug to manifest for me: none of the "Install Plugin" instances ever showed an errant "&". Couple of coding style issues though.

If appstream://photolayoutseditor.desktop isn't available on Arch, that's a packaging bug (and please file it!). A package matching that appstream ID is present in KDE Neon. Of course, it doesn't actually install. :( Filed https://bugs.kde.org/show_bug.cgi?id=394846

app/kipiexportaction.cpp
126 ↗(On Diff #35149)

Coding style: space after the if

127 ↗(On Diff #35149)

Coding style: use braces even for single-line if clauses.

app/kipiinterface.cpp
377

Same: braces please!

This revision now requires changes to proceed.May 30 2018, 3:46 AM
faridb updated this revision to Diff 35174.May 30 2018, 8:43 AM
faridb marked 3 inline comments as done.

Fixed coding style issues

Thanks! One more thought: instead of comparing the action's text, could we compare the action itself, to see if it's mInstallPluginAction?

Thanks! One more thought: instead of comparing the action's text, could we compare the action itself, to see if it's mInstallPluginAction?

mInstallPluginAction is a private member of KIPIInterface, thus inaccessible in the context of KIPIExportAction. Would it be sensible to introduce a getter just for this single use case?
I followed the same logic used in KIPIExportAction::init() which uses the action text stored in .config/gwenviewrc.

That might be more reliable and semantically correct, so let's try it out and see if we like it!

faridb updated this revision to Diff 35210.May 30 2018, 6:38 PM

Made the changes to use mInstallPluginAction instead of the action's text.
It also solved the bug I was having with the Plugins menu.

ngraham accepted this revision.May 30 2018, 6:53 PM
ngraham added a subscriber: rkflx.

Thanks, this seems like a much cleaner and more appropriate approach to me. Just one more minor style nitpick below, then I'm satisfied!

@rkflx or other Gwenview folks, thoughts?

app/kipiinterface.cpp
379

Let's put the else on the same line as the closing brace currently above it.

This revision is now accepted and ready to land.May 30 2018, 6:53 PM
faridb updated this revision to Diff 35213.May 30 2018, 6:59 PM
faridb marked an inline comment as done.

Fixed the coding style issue

rkflx added a reviewer: rkflx.May 30 2018, 9:56 PM

@faridb Awesome, works great. @ngraham already provided some valuable feedback, there's only one thing I'm hesitant about (see inline comment).


Off-topic for this patch, but still I'd like to comment:

If appstream://photolayoutseditor.desktop isn't available on Arch, that's a packaging bug (and please file it!). A package matching that appstream ID is present in KDE Neon. Of course, it doesn't actually install. :( Filed https://bugs.kde.org/show_bug.cgi?id=394846

Reading the commit history of that feature, this looks more like something which was added with packaging of a particular distro in mind. Why would this be called "photolayoutseditor" anyway, when that plugin is only part of a much larger set of plugins? Also, the description looks quite broken in Discover on that distro, while on other distros the description of the regular "kipi-plugins" package is perfectly reasonable.

My goal would be to make this less distro-specific, because I don't think asking other distros to call this "photolayoutseditor.desktop" is the right thing to do.

@ngraham Can you think of any other KDE app which has a similar install-on-demand function? If there is, I'd love to peek at it.

app/kipiinterface.cpp
388–391

Hm, I don't really like leaking that implementation detail. Let me think about an alternative way.

This revision now requires review to proceed.May 30 2018, 9:56 PM

Reading the commit history of that feature, this looks more like something which was added with packaging of a particular distro in mind. Why would this be called "photolayoutseditor" anyway, when that plugin is only part of a much larger set of plugins? Also, the description looks quite broken in Discover on that distro, while on other distros the description of the regular "kipi-plugins" package is perfectly reasonable.

Indeed, the actual add-on itself needs a lot of love to actually work! :)

@ngraham Can you think of any other KDE app which has a similar install-on-demand function? If there is, I'd love to peek at it.

Dolphin has an example on the Services page of the settings window. It uses Get Hot New Stuff. If we wanted to eventually move these plugins into GHNS, we could either integrate a GHNS chooser into Gwenview like Dolphin does, or just continue to call an appropriate URL, because Discover has a GHNS backend and can install GHNS content.

appstream://photolayoutseditor.desktop

I wonder whether it would be feasible to ship something like kipi-plugins.desktop via upstream R480 Kipi Plugins? (Just an idea in case someone wants to investigate that, I don't have time to work in it right now.)

@ngraham Can you think of any other KDE app which has a similar install-on-demand function? If there is, I'd love to peek at it.

Dolphin has an example on the Services page of the settings window. It uses Get Hot New Stuff. If we wanted to eventually move these plugins into GHNS, we could either integrate a GHNS chooser into Gwenview like Dolphin does, or just continue to call an appropriate URL, because Discover has a GHNS backend and can install GHNS content.

I was more thinking about installing binary packages (I don't think GHNS can host those?). Also, I don't think we should release our software (plugins in this case) via GHNS, because there needs to be a clear distinction between trusted distro-provided packages and random untrusted user-submitted content.

Anyway, to answer my own question: https://lxr.kde.org/search?_filestring=&_string=appstream%3A%2F%2F

appstream://photolayoutseditor.desktop

I wonder whether it would be feasible to ship something like kipi-plugins.desktop via upstream R480 Kipi Plugins? (Just an idea in case someone wants to investigate that, I don't have time to work in it right now.)

Yeah, we should definitely ship the appstream metadata ourselves. A .desktop file isn't enough, it needs an appdata.xml file too. I can see about grabbing the one from Neon's packaging and submitting a better version of it to the official repo.

rkflx added a comment.May 31 2018, 7:12 PM

Hm, I don't really like leaking that implementation detail. Let me think about an alternative way.

With D13252, you probably won't need to check for installPluginAction anymore. Please have a look, and if you think this will work and my patch landed in the repo, rebase your patch on that.

faridb updated this revision to Diff 35417.Jun 2 2018, 6:25 PM
faridb marked an inline comment as done.

Rebase on D13252

I have also made a small change to fix the following bug:

rkflx added a comment.Jun 2 2018, 6:56 PM

Rebase on D13252

LGTM, and indeed looks much nicer. You are really close to landing your first code contribution to KDE, but:

I have also made a small change to fix the following bug:

Yay, thanks for fixing this! I always wondered about this: Sometimes the button would work, sometimes you needed a second click. Looks like by calling updateMenu less often, updating actually works better (perhaps due to some Qt-internal races?).

However, I have to ask you to please submit a separate Diff for that and remove it here. Later on it will help tremendously when using git blame while trying to figure something out when the commit matches with the commit message and is only about a single topic. We even have a FAQ on that, as it's a common stumbling block: https://community.kde.org/Infrastructure/Phabricator#.22Please_do_that_in_a_separate_commit.22

Thanks for understanding!

faridb updated this revision to Diff 35425.Jun 2 2018, 8:27 PM

I created a separate Diff for the bug fix at D13289.

rkflx accepted this revision.Jun 2 2018, 8:30 PM

I created a separate Diff for the bug fix at D13289.

Thanks, that's appreciated. I'll land your patch tomorrow.

This revision is now accepted and ready to land.Jun 2 2018, 8:30 PM
rkflx added a comment.Jun 2 2018, 8:32 PM

Ah, one more thing: You might want to update the summary a bit to reflect the current state of the patch, as it will become the commit message. Simply click on Edit Revision on the top.

faridb edited the summary of this revision. (Show Details)Jun 2 2018, 8:40 PM
faridb added a comment.Jun 2 2018, 8:45 PM

I updated the summary. Is it a suitable commit message?

rkflx added a comment.Jun 2 2018, 8:52 PM

I updated the summary. Is it a suitable commit message?

Yup, LGTM. You already followed most tips from https://chris.beams.io/posts/git-commit, which is great. BTW, you can use https://secure.phabricator.com/book/phabricator/article/remarkup/ for everything on Phab (in the future, no need to change it here again ;)

This revision was automatically updated to reflect the committed changes.

Spectacle also uses KIPI plugins. A similar patch might be useful there as well :)

rkflx added a comment.Jun 24 2018, 9:44 PM

Spectacle also uses KIPI plugins. A similar patch might be useful there as well :)

@nicolasfella Feel free to open a new bug for that, so this does not get lost in a random Phab comment ;)