File indexing completed on 2024-04-28 04:38:39
0001 /* 0002 SPDX-FileCopyrightText: 2009 Andreas Pakulat <apaku@gmx.de> 0003 SPDX-FileCopyrightText: 2009 Niko Sams <niko.sams@gmail.com> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef PLASMOIDEXECUTIONCONFIG_H 0009 #define PLASMOIDEXECUTIONCONFIG_H 0010 0011 #include <interfaces/launchconfigurationtype.h> 0012 #include <interfaces/launchconfigurationpage.h> 0013 #include <interfaces/ilauncher.h> 0014 #include <interfaces/ilaunchmode.h> 0015 0016 #include "ui_plasmoidexecutionconfig.h" 0017 0018 class ExecutePlasmoidPlugin; 0019 0020 class PlasmoidExecutionConfig : public KDevelop::LaunchConfigurationPage, Ui::PlasmoidExecutionPage 0021 { 0022 Q_OBJECT 0023 public: 0024 explicit PlasmoidExecutionConfig( QWidget* parent ); 0025 void loadFromConfiguration( const KConfigGroup& cfg, KDevelop::IProject* project = nullptr ) override; 0026 void saveToConfiguration( KConfigGroup cfg, KDevelop::IProject* project = nullptr ) const override; 0027 QString title() const override; 0028 QIcon icon() const override; 0029 }; 0030 0031 class PlasmoidLauncher : public KDevelop::ILauncher 0032 { 0033 public: 0034 explicit PlasmoidLauncher( ExecutePlasmoidPlugin* plugin ); 0035 QList< KDevelop::LaunchConfigurationPageFactory* > configPages() const override; 0036 QString description() const override; 0037 QString id() override; 0038 QString name() const override; 0039 KJob* start(const QString& launchMode, KDevelop::ILaunchConfiguration* cfg) override; 0040 virtual KJob* dependencies(KDevelop::ILaunchConfiguration* cfg); 0041 QStringList supportedModes() const override; 0042 0043 static KJob* calculateDependencies(KDevelop::ILaunchConfiguration* cfg); 0044 private: 0045 ExecutePlasmoidPlugin* m_plugin; 0046 }; 0047 0048 class PlasmoidPageFactory : public KDevelop::LaunchConfigurationPageFactory 0049 { 0050 public: 0051 PlasmoidPageFactory(); 0052 KDevelop::LaunchConfigurationPage* createWidget(QWidget* parent) override; 0053 }; 0054 0055 /** 0056 * A specific configuration to start a launchable, this could be a native 0057 * compiled application, or some script file or byte-compiled file or something else 0058 * Provides access to the various configured information, as well as its type and a name 0059 */ 0060 class PlasmoidExecutionConfigType : public KDevelop::LaunchConfigurationType 0061 { 0062 Q_OBJECT 0063 public: 0064 PlasmoidExecutionConfigType(); 0065 ~PlasmoidExecutionConfigType() override; 0066 0067 static QString typeId(); 0068 QString id() const override { return typeId(); } 0069 QString name() const override; 0070 QList<KDevelop::LaunchConfigurationPageFactory*> configPages() const override; 0071 QIcon icon() const override; 0072 bool canLaunch( const QUrl &file ) const override; 0073 bool canLaunch(KDevelop::ProjectBaseItem* item) const override; 0074 void configureLaunchFromItem(KConfigGroup config, KDevelop::ProjectBaseItem* item) const override; 0075 void configureLaunchFromCmdLineArguments(KConfigGroup config, const QStringList& args) const override; 0076 0077 QMenu* launcherSuggestions() override; 0078 0079 private: 0080 QList<KDevelop::LaunchConfigurationPageFactory*> factoryList; 0081 0082 public Q_SLOTS: 0083 void suggestionTriggered(); 0084 }; 0085 #endif 0086