Progress bar will now actually show progress.

--HG--
branch : gsoc2014-dfighter
This commit is contained in:
dfighter1985 2014-06-07 17:23:06 +02:00
parent f177a49a9e
commit f0a312a6e5
6 changed files with 72 additions and 0 deletions

View file

@ -134,9 +134,15 @@ Q_SIGNALS:
/// Signal that the list of available plugins has changed. /// Signal that the list of available plugins has changed.
void pluginsChanged(); void pluginsChanged();
void pluginCount( int count );
void pluginLoading( const char *plugin ); void pluginLoading( const char *plugin );
void pluginInitializing( const char *plugin ); void pluginInitializing( const char *plugin );
void pluginStarting( const char *plugin ); void pluginStarting( const char *plugin );
void pluginsLoaded();
void pluginsInitialized();
void pluginsStarted();
}; };
}; // namespace ExtensionSystem }; // namespace ExtensionSystem

View file

@ -92,18 +92,25 @@ void PluginManager::loadPlugins()
setPluginState(spec, State::Resolved); setPluginState(spec, State::Resolved);
QList<PluginSpec *> queue = loadQueue(); QList<PluginSpec *> queue = loadQueue();
Q_EMIT pluginCount( queue.count() );
Q_FOREACH (PluginSpec *spec, queue) Q_FOREACH (PluginSpec *spec, queue)
setPluginState(spec, State::Loaded); setPluginState(spec, State::Loaded);
Q_EMIT pluginsLoaded();
Q_FOREACH (PluginSpec *spec, queue) Q_FOREACH (PluginSpec *spec, queue)
setPluginState(spec, State::Initialized); setPluginState(spec, State::Initialized);
Q_EMIT pluginsInitialized();
QListIterator<PluginSpec *> it(queue); QListIterator<PluginSpec *> it(queue);
it.toBack(); it.toBack();
while (it.hasPrevious()) while (it.hasPrevious())
setPluginState(it.previous(), State::Running); setPluginState(it.previous(), State::Running);
Q_EMIT pluginsStarted();
Q_EMIT pluginsChanged(); Q_EMIT pluginsChanged();
} }

View file

