Skip to content

Conversation

@calsys456
Copy link
Collaborator

@calsys456 calsys456 commented Jan 26, 2026

DDM simplified its configuration system for simplicity and better maintainence, adapt this change.

Related with linuxdeepin/ddm#77

Summary by Sourcery

Adapt greeter session and user models to the new shared configuration API and keys.

Enhancements:

  • Switch greeter components from the old Configuration header and field accessors to the new Config API.
  • Read X11/Wayland session directories and last session/user values via the new generic configuration getters and reuse them across model initialization and file watching.

DDM simplified its configuration system for simplicity and better
maintainence, adapt this change.
@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: calsys456

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai
Copy link

sourcery-ai bot commented Jan 26, 2026

Reviewer's Guide

Adapt greeter session and user models to the new centralized Config API, replacing the old Configuration API usage and updating how session directories and last-used session/user are read and watched.

Sequence diagram for greeter session model initialization and refresh

sequenceDiagram
    actor Greeter
    participant SessionModel
    participant mainConfig
    participant QFileSystem
    participant QFileSystemWatcher
    participant stateConfig

    Greeter ->> SessionModel: construct
    SessionModel ->> mainConfig: get QStringList X11 SessionDir
    mainConfig -->> SessionModel: x11SessionDir
    SessionModel ->> mainConfig: get QStringList Wayland SessionDir
    mainConfig -->> SessionModel: waylandSessionDir

    SessionModel ->> QFileSystem: exists /dev/dri
    QFileSystem -->> SessionModel: dri_active

    alt dri_active is true
        SessionModel ->> SessionModel: populate WaylandSession with waylandSessionDir
    end
    SessionModel ->> SessionModel: populate X11Session with x11SessionDir

    SessionModel ->> QFileSystemWatcher: create and addPaths waylandSessionDir
    SessionModel ->> QFileSystemWatcher: addPaths x11SessionDir

    loop on directoryChanged
        QFileSystemWatcher ->> SessionModel: directoryChanged
        SessionModel ->> QFileSystem: exists /dev/dri
        QFileSystem -->> SessionModel: dri_active
        SessionModel ->> SessionModel: clear sessions and displayNames
        alt dri_active is true
            SessionModel ->> SessionModel: populate WaylandSession with waylandSessionDir
        end
        SessionModel ->> SessionModel: populate X11Session with x11SessionDir
        SessionModel ->> stateConfig: get QString Last Session
        stateConfig -->> SessionModel: lastSession
        SessionModel ->> SessionModel: update lastIndex based on lastSession
    end
Loading

Sequence diagram for resolving last user via new Config API

sequenceDiagram
    actor Greeter
    participant UserModel
    participant stateConfig

    Greeter ->> UserModel: construct
    UserModel ->> UserModel: load users into users list

    UserModel ->> UserModel: lastUser()
    UserModel ->> stateConfig: get QString Last User
    stateConfig -->> UserModel: lastUserName
    UserModel ->> UserModel: find matching user and set lastIndex

    Greeter ->> UserModel: lastUser()
    UserModel ->> stateConfig: get QString Last User
    stateConfig -->> UserModel: lastUserName
    UserModel -->> Greeter: lastUserName
Loading

Class diagram for updated greeter config usage

classDiagram
    class SessionModel {
        +SessionModel(QObject parent)
        +~SessionModel()
        -void populate(DDM_Session_Type type, QStringList dirPaths)
    }

    class SessionModelPrivate {
        -QVector~SessionPtr~ sessions
        -QStringList displayNames
        -int lastIndex
    }

    class UserModel {
        +UserModel(QObject parent)
        +~UserModel()
        +int lastIndex() const
        +QString lastUser()
    }

    class UserModelPrivate {
        -QVector~UserPtr~ users
        -int lastIndex
    }

    class Config {
        +T get~T~(QString group, QString key)
    }

    class mainConfig {
    }

    class stateConfig {
    }

    SessionModel --> SessionModelPrivate : uses
    UserModel --> UserModelPrivate : uses

    SessionModel --> mainConfig : reads X11 SessionDir
    SessionModel --> mainConfig : reads Wayland SessionDir
    SessionModel --> stateConfig : reads Last Session

    UserModel --> stateConfig : reads Last User

    mainConfig --> Config : instance of
    stateConfig --> Config : instance of
Loading

File-Level Changes

Change Details Files
Switch greeter models from the old Configuration API to the new Config API for session and user settings.
  • Replace Configuration.h includes with Config.h in greeter models
  • Use mainConfig.get and stateConfig.get for accessing configuration keys instead of nested field accessors
  • Update retrieval of last session and last user to use the new Config API
src/greeter/sessionmodel.cpp
src/greeter/usermodel.cpp
Refactor session directory handling to cache config-derived paths and reuse them for model population and filesystem watching.
  • Read X11 and Wayland SessionDir lists once from mainConfig and store in local variables
  • Use cached session directory lists for initial session population and in QFileSystemWatcher directoryChanged handler
  • Update QFileSystemWatcher to watch the cached directory lists instead of accessing config fields directly
src/greeter/sessionmodel.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The QStringLists for X11/Wayland session directories are captured and copied into the directoryChanged lambda; consider moving these lists into the SessionModelPrivate and referencing them there so you avoid repeated copies and keep the watched paths in sync if the configuration is ever reloaded.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The QStringLists for X11/Wayland session directories are captured and copied into the directoryChanged lambda; consider moving these lists into the SessionModelPrivate and referencing them there so you avoid repeated copies and keep the watched paths in sync if the configuration is ever reloaded.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adapts Treeland's greeter session and user models to use the simplified configuration API introduced in DDM (related to linuxdeepin/ddm#77). The changes migrate from the old Configuration.h header with hierarchical field accessors to the new Config.h header with a generic get<T>() method.

Changes:

  • Updated include directives from Configuration.h to Config.h in session and user models
  • Migrated configuration access from stateConfig.Last.User.get() to stateConfig.get<QString>("Last", "User")
  • Refactored session directory retrieval to read values once at construction time and capture them in lambda for file system watcher callback

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/greeter/usermodel.cpp Updated config header and migrated last user retrieval to new API
src/greeter/sessionmodel.cpp Updated config header, migrated session directory and last session retrieval to new API, refactored to read config values once and capture in lambda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants