From 5fbb37d106c254d6014272f02e05e5018c3c27ce Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Thu, 2 Dec 2010 12:52:22 +0200 Subject: [PATCH] Added: #1206 Added plugin view dialog. And if there are errors while loading plugin displays a diagnostic message. --- .../3d/object_viewer_qt/src/CMakeLists.txt | 7 +- .../src/extension_system/plugin_spec.cpp | 9 +-- .../src/extension_system/plugin_view.h | 59 +++++++++++++++ .../src/extension_system/plugin_view.ui | 30 +++++++- .../src/extension_system/plugn_view.cpp | 75 +++++++++++++++++++ .../tools/3d/object_viewer_qt/src/main.cpp | 11 +++ .../3d/object_viewer_qt/src/main_window.cpp | 10 +++ .../3d/object_viewer_qt/src/main_window.h | 5 ++ 8 files changed, 197 insertions(+), 9 deletions(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_view.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/extension_system/plugn_view.cpp diff --git a/code/nel/tools/3d/object_viewer_qt/src/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/CMakeLists.txt index 63d238877..543f4b464 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/CMakeLists.txt @@ -22,7 +22,8 @@ SET(OBJECT_VIEWER_HDR main_window.h graphics_viewport.h animation_dialog.h vegetable_dialog.h global_wind_dialog.h day_night_dialog.h sun_color_dialog.h vegetable_noise_value_widget.h vegetable_density_page.h vegetable_landscape_page.h vegetable_scale_page.h vegetable_appearance_page.h vegetable_rotate_page.h - extension_system/iplugin_manager.h extension_system/plugin_manager.h) + extension_system/iplugin_manager.h extension_system/plugin_manager.h + extension_system/plugin_view.h) SET(OBJECT_VIEWER_UIS animation_form.ui animation_set_form.ui settings_form.ui setup_fog_form.ui slot_form.ui particle_control_form.ui particle_workspace_form.ui @@ -35,7 +36,9 @@ SET(OBJECT_VIEWER_UIS animation_form.ui animation_set_form.ui settings_form.ui particle_link_skeleton_form.ui water_pool_form.ui vegetable_dialog_form.ui vegetable_noise_value_form.ui global_wind_form.ui sun_color_form.ui day_night_form.ui vegetable_density_form.ui vegetable_apperance_form.ui vegetable_landscape_form.ui - vegetable_rotate_form.ui vegetable_scale_form.ui) + vegetable_rotate_form.ui vegetable_scale_form.ui + extension_system/plugin_view.ui) + SET(OBJECT_VIEWER_RCS object_viewer_qt.qrc) SET(QT_USE_QTGUI TRUE) diff --git a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_spec.cpp b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_spec.cpp index aaf9d5321..2f58d673d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_spec.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_spec.cpp @@ -100,7 +100,7 @@ QString CPluginSpec::errorString() const bool CPluginSpec::setFileName(const QString &fileName) { _name = _version - = _vendor + = _vendor = _description = _location = _filePath @@ -134,11 +134,10 @@ bool CPluginSpec::loadLibrary() return true; return reportError(QCoreApplication::translate("CPluginSpec", "Loading the library failed because state != Resolved")); } - QString libName = QString("%1/%2").arg(_location).arg(_fileName); - - QPluginLoader loader(libName); + + QPluginLoader loader(_filePath); if (!loader.load()) - return reportError(libName + QString::fromLatin1(": ") + loader.errorString()); + return reportError(loader.errorString()); IPlugin *pluginObject = qobject_cast(loader.instance()); if (!pluginObject) diff --git a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_view.h b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_view.h new file mode 100644 index 000000000..91c81b39e --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_view.h @@ -0,0 +1,59 @@ +/* + Object Viewer Qt + Copyright (C) 2010 Dzmitry Kamiahin + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +*/ + +#ifndef PLUGIN_VIEW_H +#define PLUGIN_VIEW_H + +#include "ui_plugin_view.h" + + +// STL includes + +// Qt includes + +// NeL includes + +// Project includes + + +namespace NLQT +{ + +class IPluginManager; + +class CPluginView: public QDialog +{ + Q_OBJECT + +public: + CPluginView(IPluginManager *pluginManager, QWidget *parent = 0); + ~CPluginView(); + +private Q_SLOTS: + void updateList(); + +private: + + IPluginManager *_pluginManager; + Ui::CPluginView _ui; +}; /* class CPluginView */ + +} /* namespace NLQT */ + +#endif // PLUGIN_VIEW_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_view.ui b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_view.ui index e65206408..65c24dd55 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_view.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_view.ui @@ -11,7 +11,7 @@ - Plugins + About plugins true @@ -19,6 +19,12 @@ + + false + + + false + State @@ -48,6 +54,9 @@ + + false + Details @@ -88,5 +97,22 @@ - + + + closePushButton + clicked() + CPluginView + accept() + + + 620 + 232 + + + 507 + 226 + + + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugn_view.cpp b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugn_view.cpp new file mode 100644 index 000000000..03423d9c2 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugn_view.cpp @@ -0,0 +1,75 @@ +/* + Object Viewer Qt + Copyright (C) 2010 Dzmitry Kamiahin + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +*/ + +#include "plugin_view.h" + +// Qt includes +#include +#include +#include +#include +#include +#include + +// Project includes +#include "plugin_spec.h" +#include "iplugin_manager.h" + +namespace NLQT +{ + +CPluginView::CPluginView(IPluginManager *pluginManager, QWidget *parent) + : QDialog(parent) +{ + _ui.setupUi(this); + _pluginManager = pluginManager; + + connect(_pluginManager, SIGNAL(pluginsChanged()), this, SLOT(updateList())); + + updateList(); +} + +CPluginView::~CPluginView() +{ +} + +void CPluginView::updateList() +{ + static QIcon okIcon = QApplication::style()->standardIcon(QStyle::SP_DialogApplyButton); + static QIcon errorIcon = QApplication::style()->standardIcon(QStyle::SP_DialogCancelButton); + + QList items; + Q_FOREACH (CPluginSpec *spec, _pluginManager->plugins()) + { + QTreeWidgetItem *item = new QTreeWidgetItem(QStringList() + << "" + << spec->name() + << QString("%1").arg(spec->version()) + << spec->vendor() + << QDir::toNativeSeparators(spec->filePath())); + item->setIcon(0, spec->hasError() ? errorIcon : okIcon); + items.append(item); + } + + _ui.pluginTreeWidget->clear(); + if (!items.isEmpty()) + _ui.pluginTreeWidget->addTopLevelItems(items); +} + +} /* namespace NLQT */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/main.cpp b/code/nel/tools/3d/object_viewer_qt/src/main.cpp index ccdd1b3d4..98dbc4f06 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/main.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/main.cpp @@ -3,6 +3,7 @@ #include // Qt includes +#include #include #include @@ -101,6 +102,16 @@ sint main(int argc, char **argv) Modules::plugMan().setPluginPaths(QStringList() << QString("./plugins")); Modules::plugMan().loadPlugins(); + QStringList errors; + Q_FOREACH (NLQT::CPluginSpec *spec, Modules::plugMan().plugins()) + if (spec->hasError()) + errors.append(spec->fileName() + " : " + spec->errorString()); + + if (!errors.isEmpty()) + QMessageBox::warning(0, + QCoreApplication::translate("Application", "Object Viewer Qt - Plugin loader messages"), + errors.join(QString::fromLatin1("\n\n"))); + splash->finish(&Modules::mainWin()); int result = app.exec(); Modules::release(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/main_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/main_window.cpp index d175afec4..6391fba43 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/main_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/main_window.cpp @@ -46,6 +46,8 @@ #include "day_night_dialog.h" #include "sun_color_dialog.h" +#include "extension_system/plugin_view.h" + using namespace std; using namespace NLMISC; @@ -132,6 +134,7 @@ CMainWindow::~CMainWindow() delete _ParticleControlDialog; delete _ParticleWorkspaceDialog; delete _GraphicsViewport; + delete _PluginView; } void CMainWindow::setVisible(bool visible) @@ -342,6 +345,10 @@ void CMainWindow::createActions() _aboutQtAction = new QAction(tr("About &Qt"), this); _aboutQtAction->setStatusTip(tr("Show the Qt library's About box")); connect(_aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); + + _pluginViewAction = new QAction(tr("About &Plugins"), this); + _pluginViewAction->setStatusTip(tr("Show the plugin view dialog")); + connect(_pluginViewAction, SIGNAL(triggered()), _PluginView, SLOT(show())); } void CMainWindow::createMenus() @@ -406,6 +413,7 @@ void CMainWindow::createMenus() _helpMenu = menuBar()->addMenu(tr("&Help")); _helpMenu->addAction(_aboutAction); _helpMenu->addAction(_aboutQtAction); + _helpMenu->addAction(_pluginViewAction); } void CMainWindow::createToolBars() @@ -498,6 +506,8 @@ void CMainWindow::createDialogs() addDockWidget(Qt::RightDockWidgetArea, _SetupFog); _SetupFog->setVisible(false); + _PluginView = new CPluginView(&Modules::plugMan(), this); + connect(_ParticleControlDialog, SIGNAL(changeState()), _ParticleWorkspaceDialog, SLOT(setNewState())); connect(_ParticleWorkspaceDialog, SIGNAL(changeActiveNode()), _ParticleControlDialog, SLOT(updateActiveNode())); connect(_AnimationSetDialog->ui.setLengthPushButton, SIGNAL(clicked()), _AnimationDialog, SLOT(changeAnimLength())); diff --git a/code/nel/tools/3d/object_viewer_qt/src/main_window.h b/code/nel/tools/3d/object_viewer_qt/src/main_window.h index a63a1bbad..e14471940 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/main_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/main_window.h @@ -53,6 +53,8 @@ class CGlobalWindDialog; class CDayNightDialog; class CSunColorDialog; +class CPluginView; + class CMainWindow : public QMainWindow { Q_OBJECT @@ -113,6 +115,8 @@ private: CDayNightDialog *_DayNightDialog; CSunColorDialog *_SunColorDialog; + CPluginView *_PluginView; + CSkeletonTreeModel *_SkeletonTreeModel; QPalette _originalPalette; @@ -135,6 +139,7 @@ private: QAction *_resetSceneAction; QAction *_saveScreenshotAction; QAction *_settingsAction; + QAction *_pluginViewAction; QAction *_aboutAction; QAction *_aboutQtAction; };/* class CMainWindow */