~packagekit/packagekit/kpackagekit-jaunty

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
diff -Nur kpackagekit-0.4/Settings/KpkSettings.cpp kpackagekit-0.4.new/Settings/KpkSettings.cpp
--- kpackagekit-0.4/Settings/KpkSettings.cpp	2009-02-16 19:41:58.000000000 +0100
+++ kpackagekit-0.4.new/Settings/KpkSettings.cpp	2009-02-24 11:06:00.000000000 +0100
@@ -25,6 +25,7 @@
 #include <KConfig>
 #include <KLocale>
 #include <KMessageBox>
+#include <KProcess>
 #include <KpkTransactionBar.h>
 
 using namespace PackageKit;
@@ -57,7 +58,12 @@
         originGB->setEnabled(false);
     }
 
-    intervalCB->addItem(i18n("Hourly"),  KpkEnum::Hourly);
+    // Temporarily set origin bits to hidden as the implementation is incomplete. we will
+    // use software-properties-kde temporarily for editing sources until such time as
+    // the missing functionalisy is implemented. we still let the code execute, just
+    // hide the list widget so as to not confuse the user.
+    originGB-> setHidden(true);
+
     intervalCB->addItem(i18n("Daily"),   KpkEnum::Daily);
     intervalCB->addItem(i18n("Weekly"),  KpkEnum::Weekly);
     intervalCB->addItem(i18n("Monthly"), KpkEnum::Monthly);
@@ -71,6 +77,7 @@
     connect(notifyLongTasksCB, SIGNAL(stateChanged(int)), this, SLOT(checkChanges()));
     connect(intervalCB, SIGNAL(currentIndexChanged(int)), this, SLOT(checkChanges()));
     connect(autoCB, SIGNAL(currentIndexChanged(int)), this, SLOT(checkChanges()));
+    connect( editSourcesPB, SIGNAL( clicked() ), this, SLOT( runSourcesEditor() ) );
 }
 
 void KpkSettings::on_showOriginsCB_stateChanged(int state)
@@ -108,6 +115,27 @@
         emit(changed(false));
 }
 
+void KpkSettings::runSourcesEditor()
+{
+    KProcess* proc = new KProcess(this);
+    QStringList arguments;
+    QString cmd;
+    int winID = effectiveWinId();
+    cmd = "software-properties-kde --attach " + QString::number(winID);
+    arguments << "/usr/lib/kde4/libexec/kdesu" << QString(cmd);
+    proc->setProgram(arguments);
+    find(winID)->setEnabled(false);
+    proc->start();
+    connect( proc, SIGNAL( finished(int, QProcess::ExitStatus) ),
+             this, SLOT( sourcesEditorFinished() ) );
+
+}
+
+void KpkSettings::sourcesEditorFinished()
+{
+    find(effectiveWinId())->setEnabled(true);
+}
+
 void KpkSettings::load()
 {
     KConfig config("KPackageKit");
diff -Nur kpackagekit-0.4/Settings/KpkSettings.h kpackagekit-0.4.new/Settings/KpkSettings.h
--- kpackagekit-0.4/Settings/KpkSettings.h	2009-02-16 19:41:58.000000000 +0100
+++ kpackagekit-0.4.new/Settings/KpkSettings.h	2009-02-24 11:06:26.000000000 +0100
@@ -40,6 +40,8 @@
     void save();
     void defaults();
     void checkChanges();
+    void runSourcesEditor();
+    void sourcesEditorFinished();
 
 signals:
     void changed(bool state);
diff -Nur kpackagekit-0.4/Settings/KpkSettings.ui kpackagekit-0.4.new/Settings/KpkSettings.ui
--- kpackagekit-0.4/Settings/KpkSettings.ui	2009-02-16 19:41:58.000000000 +0100
+++ kpackagekit-0.4.new/Settings/KpkSettings.ui	2009-02-24 11:09:28.000000000 +0100
@@ -59,6 +59,26 @@
         </property>
        </widget>
       </item>
+      <item row="2" column="1" >
+       <spacer name="verticalSpacer_2" >
+        <property name="orientation" >
+         <enum>Qt::Vertical</enum>
+        </property>
+        <property name="sizeHint" stdset="0" >
+         <size>
+          <width>20</width>
+          <height>40</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+      <item row="2" column="1">
+       <widget class="KPushButton" name="editSourcesPB">
+        <property name="text">
+         <string>&amp;Edit Software Sources</string>
+        </property>
+       </widget>
+      </item>
      </layout>
     </widget>
    </item>