File indexing completed on 2025-01-05 05:14:49
0001 /* 0002 SPDX-FileCopyrightText: 2021 Hamed Masafi <hamed.masfi@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <QElapsedTimer> 0010 0011 #include "appdialog.h" 0012 #include "libkommitwidgets_export.h" 0013 #include "ui_runnerdialog.h" 0014 0015 #include <QProcess> 0016 0017 namespace Git 0018 { 0019 class AbstractCommand; 0020 class Manager; 0021 } 0022 class LIBKOMMITWIDGETS_EXPORT RunnerDialog : public AppDialog, private Ui::RunnerDialog 0023 { 0024 Q_OBJECT 0025 0026 public: 0027 explicit RunnerDialog(Git::Manager *git, QWidget *parent = nullptr); 0028 void run(const QStringList &args); 0029 void run(Git::AbstractCommand *command); 0030 0031 bool autoClose() const; 0032 void setAutoClose(bool newAutoClose); 0033 0034 private Q_SLOTS: 0035 void git_readyReadStandardOutput(); 0036 void git_readyReadStandardError(); 0037 void git_finished(int exitCode, QProcess::ExitStatus exitStatus); 0038 void slotPushButtonCloseClicked(); 0039 void slotPushButtonStopClicked(); 0040 0041 private: 0042 QProcess *mGitProcess = nullptr; 0043 Git::Manager *const mGit; 0044 0045 enum Mode { None, RunByArgs, RunByCommand }; 0046 Mode mMode{None}; 0047 Git::AbstractCommand *mCmd{nullptr}; 0048 0049 QElapsedTimer mTimer; 0050 0051 bool mAutoClose{false}; 0052 0053 QByteArray mStandardOutput; 0054 QByteArray mErrorOutput; 0055 };