File indexing completed on 2024-04-21 04:34:28
0001 /* 0002 * This file is part of KDevelop project 0003 * Copyright 2016 Patrick José Pereira <patrickelectric@gmail.com> 0004 * Copyright 2009 Andreas Pakulat <apaku@gmx.de> 0005 * 0006 * This program is free software; you can redistribute it and/or modify 0007 * it under the terms of the GNU Library General Public License as 0008 * published by the Free Software Foundation; either version 2 of the 0009 * License, or (at your option) any later version. 0010 * 0011 * This program is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 * GNU General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU General Public 0017 * License along with this program; if not, write to the 0018 * Free Software Foundation, Inc., 0019 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0020 */ 0021 0022 #pragma once 0023 0024 #include <interfaces/launchconfigurationtype.h> 0025 #include <interfaces/launchconfigurationpage.h> 0026 #include <interfaces/ilauncher.h> 0027 #include <interfaces/ilaunchmode.h> 0028 0029 #include "arduinowindowmodel.h" 0030 #include "ui_embeddedlauncher.h" 0031 0032 class Board; 0033 0034 class EmbeddedLauncherConfigPage : public KDevelop::LaunchConfigurationPage, Ui::NativeAppPage 0035 { 0036 Q_OBJECT 0037 public: 0038 explicit EmbeddedLauncherConfigPage(QWidget* parent); 0039 ~EmbeddedLauncherConfigPage() override; 0040 void loadFromConfiguration(const KConfigGroup& cfg, KDevelop::IProject* project = nullptr) override; 0041 void saveToConfiguration(KConfigGroup cfg, KDevelop::IProject* project = nullptr) const override; 0042 QString title() const override; 0043 QIcon icon() const override; 0044 private: 0045 void mcuComboChanged(int index); 0046 void checkActions(const QItemSelection& , const QItemSelection&); 0047 void boardComboChanged(const QString& text); 0048 void devicesChanged(const QString& udi); 0049 void selectItemDialog(); 0050 void presetsChanged(int index); 0051 0052 const QString mcuTooltip(); 0053 const QString baudTooltip(); 0054 const QString commandTooltip(); 0055 const QString argumentsTooltip(); 0056 const QString interfaceTooltip(); 0057 const QStringList mcuList(); 0058 0059 ArduinoWindowModel *m_model; 0060 0061 Board *m_board; 0062 QStringList m_mcu; 0063 QStringList m_baud; 0064 QString m_openocdExec; 0065 QDir m_boardImgsDir; 0066 QPixmap m_pixBuffer; 0067 }; 0068 0069 class EmbeddedLauncher : public KDevelop::ILauncher 0070 { 0071 public: 0072 EmbeddedLauncher(); 0073 QList< KDevelop::LaunchConfigurationPageFactory* > configPages() const override; 0074 QString description() const override; 0075 QString id() override; 0076 QString name() const override; 0077 KJob* start(const QString& launchMode, KDevelop::ILaunchConfiguration* cfg) override; 0078 QStringList supportedModes() const override; 0079 }; 0080 0081 class NativeAppPageFactory : public KDevelop::LaunchConfigurationPageFactory 0082 { 0083 public: 0084 NativeAppPageFactory(); 0085 KDevelop::LaunchConfigurationPage* createWidget(QWidget* parent) override; 0086 }; 0087 0088 /** 0089 * A specific configuration to start a launchable, this could be a native 0090 * compiled application, or some script file or byte-compiled file or something else 0091 * Provides access to the various configured informations, as well as its type and a name 0092 */ 0093 class NativeAppConfigType : public KDevelop::LaunchConfigurationType 0094 { 0095 Q_OBJECT 0096 public: 0097 NativeAppConfigType(); 0098 ~NativeAppConfigType() override; 0099 0100 QString id() const override; 0101 QString name() const override; 0102 QList<KDevelop::LaunchConfigurationPageFactory*> configPages() const override; 0103 QIcon icon() const override; 0104 bool canLaunch(KDevelop::ProjectBaseItem* item) const override; 0105 bool canLaunch(const QUrl& file) const override; 0106 void configureLaunchFromItem(KConfigGroup cfg, 0107 KDevelop::ProjectBaseItem* item) const override; 0108 void configureLaunchFromCmdLineArguments(KConfigGroup cfg, 0109 const QStringList& args) const override; 0110 QMenu* launcherSuggestions() override; 0111 private: 0112 QList<KDevelop::LaunchConfigurationPageFactory*> factoryList; 0113 0114 public slots: 0115 void suggestionTriggered(); 0116 }; 0117