[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [lightdm] kcm: Make it possible to autologin as guest
From:       Aurélien Gâteau <aurelien.gateau () canonical ! com>
Date:       2012-02-27 17:31:42
Message-ID: 20120227173142.79DE9A60A6 () git ! kde ! org
[Download RAW message or body]

Git commit 5e29401e2823b8aa83edeb54319ce8008ceadcd1 by Aurélien Gâteau.
Committed on 27/02/2012 at 18:16.
Pushed by gateau into branch 'master'.

Make it possible to autologin as guest

M  +6    -1    kcm/CMakeLists.txt
M  +33   -6    kcm/coreconfig.cpp

http://commits.kde.org/lightdm/5e29401e2823b8aa83edeb54319ce8008ceadcd1

diff --git a/kcm/CMakeLists.txt b/kcm/CMakeLists.txt
index 8d8670b..94c95f4 100644
--- a/kcm/CMakeLists.txt
+++ b/kcm/CMakeLists.txt
@@ -3,6 +3,10 @@ find_package(KDE4 REQUIRED)
 include(KDE4Defaults)
 include(MacroLibrary)
 
+# Makes it easy to reuse code from the greeter. A bit ugly but I don't \
feel +# like setting up a static library for one class.
+set(GREETER_DIR ${CMAKE_SOURCE_DIR}/greeter)
+
 # Add the compiler flags
 add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
 include_directories(
@@ -10,7 +14,7 @@ include_directories(
   ${CMAKE_BINARY_DIR}
   ${KDE4_INCLUDES}
   ${QLIGHTDM_INCLUDE_DIR}
-
+  ${GREETER_DIR}
 )
 
 # Insert your sources here
@@ -19,6 +23,7 @@ set(LIGHTDM_KCM_SRCS
     themesmodel.cpp
     coreconfig.cpp
     lightdmkcm.cpp
+    ${GREETER_DIR}/extrarowproxymodel.cpp
 )
 
 set(LIGHTDM_KCM_UI
diff --git a/kcm/coreconfig.cpp b/kcm/coreconfig.cpp
index e8b34fc..0b23b9a 100644
--- a/kcm/coreconfig.cpp
+++ b/kcm/coreconfig.cpp
@@ -18,6 +18,7 @@ along with LightDM-KDE.  If not, see \
                <http://www.gnu.org/licenses/>.
 */
 #include "coreconfig.h"
 #include "ui_coreconfig.h"
+#include "extrarowproxymodel.h"
 
 #include "config.h"
 
@@ -29,6 +30,8 @@ along with LightDM-KDE.  If not, see \
<http://www.gnu.org/licenses/>.  #include <KConfigGroup>
 #include <KDebug>
 
+static const char* GUEST_NAME = "*guest";
+
 inline QVariant currentItemData(QComboBox* combo, int role)
 {
     return combo->itemData(combo->currentIndex(), role);
@@ -59,7 +62,13 @@ CoreConfig::CoreConfig(QWidget *parent) :
     // Hide for now: implementation is not complete
     ui->serverWidget->hide();
 
-    ui->autoLoginUser->setModel(new QLightDM::UsersModel(this));
+    ExtraRowProxyModel* usersModel = new ExtraRowProxyModel(this);
+    usersModel->setSourceModel(new QLightDM::UsersModel(this));
+    int guestId = usersModel->appendRow();
+    usersModel->setRowText(guestId, 0, i18n("Guest"));
+    usersModel->setRowData(guestId, 0, GUEST_NAME, \
QLightDM::UsersModel::NameRole); +    \
ui->autoLoginUser->setModel(usersModel); +
     ui->autoLoginSession->setModel(new QLightDM::SessionsModel(this));
 
     loadFromConfig();
@@ -86,6 +95,10 @@ void CoreConfig::loadFromConfig()
     ui->allowGuest->setChecked(seatDefaultsGroup.readEntry("allow-guest", \
true));  
     QString user = seatDefaultsGroup.readEntry("autologin-user");
+    if (user.isEmpty() && seatDefaultsGroup.readEntry("autologin-guest", \
false)) { +        // from user (string), guest (bool) to combobox user
+        user = GUEST_NAME;
+    }
     if (!user.isEmpty()) {
         setCurrentItemFromData(ui->autoLoginUser, \
QLightDM::UsersModel::NameRole, user);  }
@@ -104,11 +117,25 @@ void CoreConfig::loadFromConfig()
 QVariantMap CoreConfig::save()
 {
     QVariantMap args;
-    args["core/SeatDefaults/autologin-user"] = ui->autoLogin->isChecked()
-        ? currentItemData(ui->autoLoginUser, \
                QLightDM::UsersModel::NameRole)
-        : QString();
-    args["core/SeatDefaults/autologin-session"] = \
                currentItemData(ui->autoLoginSession, \
                QLightDM::SessionsModel::IdRole);
-    args["core/SeatDefaults/autologin-user-timeout"] = \
ui->autoLoginTimeout->value() * 60; +    if (ui->autoLogin->isChecked()) {
+        // from combobox user to user (string), guest (bool)
+        QString user = currentItemData(ui->autoLoginUser, \
QLightDM::UsersModel::NameRole).toString(); +        bool guest;
+        if (user == GUEST_NAME) {
+            guest = true;
+            user = QString();
+        } else {
+            guest = false;
+        }
+        args["core/SeatDefaults/autologin-user"] = user;
+        args["core/SeatDefaults/autologin-guest"] = guest;
+        // If LightDM gains support for these settings before us, we \
should not overwrite them +        \
//args["core/SeatDefaults/autologin-session"] = \
currentItemData(ui->autoLoginSession, QLightDM::SessionsModel::IdRole); +   \
//args["core/SeatDefaults/autologin-user-timeout"] = \
ui->autoLoginTimeout->value() * 60; +    } else {
+        args["core/SeatDefaults/autologin-user"] = QString();
+        args["core/SeatDefaults/autologin-guest"] = false;
+    }
     args["core/SeatDefaults/allow-guest"] = ui->allowGuest->isChecked();
     args["core/XDMCPServer/enabled"] = ui->enableXdmcp->isChecked();
     args["core/VNCServer/enabled"] = ui->enableVnc->isChecked();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic