~ubuntu-branches/ubuntu/utopic/kde4libs/utopic

« back to all changes in this revision

Viewing changes to interfaces/terminal/kde_terminal_interface.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-08-01 16:16:35 UTC
  • mfrom: (1.14.20)
  • Revision ID: package-import@ubuntu.com-20120801161635-qewual50h0fwfeju
Tags: 4:4.9.0a-0ubuntu1
New tar from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 * some signals you can connect to.  They aren't in this class cause
33
33
 * we can't have signals without having a QObject, which
34
34
 * TerminalInterface is not.
35
 
 * These are the signals you can connect to:
36
 
 *  void processExited( int status );
37
 
 *  void receivedData( const QString& s );
38
 
 * See the example code below for how to connect to these..
 
35
 *
 
36
 * These are some signals you can connect to:
 
37
 *  void currentDirectoryChanged(const QString& dir);
 
38
 *
 
39
 * See the example code below for how to connect to these.
39
40
 *
40
41
 * Use it like this:
41
42
 * \code
42
 
 *  // fetch the Library..
43
 
 *  KLibFactory* factory = KLibLoader::self()->factory( "libkonsolepart" );
44
 
 *  if ( factory == 0L )
45
 
 *  {
46
 
 *    // inform the user that he should install konsole..
47
 
 *    return;
48
 
 *  }
49
 
 *  // fetch the part..
50
 
 *  KParts::Part* p = static_cast<KParts::Part*>(
51
 
 *      factory->create( this, "tralala", "QObject",
52
 
 *                       "KParts::ReadOnlyPart" ) );
53
 
 *  assert( p );
54
 
 *  setCentralWidget( p->widget() );
55
 
 *
56
 
 *  // cast the part to the TerminalInterface..
57
 
 *  TerminalInterface* t = static_cast<TerminalInterface*>( p->qt_cast( "TerminalInterface" ) );
58
 
 *  if( ! t )
59
 
 *  {
60
 
 *    // This probably happens because the konsole that is installed
61
 
 *    // comes from before KDE 3.2 , and the TerminalInterface is not
62
 
 *    // available..  What you can do here is either inform the user
63
 
 *    // that he needs a more recent konsole, or try to deliver the
64
 
 *    // functionality in some other way...
65
 
 *    return;
66
 
 *  }
 
43
 *  //query the .desktop file to get service information about konsolepart
 
44
 *  KService::Ptr service = KService::serviceByDesktopName("konsolepart");
 
45
 *
 
46
 *  if (!service)
 
47
 *  {
 
48
 *      QMessageBox::critical(this, tr("Konsole not installed"), tr("Please install the kde konsole and try again!"), QMessageBox::Ok);
 
49
 *      return ;
 
50
 *  }
 
51
 *
 
52
 *  // create one instance of konsolepart
 
53
 *  KParts::ReadOnlyPart* p = service->createInstance<KParts::ReadOnlyPart>(parent, parentWidget, QVariantList());
 
54
 *
 
55
 *  if (!p)
 
56
 *  {
 
57
 *      return;
 
58
 *  }
 
59
 *
 
60
 *  // cast the konsolepart to the TerminalInterface..
 
61
 *  TerminalInterface* t = qobject_cast<TerminalInterface*>(p);
 
62
 *
 
63
 *  if (!t)
 
64
 *  {
 
65
 *      return;
 
66
 *  }
 
67
 *
67
68
 *  // now use the interface in all sorts of ways, e.g.
68
69
 *  //    t->showShellInDir( QDir::home().path() );
69
70
 *  // or:
70
 
 *  //    QStrList l;
 
71
 *  //    QStringList l;
71
72
 *  //    l.append( "python" );
72
73
 *  //    t->startProgram( QString::fromUtf8( "/usr/bin/python" ), l);
73
74
 *  // or connect to one of the signals.  Connect to the Part object,
74
75
 *  // not to the TerminalInterface, since the latter is no QObject,
75
76
 *  // and as such cannot have signals..:
76
 
 *  //    connect( p, SIGNAL( processExited( int ) ),
77
 
 *  //             this, SLOT( shellExited( int ) ) );
 
77
 *  //    connect(p, SIGNAL(currentDirectoryChanged(QString)),
 
78
 *  //             this, SLOT(currentDirectoryChanged(QString)));
78
79
 *  // etc.
79
80
 *
80
81
 * \endcode