2 KSysGuard, the KDE System Guard
4 Copyright (C) 2007 Trent Waddington <trent.waddington@gmail.com>
5 Copyright (c) 2008 John Tapsell <tapsell@kde.org>
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
25 #include "KMonitorProcessIO.h"
26 #include "DisplayProcessDlg.h"
27 #include "DisplayProcessDlg.moc"
28 #include "ui_DisplayProcessUi.h"
30 DisplayProcessDlg::DisplayProcessDlg(QWidget
* parent
, KSysGuard::Process
*process
)
33 setObjectName( "Display Process Dialog" );
35 setCaption( i18n("Monitoring I/O for %1 (%2)", process
->pid
, process
->name
) );
37 //enableLinkedHelp( true );
38 showButtonSeparator( true );
40 QWidget
*widget
= new QWidget(this);
41 setMainWidget(widget
);
42 ui
= new Ui_DisplayProcessUi();
45 ui
->mTextEdit
->setWhatsThis(i18n("The program '%1' (PID: %2) is being monitored for input and output through any file descriptor (stdin, stdout, stderr, open files, network connections, etc.). Data being written by the process is shown in red and data being read by the process is shown in blue.", process
->name
, process
->pid
));
46 if(!ui
->mTextEdit
->attach(process
->pid
)) {
47 ui
->btnDetach
->setText(i18n("&Attach"));
48 ui
->btnDetach
->setChecked(true);
49 ui
->btnPause
->setText(i18n("&Pause"));
50 ui
->btnPause
->setChecked(false);
51 ui
->btnPause
->setEnabled(false);
54 connect(ui
->btnPause
, SIGNAL(toggled(bool)), this, SLOT(slotBtnPause(bool)));
55 connect(ui
->btnDetach
, SIGNAL(toggled(bool)), this, SLOT(slotBtnDetach(bool)));
58 DisplayProcessDlg::~DisplayProcessDlg() {
59 ui
->mTextEdit
->detach();
61 void DisplayProcessDlg::slotButtonClicked(int)
63 ui
->mTextEdit
->detach();
67 QSize
DisplayProcessDlg::sizeHint() const {
68 return QSize(600,600);
71 void DisplayProcessDlg::slotBtnPause(bool pause
) {
73 ui
->mTextEdit
->pauseProcesses();
74 ui
->btnPause
->setText(i18n("&Resume"));
76 ui
->mTextEdit
->resumeProcesses();
77 ui
->btnPause
->setText(i18n("&Pause"));
80 void DisplayProcessDlg::slotBtnDetach(bool detach
) {
82 ui
->btnDetach
->setText(i18n("&Attach"));
83 ui
->btnDetach
->setChecked(true);
84 ui
->btnPause
->setText(i18n("&Pause"));
85 ui
->btnPause
->setChecked(false);
86 ui
->btnPause
->setEnabled(false);
87 ui
->mTextEdit
->detach();
89 if(!ui
->mTextEdit
->reattach()) {
91 ui
->btnDetach
->setText(i18n("&Attach"));
92 ui
->btnDetach
->setChecked(true);
93 ui
->btnPause
->setText(i18n("&Pause"));
94 ui
->btnPause
->setChecked(false);
95 ui
->btnPause
->setEnabled(false);
97 ui
->btnDetach
->setText(i18n("&Detach"));