Refactor loading song errors notification
This commit is contained in:
@@ -40,7 +40,6 @@
|
||||
|
||||
#include "GuiApplication.h"
|
||||
|
||||
bool Engine::s_hasGUI = true;
|
||||
float Engine::s_framesPerTick;
|
||||
Mixer* Engine::s_mixer = NULL;
|
||||
FxMixer * Engine::s_fxMixer = NULL;
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "ConfigManager.h"
|
||||
#include "DummyPlugin.h"
|
||||
#include "AutomatableModel.h"
|
||||
#include "MainWindow.h"
|
||||
#include "Song.h"
|
||||
|
||||
|
||||
static PixmapLoader __dummy_loader;
|
||||
@@ -128,7 +128,7 @@ Plugin * Plugin::instantiate( const QString & pluginName, Model * parent,
|
||||
|
||||
void Plugin::collectErrorForUI( QString err_msg )
|
||||
{
|
||||
gui->mainWindow()->collectError( err_msg );
|
||||
Engine::getSong()->collectError( err_msg );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
#include "Song.h"
|
||||
|
||||
#include <QTextStream>
|
||||
#include <QCoreApplication>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
@@ -90,6 +90,7 @@ Song::Song() :
|
||||
m_playing( false ),
|
||||
m_paused( false ),
|
||||
m_loadingProject( false ),
|
||||
m_errors( new QList<QString>() ),
|
||||
m_playMode( Mode_None ),
|
||||
m_length( 0 ),
|
||||
m_trackToPlay( NULL ),
|
||||
@@ -914,10 +915,6 @@ void Song::loadProject( const QString & _file_name )
|
||||
m_loadingProject = true;
|
||||
|
||||
Engine::projectJournal()->setJournalling( false );
|
||||
if( gui )
|
||||
{
|
||||
gui->mainWindow()->clearErrors();
|
||||
}
|
||||
|
||||
m_fileName = _file_name;
|
||||
m_oldFileName = _file_name;
|
||||
@@ -932,6 +929,8 @@ void Song::loadProject( const QString & _file_name )
|
||||
|
||||
clearProject();
|
||||
|
||||
clearErrors();
|
||||
|
||||
DataFile::LocaleHelper localeHelper( DataFile::LocaleHelper::ModeLoad );
|
||||
|
||||
Engine::mixer()->lock();
|
||||
@@ -1029,9 +1028,17 @@ void Song::loadProject( const QString & _file_name )
|
||||
|
||||
emit projectLoaded();
|
||||
|
||||
if( gui )
|
||||
if ( hasErrors())
|
||||
{
|
||||
gui->mainWindow()->showErrors( tr( "The following errors occured while loading: " ) );
|
||||
if ( Engine::hasGUI() )
|
||||
{
|
||||
QMessageBox::warning( NULL, "LMMS Error report", *errorSummary(),
|
||||
QMessageBox::Ok );
|
||||
}
|
||||
else
|
||||
{
|
||||
QTextStream(stderr) << *Engine::getSong()->errorSummary() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
m_loadingProject = false;
|
||||
@@ -1322,5 +1329,38 @@ void Song::removeController( Controller * _controller )
|
||||
|
||||
|
||||
|
||||
void Song::clearErrors()
|
||||
{
|
||||
m_errors->clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Song::collectError( const QString error )
|
||||
{
|
||||
m_errors->append( error );
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Song::hasErrors()
|
||||
{
|
||||
return ( m_errors->length() > 0 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
QString* Song::errorSummary()
|
||||
{
|
||||
QString* errors = new QString();
|
||||
|
||||
for ( int i = 0 ; i < m_errors->length() ; i++ )
|
||||
{
|
||||
errors->append( m_errors->value( i ) + "\n" );
|
||||
}
|
||||
|
||||
errors->prepend( "\n\n" );
|
||||
errors->prepend( tr( "The following errors occured while loading: " ) );
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
@@ -190,8 +190,6 @@ MainWindow::MainWindow() :
|
||||
vbox->addWidget( w );
|
||||
setCentralWidget( main_widget );
|
||||
|
||||
m_errors = new QList<QString>();
|
||||
|
||||
m_updateTimer.start( 1000 / 20, this ); // 20 fps
|
||||
|
||||
if( ConfigManager::inst()->value( "ui", "enableautosave" ).toInt() )
|
||||
@@ -1225,43 +1223,3 @@ void MainWindow::autoSave()
|
||||
QTimer::singleShot( 10*1000, this, SLOT( autoSave() ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MainWindow::collectErrors(const QList<QString>* errors )
|
||||
{
|
||||
m_errors->append( *errors );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MainWindow::collectError( const QString & error )
|
||||
{
|
||||
m_errors->append( error );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MainWindow::clearErrors()
|
||||
{
|
||||
m_errors->clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MainWindow::showErrors( const QString & message )
|
||||
{
|
||||
if ( m_errors->length() != 0 )
|
||||
{ QString* errors = new QString();
|
||||
for ( int i = 0 ; i < m_errors->length() ; i++ )
|
||||
{
|
||||
errors->append( m_errors->value( i ) + "\n" );
|
||||
}
|
||||
errors->prepend( "\n\n" );
|
||||
errors->prepend( message );
|
||||
QMessageBox::warning( NULL,
|
||||
"LMMS Error report",
|
||||
*errors,
|
||||
QMessageBox::Ok );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user