]> git.pld-linux.org Git - packages/kde4-kdebase-workspace.git/blame - kde4-kdebase-workspace-rootprivs.patch
- rootprivs.patch is back
[packages/kde4-kdebase-workspace.git] / kde4-kdebase-workspace-rootprivs.patch
CommitLineData
ccfc04e2 1Index: mainwindow.cpp
2===================================================================
b84414e8 3--- kde4-kdebase-workspace/systemsettings/mainwindow.cpp (revision 835492)
4+++ kde4-kdebase-workspace/systemsettings/mainwindow.cpp (working copy)
df33dfbd 5@@ -27,6 +27,7 @@
6
7 #include <QLayout>
8 #include <QStackedWidget>
9+#include <QProcess>
10
11 #include <KAction>
12 #include <KActionCollection>
13@@ -42,6 +43,7 @@
14 #include <KStandardAction>
15 #include <KTabWidget>
16 #include <kcategorizedsortfilterproxymodel.h>
17+#include <KStandardDirs>
18 #include <kcategorizedview.h>
19 #include <kcategorydrawer.h>
20 #include <kiconloader.h>
ccfc04e2 21@@ -176,13 +178,6 @@
22 connect( tv,
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&)));
28- } else {
29- connect( tv, SIGNAL(doubleClicked(const QModelIndex&)),
30- SLOT(selectionChanged(const QModelIndex&)));
31- }
32 connect( search, SIGNAL(textChanged(const QString&)),
33 kcsfpm, SLOT(setFilterRegExp(const QString&)));
34 connect( kcsfpm, SIGNAL(layoutChanged()),
35@@ -299,9 +294,13 @@
df33dfbd 36 return;
37
38 MenuItem * mItem = selected.data( Qt::UserRole ).value<MenuItem*>();
39+ bool needsRootPrivs = false;
40 if ( mItem ) {
41 kDebug() << "Selected item: " << mItem->service->name();
42 kDebug() << "Comment: " << mItem->service->comment();
43+
44+ needsRootPrivs = mItem->service->property( "X-KDE-RootOnly", QVariant::Bool ).toBool();
45+ kDebug() << "Needs root privs:" << needsRootPrivs;
46 } else {
47 kDebug() << ":'( Got dud pointer from " << selected.data( Qt::DisplayRole ).toString();
48 Q_ASSERT(mItem); // Would core dump below. Do it now
ccfc04e2 49@@ -313,6 +312,35 @@
df33dfbd 50 if ( groupWidget )
51 return;
52
53+ if ( needsRootPrivs )
54+ {
55+ QString kdesu = KStandardDirs::findExe( "kdesu" );
56+ //kDebug() << "kdesu path:" << kdesu;
57+
58+ QString cmd = mItem->service->exec().trimmed();
59+
60+ /* Prepare the process to run the kcmshell */
61+ if ( cmd.left(5) == "kdesu" )
62+ {
63+ cmd = cmd.remove(0,5).trimmed();
64+
65+ /* Remove all kdesu switches */
66+ while ( cmd.length() > 1 && cmd[ 0 ] == '-' )
67+ cmd = cmd.remove( 0, cmd.indexOf( ' ' ) ).trimmed();
68+ }
69+
70+ if ( cmd.left(9) == "kcmshell4" )
71+ cmd = cmd.remove(0,9).trimmed();
72+
73+ QStringList args;
ccfc04e2 74+ args << "-i" << QString( mItem->service->icon() ) << "-c" << QString( "%1 %2 --lang %3" ).arg( KStandardDirs::locate("exe", "kcmshell4") ).arg( cmd ).arg( KGlobal::locale()->language() );
df33dfbd 75+
76+ kDebug() << "Starting root module: " << args;
ccfc04e2 77+ QProcess::startDetached( kdesu, args );
df33dfbd 78+
79+ return;
80+ }
81+
82 groupWidget = moduleItemToWidgetDict[mItem->service];
83
84 if( !groupWidget ) {
This page took 0.123993 seconds and 4 git commands to generate.