added modified project indicator, fixed some segfaults

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@615 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Javier Serrano Polo
2007-11-27 05:02:50 +00:00
parent 37860380ff
commit 14253bc705
21 changed files with 371 additions and 280 deletions

View File

@@ -49,15 +49,6 @@
inline void mkPath( const QString & _path )
{
#warning TODO: directly integrate
// simple clean solution with Qt4...
QDir().mkpath( _path );
}
/*
void linkFile( const QString & _src, const QString & _dst )
{
@@ -514,7 +505,7 @@ void configManager::accept( void )
QMessageBox::Yes, QMessageBox::No )
== QMessageBox::Yes )
{
mkPath( m_workingDir );
QDir().mkpath( m_workingDir );
}
else
{
@@ -523,9 +514,9 @@ void configManager::accept( void )
}
}
mkPath( userProjectsDir() );
mkPath( userSamplesDir() );
mkPath( userPresetsDir() );
QDir().mkpath( userProjectsDir() );
QDir().mkpath( userSamplesDir() );
QDir().mkpath( userPresetsDir() );
/* processFilesRecursively( m_dataDir + "samples/", m_workingDir +
"samples/",
m_samplesCopyRB->isChecked() ?
@@ -923,7 +914,7 @@ void configManager::processFilesRecursively( const QString & _src_dir,
const QString & _dst_dir,
void( * _proc_func )( const QString & _src, const QString & _dst ) )
{
mkPath( _dst_dir );
QDir().mkpath( _dst_dir );
QStringList files = QDir( _src_dir ).entryList();
for( QStringList::iterator it = files.begin(); it != files.end(); ++it )
{

View File

@@ -72,6 +72,8 @@ void engine::init( const bool _has_gui )
s_automationEditor = new automationEditor;
s_ladspaManager = new ladspa2LMMS;
s_projectJournal->setJournalling( TRUE );
s_mixer->initDevices();
s_mainWindow->finalize();

View File

@@ -204,7 +204,7 @@ void mainWindow::finalize( void )
s_splashScreen->showMessage( tr( "Creating GUI..." ),
splash_alignment_flags,
Qt::white );
resetWindowTitle( "" );
resetWindowTitle();
setWindowIcon( embed::getIconPixmap( "icon" ) );
@@ -511,19 +511,20 @@ void mainWindow::addSpacingToToolBar( int _size )
void mainWindow::resetWindowTitle( const QString & _add )
void mainWindow::resetWindowTitle( void )
{
QString title = _add;
if( _add == "" && engine::getSongEditor()->projectFileName() != "" )
QString title = "";
if( engine::getSongEditor()->projectFileName() != "" )
{
title = QFileInfo( engine::getSongEditor()->projectFileName()
).completeBaseName();
}
if( title != "" )
if( title == "" )
{
title += " - ";
title = tr( "Untitled" );
}
setWindowTitle( title + tr( "LMMS %1" ).arg( VERSION ) );
setWindowTitle( title + "[*] - " + tr( "LMMS %1" ).arg( VERSION ) );
setWindowModified( FALSE );
}
@@ -566,9 +567,7 @@ void mainWindow::restoreWidgetState( QWidget * _w, const QDomElement & _de )
_de.attribute( "height" ).toInt() );
if( !r.isNull())
{
_w->show();
if (_w->parentWidget() != NULL &&
if ( _w->parentWidget() != NULL &&
_w->parentWidget()->inherits( "QMdiSubWindow" ) )
{
_w = _w->parentWidget();
@@ -576,7 +575,7 @@ void mainWindow::restoreWidgetState( QWidget * _w, const QDomElement & _de )
_w->resize( r.size() );
_w->move( r.topLeft() );
_w->setShown( _de.attribute( "visible" ).toInt() );
_w->setVisible( _de.attribute( "visible" ).toInt() );
}
}

View File

@@ -25,6 +25,9 @@
*/
#include "song_editor.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -32,7 +35,6 @@
#include <math.h>
#include <Qt/QtXml>
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
#include <QtGui/QAction>
@@ -41,41 +43,40 @@
#include <QtGui/QKeyEvent>
#include <QtGui/QLabel>
#include <QtGui/QLayout>
#include <QtGui/QMdiArea>
#include <QtGui/QMessageBox>
#include <QtGui/QScrollBar>
#include <QtGui/QStatusBar>
#include <QtGui/QMdiArea>
#include "song_editor.h"
#include "automatable_object_templates.h"
#include "automatable_slider.h"
#include "bb_editor.h"
#include "rename_dialog.h"
#include "embed.h"
#include "templates.h"
#include "export_project_dialog.h"
#include "bb_track.h"
#include "combobox.h"
#include "config_mgr.h"
#include "cpuload_widget.h"
#include "embed.h"
#include "envelope_and_lfo_widget.h"
#include "export_project_dialog.h"
#include "import_filter.h"
#include "instrument_track.h"
#include "mmp.h"
#include "lcd_spinbox.h"
#include "main_window.h"
#include "midi_client.h"
#include "mmp.h"
#include "note_play_handle.h"
#include "timeline.h"
#include "pattern.h"
#include "piano_roll.h"
#include "envelope_and_lfo_widget.h"
#include "visualization_widget.h"
#include "project_notes.h"
#include "config_mgr.h"
#include "lcd_spinbox.h"
#include "tooltip.h"
#include "tool_button.h"
#include "cpuload_widget.h"
#include "text_float.h"
#include "combobox.h"
#include "main_window.h"
#include "import_filter.h"
#include "project_journal.h"
#include "project_notes.h"
#include "rename_dialog.h"
#include "templates.h"
#include "text_float.h"
#include "timeline.h"
#include "tool_button.h"
#include "tooltip.h"
#include "visualization_widget.h"
#include "debug.h"
@@ -1295,7 +1296,7 @@ automationPattern * songEditor::tempoAutomationPattern( void )
bool songEditor::mayChangeProject( void )
{
if( m_modified == FALSE )
if( engine::getMainWindow()->isWindowModified() == FALSE )
{
return( TRUE );
}
@@ -1377,10 +1378,16 @@ void songEditor::createNewProject( void )
return;
}
m_loadingProject = TRUE;
clearProject();
engine::getProjectJournal()->setJournalling( FALSE );
m_fileName = m_oldFileName = "";
engine::getMainWindow()->resetWindowTitle();
track * t;
t = track::create( track::INSTRUMENT_TRACK, this );
dynamic_cast< instrumentTrack * >( t )->loadInstrument(
@@ -1391,20 +1398,13 @@ void songEditor::createNewProject( void )
"tripleoscillator" );
track::create( track::BB_TRACK, this );
m_loadingProject = TRUE;
m_bpmSpinBox->setInitValue( DEFAULT_BPM );
m_masterVolumeSlider->setInitValue( 100 );
m_masterPitchSlider->setInitValue( 0 );
m_loadingProject = FALSE;
m_fileName = m_oldFileName = "";
m_modified = FALSE;
engine::getMainWindow()->resetWindowTitle( "" );
engine::getProjectJournal()->setJournalling( TRUE );
m_loadingProject = FALSE;
}
@@ -1425,6 +1425,8 @@ void FASTCALL songEditor::createNewProjectFromTemplate( const QString &
// load given song
void FASTCALL songEditor::loadProject( const QString & _file_name )
{
m_loadingProject = TRUE;
clearProject();
engine::getProjectJournal()->setJournalling( FALSE );
@@ -1432,8 +1434,6 @@ void FASTCALL songEditor::loadProject( const QString & _file_name )
m_fileName = _file_name;
m_oldFileName = _file_name;
m_loadingProject = TRUE;
multimediaProject mmp( m_fileName );
// if file could not be opened, head-node is null and we create
// new project
@@ -1443,6 +1443,8 @@ void FASTCALL songEditor::loadProject( const QString & _file_name )
return;
}
engine::getMainWindow()->resetWindowTitle();
// get the header information from the DOM
m_bpmSpinBox->loadSettings( mmp.head(), "bpm" );
m_masterVolumeSlider->loadSettings( mmp.head(), "mastervol" );
@@ -1490,16 +1492,13 @@ void FASTCALL songEditor::loadProject( const QString & _file_name )
node = node.nextSibling();
}
m_modified = FALSE;
m_leftRightScroll->setValue( 0 );
m_loadingProject = FALSE;
configManager::inst()->addRecentlyOpenedProject( _file_name );
engine::getMainWindow()->resetWindowTitle( "" );
engine::getProjectJournal()->setJournalling( TRUE );
m_loadingProject = FALSE;
}
@@ -1527,15 +1526,13 @@ bool songEditor::saveProject( void )
if( mmp.writeFile( m_fileName, m_oldFileName == "" ||
m_fileName != m_oldFileName ) == TRUE )
{
m_modified = FALSE;
textFloat::displayMessage( tr( "Project saved" ),
tr( "The project %1 is now saved."
).arg( m_fileName ),
embed::getIconPixmap( "project_save", 24, 24 ),
2000 );
configManager::inst()->addRecentlyOpenedProject( m_fileName );
engine::getMainWindow()->resetWindowTitle( "" );
engine::getMainWindow()->resetWindowTitle();
}
else
{
@@ -1657,6 +1654,25 @@ void songEditor::updateFramesPerTact64th( void )
void songEditor::setModified( void )
{
if( !m_loadingProject )
{
engine::getMainWindow()->setWindowModified( TRUE );
}
}
bool songEditor::allowRubberband( void ) const
{
return( m_editModeButton->isChecked() );
}
#include "song_editor.moc"

View File

@@ -113,6 +113,7 @@ void trackContainer::loadSettings( const QDomElement & _this )
pd = new QProgressDialog( tr( "Loading project..." ),
tr( "Cancel" ), 0,
_this.childNodes().count() );
pd->setWindowModality( Qt::ApplicationModal );
pd->setWindowTitle( tr( "Please wait..." ) );
pd->show();
}

