comparison widgets/UnitConverter.cpp @ 886:01cceacee3da

Start adding piano note
author Chris Cannam
date Tue, 02 Dec 2014 13:50:49 +0000
parents 6778a82d6b76
children 139aad8bb445
comparison
equal deleted inserted replaced
885:6778a82d6b76 886:01cceacee3da
24 #include "base/Debug.h" 24 #include "base/Debug.h"
25 #include "base/Pitch.h" 25 #include "base/Pitch.h"
26 26
27 using namespace std; 27 using namespace std;
28 28
29 static QString pianoNotes[] = {
30 "C", "C# / Db", "D", "D# / Eb", "E",
31 "F", "F# / Gb", "G", "G# / Ab", "A", "A# / Bb", "B"
32 };
33
29 UnitConverter::UnitConverter(QWidget *parent) : 34 UnitConverter::UnitConverter(QWidget *parent) :
30 QDialog(parent) 35 QDialog(parent)
31 { 36 {
32 QGridLayout *grid = new QGridLayout; 37 QGridLayout *grid = new QGridLayout;
33 setLayout(grid); 38 setLayout(grid);
46 m_midi->setMaximum(127); 51 m_midi->setMaximum(127);
47 connect(m_midi, SIGNAL(valueChanged(int)), 52 connect(m_midi, SIGNAL(valueChanged(int)),
48 this, SLOT(midiChanged(int))); 53 this, SLOT(midiChanged(int)));
49 54
50 m_note = new QComboBox; 55 m_note = new QComboBox;
51 //!!! 56 for (int i = 0; i < 12; ++i) {
57 m_note->addItem(pianoNotes[i]);
58 }
59 connect(m_note, SIGNAL(currentIndexChanged(int)),
60 this, SLOT(noteChanged(int)));
52 61
53 m_octave = new QSpinBox; 62 m_octave = new QSpinBox;
54 //!!! 63 m_octave->setMinimum(-4);
64 m_octave->setMaximum(12);
65 connect(m_octave, SIGNAL(valueChanged(int)),
66 this, SLOT(octaveChanged(int)));
55 67
56 m_cents = new QDoubleSpinBox; 68 m_cents = new QDoubleSpinBox;
57 m_cents->setSuffix(tr(" cents")); 69 m_cents->setSuffix(tr(" cents"));
58 m_cents->setDecimals(4); 70 m_cents->setDecimals(4);
59 m_cents->setMinimum(-50); 71 m_cents->setMinimum(-50);
62 this, SLOT(centsChanged(double))); 74 this, SLOT(centsChanged(double)));
63 75
64 m_piano = new QSpinBox; 76 m_piano = new QSpinBox;
65 //!!! 77 //!!!
66 78
67 grid->addWidget(m_hz, 1, 0); 79 int row = 1;
68 grid->addWidget(new QLabel(tr("=")), 1, 1); 80
81 grid->addWidget(m_hz, row, 0);
82 grid->addWidget(new QLabel(tr("=")), row, 1);
69 83
70 grid->addWidget(new QLabel(tr("MIDI note")), 1, 2, 1, 2); 84 grid->addWidget(new QLabel(tr("+")), row, 7);
71 grid->addWidget(m_midi, 1, 4); 85 grid->addWidget(m_cents, row, 8);
72 86
73 grid->addWidget(new QLabel(tr("+")), 1, 5); 87 grid->addWidget(new QLabel(tr("Piano note")), row, 2, 1, 2);
74 grid->addWidget(m_cents, 1, 6); 88 grid->addWidget(m_note, row, 4);
89 grid->addWidget(new QLabel(tr("in octave")), row, 5);
90 grid->addWidget(m_octave, row, 6);
91
92 ++row;
93
94 grid->addWidget(new QLabel(tr("MIDI note")), row, 2, 1, 2);
95 grid->addWidget(m_midi, row, 4);
96
97 ++row;
75 98
76 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Close); 99 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Close);
77 grid->addWidget(bb, 2, 0, 1, 7); 100 grid->addWidget(bb, row, 0, 1, 9);
78 connect(bb, SIGNAL(rejected()), this, SLOT(close())); 101 connect(bb, SIGNAL(rejected()), this, SLOT(close()));
79 102
80 updateAllFromHz(); 103 updateAllFromHz();
81 } 104 }
82 105