Skip to content

Commit a244e4e

Browse files
authored
Merge pull request #126 from scratchcpp/abort_question
Fix #92: Hide aborted questions
2 parents 6d5c170 + 4cce7df commit a244e4e

File tree

5 files changed

+18
-1
lines changed

5 files changed

+18
-1
lines changed

libscratchcpp

Submodule libscratchcpp updated 51 files

src/ProjectPlayer.qml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ ProjectScene {
9191
questionLoader.item.clear();
9292
questionLoader.item.question = question;
9393
}
94+
95+
onQuestionAborted: questionLoader.active = false
9496
}
9597

9698
function start() {

src/projectloader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ void ProjectLoader::load()
256256
m_engine->monitorRemoved().connect(&ProjectLoader::removeMonitor, this);
257257

258258
m_engine->questionAsked().connect([this](const std::string &question) { emit questionAsked(QString::fromStdString(question)); });
259+
m_engine->questionAborted().connect([this]() { emit questionAborted(); });
259260

260261
// Load targets
261262
const auto &targets = m_engine->targets();

src/projectloader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ class ProjectLoader : public QObject
110110
void monitorAdded(MonitorModel *model);
111111
void monitorRemoved(MonitorModel *model);
112112
void questionAsked(QString question);
113+
void questionAborted();
113114

114115
protected:
115116
void timerEvent(QTimerEvent *event) override;

test/projectloader/projectloader_test.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,19 @@ TEST_F(ProjectLoaderTest, QuestionAsked)
188188
ASSERT_EQ(args.first().toString(), "test");
189189
}
190190

191+
TEST_F(ProjectLoaderTest, QuestionAborted)
192+
{
193+
ProjectLoader loader;
194+
QSignalSpy spy(&loader, &ProjectLoader::questionAborted);
195+
196+
load(&loader, "load_test.sb3");
197+
198+
auto engine = loader.engine();
199+
ASSERT_TRUE(spy.isEmpty());
200+
engine->questionAborted()();
201+
ASSERT_EQ(spy.count(), 1);
202+
}
203+
191204
TEST_F(ProjectLoaderTest, AnswerQuestion)
192205
{
193206
ProjectLoader loader;

0 commit comments

Comments
 (0)