@@ -69,6 +69,8 @@ UsersModel::UsersModel(QObject *parent)
6969 this, &UsersModel::resetEntries);
7070 connect(MockController::instance(), &MockController::userModeChanged,
7171 this, &UsersModel::resetEntries);
72+ connect(MockController::instance(), &MockController::sessionNameChanged,
73+ this, &UsersModel::setCurrentSessionName);
7274 resetEntries();
7375}
7476
@@ -77,6 +79,22 @@ UsersModel::~UsersModel()
7779 delete d_ptr;
7880}
7981
82+void UsersModel::setCurrentSessionName(const QString &sessionName, const QString &username)
83+{
84+ Q_D(UsersModel);
85+
86+ int usersIndex = 0;
87+ for (auto &entry : d->entries) {
88+ if (username == entry.username) {
89+ entry.session = sessionName;
90+ break;
91+ }
92+ usersIndex++;
93+ }
94+
95+ dataChanged(index(usersIndex, 0), index(usersIndex, 0), QVector<int>(SessionRole));
96+}
97+
8098int UsersModel::rowCount(const QModelIndex &parent) const
8199{
82100 Q_D(const UsersModel);
@@ -140,28 +158,33 @@ void UsersModel::resetEntries()
140158 } else if (userMode == "single-pin") {
141159 d->entries = {{"has-pin", "Has PIN", "", 0, false, false, "ubuntu", 0}};
142160 } else if (userMode == "full") {
161+ /*
162+ * Since the real model sorts these entries alphabetically, the model indices
163+ * don't line up correctly. The easiest way to fix this is to ensure that this
164+ * list of entries REMAINS IN ALPHABETICAL ORDER at all times.
165+ */
143166 d->entries = {
167+ { "active", "Active Account", 0, 0, true, false, "ubuntu", 0 },
168+ { "auth-error", "Auth Error", 0, 0, false, false, "ubuntu", 0 },
169+ { "black-background", "Black Background", "#000000", 0, false, false, "ubuntu", 0 },
170+ { "color-background", "Color Background", "#E95420", 0, false, false, "ubuntu", 0 },
171+ { "different-prompt", "Different Prompt", 0, 0, false, false, "ubuntu", 0 },
172+ { "empty-name", "", 0, 0, false, false, "ubuntu", 0 },
144173 { "has-password", "Has Password", 0, 0, false, false, "ubuntu", 0 },
145174 { "has-pin", "Has PIN", 0, 0, false, false, "ubuntu", 0 },
146− { "different-prompt", "Different Prompt", 0, 0, false, false, "ubuntu", 0 },
147− { "no-password", "No Password", 0, 0, false, false, "ubuntu", 0 },
148− { "auth-error", "Auth Error", 0, 0, false, false, "ubuntu", 0 },
149− { "two-factor", "Two Factor", 0, 0, false, false, "ubuntu", 0 },
150− { "info-prompt", "Info Prompt", 0, 0, false, false, "ubuntu", 0 },
151175 { "html-info-prompt", "HTML Info Prompt", 0, 0, false, false, "ubuntu", 0 },
176+ { "info-prompt", "Info Prompt", 0, 0, false, false, "ubuntu", 0 },
152177 { "long-info-prompt", "Long Info Prompt", 0, 0, false, false, "ubuntu", 0 },
153− { "wide-info-prompt", "Wide Info Prompt", 0, 0, false, false, "ubuntu", 0 },
154− { "multi-info-prompt", "Multi Info Prompt", 0, 0, false, false, "ubuntu", 0 },
155178 { "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 },
156− { "color-background", "Color Background", "#E95420", 0, false, false, "ubuntu", 0 },
157− // white and black are a bit redundant, but useful for manually testing if UI is still readable
158− { "white-background", "White Background", "#ffffff", 0, false, false, "ubuntu", 0 },
159− { "black-background", "Black Background", "#000000", 0, false, false, "ubuntu", 0 },
179+ { "multi-info-prompt", "Multi Info Prompt", 0, 0, false, false, "ubuntu", 0 },
160180 { "no-background", "No Background", "", 0, false, false, "ubuntu", 0 },
161− { "unicode", "가나다라마", 0, 0, false, false, "ubuntu", 0 },
181+ { "no-password", "No Password", 0, 0, false, false, "ubuntu", 0 },
162182 { "no-response", "No Response", 0, 0, false, false, "ubuntu", 0 },
163− { "empty-name", "", 0, 0, false, false, "ubuntu", 0 },
164− { "active", "Active Account", 0, 0, true, false, "ubuntu", 0 },
183+ { "two-factor", "Two Factor", 0, 0, false, false, "ubuntu", 0 },
184+ { "unicode", "가나다라마", 0, 0, false, false, "ubuntu", 0 },
185+ // white and black are a bit redundant, but useful for manually testing if UI is still readable
186+ { "white-background", "White Background", "#ffffff", 0, false, false, "ubuntu", 0 },
187+ { "wide-info-prompt", "Wide Info Prompt", 0, 0, false, false, "ubuntu", 0 }
165188 };
166189 }
167190