File kdesu-remember-keep-password.diff of Package kdebase4-runtime

Subject: Default to kdesu password remembering on, but remember last state
From: Lubos Lunak
Feature: bnc#386531
Patch-upstream: no
Relates: kdebase3/kdesu-remember-keep-password.diff, kdelibs4/kdesu-settings.diff

Index: kdesu/kdesu/kdesu.cpp
===================================================================
--- kdesu/kdesu/kdesu.cpp.orig
+++ kdesu/kdesu/kdesu.cpp
@@ -351,6 +351,9 @@ static int startApp()
     // Read configuration
     KConfigGroup config(KGlobal::config(), "Passwords");
     int timeout = config.readEntry("Timeout", defTimeout);
+    // 'keep' means whether to show the checkbox, 'keepByDefault' means
+    // whether it should be checked by default
+    bool keepByDefault = config.readEntry("Keep", bool(defKeep));
 
     // Check if we need a password
     SuProcess proc;
@@ -382,8 +385,7 @@ static int startApp()
         KDEsuDialog dlg(user, auth_user, keep && !terminal, icon, withIgnoreButton);
         if (prompt)
             dlg.addCommentLine(i18n("Command:"), command);
-        if (defKeep)
-            dlg.setKeepPassword(true);
+        dlg.setKeepPassword(keepByDefault);
 
         if ((priority != 50) || (scheduler != SuProcess::SchedNormal))
         {
@@ -412,6 +414,7 @@ static int startApp()
             change_uid = false;
         password = dlg.password();
         keep = dlg.keepPassword();
+        config.writeEntry("Keep", keep);
 #ifdef Q_WS_X11
         data.setSilent( KStartupInfoData::No );
         KStartupInfo::sendChange( id, data );