Fix ascending/descending choosers getting unchecked when re-selecting the same sort order
ClosedPublic

Authored by ngraham on Aug 24 2019, 8:38 PM.

Details

Summary

When you select the same sort order that's already selected, the currently-checked
sort order description (the human-readable ascending/descending items) gets unchecked
in slotSortTriggered() yet the ascending/descending items items only get checked in
slotSortOrderChanged(). Because the order hasn't gotten changed, neither one gets
checked again.

This patch fixes the problem by not unchecking them in the first place.

BUG: 411223
FIXED-IN: 19.08.2

Test Plan
  1. Right-click > Sort By > Click the currently-selected sort order
  2. Right-click > Sort By > See that the item for the current ascending/descending setting has not been changed

Diff Detail

Repository
R318 Dolphin
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
ngraham created this revision.Aug 24 2019, 8:38 PM
Restricted Application added a project: Dolphin. · View Herald TranscriptAug 24 2019, 8:38 PM
Restricted Application added a subscriber: kfm-devel. · View Herald Transcript
ngraham requested review of this revision.Aug 24 2019, 8:38 PM
meven added a subscriber: meven.Aug 25 2019, 7:16 AM

A simpler alternative could be to use m_sortByActions, I have tested it.

foreach (QAction* groupAction, m_sortByActions.values()) {
    KActionMenu* actionMenu = qobject_cast<KActionMenu*>(groupAction);
    if (actionMenu) {
        foreach (QAction* subAction, actionMenu->menu()->actions()) {
            subAction->setChecked(false);
        }
    } else if (groupAction->actionGroup()) {
        groupAction->setChecked(false);
    }
}
elvisangelaccio requested changes to this revision.Aug 25 2019, 2:04 PM

A simpler alternative could be to use m_sortByActions, I have tested it.

+1

Always nice when you can fix a bug by changing a single line of code :D

src/views/dolphinviewactionhandler.cpp
636–641

Also please update this comment: for example "all other actions get unchecked excluding the ascending/descending actions"

This revision now requires changes to proceed.Aug 25 2019, 2:04 PM
ngraham updated this revision to Diff 64589.Aug 25 2019, 3:11 PM

Simplify and update comment

ngraham marked an inline comment as done.Aug 25 2019, 3:12 PM
broulik added inline comments.
src/views/dolphinviewactionhandler.cpp
643

No need for values(), and while at it port away from foreach

for (QAction *groupAction : qAsConst(m_sortByActions)
ngraham updated this revision to Diff 64863.Aug 28 2019, 4:19 PM
ngraham marked an inline comment as done.

Don't use values() and port away from foreach

ngraham edited the summary of this revision. (Show Details)Sep 7 2019, 7:59 PM
ngraham updated this revision to Diff 65629.Sep 8 2019, 2:39 AM

Make it compile, lol

elvisangelaccio accepted this revision.Sep 9 2019, 9:05 AM
This revision is now accepted and ready to land.Sep 9 2019, 9:05 AM
This revision was automatically updated to reflect the committed changes.