From 37d93d1af1f2f96f7e78d7e7a440645b5d80fb07 Mon Sep 17 00:00:00 2001 From: SeeLook <seelook@gmail.com> Date: Sun, 18 Sep 2016 14:00:48 +0200 Subject: [PATCH] Stop asking new question under displayed certificate: - Tcanvas::hasCertificate() added and m_certifyTip is simple pointer now - decreased stamp animation time - checking finished note index, when sniffing is just paused between start and finish on the note next melody may be asked --- src/exam/tcanvas.cpp | 7 +++++-- src/exam/tcanvas.h | 8 +++++--- src/exam/texamexecutor.cpp | 10 +++++++++- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/exam/tcanvas.cpp b/src/exam/tcanvas.cpp index 7b704672b..1dd2b5d6a 100644 --- a/src/exam/tcanvas.cpp +++ b/src/exam/tcanvas.cpp @@ -172,6 +172,9 @@ void Tcanvas::startTip() { void Tcanvas::certificateTip() { + if (m_certifyTip) + return; + delete m_questionTip; clearResultTip(); clearWhatNextTip(); @@ -377,7 +380,7 @@ void Tcanvas::clearCanvas() { } delete m_startTip; delete m_questionTip; - delete m_certifyTip; + clearCertificate(); delete m_outTuneTip; clearMelodyCorrectMessage(); } @@ -532,7 +535,7 @@ bool Tcanvas::eventFilter(QObject* obj, QEvent* event) { QMouseEvent *me = static_cast<QMouseEvent *>(event); if (event->type() == QEvent::MouseButtonPress) { if (me->button() == Qt::MiddleButton && me->modifiers() | Qt::ShiftModifier && me->modifiers() | Qt::AltModifier) { - if (m_exam) + if (m_exam && !m_certifyTip) emit certificateMagicKeys(); } } diff --git a/src/exam/tcanvas.h b/src/exam/tcanvas.h index 14ec4cfe2..07c827f18 100644 --- a/src/exam/tcanvas.h +++ b/src/exam/tcanvas.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2012-2015 by Tomasz Bojczuk * + * Copyright (C) 2012-2016 by Tomasz Bojczuk * * tomaszbojczuk@gmail.com * * * * This program is free software; you can redistribute it and/or modify * @@ -103,7 +103,9 @@ public: void detectedNoteTip(const Tnote& note); QString detectedText(const QString& txt); /** Returns bigger @p txt in question color. Used for 'detected' message. */ - + + bool hasCertificate() { return m_certifyTip != 0; } + public slots: void clearResultTip(); // clears tip with results void clearTryAgainTip(); @@ -149,7 +151,7 @@ private: QPointer<TgraphicsTextTip> m_resultTip, m_whatTip, m_startTip, m_tryAgainTip; QPointer<TgraphicsTextTip> m_confirmTip, m_outTuneTip; QPointer<TquestionTip> m_questionTip; - QPointer<TnootkaCertificate> m_certifyTip; + TnootkaCertificate *m_certifyTip; Texam *m_exam; QPointer<TcombinedAnim> m_correctAnim; QTimer *m_timerToConfirm; diff --git a/src/exam/texamexecutor.cpp b/src/exam/texamexecutor.cpp index b740c17e1..81ee3843b 100755 --- a/src/exam/texamexecutor.cpp +++ b/src/exam/texamexecutor.cpp @@ -242,6 +242,9 @@ void TexamExecutor::initializeExecuting() { void TexamExecutor::askQuestion(bool isAttempt) { m_askingTimer->stop(); + if (m_canvas->hasCertificate()) // in auto mode new question can be asked "under" certificate + return; + m_lockRightButt = false; // release mouse button events if (m_exercise && !gl->E->showCorrected) // hide correct action button mW->bar->removeAction(mW->bar->correctAct); @@ -677,6 +680,8 @@ void TexamExecutor::checkAnswer(bool showResults) { markAnswer(curQ); int waitTime = gl->E->questionDelay; + if (m_melody) // increase minimal delay before next question for melodies to 500ms + waitTime = qMax(waitTime, 500); if (m_exercise) { if ((gl->E->autoNextQuest && gl->E->afterMistake != TexamParams::e_continue) || !gl->E->autoNextQuest || gl->E->showCorrected) waitTime = gl->E->correctPreview; // user has to have time to see his mistake and correct answer @@ -701,7 +706,7 @@ void TexamExecutor::checkAnswer(bool showResults) { stopExamSlot(); else { if (curQ->isCorrect()) { - m_askingTimer->start(gl->E->questionDelay); + m_askingTimer->start(m_melody ? qMax(gl->E->questionDelay, 500) : gl->E->questionDelay); } else { if (gl->E->repeatIncorrect && !m_incorrectRepeated) { if (curQ->melody()) @@ -1418,6 +1423,9 @@ void TexamExecutor::noteOfMelodyStarted(const TnoteStruct& n) { void TexamExecutor::noteOfMelodyFinished(const TnoteStruct& n) { // Tnote nn = n.pitch; // qDebug() << "[TexamExecutor] note finished" << nn.toText(); + if (m_melody->currentIndex() < 0) // meanwhile new question melody was asked - some undesired note was finished + return; + m_melody->setNote(n); if (m_melody->currentIndex() == m_exam->curQ()->melody()->length() - 1) { if (gl->E->expertsAnswerEnable) -- GitLab