Add users KCM
ClosedPublic

Authored by cblack on Mar 20 2020, 12:51 AM.

Details

Reviewers
ngraham
Group Reviewers
Plasma
VDG
Maniphest Tasks
T7246: User Manager
Commits
R119:b1c941fcdb9a: Add users KCM
Summary

This patch introduces a new users KCM based off of the AccountsService.

Co-authored-by: Nicolas Fella <nicolas.fella@gmx.de>

Closes T7246

Test Plan



Diff Detail

Repository
R119 Plasma Desktop
Branch
cblack/userkcm-ng (branched from master)
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 24004
Build 24022: arc lint + arc unit
There are a very large number of changes, so older changes are hidden. Show Older Changes
cblack updated this revision to Diff 82137.May 6 2020, 6:33 PM

begone, kule

Changing a user's avatar and clicking Reset instead of Apply makes the avatar display revert to the default avatar (which I remember you telling me isn't actually possible), not the previous one. This seems inaccurate because the avatar does in fact remain at the last one. It's just the display that's wrong.

cblack updated this revision to Diff 82150.May 6 2020, 7:59 PM

Fix faceValid checking

ngraham added a subscriber: mart.May 6 2020, 8:22 PM

Nice, that fixes the last of the avatar issues that I can find.

After you add icons to the items in the keep/delete menu and make it close it with a click outside the menu, I think I'll be done reviewing the UI--other than the multi-column sizing bug that I'd like @mart to take a look at (video #1 in D28154#663205). Nice work.

cblack updated this revision to Diff 82158.May 6 2020, 8:29 PM
cblack marked 9 inline comments as done.

Address code and icon feedback

ngraham accepted this revision.May 6 2020, 11:53 PM

Great. From my perspective this is ready to go! I'd like a Plasma person to review too, and for @mart or another Plasma person to see if they can reproduce and help figure out the issue described in the first video at D28154#663205. But that's not a hard blocker IMO.

This revision is now accepted and ready to land.May 6 2020, 11:53 PM

Which release?

We need to remove user-manager. We're technically in a repo freeze, and this would involve changing (removing) a repo a breakage of that.


Generally this looks quite neat and tidy. A big simplification +++

kcms/users/src/kcm.cpp
95

what's this for?

98

This is an odd method name.

I don't really understand what it's doing, some sort of title casing?

122

so who cleans this up?

kcms/users/src/user.cpp
97

use url.path and url.protocol for this not string manipulation

kcms/users/src/usermodel.cpp
73

why are we resetting the whole model instead of just dataChanged() on the relevant row

79

The ones not logged in will be sorted randomly.

Also note that if the intention is to have your user at the top, this check won't suffice as you can have 2 things logged in.

97

this is marked as done, yet I can't see where ?

cblack marked 5 inline comments as done.May 7 2020, 2:36 PM
cblack added inline comments.
kcms/users/src/kcm.cpp
95

used as a hook for QML to know when the KCM needs to apply

98

taking the initials of a user's real name

122

whoever is normally cleaning up tempfiles

kcms/users/src/usermodel.cpp
73

i couldn't figure out how to use those correctly. some help would be appreciated.

79

Also note that if the intention is to have your user at the top, this check won't suffice as you can have 2 things logged in.

loggedIn compares the UID of the user to the UID of the currently running program, which means only one user can be logged in at a time by our metric.

97

users are parented to the model, which will use normal QObject destructor behaviour to clean them

cblack updated this revision to Diff 82209.May 7 2020, 2:40 PM
cblack marked 4 inline comments as done.

Address some of the code feedback from d_ed

davidedmundson added inline comments.May 7 2020, 2:51 PM
kcms/users/src/kcm.cpp
98

OH!

Initial-ise

not initialise as in "to prepare"

Makes sense :)

kcms/users/src/usermodel.cpp
38

This one isn't parented to the model

cblack updated this revision to Diff 82210.May 7 2020, 2:54 PM
cblack marked an inline comment as done.

Parent the dynamically created user to the model

davidedmundson added inline comments.May 7 2020, 2:55 PM
kcms/users/src/kcm.cpp
122

Normally the app creating a temp file would clean it up.

A quick fix would be
file = new QTemporaryFile(this);

It's sort of leaking the object, but on exit it'll tidy everything up.

nicolasfella added inline comments.May 7 2020, 2:57 PM
kcms/users/src/kcm.cpp
98

Then it should have a different name, like "getInitials", else the next person will be just as confused

cblack added inline comments.May 7 2020, 2:57 PM
kcms/users/src/kcm.cpp
122

that looks like it could possibly run into race conditions, as the applyjob is executed asynchronously and IIRC is able to still be running when everything else, including this, has destructed and removed one of the files it could be using

davidedmundson added inline comments.May 7 2020, 2:59 PM
kcms/users/src/kcm.cpp
122

new QTemporaryFile(qApp) then

KJobs have an QEventLoopLocker that will stop qApp from quitting until they finish so you can be sure your applyjob is done.