@ -19,11 +19,25 @@
#include "extension_system\iplugin_manager.h" #include "extension_system\iplugin_manager.h"
#include "splash_screen.h" #include "splash_screen.h"
namespace
{
enum Progress
{
PLUGINS_LOADED = 10,
PLUGINS_INITIALIZED = 90,
PLUGINS_STARTED = 100
};
}
void PluginManagerWatcher::connect() void PluginManagerWatcher::connect()
{ {
QObject::connect( pm, SIGNAL( pluginLoading( const char * ) ), this, SLOT( onPluginLoading( const char * ) ) ); QObject::connect( pm, SIGNAL( pluginLoading( const char * ) ), this, SLOT( onPluginLoading( const char * ) ) );
QObject::connect( pm, SIGNAL( pluginInitializing( const char * ) ), this, SLOT( onPluginInitializing( const char * ) ) ); QObject::connect( pm, SIGNAL( pluginInitializing( const char * ) ), this, SLOT( onPluginInitializing( const char * ) ) );
QObject::connect( pm, SIGNAL( pluginStarting( const char * ) ), this, SLOT( onPluginStarting( const char * ) ) ); QObject::connect( pm, SIGNAL( pluginStarting( const char * ) ), this, SLOT( onPluginStarting( const char * ) ) );
QObject::connect( pm, SIGNAL( pluginsLoaded() ), this, SLOT( onPluginsLoaded() ) );
QObject::connect( pm, SIGNAL( pluginsInitialized() ), this, SLOT( onPluginsInitialized() ) );
QObject::connect( pm, SIGNAL( pluginsStarted() ), this, SLOT( onPluginsStarted() ) );
QObject::connect( pm, SIGNAL( pluginCount( int ) ), this, SLOT( onPluginCount( int ) ) );
} }
void PluginManagerWatcher::disconnect() void PluginManagerWatcher::disconnect()
@ -31,6 +45,10 @@ void PluginManagerWatcher::disconnect()
QObject::disconnect( pm, SIGNAL( pluginLoading( const char * ) ), this, SLOT( onPluginLoading( const char * ) ) ); QObject::disconnect( pm, SIGNAL( pluginLoading( const char * ) ), this, SLOT( onPluginLoading( const char * ) ) );
QObject::disconnect( pm, SIGNAL( pluginInitializing( const char * ) ), this, SLOT( onPluginInitializing( const char * ) ) ); QObject::disconnect( pm, SIGNAL( pluginInitializing( const char * ) ), this, SLOT( onPluginInitializing( const char * ) ) );
QObject::disconnect( pm, SIGNAL( pluginStarting( const char * ) ), this, SLOT( onPluginStarting( const char * ) ) ); QObject::disconnect( pm, SIGNAL( pluginStarting( const char * ) ), this, SLOT( onPluginStarting( const char * ) ) );
QObject::disconnect( pm, SIGNAL( pluginsLoaded() ), this, SLOT( onPluginsLoaded() ) );
QObject::disconnect( pm, SIGNAL( pluginsInitialized() ), this, SLOT( onPluginsInitialized() ) );
QObject::disconnect( pm, SIGNAL( pluginsStarted() ), this, SLOT( onPluginsStarted() ) );
QObject::disconnect( pm, SIGNAL( pluginCount( int ) ), this, SLOT( onPluginCount( int ) ) );
} }
void PluginManagerWatcher::onPluginLoading( const char *plugin ) void PluginManagerWatcher::onPluginLoading( const char *plugin )
@ -39,6 +57,8 @@ void PluginManagerWatcher::onPluginLoading( const char *plugin )
s += plugin; s += plugin;
s += "..."; s += "...";
sp->setText( s ); sp->setText( s );
sp->advanceProgress( PLUGINS_LOADED / pluginCount );
} }
void PluginManagerWatcher::onPluginInitializing( const char *plugin ) void PluginManagerWatcher::onPluginInitializing( const char *plugin )
@ -47,6 +67,8 @@ void PluginManagerWatcher::onPluginInitializing( const char *plugin )
s += plugin; s += plugin;
s += "..."; s += "...";
sp->setText( s ); sp->setText( s );
sp->advanceProgress( ( PLUGINS_INITIALIZED - PLUGINS_LOADED ) / pluginCount );
} }
void PluginManagerWatcher::onPluginStarting( const char *plugin ) void PluginManagerWatcher::onPluginStarting( const char *plugin )
@ -55,7 +77,27 @@ void PluginManagerWatcher::onPluginStarting( const char *plugin )
s += plugin; s += plugin;
s += "..."; s += "...";
sp->setText( s ); sp->setText( s );
sp->advanceProgress( ( PLUGINS_STARTED - PLUGINS_INITIALIZED ) / pluginCount );
} }
void PluginManagerWatcher::onPluginsLoaded()
{
sp->setProgress( PLUGINS_LOADED );
}
void PluginManagerWatcher::onPluginsInitialized()
{
sp->setProgress( PLUGINS_INITIALIZED );
}
void PluginManagerWatcher::onPluginsStarted()
{
sp->setProgress( PLUGINS_STARTED );
}
void PluginManagerWatcher::onPluginCount( int count )
{
pluginCount = count;
}

View file

@ -32,9 +32,11 @@ class PluginManagerWatcher : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
PluginManagerWatcher(){ PluginManagerWatcher(){
sp = NULL; sp = NULL;
pm = NULL; pm = NULL;
pluginCount = 0;
} }
~PluginManagerWatcher(){ ~PluginManagerWatcher(){
@ -53,9 +55,16 @@ private Q_SLOTS:
void onPluginInitializing( const char *plugin ); void onPluginInitializing( const char *plugin );
void onPluginStarting( const char *plugin ); void onPluginStarting( const char *plugin );
void onPluginsLoaded();
void onPluginsInitialized();
void onPluginsStarted();
void onPluginCount( int count );
private: private:
SplashScreen *sp; SplashScreen *sp;
ExtensionSystem::IPluginManager *pm; ExtensionSystem::IPluginManager *pm;
int pluginCount;
}; };

View file

@ -71,6 +71,13 @@ void SplashScreen::setProgress( int percent )
QCoreApplication::instance()->processEvents(); QCoreApplication::instance()->processEvents();
} }
void SplashScreen::advanceProgress( int percent )
{
progress += percent;
repaint();
QCoreApplication::instance()->processEvents();
}
void SplashScreen::drawContents( QPainter *painter ) void SplashScreen::drawContents( QPainter *painter )
{ {
QSplashScreen::drawContents( painter ); QSplashScreen::drawContents( painter );

View file

@ -34,6 +34,7 @@ public:
void clearText(); void clearText();
void setTextXY( int x, int y ){ textX = x; textY = y; } void setTextXY( int x, int y ){ textX = x; textY = y; }
void setProgress( int percent ); void setProgress( int percent );
void advanceProgress( int percent );
void setProgressBarEnabled( bool b ){ progressBarEnabled = b; } void setProgressBarEnabled( bool b ){ progressBarEnabled = b; }
void setProgressBarRect( int left, int top, int width, int height ){} void setProgressBarRect( int left, int top, int width, int height ){}