|
|
@ -23,6 +23,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#include <QDir>
|
|
|
|
#include <QDir>
|
|
|
|
#include <QString>
|
|
|
|
#include <QString>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <nel/misc/debug.h>
|
|
|
|
|
|
|
|
|
|
|
|
NLQT::CConfiguration *Modules::_configuration = NULL;
|
|
|
|
NLQT::CConfiguration *Modules::_configuration = NULL;
|
|
|
|
NLQT::IObjectViewer *Modules::_objViewerInterface = NULL;
|
|
|
|
NLQT::IObjectViewer *Modules::_objViewerInterface = NULL;
|
|
|
|
NLQT::CMainWindow *Modules::_mainWindow = NULL;
|
|
|
|
NLQT::CMainWindow *Modules::_mainWindow = NULL;
|
|
|
@ -49,28 +51,53 @@ void Modules::release()
|
|
|
|
|
|
|
|
|
|
|
|
bool Modules::loadPlugin()
|
|
|
|
bool Modules::loadPlugin()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QDir pluginsDir(qApp->applicationDirPath());
|
|
|
|
#if defined(Q_OS_WIN)
|
|
|
|
/*#if defined(Q_OS_WIN)
|
|
|
|
QString pluginPath = qApp->applicationDirPath();
|
|
|
|
if (pluginsDir.dirName().toLower() == "debug" || pluginsDir.dirName().toLower() == "release")
|
|
|
|
QString pluginFilename = "object_viewer_widget_qt.dll";
|
|
|
|
pluginsDir.cdUp();
|
|
|
|
#elif defined(Q_OS_MAC)
|
|
|
|
#elif defined(Q_OS_MAC)
|
|
|
|
QString pluginPath = qApp->applicationDirPath() + "/../PlugIns/";
|
|
|
|
if (pluginsDir.dirName() == "MacOS") {
|
|
|
|
QString pluginFilename = "libobject_viewer_widget_qt.so";
|
|
|
|
pluginsDir.cdUp();
|
|
|
|
#else // LINUX
|
|
|
|
pluginsDir.cdUp();
|
|
|
|
QString pluginPath = qApp->applicationDirPath();
|
|
|
|
pluginsDir.cdUp();
|
|
|
|
QString pluginFilename = "libobject_viewer_widget_qt.so";
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif*/
|
|
|
|
|
|
|
|
//pluginsDir.cd("plugins");
|
|
|
|
// if(!QFile::exists(pluginPath + pluginFilename))
|
|
|
|
//Q_FOREACH (QString fileName, pluginsDir.entryList(QDir::Files)) {
|
|
|
|
// {
|
|
|
|
QPluginLoader pluginLoader(pluginsDir.absoluteFilePath("object_viewer_widget_qt.dll"));
|
|
|
|
// nlwarning("Cannot find %s in %s, fallback to working dir",
|
|
|
|
|
|
|
|
// pluginFilename.toStdString().c_str(), pluginPath.toStdString().c_str());
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// pluginPath = "";
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// Q_FOREACH (QString path, qApp->libraryPaths())
|
|
|
|
|
|
|
|
// nlwarning("libraryPaths %s", path.toStdString().c_str());
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QDir pluginsDir(pluginPath);
|
|
|
|
|
|
|
|
QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(pluginFilename));
|
|
|
|
|
|
|
|
|
|
|
|
QObject *plugin = pluginLoader.instance();
|
|
|
|
QObject *plugin = pluginLoader.instance();
|
|
|
|
if (plugin)
|
|
|
|
if (plugin)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_objViewerInterface = qobject_cast<NLQT::IObjectViewer *>(plugin);
|
|
|
|
_objViewerInterface = qobject_cast<NLQT::IObjectViewer *>(plugin);
|
|
|
|
if (_objViewerInterface)
|
|
|
|
if (_objViewerInterface)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
nlinfo("Loaded %s",
|
|
|
|
|
|
|
|
pluginsDir.absoluteFilePath(pluginFilename).toStdString().c_str());
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
nlwarning("Loaded %s, but cannot cast to NLQT::IObjectViewer*",
|
|
|
|
|
|
|
|
pluginFilename.toStdString().c_str());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
nlwarning("Cannot get plugin instance for %s (searched in %s)",
|
|
|
|
|
|
|
|
pluginFilename.toStdString().c_str(),
|
|
|
|
|
|
|
|
(qApp->applicationDirPath() + pluginPath).toStdString().c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|