1 | /* |
2 | * Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com) |
3 | * |
4 | * This program is free software: you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License as published by |
6 | * the Free Software Foundation, either version 3 of the License, or |
7 | * (at your option) any later version. |
8 | * |
9 | * This program is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU General Public License |
15 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
16 | */ |
17 | #ifndef RUNNER_H |
18 | #define RUNNER_H |
19 | |
20 | #include <QThread> |
21 | |
22 | class Runner : public QThread |
23 | { |
24 | Q_OBJECT |
25 | public: |
26 | explicit Runner(const QString& filename, const QString& arguments, const QString& workDir, QObject *parent = nullptr); |
27 | |
28 | bool pausing() const; |
29 | |
30 | // time (in milliseconds) waiting for process finished in each processing loop |
31 | int waitForFinishTime() const; |
32 | void setWaitForFinishTime(int newWaitForFinishTime); |
33 | |
34 | signals: |
35 | void started(); |
36 | void terminated(); |
37 | void runErrorOccurred(const QString& reason); |
38 | void pausingForFinish(); // finish but pausing |
39 | |
40 | public slots: |
41 | void stop(); |
42 | protected: |
43 | virtual void doStop(); |
44 | void setPausing(bool newCanFinish); |
45 | protected: |
46 | bool mPausing; |
47 | bool mStop; |
48 | QString mFilename; |
49 | QString mArguments; |
50 | QString mWorkDir; |
51 | int mWaitForFinishTime; |
52 | }; |
53 | |
54 | #endif // RUNNER_H |
55 | |