properly save and restore position, size, visibility and state of MDI-subwindows

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1569 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2008-09-07 12:09:02 +00:00
parent ee6eb02c0e
commit 3372309f73
14 changed files with 123 additions and 160 deletions

View File

@@ -915,6 +915,12 @@ void song::loadProject( const QString & _file_name )
else if( engine::hasGUI() )
{
if( node.nodeName() ==
engine::getControllerRackView()->nodeName() )
{
engine::getControllerRackView()->
restoreState( node.toElement() );
}
else if( node.nodeName() ==
engine::getPianoRoll()->nodeName() )
{
engine::getPianoRoll()->restoreState(
@@ -999,6 +1005,7 @@ bool song::saveProject( void )
engine::getFxMixer()->saveState( mmp, mmp.content() );
if( engine::hasGUI() )
{
engine::getControllerRackView()->saveState( mmp, mmp.content() );
engine::getPianoRoll()->saveState( mmp, mmp.content() );
engine::getAutomationEditor()->saveState( mmp, mmp.content() );
( (journallingObject *)( engine::getProjectNotes() ) )->

View File

@@ -57,8 +57,6 @@ void trackContainer::saveSettings( QDomDocument & _doc, QDomElement & _this )
{
_this.setTagName( classNodeName() );
_this.setAttribute( "type", nodeName() );
// ### TODO
//mainWindow::saveWidgetState( this, _this );
// save settings of each track
m_tracksMutex.lockForRead();
@@ -118,10 +116,6 @@ void trackContainer::loadSettings( const QDomElement & _this )
node = node.nextSibling();
}
// ### TODO
// mainWindow::restoreWidgetState( this, _this );
if( pd != NULL )
{
pd->setValue( start_val + _this.childNodes().count() );

View File

@@ -155,7 +155,7 @@ mainWindow::mainWindow( void ) :
setCentralWidget( main_widget );
m_updateTimer.start( 1000 / 20, this ); // 20 fps
}
@@ -578,6 +578,8 @@ void mainWindow::saveWidgetState( QWidget * _w, QDomElement & _de )
_de.setAttribute( "x", _w->x() );
_de.setAttribute( "y", _w->y() );
_de.setAttribute( "visible", _w->isVisible() );
_de.setAttribute( "minimized", _w->isMinimized() );
_de.setAttribute( "maximized", _w->isMaximized() );
_de.setAttribute( "width", _w->width() );
_de.setAttribute( "height", _w->height() );
@@ -592,7 +594,7 @@ void mainWindow::restoreWidgetState( QWidget * _w, const QDomElement & _de )
tMax( 0, _de.attribute( "y" ).toInt() ),
tMax( 100, _de.attribute( "width" ).toInt() ),
tMax( 100, _de.attribute( "height" ).toInt() ) );
if( !r.isNull())
if( !r.isNull() )
{
if ( _w->parentWidget() != NULL &&
_w->parentWidget()->inherits( "QMdiSubWindow" ) )
@@ -603,6 +605,12 @@ void mainWindow::restoreWidgetState( QWidget * _w, const QDomElement & _de )
_w->resize( r.size() );
_w->move( r.topLeft() );
_w->setVisible( _de.attribute( "visible" ).toInt() );
_w->setWindowState( _de.attribute( "minimized" ).toInt() ?
( _w->windowState() | Qt::WindowMinimized ) :
( _w->windowState() & ~Qt::WindowMinimized ) );
_w->setWindowState( _de.attribute( "maximized" ).toInt() ?
( _w->windowState() | Qt::WindowMaximized ) :
( _w->windowState() & ~Qt::WindowMaximized ) );
}
}
@@ -909,6 +917,14 @@ void mainWindow::keyReleaseEvent( QKeyEvent * _ke )
void mainWindow::timerEvent( QTimerEvent * )
{
emit periodicUpdate();
}
void mainWindow::fillTemplatesMenu( void )
{
m_templatesMenu->clear();

View File

@@ -24,6 +24,7 @@
#include <QtGui/QApplication>
#include <QtGui/QLayout>
#include <QtGui/QMdiArea>
#include <QtGui/QProgressDialog>
#include <QtGui/QScrollBar>
@@ -33,9 +34,8 @@
#include "track_container_view.h"
#include "track_container.h"
#include "bb_track.h"
#include "config_mgr.h"
#include "main_window.h"
#include "debug.h"
#include "engine.h"
#include "file_browser.h"
#include "import_filter.h"
#include "instrument.h"
@@ -51,6 +51,8 @@
trackContainerView::trackContainerView( trackContainer * _tc ) :
QWidget(),
modelView( NULL, this ),
journallingObject(),
serializingObjectHook(),
m_currentPosition( 0, 0 ),
m_tc( _tc ),
m_trackViews(),
@@ -59,6 +61,8 @@ trackContainerView::trackContainerView( trackContainer * _tc ) :
m_rubberBand( new rubberBand( m_scrollArea ) ),
m_origin()
{
m_tc->setHook( this );
QVBoxLayout * layout = new QVBoxLayout( this );
layout->setMargin( 0 );
layout->setSpacing( 0 );
@@ -99,6 +103,23 @@ trackContainerView::~trackContainerView()
void trackContainerView::saveSettings( QDomDocument & _doc,
QDomElement & _this )
{
mainWindow::saveWidgetState( this, _this );
}
void trackContainerView::loadSettings( const QDomElement & _this )
{
mainWindow::restoreWidgetState( this, _this );
}
trackView * trackContainerView::addTrackView( trackView * _tv )
{
QMap<QString, QVariant> map;

View File

@@ -43,8 +43,7 @@
controllerRackView::controllerRackView( ) :
QWidget(),
modelView( NULL, this )
QWidget()
{
setFixedSize( 250, 250 );
setWindowIcon( embed::getIconPixmap( "controller" ) );
@@ -70,8 +69,6 @@ controllerRackView::controllerRackView( ) :
m_lastY = 0;
setModel( engine::getSong() );
QMdiSubWindow * subWin =
engine::getMainWindow()->workspace()->addSubWindow( this );
Qt::WindowFlags flags = subWin->windowFlags();
@@ -90,64 +87,29 @@ controllerRackView::controllerRackView( ) :
controllerRackView::~controllerRackView()
{
clear();
// delete scroll-area with all children
delete m_scrollArea;
}
void controllerRackView::clear( void )
void controllerRackView::saveSettings( QDomDocument & _doc,
QDomElement & _this )
{
/* for( QVector<effectView *>::iterator it = m_controllerViews.begin();
it != m_controllerViews.end(); ++it )
{
delete *it;
}
m_controllerViews.clear();*/
mainWindow::saveWidgetState( this, _this );
}
/*
void controllerRackView::moveUp( controllerView * _view )
void controllerRackView::loadSettings( const QDomElement & _this )
{
fxChain()->moveUp( _view->getEffect() );
if( _view != m_effectViews.first() )
{
int i = 0;
for( QVector<controllerView *>::iterator it =
m_effectViews.begin();
it != m_effectViews.end(); it++, i++ )
{
if( *it == _view )
{
break;
}
}
effectView * temp = m_effectViews[ i - 1 ];
m_effectViews[i - 1] = _view;
m_effectViews[i] = temp;
update();
}
}*/
mainWindow::restoreWidgetState( this, _this );
}
/*
void controllerRackView::moveDown( effectView * _view )
{
if( _view != m_effectViews.last() )
{
// moving next effect up is the same
moveUp( *( qFind( m_effectViews.begin(), m_effectViews.end(),
_view ) + 1 ) );
}
}*/
void controllerRackView::deleteController( controllerView * _view )
{
@@ -162,6 +124,7 @@ void controllerRackView::deleteController( controllerView * _view )
void controllerRackView::update( void )
{
QWidget * w = m_scrollArea->widget();
@@ -173,7 +136,7 @@ void controllerRackView::update( void )
int i = 0;
for( i = 0; i < m_controllerViews.size(); ++i )
{
delete m_controllerViews[i];
delete m_controllerViews[i];
}
m_controllerViews.clear();
@@ -193,57 +156,6 @@ void controllerRackView::update( void )
w->setFixedSize( 210, i*32 );
/*
for( QVector<effect *>::iterator it = fxChain()->m_effects.begin();
it != fxChain()->m_effects.end(); ++it )
{
int i = 0;
for( QVector<effectView *>::iterator vit =
m_effectViews.begin();
vit != m_effectViews.end(); ++vit, ++i )
{
if( ( *vit )->getEffect() == *it )
{
view_map[i] = TRUE;
break;
}
}
if( i >= m_effectViews.size() )
{
effectView * view = new effectView( *it, w );
connect( view, SIGNAL( moveUp( effectView * ) ),
this, SLOT( moveUp( effectView * ) ) );
connect( view, SIGNAL( moveDown( effectView * ) ),
this, SLOT( moveDown( effectView * ) ) );
connect( view, SIGNAL( deletePlugin( effectView * ) ),
this, SLOT( deletePlugin( effectView * ) ) );
view->show();
m_effectViews.append( view );
view_map[i] = TRUE;
}
}
int i = m_lastY = 0;
for( QVector<effectView *>::iterator it = m_effectViews.begin();
it != m_effectViews.end(); )
{
if( i < view_map.size() && i < m_effectViews.size() &&
view_map[i] == FALSE )
{
delete m_effectViews[i];
m_effectViews.erase( it );
}
else
{
( *it )->move( 0, m_lastY );
m_lastY += ( *it )->height();
++it;
++i;
}
}
w->setFixedSize( 210, m_lastY );
*/
setUpdatesEnabled( true );
QWidget::update();
}
@@ -267,16 +179,6 @@ void controllerRackView::addController( void )
}
/*
void effectRackView::modelChanged( void )
{
clear();
m_effectsGroupBox->setModel( &fxChain()->m_enabledModel );
update();
}
*/
#include "moc_controller_rack_view.cxx"

View File

@@ -681,10 +681,6 @@ void instrumentTrack::saveTrackSpecificSettings( QDomDocument & _doc,
m_arpeggiator.saveState( _doc, _this );
m_midiPort.saveState( _doc, _this );
m_audioPort.getEffects()->saveState( _doc, _this );
if( getHook() )
{
getHook()->saveSettings( _doc, _this );
}
}
@@ -792,11 +788,6 @@ void instrumentTrack::loadTrackSpecificSettings( const QDomElement & _this )
node = node.nextSibling();
}
engine::getMixer()->unlock();
if( getHook() )
{
getHook()->loadSettings( _this );
}
}
@@ -959,6 +950,7 @@ void instrumentTrackView::freeInstrumentTrackWindow( void )
{
if( s_windows.count() < INSTRUMENT_WINDOW_CACHE_SIZE )
{
model()->setHook( NULL );
m_window->parentWidget()->hide();
m_window->setModel(
engine::getDummyTrackContainer()->
@@ -1001,6 +993,7 @@ instrumentTrackWindow * instrumentTrackView::getInstrumentTrackWindow( void )
m_window->setInstrumentTrackView( this );
m_window->setModel( model() );
m_window->updateInstrumentView();
model()->setHook( m_window );
}
else
{