Polish up the KAccounts KCM
ClosedPublic

Authored by leinir on Feb 18 2020, 2:36 PM.

Details

Summary

Since changing to the QtQuick based KAccounts KCM, it seems that
we managed to lose a few features that really want to be in there.
This is work toward ensuring that we get those features back, and
further end up with something which is more pleasant in use in
general than what we had before.

  • Add a job for toggling an account service's enabled status and use it to allow this (and then force the model to update, because apparently it doesn't do that automatically)
  • Add a dialog when deleting accounts (to ensure less accidental data loss when just clicking around the UI)
  • Add self to copyright
  • Various little bits of polish (like swapping out icons, ensuring wording is more pleasant in a few places, and adding tooltips)

Accounts list with a few accounts (hovering over one):

Clicked the remove account action for an account:

Diff Detail

Repository
R155 KAccounts Integration
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
leinir requested review of this revision.Feb 18 2020, 2:36 PM
leinir created this revision.
leinir updated this revision to Diff 75921.Feb 18 2020, 2:48 PM
  • Remove some test data
leinir edited the summary of this revision. (Show Details)Feb 18 2020, 3:17 PM

QtQuick.Dialogs seems to be part of QtQuickControls 1, which is deprecated since Qt 5.12.
Also the point of replacing the old KCM with the QML based one was to share it between desktop and mobile devices, where this kind of dialogs don't work well. From my point of view, please use a dialog that does not open a new window.

QtQuick.Dialogs seems to be part of QtQuickControls 1, which is deprecated since Qt 5.12.
Also the point of replacing the old KCM with the QML based one was to share it between desktop and mobile devices, where this kind of dialogs don't work well. From my point of view, please use a dialog that does not open a new window.

You are absolutely correct on both cases, however since the replacement would be a Kirigami OverlaySheet, which doesn't work right when embedded in a KCM, that isn't an option as it stands... See the translations kcm to see what i mean by this. Once that's fixed i can deal with that, but at the moment the alternative is worse, and so it seems not entirely reasonable to change to that. If you can think of another option which does work, do give us a shout.

jbbgameich added a comment.EditedFeb 18 2020, 3:51 PM

Could we add a property to the OverlaySheet to disable dimming the background?
For KCMs I don't really see a different way to fix this.
Whether this is possible depends on which KF5 version we can depend on here.

Could we add a property to the OverlaySheet to disable dimming the background?
For KCMs I don't really see a different way to fix this.
Whether this is possible depends on which KF5 version we can depend on here.

Hmm... The grey background is also functional (tapping it dismisses the sheet), but that would indeed work around the problem here... It'd be even better if we could somehow fix the lack of an overflow, but i don't really see how we can sensibly do that without it just becoming a huge, nasty hack. But yes, we'll need to make sure we can actually depend on a sufficiently new Frameworks for this (it'll need changing anyway as the current dependency is absolutely ancient). Let's tag in some people here, but i think we can reasonably do so.

mart added a comment.Feb 19 2020, 9:20 AM

this look


is fine. is already used by other kcms.

I'll disable the graying out for overlaysheets when running in a kcm as with qml there is no way whatsoever to gray out the entire systemsettings area.

In D27479#613974, @mart wrote:

this look


is fine. is already used by other kcms.

I'll disable the graying out for overlaysheets when running in a kcm as with qml there is no way whatsoever to gray out the entire systemsettings area.

Right, i'll just hop back and use an OverlaySheet, then :)

leinir updated this revision to Diff 75973.Feb 19 2020, 9:46 AM
leinir edited the summary of this revision. (Show Details)

Thanks for the swift decision on that, and i look forward to the visual fix!

  • Remove unneeded variable (some old test data)
  • Add a simple-ish MessageBoxSheet (as a MessageDialog porting aid)
  • Port from QtQuick.Dialogs.MessageDialog to the MessageBoxSheet
leinir edited the summary of this revision. (Show Details)Feb 19 2020, 9:47 AM
leinir retitled this revision from [WIP] Polish up the KAccounts KCM to Polish up the KAccounts KCM.Feb 19 2020, 9:57 AM
leinir edited the summary of this revision. (Show Details)
leinir added reviewers: Plasma, bshah.
ahiemstra added inline comments.
src/jobs/accountservicetoggle.cpp
79

Better to just remove these debug lines.

src/kcm/package/contents/ui/Accounts.qml
50โ€“58

Probably a lot more readable if you just write this as two if statements.

Also, I do not think the i18n() is needed for the first line, I don't think anyone is going to translate "%1 (%2)" differently.

121

There's https://techbase.kde.org/Development/Tutorials/Localization/i18n_Semantics . Would probably work just as well and wouldn't be as verbose. :)

src/kcm/package/contents/ui/AvailableServices.qml
54

What's this for? If it is to avoid bindings breaking, with Controls 2 that does not happen as much.

src/kcm/package/contents/ui/MessageBoxSheet.qml
46

Why not use Kirigami.ActionToolBar for this?

leinir marked 2 inline comments as done.Feb 19 2020, 12:01 PM
leinir added inline comments.
src/kcm/package/contents/ui/Accounts.qml
50โ€“58

Hm, i guess... just never liked to add that style of logic to property assignments ;)

That's what i thought as well, except it turns out that parenthesis is not always parenthesis, depending on context, in certain languages (Japanese comes to mind, but i'm sure there'll be others)... so i've learned to wrap quite literally everything in an i18n call ;)

