• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • KDevelop Utility Library
 

KDevelop Utility Library

  • lib
  • util
kdevshellwidget.cpp
1 /***************************************************************************
2  * Copyright (C) 2006 by Jens Dagerbo *
3  * jens.dagerbo@swipnet.se *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  ***************************************************************************/
11 
12 #include <tqtimer.h>
13 #include <tqframe.h>
14 
15 #include <kdebug.h>
16 #include <tdeparts/part.h>
17 #include <klibloader.h>
18 #include <kde_terminal_interface.h>
19 #include <kprocess.h>
20 
21 #include "kdevshellwidget.h"
22 
23 KDevShellWidget::KDevShellWidget(TQWidget *parent, const char *name)
24  : TQVBox(parent, name), m_doAutoActivate( false ), m_isRunning( false )
25 {
26 }
27 
28 
29 KDevShellWidget::~KDevShellWidget()
30 {
31 }
32 
33 void KDevShellWidget::setShell( const TQString & shell, const TQStrList & arguments )
34 {
35  m_shellName = shell;
36  m_shellArguments = arguments;
37 }
38 
39 void KDevShellWidget::activate( )
40 {
41  KLibFactory *factory = KLibLoader::self()->factory("libkonsolepart");
42  if ( !factory ) return;
43 
44  m_konsolePart = (KParts::ReadOnlyPart *) factory->create( TQT_TQOBJECT(this), "libkonsolepart", "KParts::ReadOnlyPart" );
45  if ( !m_konsolePart ) return;
46 
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()) );
50 
51  m_konsolePart->widget()->setFocusPolicy( TQ_WheelFocus );
52  setFocusProxy( m_konsolePart->widget() );
53  m_konsolePart->widget()->setFocus();
54 
55  if ( m_konsolePart->widget()->inherits(TQFRAME_OBJECT_NAME_STRING) )
56  ((TQFrame*)m_konsolePart->widget())->setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
57 
58  m_konsolePart->widget()->show();
59 
60  TerminalInterface* ti = static_cast<TerminalInterface*>( m_konsolePart->tqt_cast( "TerminalInterface" ) );
61  if( !ti ) return;
62 
63  if ( !m_shellName.isEmpty() )
64  ti->startProgram( m_shellName, m_shellArguments );
65 
66  m_isRunning = true;
67 
68 }
69 
70 void KDevShellWidget::partDestroyed( )
71 {
72  if ( m_doAutoActivate )
73  {
74  activate();
75  }
76 }
77 
78 void KDevShellWidget::processExited( TDEProcess * proc )
79 {
80  m_isRunning = false;
81 
82  if ( !proc ) return;
83 
84  kdDebug(9000) << proc->args() << endl;
85 
86  if ( proc->normalExit() )
87  emit shellExited( proc->exitStatus() );
88  else if ( proc->signalled() )
89  emit shellSignalled( proc->exitSignal() );
90 }
91 
92 void KDevShellWidget::sendInput( const TQString & text )
93 {
94  if ( !m_konsolePart ) return;
95  TerminalInterface* ti = static_cast<TerminalInterface*>( m_konsolePart->tqt_cast( "TerminalInterface" ) );
96  if( !ti ) return;
97 
98  ti->sendInput( text );
99 }
100 
101 bool KDevShellWidget::isRunning( )
102 {
103  return m_isRunning;
104 }
105 
106 void KDevShellWidget::setAutoReactivateOnClose( bool doAutoActivate )
107 {
108  // to auto reactivate can be dangerous, do it like this to avoid
109  // reactivating with a non-working setting (the partDestroyed()
110  // slot will have ran before m_doAutoActivate is set)
111  if ( doAutoActivate )
112  TQTimer::singleShot( 3000, this, TQT_SLOT(setAutoReactivateOnCloseDelayed()) );
113  else
114  m_doAutoActivate = false;
115 }
116 
117 void KDevShellWidget::setAutoReactivateOnCloseDelayed( )
118 {
119  m_doAutoActivate = true;
120 }
121 
122 
123 #include "kdevshellwidget.moc"
124 
125 // kate: space-indent off; indent-width 4; tab-width 4; show-tabs off;

KDevelop Utility Library

Skip menu "KDevelop Utility Library"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

KDevelop Utility Library

Skip menu "KDevelop Utility Library"
  • buildtools
  •   lib
  •     base
  •     parsers
  •       autotools
  •       qmake
  •     widgets
  •   api
  • languages
  •   lib
  •     debugger
  •     designer_integration
  •     interfaces
  • lib
  •   catalog
  •   interfaces
  •     extensions
  •     external
  •     extras
  •   util
  •   widgets
  •     propeditor
  • parts
  •   documentation
  •     interfaces
  • src
  •   profileengine
  •     lib
Generated for KDevelop Utility Library by doxygen 1.8.13
This website is maintained by Timothy Pearson.