mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-05 23:09:02 +00:00
Progress bar will now actually show progress.
This commit is contained in:
parent
bfa4cec7e6
commit
6938777725
6 changed files with 72 additions and 0 deletions
|
@ -134,9 +134,15 @@ Q_SIGNALS:
|
|||
/// Signal that the list of available plugins has changed.
|
||||
void pluginsChanged();
|
||||
|
||||
void pluginCount( int count );
|
||||
|
||||
void pluginLoading( const char *plugin );
|
||||
void pluginInitializing( const char *plugin );
|
||||
void pluginStarting( const char *plugin );
|
||||
|
||||
void pluginsLoaded();
|
||||
void pluginsInitialized();
|
||||
void pluginsStarted();
|
||||
};
|
||||
|
||||
}; // namespace ExtensionSystem
|
||||
|
|
|
@ -92,17 +92,24 @@ void PluginManager::loadPlugins()
|
|||
setPluginState(spec, State::Resolved);
|
||||
|
||||
QList<PluginSpec *> queue = loadQueue();
|
||||
Q_EMIT pluginCount( queue.count() );
|
||||
|
||||
Q_FOREACH (PluginSpec *spec, queue)
|
||||
setPluginState(spec, State::Loaded);
|
||||
|
||||
Q_EMIT pluginsLoaded();
|
||||
|
||||
Q_FOREACH (PluginSpec *spec, queue)
|
||||
setPluginState(spec, State::Initialized);
|
||||
|
||||
Q_EMIT pluginsInitialized();
|
||||
|
||||
QListIterator<PluginSpec *> it(queue);
|
||||
it.toBack();
|
||||
while (it.hasPrevious())
|
||||
setPluginState(it.previous(), State::Running);
|
||||
|
||||
Q_EMIT pluginsStarted();
|
||||
|
||||
Q_EMIT pluginsChanged();
|
||||
}
|
||||
|
|
|
@ -19,11 +19,25 @@
|
|||
#include "extension_system\iplugin_manager.h"
|
||||
#include "splash_screen.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
enum Progress
|
||||
{
|
||||
PLUGINS_LOADED = 10,
|
||||
PLUGINS_INITIALIZED = 90,
|
||||
PLUGINS_STARTED = 100
|
||||
};
|
||||
}
|
||||
|
||||
void PluginManagerWatcher::connect()
|
||||
{
|
||||
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( 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()
|
||||
|
@ -31,6 +45,10 @@ void PluginManagerWatcher::disconnect()
|
|||
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( 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 )
|
||||
|
@ -39,6 +57,8 @@ void PluginManagerWatcher::onPluginLoading( const char *plugin )
|
|||
s += plugin;
|
||||
s += "...";
|
||||
sp->setText( s );
|
||||
|
||||
sp->advanceProgress( PLUGINS_LOADED / pluginCount );
|
||||
}
|
||||
|
||||
void PluginManagerWatcher::onPluginInitializing( const char *plugin )
|
||||
|
@ -47,6 +67,8 @@ void PluginManagerWatcher::onPluginInitializing( const char *plugin )
|
|||
s += plugin;
|
||||
s += "...";
|
||||
sp->setText( s );
|
||||
|
||||
sp->advanceProgress( ( PLUGINS_INITIALIZED - PLUGINS_LOADED ) / pluginCount );
|
||||
}
|
||||
|
||||
void PluginManagerWatcher::onPluginStarting( const char *plugin )
|
||||
|
@ -55,7 +77,27 @@ void PluginManagerWatcher::onPluginStarting( const char *plugin )
|
|||
s += plugin;
|
||||
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;
|
||||
}
|
|
@ -32,9 +32,11 @@ class PluginManagerWatcher : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
PluginManagerWatcher(){
|
||||
sp = NULL;
|
||||
pm = NULL;
|
||||
pluginCount = 0;
|
||||
}
|
||||
|
||||
~PluginManagerWatcher(){
|
||||
|
@ -53,9 +55,16 @@ private Q_SLOTS:
|
|||
void onPluginInitializing( const char *plugin );
|
||||
void onPluginStarting( const char *plugin );
|
||||
|
||||
void onPluginsLoaded();
|
||||
void onPluginsInitialized();
|
||||
void onPluginsStarted();
|
||||
|
||||
void onPluginCount( int count );
|
||||
|
||||
private:
|
||||
SplashScreen *sp;
|
||||
ExtensionSystem::IPluginManager *pm;
|
||||
int pluginCount;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -71,6 +71,13 @@ void SplashScreen::setProgress( int percent )
|
|||
QCoreApplication::instance()->processEvents();
|
||||
}
|
||||
|
||||
void SplashScreen::advanceProgress( int percent )
|
||||
{
|
||||
progress += percent;
|
||||
repaint();
|
||||
QCoreApplication::instance()->processEvents();
|
||||
}
|
||||
|
||||
void SplashScreen::drawContents( QPainter *painter )
|
||||
{
|
||||
QSplashScreen::drawContents( painter );
|
||||
|
|
|
@ -34,6 +34,7 @@ public:
|
|||
void clearText();
|
||||
void setTextXY( int x, int y ){ textX = x; textY = y; }
|
||||
void setProgress( int percent );
|
||||
void advanceProgress( int percent );
|
||||
|
||||
void setProgressBarEnabled( bool b ){ progressBarEnabled = b; }
|
||||
void setProgressBarRect( int left, int top, int width, int height ){}
|
||||
|
|
Loading…
Reference in a new issue