16 #include <tdeparts/part.h> 17 #include <klibloader.h> 18 #include <kde_terminal_interface.h> 21 #include "kdevshellwidget.h" 23 KDevShellWidget::KDevShellWidget(TQWidget *parent,
const char *name)
24 : TQVBox(parent, name), m_doAutoActivate( false ), m_isRunning( false )
29 KDevShellWidget::~KDevShellWidget()
33 void KDevShellWidget::setShell(
const TQString & shell,
const TQStrList & arguments )
36 m_shellArguments = arguments;
39 void KDevShellWidget::activate( )
41 KLibFactory *factory = KLibLoader::self()->factory(
"libkonsolepart");
42 if ( !factory )
return;
44 m_konsolePart = (KParts::ReadOnlyPart *) factory->create( TQT_TQOBJECT(
this),
"libkonsolepart",
"KParts::ReadOnlyPart" );
45 if ( !m_konsolePart )
return;
47 connect( m_konsolePart, TQT_SIGNAL( processExited(TDEProcess *) ),
this, TQT_SLOT( processExited(TDEProcess *) ) );
48 connect( m_konsolePart, TQT_SIGNAL( receivedData(
const TQString& ) ),
this, TQT_SIGNAL( receivedData(
const TQString& ) ) );
49 connect( m_konsolePart, TQT_SIGNAL(destroyed()),
this, TQT_SLOT(partDestroyed()) );
51 m_konsolePart->widget()->setFocusPolicy( TQ_WheelFocus );
52 setFocusProxy( m_konsolePart->widget() );
53 m_konsolePart->widget()->setFocus();
55 if ( m_konsolePart->widget()->inherits(TQFRAME_OBJECT_NAME_STRING) )
56 ((TQFrame*)m_konsolePart->widget())->setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
58 m_konsolePart->widget()->show();
60 TerminalInterface* ti =
static_cast<TerminalInterface*
>( m_konsolePart->tqt_cast(
"TerminalInterface" ) );
63 if ( !m_shellName.isEmpty() )
64 ti->startProgram( m_shellName, m_shellArguments );
70 void KDevShellWidget::partDestroyed( )
72 if ( m_doAutoActivate )
78 void KDevShellWidget::processExited( TDEProcess * proc )
84 kdDebug(9000) << proc->args() << endl;
86 if ( proc->normalExit() )
87 emit shellExited( proc->exitStatus() );
88 else if ( proc->signalled() )
89 emit shellSignalled( proc->exitSignal() );
92 void KDevShellWidget::sendInput(
const TQString & text )
94 if ( !m_konsolePart )
return;
95 TerminalInterface* ti =
static_cast<TerminalInterface*
>( m_konsolePart->tqt_cast(
"TerminalInterface" ) );
98 ti->sendInput( text );
101 bool KDevShellWidget::isRunning( )
106 void KDevShellWidget::setAutoReactivateOnClose(
bool doAutoActivate )
111 if ( doAutoActivate )
112 TQTimer::singleShot( 3000,
this, TQT_SLOT(setAutoReactivateOnCloseDelayed()) );
114 m_doAutoActivate =
false;
117 void KDevShellWidget::setAutoReactivateOnCloseDelayed( )
119 m_doAutoActivate =
true;
123 #include "kdevshellwidget.moc"