kateconsole.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "kateconsole.h"
00022 #include "kateconsole.moc"
00023
00024 #include "katemainwindow.h"
00025
00026 #include <kate/view.h>
00027 #include <kate/document.h>
00028
00029 #include <kde_terminal_interface.h>
00030
00031 #include <kurl.h>
00032 #include <klibloader.h>
00033 #include <klocale.h>
00034 #include <kapplication.h>
00035 #include <kdebug.h>
00036
00037 #include <qlayout.h>
00038
00039 KateConsole::KateConsole (QWidget* parent, const char* name, Kate::ViewManager *kvm)
00040 : QWidget (parent, name)
00041 , part (0)
00042 , lo (new QVBoxLayout(this))
00043 , m_kvm (kvm)
00044 {
00045 }
00046
00047 KateConsole::~KateConsole ()
00048 {
00049 }
00050
00051 void KateConsole::loadConsoleIfNeeded()
00052 {
00053
00054
00055 if (part) return;
00056
00057 if (!kapp->loopLevel())
00058 {
00059 connect(kapp,SIGNAL(onEventLoopEnter()),this,SLOT(loadConsoleIfNeeded()));
00060 return;
00061 }
00062
00063 if (!topLevelWidget() || !parentWidget()) return;
00064 if (!topLevelWidget() || !isVisibleTo(topLevelWidget())) return;
00065
00066
00067
00068 KLibFactory *factory = KLibLoader::self()->factory("libkonsolepart");
00069
00070 if (!factory) return;
00071
00072 part = static_cast<KParts::ReadOnlyPart *>(factory->create(this,"libkonsolepart", "KParts::ReadOnlyPart"));
00073
00074 if (!part) return;
00075
00076 KGlobal::locale()->insertCatalogue("konsole");
00077
00078 part->widget()->show();
00079 lo->addWidget(part->widget());
00080
00081 connect ( part, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) );
00082
00083 if (m_kvm->activeView())
00084 if (m_kvm->activeView()->getDoc()->url().isValid())
00085 cd(KURL( m_kvm->activeView()->getDoc()->url().path() ));
00086 }
00087
00088 void KateConsole::showEvent(QShowEvent *)
00089 {
00090 if (part) return;
00091
00092 loadConsoleIfNeeded();
00093 }
00094
00095 void KateConsole::cd (KURL url)
00096 {
00097 if (!part) return;
00098
00099 part->openURL (url);
00100 }
00101
00102 void KateConsole::sendInput( const QString& text )
00103 {
00104 if (!part) return;
00105
00106 TerminalInterface *t = static_cast<TerminalInterface*>( part->qt_cast( "TerminalInterface" ) );
00107
00108 if (!t) return;
00109
00110 t->sendInput (text);
00111 }
00112
00113 void KateConsole::slotDestroyed ()
00114 {
00115 part=0;
00116
00117
00118 if (parentWidget())
00119 parentWidget()->hide ();
00120 }
This file is part of the documentation for kate Library Version 3.4.2.