Blob Blame History Raw
diff -ur kdebase-workspace-4.4.90/systemsettings/core/ModuleView.cpp kdebase-workspace-4.4.90-rootprivs/systemsettings/core/ModuleView.cpp
--- kdebase-workspace-4.4.90/systemsettings/core/ModuleView.cpp	2010-06-24 18:28:10.000000000 +0200
+++ kdebase-workspace-4.4.90-rootprivs/systemsettings/core/ModuleView.cpp	2010-06-26 00:47:30.000000000 +0200
@@ -41,6 +41,7 @@
 #include <KCModuleProxy>
 #include <KStandardGuiItem>
 #include <KDialogButtonBox>
+#include <KStandardDirs>
 #include <kauthaction.h>
 
 #include "MenuItem.h"
@@ -131,6 +132,35 @@
         return;
     }
 
+    {
+        MenuItem *menuItemPtr = menuItem.data( Qt::UserRole ).value<MenuItem*>();
+        if ( menuItemPtr->service()->property( "X-KDE-RootOnly", QVariant::Bool ).toBool() ) {
+            QString kdesu = KStandardDirs::findExe( "kdesu" );
+            QString cmd = menuItemPtr->service()->exec().trimmed();
+
+            /* Prepare the process to run the kcmshell */
+            if ( cmd.left(5) == "kdesu" )
+            {
+                cmd = cmd.remove(0,5).trimmed();
+
+                /* Remove all kdesu switches */
+                while ( cmd.length() > 1 && cmd[ 0 ] == '-' )
+                    cmd = cmd.remove( 0, cmd.indexOf( ' ' ) ).trimmed();
+            }
+
+            if ( cmd.left(9) == "kcmshell4" )
+                cmd = cmd.remove(0,9).trimmed();
+
+            QStringList args;
+            args << "-i" << QString( menuItemPtr->service()->icon() ) << "-c" << QString( "%1 %2 --lang %3" ).arg( KStandardDirs::locate("exe", "kcmshell4") ).arg( cmd ).arg( KGlobal::locale()->language() );
+
+            kDebug() << "Starting root module: " << args;
+            QProcess::startDetached( kdesu, args );
+
+            return;
+        }
+    }
+
     QList<QModelIndex> indexes;
     for ( int done = 0; menuItem.model()->rowCount( menuItem ) > done; done = 1 + done ) {
         indexes << menuItem.model()->index( done, 0, menuItem );