Add possibility to sort by descending order
ClosedPublic

Authored by faridb on May 30 2018, 1:40 PM.

Details

Summary

Gwenview only allows sorting by ascending order. This patch adds the possibility to switch the sorting order to descending.
It is implemented similarly to the sorting menu in Dolphin.
The sorting order is also saved into the Gwenview configuration file.

Before:

After:

FEATURE: 293333

Test Plan
  • Open a folder which contains images in Gwenview
  • Check 'Descending' in View > Sort By
  • The sorting order will be switched to descending
  • Uncheck 'Descending' in View > Sort By
  • The sorting order will be reverted to ascending

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 30 2018, 1:40 PM
faridb created this revision.
xyquadrat added a subscriber: xyquadrat.

I think you forgot to specify reviewers, so I added them for you.

rkflx added a subscriber: rkflx.May 30 2018, 9:55 PM

@faridb Thanks for your patches, I'll have a look on this one in the next days.

Please make sure to install and use Arcanist (see https://community.kde.org/Infrastructure/Phabricator#Using_Arcanist_to_post_patches) to submit and update your patches in the future, as it makes reviewing and finally landing on your behalf much easier for us.

rkflx requested changes to this revision.Jun 1 2018, 8:35 PM

Thanks again for the patch, works great for folders with only images in them and even title/summary/test plan are looking excellent.

One thing users surely will complain about is that in case you have folders and images in the same directory and check Descending, the folders move to the end. This is a bit unexpected, because by default Dolphin shows them first. This also breaks how the Home and End keys as well as the corresponding entries in the Go menu are supposed to work, i.e. move between the first and last image while skipping directories.

I'm not saying you should implement a separate checkbox like in Dolphin (you could of course do that in addition, e.g. Folders First), but at least by default folders should be displayed at the top and be sorted separately. I think this can be done with only little changes, but I don't want to spoil the fun in figuring it out ;) Try if you can find the trick, otherwise I'll work on a follow-up patch myself.

There are a couple of smaller problems (but nothing you could've known):

  • By default, your updated menu might not show correctly for every user, because when changing gwenviewui.rc, it's also needed to increase the version key in line 3. (If the patch was uploaded with Arcanist, I would've been able to add that as an inline comment ;) For example if you customized keyboard shortcuts, there would be a ~/.local/share/kxmlgui5/gwenview/gwenviewui.rc, which KXMLGUI prefers over the same file from the system installation directory. If the system file had a higher version number, KXMLGUI would try to merge it into the file in the user directory.
  • When I open SettingsConfigure Shortcuts, Gwenview logs kf5.kxmlgui: Action without text! "sort_order". It does not really make sense to allow assigning a shortcut to the sort menu itself, does it? I think this can go, even if it was there before (although without the warning message ;).
  • I guess there is still something off wrt. the way you set up mSortAction. Try to look at thumbnailDetailsAction and notice how it uses QActionGroup. It may very well be that KSelectAction is not the right class to use anymore if you want to extend the submenu.

Let me know if you are stuck, then I can try to have a more detailed look.

app/browsemainpage.cpp
82

How about mSortDescendingAction?

167

There is a superfluous space before mSortOrderDesc.

170

Please use the C++11 for ( : ) here.

lib/gwenviewconfig.kcfg
221

I would prefer naming this SortDescending.

This revision now requires changes to proceed.Jun 1 2018, 8:35 PM
faridb updated this revision to Diff 35392.EditedJun 2 2018, 10:38 AM
faridb marked 4 inline comments as done.

Thanks for your detailed feedback! I have made the changes you have requested in your inline comments.
I have also added the ability to sort folders first but I will create a separate revision for that.

See D13283 for 'Folders First' sort.

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

Great, LGTM now except for two minor comments.

I'll leave it open until the dependent patch is ready and in case other members of the Gwenview project have more comments, and then land it for you.

app/browsemainpage.cpp
80

You could make this variable local to setupActions (and drop the m), now that you have QActionGroup* mSortAction.

169

I think by default isChecked() of the action is already false, and you are setting the correct value later anyway, so that line is probably not necessary.

faridb updated this revision to Diff 35433.Jun 2 2018, 9:54 PM
faridb marked 2 inline comments as done.

I made the changes you requested in your inline comments.

I also fixed the issue where folders are sorted after files when the sort order is set to descending (as you suggested in your comment in D13283).

rkflx accepted this revision.Jun 2 2018, 10:18 PM
rkflx added a subscriber: muhlenpfordt.

Excellent. I tested everything again, and the issue with the folders not appearing first anymore is now solved.

I'll leave it open until the dependent patch is ready and in case other members of the Gwenview project have more comments, and then land it for you.

@muhlenpfordt I'll wait until Monday evening with landing, just in case you also want to try/review the patch first.

I also fixed the issue where folders are sorted after files when the sort order is set to descending (as you suggested in your comment in D13283).

Thanks. I guess you can now use Add ActionAbandon Revision for D13283.

This revision is now accepted and ready to land.Jun 2 2018, 10:18 PM

@rkflx Thanks for reviewing and accepting the patch! This is my second patch and your feedback and your advices are encouraging me to keep contributing :-).

In regards to D13283, there is still one idea I want to investigate before abandoning the revision. Have a look at my last comment in D13283 and let me know if it's worth trying.

This revision was automatically updated to reflect the committed changes.