]> rtime.felk.cvut.cz Git - sojka/lightdm.git/commitdiff
Add a QT greeter
authorRobert Ancell <robert.ancell@canonical.com>
Wed, 13 Apr 2011 07:08:44 +0000 (17:08 +1000)
committerRobert Ancell <robert.ancell@canonical.com>
Wed, 13 Apr 2011 07:08:44 +0000 (17:08 +1000)
.bzrignore
NEWS
configure.ac
greeters/Makefile.am
greeters/lightdm-qt-greeter.cpp [new file with mode: 0644]
greeters/lightdm-qt-greeter.h [new file with mode: 0644]

index b355fa326289c81f5e59f83fb47413121a7abc10..5d1be4b187ca2b41d32cd21e397ba5f9aa0f9080 100644 (file)
@@ -31,6 +31,8 @@ doc/tmpl/*-unused.sgml
 doc/*.txt
 doc/xml
 greeters/lightdm-gtk-greeter
+greeters/lightdm-qt-greeter
+greeters/lightdm-qt-greeter_moc.cpp
 liblightdm-gobject/*.gir
 liblightdm-gobject/*.typelib
 liblightdm-gobject/*.vapi
diff --git a/NEWS b/NEWS
index 368e659599de839d864ea8748b8291997488ed26..96541a349e5b707761b16a7cfdcc2f16f639de15 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ Overview of changes in lightdm 0.3.0
     * liblightdmgreeter now connect asynchronously
     * Use GDBus instead of dbus-glib
     * Use the engine process name instead of a hardcoded value in theme files
+    * Add basic QT engine
 
 Overview of changes in lightdm 0.2.3
 
index 4ede8cc6b58299c3dc9f77760098a104633bd780..5251902929edf324d113da6d54cd6da061205c8b 100644 (file)
@@ -67,17 +67,28 @@ compile_liblightdm_qt=no
 if test x"$enable_liblightdm_qt" = "xauto"; then
     PKG_CHECK_MODULES(LIBLIGHTDM_QT, [
         QtCore
-        QtGui
+        QtDBus
+        QtNetwork
     ], compile_liblightdm_qt=yes, compile_liblightdm_qt=no)
 elif test x"$enable_liblightdm_qt" = "xyes"; then
     PKG_CHECK_MODULES(LIBLIGHTDM_QT, [
         QtCore
-        QtGui
+        QtDBus
+        QtNetwork
     ])
     compile_liblightdm_qt=yes
 fi
 AM_CONDITIONAL(COMPILE_LIBLIGHTDM_QT, test x"$compile_liblightdm_qt" != "xno")
 
+have_qt=no
+if test x"$compile_liblightdm_qt" = "xyes"; then
+    PKG_CHECK_MODULES(LIGHTDM_QT_GREETER, [
+        QtCore
+        QtGui
+    ], have_qt=yes, have_qt=no)
+fi
+AM_CONDITIONAL(HAVE_QT_GREETER, test $have_qt = yes)
+
 PKG_CHECK_MODULES(LIGHTDM_GTK_GREETER, [
     gtk+-2.0
 ], have_gtk=yes, have_gtk=no)
@@ -276,5 +287,6 @@ echo "
         liblightdm-gobject:       $compile_liblightdm_gobject
         GObject introspection:    $found_introspection
         liblightdm-qt:            $compile_liblightdm_qt
-        GTK+:                     $have_gtk
+        GTK+ Greeter:             $have_gtk
+        Qt Greeter:               $have_qt
 "
index 39fd0b6db44130950ec01ea5c086dec6c2b0df0c..b5b85044cd4d7fe648152f06c2d2baf4fa8fb4ea 100644 (file)
@@ -4,18 +4,15 @@ if HAVE_GTK_GREETER
 libexec_PROGRAMS += lightdm-gtk-greeter
 endif
 
-LIBLIGHTDM_LIB = $(top_builddir)/liblightdm-gobject/liblightdm-gobject.la
-LIBLIGHTDM_CFLAGS = \
-       -I$(top_srcdir)/liblightdm-gobject
-LIBLIGHTDM_LDADD = \
-       -L$(top_builddir)/liblightdm-gobject \
-       -llightdm-gobject-0
+if HAVE_QT_GREETER
+libexec_PROGRAMS += lightdm-qt-greeter
+endif
 
 lightdm_gtk_greeter_SOURCES = \
        lightdm-gtk-greeter.c
 
 lightdm_gtk_greeter_CFLAGS = \
-       $(LIBLIGHTDM_CFLAGS) \
+       -I$(top_srcdir)/liblightdm-gobject \
        $(LIGHTDM_GTK_GREETER_CFLAGS) \
        $(WARN_CFLAGS) \
        -DVERSION=\"$(VERSION)\" \
@@ -24,8 +21,32 @@ lightdm_gtk_greeter_CFLAGS = \
        -DLIGHTDM_GTK_GREETER_BINARY=\"lightdm-gtk-greeter\"
 
 lightdm_gtk_greeter_LDADD = \
-       $(LIBLIGHTDM_LDADD) \
+       -L$(top_builddir)/liblightdm-gobject \
+       -llightdm-gobject-0 \
        $(LIGHTDM_GTK_GREETER_LIBS)
 
+lightdm-qt-greeter_moc.cpp: lightdm-qt-greeter.h
+       moc $< -o $@
+
+lightdm_qt_greeter_SOURCES = \
+       lightdm-qt-greeter.cpp \
+       lightdm-qt-greeter_moc.cpp
+
+lightdm_qt_greeter_CXXFLAGS = \
+       -I$(top_srcdir)/liblightdm-qt \
+       $(LIGHTDM_QT_GREETER_CFLAGS) \
+       -DVERSION=\"$(VERSION)\" \
+       -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \
+       -DLOCALE_DIR=\"$(localedir)\" \
+       -DLIGHTDM_QT_GREETER_BINARY=\"lightdm-qt-greeter\"
+
+lightdm_qt_greeter_LDADD = \
+       -L$(top_builddir)/liblightdm-qt \
+       -llightdm-qt-0 \
+       $(LIGHTDM_QT_GREETER_LIBS)
+
+CLEANFILES = \
+       lightdm-qt-greeter_moc.cpp
+
 DISTCLEANFILES = \
        Makefile.in
diff --git a/greeters/lightdm-qt-greeter.cpp b/greeters/lightdm-qt-greeter.cpp
new file mode 100644 (file)
index 0000000..ea2a5f0
--- /dev/null
@@ -0,0 +1,83 @@
+#include <QApplication>
+#include <QtGui>
+
+#include "lightdm-qt-greeter.h"
+
+LoginDialog::LoginDialog() : QDialog()
+{
+    label = new QLabel("Username:");
+    entry = new QLineEdit;
+    connect(entry, SIGNAL(returnPressed()), this, SLOT(onLogin()));  
+    QPushButton *button = new QPushButton("Login");
+    connect(button, SIGNAL(clicked()), this, SLOT(onLogin()));
+
+    QGridLayout *layout = new QGridLayout;
+    layout->addWidget(label, 0, 0, 1, 1);
+    layout->addWidget(entry, 1, 0, 2, 1);
+    layout->addWidget(button, 2, 0, 3, 1);
+    setLayout(layout);
+
+    greeter = new LdmGreeter;
+    connect(greeter, SIGNAL(showPrompt(QString)), this, SLOT(showPrompt(QString)));
+    connect(greeter, SIGNAL(showMessage(QString)), this, SLOT(showMessage(QString)));
+    connect(greeter, SIGNAL(showError(QString)), this, SLOT(showError(QString)));
+    connect(greeter, SIGNAL(authenticationComplete()), this, SLOT(authenticationComplete()));
+    connect(greeter, SIGNAL(quit()), this, SLOT(quit()));
+    greeter->connectToServer();
+}
+
+void LoginDialog::onLogin()
+{
+    if(greeter->inAuthentication())
+    {
+        if(inPrompt)
+            greeter->provideSecret(entry->text());
+        inPrompt = false;
+        entry->setText("");
+        entry->setEchoMode(QLineEdit::Normal);
+    }
+    else
+        greeter->startAuthentication(entry->text());
+}
+
+void LoginDialog::showPrompt(QString text)
+{
+    entry->setText("");
+    entry->setEchoMode(QLineEdit::Password);
+    label->setText(text);
+    inPrompt = true;
+}
+
+void LoginDialog::showMessage(QString text)
+{    
+    label->setText(text);
+}
+
+void LoginDialog::showError(QString text)
+{
+     label->setText(text);
+}
+
+void LoginDialog::authenticationComplete()
+{
+    entry->setText("");
+    if(greeter->isAuthenticated())
+        greeter->login(greeter->authenticationUser(), greeter->defaultSession(), greeter->defaultLanguage());
+    else
+        label->setText("Failed to authenticate");
+}
+
+void LoginDialog::quit()
+{
+    exit(0);
+}
+
+int main(int argc, char *argv[])
+{
+    QApplication a(argc, argv);
+
+    LoginDialog d;
+    d.show();
+
+    return a.exec();
+}
diff --git a/greeters/lightdm-qt-greeter.h b/greeters/lightdm-qt-greeter.h
new file mode 100644 (file)
index 0000000..832964f
--- /dev/null
@@ -0,0 +1,24 @@
+#include <QtGui>
+
+#include "ldmgreeter.h"
+
+class LoginDialog : public QDialog
+{
+    Q_OBJECT
+public:
+    LoginDialog();
+
+private:
+    LdmGreeter *greeter;
+    QLabel *label;
+    QLineEdit *entry;
+    bool inPrompt;
+
+private slots:
+    void onLogin();
+    void showPrompt(QString text);
+    void showMessage(QString text);
+    void showError(QString text);
+    void authenticationComplete();
+    void quit();
+};