From 6b39edeb1ec0c7857816a9a0c7e0ff1f25aa839f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 2 May 2018 13:44:11 +0200 Subject: [PATCH] Added a list of failed plugins to the about dialog --- Core/PluginLoader.cc | 49 +++++++++++++++++++++++++++++++++++++ common/PluginStorage.cc | 7 ++++++ common/PluginStorage.hh | 6 +++++ widgets/coreWidget/About.cc | 32 ++++++++++++++++++++++++ 4 files changed, 94 insertions(+) diff --git a/Core/PluginLoader.cc b/Core/PluginLoader.cc index 103b6038..91819278 100644 --- a/Core/PluginLoader.cc +++ b/Core/PluginLoader.cc @@ -87,6 +87,7 @@ #include "OpenFlipper/widgets/PluginDialog/PluginDialog.hh" #include +#include /** @@ -804,6 +805,12 @@ void Core::loadPlugin(const QString& _filename,const bool _silent, QString& _lic printPluginLoadLog(errors, warnings); info.description = basePlugin->description() + tr(" *Already loaded.*"); + + info.errors = errors; + info.warnings = warnings; + + PluginStorage::pluginsFailed().push_back(info); + return; }else{ //ask the user int ret = QMessageBox::question(coreWidget_, @@ -819,6 +826,11 @@ void Core::loadPlugin(const QString& _filename,const bool _silent, QString& _lic printPluginLoadLog(errors, warnings); info.description = basePlugin->description() + tr(" *Already loaded.*"); + + info.errors = errors; + info.warnings = warnings; + + PluginStorage::pluginsFailed().push_back(info); return; } } @@ -834,6 +846,12 @@ void Core::loadPlugin(const QString& _filename,const bool _silent, QString& _lic printPluginLoadLog(errors, warnings); info.status = PluginInfo::BLOCKED; + + info.errors = errors; + info.warnings = warnings; + + PluginStorage::pluginsFailed().push_back(info); + return; } @@ -859,6 +877,11 @@ void Core::loadPlugin(const QString& _filename,const bool _silent, QString& _lic info.description = basePlugin->description() + tr(" *Plugin access denied.*"); // Abort here, as the plugin will not do anything else until correct authentication. + + info.errors = errors; + info.warnings = warnings; + + PluginStorage::pluginsFailed().push_back(info); return; } } @@ -881,6 +904,11 @@ void Core::loadPlugin(const QString& _filename,const bool _silent, QString& _lic printPluginLoadLog(errors, warnings); + info.errors = errors; + info.warnings = warnings; + + PluginStorage::pluginsFailed().push_back(info); + return; } @@ -894,6 +922,11 @@ void Core::loadPlugin(const QString& _filename,const bool _silent, QString& _lic printPluginLoadLog(errors, warnings); + info.errors = errors; + info.warnings = warnings; + + PluginStorage::pluginsFailed().push_back(info); + return; } @@ -902,6 +935,11 @@ void Core::loadPlugin(const QString& _filename,const bool _silent, QString& _lic printPluginLoadLog(errors, warnings); + info.errors = errors; + info.warnings = warnings; + + PluginStorage::pluginsFailed().push_back(info); + return; } @@ -2086,6 +2124,11 @@ void Core::loadPlugin(const QString& _filename,const bool _silent, QString& _lic printPluginLoadLog(errors, warnings); + info.errors = errors; + info.warnings = warnings; + + PluginStorage::pluginsFailed().push_back(info); + return; } @@ -2144,6 +2187,12 @@ void Core::loadPlugin(const QString& _filename,const bool _silent, QString& _lic if ( openGLCheck != "" ) { errors += tr("Error: Insufficient OpenGL capabilities in post processor Plugin ") + postProcessorNameString + " !" + "\n"; errors += openGLCheck + "\n"; + + info.errors = errors; + info.warnings = warnings; + + PluginStorage::pluginsFailed().push_back(info); + return; } diff --git a/common/PluginStorage.cc b/common/PluginStorage.cc index 95cfc74f..09666618 100644 --- a/common/PluginStorage.cc +++ b/common/PluginStorage.cc @@ -72,11 +72,18 @@ namespace PluginStorage { /// reference to Core plugin list static std::vector plugins_; +/// reference to failed plugin list +static std::vector pluginsFailed_; + std::vector& plugins() { return plugins_; } +std::vector& pluginsFailed() { + return pluginsFailed_; +} + } //============================================================================= diff --git a/common/PluginStorage.hh b/common/PluginStorage.hh index 057a281c..205ab5e5 100644 --- a/common/PluginStorage.hh +++ b/common/PluginStorage.hh @@ -63,6 +63,7 @@ #pragma once +#include #include @@ -72,8 +73,13 @@ namespace PluginStorage { /// Get the vector of all PluginInfos + DLLEXPORT std::vector& plugins(); + /// Get the vector of all PluginInfos for plugins that failed to load at startup + DLLEXPORT + std::vector& pluginsFailed(); + } diff --git a/widgets/coreWidget/About.cc b/widgets/coreWidget/About.cc index 77cad931..db326669 100644 --- a/widgets/coreWidget/About.cc +++ b/widgets/coreWidget/About.cc @@ -777,6 +777,38 @@ void CoreWidget::showAboutWidget( ) { } + // ===================================================================================== + // List failed Plugins + // ===================================================================================== + aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont); + aboutWidget_->OpenFlipperAbout->append(tr("Failed Plugins:")); + aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont); + + for ( unsigned i = 0 ; i < PluginStorage::pluginsFailed().size() ; ++i ) { + aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont); + aboutWidget_->OpenFlipperAbout->append( "\t" + PluginStorage::pluginsFailed()[i].name ); + aboutWidget_->OpenFlipperAbout->setCurrentFont(standardFont); + aboutWidget_->OpenFlipperAbout->append( "\t\t Version: \t\t" + PluginStorage::pluginsFailed()[i].version ); + aboutWidget_->OpenFlipperAbout->append( "\t\t Description: \t" + PluginStorage::pluginsFailed()[i].description ); + aboutWidget_->OpenFlipperAbout->append( "\t\t Path \t\t" + PluginStorage::pluginsFailed()[i].path ); + + if ( !PluginStorage::pluginsFailed()[i].warnings.isEmpty() ) { + aboutWidget_->OpenFlipperAbout->setTextColor(Qt::darkYellow); + aboutWidget_->OpenFlipperAbout->append( "\t\t Warnings: \t\t" + PluginStorage::pluginsFailed()[i].warnings ); + aboutWidget_->OpenFlipperAbout->setTextColor(Qt::black); + } + + if ( !PluginStorage::pluginsFailed()[i].errors.isEmpty() ) { + aboutWidget_->OpenFlipperAbout->setTextColor(Qt::darkRed); + aboutWidget_->OpenFlipperAbout->append( "\t\t Errors: \t\t" + PluginStorage::pluginsFailed()[i].errors ); + aboutWidget_->OpenFlipperAbout->setTextColor(Qt::black); + } + + } + + + + // ===================================================================================== // List of build-in resources // ===================================================================================== -- GitLab