LoginForm::LoginForm(QWidget *parent) : QWidget(parent), ui(new Ui::LoginForm) { if (! m_Greeter.connectSync()) { close(); } ui->setupUi(this); setStyleSheet(razorTheme.qss("razor-lightdm-greeter/razor-lightdm-greeter")); ui->hostnameLabel->setFocus(); // Setup users m_UsersModel = new QLightDM::UsersModel(); QStringList userIds; for (int i = 0; i < m_UsersModel->rowCount(QModelIndex()); i++) { QModelIndex index = m_UsersModel->index(i); QString userId = m_UsersModel->data(index, Qt::UserRole).toString(); userIds << userId; } QCompleter *completer = new QCompleter(userIds); completer->setCompletionMode(QCompleter::InlineCompletion); ui->userIdInput->setCompleter(completer); // Setup sessions m_SessionsModel = new QLightDM::SessionsModel(); ui->sessionCombo->setModel(m_SessionsModel); for (int row = 0; row < ui->sessionCombo->model()->rowCount(); row++) { QModelIndex index = ui->sessionCombo->model()->index(row, 0); if (QString("Razor Desktop") == ui->sessionCombo->model()->data(index, Qt::DisplayRole).toString()) { ui->sessionCombo->setCurrentIndex(row); break; } } QPixmap icon(QString(SHARE_DIR) + "/graphics/rqt-2.svg"); ui->iconLabel->setPixmap(icon.scaled(ui->iconLabel->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation)); #ifdef USING_LIGHTDM_QT_1 ui->hostnameLabel->setText(QLightDM::hostname()); connect(&m_Greeter, SIGNAL(showPrompt(QString,QLightDM::PromptType)), this, SLOT(onPrompt(QString,QLightDM::PromptType))); #else ui->hostnameLabel->setText(m_Greeter.hostname()); connect(&m_Greeter, SIGNAL(showPrompt(QString,QLightDM::Greeter::PromptType)), this, SLOT(onPrompt(QString,QLightDM::Greeter::PromptType))); #endif connect(ui->loginButton, SIGNAL(clicked(bool)), this, SLOT(doLogin())); connect(ui->cancelButton, SIGNAL(clicked()), SLOT(doCancel())); connect(&m_Greeter, SIGNAL(authenticationComplete()), this, SLOT(authenticationDone())); connect(ui->leaveButton, SIGNAL(clicked()), SLOT(doLeave())); connect(&m_razorPowerProcess, SIGNAL(finished(int)), this, SLOT(razorPowerDone())); }
void LoginForm::initialize() { QPixmap icon(":/resources/rqt-2.png"); // This project came from Razor-qt ui->iconLabel->setPixmap(icon.scaled(ui->iconLabel->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation)); ui->hostnameLabel->setText(m_Greeter.hostname()); ui->sessionCombo->setModel(&sessionsModel); addLeaveEntry(power.canShutdown(), "system-shutdown", tr("Shutdown"), "shutdown"); addLeaveEntry(power.canRestart(), "system-reboot", tr("Restart"), "restart"); addLeaveEntry(power.canHibernate(), "system-suspend-hibernate", tr("Hibernate"), "hibernate"); addLeaveEntry(power.canSuspend(), "system-suspend", tr("Suspend"), "suspend"); ui->leaveComboBox->setDisabled(ui->leaveComboBox->count() <= 1); ui->sessionCombo->setCurrentIndex(0); setCurrentSession(m_Greeter.defaultSessionHint()); connect(ui->userInput, SIGNAL(editingFinished()), this, SLOT(userChanged())); connect(ui->leaveComboBox, SIGNAL(activated(int)), this, SLOT(leaveDropDownActivated(int))); connect(&m_Greeter, SIGNAL(showPrompt(QString, QLightDM::Greeter::PromptType)), this, SLOT(onPrompt(QString, QLightDM::Greeter::PromptType))); connect(&m_Greeter, SIGNAL(authenticationComplete()), this, SLOT(authenticationComplete())); ui->passwordInput->setEnabled(false); ui->passwordInput->clear(); if (! m_Greeter.hideUsersHint()) { QStringList knownUsers; QLightDM::UsersModel usersModel; for (int i = 0; i < usersModel.rowCount(QModelIndex()); i++) { knownUsers << usersModel.data(usersModel.index(i, 0), QLightDM::UsersModel::NameRole).toString(); } ui->userInput->setCompleter(new QCompleter(knownUsers)); ui->userInput->completer()->setCompletionMode(QCompleter::InlineCompletion); } QString user = Cache().getLastUser(); if (user.isEmpty()) { user = m_Greeter.selectUserHint(); } ui->userInput->setText(user); userChanged(); }