File 0008-Choose-the-current-user-in-the-combobox-if-it-is-pre.patch of Package polkit-kde-agent-5

From df12892c7a8b1475b6590186f590b349f52a54d4 Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <tsdgeos@terra.es>
Date: Tue, 13 Dec 2011 09:35:39 +0100
Subject: [PATCH 1/1] Choose the current user in the combobox if it is present

REVIEW: 103399
---
 AuthDialog.cpp | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/AuthDialog.cpp b/AuthDialog.cpp
index d698f79..2aa3f2d 100644
--- a/AuthDialog.cpp
+++ b/AuthDialog.cpp
@@ -195,10 +195,13 @@ void AuthDialog::createUserCB(const PolkitQt1::Identity::List &identities)
         qobject_cast<QStandardItemModel *>(userCB->model())->item(userCB->count()-1)->setEnabled(false);
 
         // For each user
+        int index = 1; // Start at 1 because of the "Select User" entry
+        int currentUserIndex = -1;
+        const KUser currentUser;
         foreach(const PolkitQt1::Identity &identity, identities) {
             // First check to see if the user is valid
             kDebug() << "User: " << identity.toString();
-            KUser user(identity.toString().remove("unix-user:"));
+            const KUser user(identity.toString().remove("unix-user:"));
             if (!user.isValid()) {
                 kWarning() << "User invalid: " << user.loginName();
                 continue;
@@ -221,9 +224,17 @@ void AuthDialog::createUserCB(const PolkitQt1::Identity::List &identities)
             }
             // appends the user item
             userCB->addItem(icon, display, qVariantFromValue<QString> (identity.toString()));
+
+            if (user == currentUser) {
+                currentUserIndex = index;
+            }
+            ++index;
         }
 
         // Show the widget and set focus
+        if (currentUserIndex != -1) {
+            userCB->setCurrentIndex(currentUserIndex);
+        }
         userCB->show();
         userCB->setFocus();
     }
-- 
1.9.3

openSUSE Build Service is sponsored by