~noskcaj/ubuntu/wily/nootka/1.2

« back to all changes in this revision

Viewing changes to src/exam/tquestiontip.cpp

  • Committer: Package Import Robot
  • Author(s): Jackson Doak
  • Date: 2014-05-28 07:22:46 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20140528072246-7m1u5qc24gqhqurg
Tags: 1.0.1-0ubuntu1
* Add a debian/watch file
* New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/***************************************************************************
2
 
 *   Copyright (C) 2012 by Tomasz Bojczuk                                  *
 
2
 *   Copyright (C) 2012-2014 by Tomasz Bojczuk                             *
3
3
 *   tomaszbojczuk@gmail.com                                               *
4
4
 *                                                                         *
5
5
 *   This program is free software; you can redistribute it and/or modify  *
20
20
#include "tquestiontip.h"
21
21
#include "tqaunit.h"
22
22
#include "texam.h"
23
 
#include <tnotename.h>
24
23
#include "tquestionaswdg.h"
25
24
#include "tglobals.h"
26
 
#include <texamlevel.h>
 
25
#include <tlevel.h>
27
26
#include <ttipchart.h>
 
27
#include <animations/tfadeinanim.h>
 
28
#include <tcolor.h>
 
29
// #include <QDebug>
28
30
 
29
31
extern Tglobals *gl;
30
32
 
42
44
 
43
45
 
44
46
QString TquestionTip::onStringTxt(quint8 strNr) {
45
 
    return tr("on <span style=\"font-family: nootka;\">%1</span> string.").arg(strNr);
46
 
}
 
47
    return "<b>" + tr("on %1 string.").arg(QString("</b><span style=\"font-family: nootka;\">%1</span><b>").arg(strNr)) + "</b>";
 
48
}
 
49
 
 
50
 
 
51
QString TquestionTip::playOrSing(int instr) {
 
52
        if (Einstrument(instr) == e_noInstrument)
 
53
                return tr("Play or sing");
 
54
        else
 
55
                return tr("Play");
 
56
}
 
57
 
47
58
 
48
59
//##########################################################################################
49
60
//#################################### CONSTRUCTOR #########################################
53
64
  TgraphicsTextTip(getQuestion(exam->question(exam->count()-1), exam->count(), exam->level(), scale))
54
65
{
55
66
  setBgColor(gl->EquestionColor);
 
67
  hide();
 
68
  m_fadeInAnim = new TfadeInAnim(this);
 
69
  m_fadeInAnim->setEasingCurveType(QEasingCurve::InExpo);
 
70
  m_fadeInAnim->startFadeIn();
56
71
}
57
72
 
58
 
TquestionTip::~TquestionTip() {}
 
73
TquestionTip::~TquestionTip() 
 
74
{
 
75
                delete m_fadeInAnim;
 
76
}
59
77
 
60
78
 
61
79
//##########################################################################################
63
81
//##########################################################################################
64
82
 
65
83
QString TquestionTip::getNiceNoteName(Tnote note, Tnote::EnameStyle style) {
66
 
    return QString("<b><span style=\"%1\">&nbsp;").arg(gl->getBGcolorText(gl->EquestionColor)) +
 
84
    return QString("<b><span style=\"%1\">&nbsp;").arg(Tcolor::bgTag(gl->EquestionColor)) +
67
85
            note.toRichText(style) + " </span></b>";
68
86
}
69
87
 
70
 
QString TquestionTip::getQuestion(TQAunit& question, int questNr, TexamLevel* level, double scale) {
 
88
QString TquestionTip::getQuestion(TQAunit& question, int questNr, Tlevel* level, double scale) {
71
89
  m_scoreFree = true;
72
90
  m_nameFree = true;
73
91
  m_guitarFree = true;
75
93
  double sc = 4.0;
76
94
  if (scale) {
77
95
    quest = QString("<p style=\"font-size: %1px;\">").arg(qRound(scale * 22.0));
78
 
//     sc = 4.0 * scale;     
 
96
    sc = 4.0 * scale;     
79
97
  }
80
98
  quest += QString("<b><u>&nbsp;%1.&nbsp;</u></b><br>").arg(questNr);
81
99
    QString apendix = "";
82
100
    QString noteStr;
83
101
    switch (question.questionAs) {
84
 
      case TQAtype::e_asNote:
 
102
      case TQAtype::e_asNote: {
85
103
        m_scoreFree = false;
86
104
        if (question.answerAs == TQAtype::e_asNote) {
87
105
            if (question.qa.note.acidental != question.qa_2.note.acidental)
88
 
                quest += tr("Change enharmonicaly and show in the score");
 
106
                quest += tr("Change enharmonically and show on the staff");
89
107
            else
90
 
                quest += tr("Given note show in the score");
91
 
          if (level->useKeySign && level->manualKey) {
92
 
            apendix = tr("<br><b>in %1 key.</b>", "in key signature").arg(question.key.getName());
93
 
          }
94
 
//           if (level->forceAccids)
95
 
            quest += getTextHowAccid((Tnote::Eacidentals)question.qa_2.note.acidental);
96
 
        } else
97
 
          if (question.answerAs == TQAtype::e_asName) {
 
108
                quest += tr("Given note show on the staff");
 
109
                                                if (level->useKeySign && level->manualKey)
 
110
                                                                apendix = tr("<br><b>in %1 key.</b>", "in key signature").arg(question.key.getName());
 
111
                                                quest += getTextHowAccid((Tnote::Eacidentals)question.qa_2.note.acidental);
 
112
        } else if (question.answerAs == TQAtype::e_asName) {
98
113
            m_nameFree = false;
99
114
            quest += tr("Give name of");
100
 
          } else
101
 
            if (question.answerAs == TQAtype::e_asFretPos) {
 
115
                                } else if (question.answerAs == TQAtype::e_asFretPos) {
102
116
              m_guitarFree = false;
103
117
              quest += tr("Show on the guitar");
104
 
              if (level->showStrNr)
105
 
                apendix = "<br><b> " + onStringTxt(question.qa.pos.str()) + "</b>";
106
 
            } else
107
 
              if (question.answerAs == TQAtype::e_asSound) {
108
 
                quest += tr("Play or sing");
109
 
              }
 
118
                                } else if (question.answerAs == TQAtype::e_asSound) {
 
119
                quest += playOrSing(int(level->instrument));
 
120
                                }
 
121
        if (question.answerAs == TQAtype::e_asFretPos || question.answerAs == TQAtype::e_asSound) {
 
122
                                        if (level->instrument != e_noInstrument && level->showStrNr && !level->onlyLowPos) {
 
123
                                                apendix = "<br> " + onStringTxt(question.qa.pos.str());
 
124
                                        }
 
125
        }
110
126
        if (level->useKeySign && level->manualKey && question.answerAs == TQAtype::e_asNote) // hide key signature
111
127
            quest += "<br>" + TtipChart::wrapPixToHtml(question.qa.note, true, TkeySignature(0), sc);
112
128
        else
113
129
            quest += "<br>" + TtipChart::wrapPixToHtml(question.qa.note, true, question.key, sc);
114
130
        if (apendix != "")
115
131
          quest += apendix;
116
 
      break;
 
132
                                break;
 
133
                        }
117
134
      
118
135
      case TQAtype::e_asName:
119
136
        m_nameFree = false;
120
137
        noteStr = "<br>" + getNiceNoteName(question.qa.note, question.styleOfQuestion());
121
138
        if (question.answerAs == TQAtype::e_asNote) {
122
 
          m_nameFree = false;
123
 
          quest += tr("Show in the score") + noteStr;
124
 
          if (level->useKeySign && level->manualKey) {
125
 
            quest += tr("<br><b>in %1 key.</b>", "in key signature").arg(question.key.getName());
126
 
          }
127
 
        } else
128
 
          if (question.answerAs == TQAtype::e_asName) {
 
139
                                                m_scoreFree = false;
 
140
                                                quest += tr("Show on the staff") + noteStr;
 
141
                                                if (level->useKeySign && level->manualKey) {
 
142
                                                        quest += tr("<br><b>in %1 key.</b>", "in key signature").arg(question.key.getName());
 
143
                                                }
 
144
        } else if (question.answerAs == TQAtype::e_asName) {
129
145
            m_nameFree = false;
130
146
            noteStr = "<br>" + getNiceNoteName(question.qa.note, question.styleOfQuestion());
131
147
            if (question.qa.note.acidental != question.qa_2.note.acidental) {
132
 
                quest += tr("Change enharmonicaly and give name of");
 
148
                quest += tr("Change enharmonically and give name of");
133
149
                quest += noteStr + getTextHowAccid((Tnote::Eacidentals)question.qa_2.note.acidental);
134
150
            } else
135
151
                quest += tr("Use another style to give name of") + noteStr;
136
 
//             quest += noteStr + getTextHowAccid((Tnote::Eacidentals)question.qa_2.note.acidental);
137
 
          } else
138
 
            if (question.answerAs == TQAtype::e_asFretPos) {
139
 
              m_guitarFree = false;
140
 
              quest += tr("Show on the guitar") + noteStr;
141
 
              if (level->showStrNr)
142
 
                quest += "<br><b> " + onStringTxt(question.qa.pos.str()) + "</b>";
143
 
            } else
144
 
              if (question.answerAs == TQAtype::e_asSound) {
145
 
                quest += "<br>" + tr("Play or sing") + noteStr;
146
 
              }
147
 
      break;
 
152
                                } else if (question.answerAs == TQAtype::e_asFretPos) {
 
153
                                                m_guitarFree = false;
 
154
                                                quest += tr("Show on the guitar") + noteStr;
 
155
                                } else if (question.answerAs == TQAtype::e_asSound) {
 
156
                                                quest += playOrSing(int(level->instrument)) + noteStr;
 
157
                                }
 
158
                                if (question.answerAs == TQAtype::e_asFretPos || question.answerAs == TQAtype::e_asSound) {
 
159
                                                if (level->instrument != e_noInstrument && level->showStrNr && !level->onlyLowPos)
 
160
                                                                quest += "<br> " + onStringTxt(question.qa.pos.str());
 
161
                                }
 
162
                        break;
148
163
      
149
164
      case TQAtype::e_asFretPos:
150
165
        quest += "";
151
166
        m_guitarFree = false;
152
167
        if (question.answerAs == TQAtype::e_asNote) {
153
 
          m_scoreFree = false;
154
 
          quest += tr("Show on the score note played on");
155
 
          if (level->useKeySign && level->manualKey) {
156
 
            apendix = tr("<b>in %1 key.</b>", "in key signature").arg(question.key.getName());
157
 
          }
158
 
        } else
159
 
          if (question.answerAs == TQAtype::e_asName) {
 
168
                                                m_scoreFree = false;
 
169
                                                quest += tr("Show on the staff note played on");
 
170
                                                if (level->useKeySign && level->manualKey) {
 
171
                                                        apendix = tr("<b>in %1 key.</b>", "in key signature").arg(question.key.getName());
 
172
                                                }
 
173
        } else if (question.answerAs == TQAtype::e_asName) {
160
174
            m_nameFree = false;
161
175
            quest += tr("Give name of");
162
 
          } else
163
 
            if (question.answerAs == TQAtype::e_asFretPos) {
 
176
                                } else if (question.answerAs == TQAtype::e_asFretPos) {
164
177
              quest += tr("Show sound from position:", "... and string + fret numbers folowing");
165
 
              apendix = "<br><b> " + onStringTxt(question.qa_2.pos.str()) + "</b>";
166
 
            } else
167
 
              if (question.answerAs == TQAtype::e_asSound) {
168
 
                  quest += tr("Play or sing");
169
 
              }
170
 
        quest += QString("<br><span style=\"font-size: 30px; %1\">&nbsp;").arg(gl->getBGcolorText(gl->EquestionColor)) +
 
178
              apendix = "<br> " + onStringTxt(question.qa_2.pos.str());
 
179
                                } else if (question.answerAs == TQAtype::e_asSound) {
 
180
                                                        quest += playOrSing(int(level->instrument));
 
181
                                }
 
182
        quest += QString("<br><span style=\"font-size: 30px; %1\">&nbsp;").arg(Tcolor::bgTag(gl->EquestionColor)) +
171
183
                    question.qa.pos.toHtml() + " </span>";
172
184
        if (apendix != "")
173
185
          quest += "<br>" + apendix;
174
186
        if (question.answerAs == TQAtype::e_asNote || question.answerAs == TQAtype::e_asName)
175
187
          if (level->forceAccids)
176
188
            quest += "<br" + getTextHowAccid((Tnote::Eacidentals)question.qa.note.acidental);
177
 
        
178
189
      break;
179
190
      
180
191
      case TQAtype::e_asSound:
181
192
        if (question.answerAs == TQAtype::e_asNote) {
182
 
          m_scoreFree = false;
183
 
          quest += tr("Listened sound show in the score");
184
 
          if (level->useKeySign && level->manualKey) {
185
 
            quest += tr("<br><b>in %1 key.</b>", "in key signature").arg(question.key.getName());
186
 
          }
187
 
          if (level->forceAccids)
188
 
            quest += getTextHowAccid((Tnote::Eacidentals)question.qa.note.acidental);
189
 
        } else
190
 
          if (question.answerAs == TQAtype::e_asName) {
 
193
                                                m_scoreFree = false;
 
194
                                                quest += tr("Listened sound show on the staff");
 
195
                                                if (level->useKeySign && level->manualKey) {
 
196
                                                        quest += tr("<br><b>in %1 key.</b>", "in key signature").arg(question.key.getName());
 
197
                                                }
 
198
                                                if (level->forceAccids)
 
199
                                                        quest += getTextHowAccid((Tnote::Eacidentals)question.qa.note.acidental);
 
200
        } else if (question.answerAs == TQAtype::e_asName) {
191
201
            m_nameFree = false;
192
202
            quest += tr("Give name of listened sound");
193
203
            if (level->forceAccids)
194
204
                quest += getTextHowAccid((Tnote::Eacidentals)question.qa.note.acidental);
195
 
          } else
196
 
            if (question.answerAs == TQAtype::e_asFretPos) {
 
205
                                } else if (question.answerAs == TQAtype::e_asFretPos) {
197
206
              m_guitarFree = false;
198
207
              quest += tr("Listened sound show on the guitar");
199
208
              if (level->showStrNr)
200
 
              quest += "<br><b> " + onStringTxt(question.qa.pos.str()) + "</b>";
201
 
            } else
202
 
              if (question.answerAs == TQAtype::e_asSound) {
 
209
              quest += "<br> " + onStringTxt(question.qa.pos.str());
 
210
                                } else if (question.answerAs == TQAtype::e_asSound) {
203
211
                quest += tr("Play or sing listened sound");          
204
 
              }
 
212
                                }
205
213
      break;
206
214
    }
207
 
    if (scale)
208
 
      quest += "</p>";
209
 
    quest = "<table><tr><td valign=\"middle\" style=\"font-family: nootka; color: transparent; font-size: 30px;\">" +
210
 
            TquestionAsWdg::qaTypeSymbol(question.questionAs) + "</td><td valign=\"middle\" align=\"center\">" + quest + "</td>" +
211
 
            "<td valign=\"middle\" style=\"font-family: nootka; color: transparent; font-size: 30px;\">" +
212
 
            TquestionAsWdg::qaTypeSymbol(question.answerAs) +
213
 
            "</td></tr></table>";
 
215
                        if (scale)
 
216
                                quest += "</p>";
214
217
    return quest;
215
218
  
216
219
}