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:
26
ChangeLog
26
ChangeLog
@@ -1,5 +1,31 @@
|
||||
2008-09-07 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
|
||||
|
||||
* include/controller_rack_view.h:
|
||||
* include/fx_mixer_view.h:
|
||||
* include/main_window.h:
|
||||
* include/piano_roll.h:
|
||||
* include/project_notes.h:
|
||||
* include/track_container.h:
|
||||
* include/track_container_view.h:
|
||||
* src/core/song.cpp:
|
||||
* src/core/track_container.cpp:
|
||||
* src/gui/fx_mixer_view.cpp:
|
||||
* src/gui/main_window.cpp:
|
||||
* src/gui/track_container_view.cpp:
|
||||
* src/gui/widgets/controller_rack_view.cpp:
|
||||
* src/tracks/instrument_track.cpp:
|
||||
properly save and restore position, size, visibility and state of
|
||||
MDI-subwindows
|
||||
|
||||
* src/core/serializing_object.cpp:
|
||||
fixed hook-mechanism
|
||||
|
||||
* include/song_editor.h:
|
||||
* src/gui/song_editor.cpp:
|
||||
* src/gui/fx_mixer_view.cpp:
|
||||
* src/gui/widgets/visualization_widget.cpp:
|
||||
moved peridic update-timer from songEditor to mainWindow
|
||||
|
||||
* data/projects/cool_songs/Chris-HorizonRemix.mmp:
|
||||
added song
|
||||
|
||||
|
||||
@@ -27,25 +27,31 @@
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
#include "serializing_object.h"
|
||||
#include "types.h"
|
||||
|
||||
#include "mv_base.h"
|
||||
|
||||
class QPushButton;
|
||||
class QScrollArea;
|
||||
class QVBoxLayout;
|
||||
//class QVBoxLayout;
|
||||
|
||||
class controllerView;
|
||||
|
||||
|
||||
class controllerRackView : public QWidget, public modelView
|
||||
class controllerRackView : public QWidget, public serializingObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
controllerRackView();
|
||||
virtual ~controllerRackView();
|
||||
|
||||
void clear( void );
|
||||
virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );
|
||||
virtual void loadSettings( const QDomElement & _this );
|
||||
|
||||
inline virtual QString nodeName( void ) const
|
||||
{
|
||||
return( "controllerrackview" );
|
||||
}
|
||||
|
||||
|
||||
public slots:
|
||||
@@ -56,24 +62,11 @@ private slots:
|
||||
virtual void update( void );
|
||||
void addController( void );
|
||||
|
||||
|
||||
private:
|
||||
/*virtual void modelChanged( void );
|
||||
|
||||
inline effectChain * fxChain( void )
|
||||
{
|
||||
return( castModel<effectChain>() );
|
||||
}
|
||||
|
||||
inline const effectChain * fxChain( void ) const
|
||||
{
|
||||
return( castModel<effectChain>() );
|
||||
}
|
||||
*/
|
||||
|
||||
QVector<controllerView *> m_controllerViews;
|
||||
|
||||
QVBoxLayout * m_mainLayout;
|
||||
//groupBox * m_effectsGroupBox;
|
||||
QScrollArea * m_scrollArea;
|
||||
QPushButton * m_addButton;
|
||||
|
||||
|
||||
@@ -40,13 +40,17 @@ class pixmapButton;
|
||||
|
||||
|
||||
|
||||
class fxMixerView : public QWidget, public modelView
|
||||
class fxMixerView : public QWidget, public modelView,
|
||||
public serializingObjectHook
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
fxMixerView();
|
||||
virtual ~fxMixerView();
|
||||
|
||||
virtual void saveSettings( QDomDocument & _doc, QDomElement & _this );
|
||||
virtual void loadSettings( const QDomElement & _this );
|
||||
|
||||
fxLine * currentFxLine( void )
|
||||
{
|
||||
return( m_currentFxLine );
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#ifndef _MAIN_WINDOW_H
|
||||
#define _MAIN_WINDOW_H
|
||||
|
||||
#include <QtCore/QBasicTimer>
|
||||
#include <QtCore/QList>
|
||||
#include <QtGui/QMainWindow>
|
||||
#include <QtGui/QWhatsThis>
|
||||
@@ -120,6 +121,7 @@ protected:
|
||||
virtual void focusOutEvent( QFocusEvent * _fe );
|
||||
virtual void keyPressEvent( QKeyEvent * _ke );
|
||||
virtual void keyReleaseEvent( QKeyEvent * _ke );
|
||||
virtual void timerEvent( QTimerEvent * _ev );
|
||||
|
||||
|
||||
private:
|
||||
@@ -157,6 +159,8 @@ private:
|
||||
QMenu * m_toolsMenu;
|
||||
QList<pluginView *> m_tools;
|
||||
|
||||
QBasicTimer m_updateTimer;
|
||||
|
||||
|
||||
friend class engine;
|
||||
|
||||
@@ -168,6 +172,10 @@ private slots:
|
||||
void showTool( QAction * _idx );
|
||||
void updateRecentlyOpenedProjectsMenu( void );
|
||||
|
||||
|
||||
signals:
|
||||
void periodicUpdate( void );
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
#include "combobox_model.h"
|
||||
#include "journalling_object.h"
|
||||
#include "serializing_object.h"
|
||||
#include "note.h"
|
||||
#include "types.h"
|
||||
|
||||
@@ -46,7 +46,7 @@ class timeLine;
|
||||
class toolButton;
|
||||
|
||||
|
||||
class pianoRoll : public QWidget, public journallingObject
|
||||
class pianoRoll : public QWidget, public serializingObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -72,6 +72,7 @@ public:
|
||||
|
||||
virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );
|
||||
virtual void loadSettings( const QDomElement & _this );
|
||||
|
||||
inline virtual QString nodeName( void ) const
|
||||
{
|
||||
return( "pianoroll" );
|
||||
|
||||
@@ -37,7 +37,7 @@ class QTextCharFormat;
|
||||
class QTextEdit;
|
||||
|
||||
|
||||
class EXPORT projectNotes : public QMainWindow, public journallingObject
|
||||
class EXPORT projectNotes : public QMainWindow, public serializingObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -49,6 +49,7 @@ public:
|
||||
|
||||
virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );
|
||||
virtual void loadSettings( const QDomElement & _this );
|
||||
|
||||
inline virtual QString nodeName( void ) const
|
||||
{
|
||||
return( "projectnotes" );
|
||||
|
||||
@@ -66,13 +66,6 @@ public:
|
||||
|
||||
void clearAllTracks( void );
|
||||
|
||||
/*
|
||||
trackList & tracks( void )
|
||||
{
|
||||
return( m_tracks );
|
||||
}
|
||||
*/
|
||||
|
||||
const trackList & tracks( void ) const
|
||||
{
|
||||
return( m_tracks );
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
#ifndef _TRACK_CONTAINER_VIEW_H
|
||||
#define _TRACK_CONTAINER_VIEW_H
|
||||
|
||||
#include <QtGui/QScrollArea>
|
||||
#include <QtCore/QVector>
|
||||
#include <QtGui/QScrollArea>
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
|
||||
@@ -40,13 +40,17 @@ class trackContainer;
|
||||
|
||||
|
||||
class trackContainerView : public QWidget, public modelView,
|
||||
public journallingObject
|
||||
public journallingObject,
|
||||
public serializingObjectHook
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
trackContainerView( trackContainer * _tc );
|
||||
virtual ~trackContainerView();
|
||||
|
||||
virtual void saveSettings( QDomDocument & _doc, QDomElement & _this );
|
||||
virtual void loadSettings( const QDomElement & _this );
|
||||
|
||||
QWidget * contentWidget( void )
|
||||
{
|
||||
return( m_scrollArea );
|
||||
|
||||
@@ -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() ) )->
|
||||
|
||||
@@ -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() );
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user