File indexing completed on 2024-04-21 05:03:23
0001 /*************************************************************************************** 0002 begin : mon 3-11 20:40:00 CEST 2003 0003 copyright : (C) 2003 by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net) 0004 2008-2019 by Michel Ludwig (michel.ludwig@kdemail.net) 0005 ***************************************************************************************/ 0006 0007 /*************************************************************************** 0008 * * 0009 * This program is free software; you can redistribute it and/or modify * 0010 * it under the terms of the GNU General Public License as published by * 0011 * the Free Software Foundation; either version 2 of the License, or * 0012 * (at your option) any later version. * 0013 * * 0014 ***************************************************************************/ 0015 0016 #ifndef KILE_LAUNCHER 0017 #define KILE_LAUNCHER 0018 0019 #include <QObject> 0020 #include <QProcess> 0021 0022 class KProcess; 0023 0024 class KileInfo; 0025 0026 namespace KParts { 0027 class ReadOnlyPart; 0028 class PartManager; 0029 } 0030 0031 namespace KileTool 0032 { 0033 class Base; 0034 0035 /** 0036 * This class represents a way to launch a tool. This could be a commandline tool 0037 * running in a Konsole, running as a separate process, it could even be responsible 0038 * for starting a KPart. 0039 * 0040 * @author Jeroen Wijnhout 0041 **/ 0042 class Launcher : public QObject 0043 { 0044 Q_OBJECT 0045 0046 public: 0047 Launcher(); 0048 ~Launcher(); 0049 0050 public Q_SLOTS: 0051 virtual bool launch() = 0; 0052 virtual void kill(bool emitSignals = true) = 0; 0053 virtual bool selfCheck() = 0; 0054 0055 public: 0056 virtual void setWorkingDirectory(const QString &) {} 0057 0058 void setTool(Base *tool) { 0059 m_tool = tool; 0060 } 0061 Base* tool() { 0062 return m_tool; 0063 } 0064 0065 Q_SIGNALS: 0066 void message(int, const QString&); 0067 void output(const QString&); 0068 0069 void exitedWith(int); 0070 void abnormalExit(); 0071 0072 void done(int); 0073 0074 private: 0075 //QDict<QString> *m_pdictParams; 0076 Base *m_tool; 0077 }; 0078 0079 class ProcessLauncher : public Launcher 0080 { 0081 Q_OBJECT 0082 0083 public: 0084 ProcessLauncher(); 0085 ~ProcessLauncher(); 0086 0087 public: 0088 virtual void setWorkingDirectory(const QString &wd) override; 0089 void changeToWorkingDirectory(bool change); 0090 void setCommand(const QString& cmd); 0091 void setOptions(const QString& opt); 0092 0093 public Q_SLOTS: 0094 virtual bool launch() override; 0095 virtual void kill(bool emitSignals = true) override; 0096 virtual bool selfCheck() override; 0097 0098 private Q_SLOTS: 0099 void slotProcessOutput(); 0100 void slotProcessExited(int exitCode, QProcess::ExitStatus exitStatus); 0101 void slotProcessError(QProcess::ProcessError error); 0102 0103 private: 0104 QString m_wd, m_cmd; 0105 QString m_options; 0106 KProcess *m_proc; 0107 bool m_changeTo; 0108 }; 0109 0110 class KonsoleLauncher : public ProcessLauncher 0111 { 0112 Q_OBJECT 0113 0114 public: 0115 KonsoleLauncher(); 0116 0117 public Q_SLOTS: 0118 virtual bool launch() override; 0119 }; 0120 0121 class DocumentViewerLauncher : public Launcher 0122 { 0123 Q_OBJECT 0124 0125 public: 0126 DocumentViewerLauncher(); 0127 ~DocumentViewerLauncher(); 0128 0129 public Q_SLOTS: 0130 virtual bool launch() override; 0131 virtual void kill(bool emitSignals = true) override; 0132 virtual bool selfCheck() override; 0133 0134 }; 0135 } 0136 0137 #endif