Skip to content

Commit

Permalink
App: more documentation for DialogExecScript
Browse files Browse the repository at this point in the history
  • Loading branch information
HuguesDelorme committed Jul 19, 2024
1 parent f9d4cf4 commit d6e76e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/app/dialog_exec_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ void DialogExecScript::setScriptFilePath(const FilePath& scriptFilePath)

void DialogExecScript::startScript()
{
if (m_scriptExecIsRunning)
return;

m_scriptExecTaskId = m_taskMgr.newTask([=](TaskProgress*) {
// Override the "console output" handler of LogMessageHandler, first keep the current handler
// so it can be restored before exiting
Expand Down
13 changes: 9 additions & 4 deletions src/app/dialog_exec_script.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,29 @@
#include "../base/task_manager.h"

#include <QtWidgets/QDialog>

#include <functional>

class QJSEngine;

namespace Mayo {

using ScriptEngineCreator = std::function<QJSEngine*(QObject*)>;

// Provides a dialog to control execution of a JS script
class DialogExecScript : public QDialog {
Q_OBJECT
public:
// Ctor & dtor
DialogExecScript(QWidget* parent = nullptr);
~DialogExecScript();

// Set the function used to create a JS engine to evaluate scripts
using ScriptEngineCreator = std::function<QJSEngine*(QObject*)>;
void setScriptEngineCreator(ScriptEngineCreator fn);

// Path to the script file to be executed
void setScriptFilePath(const FilePath& scriptFilePath);

// Asynchronous execution of script file defined with setScriptFilePath()
// Does nothing(returns) if script execution is currently running
void startScript();

private:
Expand All @@ -39,7 +44,7 @@ class DialogExecScript : public QDialog {
struct Message {
QtMsgType type = QtDebugMsg;
QString text;
QString contextFile = nullptr;
QString contextFile;
int contextLine = -1;
};

Expand Down

0 comments on commit d6e76e1

Please sign in to comment.