8 #include "ui_FileRunner.h"
15 #include <QFileDialog>
16 #include <QResizeEvent>
20 : QDialog(parent), m_interpreter(interp), m_busyWidget(nullptr), m_ui(new
Ui::
FileRunner)
24 m_ui->runFileBtn->setEnabled(
false);
25 m_ui->runFileBtn->setIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowRight));
29 connect(m_ui->selectFileBtn, &QPushButton::clicked,
this, &FileRunner::selectFile);
30 connect(m_ui->runFileBtn, &QPushButton::clicked,
this, &FileRunner::runFile);
36 void FileRunner::selectFile()
38 m_filePath = QFileDialog::getOpenFileName(
this,
39 QStringLiteral(
"Select Python Script"),
41 QStringLiteral(
"Python Script (*.py)"));
42 m_ui->filePathLabel->setText(m_filePath);
43 m_ui->runFileBtn->setEnabled(!m_filePath.isEmpty());
46 void FileRunner::runFile()
const
48 if (!m_filePath.isEmpty() && m_interpreter)
50 const std::string
path = m_filePath.toStdString();
55 void FileRunner::pythonExecutionStarted()
58 m_busyWidget->
start();
61 void FileRunner::pythonExecutionEnded()
74 m_busyWidget->resize(
event->size());
75 QDialog::resizeEvent(
event);
void resizeEvent(QResizeEvent *event) override
~FileRunner() noexcept override
FileRunner(PythonInterpreter *interp, QWidget *parent=nullptr)
bool executeFile(const std::string &filePath)
Execution functions (and slots)
static const std::string path