File indexing completed on 2024-04-28 04:37:24
0001 /* 0002 SPDX-FileCopyrightText: 2007-2008 Hamish Rodda <rodda@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KDEVPLATFORM_RUNCONTROLLER_H 0008 #define KDEVPLATFORM_RUNCONTROLLER_H 0009 0010 #include <QItemDelegate> 0011 0012 #include <KColorScheme> 0013 0014 #include <interfaces/ilaunchconfiguration.h> 0015 #include <interfaces/iruncontroller.h> 0016 0017 #include "shellexport.h" 0018 0019 class QStyleOptionViewItem; 0020 class QModelIndex; 0021 class KStatefulBrush; 0022 0023 namespace KDevelop 0024 { 0025 class Context; 0026 class ContextMenuExtension; 0027 class IPlugin; 0028 class IProject; 0029 class LaunchConfiguration; 0030 class LaunchConfigurationType; 0031 class RunControllerPrivate; 0032 0033 class KDEVPLATFORMSHELL_EXPORT RunController : public IRunController 0034 { 0035 Q_OBJECT 0036 Q_CLASSINFO("D-Bus Interface", "org.kdevelop.RunController") 0037 0038 public: 0039 explicit RunController(QObject *parent); 0040 ~RunController() override; 0041 0042 void registerJob(KJob *job) override; 0043 void unregisterJob(KJob *job) override; 0044 QList<KJob*> currentJobs() const override; 0045 0046 KJob* execute(const QString& launchMode, ILaunchConfiguration* launch) override; 0047 QList<ILaunchMode*> launchModes() const override; 0048 0049 /** 0050 * @copydoc IRunController::addLaunchMode 0051 */ 0052 void addLaunchMode( ILaunchMode* mode ) override; 0053 0054 /** 0055 * @copydoc IRunController::removeLaunchMode 0056 */ 0057 void removeLaunchMode( ILaunchMode* mode ) override; 0058 0059 /** 0060 * @copydoc IRunController::launchModeForId() 0061 */ 0062 KDevelop::ILaunchMode* launchModeForId(const QString& id) const override; 0063 0064 void initialize(); 0065 void cleanup(); 0066 0067 QItemDelegate* delegate() const; 0068 0069 void addLaunchConfiguration( LaunchConfiguration* l ); 0070 void removeLaunchConfiguration( LaunchConfiguration* l ); 0071 0072 QList<LaunchConfiguration*> launchConfigurationsInternal() const; 0073 QList<ILaunchConfiguration*> launchConfigurations() const override; 0074 /** 0075 * @copydoc IRunController::launchConfigurationTypes() 0076 */ 0077 QList<LaunchConfigurationType*> launchConfigurationTypes() const override; 0078 0079 /** 0080 * @copydoc IRunController::addConfigurationType() 0081 */ 0082 void addConfigurationType( LaunchConfigurationType* type ) override; 0083 0084 /** 0085 * @copydoc IRunController::removeConfigurationType() 0086 */ 0087 void removeConfigurationType( LaunchConfigurationType* type ) override; 0088 0089 /** 0090 * Find the launch configuration type for the given @p id. 0091 * @returns the launch configuration type having the id, or 0 if no such type is known 0092 */ 0093 LaunchConfigurationType* launchConfigurationTypeForId( const QString& ) override; 0094 0095 ILaunchConfiguration* createLaunchConfiguration ( LaunchConfigurationType* type, 0096 const QPair<QString,QString>& launcher, 0097 IProject* project = nullptr, 0098 const QString& name = QString() ) override; 0099 0100 void setDefaultLaunch(ILaunchConfiguration* l); 0101 LaunchConfiguration* defaultLaunch() const; 0102 0103 /** 0104 * @copydoc IRunController::showConfigurationDialog() 0105 */ 0106 void showConfigurationDialog() const override; 0107 0108 ContextMenuExtension contextMenuExtension(KDevelop::Context* ctx, QWidget* parent); 0109 0110 public Q_SLOTS: 0111 Q_SCRIPTABLE void executeDefaultLaunch(const QString& runMode) override; 0112 0113 Q_SCRIPTABLE void stopAllProcesses() override; 0114 0115 protected Q_SLOTS: 0116 void finished(KJob *job) override; 0117 void suspended(KJob *job) override; 0118 void resumed(KJob *job) override; 0119 0120 private Q_SLOTS: 0121 void slotExecute(); 0122 void slotDebug(); 0123 void slotProfile(); 0124 void slotProjectOpened(KDevelop::IProject* project); 0125 void slotProjectClosing(KDevelop::IProject* project); 0126 void slotKillJob(); 0127 void launchChanged(LaunchConfiguration*); 0128 void jobDestroyed(QObject* job); 0129 void jobPercentChanged(); 0130 0131 private: 0132 void setupActions(); 0133 void checkState(); 0134 void removeLaunchConfigurationInternal( LaunchConfiguration* l ); 0135 0136 private: 0137 const QScopedPointer<class RunControllerPrivate> d_ptr; 0138 Q_DECLARE_PRIVATE(RunController) 0139 }; 0140 0141 class RunDelegate : public QItemDelegate 0142 { 0143 Q_OBJECT 0144 public: 0145 explicit RunDelegate( QObject* = nullptr ); 0146 void paint(QPainter*, const QStyleOptionViewItem&, const QModelIndex&) const override; 0147 private: 0148 KStatefulBrush runProviderBrush; 0149 KStatefulBrush errorBrush; 0150 }; 0151 0152 } 0153 0154 #endif