/* This file is part of the KDE project Copyright (C) 2001 Christoph Cullmann Copyright (C) 2002 Joseph Wenninger Copyright (C) 2002 Anders Lund This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "scriptdebugoutput.h" #include "scriptdebugoutput.moc" #include #include #include #include #include #include #include #include #include //Added by qt3to4: #include #include #include K_EXPORT_COMPONENT_FACTORY( scriptdebugoutputplugin, KGenericFactory( "scriptdebugoutputplugin" ) ) using namespace Kate::Private::Plugin; ScriptDebugOutputPlugin::ScriptDebugOutputPlugin( QObject* parent, const QStringList& ): Kate::Plugin ( (Kate::Application*)parent ) { if (!KAuthorized::authorizeKAction("shell_access")) { KMessageBox::sorry(0, i18n ("You do not have enough karma to access a shell or terminal emulation")); } } void ScriptDebugOutputPlugin::addView(Kate::MainWindow *win) { kDebug()<<"ScriptDebugOutputPlugin::createView"<createToolView ("kate_private_plugin_scriptdebugoutputplugin", MainWindow::Bottom, SmallIcon("bug"), i18n("Script Output")); m_views.append(new ScriptDebugOutput(win,toolview)); } } void ScriptDebugOutputPlugin::removeView(Kate::MainWindow *win) { for(QLinkedList::iterator it=m_views.begin();it!=m_views.end();++it) { if ((*it)->mainWindow()==win) { QWidget *pw=(*it)->parentWidget(); delete *it; delete pw; m_views.erase(it); break; } } } ScriptDebugOutput::ScriptDebugOutput (Kate::MainWindow *mw, QWidget *parent) : KVBox (parent), KXMLGUIClient() , m_part (0) , m_mw (mw) , m_toolView (parent) { /*KAction* a = new KAction(KIcon("pipe"), i18n("&Pipe to Console"), actionCollection(), "ScriptDebugOutput_tools_pipe_to_terminal"); connect(a, SIGNAL(triggered()), this, SLOT(slotPipeToConsole())); setInstance (new KInstance("kate")); setXMLFile("plugins/scriptdebugoutput/ui.rc"); m_mw->guiFactory()->addClient (this); */ } ScriptDebugOutput::~ScriptDebugOutput () { m_mw->guiFactory()->removeClient (this); disconnect ( m_part, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); } void ScriptDebugOutput::loadConsoleIfNeeded() { /* if (m_part) return; if (!window() || !parentWidget()) return; if (!window() || !isVisibleTo(window())) return; KLibFactory *factory = KLibLoader::self()->factory("libdebugoutputpart"); if (!factory) return; m_part = static_cast(factory->create(this, "KParts::ReadOnlyPart")); if (!m_part) return; KGlobal::locale()->insertCatalog("debugoutput"); setFocusProxy(m_part->widget()); m_part->widget()->show(); connect ( m_part, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); */ QObject::connect(application()->editor(), SIGNAL(sDebugScript(QString)), this, SLOT(showMessage(QString))); } void ScriptDebugOutput::slotDestroyed () { m_part = 0; // hide the dockwidget if (parentWidget()) { m_mw->hideToolView (m_toolView); m_mw->centralWidget()->setFocus (); } } void ScriptDebugOutput::showDebug(const QString& str) { kDebug(13051) << "PIPPO: " + str << endl; } void ScriptDebugOutput::showEvent(QShowEvent *) { if (m_part) return; loadConsoleIfNeeded(); }