Added: #1206 Added plugin view dialog. And if there are errors while loading plugin displays a diagnostic message.
This commit is contained in:
parent
165c9c686a
commit
1331037de3
8 changed files with 197 additions and 9 deletions
|
@ -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)
|
||||
|
|
|
@ -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<IPlugin*>(loader.instance());
|
||||
if (!pluginObject)
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
Object Viewer Qt
|
||||
Copyright (C) 2010 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
#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
|
|
@ -11,7 +11,7 @@
|
|||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Plugins</string>
|
||||
<string>About plugins</string>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
|
@ -19,6 +19,12 @@
|
|||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="4">
|
||||
<widget class="QTreeWidget" name="pluginTreeWidget">
|
||||
<property name="rootIsDecorated">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="itemsExpandable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>State</string>
|
||||
|
@ -48,6 +54,9 @@
|
|||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="detailsPushButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Details</string>
|
||||
</property>
|
||||
|
@ -88,5 +97,22 @@
|
|||
<resources>
|
||||
<include location="../object_viewer_qt.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>closePushButton</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>CPluginView</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>620</x>
|
||||
<y>232</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>507</x>
|
||||
<y>226</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
Object Viewer Qt
|
||||
Copyright (C) 2010 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
#include "plugin_view.h"
|
||||
|
||||
// Qt includes
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtGui/QIcon>
|
||||
#include <QtGui/QStyle>
|
||||
#include <QtGui/QTreeWidgetItem>
|
||||
|
||||
// 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<QTreeWidgetItem *> 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 */
|
|
@ -3,6 +3,7 @@
|
|||
#include <nel/misc/app_context.h>
|
||||
|
||||
// Qt includes
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QSplashScreen>
|
||||
|
||||
|
@ -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();
|
||||
|
|
|
@ -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()));
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in a new issue