File indexing completed on 2024-04-28 04:38:40

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 KDEVPLATFORM_PLUGIN_SCRIPTAPPCONFIGTYPE_H
0009 #define KDEVPLATFORM_PLUGIN_SCRIPTAPPCONFIGTYPE_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_scriptappconfig.h"
0017 
0018 class ExecuteScriptPlugin;
0019 
0020 class ScriptAppConfigPage : public KDevelop::LaunchConfigurationPage, Ui::ScriptAppPage
0021 {
0022 Q_OBJECT
0023 public:
0024     explicit ScriptAppConfigPage( 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 ScriptAppLauncher : public KDevelop::ILauncher
0032 {
0033 public:
0034     explicit ScriptAppLauncher( ExecuteScriptPlugin* );
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     QStringList supportedModes() const override;
0041 private:
0042     ExecuteScriptPlugin* m_plugin;
0043 };
0044 
0045 class ScriptAppPageFactory : public KDevelop::LaunchConfigurationPageFactory
0046 {
0047 public:
0048     ScriptAppPageFactory();
0049     KDevelop::LaunchConfigurationPage* createWidget(QWidget* parent) override;
0050 };
0051 
0052 /**
0053  * A specific configuration to start a launchable, this could be a native
0054  * compiled application, or some script file or byte-compiled file or something else
0055  * Provides access to the various configured information, as well as its type and a name
0056  */
0057 class ScriptAppConfigType : public KDevelop::LaunchConfigurationType
0058 {
0059     Q_OBJECT
0060 public:
0061     ScriptAppConfigType();
0062     ~ScriptAppConfigType() override;
0063 
0064     static QString sharedId();
0065 
0066     QString id() const override;
0067     QString name() const override;
0068     QList<KDevelop::LaunchConfigurationPageFactory*> configPages() const override;
0069     QIcon icon() const override;
0070     bool canLaunch( const QUrl& file ) const override;
0071     bool canLaunch(KDevelop::ProjectBaseItem* item) const override;
0072     void configureLaunchFromItem(KConfigGroup config, KDevelop::ProjectBaseItem* item) const override;
0073     void configureLaunchFromCmdLineArguments(KConfigGroup config, const QStringList& args) const override;
0074 
0075 private:
0076     QList<KDevelop::LaunchConfigurationPageFactory*> factoryList;
0077 };
0078 #endif
0079