From 4995b3a87cd05bbbc0311b9bfb6b66ecfef7581c Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Sat, 18 Apr 2009 18:25:44 +0200 Subject: [PATCH] InstrumentTrackView: save and restore last position of window When closing a InstrumentTrackWindow save its position so it can be restored later when showing it. Fixes windows always popping up somewhere else when toggling instrument track button repeatedly. (cherry picked from commit 232c1de4048b2930d5ef96174b90ef7cf6ae3b5c) --- include/instrument_track.h | 4 +++- src/tracks/instrument_track.cpp | 9 ++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/instrument_track.h b/include/instrument_track.h index 074ca0c52..8d700c417 100644 --- a/include/instrument_track.h +++ b/include/instrument_track.h @@ -288,7 +288,7 @@ private slots: private: instrumentTrackWindow * m_window; - + static QQueue s_windows; // widgets in track-settings-widget @@ -302,6 +302,8 @@ private: QAction * m_midiInputAction; QAction * m_midiOutputAction; + QPoint m_lastPos; + friend class instrumentTrackWindow; diff --git a/src/tracks/instrument_track.cpp b/src/tracks/instrument_track.cpp index 363d0f7a5..f8a705788 100644 --- a/src/tracks/instrument_track.cpp +++ b/src/tracks/instrument_track.cpp @@ -860,7 +860,8 @@ QQueue instrumentTrackView::s_windows; instrumentTrackView::instrumentTrackView( instrumentTrack * _it, trackContainerView * _tcv ) : trackView( _it, _tcv ), - m_window( NULL ) + m_window( NULL ), + m_lastPos( -1, -1 ) { setAcceptDrops( true ); setFixedHeight( 32 ); @@ -970,6 +971,7 @@ void instrumentTrackView::freeInstrumentTrackWindow( void ) { if( m_window != NULL ) { + m_lastPos = m_window->parentWidget()->pos(); if( s_windows.count() < INSTRUMENT_WINDOW_CACHE_SIZE ) { model()->setHook( NULL ); @@ -1016,6 +1018,11 @@ instrumentTrackWindow * instrumentTrackView::getInstrumentTrackWindow( void ) m_window->setModel( model() ); m_window->updateInstrumentView(); model()->setHook( m_window ); + + if( m_lastPos.x() > 0 || m_lastPos.y() > 0 ) + { + m_window->parentWidget()->move( m_lastPos ); + } } else {