@@ -63,24 +63,70 @@ QVariant MangleModel::data(const QModelIndex &index, int role) const
64UsersModel::UsersModel(QObject* parent)
64UsersModel::UsersModel(QObject* parent)
65 : UnitySortFilterProxyModelQML(parent)
65 : UnitySortFilterProxyModelQML(parent)
66+ , m_showManual(false)
68+ if (!Greeter::instance()->hideUsersHint()) {
67− setModel(new MangleModel(this));
69+ setModel(new MangleModel(this));
68 setSortCaseSensitivity(Qt::CaseInsensitive);
71 setSortCaseSensitivity(Qt::CaseInsensitive);
69 setSortLocaleAware(true);
72 setSortLocaleAware(true);
70 setSortRole(QLightDM::UsersModel::RealNameRole);
73 setSortRole(QLightDM::UsersModel::RealNameRole);
76+ connect(this, &UnitySortFilterProxyModelQML::countChanged,
77+ this, &UsersModel::updateShowManual);
81+void UsersModel::updateShowManual()
83+ // Show manual login if we are asked to OR if no other entry exists
84+ bool showManual = Greeter::instance()->showManualLoginHint() ||
85+ (QSortFilterProxyModel::rowCount() == 0 &&
86+ !Greeter::instance()->hasGuestAccount());
88+ if (m_showManual != showManual) {
89+ int row = QSortFilterProxyModel::rowCount();
91+ beginInsertRows(QModelIndex(), row, row);
93+ beginRemoveRows(QModelIndex(), row, row);
95+ m_showManual = showManual;
104+int UsersModel::manualRow() const
109+ return QSortFilterProxyModel::rowCount();
74int UsersModel::guestRow() const
112int UsersModel::guestRow() const
76− return Greeter::instance()->hasGuestAccount() ?
114+ if (!Greeter::instance()->hasGuestAccount())
77− UnitySortFilterProxyModelQML::rowCount() : -1;
115+ return -1;
117+ int row = QSortFilterProxyModel::rowCount();
80int UsersModel::rowCount(const QModelIndex &parent) const
124int UsersModel::rowCount(const QModelIndex &parent) const
82 auto count = UnitySortFilterProxyModelQML::rowCount(parent);
126 auto count = UnitySortFilterProxyModelQML::rowCount(parent);
128+ if (m_showManual && !parent.isValid())
84 if (Greeter::instance()->hasGuestAccount() && !parent.isValid())
130 if (Greeter::instance()->hasGuestAccount() && !parent.isValid())
@@ -89,7 +135,7 @@ int UsersModel::rowCount(const QModelIndex &parent) const
90QModelIndex UsersModel::index(int row, int column, const QModelIndex &parent) const
136QModelIndex UsersModel::index(int row, int column, const QModelIndex &parent) const
92− if (row == guestRow() && !parent.isValid()) {
138+ if ((row == manualRow() || row == guestRow()) && !parent.isValid()) {
93 return createIndex(row, column);
139 return createIndex(row, column);
95 return UnitySortFilterProxyModelQML::index(row, column, parent);
141 return UnitySortFilterProxyModelQML::index(row, column, parent);
@@ -98,7 +144,15 @@ QModelIndex UsersModel::index(int row, int column, const QModelIndex &parent) co
99QVariant UsersModel::data(const QModelIndex &index, int role) const
145QVariant UsersModel::data(const QModelIndex &index, int role) const
147+ if (index.row() == manualRow() && index.column() == 0) {
149+ case QLightDM::UsersModel::NameRole: return QStringLiteral("*other");
150+ case QLightDM::UsersModel::RealNameRole: return gettext("Login");
151+ case QLightDM::UsersModel::LoggedInRole: return false;
152+ case QLightDM::UsersModel::SessionRole: return Greeter::instance()->defaultSessionHint();
153+ default: return QVariant();
101− if (index.row() == guestRow() && index.column() == 0) {
155+ } else if (index.row() == guestRow() && index.column() == 0) {
102 switch (role) {
156 switch (role) {
103 case QLightDM::UsersModel::NameRole: return QStringLiteral("*guest");
157 case QLightDM::UsersModel::NameRole: return QStringLiteral("*guest");
104 case QLightDM::UsersModel::RealNameRole: return gettext("Guest Session");
158 case QLightDM::UsersModel::RealNameRole: return gettext("Guest Session");