121

The semantic markup is partially orthogonal to that verbose description, though... It'd be nice to add those in, i guess, but i'm also weary of this taking a huge amount more time (which me learning a new markup language would require ;) ). It'd certainly be good to get in, but i'd like to postpone that for another patch.

src/kcm/package/contents/ui/AvailableServices.qml
54

the "not as much" bit is what scares me most about that statement, basically ;) The whole thing where a checkbox reflects the state of something else and isn't state in itself is always a bit fun, so i would quite like to ensure that the value-change logic is kept entirely separate from the visual representation, which... i can accept is a workaround, but it's a fully safe one, at the cost of a bit of verbosity.

src/kcm/package/contents/ui/MessageBoxSheet.qml
46

In short, because this isn't a toolbar, and toolbuttons want to stay in toolbars :) Long version: Because making use of displayComponent would be quite awkward, given the type of control i'm attempting to produce here (in short, this component is supposed to make it easier, not more work, to produce a message box type thing... and requiring the actions to be given a display component does not make that easier). However, as a thought for some future work, modifying ActionToolBar to expose its default delegate would make it a candidate for a future refactor of this component :) (perhaps at the same time it ends up in Kirigami... because it seems like this type of component is kind of missing, and would be distinctly handy to have in the framework)

leinir updated this revision to Diff 75981.Feb 19 2020, 12:02 PM
leinir marked an inline comment as done.

Address some of the issues highlighted by @ahiemstra

  • Actually close the message box when clicking one of the buttons
  • Swap the inline conditionals for explicit if statements
  • Pull out some commented-out debug statements with no useful info
leinir updated this revision to Diff 75984.Feb 19 2020, 12:29 PM
  • These are not bookmarks, they're things that should be removed...
leinir edited the summary of this revision. (Show Details)Feb 19 2020, 12:30 PM
ahiemstra added inline comments.Feb 19 2020, 12:37 PM
src/kcm/package/contents/ui/Accounts.qml
121

Many of these can be shortened when using semantic markup, like the title can just be "@title:window" since the "Remove Account" is already part of the main string. In any case, it's more a "hey you might want to have a look at this for the future" thing.

src/kcm/package/contents/ui/AvailableServices.qml
54

Hmm, to be honest, if you want to make sure a binding does not break, using an explicit binding object would be more semantically correct.

My main issue with using a MouseArea to override behaviour on a parent control is that it'll cancel out any pre-exising behaviour the parent has. I have seen it break things like hover states for example. But I guess if it works it works.

src/kcm/package/contents/ui/MessageBoxSheet.qml
46

If you set ActionToolBar's flat property to false you effectively get the same result, since a non-flat ToolButton is basically just a Button. :)

Exposing the default delegate of ActionToolBar is a good idea... I'll ponder that a bit sometime in the future.

leinir marked 3 inline comments as done.Feb 19 2020, 1:01 PM
leinir added inline comments.
src/kcm/package/contents/ui/Accounts.qml
121

Definitely a part of the plan, yup - i'd not been pointed at that page before, so now i have somewhere to look at :)

src/kcm/package/contents/ui/AvailableServices.qml
54

Hm, you're right though... yeah, switching to a Binding does make sense, i'll do that

src/kcm/package/contents/ui/MessageBoxSheet.qml
46

Still got that component.close() bit to handle, though, and i'm not really sure how to deal with that in any remotely pleasant fashion... though, again, if the default delegate gets exposed, the same trick from here could be used, so... i'll mark this one down for future work, i think :)

leinir updated this revision to Diff 75993.Feb 19 2020, 1:01 PM
leinir marked an inline comment as done.
  • Switch to using a Binding
leinir updated this revision to Diff 75994.Feb 19 2020, 1:24 PM
  • Add a helpful label when there are no accounts in the list

Thanks for taking this up, I have to admit I neglected this after doing the initial QML "port"/transfer

src/jobs/accountservicetoggle.cpp
80

I think this would be more readable if you'd return on error

src/kcm/package/contents/ui/Accounts.qml
66

this could use a text so it has a tooltip. Probably also helpful for a11y

leinir updated this revision to Diff 76042.Feb 20 2020, 10:50 AM
leinir marked an inline comment as done.
  • Add a text (and thus tooltip) to the account delegate's remove action

Thanks for taking this up, I have to admit I neglected this after doing the initial QML "port"/transfer

Not a problem, these things happen - turns out i now need this to work right, so... getting it polished up over a couple of goes, first that initial "make the listview actually work" one from earlier this week, then this "bring it up to basic scratch" one, and i'm planning a "make it super pretty" one for next (also why i've not tagged in the VDG on this one, as the look is... not /super/ important for this one, as it'd likely change anyway) :)

src/jobs/accountservicetoggle.cpp
80

For me, returning early is an absolute no-no; i have run into way too many bugs caused by mistaken assumptions in early returns that you just don't get with a nested approach like this one... It does make the code indentations deeper, but i feel like that's a reasonable cost to pay for less accidentally-buggy code :)

src/kcm/package/contents/ui/Accounts.qml
66

Good call, yes :)

nicolasfella accepted this revision.Feb 23 2020, 2:32 PM

Looks good to me

This revision is now accepted and ready to land.Feb 23 2020, 2:32 PM
leinir edited the summary of this revision. (Show Details)Feb 24 2020, 11:03 AM
This revision was automatically updated to reflect the committed changes.