File indexing completed on 2024-05-05 16:46:03
0001 /* 0002 SPDX-FileCopyrightText: 2010 Milian Wolff <mail@milianw.de> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KDEVPLATFORM_PLUGIN_IOPENWITH_H 0008 #define KDEVPLATFORM_PLUGIN_IOPENWITH_H 0009 0010 #include <QUrl> 0011 0012 #include <interfaces/icore.h> 0013 #include <interfaces/iplugincontroller.h> 0014 #include <interfaces/idocumentcontroller.h> 0015 #include <interfaces/context.h> 0016 0017 namespace KDevelop { 0018 0019 /** 0020 * Interface for the OpenWith plugin. 0021 */ 0022 class IOpenWith { 0023 public: 0024 virtual ~IOpenWith() {} 0025 /** 0026 * Open @p files with the preferred applications or parts as chosen by the user. 0027 * 0028 * If the open with plugin was disabled by the user, the files will be opened 0029 * as text documents. 0030 */ 0031 static void openFiles(const QList<QUrl> &files) 0032 { 0033 IPlugin* i = ICore::self()->pluginController()->pluginForExtension( QStringLiteral( "org.kdevelop.IOpenWith" ) ); 0034 if (i) { 0035 auto* openWith = i->extension<KDevelop::IOpenWith>(); 0036 Q_ASSERT(openWith); 0037 openWith->openFilesInternal(files); 0038 return; 0039 } 0040 0041 for (const QUrl& url : files) { 0042 ICore::self()->documentController()->openDocument( url ); 0043 } 0044 } 0045 0046 protected: 0047 virtual void openFilesInternal(const QList<QUrl> &files) = 0; 0048 }; 0049 0050 } 0051 0052 Q_DECLARE_INTERFACE( KDevelop::IOpenWith, "org.kdevelop.IOpenWith" ) 0053 0054 #endif // KDEVPLATFORM_PLUGIN_IOPENWITH_H