1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
/***************************************************************************
* Copyright 2003, 2006 Adam Treat <treat@kde.org> *
* Copyright 2007 Andreas Pakulat <apaku@gmx.de> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "kdevkonsoleviewplugin.h"
#include <KLocalizedString>
#include <KService>
#include <interfaces/iuicontroller.h>
#include <interfaces/icore.h>
#include "kdevkonsoleview.h"
#include "debug.h"
QObject* createKonsoleView( QWidget*, QObject* op, const QVariantList& args)
{
KService::Ptr service = KService::serviceByDesktopName(QStringLiteral("konsolepart"));
KPluginFactory* factory = nullptr;
if (service) {
factory = KPluginLoader(*service.data()).factory();
}
if (!factory) {
qCWarning(PLUGIN_KONSOLE) << "Failed to load 'konsolepart' plugin";
}
return new KDevKonsoleViewPlugin(factory, op, args);
}
K_PLUGIN_FACTORY_WITH_JSON(KonsoleViewFactory, "kdevkonsoleview.json", registerPlugin<KDevKonsoleViewPlugin>( QString(), &createKonsoleView );)
class KDevKonsoleViewFactory: public KDevelop::IToolViewFactory{
public:
explicit KDevKonsoleViewFactory(KDevKonsoleViewPlugin *plugin):
mplugin(plugin) {}
QWidget* create(QWidget *parent = nullptr) override
{
return new KDevKonsoleView(mplugin, parent);
}
Qt::DockWidgetArea defaultPosition() const override
{
return Qt::BottomDockWidgetArea;
}
QString id() const override
{
return QStringLiteral("org.kdevelop.KonsoleView");
}
private:
KDevKonsoleViewPlugin *mplugin;
};
KDevKonsoleViewPlugin::KDevKonsoleViewPlugin( KPluginFactory* konsoleFactory, QObject *parent, const QVariantList & )
: KDevelop::IPlugin( QStringLiteral("kdevkonsoleview"), parent )
, m_konsoleFactory(konsoleFactory)
, m_viewFactory(konsoleFactory ? new KDevKonsoleViewFactory(this) : nullptr)
{
if(!m_viewFactory) {
setErrorDescription(i18n("Failed to load 'konsolepart' plugin"));
} else {
core()->uiController()->addToolView(QStringLiteral("Konsole"), m_viewFactory);
}
}
void KDevKonsoleViewPlugin::unload()
{
if (m_viewFactory) {
core()->uiController()->removeToolView(m_viewFactory);
}
}
KPluginFactory* KDevKonsoleViewPlugin::konsoleFactory() const
{
return m_konsoleFactory;
}
KDevKonsoleViewPlugin::~KDevKonsoleViewPlugin()
{
}
#include "kdevkonsoleviewplugin.moc"
|