Add part 2 of colorpalette example: login and logout users


Expose QtOAIUsersApi singleton as a Foreign type.
Add Credentials class marked with QML_SINGLETON to handle instantiation
of a QtOAICredentials instance.

Add a refactored UserMenu component which provides delegates for each
user and add login and logout actions based on the user's current
status (logged in or not).

My changes in ColorView.qml compared to the original example:
- Add UsersApi Connections.
- Add local loggedIn, userId and currentUserAvatar properties.
- Refactor UserMenu instantiation: Replaced the injection of objects
(userMenuUsers, userLoginService) with the direct binding of local state
properties (loggedInValue and loggedInUserId). (1)
- Refactor UserImage binding: Replace the internal getCurrentUserImage()
function with a direct, conditional binding to the local state property
root.currentUserAvatar (if logged in) or the default user icon.
- Extend reserState() function, added in the previous change, to reset
the user menu too.
- Add handleError(errorStr) to avoid repetition when errors occur.
- Call fetchUsers() when the userMenu button is clicked on.

UserMenu.qml was also imported from the original colorpalette example.
My changes:
- (1) : Add local required properties logged in value and user's id.
- userListView now uses the local usersListModel, filled via the newly
added fetchUsers() function, instead of binding to the external
userMenuUsers.data property.
- Modify the "userInfo" delegate loggedin property value:
  Switch the logged-in check from comparing modelData.email against the
  external userLoginService.user to comparing the model's id against the
  local state property userMenu.loggedInUserId.
- Move pagination logic from the external PaginatedResource userMenuUsers
object to the local userMenu popup component properties "currentUserPage"
and "totalUserPages".
- Add onCurrentUserPageChanged.
- Add connectionError signal.

This change prepare for the next changes where we can delete, add and
edit colors. These actions are only allowed when the user is logged in.

Task-number: QTBUG-140020
Change-Id: I8fbc21bc231d1063c1d4ab8b1cc3b222797a0438
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
commitb7fe94089bbca523384484fb9528f096f853f470
parentdad0d0f7fcbe800865db9f2e3631a77e5a4e22b6
authorRym Bouabid <rym.bouabid@qt.io>
committerRym Bouabid <rym.bouabid@qt.io>
commit timeFri, 5 Dec 2025 20:37:29 +0100