@@ -73,6 +73,8 @@ UsersModel::UsersModel(QObject *parent)
7373 this, &UsersModel::resetEntries);
7474 connect(MockController::instance(), &MockController::userModeChanged,
7575 this, &UsersModel::resetEntries);
76+ connect(MockController::instance(), &MockController::sessionNameChanged,
77+ this, &UsersModel::setCurrentSessionName);
7678 resetEntries();
7779}
7880
@@ -81,6 +83,22 @@ UsersModel::~UsersModel()
8183 delete d_ptr;
8284}
8385
86+void UsersModel::setCurrentSessionName(const QString &sessionName, const QString &username)
87+{
88+ Q_D(UsersModel);
89+
90+ int usersIndex = 0;
91+ for (auto &entry : d->entries) {
92+ if (username == entry.username) {
93+ entry.session = sessionName;
94+ break;
95+ }
96+ usersIndex++;
97+ }
98+
99+ dataChanged(index(usersIndex, 0), index(usersIndex, 0), QVector<int>(SessionRole));
100+}
101+
84102int UsersModel::rowCount(const QModelIndex &parent) const
85103{
86104 Q_D(const UsersModel);
@@ -144,33 +162,38 @@ void UsersModel::resetEntries()
144162 } else if (userMode == "single-pin") {
145163 d->entries = {{"has-pin", "Has PIN", "", 0, false, false, "ubuntu", 0}};
146164 } else if (userMode == "full") {
165+ /*
166+ * Since the real model sorts these entries alphabetically, the model indices
167+ * don't line up correctly. The easiest way to fix this is to ensure that this
168+ * list of entries REMAINS IN ALPHABETICAL ORDER at all times.
169+ */
147170 d->entries = {
171+ { "active", "Active Account", 0, 0, true, false, "ubuntu", 0 },
172+ { "auth-error", "Auth Error", 0, 0, false, false, "ubuntu", 0 },
173+ { "black-background", "Black Background", "#000000", 0, false, false, "ubuntu", 0 },
174+ { "color-background", "Color Background", "#E95420", 0, false, false, "ubuntu", 0 },
175+ { "different-prompt", "Different Prompt", 0, 0, false, false, "ubuntu", 0 },
176+ { "empty-name", "", 0, 0, false, false, "ubuntu", 0 },
148177 { "has-password", "Has Password", 0, 0, false, false, "ubuntu", 0 },
149178 { "has-pin", "Has PIN", 0, 0, false, false, "ubuntu", 0 },
150− { "different-prompt", "Different Prompt", 0, 0, false, false, "ubuntu", 0 },
151− { "question-prompt", "Question Prompt", 0, 0, false, false, "ubuntu", 0 },
152− { "no-password", "No Password", 0, 0, false, false, "ubuntu", 0 },
153− { "auth-error", "Auth Error", 0, 0, false, false, "ubuntu", 0 },
154− { "two-factor", "Two Factor", 0, 0, false, false, "ubuntu", 0 },
155− { "two-prompts", "Two Prompts", 0, 0, false, false, "ubuntu", 0 },
156− { "wacky-prompts", "Interspersed Prompts", 0, 0, false, false, "ubuntu", 0 },
157− { "info-prompt", "Info Prompt", 0, 0, false, false, "ubuntu", 0 },
158179 { "html-info-prompt", "HTML Info Prompt", 0, 0, false, false, "ubuntu", 0 },
159− { "long-info-prompt", "Long Info Prompt", 0, 0, false, false, "ubuntu", 0 },
160− { "wide-info-prompt", "Wide Info Prompt", 0, 0, false, false, "ubuntu", 0 },
161− { "multi-info-prompt", "Multi Info Prompt", 0, 0, false, false, "ubuntu", 0 },
162180 { "info-after-login", "Info After Login", 0, 0, false, false, "ubuntu", 0 },
181+ { "info-prompt", "Info Prompt", 0, 0, false, false, "ubuntu", 0 },
182+ { "wacky-prompts", "Interspersed Prompts", 0, 0, false, false, "ubuntu", 0 },
183+ { "locked", "Locked", 0, 0, false, false, "ubuntu", 0 },
184+ { "long-info-prompt", "Long Info Prompt", 0, 0, false, false, "ubuntu", 0 },
163185 { "long-name", "Long name (far far too long to fit, seriously this would never fit on the screen, you will never see this part of the name)", 0, 0, false, false, "ubuntu", 0 },
164− { "color-background", "Color Background", "#E95420", 0, false, false, "ubuntu", 0 },
165− // white and black are a bit redundant, but useful for manually testing if UI is still readable
166− { "white-background", "White Background", "#ffffff", 0, false, false, "ubuntu", 0 },
167− { "black-background", "Black Background", "#000000", 0, false, false, "ubuntu", 0 },
186+ { "multi-info-prompt", "Multi Info Prompt", 0, 0, false, false, "ubuntu", 0 },
168187 { "no-background", "No Background", "", 0, false, false, "ubuntu", 0 },
169− { "unicode", "가나다라마", 0, 0, false, false, "ubuntu", 0 },
188+ { "no-password", "No Password", 0, 0, false, false, "ubuntu", 0 },
170189 { "no-response", "No Response", 0, 0, false, false, "ubuntu", 0 },
171− { "empty-name", "", 0, 0, false, false, "ubuntu", 0 },
172− { "active", "Active Account", 0, 0, true, false, "ubuntu", 0 },
173− { "locked", "Locked", 0, 0, false, false, "ubuntu", 0 },
190+ { "question-prompt", "Question Prompt", 0, 0, false, false, "ubuntu", 0 },
191+ { "two-factor", "Two Factor", 0, 0, false, false, "ubuntu", 0 },
192+ { "two-prompts", "Two Prompts", 0, 0, false, false, "ubuntu", 0 },
193+ // white and black are a bit redundant, but useful for manually testing if UI is still readable
194+ { "white-background", "White Background", "#ffffff", 0, false, false, "ubuntu", 0 },
195+ { "wide-info-prompt", "Wide Info Prompt", 0, 0, false, false, "ubuntu", 0 },
196+ { "unicode", "가나다라마", 0, 0, false, false, "ubuntu", 0 }
174197 };
175198 }
176199