Index: workspace/systemsettings/mainwindow.cpp
===================================================================
--- systemsettings/mainwindow.cpp (revision 780207)
+++ systemsettings/mainwindow.cpp (working copy)
@@ -26,6 +26,7 @@
#include <QLayout>
#include <QScrollArea>
#include <QStackedWidget>
+#include <QProcess>
#include <KAboutApplicationDialog>
#include <KActionCollection>
@@ -45,6 +46,7 @@
#include <KToggleToolBarAction>
#include <KToolBarSpacerAction>
#include <kcategorizedsortfilterproxymodel.h>
+#include <KStandardDirs>
#include "kcategorizedview.h"
#include "kcategorydrawer.h"
@@ -83,7 +85,7 @@
QSize MainWindow::sizeHint() const
{
return QSize(780, 580);
-}
+}
void MainWindow::readMenu( MenuItem * parent )
{
@@ -346,9 +348,13 @@
return;
MenuItem * mItem = selected.data( Qt::UserRole ).value<MenuItem*>();
+ bool needsRootPrivs = false;
if ( mItem ) {
kDebug() << "Selected item: " << mItem->service->name();
kDebug() << "Comment: " << mItem->service->comment();
+
+ needsRootPrivs = mItem->service->property( "X-KDE-RootOnly", QVariant::Bool ).toBool();
+ kDebug() << "Needs root privs:" << needsRootPrivs;
} else {
kDebug() << ":'( Got dud pointer from " << selected.data( Qt::DisplayRole ).toString();
}
@@ -358,6 +364,35 @@
if ( groupWidget )
return;
+ if ( needsRootPrivs )
+ {
+ QString kdesu = KStandardDirs::findExe( "kdesu" );
+ //kDebug() << "kdesu path:" << kdesu;
+
+ QString cmd = mItem->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 << "-c" << QString( "%1 %2 --lang %3" ).arg( KStandardDirs::locate("exe", "kcmshell4") ).arg( cmd ).arg( KGlobal::locale()->language() );
+
+ kDebug() << "Starting root module: " << args;
+ QProcess::execute( kdesu, args );
+
+ return;
+ }
+
groupWidget = moduleItemToWidgetDict[mItem->service];
if( !groupWidget ) {