Skip to content

Commit

Permalink
Provide status messages on splash screen when loading (LMMS#1696)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wallacoloo committed Apr 2, 2015
1 parent 77c6f5a commit c4900c7
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 2 deletions.
21 changes: 20 additions & 1 deletion include/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
#define ENGINE_H

#include <QtCore/QMap>
#include <QtCore/QString>
#include <QtCore/QObject>


#include "export.h"

Expand All @@ -39,8 +42,9 @@ class Song;
class Ladspa2LMMS;


class EXPORT Engine
class EXPORT Engine : public QObject
{
Q_OBJECT
public:
static void init();
static void destroy();
Expand Down Expand Up @@ -94,6 +98,18 @@ class EXPORT Engine
return s_pluginFileHandling;
}

static inline Engine * inst()
{
if( s_instanceOfMe == NULL )
{
s_instanceOfMe = new Engine();
}
return s_instanceOfMe;
}

signals:
void initProgress(const QString &msg);


private:
// small helper function which sets the pointer to NULL before actually deleting
Expand All @@ -120,6 +136,9 @@ class EXPORT Engine

static QMap<QString, QString> s_pluginFileHandling;

// even though most methods are static, an instance is needed for Qt slots/signals
static Engine * s_instanceOfMe;

static void initPluginFileHandling();

friend class GuiApplication;
Expand Down
11 changes: 10 additions & 1 deletion include/GuiApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@
#ifndef GUIAPPLICATION_H
#define GUIAPPLICATION_H

#include <QtCore/QObject>

#include "export.h"

class QSplashScreen;

class AutomationEditorWindow;
class BBEditor;
class ControllerRackView;
Expand All @@ -36,8 +40,9 @@ class PianoRollWindow;
class ProjectNotes;
class SongEditorWindow;

class EXPORT GuiApplication
class EXPORT GuiApplication : public QObject
{
Q_OBJECT;
public:
explicit GuiApplication();
~GuiApplication();
Expand All @@ -53,6 +58,9 @@ class EXPORT GuiApplication
AutomationEditorWindow* automationEditor() { return m_automationEditor; }
ControllerRackView* getControllerRackView() { return m_controllerRackView; }

public slots:
void displayInitProgress(const QString &msg);

private:
static GuiApplication* s_instance;

Expand All @@ -64,6 +72,7 @@ class EXPORT GuiApplication
PianoRollWindow* m_pianoRoll;
ProjectNotes* m_projectNotes;
ControllerRackView* m_controllerRackView;
QSplashScreen* m_splashScreen;
};

#define gui GuiApplication::instance()
Expand Down
8 changes: 8 additions & 0 deletions src/core/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,16 @@ QMap<QString, QString> Engine::s_pluginFileHandling;

void Engine::init()
{
Engine *engine = inst();

emit engine->initProgress(tr("Generating wavetables"));
// generate (load from file) bandlimited wavetables
BandLimitedWave::generateWaves();

emit engine->initProgress(tr("Locating plugins"));
initPluginFileHandling();

emit engine->initProgress(tr("Initializing data structures"));
s_projectJournal = new ProjectJournal;
s_mixer = new Mixer;
s_song = new Song;
Expand All @@ -67,11 +72,13 @@ void Engine::init()

s_projectJournal->setJournalling( true );

emit engine->initProgress(tr("Opening audio and midi devices"));
s_mixer->initDevices();

PresetPreviewPlayHandle::init();
s_dummyTC = new DummyTrackContainer;

emit engine->initProgress(tr("Launching mixer threads"));
s_mixer->startProcessing();
}

Expand Down Expand Up @@ -142,3 +149,4 @@ void Engine::initPluginFileHandling()
}


Engine * Engine::s_instanceOfMe = NULL;
18 changes: 18 additions & 0 deletions src/gui/GuiApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ GuiApplication* GuiApplication::instance()
return s_instance;
}


GuiApplication::GuiApplication()
{
// Init style and palette
Expand All @@ -63,16 +64,22 @@ GuiApplication::GuiApplication()

// Show splash screen
QSplashScreen splashScreen( embed::getIconPixmap( "splash" ) );
m_splashScreen = &splashScreen;
splashScreen.show();
splashScreen.showMessage( MainWindow::tr( "Version %1" ).arg( LMMS_VERSION ),
Qt::AlignRight | Qt::AlignBottom, Qt::white );
qApp->processEvents();

connect(Engine::inst(), SIGNAL(initProgress(const QString&)),
this, SLOT(displayInitProgress(const QString&)));

// Init central engine which handles all components of LMMS
Engine::init();

s_instance = this;

displayInitProgress("Preparing UI");

m_mainWindow = new MainWindow;

m_songEditor = new SongEditorWindow(Engine::getSong());
Expand All @@ -85,10 +92,21 @@ GuiApplication::GuiApplication()

m_mainWindow->finalize();
splashScreen.finish(m_mainWindow);

m_splashScreen = nullptr;
}

GuiApplication::~GuiApplication()
{
InstrumentTrackView::cleanupWindowCache();
s_instance = nullptr;
}


void GuiApplication::displayInitProgress(const QString &msg)
{
if (m_splashScreen != nullptr)
{
m_splashScreen->showMessage(msg, Qt::AlignLeft | Qt::AlignBottom, Qt::white);
}
}

0 comments on commit c4900c7

Please sign in to comment.