diff --git a/changes b/changes index 756a49633010a076005b40aeb455362870e0aa47..67e360a31f710d746a52c4535ebd9e4feebd9558 100644 --- a/changes +++ b/changes @@ -1,3 +1,8 @@ +1.1.3 alpha + + BUGS FIXES + - flickering an analyze chart position put right + 1.1.2 alpha - exams/exercises support for playing melodies from a score - exams/exercises support for writing listened melodies diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a40a61c29f60eaea374a2372cb77e330b8958598..b3e27c1ab23df933b76c0f7b8a1f8c705375b9af 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -31,7 +31,7 @@ include_directories( libs/core libs/sound libs/misc ) # add_subdirectory( charts ) # nootka analyzer -add_subdirectory( level ) # level creator +# add_subdirectory( level ) # level creator #add_subdirectory( updater ) # nootka updater @@ -84,14 +84,14 @@ if(MINGW) endif(MINGW) -# add_executable(nootka WIN32 ${NOOTKA_SRC} ${NOOTKA_EXE_ICON}) -# target_link_libraries(nootka -# NootkaCore -# NootkaSound -# NootkaMisc -# Qt5::Widgets -# Qt5::PrintSupport -# ) +add_executable(nootka WIN32 ${NOOTKA_SRC} ${NOOTKA_EXE_ICON}) +target_link_libraries(nootka + NootkaCore + NootkaSound + NootkaMisc + Qt5::Widgets + Qt5::PrintSupport +) # get_directory_property( DirDefs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_DEFINITIONS ) diff --git a/src/charts/tanalysdialog.cpp b/src/charts/tanalysdialog.cpp index 31f42176a2c3c00d1256fae788bd419f4baa95d2..6140b1835270601be2b60961feb955ff0ee87898 100755 --- a/src/charts/tanalysdialog.cpp +++ b/src/charts/tanalysdialog.cpp @@ -79,7 +79,7 @@ TanalysDialog::TanalysDialog(Texam* exam, QWidget* parent) : headLay->addWidget(new QLabel(tr("student name:"), this), 0, 1, Qt::AlignCenter); headLay->addWidget(new QLabel(tr("level:"), this), 0, 2, Qt::AlignCenter); m_chartListCombo = new QComboBox(this); - m_chartListCombo->addItem(tr("question number", "see coment in 'ordered by:' entry")); + m_chartListCombo->addItem(tr("question number", "see comment in 'ordered by:' entry")); m_chartListCombo->addItem(tr("note pitch")); m_chartListCombo->addItem(tr("fret number")); m_chartListCombo->addItem(tr("key signature")); @@ -168,8 +168,7 @@ void TanalysDialog::setExam(Texam* exam) { m_userLab->setText("<b>" + m_exam->userName() + "</b>"); m_levelLab->setText("<b>" + m_exam->level()->name + "</b>"); m_questNrLab->setText(tr("Question number") + QString(": <b>%1</b>").arg(exam->count()) ); - m_effectLab->setText(TexTrans::effectTxt() + QString(": <b>%1%</b>") - .arg(m_exam->effectiveness(), 0, 'f', 1, '0') ); + m_effectLab->setText(TexTrans::effectTxt() + QString(": <b>%1%</b>").arg(m_exam->effectiveness(), 0, 'f', 1, '0') ); m_moreButton->setDisabled(false); if (exam->level()->instrument != e_noInstrument) { bool showTun = false; @@ -339,9 +338,9 @@ void TanalysDialog::createActions() { void TanalysDialog::createChart(Tchart::Tsettings& chartSett) { - qreal scaleFactor = 1; +// qreal scaleFactor = 1; // TODO restore restoring scale factor if (m_chart) { - scaleFactor = m_chart->transform().m11(); +// scaleFactor = m_chart->transform().m11(); delete m_chart; m_chart = 0; } @@ -353,7 +352,7 @@ void TanalysDialog::createChart(Tchart::Tsettings& chartSett) { } else m_chart = new Tchart(this); // empty chart by default - m_chart->scale(scaleFactor, scaleFactor); +// m_chart->scale(scaleFactor, scaleFactor); m_plotLay->addWidget(m_chart); } diff --git a/src/charts/tchart.cpp b/src/charts/tchart.cpp index e8bcd6dd5e4539d6d0b087b8b72e0c5af025a570..fcec8c384526ab401cd78d4e44801858cf2e91bf 100644 --- a/src/charts/tchart.cpp +++ b/src/charts/tchart.cpp @@ -24,6 +24,7 @@ #include "ttiphandler.h" #include <QGraphicsEllipseItem> #include <QMouseEvent> +#include <QTimer> Tchart::Tchart(QWidget* parent) : @@ -46,20 +47,12 @@ Tchart::Tchart(QWidget* parent) : scene->addItem(xAxis); xAxis->setLength(550); xAxis->setPos(52, yAxis->boundingRect().height() - 7); - - // stupid trick to make room for further tips of ticks of x axis - QGraphicsEllipseItem *el = new QGraphicsEllipseItem(); - el->setPen(Qt::NoPen); - scene->addItem(el); - el->setRect(0, 0, 15, xAxis->rectBoundText("X").height()*4); - el->setPos(27, yAxis->boundingRect().height() + 15); + + QTimer::singleShot(20, this, SLOT(ajustChartHeight())); } -Tchart::~Tchart() {} - - void Tchart::zoom(bool in) { double coef = 1.125; if (!in) @@ -68,12 +61,22 @@ void Tchart::zoom(bool in) { } +void Tchart::ajustChartHeight() { + qreal factor = (viewport()->rect().height() / scene->sceneRect().height()); + if (viewport()->rect().width() > scene->sceneRect().width()) { + setSceneRect(0, 0, viewport()->rect().width(), scene->sceneRect().height()); + factor = (viewport()->rect().height() / scene->sceneRect().height()) * 0.95; + } + scale(factor, factor); +} + + + //########################################################################################## //####################### EVENTS ################################################ //########################################################################################## -bool Tchart::event(QEvent* event) -{ +bool Tchart::event(QEvent* event) { if (event->type() == QEvent::Wheel) { QWheelEvent *we = static_cast<QWheelEvent *>(event); if (we->modifiers() == Qt::ControlModifier) { diff --git a/src/charts/tchart.h b/src/charts/tchart.h index 0e9c7f1401adb11c04cd8480e2373454a264b29f..f8d2af6f348abb8bf8bc5d54eae7a636c48f247c 100644 --- a/src/charts/tchart.h +++ b/src/charts/tchart.h @@ -28,9 +28,10 @@ class TXaxis; -/** This is base class for charts in Nootka. - * It has got QGraphicsScene *scene and - * two axises xAxis and yAxis witch are created by default. +/** + * This is base class for charts in Nootka. + * It has got @p QGraphicsScene *scene() and + * two axis-es xAxis and yAxis which are created by default. */ class Tchart : public QGraphicsView { @@ -65,7 +66,6 @@ public: }; Tchart(QWidget* parent = 0); - virtual ~Tchart(); virtual void setAnalyse(EanswersOrder order) {} // prototype only @@ -78,6 +78,8 @@ protected: TXaxis *xAxis; TYaxis *yAxis; +protected slots: + void ajustChartHeight(); /** Invoked by timer after chart creation to adjust scene height to view height. */ private: diff --git a/src/charts/tmainchart.cpp b/src/charts/tmainchart.cpp index 841d71b509ac54261fc39affaee1b8d7537becd8..9db04e1ede80ab55fb21fcd1ac6672d3a7d0ffcf 100644 --- a/src/charts/tmainchart.cpp +++ b/src/charts/tmainchart.cpp @@ -113,8 +113,7 @@ void TmainChart::prepareChart(int maxX) { if (chartSett.type != e_bar) { // vertical lines only for linear chart for(int i = 5; i < maxX; i++) { if (i%5 == 0) - scene->addLine(xAxis->mapValue(i) + xAxis->pos().x(), 0, - xAxis->mapValue(i) + xAxis->pos().x(), yAxis->length(), + scene->addLine(xAxis->mapValue(i) + xAxis->pos().x(), 0, xAxis->mapValue(i) + xAxis->pos().x(), yAxis->length(), QPen(QBrush(lineColor), 1, Qt::DashLine)); } } @@ -122,9 +121,7 @@ void TmainChart::prepareChart(int maxX) { yAxis->getYforGrid(listY); if (listY.size()) { for(int i = 0; i < listY.size(); i++) - scene->addLine(xAxis->pos().x(), listY[i], - xAxis->pos().x() + xAxis->length(), listY[i], - QPen(QBrush(lineColor), 1, Qt::DashLine)); + scene->addLine(xAxis->pos().x(), listY[i], xAxis->pos().x() + xAxis->length(), listY[i], QPen(QBrush(lineColor), 1, Qt::DashLine)); } } diff --git a/src/charts/tmainline.h b/src/charts/tmainline.h index 02a7b28b67020ad3f271eab8dcc18925d1e1f0de..72926c83eb8cbe9eed8036fb66e55da401c7bfe3 100644 --- a/src/charts/tmainline.h +++ b/src/charts/tmainline.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2012 by Tomasz Bojczuk * + * Copyright (C) 2012-2014 by Tomasz Bojczuk * * tomaszbojczuk@gmail.com * * * * This program is free software; you can redistribute it and/or modify * @@ -21,7 +21,7 @@ #include <QList> -// #include "tquestionpoint.h" + class TquestionPoint; class TgroupedQAunit; @@ -31,8 +31,9 @@ class TQAunit; -/** This is main line of a chart. - * It paints qustions points TquestionPoint over the scene. +/** + * This is main line of a chart. + * It paints questions points TquestionPoint over the scene. * It also performs Tips - information about question */ class TmainLine diff --git a/src/charts/tquestionpoint.cpp b/src/charts/tquestionpoint.cpp index a4cca47b019bd89d3e26b49c6744b413c53111e1..d9ff2da10873e2d4215703b1b903a7eede8ac77b 100644 --- a/src/charts/tquestionpoint.cpp +++ b/src/charts/tquestionpoint.cpp @@ -26,6 +26,7 @@ #include <QGraphicsScene> + /* static */ void TquestionPoint::setColors(QColor goodColor, QColor wrongColor, QColor notBadColor, QColor shadowColor, QColor bgColor) { m_goodColor = goodColor; @@ -81,23 +82,27 @@ void TquestionPoint::paint(QPainter* painter, const QStyleOptionGraphicsItem* op #endif painter->setPen(m_color); rect.translate(-1, -1); -// if (m_question->isWrong()) -// setRotation(180); QString glyph = "n"; if (m_qaPtr.qaPtr->isWrong()) glyph = "N"; + if (m_qaPtr.qaPtr->melody()) + glyph = "m"; painter->drawText(rect, Qt::AlignCenter, glyph); } + QRectF TquestionPoint::boundingRect() const { -// QFontMetrics metrics = QFont("nootka", 25); -// QRectF rect = metrics.boundingRect("n"); - QRectF rect(-9, -29, 24, 41); // values calculated from above, hardcoded for speedy - if (m_qaPtr.qaPtr->isWrong()) - rect.setRect(-11, -10, 24, 41);; +// QFontMetrics metrics = QFont("nootka", 25); +// QRectF rect = metrics.boundingRect("n"); + QRectF rect(-9, -29, 24, 41); // values calculated from above, hard-coded for speedy + if (m_qaPtr.qaPtr->melody()) + rect.setRect(-11, -29, 24, 41); + else if (m_qaPtr.qaPtr->isWrong()) + rect.setRect(-11, -10, 24, 41); return rect; } + void TquestionPoint::hoverEnterEvent(QGraphicsSceneHoverEvent* event ) { if (tip) { if (tip == initObject()) diff --git a/src/charts/ttipchart.cpp b/src/charts/ttipchart.cpp index 7efff964da8aef40e588d0a2cc5c9a4b526c544f..15789f394fc83dea6fd6aeeb675b0d3d50d9512f 100644 --- a/src/charts/ttipchart.cpp +++ b/src/charts/ttipchart.cpp @@ -46,66 +46,77 @@ TtipChart::TtipChart(TquestionPoint *point) : QString txt; if (point->nr()) txt = QString("<span style=\"font-size: 20px\"><b>%1.</b></span><br>").arg(point->nr()); - txt += TquestionAsWdg::questionTxt() + ": <b>" + TquestionAsWdg::qaTypeText(point->question()->questionAs) + "</b><br>" + - TquestionAsWdg::answerTxt() + ": <b>" + TquestionAsWdg::qaTypeText(point->question()->answerAs) + "</b><br>"; - QString qS = "", aS = ""; - switch (point->question()->questionAs) { - case TQAtype::e_asNote : { - int qStrNr = 0; - if (point->question()->answerAs == TQAtype::e_asFretPos) { - qStrNr = point->question()->qa.pos.str(); - if (qStrNr < 1 || qStrNr > 6) - qStrNr = 0; // to avoid any stupidity + if (point->question()->melody()) { + if (point->question()->questionAsNote() && point->question()->answerAsSound()) + txt += ("<b>" + QApplication::translate("TtipChart", "play a melody") + "</b><br>"); + else if (point->question()->questionAsSound() && point->question()->answerAsNote()) + txt += ("<b>" + QApplication::translate("TtipChart", "write a melody") + "</b><br>"); + txt += pixToHtml(getMelodyPixmap(point->question()->melody())) + "<br>"; + txt += QApplication::translate("TtipChart", "%n attempt(s)", "", point->question()->attemptsCount()) + "<br>"; + } else { + txt += TquestionAsWdg::questionTxt() + ": <b>" + TquestionAsWdg::qaTypeText(point->question()->questionAs) + "</b><br>" + + TquestionAsWdg::answerTxt() + ": <b>" + TquestionAsWdg::qaTypeText(point->question()->answerAs) + "</b><br>"; + QString qS = "", aS = ""; + switch (point->question()->questionAs) { + case TQAtype::e_asNote : { + int qStrNr = 0; + if (point->question()->answerAs == TQAtype::e_asFretPos) { + qStrNr = point->question()->qa.pos.str(); + if (qStrNr < 1 || qStrNr > 6) + qStrNr = 0; // to avoid any stupidity + } + qS = wrapPixToHtml(point->question()->qa.note, true, point->question()->key, 4.0, qStrNr); + if (point->question()->answerAs == TQAtype::e_asNote) { + qS = wrapPixToHtml(point->question()->qa.note, true, TkeySignature(0)); // no key in question + aS = wrapPixToHtml(point->question()->qa_2.note, true, point->question()->key); + } + break; } - qS = wrapPixToHtml(point->question()->qa.note, true, point->question()->key, 4.0, qStrNr); - if (point->question()->answerAs == TQAtype::e_asNote) { - qS = wrapPixToHtml(point->question()->qa.note, true, TkeySignature(0)); // no key in question - aS = wrapPixToHtml(point->question()->qa_2.note, true, point->question()->key); - } - break; + case TQAtype::e_asName: + qS = "<span style=\"font-size: 25px;\">" + point->question()->qa.note.toRichText(point->question()->styleOfQuestion()) + + "</span>"; + if (point->question()->answerAs == TQAtype::e_asName) + aS = "<span style=\"font-size: 25px;\">" + point->question()->qa_2.note.toRichText(point->question()->styleOfAnswer()) + + "</span>"; + break; + case TQAtype::e_asFretPos: + qS = point->question()->qa.pos.toHtml(); + break; + case TQAtype::e_asSound: + qS = TnooFont::span("n", 45); + if (point->question()->answerAs == TQAtype::e_asSound) + aS = wrapPixToHtml(point->question()->qa.note, true, point->question()->key); + break; } - case TQAtype::e_asName: - qS = "<span style=\"font-size: 25px;\">" + point->question()->qa.note.toRichText(point->question()->styleOfQuestion()) - + "</span>"; - if (point->question()->answerAs == TQAtype::e_asName) - aS = "<span style=\"font-size: 25px;\">" + point->question()->qa_2.note.toRichText(point->question()->styleOfAnswer()) - + "</span>"; - break; - case TQAtype::e_asFretPos: - qS = point->question()->qa.pos.toHtml(); - break; - case TQAtype::e_asSound: - qS = TnooFont::span("n", 45); - if (point->question()->answerAs == TQAtype::e_asSound) - aS = wrapPixToHtml(point->question()->qa.note, true, point->question()->key); - break; - } - if (aS == "") { - switch (point->question()->answerAs) { - case TQAtype::e_asNote : - aS = wrapPixToHtml(point->question()->qa.note, true, point->question()->key); - break; - case TQAtype::e_asName: - aS = "<span style=\"font-size: 25px;\">" + point->question()->qa.note.toRichText(point->question()->styleOfAnswer()) - + "</span>"; - break; - case TQAtype::e_asFretPos: - if (point->question()->questionAs == TQAtype::e_asFretPos) - aS = point->question()->qa_2.pos.toHtml(); - else - aS = point->question()->qa.pos.toHtml(); - break; - case TQAtype::e_asSound: - if (point->question()->questionAs == TQAtype::e_asNote) - aS = TnooFont::span("n",45); - else - aS = wrapPixToHtml(point->question()->qa.note, true, point->question()->key); - break; + if (aS == "") { + switch (point->question()->answerAs) { + case TQAtype::e_asNote : + aS = wrapPixToHtml(point->question()->qa.note, true, point->question()->key); + break; + case TQAtype::e_asName: + aS = "<span style=\"font-size: 25px;\">" + point->question()->qa.note.toRichText(point->question()->styleOfAnswer()) + + "</span>"; + break; + case TQAtype::e_asFretPos: + if (point->question()->questionAs == TQAtype::e_asFretPos) + aS = point->question()->qa_2.pos.toHtml(); + else + aS = point->question()->qa.pos.toHtml(); + break; + case TQAtype::e_asSound: + if (point->question()->questionAs == TQAtype::e_asNote) + aS = TnooFont::span("n",45); + else + aS = wrapPixToHtml(point->question()->qa.note, true, point->question()->key); + break; - } - } - txt += "<table valign=\"middle\" align=\"center\"><tr><td> " + qS + " </td><td>" + insertQMark() + " </td><td> " + aS + " </td></tr></table>"; + } + } + txt += "<table valign=\"middle\" align=\"center\"><tr><td> " + qS + " </td><td>" + insertQMark() + " </td><td> " + aS + " </td></tr></table>"; + } txt += wasAnswerOKtext(point->question(), point->color()); + if (point->question()->melody() && !point->question()->isWrong()) + txt += TexTrans::effectTxt() + QString(": <b>%1%</b><br>").arg(point->question()->effectiveness(), 0, 'f', 1, '0'); txt += TexTrans::reactTimeTxt() + QString("<span style=\"font-size: 20px\"> %1</span>").arg(Texam::formatReactTime(point->question()->time, true)); diff --git a/src/charts/txaxis.cpp b/src/charts/txaxis.cpp index 702dd5353458c8c9f0b09346ac98034205c6c55b..8b86ce7d242bfc044ebf17fb2652eeb83afefac5 100644 --- a/src/charts/txaxis.cpp +++ b/src/charts/txaxis.cpp @@ -77,10 +77,15 @@ void TXaxis::setTicText(QGraphicsTextItem *tic, TQAunit &unit, int questNr) { altStyle = TnameStyleFilter::get(Tnote::e_italiano_Si); altStyleText = QString(" <small><i>(%1)</small></i>").arg(unit.qa.note.toRichText(altStyle, false)); } - txt += QString("<b>%1</b>").arg(unit.qa.note.toRichText()) + altStyleText; - if (unit.questionAs == TQAtype::e_asFretPos || unit.answerAs == TQAtype::e_asFretPos || unit.answerAs == TQAtype::e_asSound) - txt += "<br>" + TnooFont::span(QString::number((int)unit.qa.pos.str()), 15) + - QString("<span style=\"font-size: 15px;\">%1</span>").arg(TfingerPos::romanFret(unit.qa.pos.fret())); + if (unit.melody()) +// txt += "<small>" + QApplication::translate("TXaxis", "%n attempt(s)", "", unit.attemptsCount()) + "</small>"; + ; + else { + txt += QString("<b>%1</b>").arg(unit.qa.note.toRichText()) + altStyleText; + if (unit.questionAs == TQAtype::e_asFretPos || unit.answerAs == TQAtype::e_asFretPos || unit.answerAs == TQAtype::e_asSound) + txt += "<br>" + TnooFont::span(QString::number((int)unit.qa.pos.str()), 15) + + QString("<span style=\"font-size: 15px;\">%1</span>").arg(TfingerPos::romanFret(unit.qa.pos.fret())); + } if (m_level->useKeySign && (unit.questionAs == TQAtype::e_asNote || unit.answerAs == TQAtype::e_asNote)) { txt += "<br><i>" + unit.key.getName() + "</i>"; diff --git a/src/libs/core/graphics/tnotepixmap.cpp b/src/libs/core/graphics/tnotepixmap.cpp index 58db3a5dbfa2d947e63905ec326704053a004edc..9b6b63211c5209e3d9d48e9b7c9e6671ac5e0750 100644 --- a/src/libs/core/graphics/tnotepixmap.cpp +++ b/src/libs/core/graphics/tnotepixmap.cpp @@ -136,8 +136,6 @@ QPixmap getMelodyPixmap(Tmelody* mel, bool showStrings, qreal factor) { leftPix = -1; staff->setScale(factor); qreal pixWidth = scene->width(); -// if (notesCount == 0) -// pixWidth = 13 * factor; QPixmap pix(pixWidth, qRound((bottomPix - topPix) * factor)); pix.fill(Qt::transparent);