InstrumentTrackView: use QMdiArea's window activation history

There's no need to implement an own (buggy) window activation history
for InstrumentTrackWindows. Use QMdiArea::subWindowList(...) instead.
Fixes buggy keyboard focus when switching between InstrumentTrackWindows.
This commit is contained in:
Tobias Doerffel
2010-10-06 10:14:22 +02:00
parent fd40743772
commit c05965117c
3 changed files with 26 additions and 29 deletions

View File

@@ -41,7 +41,6 @@
class QLineEdit;
template<class T> class QQueue;
template<class T> class QStack;
class ArpeggiatorView;
class ChordCreatorView;
class EffectRackView;
@@ -260,10 +259,7 @@ public:
return castModel<InstrumentTrack>();
}
static InstrumentTrackWindow * topLevelInstrumentTrackWindow()
{
return s_windowStack.isEmpty() ? NULL : s_windowStack.top();
}
static InstrumentTrackWindow * topLevelInstrumentTrackWindow();
QMenu * midiMenu()
{
@@ -294,7 +290,6 @@ private:
InstrumentTrackWindow * m_window;
static QQueue<InstrumentTrackWindow *> s_windowCache;
static QStack<InstrumentTrackWindow *> s_windowStack;
// widgets in track-settings-widget
trackLabelButton * m_tlb;

View File

@@ -1243,15 +1243,18 @@ void MainWindow::keyPressEvent( QKeyEvent * _ke )
case Qt::Key_Shift: m_keyMods.m_shift = true; break;
case Qt::Key_Alt: m_keyMods.m_alt = true; break;
default:
if( InstrumentTrackView::topLevelInstrumentTrackWindow() )
{
InstrumentTrackWindow * w =
InstrumentTrackView::topLevelInstrumentTrackWindow();
if( w )
{
InstrumentTrackView::topLevelInstrumentTrackWindow()->
pianoView()->keyPressEvent( _ke );
w->pianoView()->keyPressEvent( _ke );
}
if( !_ke->isAccepted() )
{
QMainWindow::keyPressEvent( _ke );
}
}
}
}

View File

@@ -26,7 +26,6 @@
#include <QtCore/QDir>
#include <QtCore/QFile>
#include <QtCore/QQueue>
#include <QtCore/QStack>
#include <QtGui/QApplication>
#include <QtGui/QCloseEvent>
#include <QtGui/QFileDialog>
@@ -876,7 +875,6 @@ Instrument * InstrumentTrack::loadInstrument( const QString & _plugin_name )
QQueue<InstrumentTrackWindow *> InstrumentTrackView::s_windowCache;
QStack<InstrumentTrackWindow *> InstrumentTrackView::s_windowStack;
@@ -987,6 +985,24 @@ InstrumentTrackView::~InstrumentTrackView()
InstrumentTrackWindow * InstrumentTrackView::topLevelInstrumentTrackWindow()
{
InstrumentTrackWindow * w = NULL;
foreach( QMdiSubWindow * sw,
engine::mainWindow()->workspace()->subWindowList(
QMdiArea::ActivationHistoryOrder ) )
{
if( sw->isVisible() && sw->widget()->inherits( "InstrumentTrackWindow" ) )
{
w = qobject_cast<InstrumentTrackWindow *>( sw->widget() );
}
}
return w;
}
// TODO: Add windows to free list on freeInstrumentTrackWindow.
// But, don't NULL m_window or disconnect signals. This will allow windows
// that are being show/hidden frequently to stay connected.
@@ -994,12 +1010,6 @@ void InstrumentTrackView::freeInstrumentTrackWindow()
{
if( m_window != NULL )
{
if( qFind( s_windowStack.begin(), s_windowStack.end(), m_window ) !=
s_windowStack.end() )
{
s_windowStack.erase(
qFind( s_windowStack.begin(), s_windowStack.end(), m_window ) );
}
m_lastPos = m_window->parentWidget()->pos();
if( configManager::inst()->value( "ui",
@@ -1102,23 +1112,12 @@ void InstrumentTrackView::dropEvent( QDropEvent * _de )
void InstrumentTrackView::toggleInstrumentWindow( bool _on )
{
InstrumentTrackWindow * w = getInstrumentTrackWindow();
w->toggleVisibility( _on );
getInstrumentTrackWindow()->toggleVisibility( _on );
if( !_on )
{
freeInstrumentTrackWindow();
}
else
{
if( qFind( s_windowStack.begin(), s_windowStack.end(), w ) !=
s_windowStack.end() )
{
s_windowStack.erase(
qFind( s_windowStack.begin(), s_windowStack.end(), w ) );
}
s_windowStack.push( w );
}
}