View File

@@ -37,7 +37,7 @@ projectJournal::projectJournal( void ) :
m_joIDs(),
m_journalEntries(),
m_currentJournalEntry( m_journalEntries.end() ),
m_journalling( TRUE )
m_journalling( FALSE )
{
}

View File

@@ -29,7 +29,6 @@
#include "instrument_track.h"
#include <Qt/QtXml>
#include <QtCore/QDir>
#include <QtCore/QFile>
#include <QtGui/QApplication>
@@ -38,10 +37,9 @@
#include <QtGui/QLabel>
#include <QtGui/QLayout>
#include <QtGui/QLineEdit>
#include <QtGui/QMdiArea>
#include <QtGui/QMenu>
#include <QtGui/QMessageBox>
#include <QtGui/QMdiArea>
#include <QtGui/QMdiSubWindow>
#include "arp_and_chords_tab_widget.h"
@@ -98,7 +96,6 @@ const int PIANO_HEIGHT = 84;
instrumentTrack::instrumentTrack( trackContainer * _tc ) :
QMdiSubWindow( engine::getMainWindow()->workspace() ),
track( _tc ),
midiEventProcessor(),
m_trackType( INSTRUMENT_TRACK ),
@@ -112,9 +109,6 @@ instrumentTrack::instrumentTrack( trackContainer * _tc ) :
m_midiInputAction( NULL ),
m_midiOutputAction( NULL )
{
QWidget * widget = new QWidget();
for( int i = 0; i < NOTES; ++i )
{
m_notes[i] = NULL;
@@ -171,12 +165,12 @@ instrumentTrack::instrumentTrack( trackContainer * _tc ) :
// init own layout + widgets
setFocusPolicy( Qt::StrongFocus );
QVBoxLayout * vlayout = new QVBoxLayout( widget );
QVBoxLayout * vlayout = new QVBoxLayout( this );
vlayout->setMargin( 0 );
vlayout->setSpacing( 0 );
m_generalSettingsWidget = new tabWidget( tr( "GENERAL SETTINGS" ),
widget );
this );
m_generalSettingsWidget->setFixedHeight( 90 );
// setup line-edit for changing channel-name
@@ -314,38 +308,40 @@ instrumentTrack::instrumentTrack( trackContainer * _tc ) :
_tc->updateAfterTrackAdd();
setWidget( widget );
setFixedWidth( INSTRUMENT_WIDTH );
resize( sizeHint() );
if( engine::getMainWindow()->workspace() )
{
engine::getMainWindow()->workspace()->addSubWindow( this );
parentWidget()->hide();
}
else
{
hide();
}
hide();
}
instrumentTrack::~instrumentTrack()
{
engine::getMixer()->removePlayHandles( this );
delete m_effWidget;
delete m_audioPort;
engine::getMixer()->getMIDIClient()->removePort( m_midiPort );
if( engine::getMainWindow()->workspace() )
{
parentWidget()->hide();
parentWidget()->deleteLater();
}
}
void instrumentTrack::saveSettingsBtnClicked( void )
{
QFileDialog sfd( this, tr( "Save channel-settings in file" ), "",
@@ -1209,12 +1205,28 @@ void instrumentTrack::toggledInstrumentTrackButton( bool _on )
}
if( _on )
{
show();
raise();
if( engine::getMainWindow()->workspace() )
{
show();
parentWidget()->show();
parentWidget()->raise();
}
else
{
show();
raise();
}
}
else
{
hide();
if( engine::getMainWindow()->workspace() )
{
parentWidget()->hide();
}
else
{
hide();
}
}
}
@@ -1224,7 +1236,14 @@ void instrumentTrack::toggledInstrumentTrackButton( bool _on )
void instrumentTrack::closeEvent( QCloseEvent * _ce )
{
_ce->ignore();
hide();
if( engine::getMainWindow()->workspace() )
{
parentWidget()->hide();
}
else
{
hide();
}
m_tswInstrumentTrackButton->setChecked( FALSE );
}