]> code.delx.au - virtualtones/blobdiff - mainwin.cpp
Updated to modern Qt
[virtualtones] / mainwin.cpp
index d7796c904bc6939eeaf6516c78b63d11c2985518..243d9b07b49bbbc3e0d623330aa8209d42f7cf5d 100644 (file)
@@ -5,11 +5,13 @@
 
 #include "mainwin.h"
 
+using namespace Qt;
+
 
 MainWin::MainWin()
 : QWidget(0,0)
 {
-       setCaption("Virtual Tones");
+       setWindowTitle("Virtual Tones");
 
        // Setup the MIDI output
        midi = new MidiReal();
@@ -21,29 +23,29 @@ MainWin::MainWin()
        midiFile = 0;
 
        // Create the sound selector
-       soundSelection = new QComboBox(false, this);
-       QToolTip::add(soundSelection, "Select the MIDI instrument to play with");
+       soundSelection = new QComboBox(this);
+       soundSelection->setToolTip("Select the MIDI instrument to play with");
        fillSounds();
        connect(soundSelection, SIGNAL(activated(int)), midi, SLOT(setInstrument(int)));
        soundSelectionLabel = new QLabel("Sound:", this);
 
        // Setup the interface selector
-       interfaceSelection = new QComboBox(false, this);
-       QToolTip::add(interfaceSelection, "Select the interface to play with");
-       interfaceSelection->insertItem("Piano", 0);
-       interfaceSelection->insertItem("Violin", 1);
-       interfaceSelection->insertItem("Viola", 2);
-       interfaceSelection->insertItem("Cello", 3);
-       interfaceSelection->insertItem("Contrabass", 4);
+       interfaceSelection = new QComboBox(this);
+       interfaceSelection->setToolTip("Select the interface to play with");
+       interfaceSelection->insertItem(0, "Piano");
+       interfaceSelection->insertItem(1, "Violin");
+       interfaceSelection->insertItem(2, "Viola");
+       interfaceSelection->insertItem(3, "Cello");
+       interfaceSelection->insertItem(4, "Contrabass");
        connect(interfaceSelection, SIGNAL(activated(int)), this, SLOT(interfaceSelectionSlot(int)));
        instrument = 0;
        interfaceSelectionLabel = new QLabel("Interface:", this);
 
        // Setup the octave selector
-       octaveSelection = new QComboBox(false, this);
-       QToolTip::add(octaveSelection, "Select the starting octave");
+       octaveSelection = new QComboBox(this);
+       octaveSelection->setToolTip("Select the starting octave");
        for(int i = 0; i < 11; i++) {
-               octaveSelection->insertItem("Octave " + QString::number(i - 2), i);
+               octaveSelection->insertItem(i, "Octave " + QString::number(i - 2));
        }
        octaveSelectionLabel = new QLabel("Base Octave:", this);
 
@@ -54,11 +56,11 @@ MainWin::MainWin()
 
        // MIDI recording buttons
        recordBtn = new QPushButton("Record", this);
-       QToolTip::add(recordBtn, "Starts a MIDI recording of the notes played");
+       recordBtn->setToolTip("Starts a MIDI recording of the notes played");
        recordBtn->setEnabled(true);
        connect(recordBtn, SIGNAL(clicked()), SLOT(setupRecord()));
        stopBtn = new QPushButton("Stop", this);
-       QToolTip::add(stopBtn, "Stops the MIDI recording");
+       stopBtn->setToolTip("Stops the MIDI recording");
        stopBtn->setEnabled(false);
        connect(stopBtn, SIGNAL(clicked()), SLOT(finishRecord()));
 
@@ -125,7 +127,7 @@ MainWin::~MainWin()
 
 void MainWin::setupRecord() {
        if(midiFile == 0) {
-               QString filename = QFileDialog::getSaveFileName(QString::null, "MIDI files (*.mid *.midi)", this);
+               QString filename = QFileDialog::getSaveFileName(NULL, "MIDI files (*.mid *.midi)");
                if(filename.isNull() || filename.isEmpty())
                        return;
                midiFile = new MidiFile(filename);
@@ -173,7 +175,7 @@ void MainWin::interfaceSelectionSlot(int num)
                PianoInstrument *p = new PianoInstrument(this);
                instrument = p;
                // Select piano as the default
-               soundSelection->setCurrentItem(0);
+               soundSelection->setCurrentIndex(0);
                midi->setInstrument(0);
                if(midiFile != 0)
                        midiFile->setInstrument(0);
@@ -183,7 +185,7 @@ void MainWin::interfaceSelectionSlot(int num)
                ViolinInstrument *p = new ViolinInstrument(this);
                instrument = p;
                // Select violin as the default
-               soundSelection->setCurrentItem(40);
+               soundSelection->setCurrentIndex(40);
                midi->setInstrument(40);
                if(midiFile != 0)
                        midiFile->setInstrument(40);
@@ -193,7 +195,7 @@ void MainWin::interfaceSelectionSlot(int num)
                ViolaInstrument *p = new ViolaInstrument(this);
                instrument = p;
                // Select violin as the default
-               soundSelection->setCurrentItem(41);
+               soundSelection->setCurrentIndex(41);
                midi->setInstrument(41);
                if(midiFile != 0)
                        midiFile->setInstrument(41);
@@ -203,7 +205,7 @@ void MainWin::interfaceSelectionSlot(int num)
                CelloInstrument *p = new CelloInstrument(this);
                instrument = p;
                // Select violin as the default
-               soundSelection->setCurrentItem(42);
+               soundSelection->setCurrentIndex(42);
                midi->setInstrument(42);
                if(midiFile != 0)
                        midiFile->setInstrument(42);
@@ -213,7 +215,7 @@ void MainWin::interfaceSelectionSlot(int num)
                ContrabassInstrument *p = new ContrabassInstrument(this);
                instrument = p;
                // Select violin as the default
-               soundSelection->setCurrentItem(43);
+               soundSelection->setCurrentIndex(43);
                midi->setInstrument(43);
                if(midiFile != 0)
                        midiFile->setInstrument(43);
@@ -223,6 +225,7 @@ void MainWin::interfaceSelectionSlot(int num)
 
        // Relayout
        vLayout->insertWidget(3, instrument);
+       setFixedSize(640, 640);
        instrument->show();
 
        // Connect signals
@@ -236,139 +239,138 @@ void MainWin::interfaceSelectionSlot(int num)
        connect(octaveSelection, SIGNAL(activated(int)), instrument, SLOT(setStartOctave(int)));
 
        // Set the octave widget
-       octaveSelection->setCurrentItem(instrument->getNoteStart() / 12);
+       octaveSelection->setCurrentIndex(instrument->getNoteStart() / 12);
 }
 
 void MainWin::fillSounds()
 {
-       soundSelection->insertItem("Acoustic Grand Piano", 0);
-       soundSelection->insertItem("Bright Acoustic Piano", 1);
-       soundSelection->insertItem("Electric Grand Piano", 2);
-       soundSelection->insertItem("Honky-tonk Piano", 3);
-       soundSelection->insertItem("Rhodes Piano", 4);
-       soundSelection->insertItem("Chorused Piano", 5);
-       soundSelection->insertItem("Harpsichord", 6);
-       soundSelection->insertItem("Clavinet", 7);
-       soundSelection->insertItem("Celesta", 8);
-       soundSelection->insertItem("Glockenspiel", 9);
-       soundSelection->insertItem("Music Box", 10);
-       soundSelection->insertItem("Vibraphone", 11);
-       soundSelection->insertItem("Marimba", 12);
-       soundSelection->insertItem("Xylophone", 13);
-       soundSelection->insertItem("Tubular bells", 14);
-       soundSelection->insertItem("Dulcimer", 15);
-       soundSelection->insertItem("Draw Organ", 16);
-       soundSelection->insertItem("Percussive Organ", 17);
-       soundSelection->insertItem("Rock Organ", 18);
-       soundSelection->insertItem("Church Organ", 19);
-       soundSelection->insertItem("Reed Organ", 20);
-       soundSelection->insertItem("Accordion", 21);
-       soundSelection->insertItem("Harmonica", 22);
-       soundSelection->insertItem("Tango Accordion", 23);
-       soundSelection->insertItem("Acoustic Nylon Guitar", 24);
-       soundSelection->insertItem("Acoustic Steel Guitar", 25);
-       soundSelection->insertItem("Electric Jazz Guitar", 26);
-       soundSelection->insertItem("Electric clean Guitar", 27);
-       soundSelection->insertItem("Electric Guitar muted", 28);
-       soundSelection->insertItem("Overdriven Guitar", 29);
-       soundSelection->insertItem("Distortion Guitar", 30);
-       soundSelection->insertItem("Guitar Harmonics", 31);
-       soundSelection->insertItem("Wood Bass", 32);
-       soundSelection->insertItem("Electric Bass Fingered", 33);
-       soundSelection->insertItem("Electric Bass Picked", 34);
-       soundSelection->insertItem("Fretless Bass", 35);
-       soundSelection->insertItem("Slap Bass 1", 36);
-       soundSelection->insertItem("Slap Bass 2", 37);
-       soundSelection->insertItem("Synth Bass 1", 38);
-       soundSelection->insertItem("Synth Bass 2", 39);
-       soundSelection->insertItem("Violin", 40);
-       soundSelection->insertItem("Viola", 41);
-       soundSelection->insertItem("Cello", 42);
-       soundSelection->insertItem("Contrabass", 43);
-       soundSelection->insertItem("Tremolo Strings", 44);
-       soundSelection->insertItem("Pizzicato Strings", 45);
-       soundSelection->insertItem("Orchestral Harp", 46);
-       soundSelection->insertItem("Timpani", 47);
-       soundSelection->insertItem("Acoustic String Ensemble 1", 48);
-       soundSelection->insertItem("Acoustic String Ensemble 2", 49);
-       soundSelection->insertItem("Synth Strings 1", 50);
-       soundSelection->insertItem("Synth Strings 2", 51);
-       soundSelection->insertItem("Aah Choir", 52);
-       soundSelection->insertItem("Ooh Choir", 53);
-       soundSelection->insertItem("Synvox", 54);
-       soundSelection->insertItem("Orchestra Hit", 55);
-       soundSelection->insertItem("Trumpet", 56);
-       soundSelection->insertItem("Trombone", 57);
-       soundSelection->insertItem("Tuba", 58);
-       soundSelection->insertItem("Muted Trumpet", 59);
-       soundSelection->insertItem("French Horn", 60);
-       soundSelection->insertItem("Brass Section", 61);
-       soundSelection->insertItem("Synth Brass 1", 62);
-       soundSelection->insertItem("Synth Brass 2", 63);
-       soundSelection->insertItem("Soprano Sax", 64);
-       soundSelection->insertItem("Alto Sax", 65);
-       soundSelection->insertItem("Tenor Sax", 66);
-       soundSelection->insertItem("Baritone Sax", 67);
-       soundSelection->insertItem("Oboe", 68);
-       soundSelection->insertItem("English Horn", 69);
-       soundSelection->insertItem("Bassoon", 70);
-       soundSelection->insertItem("Clarinet", 71);
-       soundSelection->insertItem("Piccolo", 72);
-       soundSelection->insertItem("Flute", 73);
-       soundSelection->insertItem("Recorder", 74);
-       soundSelection->insertItem("Pan Flute", 75);
-       soundSelection->insertItem("Bottle blow", 76);
-       soundSelection->insertItem("Shakuhachi", 77);
-       soundSelection->insertItem("Whistle", 78);
-       soundSelection->insertItem("Ocarina", 79);
-       soundSelection->insertItem("Square Lead", 80);
-       soundSelection->insertItem("Saw Lead", 81);
-       soundSelection->insertItem("Calliope", 82);
-       soundSelection->insertItem("Chiffer", 83);
-       soundSelection->insertItem("Synth Lead 5", 84);
-       soundSelection->insertItem("Synth Lead 6", 85);
-       soundSelection->insertItem("Synth Lead 7", 86);
-       soundSelection->insertItem("Synth Lead 8", 87);
-       soundSelection->insertItem("Synth Pad 1", 88);
-       soundSelection->insertItem("Synth Pad 2", 89);
-       soundSelection->insertItem("Synth Pad 3", 90);
-       soundSelection->insertItem("Synth Pad 4", 91);
-       soundSelection->insertItem("Synth Pad 5", 92);
-       soundSelection->insertItem("Synth Pad 6", 93);
-       soundSelection->insertItem("Synth Pad 7", 94);
-       soundSelection->insertItem("Synth Pad 8", 95);
-       soundSelection->insertItem("Ice Rain", 96);
-       soundSelection->insertItem("Soundtracks", 97);
-       soundSelection->insertItem("Crystal", 98);
-       soundSelection->insertItem("Atmosphere", 99);
-       soundSelection->insertItem("Bright", 100);
-       soundSelection->insertItem("Goblin", 101);
-       soundSelection->insertItem("Echoes", 102);
-       soundSelection->insertItem("Space", 103);
-       soundSelection->insertItem("Sitar", 104);
-       soundSelection->insertItem("Banjo", 105);
-       soundSelection->insertItem("Shamisen", 106);
-       soundSelection->insertItem("Koto", 107);
-       soundSelection->insertItem("Kalimba", 108);
-       soundSelection->insertItem("Bagpipe", 109);
-       soundSelection->insertItem("Fiddle", 110);
-       soundSelection->insertItem("Shanai", 111);
-       soundSelection->insertItem("Tinkle bell", 112);
-       soundSelection->insertItem("Agogo", 113);
-       soundSelection->insertItem("Steel Drums", 114);
-       soundSelection->insertItem("Woodblock", 115);
-       soundSelection->insertItem("Taiko Drum", 116);
-       soundSelection->insertItem("Melodic Tom", 117);
-       soundSelection->insertItem("Synth Tom", 118);
-       soundSelection->insertItem("Reverse Cymbal", 119);
-       soundSelection->insertItem("Guitar Fret Noise", 120);
-       soundSelection->insertItem("Breath Noise", 121);
-       soundSelection->insertItem("Seashore", 122);
-       soundSelection->insertItem("Bird Tweet", 123);
-       soundSelection->insertItem("Telephone Ring", 124);
-       soundSelection->insertItem("Helicopter", 125);
-       soundSelection->insertItem("Applause", 126);
-       soundSelection->insertItem("Gunshot", 127);
+       soundSelection->insertItem(0, "Acoustic Grand Piano");
+       soundSelection->insertItem(1, "Bright Acoustic Piano");
+       soundSelection->insertItem(2, "Electric Grand Piano");
+       soundSelection->insertItem(3, "Honky-tonk Piano");
+       soundSelection->insertItem(4, "Rhodes Piano");
+       soundSelection->insertItem(5, "Chorused Piano");
+       soundSelection->insertItem(6, "Harpsichord");
+       soundSelection->insertItem(7, "Clavinet");
+       soundSelection->insertItem(8, "Celesta");
+       soundSelection->insertItem(9, "Glockenspiel");
+       soundSelection->insertItem(10, "Music Box");
+       soundSelection->insertItem(11, "Vibraphone");
+       soundSelection->insertItem(12, "Marimba");
+       soundSelection->insertItem(13, "Xylophone");
+       soundSelection->insertItem(14, "Tubular bells");
+       soundSelection->insertItem(15, "Dulcimer");
+       soundSelection->insertItem(16, "Draw Organ");
+       soundSelection->insertItem(17, "Percussive Organ");
+       soundSelection->insertItem(18, "Rock Organ");
+       soundSelection->insertItem(19, "Church Organ");
+       soundSelection->insertItem(20, "Reed Organ");
+       soundSelection->insertItem(21, "Accordion");
+       soundSelection->insertItem(22, "Harmonica");
+       soundSelection->insertItem(23, "Tango Accordion");
+       soundSelection->insertItem(24, "Acoustic Nylon Guitar");
+       soundSelection->insertItem(25, "Acoustic Steel Guitar");
+       soundSelection->insertItem(26, "Electric Jazz Guitar");
+       soundSelection->insertItem(27, "Electric clean Guitar");
+       soundSelection->insertItem(28, "Electric Guitar muted");
+       soundSelection->insertItem(29, "Overdriven Guitar");
+       soundSelection->insertItem(30, "Distortion Guitar");
+       soundSelection->insertItem(31, "Guitar Harmonics");
+       soundSelection->insertItem(32, "Wood Bass");
+       soundSelection->insertItem(33, "Electric Bass Fingered");
+       soundSelection->insertItem(34, "Electric Bass Picked");
+       soundSelection->insertItem(35, "Fretless Bass");
+       soundSelection->insertItem(36, "Slap Bass 1");
+       soundSelection->insertItem(37, "Slap Bass 2");
+       soundSelection->insertItem(38, "Synth Bass 1");
+       soundSelection->insertItem(39, "Synth Bass 2");
+       soundSelection->insertItem(40, "Violin");
+       soundSelection->insertItem(41, "Viola");
+       soundSelection->insertItem(42, "Cello");
+       soundSelection->insertItem(43, "Contrabass");
+       soundSelection->insertItem(44, "Tremolo Strings");
+       soundSelection->insertItem(45, "Pizzicato Strings");
+       soundSelection->insertItem(46, "Orchestral Harp");
+       soundSelection->insertItem(47, "Timpani");
+       soundSelection->insertItem(48, "Acoustic String Ensemble 1");
+       soundSelection->insertItem(49, "Acoustic String Ensemble 2");
+       soundSelection->insertItem(50, "Synth Strings 1");
+       soundSelection->insertItem(51, "Synth Strings 2");
+       soundSelection->insertItem(52, "Aah Choir");
+       soundSelection->insertItem(53, "Ooh Choir");
+       soundSelection->insertItem(54, "Synvox");
+       soundSelection->insertItem(55, "Orchestra Hit");
+       soundSelection->insertItem(56, "Trumpet");
+       soundSelection->insertItem(57, "Trombone");
+       soundSelection->insertItem(58, "Tuba");
+       soundSelection->insertItem(59, "Muted Trumpet");
+       soundSelection->insertItem(60, "French Horn");
+       soundSelection->insertItem(61, "Brass Section");
+       soundSelection->insertItem(62, "Synth Brass 1");
+       soundSelection->insertItem(63, "Synth Brass 2");
+       soundSelection->insertItem(64, "Soprano Sax");
+       soundSelection->insertItem(65, "Alto Sax");
+       soundSelection->insertItem(66, "Tenor Sax");
+       soundSelection->insertItem(67, "Baritone Sax");
+       soundSelection->insertItem(68, "Oboe");
+       soundSelection->insertItem(69, "English Horn");
+       soundSelection->insertItem(70, "Bassoon");
+       soundSelection->insertItem(71, "Clarinet");
+       soundSelection->insertItem(72, "Piccolo");
+       soundSelection->insertItem(73, "Flute");
+       soundSelection->insertItem(74, "Recorder");
+       soundSelection->insertItem(75, "Pan Flute");
+       soundSelection->insertItem(76, "Bottle blow");
+       soundSelection->insertItem(77, "Shakuhachi");
+       soundSelection->insertItem(78, "Whistle");
+       soundSelection->insertItem(79, "Ocarina");
+       soundSelection->insertItem(80, "Square Lead");
+       soundSelection->insertItem(81, "Saw Lead");
+       soundSelection->insertItem(82, "Calliope");
+       soundSelection->insertItem(83, "Chiffer");
+       soundSelection->insertItem(84, "Synth Lead 5");
+       soundSelection->insertItem(85, "Synth Lead 6");
+       soundSelection->insertItem(86, "Synth Lead 7");
+       soundSelection->insertItem(87, "Synth Lead 8");
+       soundSelection->insertItem(88, "Synth Pad 1");
+       soundSelection->insertItem(89, "Synth Pad 2");
+       soundSelection->insertItem(90, "Synth Pad 3");
+       soundSelection->insertItem(91, "Synth Pad 4");
+       soundSelection->insertItem(92, "Synth Pad 5");
+       soundSelection->insertItem(93, "Synth Pad 6");
+       soundSelection->insertItem(94, "Synth Pad 7");
+       soundSelection->insertItem(95, "Synth Pad 8");
+       soundSelection->insertItem(96, "Ice Rain");
+       soundSelection->insertItem(97, "Soundtracks");
+       soundSelection->insertItem(98, "Crystal");
+       soundSelection->insertItem(99, "Atmosphere");
+       soundSelection->insertItem(100, "Bright");
+       soundSelection->insertItem(101, "Goblin");
+       soundSelection->insertItem(102, "Echoes");
+       soundSelection->insertItem(103, "Space");
+       soundSelection->insertItem(104, "Sitar");
+       soundSelection->insertItem(105, "Banjo");
+       soundSelection->insertItem(106, "Shamisen");
+       soundSelection->insertItem(107, "Koto");
+       soundSelection->insertItem(108, "Kalimba");
+       soundSelection->insertItem(109, "Bagpipe");
+       soundSelection->insertItem(110, "Fiddle");
+       soundSelection->insertItem(111, "Shanai");
+       soundSelection->insertItem(112, "Tinkle bell");
+       soundSelection->insertItem(113, "Agogo");
+       soundSelection->insertItem(114, "Steel Drums");
+       soundSelection->insertItem(115, "Woodblock");
+       soundSelection->insertItem(116, "Taiko Drum");
+       soundSelection->insertItem(117, "Melodic Tom");
+       soundSelection->insertItem(118, "Synth Tom");
+       soundSelection->insertItem(119, "Reverse Cymbal");
+       soundSelection->insertItem(120, "Guitar Fret Noise");
+       soundSelection->insertItem(121, "Breath Noise");
+       soundSelection->insertItem(122, "Seashore");
+       soundSelection->insertItem(123, "Bird Tweet");
+       soundSelection->insertItem(124, "Telephone Ring");
+       soundSelection->insertItem(125, "Helicopter");
+       soundSelection->insertItem(126, "Applause");
+       soundSelection->insertItem(127, "Gunshot");
 
 }
-