2 ===================================================================
3 --- mainwindow.cpp (revision 835492)
4 +++ mainwindow.cpp (working copy)
8 #include <QStackedWidget>
12 #include <KActionCollection>
14 #include <KStandardAction>
16 #include <kcategorizedsortfilterproxymodel.h>
17 +#include <KStandardDirs>
18 #include <kcategorizedview.h>
19 #include <kcategorydrawer.h>
20 #include <kiconloader.h>
23 SIGNAL(activated(const QModelIndex&)),
24 SLOT(selectionChanged(const QModelIndex&)) );
25 - if (KGlobalSettings::singleClick()) {
26 - connect( tv, SIGNAL(clicked(const QModelIndex&)),
27 - SLOT(selectionChanged(const QModelIndex&)));
29 - connect( tv, SIGNAL(doubleClicked(const QModelIndex&)),
30 - SLOT(selectionChanged(const QModelIndex&)));
32 connect( search, SIGNAL(textChanged(const QString&)),
33 kcsfpm, SLOT(setFilterRegExp(const QString&)));
34 connect( kcsfpm, SIGNAL(layoutChanged()),
38 MenuItem * mItem = selected.data( Qt::UserRole ).value<MenuItem*>();
39 + bool needsRootPrivs = false;
41 kDebug() << "Selected item: " << mItem->service->name();
42 kDebug() << "Comment: " << mItem->service->comment();
44 + needsRootPrivs = mItem->service->property( "X-KDE-RootOnly", QVariant::Bool ).toBool();
45 + kDebug() << "Needs root privs:" << needsRootPrivs;
47 kDebug() << ":'( Got dud pointer from " << selected.data( Qt::DisplayRole ).toString();
48 Q_ASSERT(mItem); // Would core dump below. Do it now
53 + if ( needsRootPrivs )
55 + QString kdesu = KStandardDirs::findExe( "kdesu" );
56 + //kDebug() << "kdesu path:" << kdesu;
58 + QString cmd = mItem->service->exec().trimmed();
60 + /* Prepare the process to run the kcmshell */
61 + if ( cmd.left(5) == "kdesu" )
63 + cmd = cmd.remove(0,5).trimmed();
65 + /* Remove all kdesu switches */
66 + while ( cmd.length() > 1 && cmd[ 0 ] == '-' )
67 + cmd = cmd.remove( 0, cmd.indexOf( ' ' ) ).trimmed();
70 + if ( cmd.left(9) == "kcmshell4" )
71 + cmd = cmd.remove(0,9).trimmed();
74 + args << "-i" << QString( mItem->service->icon() ) << "-c" << QString( "%1 %2 --lang %3" ).arg( KStandardDirs::locate("exe", "kcmshell4") ).arg( cmd ).arg( KGlobal::locale()->language() );
76 + kDebug() << "Starting root module: " << args;
77 + QProcess::startDetached( kdesu, args );
82 groupWidget = moduleItemToWidgetDict[mItem->service];