Diffstat (limited to 'noncore/settings/sysinfo/processinfo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/sysinfo/processinfo.cpp | 65 |
1 files changed, 58 insertions, 7 deletions
diff --git a/noncore/settings/sysinfo/processinfo.cpp b/noncore/settings/sysinfo/processinfo.cpp index 86133a9..35d7ba1 100644 --- a/noncore/settings/sysinfo/processinfo.cpp +++ b/noncore/settings/sysinfo/processinfo.cpp | |||
@@ -25,13 +25,21 @@ | |||
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | #include <qlistview.h> | 26 | #include <qlistview.h> |
27 | #include <qmessagebox.h> | ||
27 | #include <qtimer.h> | 28 | #include <qtimer.h> |
28 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
29 | 30 | ||
31 | #include <sys/types.h> | ||
32 | #include <signal.h> | ||
33 | |||
30 | #include "processinfo.h" | 34 | #include "processinfo.h" |
35 | #include "detail.h" | ||
31 | 36 | ||
32 | ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) | 37 | ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) |
33 | : QWidget( parent, name, fl ) | 38 | : QWidget( parent, name, fl ) |
34 | { | 39 | { |
35 | QVBoxLayout *layout = new QVBoxLayout( this, 5 ); | 40 | QGridLayout *layout = new QGridLayout( this ); |
41 | layout->setSpacing( 4 ); | ||
42 | layout->setMargin( 4 ); | ||
43 | |||
36 | 44 | ||
37 | ProcessView = new QListView( this, "ProcessView" ); | 45 | ProcessView = new QListView( this, "ProcessView" ); |
@@ -46,6 +54,28 @@ ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) | |||
46 | connect( ProcessView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 54 | connect( ProcessView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), |
47 | this, SLOT( viewProcess( QListViewItem * ) ) ); | 55 | this, SLOT( viewProcess( QListViewItem * ) ) ); |
48 | layout->addWidget( ProcessView ); | 56 | layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 ); |
49 | QWhatsThis::add( ProcessView, tr( "This is a list of all the processes on this handheld device.\n\nClick and hold on a process to see additional information about the process, or to send a signal to it." ) ); | 57 | QWhatsThis::add( ProcessView, tr( "This is a list of all the processes on this handheld device.\n\nClick and hold on a process to see additional information about the process, or to send a signal to it." ) ); |
58 | |||
59 | SignalCB = new QComboBox( FALSE, this, "SignalCB" ); | ||
60 | SignalCB->insertItem( " 1: SIGHUP" ); | ||
61 | SignalCB->insertItem( " 2: SIGINT" ); | ||
62 | SignalCB->insertItem( " 3: SIGQUIT" ); | ||
63 | SignalCB->insertItem( " 5: SIGTRAP" ); | ||
64 | SignalCB->insertItem( " 6: SIGABRT" ); | ||
65 | SignalCB->insertItem( " 9: SIGKILL" ); | ||
66 | SignalCB->insertItem( "14: SIGALRM" ); | ||
67 | SignalCB->insertItem( "15: SIGTERM" ); | ||
68 | SignalCB->insertItem( "18: SIGCONT" ); | ||
69 | SignalCB->insertItem( "19: SIGSTOP" ); | ||
70 | layout->addWidget( SignalCB, 1, 0 ); | ||
71 | QWhatsThis::add( SignalCB, tr( "Select a signal here and then click the Send button to the right to send to this process." ) ); | ||
72 | |||
73 | SendButton = new QPushButton( this, "SendButton" ); | ||
74 | SendButton->setMinimumSize( QSize( 50, 24 ) ); | ||
75 | SendButton->setMaximumSize( QSize( 50, 24 ) ); | ||
76 | SendButton->setText( tr( "Send" ) ); | ||
77 | connect( SendButton, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); | ||
78 | layout->addWidget( SendButton, 1, 1 ); | ||
79 | QWhatsThis::add( SendButton, tr( "Click here to send the selected signal to this process." ) ); | ||
50 | 80 | ||
51 | QTimer *t = new QTimer( this ); | 81 | QTimer *t = new QTimer( this ); |
@@ -55,6 +85,6 @@ ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) | |||
55 | updateData(); | 85 | updateData(); |
56 | 86 | ||
57 | ProcessDtl = new ProcessDetail( 0, 0, 0 ); | 87 | ProcessDtl = new Detail(); |
58 | ProcessDtl->ProcessView->setTextFormat( RichText ); | 88 | QWhatsThis::add( ProcessDtl->detailView, tr( "This area shows detailed information about this process." ) ); |
59 | } | 89 | } |
60 | 90 | ||
@@ -113,4 +143,26 @@ void ProcessInfo::updateData() | |||
113 | } | 143 | } |
114 | 144 | ||
145 | void ProcessInfo::slotSendClicked() | ||
146 | { | ||
147 | QString capstr = tr( "You really want to send\n" ); | ||
148 | capstr.append( SignalCB->currentText() ); | ||
149 | capstr.append( "\nto this process?" ); | ||
150 | |||
151 | QListViewItem *currprocess = ProcessView->currentItem(); | ||
152 | |||
153 | if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr, | ||
154 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) | ||
155 | { | ||
156 | QString sigstr = SignalCB->currentText(); | ||
157 | sigstr.truncate(2); | ||
158 | int sigid = sigstr.toUInt(); | ||
159 | if ( kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid ) == 0 ) | ||
160 | { | ||
161 | hide(); | ||
162 | } | ||
163 | } | ||
164 | |||
165 | } | ||
166 | |||
115 | void ProcessInfo::viewProcess( QListViewItem *process ) | 167 | void ProcessInfo::viewProcess( QListViewItem *process ) |
116 | { | 168 | { |
@@ -118,5 +170,4 @@ void ProcessInfo::viewProcess( QListViewItem *process ) | |||
118 | QString command = process->text( 1 ); | 170 | QString command = process->text( 1 ); |
119 | ProcessDtl->setCaption( pid + " - " + command ); | 171 | ProcessDtl->setCaption( pid + " - " + command ); |
120 | ProcessDtl->pid = pid.toUInt(); | ||
121 | FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); | 172 | FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); |
122 | if ( statfile ) | 173 | if ( statfile ) |
@@ -124,8 +175,8 @@ void ProcessInfo::viewProcess( QListViewItem *process ) | |||
124 | char line[81]; | 175 | char line[81]; |
125 | fgets( line, 81, statfile ); | 176 | fgets( line, 81, statfile ); |
126 | ProcessDtl->ProcessView->setText( line ); | 177 | ProcessDtl->detailView->setText( line ); |
127 | while ( fgets( line, 81, statfile ) ) | 178 | while ( fgets( line, 81, statfile ) ) |
128 | { | 179 | { |
129 | ProcessDtl->ProcessView->append( line ); | 180 | ProcessDtl->detailView->append( line ); |
130 | } | 181 | } |
131 | fclose( statfile ); | 182 | fclose( statfile ); |