author | bipolar <bipolar> | 2002-03-07 02:27:02 (UTC) |
---|---|---|
committer | bipolar <bipolar> | 2002-03-07 02:27:02 (UTC) |
commit | 09444065297662fca1396abf8c0c9dd00380699f (patch) (side-by-side diff) | |
tree | 1e7fbec969b991e5f75406674679d450daa94889 | |
parent | fc2c85782429209229228602b6149248635597a5 (diff) | |
download | opie-09444065297662fca1396abf8c0c9dd00380699f.zip opie-09444065297662fca1396abf8c0c9dd00380699f.tar.gz opie-09444065297662fca1396abf8c0c9dd00380699f.tar.bz2 |
ljp: added processinfo for drw
-rw-r--r-- | noncore/settings/sysinfo/processdetail.cpp | 85 | ||||
-rw-r--r-- | noncore/settings/sysinfo/processdetail.h | 47 | ||||
-rw-r--r-- | noncore/settings/sysinfo/processinfo.cpp | 44 | ||||
-rw-r--r-- | noncore/settings/sysinfo/sysinfo.pro | 4 |
4 files changed, 156 insertions, 24 deletions
diff --git a/noncore/settings/sysinfo/processdetail.cpp b/noncore/settings/sysinfo/processdetail.cpp new file mode 100644 index 0000000..1ca1e72 --- a/dev/null +++ b/noncore/settings/sysinfo/processdetail.cpp @@ -0,0 +1,85 @@ +/********************************************************************** +** ProcessDetail +** +** Display process information +** +** Copyright (C) 2002, Dan Williams +** williamsdr@acm.org +** http://draknor.net +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +**********************************************************************/ + +#include "processdetail.h" + +#include <sys/types.h> +#include <signal.h> + +#include <qcombobox.h> +#include <qpushbutton.h> +#include <qtextview.h> +#include <qlayout.h> +#include <qlistview.h> +#include <qmessagebox.h> + +ProcessDetail::ProcessDetail( QWidget* parent, const char* name, bool modal, WFlags fl ) + : QDialog( parent, name, modal, fl ) +{ + pid = 0; + + QGridLayout *layout = new QGridLayout( this ); + layout->setSpacing( 6 ); + layout->setMargin( 11 ); + + SignalCB = new QComboBox( FALSE, this, "SignalCB" ); + SignalCB->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)7, SignalCB->sizePolicy().hasHeightForWidth() ) ); + SignalCB->setMinimumSize( QSize( 50, 24 ) ); + SignalCB->setMaximumSize( QSize( 600, 24 ) ); + SignalCB->insertItem( " 1: SIGHUP" ); + SignalCB->insertItem( " 9: SIGKILL" ); + SignalCB->insertItem( "15: SIGTERM" ); + layout->addWidget( SignalCB, 1, 0 ); + + ProcessView = new QTextView( this, "ProcessView" ); + ProcessView->setFrameShadow( QTextView::Plain ); + layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 ); + + SendButton = new QPushButton( this, "SendButton" ); + SendButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, SendButton->sizePolicy().hasHeightForWidth() ) ); + SendButton->setMinimumSize( QSize( 50, 24 ) ); + SendButton->setMaximumSize( QSize( 50, 24 ) ); + SendButton->setText( tr( "Send" ) ); + connect( SendButton, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); + layout->addWidget( SendButton, 1, 1 ); +} + +ProcessDetail::~ProcessDetail() +{ +} + +void ProcessDetail::slotSendClicked() +{ + QString sigstr = SignalCB->currentText(); + sigstr.truncate(2); + int sigid = sigstr.toUInt(); + + if ( !QMessageBox::information( this, caption(), + ( tr( "You really want to send\n" + SignalCB->currentText() + "\nto this process?") ), + ( tr( "Yes" ) ), ( tr( "No" ) ), 0 ) ) + { + if ( kill( pid, sigid ) == 0 ) + { + accept(); + } + } + +} + + diff --git a/noncore/settings/sysinfo/processdetail.h b/noncore/settings/sysinfo/processdetail.h new file mode 100644 index 0000000..5d418ac --- a/dev/null +++ b/noncore/settings/sysinfo/processdetail.h @@ -0,0 +1,47 @@ +/********************************************************************** +** ProcessDetail +** +** Display process information +** +** Copyright (C) 2002, Dan Williams +** williamsdr@acm.org +** http://draknor.net +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +**********************************************************************/ + +#ifndef PROCESSDETAIL_H +#define PROCESSDETAIL_H + +#include <qdialog.h> +#include <qcombo.h> +#include <qtextview.h> +#include <qpushbutton.h> +#include <qlistview.h> + +class ProcessDetail : public QDialog +{ + Q_OBJECT + +public: + ProcessDetail( QWidget* parent, const char* name, bool modal, WFlags fl ); + ~ProcessDetail(); + + QComboBox* SignalCB; + QTextView* ProcessView; + QPushButton* SendButton; + + int pid; + +private slots: + void slotSendClicked(); +}; + +#endif // PROCESSDETAIL_H diff --git a/noncore/settings/sysinfo/processinfo.cpp b/noncore/settings/sysinfo/processinfo.cpp index 4ecb704..225da63 100644 --- a/noncore/settings/sysinfo/processinfo.cpp +++ b/noncore/settings/sysinfo/processinfo.cpp @@ -20,37 +20,32 @@ #include <qheader.h> #include <qlistview.h> #include <qlayout.h> #include <qtimer.h> #include <qfile.h> #include <qdir.h> -#include <qmessagebox.h> - -#include <sys/types.h> -#include <signal.h> #include "processinfo.h" +#include "processdetail.h" ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { - QVBoxLayout *vb = new QVBoxLayout( this, 5 ); + QVBoxLayout *layout = new QVBoxLayout( this, 5 ); ProcessView = new QListView( this, "ProcessView" ); int colnum = ProcessView->addColumn( tr( "PID" ) ); ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); colnum = ProcessView->addColumn( tr( "Command" ),96 ); - ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); colnum = ProcessView->addColumn( tr( "Status" ) ); - ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); colnum = ProcessView->addColumn( tr( "Time" ) ); ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); ProcessView->setAllColumnsShowFocus( TRUE ); connect( ProcessView, SIGNAL( doubleClicked(QListViewItem *) ), this, SLOT( viewProcess(QListViewItem *) ) ); - vb->addWidget( ProcessView ); + layout->addWidget( ProcessView ); QTimer *t = new QTimer( this ); connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); t->start( 5000 ); updateData(); @@ -116,24 +111,27 @@ void ProcessInfo::updateData() delete proclist; delete procdir; } void ProcessInfo::viewProcess(QListViewItem *process) { - QString pid= process->text(0); + QString pid= process->text(0).stripWhiteSpace(); QString command = process->text(1); - switch( QMessageBox::information( this, (tr("Kill Process?")), - (tr("You really want to kill\n"+command+" PID: "+pid+"?")), - (tr("Yes")), (tr("No")), 0 )){ - case 0: // Yes clicked, + ProcessDetail *processdtl = new ProcessDetail( this, 0, TRUE, 0); + processdtl->setCaption( pid + " - " + command ); + processdtl->pid = pid.toUInt(); + processdtl->ProcessView->setTextFormat( RichText ); + FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); + if ( statfile ) + { + char line[81]; + fgets( line, 81, statfile ); + processdtl->ProcessView->setText( line ); + while ( fgets( line, 81, statfile ) ) { - bool ok; - pid_t child=pid.toInt(&ok,10); - if((kill(child,SIGKILL)) < 0) - perror("kill:SIGKILL"); - } - break; - case 1: // Cancel - break; - }; -//printf("Double click for PID: %s\n", process->text(0).stripWhiteSpace().latin1()); + processdtl->ProcessView->append( line ); + } + fclose( statfile ); + } + + processdtl->showMaximized(); } diff --git a/noncore/settings/sysinfo/sysinfo.pro b/noncore/settings/sysinfo/sysinfo.pro index 7f84dec..f14716e 100644 --- a/noncore/settings/sysinfo/sysinfo.pro +++ b/noncore/settings/sysinfo/sysinfo.pro @@ -3,20 +3,22 @@ CONFIG = qt warn_on release DESTDIR = $(OPIEDIR)/bin HEADERS = memory.h \ graph.h \ load.h \ storage.h \ processinfo.h \ + processdetail.h \ versioninfo.h \ sysinfo.h SOURCES = main.cpp \ memory.cpp \ graph.cpp \ load.cpp \ storage.cpp \ - processinfo.cpp \ + processinfo.cpp \ + processdetail.cpp \ versioninfo.cpp \ sysinfo.cpp INTERFACES = INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include |