1
#include "lightdm-example-qt-greeter.h"
3
#include <QtGui/QApplication>
4
#include <QtGui/QLabel>
5
#include <QtGui/QLineEdit>
6
#include <QtGui/QPushButton>
7
#include <QtGui/QGridLayout>
8
#include <QtCore/QDebug>
10
#include "ldmgreeter.h"
12
LoginDialog::LoginDialog() :
15
label = new QLabel("Username:", this);
16
entry = new QLineEdit(this);
17
connect(entry, SIGNAL(returnPressed()), this, SLOT(onLogin()));
19
QPushButton *button = new QPushButton("Login", this);
20
connect(button, SIGNAL(clicked()), this, SLOT(onLogin()));
22
QGridLayout *layout = new QGridLayout(this);
23
layout->addWidget(label, 0, 0, 1, 1);
24
layout->addWidget(entry, 1, 0, 2, 1);
25
layout->addWidget(button, 2, 0, 3, 1);
28
greeter = new LdmGreeter(this);
29
connect(greeter, SIGNAL(showPrompt(QString)), this, SLOT(showPrompt(QString)));
30
connect(greeter, SIGNAL(showMessage(QString)), this, SLOT(showMessage(QString)));
31
connect(greeter, SIGNAL(showError(QString)), this, SLOT(showError(QString)));
32
connect(greeter, SIGNAL(authenticationComplete()), this, SLOT(authenticationComplete()));
33
connect(greeter, SIGNAL(quit()), this, SLOT(quit()));
34
greeter->connectToServer();
37
void LoginDialog::onLogin()
39
if(greeter->inAuthentication()) {
41
greeter->provideSecret(entry->text());
45
entry->setEchoMode(QLineEdit::Normal);
48
greeter->startAuthentication(entry->text());
52
void LoginDialog::showPrompt(QString text)
55
entry->setEchoMode(QLineEdit::Password);
60
void LoginDialog::showMessage(QString text)
65
void LoginDialog::showError(QString text)
70
void LoginDialog::authenticationComplete()
73
if(greeter->isAuthenticated()) {
74
greeter->login(greeter->authenticationUser(), greeter->defaultSession(), greeter->defaultLanguage());
77
label->setText("Failed to authenticate");
81
void LoginDialog::quit()
86
int main(int argc, char *argv[])
88
QApplication a(argc, argv);