Don't lose list position after installing KNS cursor themes
ClosedPublic

Authored by leinir on Apr 2 2019, 9:54 AM.

Details

Reviewers
ngraham
broulik
apol
Group Reviewers
Plasma
Summary

When installing a new cursor theme (or ditto uninstalling) from KNewStuff, the current theme would become deselected due to a full refresh of the theme list.

BUG:406084

Test Plan

Install a theme using Get Hot New Stuff, see that after the list refreshes, the current theme is reselected. Also uninstall a KNS originated theme and see the same is true.

Diff Detail

Repository
R119 Plasma Desktop
Lint
Lint Skipped
Unit
Unit Tests Skipped
leinir created this revision.Apr 2 2019, 9:54 AM
Restricted Application added a subscriber: plasma-devel. · View Herald TranscriptApr 2 2019, 9:54 AM
leinir requested review of this revision.Apr 2 2019, 9:54 AM

Why do we need this do-it-once helper function?

kcms/cursortheme/kcmcursortheme.cpp
466

Coding style: space between if and (

apol added a subscriber: apol.Apr 2 2019, 10:21 PM
apol added inline comments.
kcms/cursortheme/kcmcursortheme.cpp
466

This reads weird: how about:

if (selectedIndex().isValid()) {
    const CursorTheme* theme = m_proxyModel->theme(selectedIndex());
    ...
}
472

Maybe another solution would be having the model insert/remove instead of resetting, although that works too I guess.

kcms/cursortheme/kcmcursortheme.h
150 ↗(On Diff #55261)

:) this sounds familiar.

Maybe we should keep this in the cpp file? it's only used there.

leinir added a comment.Apr 3 2019, 7:51 AM

Why do we need this do-it-once helper function?

To avoid having the lambda being called multiple times for subsequent installations, especially with incorrect parameters... It's a bit of a workaround for some missing metaprogramming abilities in C++/Qt that Discover also uses in a couple of places, it's quite handy and i can't help but think it wants to be somewhere more centrally available, but i also am not sure where that'd want to be ;)

kcms/cursortheme/kcmcursortheme.cpp
466

Thanks @ngraham :)

Good point @apol, it's a straight up copy from the save() function, and i'd just not unpacked it all the way. Yes, that definitely reads better, i'll swap it for that :)

kcms/cursortheme/kcmcursortheme.h
150 ↗(On Diff #55261)

It certainly does ;) Hmm... true, it doesn't actually need moc-ing, at least when using the modern connect syntax like is being done here, so... yup, i'll pop it in there :)

leinir updated this revision to Diff 55330.Apr 3 2019, 7:55 AM

Address comments by @ngraham and @apol

apol added a comment.Apr 3 2019, 11:52 AM

So fixing refreshList to not reset isn't feasible?

In D20198#442785, @apol wrote:

So fixing refreshList to not reset isn't feasible?

Hmm... i'll have a look, it might be

leinir updated this revision to Diff 55403.Apr 4 2019, 9:43 AM
leinir edited the summary of this revision. (Show Details)
leinir edited the test plan for this revision. (Show Details)

Less invasive change, but with more (what seem like fairly reasonable) assumptions. We now operate explicitly on installed and uninstalled files as presented by KNS, rather than simply rechecking the theme locations (which it turns out is surprisingly intensive, but then again, it /is/ a disk IO operation, so perhaps not really that surprising).

leinir marked 4 inline comments as done.Apr 4 2019, 9:44 AM
leinir added inline comments.
kcms/cursortheme/kcmcursortheme.cpp
472

New patch does this - less invasive change as well, though there's now a non-zero number of assumptions being made about what things look like on the filesystem.

apol added a comment.Apr 4 2019, 7:03 PM

Otherwise makes sense to me.

kcms/cursortheme/kcmcursortheme.cpp
468

Use splitRef if you're just taking the last one.

leinir marked 2 inline comments as done.Apr 5 2019, 7:29 AM
leinir added inline comments.
kcms/cursortheme/kcmcursortheme.cpp
468

Quite - still need to convert that last to a string later, but less string creation's good :) Kind of a microoptimisation, given we're dealing with disk io as well, but it doesn't hurt readability anyway, so, yup :)

leinir updated this revision to Diff 55455.EditedApr 5 2019, 7:29 AM
leinir marked an inline comment as done.

Address @apol's comment (can't use splitref in the second bit, as we're joining the list again at the end)

apol accepted this revision.Apr 5 2019, 11:03 AM
This revision is now accepted and ready to land.Apr 5 2019, 11:03 AM
leinir closed this revision.Apr 5 2019, 12:20 PM

Forgot to close the revision in R119:4545601adec0

FYI the patch gets closed automatically only if the commit message has Differential Revision: https://phabricator.kde.org/D20198 somewhere in it. If you use arc land or cherry-pick the commit hash of the arc-created patch, that happens automatically.

leinir added a comment.Apr 5 2019, 1:01 PM

FYI the patch gets closed automatically only if the commit message has Differential Revision: https://phabricator.kde.org/D20198 somewhere in it. If you use arc land or cherry-pick the commit hash of the arc-created patch, that happens automatically.

That is indeed what i usually do, which is why i said i forgot to do so ;)