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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
/***************************************************************************
* Copyright (C) 1999-2002 by Bernd Gehrmann *
* bernd@kdevelop.org *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "appoutputviewpart.h"
#include <tqwhatsthis.h>
#include <tqdir.h>
#include <kdebug.h>
#include <tdelocale.h>
#include <tdeaction.h>
#include <kiconloader.h>
#include <tdeparts/part.h>
#include <kdevgenericfactory.h>
#include <kdevplugininfo.h>
#include <tdeapplication.h>
#include "kdevproject.h"
#include "kdevcore.h"
#include "kdevmainwindow.h"
#include "appoutputwidget.h"
#include "kdevpartcontroller.h"
#include "settings.h"
static const KDevPluginInfo data("kdevappoutputview");
typedef KDevGenericFactory< AppOutputViewPart > AppViewFactory;
K_EXPORT_COMPONENT_FACTORY( libkdevappview, AppViewFactory( data ) )
AppOutputViewPart::AppOutputViewPart(TQObject *parent, const char *name, const TQStringList &)
: KDevAppFrontend(&data, parent, name ? name : "AppOutputViewPart")
{
setInstance(AppViewFactory::instance());
m_dcop = new KDevAppFrontendIface(this);
m_widget = new AppOutputWidget(this);
m_widget->setIcon( SmallIcon("openterm") );
m_widget->setCaption(i18n("Application Output"));
TQWhatsThis::add(m_widget, i18n("<b>Application output</b><p>"
"The stdout/stderr output window is a replacement for "
"terminal-based application communication. Running terminal "
"applications use this instead of a terminal window."));
mainWindow()->embedOutputView(m_widget, i18n("Application"), i18n("Output of the executed user program"));
hideView();
connect( core(), TQT_SIGNAL(stopButtonClicked(KDevPlugin*)),
this, TQT_SLOT(slotStopButtonClicked(KDevPlugin*)) );
connect(m_widget, TQT_SIGNAL(processExited(TDEProcess*)), this, TQT_SLOT(slotProcessExited()));
connect(m_widget, TQT_SIGNAL(processExited(TDEProcess*)), TQT_SIGNAL(processExited()));
}
AppOutputViewPart::~AppOutputViewPart()
{
if ( m_widget )
mainWindow()->removeView( m_widget );
delete m_widget;
delete m_dcop;
}
void AppOutputViewPart::slotStopButtonClicked( KDevPlugin* which )
{
if ( which != 0 && which != this )
return;
stopApplication();
}
void AppOutputViewPart::stopApplication()
{
m_widget->killJob();
core()->running( this, false );
}
void AppOutputViewPart::slotProcessExited()
{
core()->running( this, false );
if ( partController()->activePart() && partController()->activePart()->widget() )
partController()->activePart()->widget()->setFocus();
}
/**
* If directory is empty it will use the user's home directory.
* If inTerminal is true, the program is started in an external
* konsole.
*/
void AppOutputViewPart::startAppCommand(const TQString &directory, const TQString &program, bool inTerminal)
{
TQString cmd;
if (inTerminal) {
cmd = Settings::terminalEmulatorName( *kapp->config() );
if ( cmd == "konsole" && !directory.isNull() ) { // isn't setting the working directory below enough?
// If a directory was specified, use it
cmd += TQString(" --workdir '%1'").arg(directory);
}
cmd += " -e /bin/sh -c '";
cmd += program;
cmd += "; echo \"";
cmd += i18n("Press Enter to continue!");
cmd += "\";read dummy'";
} else
cmd = program;
m_widget->clearViewAndContents();
if ( directory.isNull() )
// use the user's home directory
m_widget->startJob(TQDir::homeDirPath(), cmd);
else
// use the supplied directory
m_widget->startJob(directory, cmd);
core()->running( this, true );
showView();
mainWindow()->raiseView(m_widget);
}
bool AppOutputViewPart::isRunning()
{
return m_widget->isRunning();
}
void AppOutputViewPart::insertStdoutLine(const TQCString &line)
{
m_widget->insertStdoutLine(line);
}
void AppOutputViewPart::insertStderrLine(const TQCString &line)
{
m_widget->insertStderrLine(line);
}
void AppOutputViewPart::clearView()
{
m_widget->clearViewAndContents();
}
void AppOutputViewPart::hideView()
{
m_viewIsVisible = false;
mainWindow()->setViewAvailable( m_widget, m_viewIsVisible );
}
void AppOutputViewPart::showView()
{
m_viewIsVisible = true;
mainWindow()->setViewAvailable( m_widget, m_viewIsVisible );
}
bool AppOutputViewPart::isViewVisible()
{
return m_viewIsVisible;
}
void AppOutputViewPart::addPartialStderrLine(const TQCString & line)
{
m_widget->addPartialStderrLine(line);
}
void AppOutputViewPart::addPartialStdoutLine(const TQCString & line)
{
m_widget->addPartialStdoutLine(line);
}
#include "appoutputviewpart.moc"
|