cblack updated this revision to Diff 82211.May 7 2020, 2:59 PM

Refine method signature and add a comment for less ambiguity

cblack updated this revision to Diff 82212.May 7 2020, 3:00 PM

realize you forgot to change the name of the argument in the body as well

cblack updated this revision to Diff 82214.May 7 2020, 3:02 PM
cblack marked 4 inline comments as done.

Parent temporary file to the application

From my POV. +1

I still need a reply on:

"Which release?"

I would like to get this into 5.19, which would mean moving the code back into the user-manager repo, or removing it as a dependency for Plasma 5.19 by requesting an exception to the repo freeze.

Please do not get me wrong (I'm fine with the new designs and updating the code and this new KCM is very good), but it would be good to hear some words from @ltoscano on the catalog (and KCM) naming.

It is also evident that all the new KCMs do not have the "Help" button. Is it the new policy?

Thanks in advance for your comments.

Technically kcm should be called kcm<Plasma_version>_<name>. So far the Plasma_version part has been ignored, but at least kcm_ should be there.

I'm not sure about the lack of the button.

Technically kcm should be called kcm<Plasma_version>_<name>. So far the Plasma_version part has been ignored, but at least kcm_ should be there.

I'm not sure about the lack of the button.

I objected to changing the name to avoid breaking compatibility with users and software that have the old name hardcoded, but maybe that was too inflexible. If everyone else is okay with changing the name to the more common style, I'll rescind my objection.

Pretty cool

kcms/users/package/contents/ui/UserDetailsPage.qml
37

Use property var, or even property QtObject since User is a QObject

83

i18n

97

Is this a RoundButton bug that it doesn't indicate keyboard focus when I tab to it?

98

Pfp?

100

readonly property

112

I *think* one needs to multiple that with Screen.devicePixelRatio

218

Can you add some way to make Escape close the sheet but not the entire KCM, when run standalone through kcmshell? Hopefully the following is sufficient, otherwise you'd have to mess with FocusScope and the like:

Keys.onEscapePressed: {
    close();
    event.accepted = true;
}
220

Is this RowLayout needed?

288

Can we not hardcode the list of avatars, please.
Also, you probably want to use a proper GridView for all of this, otherwise you end up creating every single delegate immediately on opening.

343

A tooltip and Accessible.name with the name of the avatar would be nice

347

Is this ColumnLayout needed?

362

What's all of this? I don't see anything in the UI.
Anyway, we probably want to make all of this into a proper QAbstractListModel

400

Not sure if clever or mad :) Can we not just generate a colored rectangle on C++ side?

kcms/users/src/usermodel.cpp
113

I just learned that you need to pass QAbstractItemModel::CheckIndesOptions::IndexIsValid otherwise it only checks for blatant out of bounds indices but not invalid "Null" ones :/

ngraham added inline comments.May 13 2020, 2:04 PM
kcms/users/package/contents/ui/UserDetailsPage.qml
218

FWIW KCMs opened through KRunner are now opened in System Settings so KCMShell is something we're going to have to deal with much less. :)

broulik added inline comments.May 13 2020, 2:05 PM
kcms/users/package/contents/ui/UserDetailsPage.qml
218

Yes, but it's still something to consider. Right now Esc does nothing at all, and neither do arrow keys. This thing needs some FocusScope treatment

Now that D29394 has landed, you can add those images here!

cblack updated this revision to Diff 83074.May 19 2020, 10:09 PM
cblack marked 17 inline comments as done.

Address code concerns; add escape keyboard gesture

The avatar sheet still does not close with Esc. :/

cblack updated this revision to Diff 83079.May 19 2020, 11:06 PM

Focus the stackSwitcher when opening the sheet

Great, that works!

BTW I think you can change the KCM name to kcm_users as you originally wanted. Sorry for saying otherwise.

cblack added inline comments.May 20 2020, 6:26 AM
kcms/users/package/contents/ui/UserDetailsPage.qml
98

profile picture

220

it's a convenience for the default alignment of a layout (Qt.AlignVCenter | Qt.AlignLeft)

meven added a comment.May 20 2020, 9:10 AM

So next step would be to shadow user_manager ?

A naive ripgrep gave :

$ rg user_manager ..
../kxmlgui/src/kbugreport.cpp
352:    m_process->start(QStringLiteral("kcmshell5"), QStringList() << QStringLiteral("user_manager"));

../systemsettings/sidebar/SidebarMode.cpp
130:        item->setData(QUrl(QStringLiteral("kcm:user_manager.desktop")), ResultModel::ResourceRole);

../plasma-desktop/applets/kickoff/package/contents/ui/Header.qml
128:            KCMShell.open("user_manager")
130:        visible: KCMShell.authorize("user_manager.desktop").length > 0
cblack updated this revision to Diff 83095.May 20 2020, 5:31 PM

Rename to kcm_users

ngraham accepted this revision.May 20 2020, 5:36 PM
cblack closed this revision.May 21 2020, 7:18 PM

Now that D29394 has landed, you can add those images here!

.