! \brief Handle the focus leaving the piano display view * * Turn off all notes if we lose focus. * * \todo Is there supposed to be a parameter given here? */
| 658 | * \todo Is there supposed to be a parameter given here? |
| 659 | */ |
| 660 | void PianoView::focusOutEvent( QFocusEvent * ) |
| 661 | { |
| 662 | if( m_piano == NULL ) |
| 663 | { |
| 664 | return; |
| 665 | } |
| 666 | |
| 667 | // focus just switched to another control inside the instrument track |
| 668 | // window we live in? |
| 669 | if( parentWidget()->parentWidget()->focusWidget() != this && |
| 670 | parentWidget()->parentWidget()->focusWidget() != NULL && |
| 671 | !(parentWidget()->parentWidget()-> |
| 672 | focusWidget()->inherits( "QLineEdit" ) || |
| 673 | parentWidget()->parentWidget()-> |
| 674 | focusWidget()->inherits( "QPlainTextEdit" ) )) |
| 675 | { |
| 676 | // then reclaim keyboard focus! |
| 677 | setFocus(); |
| 678 | return; |
| 679 | } |
| 680 | |
| 681 | // if we loose focus, we HAVE to note off all running notes because |
| 682 | // we don't receive key-release-events anymore and so the notes would |
| 683 | // hang otherwise |
| 684 | for( int i = 0; i < NumKeys; ++i ) |
| 685 | { |
| 686 | m_piano->midiEventProcessor()->processInEvent( MidiEvent( MidiNoteOff, -1, i, 0 ) ); |
| 687 | m_piano->setKeyState( i, false ); |
| 688 | } |
| 689 | update(); |
| 690 | } |
| 691 | |
| 692 | |
| 693 |
nothing calls this directly
no test coverage detected