1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #ifndef PROCESSDIALOG_H |
6 | #define PROCESSDIALOG_H |
7 | |
8 | #include <QDialog> |
9 | #include <QProcess> |
10 | #include <QProgressBar> |
11 | #include <QTextBrowser> |
12 | #include <QVBoxLayout> |
13 | |
14 | class ProcessDialog : public QDialog |
15 | { |
16 | Q_OBJECT |
17 | public: |
18 | explicit ProcessDialog(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); |
19 | virtual ~ProcessDialog(); |
20 | void setProgram(const QString & program); |
21 | QString program() const; |
22 | void setArguments(const QStringList &args); |
23 | QStringList arguments(); |
24 | void setWorkingDirectory(const QString &workDir); |
25 | QString workDirectory() const; |
26 | void setEnvironment(const QStringList &env); |
27 | virtual int exec() override; |
28 | |
29 | protected: |
30 | virtual void doShowStdErr(const QByteArray &array); |
31 | virtual void doShowStdOut(const QByteArray &array); |
32 | virtual void doFinished(int exitCode, QProcess::ExitStatus status); |
33 | virtual void doShowProgress(int current, int count); |
34 | |
35 | protected: |
36 | QProcess process; |
37 | QProgressBar *progressBar{nullptr}; |
38 | QTextBrowser *textBrowser{nullptr}; |
39 | QVBoxLayout *vLayout{nullptr}; |
40 | }; |
41 | |
42 | #endif // PROCESSDIALOG_H |
43 | |