added api autobot pause method
This commit is contained in:
parent
840bbb1a1c
commit
b26232d348
5 changed files with 33 additions and 2 deletions
|
@ -19,12 +19,11 @@ function main()
|
|||
{name: "Select Piano", func: function() {
|
||||
api.navigation.goToControl("NewScoreDialog", "FamilyView", "Keyboards")
|
||||
api.navigation.goToControl("NewScoreDialog", "InstrumentsView", "Piano")
|
||||
|
||||
|
||||
}},
|
||||
{name: "Select Piano (apply)", func: function() {
|
||||
api.navigation.goToControl("NewScoreDialog", "SelectPanel", "Select")
|
||||
api.navigation.trigger()
|
||||
api.autobot.pause()
|
||||
|
||||
}},
|
||||
{name: "Done", func: function() {
|
||||
|
|
|
@ -40,6 +40,25 @@ bool AutobotApi::openProject(const QString& name)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void AutobotApi::abort()
|
||||
{
|
||||
m_abort = true;
|
||||
}
|
||||
|
||||
bool AutobotApi::pause()
|
||||
{
|
||||
using namespace mu::framework;
|
||||
IInteractive::Result res = interactive()->question("Pause", "Continue?",
|
||||
{ IInteractive::Button::Continue, IInteractive::Button::Abort });
|
||||
|
||||
if (res.standardButton() == IInteractive::Button::Abort) {
|
||||
abort();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AutobotApi::sleep(int msec)
|
||||
{
|
||||
if (msec < 0) {
|
||||
|
@ -60,6 +79,7 @@ void AutobotApi::setInterval(int msec)
|
|||
|
||||
void AutobotApi::runTestCase(QJSValue testCase)
|
||||
{
|
||||
m_abort = false;
|
||||
m_testCase.testCase = testCase;
|
||||
m_testCase.steps = testCase.property("steps");
|
||||
m_testCase.stepsCount = m_testCase.steps.property("length").toInt();
|
||||
|
@ -74,6 +94,11 @@ void AutobotApi::runTestCase(QJSValue testCase)
|
|||
|
||||
void AutobotApi::nextStep()
|
||||
{
|
||||
if (m_abort) {
|
||||
m_testCase.loop.quit();
|
||||
return;
|
||||
}
|
||||
|
||||
m_testCase.currentStepIdx += 1;
|
||||
|
||||
if (m_testCase.currentStepIdx >= m_testCase.stepsCount) {
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "modularity/ioc.h"
|
||||
#include "project/iprojectfilescontroller.h"
|
||||
#include "autobot/iautobotconfiguration.h"
|
||||
#include "iinteractive.h"
|
||||
|
||||
namespace mu::api {
|
||||
class AutobotApi : public ApiObject
|
||||
|
@ -38,6 +39,7 @@ class AutobotApi : public ApiObject
|
|||
|
||||
INJECT(api, autobot::IAutobotConfiguration, autobotConfiguration)
|
||||
INJECT(api, project::IProjectFilesController, projectFilesController)
|
||||
INJECT(api, framework::IInteractive, interactive)
|
||||
|
||||
public:
|
||||
explicit AutobotApi(IApiEngine* e);
|
||||
|
@ -47,6 +49,8 @@ public:
|
|||
|
||||
Q_INVOKABLE bool openProject(const QString& name);
|
||||
|
||||
Q_INVOKABLE void abort();
|
||||
Q_INVOKABLE bool pause();
|
||||
Q_INVOKABLE void sleep(int msec = -1);
|
||||
|
||||
private:
|
||||
|
@ -65,6 +69,7 @@ private:
|
|||
|
||||
int m_intervalMsec = 1000;
|
||||
TestCase m_testCase;
|
||||
bool m_abort = false;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ public:
|
|||
Apply,
|
||||
Reset,
|
||||
RestoreDefaults,
|
||||
Continue,
|
||||
|
||||
CustomButton
|
||||
};
|
||||
|
|
|
@ -90,6 +90,7 @@ IInteractive::ButtonData Interactive::buttonData(Button b) const
|
|||
case IInteractive::Button::Apply: return ButtonData(int(b), trc("ui", "Apply"));
|
||||
case IInteractive::Button::Reset: return ButtonData(int(b), trc("ui", "Reset"));
|
||||
case IInteractive::Button::RestoreDefaults: return ButtonData(int(b), trc("ui", "Restore Defaults"));
|
||||
case IInteractive::Button::Continue: return ButtonData(int(b), trc("ui", "Continue"));
|
||||
case IInteractive::Button::CustomButton: return ButtonData(int(b), "");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue