Skip to content
Snippets Groups Projects
Commit 064bb686 authored by SeeLook's avatar SeeLook
Browse files

TmainScoreObject handles single note routines instead of MainScore.qml

parent d8c2e63a
No related branches found
No related tags found
No related merge requests found
......@@ -460,7 +460,7 @@ void TexamExecutor::askQuestion(bool isAttempt) {
if (!curQ->melody()) {
if (m_level.useKeySign) {
if (m_level.manualKey) { // user have to manually select a key
// if (m_penalty->isNot()) // if black question key mode is defined
// if (m_penalty->isNot()) // if black question key mode is defined (FIXME: What is this dead code?)
// curQ->key.setMinor(bool(qrand() % 2));
// we randomize some key to cover this expected one
TkeySignature fakeKey((qrand() % (m_level.hiKey.value() - m_level.loKey.value() + 1)) + m_level.loKey.value());
......@@ -546,7 +546,7 @@ void TexamExecutor::askQuestion(bool isAttempt) {
if (curQ->questionAsSound())
connect(SOUND, &Tsound::plaingFinished, this, &TexamExecutor::sniffAfterPlaying); // sniffing after finished sound
else
QTimer::singleShot(WAIT_TIME, this, SLOT(startSniffing()));
QTimer::singleShot(WAIT_TIME, [=]{ startSniffing(); });
// Give a student some time to prepare itself for next question in expert mode
// It avoids capture previous played sound as current answer
} else
......
......@@ -25,12 +25,14 @@
#include <tsound.h>
#include <tcolor.h>
#include <music/tkeysignature.h>
#include <score/tnoteobject.h>
#include <QtGui/qguiapplication.h>
#include <QtGui/qpalette.h>
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcomponent.h>
#include <QtQuick/qquickitem.h>
#include <QtCore/qdebug.h>
......@@ -96,6 +98,9 @@ void TmainScoreObject::setScoreObject(TscoreObject* scoreObj) {
connect(m_zoomOutAct, &Taction::triggered, [=]{ m_scoreObj->setScaleFactor(qMax(0.4, m_scoreObj->scaleFactor() - 0.2)); });
connect(m_zoomInAct, &Taction::triggered, [=]{ m_scoreObj->setScaleFactor(qMin(m_scoreObj->scaleFactor() + 0.2, 1.4)); });
connect(GLOB, &Tglobals::isExamChanged, this, &TmainScoreObject::isExamChangedSlot);
connect(m_scoreObj, &TscoreObject::singleNoteChanged, this, &TmainScoreObject::singleModeSlot);
connect(GLOB, &Tglobals::showEnharmNotesChanged, this, &TmainScoreObject::checkSingleNoteVisibility);
connect(GLOB, &Tglobals::enableDoubleAccidsChanged, this, &TmainScoreObject::checkSingleNoteVisibility);
}
......@@ -216,6 +221,22 @@ void TmainScoreObject::isExamChangedSlot() {
}
void TmainScoreObject::singleModeSlot() {
if (GLOB->isSingleNote()) {
m_scoreObj->setRecordMode(false);
if (GLOB->isExam()) {
m_scoreObj->note(1)->setColor(qApp->palette().text().color());
m_scoreObj->note(2)->setColor(qApp->palette().text().color());
} else {
m_scoreObj->note(1)->setColor(GLOB->getEnharmNoteColor());
m_scoreObj->note(2)->setColor(GLOB->getEnharmNoteColor());
}
checkSingleNoteVisibility();
}
}
void TmainScoreObject::paletteSlot() {
if (m_questionMark)
m_questionMark->setProperty("color", scoreBackgroundColor(GLOB->EquestionColor, 40));
......@@ -225,3 +246,11 @@ void TmainScoreObject::paletteSlot() {
QColor TmainScoreObject::scoreBackgroundColor(const QColor& c, int alpha) {
return Tcolor::merge(NOO->alpha(c, alpha), qApp->palette().base().color());
}
void TmainScoreObject::checkSingleNoteVisibility() {
if (m_scoreObj && m_scoreObj->singleNote()) {
m_scoreObj->note(1)->setVisible(GLOB->showEnharmNotes() || GLOB->isExam());;
m_scoreObj->note(2)->setVisible(!GLOB->isExam() && GLOB->showEnharmNotes() && GLOB->enableDoubleAccids());;
}
}
......@@ -109,8 +109,11 @@ protected:
void openXmlActSlot();
void saveXmlActSlot();
void isExamChangedSlot();
void singleModeSlot();
void paletteSlot();
QColor scoreBackgroundColor(const QColor& c, int alpha);
void checkSingleNoteVisibility();
private:
TscoreObject *m_scoreObj = nullptr;
......
......@@ -42,6 +42,7 @@ Score {
scoreObj.nameColor: GLOB.nameColor
scoreObj.nameStyle: GLOB.noteNameStyle
scoreObj.enableDoubleAccidentals: GLOB.enableDoubleAccids
scoreObj.enharmNotesEnabled: GLOB.showEnharmNotes
scoreObj.bgColor: activPal.base
TmainScoreObject {
......@@ -99,7 +100,7 @@ Score {
Connections {
target: SOUND
onInitialized: {
singleNote = GLOB.singleNoteMode
singleNote = Qt.binding(function() { return GLOB.singleNoteMode })
scoreObj.allowAdding = Qt.binding(function() { return !GLOB.singleNoteMode })
enableKeySign = Qt.binding(function() { return GLOB.keySignatureEnabled })
updateScord()
......@@ -109,15 +110,6 @@ Score {
target: GLOB
onKeyNameChanged: keyName.text = Qt.binding(keyName.getKeyNameText)
onClefTypeChanged: score.clef = GLOB.clefType
onSingleNoteModeChanged: {
scoreObj.singleNote = GLOB.singleNoteMode
if (GLOB.singleNoteMode) {
recordMode = false
scoreObj.enharmNotesEnabled = Qt.binding(function() { return GLOB.showEnharmNotes })
scoreObj.note(1).visible = Qt.binding(function() { return GLOB.showEnharmNotes || GLOB.isExam })
scoreObj.note(2).visible = Qt.binding(function() { return GLOB.isExam || (GLOB.showEnharmNotes && GLOB.enableDoubleAccids) })
}
}
}
Connections {
target: GLOB.tuning
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment