From 9d347a9993da7f218045f15cf3f9c7e8d1289455 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 5 Jun 2014 01:57:13 +0200 Subject: [PATCH] The splash screen will now inform the user about what's happening. --- code/studio/src/CMakeLists.txt | 3 +- .../src/extension_system/iplugin_manager.h | 4 ++ .../src/extension_system/plugin_manager.cpp | 3 + code/studio/src/main.cpp | 14 ++++- code/studio/src/pm_watcher.cpp | 61 ++++++++++++++++++ code/studio/src/pm_watcher.h | 63 +++++++++++++++++++ 6 files changed, 145 insertions(+), 3 deletions(-) create mode 100644 code/studio/src/pm_watcher.cpp create mode 100644 code/studio/src/pm_watcher.h diff --git a/code/studio/src/CMakeLists.txt b/code/studio/src/CMakeLists.txt index 216acdac2..9bc071bf2 100644 --- a/code/studio/src/CMakeLists.txt +++ b/code/studio/src/CMakeLists.txt @@ -12,7 +12,8 @@ FILE(GLOB STUDIO_SRC extension_system/*.h SET(STUDIO_HDR extension_system/iplugin_manager.h extension_system/plugin_manager.h settings_dialog.h - splash_screen.h ) + splash_screen.h + pm_watcher.h ) SET(STUDIO_RCS studio.qrc ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc) diff --git a/code/studio/src/extension_system/iplugin_manager.h b/code/studio/src/extension_system/iplugin_manager.h index e38748e77..1c8eea5d4 100644 --- a/code/studio/src/extension_system/iplugin_manager.h +++ b/code/studio/src/extension_system/iplugin_manager.h @@ -133,6 +133,10 @@ Q_SIGNALS: /// Signal that the list of available plugins has changed. void pluginsChanged(); + + void pluginLoading( const char *plugin ); + void pluginInitializing( const char *plugin ); + void pluginStarting( const char *plugin ); }; }; // namespace ExtensionSystem diff --git a/code/studio/src/extension_system/plugin_manager.cpp b/code/studio/src/extension_system/plugin_manager.cpp index a976583fb..4dcb40d31 100644 --- a/code/studio/src/extension_system/plugin_manager.cpp +++ b/code/studio/src/extension_system/plugin_manager.cpp @@ -218,6 +218,7 @@ void PluginManager::setPluginState(PluginSpec *spec, int destState) spec->resolveDependencies(m_pluginSpecs); return; case State::Running: + Q_EMIT pluginStarting( spec->name().toUtf8().data() ); spec->initializeExtensions(); return; case State::Deleted: @@ -239,9 +240,11 @@ void PluginManager::setPluginState(PluginSpec *spec, int destState) switch (destState) { case State::Loaded: + Q_EMIT pluginLoading( spec->name().toUtf8().data() ); spec->loadLibrary(); return; case State::Initialized: + Q_EMIT pluginInitializing( spec->name().toUtf8().data() ); spec->initializePlugin(); break; case State::Stopped: diff --git a/code/studio/src/main.cpp b/code/studio/src/main.cpp index 8cb056037..e758037c0 100644 --- a/code/studio/src/main.cpp +++ b/code/studio/src/main.cpp @@ -43,6 +43,7 @@ #include "settings_dialog.h" #include "splash_screen.h" +#include "pm_watcher.h" #ifdef HAVE_OVQT_CONFIG_H #include "ovqt_config.h" @@ -107,6 +108,7 @@ static inline QString msgCoreLoadFailure(const QString &why) return QCoreApplication::translate("Application", "Failed to load Core plugin: %1").arg(why); } + #ifdef NL_OS_WINDOWS int __stdcall WinMain(void *hInstance, void *hPrevInstance, void *lpCmdLine, int nShowCmd) #else // NL_OS_WINDOWS @@ -173,6 +175,9 @@ int main(int argc, char **argv) app.installTranslator(&translator); app.installTranslator(&qtTranslator); + splash->setText( "Loading plugins..." ); + splash->setProgress( 20 ); + #if defined(NL_OS_MAC) QDir::setCurrent(qApp->applicationDirPath() + QString("/../Resources")); NLMISC::CLibrary::addLibPath((qApp->applicationDirPath() + QString("/../PlugIns/nel")).toUtf8().constData()); @@ -188,10 +193,15 @@ int main(int argc, char **argv) #endif pluginManager.setPluginPaths(pluginPaths); - splash->setText( "Loading plugins..." ); - splash->setProgress( 20 ); + + PluginManagerWatcher watcher; + watcher.setPluginManager( &pluginManager ); + watcher.setSplashScreen( splash ); + watcher.connect(); + pluginManager.loadPlugins(); + watcher.disconnect(); splash->hide(); ExtensionSystem::IPluginSpec *corePlugin = pluginManager.pluginByName("Core"); diff --git a/code/studio/src/pm_watcher.cpp b/code/studio/src/pm_watcher.cpp new file mode 100644 index 000000000..350fd886a --- /dev/null +++ b/code/studio/src/pm_watcher.cpp @@ -0,0 +1,61 @@ +// Ryzom Core - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#include "pm_watcher.h" +#include "extension_system\iplugin_manager.h" +#include "splash_screen.h" + +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 * ) ) ); +} + +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 * ) ) ); +} + +void PluginManagerWatcher::onPluginLoading( const char *plugin ) +{ + QString s = "Loading plugin "; + s += plugin; + s += "..."; + sp->setText( s ); +} + +void PluginManagerWatcher::onPluginInitializing( const char *plugin ) +{ + QString s = "Initializing plugin "; + s += plugin; + s += "..."; + sp->setText( s ); +} + +void PluginManagerWatcher::onPluginStarting( const char *plugin ) +{ + QString s = "Starting plugin "; + s += plugin; + s += "..."; + sp->setText( s ); +} + + + diff --git a/code/studio/src/pm_watcher.h b/code/studio/src/pm_watcher.h new file mode 100644 index 000000000..fe2755783 --- /dev/null +++ b/code/studio/src/pm_watcher.h @@ -0,0 +1,63 @@ +// Ryzom Core - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef PM_WATCHER_H +#define PM_WATCHER_H + +#include + +namespace ExtensionSystem +{ + class IPluginManager; +} + +class SplashScreen; +class PluginManager; + +class PluginManagerWatcher : public QObject +{ + Q_OBJECT +public: + PluginManagerWatcher(){ + sp = NULL; + pm = NULL; + } + + ~PluginManagerWatcher(){ + sp = NULL; + pm = NULL; + } + + void setSplashScreen( SplashScreen *s ){ sp = s; } + void setPluginManager( ExtensionSystem::IPluginManager *m ){ pm = m; } + + void connect(); + void disconnect(); + +private Q_SLOTS: + void onPluginLoading( const char *plugin ); + void onPluginInitializing( const char *plugin ); + void onPluginStarting( const char *plugin ); + +private: + SplashScreen *sp; + ExtensionSystem::IPluginManager *pm; +}; + + +#endif +