-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathErrorIdentifier.qml
692 lines (604 loc) · 24 KB
/
ErrorIdentifier.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
//=============================================================================
//
//=============================================================================
import MuseScore 3.0
import QtQuick 2.0
import QtQuick.Layouts 1.0
import QtQuick.Controls 1.4
import QtQuick.Dialogs 1.2
import Qt.labs.settings 1.0
MuseScore {
menuPath: "Plugins.Analysis.Partwriting Error Identifier"
description: 'Automatically Identify Errors in part-writing'
version: "0.1.0"
pluginType: "dialog"
// Allowed Part Range Configurations
property int sopranoHighestNote : 79 // G5
property int sopranoLowestNote : 60 // C4
property int altoHighestNote : 72 // C5
property int altoLowestNote : 55 // G3
property int tenorHighestNote : 67 // G4
property int tenorLowestNote : 48 // C3
property int bassHighestNote : 60 // C4
property int bassLowestNote : 40 // E2
// Maximum Spacing Configuration
property int sopranoAltoMaxDistance : 12 // P8
property int altoTenorMaxDistance : 12 // P8
property int tenorBassMaxDistance : 24 // P15
// Error Counters
property int totalErrorCount : 0
property int rangeErrorCount : 0
property int melodicDissonanceCount : 0
property int spacingErrorCount : 0
property int crossedVoicesErrorCount : 0
property int parallelErrorCount : 0
property int hiddenFifthErrorCount : 0
property int diminishedFifthErrorCount : 0
// Error Colors
property variant noErrors : "#000000" // Black
property variant rangeErrorColor : "#CCCC00" // Dark Yellow
property variant melodicDissonanceColor : "#0000FF" // Blue
property variant spacingErrorColor : "#008000" // Green
property variant crossedVoicesColor : "#008080" // Teal
property variant parallelErrorColor : "#ff0000" // Red
property variant hiddenFifthsColor : "#4040ff" // Not Sure what color this is
property variant diminishedFifthColor : "#800080" // Purple
// Sorts an array of notes so that the lowest note is at the start of the
// array and the highest note is at the end. This makes some assumptions
// but could prove useful in some cases
function sortNoteArray(notes) {
if(notes.length == 0) {
return notes;
}
var sorted = false;
var index = 0;
while(!sorted) {
if(index + 1 < notes.length) {
if(notes[index+1].pitch < notes[index]) {
var temp = notes[index];
notes[index] = notes[index + 1]
notes[index+1] = temp;
index = 0
}
} else {
sorted = true;
}
}
}
// A basic absolute value function
function abs(value) {
if (value < 0) {
return value * -1;
} else {
return value;
}
}
// Labels any Range errors.
function labelRangeErrors(chord) {
if(chord.length != 4) {
// TODO: Decide what to do in these kind of situations
console.log('I saw too many notes here!')
}
// Check Bass
if(chord[0].pitch < bassLowestNote) {
console.log('Range Error Found!');
chord[0].color = rangeErrorColor;
totalErrorCount++;
rangeErrorCount++;
}
if(chord[0].pitch > bassHighestNote) {
console.log('Range Error Found!');
chord[0].color = rangeErrorColor;
totalErrorCount++;
rangeErrorCount++;
}
// Check Tenor
if(chord[1].pitch < tenorLowestNote) {
console.log('Range Error Found!');
chord[1].color = rangeErrorColor;
totalErrorCount++;
rangeErrorCount++;
}
if(chord[1].pitch > tenorHighestNote) {
console.log('Range Error Found!');
chord[1].color = rangeErrorColor;
totalErrorCount++;
rangeErrorCount++;
}
// Check Alto
if(chord[2].pitch < altoLowestNote) {
console.log('Range Error Found!');
chord[2].color = rangeErrorColor;
totalErrorCount++;
rangeErrorCount++;
}
if(chord[2].pitch > altoHighestNote) {
console.log('Range Error Found!');
chord[2].color = rangeErrorColor;
totalErrorCount++;
rangeErrorCount++;
}
// Check Soprano
if(chord[3].pitch < sopranoLowestNote) {
console.log('Range Error Found!');
chord[3].color = rangeErrorColor;
totalErrorCount++;
rangeErrorCount++;
}
if(chord[3].pitch > sopranoHighestNote) {
console.log('Range Error Found!');
chord[3].color = rangeErrorColor;
totalErrorCount++;
rangeErrorCount++;
}
}
function findRangeErrors(all_chords) {
for (var i = 0; i < all_chords.length; i++) {
labelRangeErrors(all_chords[i]);
}
}
function labelMelodicDissonanceErrors(note1, note2) {
var dist = note1.tpc1 - note2.tpc1;
if(dist < 0) {
dist = dist * -1;
}
if(dist >= 6) {
// Indicates a Melodic Dissonance Error
console.log("Melodic Dissonance Error Found. Dist: " + dist);
note1.color = melodicDissonanceColor;
note2.color = melodicDissonanceColor;
totalErrorCount++;
melodicDissonanceCount++;
}
}
function findMelodicDissonanceErrors(all_chords) {
for(var i = 0; i < 4; i++) {
for(var j = 0; j < all_chords.length - 1; j++){
labelMelodicDissonanceErrors(all_chords[j][i], all_chords[j+1][i]);
}
}
}
function labelSpacingErrors(chord) {
// Calculate Spacings
var tenorBassSpacing = chord[1].pitch - chord[0].pitch;
var altoTenorSpacing = chord[2].pitch - chord[1].pitch;
var sopranoAltoSpacing = chord[3].pitch - chord[2].pitch;
if(tenorBassSpacing > tenorBassMaxDistance) {
console.log("Spacing Error Found!");
chord[0].color = spacingErrorColor;
chord[1].color = spacingErrorColor;
totalErrorCount++;
spacingErrorCount++;
}
if(altoTenorSpacing > altoTenorMaxDistance) {
console.log("Spacing Error Found!");
chord[1].color = spacingErrorColor;
chord[2].color = spacingErrorColor;
totalErrorCount++;
spacingErrorCount++;
}
if(sopranoAltoSpacing > sopranoAltoMaxDistance) {
console.log("Spacing Error Found!");
chord[2].color = spacingErrorColor;
chord[3].color = spacingErrorColor;
totalErrorCount++;
spacingErrorCount++;
}
}
function findSpacingErrors(all_chords) {
for(var i = 0; i < all_chords.length; i++) {
labelSpacingErrors(all_chords[i]);
}
}
function labelCrossedVoices(chord) {
if(chord[0].pitch > chord[1].pitch) {
console.log("Crossed Voices Found!");
chord[0].color = crossedVoicesColor;
chord[1].color = crossedVoicesColor;
totalErrorCount++;
crossedVoicesErrorCount++;
}
if(chord[1].pitch > chord[2].pitch) {
console.log("Crossed Voices Found!");
chord[1].color = crossedVoicesColor;
chord[2].color = crossedVoicesColor;
totalErrorCount++;
crossedVoicesErrorCount++;
}
if(chord[2].pitch > chord[3].pitch) {
console.log("Crossed Voices Found!");
chord[2].color = crossedVoicesColor;
chord[3].color = crossedVoicesColor;
totalErrorCount++;
crossedVoicesErrorCount++;
}
}
function findCrossedVoices(all_chords) {
for(var i = 0; i < all_chords.length; i++) {
labelCrossedVoices(all_chords[i]);
}
}
function labelParallels(chord1, chord2) {
for(var i = 0; i < chord1.length - 1; i++) {
for(var j = i + 1; j < chord1.length; j++) {
// Calculate intervals between pitches
var chord1Diff = chord1[j].pitch - chord1[i].pitch;
var chord2Diff = chord2[j].pitch - chord2[i].pitch;
// Determine Parallel
var isParallel = chord1Diff == chord2Diff;
// Correct for wider ranges
chord1Diff = chord1Diff % 12;
chord2Diff = chord2Diff % 12;
// Check Octaves
if(isParallel && chord1Diff == 0) {
console.log("Parallel Octaves Found");
chord1[i].color = parallelErrorColor;
chord1[j].color = parallelErrorColor;
chord2[i].color = parallelErrorColor;
chord2[j].color = parallelErrorColor;
totalErrorCount++;
parallelErrorCount++;
}
// Check Fifths
if(isParallel && chord1Diff == 7) {
console.log("Parallel Fifths Found");
chord1[i].color = parallelErrorColor;
chord1[j].color = parallelErrorColor;
chord2[i].color = parallelErrorColor;
chord2[j].color = parallelErrorColor;
totalErrorCount++;
parallelErrorCount++;
}
}
}
}
function findParallels(all_chords) {
for(var i = 0; i < all_chords.length - 1; i++) {
labelParallels(all_chords[i], all_chords[i+1]);
}
}
function labelHiddenFifthsAndOctaves(chord1, chord2) {
var sopPitchDifference = chord2[3].pitch - chord1[3].pitch;
var bassPitchDifference = chord2[0].pitch - chord1[0].pitch;
var chord2Interval = (chord2[3].pitch - chord2[0].pitch) % 12;
var isSopLeap = abs(sopPitchDifference) > 2;
var isSameDirection = false;
var isBadInterval = false;
if(sopPitchDifference > 0 && bassPitchDifference > 0) {
isSameDirection = true;
}
if(sopPitchDifference < 0 && bassPitchDifference < 0) {
isSameDirection = true;
}
if(chord2Interval == 0 || chord2Interval == 7) {
isBadInterval = true;
}
if(isSopLeap && isSameDirection && isBadInterval) {
console.log("A Hidden fifth or octave was found!");
chord1[0].color = hiddenFifthsColor;
chord1[3].color = hiddenFifthsColor;
chord2[0].color = hiddenFifthsColor;
chord2[3].color = hiddenFifthsColor;
totalErrorCount++;
hiddenFifthErrorCount++;
}
}
function findHiddenFifthsAndOctaves(all_chords) {
for(var i = 0; i < all_chords.length - 1; i++) {
labelHiddenFifthsAndOctaves(all_chords[i], all_chords[i+1]);
}
}
function labelDiminishedFifthResolutionErrors(chord1, chord2) {
for(var i = 0; i < chord1.length - 1; i++) {
for(var j = i + 1; j < chord1.length; j++) {
// Calculate intervals between pitches
var chord1Diff = chord1[j].pitch - chord1[i].pitch;
var chord2Diff = chord2[j].pitch - chord2[i].pitch;
if(chord1Diff == 6 && chord2Diff == 7) {
console.log("Found an improper diminished fifths resolution.");
chord1[i].color = diminishedFifthColor;
chord1[j].color = diminishedFifthColor;
chord2[i].color = diminishedFifthColor;
chord2[j].color = diminishedFifthColor;
totalErrorCount++;
diminishedFifthErrorCount++;
}
}
}
}
function findDiminishedFifthResolutionErrors(all_chords) {
for(var i = 0; i < all_chords.length - 1; i++) {
labelDiminishedFifthResolutionErrors(all_chords[i], all_chords[i+1]);
}
}
// Borrowed from chord identifier pop jazz.qml
function chordDuration(chord){
var duration = chord.globalDuration; // only from MS 3.5 onwards
if ( !duration )
duration = chord.duration;
return duration.ticks;
}
// Borrowed from chord identifier pop jazz.qml
function getAllCurrentNotes(cursor, startStaff, endStaff, onlySelected, prev_chord){
var full_chord = [];
var tickLogged = false;
for (var staff = endStaff; staff >= startStaff; staff--) {
for (var voice = 3; voice >=0; voice--) {
var trackLogged = false;
cursor.voice = voice;
cursor.staffIdx = staff;
if (cursor.element && cursor.element.type == Element.CHORD) {
var notes = cursor.element.notes;
for (var i = 0; i < notes.length; i++) {
if (onlySelected && !notes[i].selected)
continue;
if ( !tickLogged ) {
console.log('>>>>> tick ' + cursor.tick);
tickLogged = true;
}
if ( !trackLogged ) {
console.log(' >> s'+staff+' v'+voice+' duration:'+chordDuration(cursor.element));
trackLogged = true;
}
full_chord.push(notes[i]);
console.log(' >> pitch:' + notes[i].pitch);
}
}
}
}
if (prev_chord) {
for (var i = 0; i < prev_chord.length; i++) {
var note = prev_chord[i];
var excl = (note.parent.parent.tick + chordDuration(note.parent) > cursor.tick ? "!!!" : "");
if (excl && settings.entire_note_duration)
full_chord.push(note);
}
}
if (cursor.element && cursor.element.type != Element.CHORD) {
console.log('Found Other: ' + cursor.element.type);
}
return full_chord;
}
// Borrowed from chord identifier pop jazz.qml
function setToClosestNextElement(cursor, elemType) {
// move cursor to closest next segment with Element elemType, whatever the track
var seg = cursor.segment;
if ( !seg )
return false;
while(seg = seg.next) {
// console.log(' next seg: tick='+seg.tick);
var tr;
for (tr = 0; tr < curScore.ntracks; tr++) {
var el = seg.elementAt(tr);
// if (el) console.log(' track#'+tr+' of type '+el.userName());
if (el && el.type == elemType)
break;
}
if (tr < curScore.ntracks) {
cursor.track = tr;
while (cursor.tick < seg.tick)
cursor.next();
if (cursor.tick > seg.tick)
console.log('BUG!!! cursor('+cursor.tick+') went beyond seg('+seg.tick+') !!');
return true;
} else {
// console.log(' required element not found');
}
}
if ( !seg ) {
// reached end without finding Element Type
return false;
}
}
function clearAllColors(cursor, startStaff, endStaff, fullScore) {
// Iterate over the score to identify errors
cursor.rewind(Cursor.SCORE_START); // start from beginning of score
var segment;
while (segment=cursor.segment) {
var full_chord = getAllCurrentNotes(cursor, startStaff, endStaff, !fullScore, full_chord);
for(var i = 0; i < full_chord.length; i++){
full_chord[i].color = noErrors;
}
if ( !setToClosestNextElement(cursor, Element.CHORD) )
break;
}
}
function clearAllColorsQuick() {
var cursor = curScore.newCursor(),
startStaff = 0,
endStaff = curScore.nstaves - 1,
fullScore = (curScore.selection.elements.length <= 1); // ignore accidental note or element
clearAllColors(cursor, startStaff, endStaff, fullScore);
}
function buildNotesArray(cursor, startStaff, endStaff, fullScore) {
cursor.rewind(Cursor.SCORE_START)
// Count number of chords and build array
var segment;
var numSegments = 0;
var all_chords = [];
while (segment=cursor.segment) {
var full_chord = getAllCurrentNotes(cursor, startStaff, endStaff, fullScore, full_chord);
numSegments++;
all_chords.push(full_chord);
if (!setToClosestNextElement(cursor, Element.CHORD)) break;
}
console.log('Found ' + numSegments + ' Chords');
return all_chords;
}
function startAnalysis() {
// For now, borrowed from chord identifier plugin
// Start a new Cursor (used to navigate the score)
var cursor = curScore.newCursor(),
startStaff = 0,
endStaff = curScore.nstaves - 1,
fullScore = (curScore.selection.elements.length <= 1); // ignore accidental note or element
console.log('startStaff: ' + startStaff);
console.log('endStaff: ' + endStaff);
console.log('curScore.nstaves: ' + curScore.nstaves);
// Reset all coloring in the case that errors have been resolved
clearAllColors(cursor, startStaff, endStaff, fullScore);
// Identify both possible key signatures
cursor.rewind(Cursor.SCORE_START); // start from beginning of score
var keySig = cursor.keySignature;
// var keysig_name_major = getNoteName(keySig+7+7);
// var keysig_name_minor = getNoteName(keySig+7+10);
// console.log('559: keysig: ' + keySig + ' -> '+keysig_name_major+' major or '+keysig_name_minor+' minor.');
var all_chords = buildNotesArray(cursor, startStaff, endStaff, !fullScore);
findRangeErrors(all_chords);
findMelodicDissonanceErrors(all_chords);
findSpacingErrors(all_chords);
findCrossedVoices(all_chords);
findParallels(all_chords);
findHiddenFifthsAndOctaves(all_chords);
findDiminishedFifthResolutionErrors(all_chords)
// Iterate over the score to identify errors
// var segment;
// while (segment=cursor.segment) {
// var full_chord = getAllCurrentNotes(cursor, startStaff, endStaff, !fullScore, full_chord);
// // labelRangeErrors(full_chord);
// if ( !setToClosestNextElement(cursor, Element.CHORD) )
// break;
// }
}
onRun: {
startAnalysis();
console.log('Total Errors: ' + totalErrorCount);
}
id: mainDialog
width: 500
height: 400
ColumnLayout {
id: errorsFoundDisplay
anchors.left: Button.right
RowLayout {
id: intro
spacing: 20
Text { text: " Welcome to the part-writing Error Identifier"; font.bold: true }
}
RowLayout {
id: columnHeaderRow
spacing: 10
Text { text: " Color:"; font.bold: true }
Text { text: "Error Type:"; font.bold: true }
Text { text: "Num Errors:"; font.bold: true }
}
RowLayout {
id: rangeErrorRow
spacing: 10
Text { text: " 𝅘𝅥 𝅘𝅥 𝅘𝅥 𝅘𝅥 "; color: rangeErrorColor }
Text {
text: '<html><a href="https://partwriting-error-checker.readthedocs.io/en/latest/Errors/RangeErrors/">Range Errors</a></html>'
onLinkActivated:Qt.openUrlExternally(link)
}
Text { text: rangeErrorCount }
}
RowLayout {
id: melodicDissonanceErrorRow
spacing: 10
Text { text: " 𝅘𝅥 𝅘𝅥 𝅘𝅥 𝅘𝅥 "; color: melodicDissonanceColor }
Text {
text: '<html><a href="https://partwriting-error-checker.readthedocs.io/en/latest/Errors/MelodicDissonance/">Melodic Dissonance Errors</a></html>'
onLinkActivated:Qt.openUrlExternally(link)
}
Text { text: melodicDissonanceCount }
}
RowLayout {
id: spacingErrorRow
spacing: 10
Text { text: " 𝅘𝅥 𝅘𝅥 𝅘𝅥 𝅘𝅥 "; color: spacingErrorColor }
Text {
text: '<html><a href="https://partwriting-error-checker.readthedocs.io/en/latest/Errors/SpacingErrors/">Spacing Errors</a></html>'
onLinkActivated:Qt.openUrlExternally(link)
}
Text { text: spacingErrorCount }
}
RowLayout {
id: crossedErrorRow
spacing: 10
Text { text: " 𝅘𝅥 𝅘𝅥 𝅘𝅥 𝅘𝅥 "; color: crossedVoicesColor }
Text {
text: '<html><a href="https://partwriting-error-checker.readthedocs.io/en/latest/Errors/CrossedVoices/">Crossed Voices Errors</a></html>'
onLinkActivated:Qt.openUrlExternally(link)
}
Text { text: crossedVoicesErrorCount }
}
RowLayout {
id: parallelErrorRow
spacing: 10
Text { text: " 𝅘𝅥 𝅘𝅥 𝅘𝅥 𝅘𝅥 "; color: parallelErrorColor }
Text {
text: '<html><a href="https://partwriting-error-checker.readthedocs.io/en/latest/Errors/ParallelErrors/">Parallel 5ths/8va Errors</a></html>'
onLinkActivated:Qt.openUrlExternally(link)
}
Text { text: parallelErrorCount }
}
RowLayout {
id: hiddenFifthsErrorRow
spacing: 10
Text { text: " 𝅘𝅥 𝅘𝅥 𝅘𝅥 𝅘𝅥 "; color: hiddenFifthsColor }
Text {
text: '<html><a href="https://partwriting-error-checker.readthedocs.io/en/latest/Errors/HiddenFifths/">Hidden Fifths Errors</a></html>'
onLinkActivated:Qt.openUrlExternally(link)
}
Text { text: hiddenFifthErrorCount }
}
RowLayout {
id: diminishedFifthErrorRow
spacing: 10
Text { text: " 𝅘𝅥 𝅘𝅥 𝅘𝅥 𝅘𝅥 "; color: diminishedFifthColor }
Text {
text: '<html><a href="https://partwriting-error-checker.readthedocs.io/en/latest/Errors/DiminishedFifthResolutions/">Diminished Fifth Resolution Errors</a></html>'
onLinkActivated:Qt.openUrlExternally(link)
}
Text { text: diminishedFifthErrorCount }
}
RowLayout {
id: totalErrorsRow
spacing: 20
Text { text: " Total Errors:"; font.bold: true }
Text { text: totalErrorCount; font.bold: false }
}
}
Button {
id: buttonFeedback
text: qsTr("Provide Feedback")
anchors.bottom: mainDialog.bottom
anchors.left: mainDialog.left
anchors.bottomMargin: 10
anchors.leftMargin: 10
width: 100
height: 40
onClicked: {
Qt.openUrlExternally("https://uah.co1.qualtrics.com/jfe/form/SV_4ZxsMoY3zoPbdnU")
}
}
Button {
id: buttonOK
text: qsTr("OK")
anchors.bottom: mainDialog.bottom
anchors.right: mainDialog.right
anchors.bottomMargin: 10
anchors.rightMargin: 10
width: 100
height: 40
onClicked: {
Qt.quit();
}
}
Button {
id: buttonClearColors
text: qsTr("Clear Colors")
anchors.bottom: mainDialog.bottom
anchors.right: buttonOK.left
anchors.rightMargin: 10
anchors.bottomMargin: 10
width: 100
height: 40
onClicked: {
curScore.startCmd();
clearAllColorsQuick();
curScore.endCmd();
Qt.quit();
}
}
}