File indexing completed on 2024-05-05 16:45:35
0001 /* 0002 SPDX-FileCopyrightText: 2006 Alexander Dymo <adymo@kdevelop.org> 0003 SPDX-FileCopyrightText: 2007 Andreas Pakulat <apaku@gmx.de> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #include "kdevfilemanagerplugin.h" 0009 0010 #include <KLocalizedString> 0011 #include <KPluginFactory> 0012 0013 #include <interfaces/icore.h> 0014 #include <interfaces/iuicontroller.h> 0015 0016 #include "filemanager.h" 0017 0018 K_PLUGIN_FACTORY_WITH_JSON(KDevFileManagerFactory, "kdevfilemanager.json", registerPlugin<KDevFileManagerPlugin>();) 0019 0020 class KDevFileManagerViewFactory: public KDevelop::IToolViewFactory{ 0021 public: 0022 explicit KDevFileManagerViewFactory(KDevFileManagerPlugin *plugin): m_plugin(plugin) {} 0023 QWidget* create(QWidget *parent = nullptr) override 0024 { 0025 Q_UNUSED(parent) 0026 return new FileManager(m_plugin,parent); 0027 } 0028 0029 QList<QAction*> toolBarActions( QWidget* w ) const override 0030 { 0031 auto* m = qobject_cast<FileManager*>(w); 0032 if( m ) 0033 return m->toolBarActions(); 0034 return KDevelop::IToolViewFactory::toolBarActions( w ); 0035 } 0036 0037 Qt::DockWidgetArea defaultPosition() const override 0038 { 0039 return Qt::LeftDockWidgetArea; 0040 } 0041 0042 QString id() const override 0043 { 0044 return QStringLiteral("org.kdevelop.FileManagerView"); 0045 } 0046 0047 bool allowMultiple() const override 0048 { 0049 return true; 0050 } 0051 0052 private: 0053 KDevFileManagerPlugin *m_plugin; 0054 }; 0055 0056 KDevFileManagerPlugin::KDevFileManagerPlugin(QObject *parent, const QVariantList &/*args*/) 0057 :KDevelop::IPlugin(QStringLiteral("kdevfilemanager"), parent) 0058 { 0059 setXMLFile(QStringLiteral("kdevfilemanager.rc")); 0060 0061 QMetaObject::invokeMethod(this, "init", Qt::QueuedConnection); 0062 } 0063 0064 void KDevFileManagerPlugin::init() 0065 { 0066 m_factory = new KDevFileManagerViewFactory(this); 0067 core()->uiController()->addToolView(i18nc("@title:window", "File System"), m_factory); 0068 } 0069 0070 KDevFileManagerPlugin::~KDevFileManagerPlugin() 0071 { 0072 } 0073 0074 void KDevFileManagerPlugin::unload() 0075 { 0076 core()->uiController()->removeToolView(m_factory); 0077 } 0078 0079 #include "kdevfilemanagerplugin.moc" 0080 #include "moc_kdevfilemanagerplugin.cpp"