diff --git a/src/plugins/exam/tcanvas.cpp b/src/plugins/exam/tcanvas.cpp index 5535ec47041693cda8e557b0df6d26dd84a6cae5..30150725004bd7e28cbf256ad108ce0b86b04cee 100644 --- a/src/plugins/exam/tcanvas.cpp +++ b/src/plugins/exam/tcanvas.cpp @@ -67,7 +67,7 @@ QFont smalTipFont(QWidget* w) { /** Multiplexer of question tip scale factor to make it big enough on hi dpi tablet screens */ inline qreal multiScale() { - return qreal(Tmtr::shortScreenSide() / Tmtr::fingerPixels()) / 5.0; + return (static_cast<qreal>(Tmtr::shortScreenSide()) / Tmtr::fingerPixels()) / 5.0; } #endif @@ -82,7 +82,8 @@ Tcanvas::Tcanvas(QGraphicsView* view, Texam* exam) : m_exam(exam), m_timerToConfirm(new QTimer(this)), m_flyEllipse(nullptr), - m_minimizedQuestion(false), m_melodyCorrectMessage(false) + m_minimizedQuestion(false), m_melodyCorrectMessage(false), + m_tipPos(e_bottomRight) { m_scene = m_view->scene(); m_newSize = m_scene->sceneRect().size().toSize(); @@ -305,13 +306,11 @@ void Tcanvas::whatNextTip(bool isCorrect, bool toCorrection) { } whatNextText += br + TexamHelp::toStopExamTxt(QLatin1String("<a href=\"stopExam\">") + pixToHtml(Tpath::img("stopExam"), m_iconSize) + a); m_whatTip = new TgraphicsTextTip(whatNextText, m_view->palette().highlight().color()); -// if (m_guitarFree) // tip is wide there, otherwise text is word-wrapped and is narrowest but higher -// m_whatTip->setTextWidth(m_maxTipWidth); m_scene->addItem(m_whatTip); m_whatTip->setTextInteractionFlags(Qt::LinksAccessibleByMouse | Qt::LinksAccessibleByKeyboard); m_whatTip->setTipMovable(true); connect(m_whatTip, SIGNAL(linkActivated(QString)), this, SLOT(linkActivatedSlot(QString))); - connect(m_whatTip, SIGNAL(moved()), this, SLOT(tipMoved())); + connect(m_whatTip, &TgraphicsTextTip::moved, this, &Tcanvas::tipMoved); #endif setWhatNextPos(); } @@ -371,21 +370,10 @@ void Tcanvas::questionTip() { delete m_outTuneTip; clearWhatNextTip(); clearMelodyCorrectMessage(); - createQuestionTip(); - m_guitarFree = m_questionTip->freeGuitar() && GUITAR->isVisible(); - m_nameFree = m_questionTip->freeName() && SCORE->insertMode() == TmultiScore::e_single; - m_scoreFree = m_questionTip->freeScore(); - if (!m_guitarFree && !m_nameFree && !m_scoreFree) // workaround when only score is visible - m_scoreFree = true; - m_tipPos = e_scoreOver; // score is visible always - if (m_nameFree && SCORE->insertMode() == TmultiScore::e_single) - m_tipPos = e_nameOver; - else if (m_scoreFree) - m_tipPos = e_scoreOver; - else if (m_guitarFree && GUITAR->isVisible()) - m_tipPos = e_guitarOver; - m_questionTip->setMinimized(m_minimizedQuestion); - setQuestionPos(); + createQuestionTip(); + m_tipPos = determineTipPos(); + m_questionTip->setMinimized(m_minimizedQuestion); + setQuestionPos(); } @@ -569,10 +557,6 @@ void Tcanvas::clearMelodyCorrectMessage() { } -void Tcanvas::markAnswer(TQAtype::Etype qType, TQAtype::Etype aType) { -} - - const QRect& Tcanvas::getRect(TQAtype::Etype kindOf) { switch (kindOf) { case TQAtype::e_asNote: @@ -592,12 +576,12 @@ const QRect& Tcanvas::getRect(TQAtype::Etype kindOf) { void Tcanvas::sizeChangedDelayed(const QRectF& newRect) { QSizeF factor(newRect.width() / m_prevSize.width(), newRect.height() / m_prevSize.height()); - for (int i = 0; i < 3; ++i) { - if (!m_posOfQuestTips[i].isNull()) - m_posOfQuestTips[i] = QPointF(m_posOfQuestTips[i].x() * factor.width(), m_posOfQuestTips[i].y() * factor.height()); - if (!m_posOfWhatTips[i].isNull()) - m_posOfWhatTips[i] = QPointF(m_posOfWhatTips[i].x() * factor.width(), m_posOfWhatTips[i].y() * factor.height()); - } + for (int i = 0; i < TIP_POS_NUM; ++i) { + if (!m_posOfQuestTips[i].isNull()) + m_posOfQuestTips[i] = QPointF(m_posOfQuestTips[i].x() * factor.width(), m_posOfQuestTips[i].y() * factor.height()); + if (!m_posOfWhatTips[i].isNull()) + m_posOfWhatTips[i] = QPointF(m_posOfWhatTips[i].x() * factor.width(), m_posOfWhatTips[i].y() * factor.height()); + } if (!m_posOfConfirm.isNull()) m_posOfConfirm = QPointF(m_posOfConfirm.x() * factor.width(), m_posOfConfirm.y() * factor.height()); m_prevSize = newRect.size(); @@ -641,8 +625,6 @@ void Tcanvas::sizeChanged() { if (m_confirmTip) { clearConfirmTip(); // To re-create confirm tip works better than re-scaling showConfirmTip(); -// m_confirmTip->setScale(m_scale * 1.2); -// setConfirmPos(); } if (m_certifyTip) { clearCertificate(); @@ -706,30 +688,27 @@ bool Tcanvas::eventFilter(QObject* obj, QEvent* event) { //################################################################################################## int Tcanvas::getMaxTipHeight() { - if (m_nameFree || m_scoreFree) - return SCORE->height() * 0.6; - else - return GUITAR->height() * 1.1; + if (m_tipPos == e_nameOver || m_tipPos == e_scoreOver) + return SCORE->height() * 0.6; + else + return GUITAR->height() * 1.1; } void Tcanvas::setPosOfTip(TgraphicsTextTip* tip) { - QRect geoRect; - if (m_nameFree) { // middle of the noteName - geoRect = NOTENAME->geometry(); - } else if (m_scoreFree) {// on the score at its center - geoRect = SCORE->geometry(); - fixWidthOverScore(tip); - if (SCORE->insertMode() != TmultiScore::e_single && !GUITAR->isVisible()) // only score - place it bottom right - geoRect = QRect(m_view->width() - tip->realW(), m_view->height() - tip->realH(), tip->realW(), tip->realH()); - } else { // middle of the guitar - geoRect = GUITAR->geometry(); - if (m_exam && !m_exam->melodies()) // in single mode put a tip on the right guitar side, below note name - geoRect.setRect(NOTENAME->x(), GUITAR->y(), NOTENAME->width(), GUITAR->height()); - } - tip->setPos(qMin(geoRect.x() + (geoRect.width() - tip->realW()) / 2, m_view->width() - tip->realW() - 5.0), - qMin(geoRect.y() + (geoRect.height() - tip->realH()) / 2, m_view->height() - tip->realH() - 5.0)); - // qMin guards a tip position in scene boundaries + QRect geoRect; + if (m_tipPos == e_nameOver) { // middle of the noteName + geoRect.setRect(SCORE->x() + SCORE->width(), SCORE->y() + NOTENAME->y(), NOTENAME->width(), NOTENAME->height()); + } else if (m_tipPos == e_scoreOver) {// on the score at its center + geoRect = SCORE->geometry(); + fixWidthOverScore(tip); + } else if (m_tipPos == e_guitarOver) // middle of the guitar + geoRect = GUITAR->geometry(); + else // bottom-right corner + geoRect = QRect(m_view->width() - tip->realW(), m_view->height() - tip->realH(), tip->realW(), tip->realH()); + tip->setPos(qMin(geoRect.x() + (geoRect.width() - tip->realW()) / 2, m_view->width() - tip->realW() - 5.0), + qMin(geoRect.y() + (geoRect.height() - tip->realH()) / 2, m_view->height() - tip->realH() - 5.0)); + // qMin guards a tip position in scene boundaries } @@ -778,19 +757,20 @@ void Tcanvas::setWhatNextPos() { } #else int maxTipHeight = getMaxTipHeight(); - if (!m_nameFree && m_whatTip->realH() != maxTipHeight) - m_whatTip->setScale((qreal)maxTipHeight / m_whatTip->realH()); - if (m_tipPos == e_nameOver) { - if (m_whatTip->realW() != m_view->width() * 0.45) - m_whatTip->setScale((m_view->width() * 0.45) / m_whatTip->realW()); - if (m_whatTip->realH() > SCORE->height()) - m_whatTip->setScale((qreal)(SCORE->height()) / m_whatTip->realH()); - } else - fixWidthOverScore(m_whatTip); - if (m_posOfWhatTips[(int)m_tipPos].isNull()) // calculate tip position only when user doesn't change it - setPosOfTip(m_whatTip); - else - m_whatTip->setFixPos(m_posOfWhatTips[(int)m_tipPos]); + if (m_tipPos != e_nameOver && m_whatTip->realH() != maxTipHeight) + m_whatTip->setScale(maxTipHeight / m_whatTip->realH()); + + if (m_tipPos == e_nameOver) { + if (m_whatTip->realW() != m_view->width() * 0.45) + m_whatTip->setScale((m_view->width() * 0.45) / m_whatTip->realW()); + if (m_whatTip->realH() > SCORE->height()) + m_whatTip->setScale(SCORE->height() / m_whatTip->realH()); + } else + fixWidthOverScore(m_whatTip); + if (m_posOfWhatTips[static_cast<int>(m_tipPos)].isNull()) // calculate tip position only when user doesn't change it + setPosOfTip(m_whatTip); + else + m_whatTip->setFixPos(m_posOfWhatTips[static_cast<int>(m_tipPos)]); #endif } @@ -828,8 +808,8 @@ void Tcanvas::createQuestionTip() { void Tcanvas::setQuestionPos() { - int maxTipHeight = getMaxTipHeight() * 1.1; - qreal fineScale; + int maxTipHeight = qRound(getMaxTipHeight() * 1.1); + qreal fineScale; if (m_questionTip->boundingRect().height() > maxTipHeight) { // check is scaling needed fineScale = (qreal)maxTipHeight / m_questionTip->boundingRect().height(); #if defined (Q_OS_ANDROID) @@ -845,13 +825,13 @@ void Tcanvas::setQuestionPos() { scaleStep += 0.1; } } - if (m_posOfQuestTips[(int)m_tipPos].isNull()) // calculate tip position only when user doesn't change it - setPosOfTip(m_questionTip); - else { - fixWidthOverScore(m_questionTip); - m_questionTip->setFixPos(m_posOfQuestTips[(int)m_tipPos]); - } - m_questionTip->show(); + if (m_posOfQuestTips[static_cast<int>(m_tipPos)].isNull()) // calculate tip position only when user doesn't change it + setPosOfTip(m_questionTip); + else { + fixWidthOverScore(m_questionTip); + m_questionTip->setFixPos(m_posOfQuestTips[static_cast<int>(m_tipPos)]); + } + m_questionTip->show(); } @@ -873,19 +853,19 @@ void Tcanvas::updateRelatedPoint() { void Tcanvas::fixWidthOverScore ( TgraphicsTextTip* tip ) { - if (m_tipPos == e_scoreOver && tip->realW() > SCORE->width()) - tip->setScale((qMax((qreal)SCORE->width() * 0.9, m_view->width() / 3.0) / (tip->boundingRect().width()))); + if (m_tipPos == e_scoreOver && tip->realW() > SCORE->width()) + tip->setScale((qMax(SCORE->width() * 0.9, m_view->width() / 3.0) / (tip->boundingRect().width()))); } void Tcanvas::tipMoved() { - if (sender() == m_questionTip) - m_posOfQuestTips[(int)m_tipPos] = m_questionTip->pos(); - else if (sender() == m_whatTip) - m_posOfWhatTips[(int)m_tipPos] = m_whatTip->pos(); - else if (sender() == m_confirmTip) - m_posOfConfirm = m_confirmTip->pos(); + if (sender() == m_questionTip) + m_posOfQuestTips[static_cast<int>(m_tipPos)] = m_questionTip->pos(); + else if (sender() == m_whatTip) + m_posOfWhatTips[static_cast<int>(m_tipPos)] = m_whatTip->pos(); + else if (sender() == m_confirmTip) + m_posOfConfirm = m_confirmTip->pos(); } @@ -895,6 +875,54 @@ void Tcanvas::tipStateChanged() { } +/** + * For details, see table in tip_positions.html file + */ +Tcanvas::EtipPos Tcanvas::determineTipPos() { + EtipPos tipPos; + switch (m_exam->curQ()->questionAs) { + /** Question is note on the score, so place a tip over name if not used or over guitar if visible but if not - in bottom-right corner. */ + case TQAtype::e_asNote : { + if (SCORE->insertMode() == TmainScore::e_single) { + if (m_exam->curQ()->answerAs == TQAtype::e_asName) { + tipPos = GUITAR->isVisible() ? e_guitarOver : e_bottomRight; + } else + tipPos = e_nameOver; + } else { // melody, so answer is sound (only supported case) + tipPos = GUITAR->isVisible() ? e_guitarOver : e_bottomRight; + } + break; + } + /** Question is note name, so place a tip over score if not used, or over guitar. */ + case TQAtype::e_asName : { // single note mode only + if (m_exam->curQ()->answerAs == TQAtype::e_asNote) + tipPos = GUITAR->isVisible() ? e_guitarOver : e_bottomRight; + else + tipPos = e_scoreOver; + break; + } + case TQAtype::e_asFretPos : { // single note mode only + if (m_exam->curQ()->answerAs == TQAtype::e_asNote) + tipPos = e_nameOver; + else + tipPos = e_scoreOver; + break; + } + case TQAtype::e_asSound : { + if (SCORE->insertMode() == TmainScore::e_single) { + if (m_exam->curQ()->answerAs == TQAtype::e_asNote) + tipPos = e_nameOver; + else + tipPos = e_scoreOver; + } else { + tipPos = GUITAR->isVisible() ? e_guitarOver : e_bottomRight; + } + break; + } + } + return tipPos; +} + diff --git a/src/plugins/exam/tcanvas.h b/src/plugins/exam/tcanvas.h index d4773a8f36784258a26b74ce1f0a188d3973f019..366dbbbcb8e46fc4502c4a81edf46db6c5247450 100644 --- a/src/plugins/exam/tcanvas.h +++ b/src/plugins/exam/tcanvas.h @@ -27,6 +27,8 @@ #include <tfingerpos.h> +#define TIP_POS_NUM (4) /**< Number of possible tip positions depends on question/answer combination */ + class Tnote; class TnoteName; class TcombinedAnim; @@ -56,16 +58,25 @@ class Tcanvas : public QObject public: - enum EtipPos { - e_guitarOver = 0, e_scoreOver = 1, e_nameOver = 2 - }; /**< Describes a kind of tip position depended on q/a type - over what widget tip is placed */ + /** + * Describes a kind of tip position depended on q/a type - over what widget tip is placed. + * Number of enumerators has to correspond with @p TIP_POS_NUM definition + */ + enum EtipPos { + e_guitarOver = 0, e_scoreOver = 1, e_nameOver = 2, e_bottomRight + }; +#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) + Q_ENUM(EtipPos) +#endif Tcanvas(QGraphicsView* view, Texam* exam); virtual ~Tcanvas(); - /** Cross platform status message: - * - status bar on desktops (@class TstatusLabel) - * - pop up message on screen bottom for mobile (@class TtouchMessage) */ + /** + * Cross platform status message: + * - status bar on desktops (@p TstatusLabel) + * - pop up message on screen bottom for mobile (@p TtouchMessage) + */ void setStatusMessage(const QString& text, int duration = 0); void changeExam(Texam* newExam); /**< Replaces exam pointer given in constructor to the new one. */ @@ -74,11 +85,15 @@ public: void resultTip(TQAunit *answer, int time = 0); /**< show was question correct text, hides after given time */ void startTip(); /**< Text with help on an exam start */ - /** Text with what to click after an answer. + /** + * Text with what to click after an answer. * @p isCorrect - was the question correct - * @p toCorrection - text how to see corrected answer will be shown. */ - void whatNextTip(bool isCorrect, bool toCorrection = false); - void questionTip(); /**< Text with question context */ + * @p toCorrection - text how to see corrected answer will be shown. + */ + void whatNextTip(bool isCorrect, bool toCorrection = false); + + /** Text with question context */ + void questionTip(); void tryAgainTip(int time); /**< "Try again" text" */ void confirmTip(int time = 0); /**< tip about confirm an answer appears after given time */ void melodyCorrectMessage(); /**< Status message about how to correct a melody notes. */ @@ -99,8 +114,6 @@ public: QFont tipFont(qreal factor = 1); QString startTipText(); - /** Paints animated exclamation mark over answering widget. */ - void markAnswer(TQAtype::Etype qType, TQAtype::Etype aType); /** Paints rectangle around given type of widget to mark where is answer. */ const QRect& getRect(TQAtype::Etype kindOf); @@ -165,7 +178,6 @@ private: QPointer<TcombinedAnim> m_correctAnim; QTimer *m_timerToConfirm; int m_maxTipWidth; - bool m_guitarFree, m_nameFree, m_scoreFree; QSizeF m_prevSize; QSize m_newSize; QGraphicsEllipseItem *m_flyEllipse; @@ -173,7 +185,7 @@ private: QColor m_correctColor; TnoteName *m_noteName; QPoint m_relPoint; - QPointF m_posOfQuestTips[3], m_posOfWhatTips[3], m_posOfConfirm; + QPointF m_posOfQuestTips[TIP_POS_NUM], m_posOfWhatTips[TIP_POS_NUM], m_posOfConfirm; bool m_minimizedQuestion, m_melodyCorrectMessage; EtipPos m_tipPos; /**< Kind of tip position */ int m_iconSize; /**< Icon image size on tips calculated from actual font metrics. */ @@ -191,6 +203,7 @@ private: void updateRelatedPoint(); void createQuestionTip(); /**< Be sure that @p m_exam has already pointed current exam */ void fixWidthOverScore(TgraphicsTextTip* tip); /**< Scales tip if its width is bigger than score widget */ + EtipPos determineTipPos(); }; diff --git a/src/plugins/exam/tip positions.ods b/src/plugins/exam/tip positions.ods new file mode 100644 index 0000000000000000000000000000000000000000..f3b5b1b521b80f98faf2a77fdc2ddcec7ae9c043 Binary files /dev/null and b/src/plugins/exam/tip positions.ods differ diff --git a/src/plugins/exam/tip_positions.html b/src/plugins/exam/tip_positions.html new file mode 100644 index 0000000000000000000000000000000000000000..7578581bf4181f723a607d3bb75aff0e26d79121 --- /dev/null +++ b/src/plugins/exam/tip_positions.html @@ -0,0 +1,126 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> + +<html> +<head> + + <meta http-equiv="content-type" content="text/html; charset=utf-8"/> + <title></title> + <meta name="generator" content="LibreOffice 5.2.3.3 (Linux)"/> + <meta name="created" content="2016-12-04T12:40:04.099779111"/> + <meta name="changed" content="2016-12-04T15:03:39.802531112"/> + + <style type="text/css"> + body,div,table,thead,tbody,tfoot,tr,th,td,p { font-family:"Arial"; font-size:x-small } + a.comment-indicator:hover + comment { background:#ffd; position:absolute; display:block; border:1px solid black; padding:0.5em; } + a.comment-indicator { background:red; display:inline-block; border:1px solid black; width:0.5em; height:0.5em; } + comment { display:none; } + </style> + +</head> + +<body> +<table cellspacing="0" border="0"> + <colgroup width="85"></colgroup> + <colgroup width="102"></colgroup> + <colgroup width="121"></colgroup> + <colgroup width="85"></colgroup> + <colgroup width="134"></colgroup> + <tr> + <td height="17" align="center" valign=middle>q/a</td> + <td align="center" valign=middle>score</td> + <td align="center" valign=middle>name</td> + <td align="center" valign=middle>guitar</td> + <td align="center" valign=middle>sound</td> + </tr> + <tr> + <td height="33" align="center" valign=middle>score</td> + <td align="center" valign=middle>------------</td> + <td align="center" valign=middle>------------</td> + <td align="center" valign=middle>------------</td> + <td align="center" valign=middle>over guitar<br>Or bottom-right</td> + </tr> + <tr> + <td height="33" align="center" valign=middle>score single</td> + <td align="center" valign=middle>over name</td> + <td align="center" valign=middle>over guitar <br>or bottom-right</td> + <td align="center" valign=middle>over name</td> + <td align="center" valign=middle>over name</td> + </tr> + <tr> + <td height="33" align="center" valign=middle>name single</td> + <td align="center" valign=middle>over guitar<br>Or bottom-right</td> + <td align="center" valign=middle>over score</td> + <td align="center" valign=middle>over score</td> + <td align="center" valign=middle>over score</td> + </tr> + <tr> + <td height="17" align="center" valign=middle>guitar single</td> + <td align="center" valign=middle>over name</td> + <td align="center" valign=middle>over score</td> + <td align="center" valign=middle>over score</td> + <td align="center" valign=middle>over score</td> + </tr> + <tr> + <td height="33" align="center" valign=middle>sound</td> + <td align="center" valign=middle>over guitar <br>or bottom-right</td> + <td align="center" valign=middle>------------</td> + <td align="center" valign=middle>------------</td> + <td align="center" valign=middle>------------</td> + </tr> + <tr> + <td height="17" align="center" valign=middle>sound single</td> + <td align="center" valign=middle>over name</td> + <td align="center" valign=middle>over score</td> + <td align="center" valign=middle>over score</td> + <td align="center" valign=middle>over score</td> + </tr> + <tr> + <td height="17" align="center" valign=middle><br></td> + <td align="center" valign=middle><br></td> + <td align="center" valign=middle><br></td> + <td align="center" valign=middle><br></td> + <td align="center" valign=middle><br></td> + </tr> + <tr> + <td height="17" align="center" valign=middle><br></td> + <td align="left"><br></td> + <td align="left"><br></td> + <td align="left"><br></td> + <td align="left"><br></td> + </tr> + <tr> + <td height="17" align="center" valign=middle><br></td> + <td align="left"><br></td> + <td align="left"><br></td> + <td align="left"><br></td> + <td align="left"><br></td> + </tr> + <tr> + <td height="17" align="center" valign=middle><br></td> + <td align="left"><br></td> + <td align="left"><br></td> + <td align="left"><br></td> + <td align="left"><br></td> + </tr> + <tr> + <td height="17" align="center" valign=middle><br></td> + <td align="left"><br></td> + <td align="left"><br></td> + <td align="left"><br></td> + <td align="left"><br></td> + </tr> + <tr> + <td height="17" align="center" valign=middle><br></td> + <td align="left"><br></td> + <td align="left"><br></td> + <td align="left"><br></td> + <td align="left"><br></td> + </tr> + <tr> + <td colspan=5 rowspan=4 height="68" align="center" valign=middle>This table describes all possible positions of tip (question or what next)<br>Available for melodies and single note questions/answers</td> + </tr> +</table> +<!-- ************************************************************************** --> +</body> + +</html> diff --git a/src/plugins/exam/tquestiontip.cpp b/src/plugins/exam/tquestiontip.cpp index cdbaa679a89efa4262c01389f11e6a159f3234d6..35a6f8e9b2bf54e79f5e851b62b21215577cc36f 100644 --- a/src/plugins/exam/tquestiontip.cpp +++ b/src/plugins/exam/tquestiontip.cpp @@ -109,9 +109,6 @@ QString TquestionTip::getNiceNoteName(Tnote& note, Tnote::EnameStyle style) { QString TquestionTip::getQuestion(TQAunit* question, int questNr, Tlevel* level, double scale) { QString br = QStringLiteral("<br>"); QString sp = QStringLiteral(" "); - m_scoreFree = true; - m_nameFree = !(bool)question->melody(); // no name widget when level uses melodies - m_guitarFree = true; m_questText.clear(); double sc = 4.0; if (scale) { @@ -126,7 +123,6 @@ QString TquestionTip::getQuestion(TQAunit* question, int questNr, Tlevel* level, QString noteStr; switch (question->questionAs) { case TQAtype::e_asNote: { - m_scoreFree = false; if (question->answerAsNote()) { if (question->qa.note.alter != question->qa_2.note.alter) m_questText += tr("Change enharmonically and show on the staff"); @@ -136,10 +132,8 @@ QString TquestionTip::getQuestion(TQAunit* question, int questNr, Tlevel* level, apendix = tr("<br><b>in %1 key.</b>", "in key signature").arg(question->key.getName()); m_questText += getTextHowAccid((Tnote::Ealter)question->qa_2.note.alter); } else if (question->answerAsName()) { - m_nameFree = false; m_questText += tr("Give name of"); } else if (question->answerAsFret()) { - m_guitarFree = false; m_questText += tr("Show on the guitar"); } else if (question->answerAsSound()) { if (question->melody()) @@ -164,27 +158,23 @@ QString TquestionTip::getQuestion(TQAunit* question, int questNr, Tlevel* level, } case TQAtype::e_asName: - m_nameFree = false; noteStr = br + getNiceNoteName(question->qa.note, question->styleOfQuestion()); if (question->answerAsNote()) { - m_scoreFree = false; m_questText += tr("Show on the staff") + noteStr; if (level->useKeySign && level->manualKey) { m_questText += tr("<br><b>in %1 key.</b>", "in key signature").arg(question->key.getName()); } } else if (question->answerAsName()) { - m_nameFree = false; noteStr = br + getNiceNoteName(question->qa.note, question->styleOfQuestion()); if (question->qa.note.alter != question->qa_2.note.alter) { m_questText += tr("Change enharmonically and give name of"); m_questText += noteStr + getTextHowAccid((Tnote::Ealter)question->qa_2.note.alter); } else m_questText += tr("Use another style to give name of") + noteStr; - } else if (question->answerAsFret()) { - m_guitarFree = false; - m_questText += tr("Show on the guitar") + noteStr; - } else if (question->answerAsSound()) { - m_questText += playOrSing(int(level->instrument)) + noteStr; + } else if (question->answerAsFret()) { + m_questText += tr("Show on the guitar") + noteStr; + } else if (question->answerAsSound()) { + m_questText += playOrSing(int(level->instrument)) + noteStr; } if (question->answerAsFret() || question->answerAsSound()) { if (level->instrument != e_noInstrument && level->showStrNr && !level->onlyLowPos) @@ -193,15 +183,12 @@ QString TquestionTip::getQuestion(TQAunit* question, int questNr, Tlevel* level, break; case TQAtype::e_asFretPos: - m_guitarFree = false; if (question->answerAsNote()) { - m_scoreFree = false; m_questText += tr("Show on the staff note played on"); if (level->useKeySign && level->manualKey) { apendix = tr("<b>in %1 key.</b>", "in key signature").arg(question->key.getName()); } } else if (question->answerAsName()) { - m_nameFree = false; m_questText += tr("Give name of"); } else if (question->answerAsFret()) { m_questText += tr("Show sound from position:", "... and string + fret numbers folowing"); @@ -220,7 +207,6 @@ QString TquestionTip::getQuestion(TQAunit* question, int questNr, Tlevel* level, case TQAtype::e_asSound: if (question->answerAsNote()) { - m_scoreFree = false; if (question->melody()) { m_questText += TexTrans::writeDescTxt(); if (level->useKeySign && level->manualKey && level->onlyCurrKey) @@ -233,12 +219,10 @@ QString TquestionTip::getQuestion(TQAunit* question, int questNr, Tlevel* level, m_questText += getTextHowAccid((Tnote::Ealter)question->qa.note.alter); } } else if (question->answerAsName()) { - m_nameFree = false; m_questText += tr("Give name of listened sound"); if (level->forceAccids) m_questText += getTextHowAccid((Tnote::Ealter)question->qa.note.alter); } else if (question->answerAsFret()) { - m_guitarFree = false; m_questText += tr("Listened sound show on the guitar"); if (level->showStrNr) m_questText += br + sp + onStringTxt(question->qa.pos.str()); diff --git a/src/plugins/exam/tquestiontip.h b/src/plugins/exam/tquestiontip.h index 8701c476ab174bd1c166c059cb6df9d5854064b7..47c03292044405f239ea4c94c040eeb144b98291 100644 --- a/src/plugins/exam/tquestiontip.h +++ b/src/plugins/exam/tquestiontip.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2012-2014 by Tomasz Bojczuk * + * Copyright (C) 2012-2016 by Tomasz Bojczuk * * seelook@gmail.com * * * * This program is free software; you can redistribute it and/or modify * @@ -15,19 +15,22 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ - + #ifndef TQUESTIONTIP_H #define TQUESTIONTIP_H + #include <graphics/tgraphicstexttip.h> #include <music/tnote.h> -#include <QLinearGradient> +#include <QtGui/qbrush.h> + class TfadeAnim; class Texam; class Tlevel; class TQAunit; + /** * This is graphics tip (rectangle) representing a question context * It can be minimized with mouse. @@ -35,53 +38,47 @@ class TQAunit; class TquestionTip : public TgraphicsTextTip { Q_OBJECT - + public: - /** Constructs tip with question content. */ - TquestionTip(Texam *exam, double scale = 0); - ~TquestionTip(); - - static QString getTextHowAccid(Tnote::Ealter accid); - static QString onStringTxt(quint8 strNr); /** Returns translated text on (strNr) string in Nootka font. */ - - /** Depend on @p instrument it returns text: - * 'Play or sing' (other instrument) - * 'Play' (guitars) */ - static QString playOrSing(int instr); - - static QString& text() { return m_questText; } /** Returns a reference to question HTML string. */ - - bool freeScore() { return m_scoreFree; } /** true when question is not on score */ - bool freeName() { return m_nameFree; } /** true when question is not on note name */ - bool freeGuitar() { return m_guitarFree; } /** true when question is not on guitar */ - - bool isMinimized() { return m_minimized; } /** True when tip is minimized */ - void setMinimized(bool min); /** Minimizes of maximizes a tip */ - - virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0); - virtual QRectF boundingRect() const; - - virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* event); - virtual void hoverMoveEvent(QGraphicsSceneHoverEvent* event); - virtual void mousePressEvent(QGraphicsSceneMouseEvent* event); - + /** Constructs tip with question content. */ + TquestionTip(Texam *exam, double scale = 0); + ~TquestionTip(); + + static QString getTextHowAccid(Tnote::Ealter accid); + static QString onStringTxt(quint8 strNr); /** Returns translated text on (strNr) string in Nootka font. */ + + /** Depend on @p instrument it returns text: + * 'Play or sing' (other instrument) + * 'Play' (guitars) */ + static QString playOrSing(int instr); + + static QString& text() { return m_questText; } /**< Returns a reference to question HTML string. */ + + bool isMinimized() { return m_minimized; } /**< True when tip is minimized */ + void setMinimized(bool min); /**< Minimizes of maximizes a tip */ + + virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0); + virtual QRectF boundingRect() const; + + virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* event); + virtual void hoverMoveEvent(QGraphicsSceneHoverEvent* event); + virtual void mousePressEvent(QGraphicsSceneMouseEvent* event); + signals: - void minimizeChanged(); /** Emitted when tips gets minimized or restored to normal state */ - + void minimizeChanged(); /**< Emitted when tips gets minimized or restored to normal state */ + protected: - /** Returns html-formatted question text. */ - QString getQuestion(TQAunit* question, int questNr, Tlevel* level, double scale = 0); - QString getNiceNoteName(Tnote& note, Tnote::EnameStyle style); - - + /** Returns html-formatted question text. */ + QString getQuestion(TQAunit* question, int questNr, Tlevel* level, double scale = 0); + QString getNiceNoteName(Tnote& note, Tnote::EnameStyle style); + private: - bool m_scoreFree, m_nameFree, m_guitarFree; /** Indicate where a tip has to be placed. */ - Tnote::Ealter m_forcedAccid; /** When different than Tnote::e_Natural text is shown */ - TfadeAnim *m_fadeInAnim; - bool m_markCorner, m_minimized; - static QString m_questText; - QLinearGradient m_staffGradient; + Tnote::Ealter m_forcedAccid; /**< When different than Tnote::e_Natural text is shown */ + TfadeAnim *m_fadeInAnim; + bool m_markCorner, m_minimized; + static QString m_questText; + QLinearGradient m_staffGradient; }; -#endif // TQUESTIONTIP_H \ No newline at end of file +#endif // TQUESTIONTIP_H