~noskcaj/ubuntu/wily/nootka/1.2

« back to all changes in this revision

Viewing changes to src/level/accidsettings.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-2013 by Tomasz Bojczuk                             *
3
3
 *   tomaszbojczuk@gmail.com                                               *
4
4
 *                                                                         *
5
5
 *   This program is free software; you can redistribute it and/or modify  *
19
19
 
20
20
#include "accidsettings.h"
21
21
#include "tkeysigncombobox.h"
22
 
#include "texamlevel.h"
 
22
#include "tlevel.h"
23
23
#include "QtGui"
24
24
 
25
25
extern bool isNotSaved;
26
26
 
 
27
bool levelIsLoadingInAccids = false;
 
28
 
27
29
accidSettings::accidSettings(QWidget* parent) :
28
30
  QWidget(parent)
29
31
{
33
35
    
34
36
    QVBoxLayout *accLay = new QVBoxLayout;
35
37
    m_sharpsChB = new QCheckBox(tr("# - sharps"),this);
36
 
    m_sharpsChB->setStatusTip(tr("Sharps will be uesd in exam's questions and answers.<br>It has to be checked, if keys with sharps are used."));
 
38
    m_sharpsChB->setStatusTip(tr("Sharps will be used in questions and answers.<br>It has to be checked, if keys with sharps are used."));
37
39
    m_sharpsChB->setChecked(true);
38
40
    m_flatsChB = new QCheckBox(tr("b - flats"),this);
39
 
    m_flatsChB->setStatusTip(tr("Flats will be uesd in exam's questions and answers.<br>It has to be checked, if keys with flats are used."));
 
41
    m_flatsChB->setStatusTip(tr("Flats will be used in questions and answers.<br>It has to be checked, if keys with flats are used."));
40
42
    m_flatsChB->setChecked(true);
41
43
    m_doubleAccChB = new QCheckBox(tr("x, bb - double accidentals"),this);
42
44
    accLay->addWidget(m_sharpsChB);
49
51
    mainLay->addWidget(m_accidGr, 1, Qt::AlignCenter);
50
52
    
51
53
    QHBoxLayout *keyLay = new QHBoxLayout;
52
 
    m_keySignGr = new QGroupBox(tr("use keys singature"),this);
 
54
    m_keySignGr = new QGroupBox(tr("use key signatures"),this);
53
55
    m_keySignGr->setCheckable(true);
54
56
 
55
57
    QVBoxLayout *rangeLay = new QVBoxLayout;
66
68
    rangeLay->addWidget(m_rangeKeysRadio,0,Qt::AlignCenter);
67
69
    QHBoxLayout *comboLay = new QHBoxLayout;
68
70
    m_fromKeyCombo = new TkeySignComboBox(this);
69
 
    m_fromKeyCombo->setStatusTip(tr("Select a key signature.<br>Apropirate accidentals used in exam<br>will be automatically selected !"));
 
71
    m_fromKeyCombo->setStatusTip(tr("Select a key signature.<br>Appropriate accidentals used in exam<br>will be automatically selected !"));
70
72
    m_fromKeyCombo->setKeySignature(TkeySignature(0));
71
73
    m_toKeyCombo = new TkeySignComboBox(this);
72
74
    m_toKeyCombo->setStatusTip(m_fromKeyCombo->statusTip());
113
115
//#################### PUBLIC METHODS ######################
114
116
 
115
117
 
116
 
void accidSettings::loadLevel ( TexamLevel& level ) {
 
118
void accidSettings::loadLevel ( Tlevel& level ) {
 
119
        levelIsLoadingInAccids = true;
117
120
    disconnect(m_rangeButGr, SIGNAL(buttonClicked(int)), this, SLOT(keyRangeChanged()));
118
121
    
119
122
    m_sharpsChB->setChecked(level.withSharps);
130
133
    keyRangeChanged();
131
134
 
132
135
    connect(m_rangeButGr, SIGNAL(buttonClicked(int)), this, SLOT(keyRangeChanged()));
 
136
        levelIsLoadingInAccids = false;
133
137
}
134
138
 
135
 
void accidSettings::saveLevel ( TexamLevel& level ) {
 
139
void accidSettings::saveLevel ( Tlevel& level ) {
136
140
  if (m_accidGr->isEnabled()) {
137
141
    level.withSharps = m_sharpsChB->isChecked();
138
142
    level.withFlats = m_flatsChB->isChecked();
179
183
       setStatusTip("");
180
184
    } else {
181
185
      m_accidGr->setDisabled(true);
182
 
      setStatusTip("<b>" + tr("Elements are disabled because appropirate types of questions or answers are not selected.") 
183
 
        + "</b>");
 
186
      updateStatusTip();
184
187
    }
185
188
}
186
189
 
187
 
void accidSettings::enableKeys(bool enable)
188
 
{
 
190
void accidSettings::enableKeys(bool enable) {
189
191
    if (enable) { // score is enabled in the level
190
192
       m_keySignGr->setDisabled(false);
191
193
       if (m_accidGr->isEnabled())
192
194
          setStatusTip("");
193
195
    } else {
194
196
      m_keySignGr->setDisabled(true);
195
 
      setStatusTip("<b>" + tr("Elements are disabled because appropirate types of questions or answers are not selected.") 
196
 
        + "</b>");
 
197
      updateStatusTip();
197
198
    }
198
199
}
199
200
 
272
273
}
273
274
 
274
275
void accidSettings::whenParamsChanged() {
 
276
                if (levelIsLoadingInAccids)
 
277
                         return;
 
278
                
275
279
    if (!isNotSaved) {
276
280
        isNotSaved = true;
277
281
        emit accidsChanged();
278
282
    }
279
283
}
280
284
 
 
285
void accidSettings::updateStatusTip() {
 
286
                setStatusTip("<b>" + tr("Elements are disabled because appropriate types of questions or answers are not selected.") 
 
287
        + "</b>");
 
288
}
281
289
 
282
290
 
283
291