Changed: #1206 Update core and example plugin.
This commit is contained in:
parent
8665899abf
commit
9937f56978
23 changed files with 552 additions and 224 deletions
|
@ -57,7 +57,7 @@ FOREACH(LANGUAGE ${LANGUAGES})
|
||||||
ADD_CUSTOM_COMMAND (OUTPUT ${QM} COMMAND ${QT_LRELEASE_EXECUTABLE} ${TS} MAIN_DEPENDENCY ${TS})
|
ADD_CUSTOM_COMMAND (OUTPUT ${QM} COMMAND ${QT_LRELEASE_EXECUTABLE} ${TS} MAIN_DEPENDENCY ${TS})
|
||||||
ENDFOREACH()
|
ENDFOREACH()
|
||||||
|
|
||||||
ADD_CUSTOM_TARGET (translations COMMAND ${QT_LUPDATE_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR} -recursive -ts ${TRANSLATIONS})
|
ADD_CUSTOM_TARGET (translations COMMAND ${QT_LUPDATE_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR} -recursive -no-obsolete -ts ${TRANSLATIONS})
|
||||||
ADD_CUSTOM_COMMAND (TARGET translations COMMAND ${QT_LRELEASE_EXECUTABLE} ${TRANSLATIONS})
|
ADD_CUSTOM_COMMAND (TARGET translations COMMAND ${QT_LRELEASE_EXECUTABLE} ${TRANSLATIONS})
|
||||||
|
|
||||||
SOURCE_GROUP(QtResources FILES ${OBJECT_VIEWER_UIS} ${OBJECT_VIEWER_RCS})
|
SOURCE_GROUP(QtResources FILES ${OBJECT_VIEWER_UIS} ${OBJECT_VIEWER_RCS})
|
||||||
|
|
|
@ -40,6 +40,9 @@
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "modules.h"
|
#include "modules.h"
|
||||||
#include "extension_system/iplugin_spec.h"
|
#include "extension_system/iplugin_spec.h"
|
||||||
|
#include "extension_system/plugin_manager.h"
|
||||||
|
|
||||||
|
static const char *appNameC = "ObjectViewerQt";
|
||||||
|
|
||||||
// nel_qt log file name
|
// nel_qt log file name
|
||||||
#define NLQT_LOG_FILE "nel_qt.log"
|
#define NLQT_LOG_FILE "nel_qt.log"
|
||||||
|
@ -82,6 +85,29 @@ CFileDisplayer *s_FileDisplayer = NULL;
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
|
||||||
|
static void displayError(const QString &t) // No console on Windows.
|
||||||
|
{
|
||||||
|
QMessageBox::critical(0, QLatin1String(appNameC), t);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
static void displayError(const QString &t)
|
||||||
|
{
|
||||||
|
qCritical("%s", qPrintable(t));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline QString msgCoreLoadFailure(const QString &why)
|
||||||
|
{
|
||||||
|
return QCoreApplication::translate("Application", "Failed to load Core plugin: %1").arg(why);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define OVQT_OLD true
|
||||||
|
|
||||||
sint main(int argc, char **argv)
|
sint main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
// go nel!
|
// go nel!
|
||||||
|
@ -111,8 +137,9 @@ sint main(int argc, char **argv)
|
||||||
splash->setPixmap(QPixmap(":/images/nel_ide_load.png"));
|
splash->setPixmap(QPixmap(":/images/nel_ide_load.png"));
|
||||||
splash->show();
|
splash->show();
|
||||||
|
|
||||||
|
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||||
QSettings *settings = new QSettings(QSettings::IniFormat, QSettings::UserScope,
|
QSettings *settings = new QSettings(QSettings::IniFormat, QSettings::UserScope,
|
||||||
QLatin1String("Ryzom Core"), QLatin1String("ObjectViewerQt"));
|
QLatin1String("RyzomCore"), QLatin1String(appNameC));
|
||||||
|
|
||||||
QTranslator translator;
|
QTranslator translator;
|
||||||
QTranslator qtTranslator;
|
QTranslator qtTranslator;
|
||||||
|
@ -128,6 +155,7 @@ sint main(int argc, char **argv)
|
||||||
CLibrary::addLibPath((qApp->applicationDirPath() + QString("/../PlugIns/nel")).toStdString());
|
CLibrary::addLibPath((qApp->applicationDirPath() + QString("/../PlugIns/nel")).toStdString());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(OVQT_OLD)
|
||||||
Modules::init();
|
Modules::init();
|
||||||
|
|
||||||
Modules::plugMan().setSettings(settings);
|
Modules::plugMan().setSettings(settings);
|
||||||
|
@ -161,5 +189,57 @@ sint main(int argc, char **argv)
|
||||||
splash->finish(&Modules::mainWin());
|
splash->finish(&Modules::mainWin());
|
||||||
int result = app.exec();
|
int result = app.exec();
|
||||||
Modules::release();
|
Modules::release();
|
||||||
|
#else
|
||||||
|
ExtensionSystem::CPluginManager pluginManager;
|
||||||
|
pluginManager.setSettings(settings);
|
||||||
|
QStringList pluginPaths;
|
||||||
|
#if !defined(NL_OS_MAC)
|
||||||
|
pluginPaths << QString("./plugins");
|
||||||
|
#else
|
||||||
|
pluginPaths << qApp->applicationDirPath() + QString("/../PlugIns/ovqt");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
pluginManager.setPluginPaths(pluginPaths);
|
||||||
|
pluginManager.loadPlugins();
|
||||||
|
|
||||||
|
splash->hide();
|
||||||
|
|
||||||
|
const QList<ExtensionSystem::IPluginSpec *> plugins = pluginManager.plugins();
|
||||||
|
ExtensionSystem::IPluginSpec *corePlugin = 0;
|
||||||
|
Q_FOREACH(ExtensionSystem::IPluginSpec *spec, plugins)
|
||||||
|
{
|
||||||
|
if (spec->name() == QLatin1String("Core"))
|
||||||
|
{
|
||||||
|
corePlugin = spec;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!corePlugin)
|
||||||
|
{
|
||||||
|
QDir absolutePluginPaths(pluginPaths.join(QLatin1String(",")));
|
||||||
|
QString absolutePaths = absolutePluginPaths.absolutePath();
|
||||||
|
const QString reason = QCoreApplication::translate("Application", "Could not find ovqt_plugin_core in %1").arg(absolutePaths);
|
||||||
|
displayError(msgCoreLoadFailure(reason));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (corePlugin->hasError())
|
||||||
|
{
|
||||||
|
displayError(msgCoreLoadFailure(corePlugin->errorString()));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList errors;
|
||||||
|
Q_FOREACH (ExtensionSystem::IPluginSpec *spec, pluginManager.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")));
|
||||||
|
|
||||||
|
int result = app.exec();
|
||||||
|
#endif
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
|
@ -9,10 +9,13 @@ SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h)
|
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h)
|
||||||
|
|
||||||
SET(OVQT_CORE_PLUGIN_HDR
|
SET(OVQT_CORE_PLUGIN_HDR
|
||||||
|
icore.h
|
||||||
|
icontext.h
|
||||||
imenu_manager.h
|
imenu_manager.h
|
||||||
icore_listener.h
|
icore_listener.h
|
||||||
ioptions_page.h
|
ioptions_page.h
|
||||||
core_plugin.h
|
core_plugin.h
|
||||||
|
core.h
|
||||||
main_window.h
|
main_window.h
|
||||||
menu_manager.h
|
menu_manager.h
|
||||||
settings_dialog.h
|
settings_dialog.h
|
||||||
|
|
66
code/nel/tools/3d/object_viewer_qt/src/plugins/core/core.cpp
Normal file
66
code/nel/tools/3d/object_viewer_qt/src/plugins/core/core.cpp
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||||
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
|
// Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||||
|
//
|
||||||
|
// 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include "core.h"
|
||||||
|
#include "imenu_manager.h"
|
||||||
|
#include "main_window.h"
|
||||||
|
|
||||||
|
static Core::CoreImpl *m_coreInstance = 0;
|
||||||
|
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
|
||||||
|
ICore *ICore::instance()
|
||||||
|
{
|
||||||
|
return m_coreInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
CoreImpl::CoreImpl(MainWindow *mainWindow)
|
||||||
|
{
|
||||||
|
m_mainWindow = mainWindow;
|
||||||
|
m_coreInstance = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
CoreImpl::~CoreImpl()
|
||||||
|
{
|
||||||
|
m_coreInstance = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CoreImpl::showOptionsDialog(const QString &group,
|
||||||
|
const QString &page,
|
||||||
|
QWidget *parent)
|
||||||
|
{
|
||||||
|
return m_mainWindow->showOptionsDialog(group, page, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
IMenuManager *CoreImpl::menuManager() const
|
||||||
|
{
|
||||||
|
return m_mainWindow->menuManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
QSettings *CoreImpl::settings() const
|
||||||
|
{
|
||||||
|
return m_mainWindow->settings();
|
||||||
|
}
|
||||||
|
|
||||||
|
QMainWindow *CoreImpl::mainWindow() const
|
||||||
|
{
|
||||||
|
return m_mainWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Core
|
52
code/nel/tools/3d/object_viewer_qt/src/plugins/core/core.h
Normal file
52
code/nel/tools/3d/object_viewer_qt/src/plugins/core/core.h
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||||
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
|
// Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||||
|
//
|
||||||
|
// 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef CORE_H
|
||||||
|
#define CORE_H
|
||||||
|
|
||||||
|
#include "icore.h"
|
||||||
|
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
class MainWindow;
|
||||||
|
|
||||||
|
class CoreImpl : public ICore
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
CoreImpl(MainWindow *mainWindow);
|
||||||
|
virtual ~CoreImpl();
|
||||||
|
|
||||||
|
virtual bool showOptionsDialog(const QString &group = QString(),
|
||||||
|
const QString &page = QString(),
|
||||||
|
QWidget *parent = 0);
|
||||||
|
|
||||||
|
virtual IMenuManager *menuManager() const;
|
||||||
|
|
||||||
|
virtual QSettings *settings() const;
|
||||||
|
virtual QMainWindow *mainWindow() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
MainWindow *m_mainWindow;
|
||||||
|
friend class MainWindow;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Core
|
||||||
|
|
||||||
|
#endif // CORE_H
|
|
@ -48,13 +48,15 @@ CorePlugin::~CorePlugin()
|
||||||
}
|
}
|
||||||
qDeleteAll(_autoReleaseObjects);
|
qDeleteAll(_autoReleaseObjects);
|
||||||
_autoReleaseObjects.clear();
|
_autoReleaseObjects.clear();
|
||||||
|
|
||||||
|
if (_oldOVQT)
|
||||||
|
delete _mainWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CorePlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString)
|
bool CorePlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString)
|
||||||
{
|
{
|
||||||
Q_UNUSED(errorString);
|
Q_UNUSED(errorString);
|
||||||
_plugMan = pluginManager;
|
_plugMan = pluginManager;
|
||||||
_oldOVQT = false;
|
|
||||||
|
|
||||||
// for old ovqt
|
// for old ovqt
|
||||||
QMainWindow *wnd = qobject_cast<QMainWindow *>(_plugMan->objectByName("CMainWindow"));
|
QMainWindow *wnd = qobject_cast<QMainWindow *>(_plugMan->objectByName("CMainWindow"));
|
||||||
|
@ -72,11 +74,11 @@ bool CorePlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QStr
|
||||||
|
|
||||||
connect(newAction, SIGNAL(triggered()), this, SLOT(execSettings()));
|
connect(newAction, SIGNAL(triggered()), this, SLOT(execSettings()));
|
||||||
connect(newAction2, SIGNAL(triggered()), _pluginView, SLOT(show()));
|
connect(newAction2, SIGNAL(triggered()), _pluginView, SLOT(show()));
|
||||||
_oldOVQT = true;
|
_oldOVQT = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_mainWindow = new CMainWindow(this);
|
_mainWindow = new MainWindow(pluginManager);
|
||||||
#ifdef Q_WS_X11
|
#ifdef Q_WS_X11
|
||||||
_mainWindow->setAttribute(Qt::WA_TranslucentBackground);
|
_mainWindow->setAttribute(Qt::WA_TranslucentBackground);
|
||||||
_mainWindow->setAttribute(Qt::WA_NoSystemBackground, false);
|
_mainWindow->setAttribute(Qt::WA_NoSystemBackground, false);
|
||||||
|
@ -93,7 +95,9 @@ bool CorePlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QStr
|
||||||
QtWin::extendFrameIntoClientArea(_mainWindow);
|
QtWin::extendFrameIntoClientArea(_mainWindow);
|
||||||
_mainWindow->setContentsMargins(0, 0, 0, 0);
|
_mainWindow->setContentsMargins(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
_mainWindow->show();
|
_oldOVQT = true;
|
||||||
|
bool success = _mainWindow->initialize(errorString);
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
addAutoReleasedObject(new CSearchPathsSettingsPage(this));
|
addAutoReleasedObject(new CSearchPathsSettingsPage(this));
|
||||||
|
@ -103,20 +107,18 @@ bool CorePlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QStr
|
||||||
void CorePlugin::extensionsInitialized()
|
void CorePlugin::extensionsInitialized()
|
||||||
{
|
{
|
||||||
_pluginView = new ExtensionSystem::CPluginView(_plugMan);
|
_pluginView = new ExtensionSystem::CPluginView(_plugMan);
|
||||||
|
if (_oldOVQT)
|
||||||
|
_mainWindow->extensionsInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CorePlugin::shutdown()
|
void CorePlugin::shutdown()
|
||||||
{
|
{
|
||||||
if (!_oldOVQT)
|
delete _pluginView;
|
||||||
{
|
|
||||||
delete _mainWindow;
|
|
||||||
delete _pluginView;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CorePlugin::execSettings()
|
void CorePlugin::execSettings()
|
||||||
{
|
{
|
||||||
CSettingsDialog settingsDialog(this);
|
CSettingsDialog settingsDialog(_plugMan);
|
||||||
settingsDialog.show();
|
settingsDialog.show();
|
||||||
settingsDialog.execDialog();
|
settingsDialog.execDialog();
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ private Q_SLOTS:
|
||||||
private:
|
private:
|
||||||
ExtensionSystem::IPluginManager *_plugMan;
|
ExtensionSystem::IPluginManager *_plugMan;
|
||||||
ExtensionSystem::CPluginView *_pluginView;
|
ExtensionSystem::CPluginView *_pluginView;
|
||||||
CMainWindow *_mainWindow;
|
MainWindow *_mainWindow;
|
||||||
QList<QObject *> _autoReleaseObjects;
|
QList<QObject *> _autoReleaseObjects;
|
||||||
bool _oldOVQT;
|
bool _oldOVQT;
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,25 +15,35 @@
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#ifndef IAPP_PAGE_H
|
#ifndef ICONTEXT_H
|
||||||
#define IAPP_PAGE_H
|
#define ICONTEXT_H
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "core_global.h"
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
#include <QtCore/QString>
|
||||||
|
#include <QtGui/QIcon>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
class QWidget;
|
class QWidget;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Core
|
namespace Core
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@interface IAppPage
|
@interface IContext
|
||||||
@brief The IAppPage is an interface for providing app pages in main window.
|
@brief The IContext is an interface for providing tab pages in main window.
|
||||||
@details You need to subclass this interface and put an instance of your subclass
|
@details You need to subclass this interface and put an instance of your subclass
|
||||||
into the plugin manager object pool.
|
into the plugin manager object pool.
|
||||||
*/
|
*/
|
||||||
class IAppPage
|
class CORE_EXPORT IContext: public QObject
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
virtual ~IAppPage() {}
|
IContext(QObject *parent = 0): QObject(parent) {}
|
||||||
|
virtual ~IContext() {}
|
||||||
|
|
||||||
/// id() is a unique identifier for referencing this page
|
/// id() is a unique identifier for referencing this page
|
||||||
virtual QString id() const = 0;
|
virtual QString id() const = 0;
|
||||||
|
@ -50,6 +60,4 @@ public:
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|
||||||
Q_DECLARE_INTERFACE(Core::IAppPage, "dev.ryzom.com.IAppPage/0.1")
|
#endif // ICONTEXT_H
|
||||||
|
|
||||||
#endif // IAPP_PAGE_H
|
|
60
code/nel/tools/3d/object_viewer_qt/src/plugins/core/icore.h
Normal file
60
code/nel/tools/3d/object_viewer_qt/src/plugins/core/icore.h
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||||
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
|
// Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||||
|
//
|
||||||
|
// 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef ICORE_H
|
||||||
|
#define ICORE_H
|
||||||
|
|
||||||
|
#include "core_global.h"
|
||||||
|
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QMainWindow;
|
||||||
|
class QSettings;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
class IMenuManager;
|
||||||
|
|
||||||
|
class CORE_EXPORT ICore : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
ICore() {}
|
||||||
|
virtual ~ICore() {}
|
||||||
|
|
||||||
|
static ICore *instance();
|
||||||
|
|
||||||
|
virtual bool showOptionsDialog(const QString &group = QString(),
|
||||||
|
const QString &page = QString(),
|
||||||
|
QWidget *parent = 0) = 0;
|
||||||
|
|
||||||
|
virtual IMenuManager *menuManager() const = 0;
|
||||||
|
|
||||||
|
virtual QSettings *settings() const = 0;
|
||||||
|
virtual QMainWindow *mainWindow() const = 0;
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void closeMainWindow();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Core
|
||||||
|
|
||||||
|
#endif // ICORE_H
|
|
@ -17,10 +17,10 @@
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "main_window.h"
|
#include "main_window.h"
|
||||||
#include "menu_manager.h"
|
#include "icontext.h"
|
||||||
#include "core_plugin.h"
|
|
||||||
#include "iapp_page.h"
|
|
||||||
#include "icore_listener.h"
|
#include "icore_listener.h"
|
||||||
|
#include "menu_manager.h"
|
||||||
|
#include "core.h"
|
||||||
#include "core_constants.h"
|
#include "core_constants.h"
|
||||||
#include "settings_dialog.h"
|
#include "settings_dialog.h"
|
||||||
|
|
||||||
|
@ -28,94 +28,117 @@
|
||||||
#include <nel/misc/debug.h>
|
#include <nel/misc/debug.h>
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
|
#include <QtCore/QCoreApplication>
|
||||||
#include <QtGui/QtGui>
|
#include <QtGui/QtGui>
|
||||||
|
|
||||||
namespace Core
|
namespace Core
|
||||||
{
|
{
|
||||||
|
|
||||||
CMainWindow::CMainWindow(CorePlugin *corePlugin, QWidget *parent)
|
MainWindow::MainWindow(ExtensionSystem::IPluginManager *pluginManager, QWidget *parent)
|
||||||
: QMainWindow(parent),
|
: QMainWindow(parent),
|
||||||
_pluginManager(0),
|
m_pluginManager(0),
|
||||||
_corePlugin(0),
|
m_menuManager(0),
|
||||||
_menuManager(0),
|
m_coreImpl(0),
|
||||||
_lastDir("."),
|
m_lastDir("."),
|
||||||
_settings(0)
|
m_settings(0)
|
||||||
{
|
{
|
||||||
_corePlugin = corePlugin;
|
QCoreApplication::setApplicationName(QLatin1String("ObjectViewerQt"));
|
||||||
_pluginManager = _corePlugin->pluginManager();
|
QCoreApplication::setApplicationVersion(QLatin1String(Core::Constants::OVQT_VERSION_LONG));
|
||||||
_settings = _pluginManager->settings();
|
QCoreApplication::setOrganizationName(QLatin1String("RyzomCore"));
|
||||||
|
|
||||||
setObjectName(Constants::MAIN_WINDOW);
|
setObjectName(Constants::MAIN_WINDOW);
|
||||||
|
setWindowIcon(QIcon(Constants::ICON_NEL));
|
||||||
|
setWindowTitle(tr("Object Viewer Qt"));
|
||||||
|
|
||||||
_menuManager = new MenuManager(this);
|
m_pluginManager = pluginManager;
|
||||||
_menuManager->setMenuBar(menuBar());
|
m_settings = m_pluginManager->settings();
|
||||||
_pluginManager->addObject(_menuManager);
|
m_coreImpl = new CoreImpl(this);
|
||||||
|
|
||||||
_tabWidget = new QTabWidget(this);
|
m_menuManager = new MenuManager(this);
|
||||||
_tabWidget->setTabPosition(QTabWidget::South);
|
m_menuManager->setMenuBar(menuBar());
|
||||||
setCentralWidget(_tabWidget);
|
|
||||||
|
|
||||||
QList<IAppPage *> listAppPages = _pluginManager->getObjects<IAppPage>();
|
m_tabWidget = new QTabWidget(this);
|
||||||
|
m_tabWidget->setTabPosition(QTabWidget::South);
|
||||||
Q_FOREACH(IAppPage *appPage, listAppPages)
|
setCentralWidget(m_tabWidget);
|
||||||
{
|
|
||||||
addAppPage(appPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
setDockNestingEnabled(true);
|
setDockNestingEnabled(true);
|
||||||
|
m_originalPalette = QApplication::palette();
|
||||||
_originalPalette = QApplication::palette();
|
|
||||||
|
|
||||||
createDialogs();
|
createDialogs();
|
||||||
createActions();
|
createActions();
|
||||||
createMenus();
|
createMenus();
|
||||||
createStatusBar();
|
createStatusBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
MainWindow::~MainWindow()
|
||||||
|
{
|
||||||
|
m_pluginManager->removeObject(m_coreImpl);
|
||||||
|
m_pluginManager->removeObject(m_menuManager);
|
||||||
|
|
||||||
|
delete m_coreImpl;
|
||||||
|
m_coreImpl = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MainWindow::initialize(QString *errorString)
|
||||||
|
{
|
||||||
|
Q_UNUSED(errorString);
|
||||||
|
m_pluginManager->addObject(m_coreImpl);
|
||||||
|
m_pluginManager->addObject(m_menuManager);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::extensionsInitialized()
|
||||||
|
{
|
||||||
|
QList<IContext *> listContexts = m_pluginManager->getObjects<IContext>();
|
||||||
|
|
||||||
|
Q_FOREACH(IContext *context, listContexts)
|
||||||
|
{
|
||||||
|
addContextObject(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
connect(m_pluginManager, SIGNAL(objectAdded(QObject *)), this, SLOT(checkObject(QObject *)));
|
||||||
readSettings();
|
readSettings();
|
||||||
|
show();
|
||||||
setWindowIcon(QIcon(Constants::ICON_NEL));
|
|
||||||
setWindowTitle(tr("Object Viewer Qt"));
|
|
||||||
|
|
||||||
connect(_pluginManager, SIGNAL(objectAdded(QObject *)), this, SLOT(checkObject(QObject *)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CMainWindow::~CMainWindow()
|
IMenuManager *MainWindow::menuManager() const
|
||||||
{
|
{
|
||||||
|
return m_menuManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
IMenuManager *CMainWindow::menuManager() const
|
QSettings *MainWindow::settings() const
|
||||||
{
|
{
|
||||||
return _menuManager;
|
return m_settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMainWindow::checkObject(QObject *obj)
|
void MainWindow::checkObject(QObject *obj)
|
||||||
{
|
{
|
||||||
IAppPage *appPage = qobject_cast<IAppPage *>(obj);
|
IContext *context = qobject_cast<IContext *>(obj);
|
||||||
if (appPage)
|
if (context)
|
||||||
addAppPage(appPage);
|
addContextObject(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CMainWindow::showOptionsDialog(const QString &group,
|
bool MainWindow::showOptionsDialog(const QString &group,
|
||||||
const QString &page,
|
const QString &page,
|
||||||
QWidget *parent)
|
QWidget *parent)
|
||||||
{
|
{
|
||||||
if (!parent)
|
if (!parent)
|
||||||
parent = this;
|
parent = this;
|
||||||
CSettingsDialog _settingsDialog(_corePlugin, group, page, parent);
|
CSettingsDialog settingsDialog(m_pluginManager, group, page, parent);
|
||||||
_settingsDialog.show();
|
settingsDialog.show();
|
||||||
return _settingsDialog.execDialog();
|
return settingsDialog.execDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMainWindow::about()
|
void MainWindow::about()
|
||||||
{
|
{
|
||||||
QMessageBox::about(this, tr("About Object Viewer Qt"),
|
QMessageBox::about(this, tr("About Object Viewer Qt"),
|
||||||
tr("<h2>Object Viewer Qt NG</h2>"
|
tr("<h2>Object Viewer Qt NG</h2>"
|
||||||
"<p> Author: dnk-88 <p>Compiled on %1 %2").arg(__DATE__).arg(__TIME__));
|
"<p> Author: dnk-88 <p>Compiled on %1 %2").arg(__DATE__).arg(__TIME__));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMainWindow::closeEvent(QCloseEvent *event)
|
void MainWindow::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
QList<ICoreListener *> listeners = _pluginManager->getObjects<ICoreListener>();
|
QList<ICoreListener *> listeners = m_pluginManager->getObjects<ICoreListener>();
|
||||||
Q_FOREACH(ICoreListener *listener, listeners)
|
Q_FOREACH(ICoreListener *listener, listeners)
|
||||||
{
|
{
|
||||||
if (!listener->closeMainWindow())
|
if (!listener->closeMainWindow())
|
||||||
|
@ -124,112 +147,122 @@ void CMainWindow::closeEvent(QCloseEvent *event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Q_EMIT m_coreImpl->closeMainWindow();
|
||||||
|
|
||||||
writeSettings();
|
writeSettings();
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMainWindow::addAppPage(IAppPage *appPage)
|
void MainWindow::addContextObject(IContext *context)
|
||||||
{
|
{
|
||||||
QWidget *tabWidget = new QWidget(_tabWidget);
|
QWidget *tabWidget = new QWidget(m_tabWidget);
|
||||||
_tabWidget->addTab(tabWidget, appPage->icon(), appPage->trName());
|
m_tabWidget->addTab(tabWidget, context->icon(), context->trName());
|
||||||
QGridLayout *gridLayout = new QGridLayout(tabWidget);
|
QGridLayout *gridLayout = new QGridLayout(tabWidget);
|
||||||
gridLayout->setObjectName(QString::fromUtf8("gridLayout_") + appPage->id());
|
gridLayout->setObjectName(QString::fromUtf8("gridLayout_") + context->id());
|
||||||
gridLayout->setContentsMargins(0, 0, 0, 0);
|
gridLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
gridLayout->addWidget(appPage->widget(), 0, 0, 1, 1);
|
gridLayout->addWidget(context->widget(), 0, 0, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMainWindow::createActions()
|
void MainWindow::createActions()
|
||||||
{
|
{
|
||||||
_openAction = new QAction(tr("&Open..."), this);
|
m_openAction = new QAction(tr("&Open..."), this);
|
||||||
_openAction->setIcon(QIcon(":/images/open-file.png"));
|
m_openAction->setIcon(QIcon(":/images/open-file.png"));
|
||||||
_openAction->setShortcut(QKeySequence::Open);
|
m_openAction->setShortcut(QKeySequence::Open);
|
||||||
_openAction->setStatusTip(tr("Open an existing file"));
|
m_openAction->setStatusTip(tr("Open an existing file"));
|
||||||
menuManager()->registerAction(_openAction, Constants::OPEN);
|
menuManager()->registerAction(m_openAction, Constants::OPEN);
|
||||||
// connect(_openAction, SIGNAL(triggered()), this, SLOT(open()));
|
// connect(m_openAction, SIGNAL(triggered()), this, SLOT(open()));
|
||||||
|
|
||||||
_exitAction = new QAction(tr("E&xit"), this);
|
m_exitAction = new QAction(tr("E&xit"), this);
|
||||||
_exitAction->setShortcut(tr("Ctrl+Q"));
|
m_exitAction->setShortcut(QKeySequence(tr("Ctrl+Q")));
|
||||||
_exitAction->setStatusTip(tr("Exit the application"));
|
m_exitAction->setStatusTip(tr("Exit the application"));
|
||||||
menuManager()->registerAction(_exitAction, Constants::EXIT);
|
menuManager()->registerAction(m_exitAction, Constants::EXIT);
|
||||||
connect(_exitAction, SIGNAL(triggered()), this, SLOT(close()));
|
connect(m_exitAction, SIGNAL(triggered()), this, SLOT(close()));
|
||||||
|
|
||||||
_settingsAction = new QAction(tr("&Settings"), this);
|
m_settingsAction = new QAction(tr("&Settings"), this);
|
||||||
_settingsAction->setIcon(QIcon(":/images/preferences.png"));
|
m_settingsAction->setIcon(QIcon(":/images/preferences.png"));
|
||||||
_settingsAction->setStatusTip(tr("Open the settings dialog"));
|
m_settingsAction->setShortcut(QKeySequence::Preferences);
|
||||||
menuManager()->registerAction(_settingsAction, Constants::SETTINGS);
|
m_settingsAction->setStatusTip(tr("Open the settings dialog"));
|
||||||
connect(_settingsAction, SIGNAL(triggered()), this, SLOT(showOptionsDialog()));
|
menuManager()->registerAction(m_settingsAction, Constants::SETTINGS);
|
||||||
|
connect(m_settingsAction, SIGNAL(triggered()), this, SLOT(showOptionsDialog()));
|
||||||
|
|
||||||
_aboutAction = new QAction(tr("&About"), this);
|
m_aboutAction = new QAction(tr("&About"), this);
|
||||||
_aboutAction->setStatusTip(tr("Show the application's About box"));
|
m_aboutAction->setStatusTip(tr("Show the application's About box"));
|
||||||
menuManager()->registerAction(_aboutAction, Constants::ABOUT);
|
menuManager()->registerAction(m_aboutAction, Constants::ABOUT);
|
||||||
connect(_aboutAction, SIGNAL(triggered()), this, SLOT(about()));
|
connect(m_aboutAction, SIGNAL(triggered()), this, SLOT(about()));
|
||||||
|
|
||||||
_aboutQtAction = new QAction(tr("About &Qt"), this);
|
m_aboutQtAction = new QAction(tr("About &Qt"), this);
|
||||||
_aboutQtAction->setStatusTip(tr("Show the Qt library's About box"));
|
m_aboutQtAction->setStatusTip(tr("Show the Qt library's About box"));
|
||||||
menuManager()->registerAction(_aboutQtAction, Constants::ABOUT_QT);
|
menuManager()->registerAction(m_aboutQtAction, Constants::ABOUT_QT);
|
||||||
connect(_aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
|
connect(m_aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
|
||||||
|
|
||||||
_pluginViewAction = new QAction(tr("About &Plugins"), this);
|
m_pluginViewAction = new QAction(tr("About &Plugins"), this);
|
||||||
_pluginViewAction->setStatusTip(tr("Show the plugin view dialog"));
|
m_pluginViewAction->setStatusTip(tr("Show the plugin view dialog"));
|
||||||
menuManager()->registerAction(_pluginViewAction, Constants::ABOUT_PLUGINS);
|
menuManager()->registerAction(m_pluginViewAction, Constants::ABOUT_PLUGINS);
|
||||||
connect(_pluginViewAction, SIGNAL(triggered()), _pluginView, SLOT(show()));
|
connect(m_pluginViewAction, SIGNAL(triggered()), m_pluginView, SLOT(show()));
|
||||||
|
|
||||||
|
#ifdef Q_WS_MAC
|
||||||
|
m_exitAction->setMenuRole(QAction::QuitRole);
|
||||||
|
m_settingsAction->setMenuRole(QAction::PreferencesRole);
|
||||||
|
m_aboutAction->setMenuRole(QAction::AboutRole);
|
||||||
|
m_aboutQtAction->setMenuRole(QAction::AboutQtRole);
|
||||||
|
m_pluginViewAction->setMenuRole(QAction::ApplicationSpecificRole);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMainWindow::createMenus()
|
void MainWindow::createMenus()
|
||||||
{
|
{
|
||||||
_fileMenu = menuBar()->addMenu(tr("&File"));
|
m_fileMenu = menuBar()->addMenu(tr("&File"));
|
||||||
menuManager()->registerMenu(_fileMenu, Constants::M_FILE);
|
menuManager()->registerMenu(m_fileMenu, Constants::M_FILE);
|
||||||
_fileMenu->addSeparator();
|
m_fileMenu->addSeparator();
|
||||||
_fileMenu->addAction(_exitAction);
|
m_fileMenu->addAction(m_exitAction);
|
||||||
|
|
||||||
_editMenu = menuBar()->addMenu(tr("&Edit"));
|
m_editMenu = menuBar()->addMenu(tr("&Edit"));
|
||||||
menuManager()->registerMenu(_editMenu, Constants::M_EDIT);
|
menuManager()->registerMenu(m_editMenu, Constants::M_EDIT);
|
||||||
|
|
||||||
_viewMenu = menuBar()->addMenu(tr("&View"));
|
m_viewMenu = menuBar()->addMenu(tr("&View"));
|
||||||
menuManager()->registerMenu(_viewMenu, Constants::M_VIEW);
|
menuManager()->registerMenu(m_viewMenu, Constants::M_VIEW);
|
||||||
|
|
||||||
_toolsMenu = menuBar()->addMenu(tr("&Tools"));
|
m_toolsMenu = menuBar()->addMenu(tr("&Tools"));
|
||||||
menuManager()->registerMenu(_toolsMenu, Constants::M_TOOLS);
|
menuManager()->registerMenu(m_toolsMenu, Constants::M_TOOLS);
|
||||||
|
|
||||||
|
|
||||||
_toolsMenu->addSeparator();
|
m_toolsMenu->addSeparator();
|
||||||
|
|
||||||
_toolsMenu->addAction(_settingsAction);
|
m_toolsMenu->addAction(m_settingsAction);
|
||||||
|
|
||||||
menuBar()->addSeparator();
|
menuBar()->addSeparator();
|
||||||
|
|
||||||
_helpMenu = menuBar()->addMenu(tr("&Help"));
|
m_helpMenu = menuBar()->addMenu(tr("&Help"));
|
||||||
menuManager()->registerMenu(_helpMenu, Constants::M_HELP);
|
menuManager()->registerMenu(m_helpMenu, Constants::M_HELP);
|
||||||
_helpMenu->addAction(_aboutAction);
|
m_helpMenu->addAction(m_aboutAction);
|
||||||
_helpMenu->addAction(_aboutQtAction);
|
m_helpMenu->addAction(m_aboutQtAction);
|
||||||
_helpMenu->addAction(_pluginViewAction);
|
m_helpMenu->addAction(m_pluginViewAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMainWindow::createStatusBar()
|
void MainWindow::createStatusBar()
|
||||||
{
|
{
|
||||||
statusBar()->showMessage(tr("StatusReady"));
|
statusBar()->showMessage(tr("StatusReady"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMainWindow::createDialogs()
|
void MainWindow::createDialogs()
|
||||||
{
|
{
|
||||||
_pluginView = new ExtensionSystem::CPluginView(_pluginManager, this);
|
m_pluginView = new ExtensionSystem::CPluginView(m_pluginManager, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMainWindow::readSettings()
|
void MainWindow::readSettings()
|
||||||
{
|
{
|
||||||
_settings->beginGroup("MainWindowSettings");
|
m_settings->beginGroup("MainWindow");
|
||||||
restoreState(_settings->value("QtWindowState").toByteArray());
|
restoreState(m_settings->value("WindowState").toByteArray());
|
||||||
restoreGeometry(_settings->value("QtWindowGeometry").toByteArray());
|
restoreGeometry(m_settings->value("WindowGeometry").toByteArray());
|
||||||
_settings->endGroup();
|
m_settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMainWindow::writeSettings()
|
void MainWindow::writeSettings()
|
||||||
{
|
{
|
||||||
_settings->beginGroup("MainWindowSettings");
|
m_settings->beginGroup("MainWindow");
|
||||||
_settings->setValue("QtWindowState", saveState());
|
m_settings->setValue("WindowState", saveState());
|
||||||
_settings->setValue("QtWindowGeometry", saveGeometry());
|
m_settings->setValue("WindowGeometry", saveGeometry());
|
||||||
_settings->endGroup();
|
m_settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace Core */
|
} /* namespace Core */
|
||||||
|
|
|
@ -32,31 +32,39 @@ namespace Core
|
||||||
{
|
{
|
||||||
class CSettingsDialog;
|
class CSettingsDialog;
|
||||||
class CorePlugin;
|
class CorePlugin;
|
||||||
class IAppPage;
|
class IContext;
|
||||||
class IMenuManager;
|
class IMenuManager;
|
||||||
class MenuManager;
|
class MenuManager;
|
||||||
|
class CoreImpl;
|
||||||
|
|
||||||
class CMainWindow : public QMainWindow
|
class MainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CMainWindow(CorePlugin *corePlugin, QWidget *parent = 0);
|
MainWindow(ExtensionSystem::IPluginManager *pluginManager, QWidget *parent = 0);
|
||||||
~CMainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
|
bool initialize(QString *errorString);
|
||||||
|
void extensionsInitialized();
|
||||||
|
|
||||||
IMenuManager *menuManager() const;
|
IMenuManager *menuManager() const;
|
||||||
|
QSettings *settings() const;
|
||||||
|
|
||||||
private Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void checkObject(QObject *obj);
|
|
||||||
bool showOptionsDialog(const QString &group = QString(),
|
bool showOptionsDialog(const QString &group = QString(),
|
||||||
const QString &page = QString(),
|
const QString &page = QString(),
|
||||||
QWidget *parent = 0);
|
QWidget *parent = 0);
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void checkObject(QObject *obj);
|
||||||
void about();
|
void about();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void closeEvent(QCloseEvent *event);
|
virtual void closeEvent(QCloseEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addAppPage(IAppPage *appPage);
|
void addContextObject(IContext *appPage);
|
||||||
|
|
||||||
void createActions();
|
void createActions();
|
||||||
void createMenus();
|
void createMenus();
|
||||||
|
@ -66,35 +74,35 @@ private:
|
||||||
void readSettings();
|
void readSettings();
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
|
|
||||||
ExtensionSystem::IPluginManager *_pluginManager;
|
ExtensionSystem::IPluginManager *m_pluginManager;
|
||||||
ExtensionSystem::CPluginView *_pluginView;
|
ExtensionSystem::CPluginView *m_pluginView;
|
||||||
CorePlugin *_corePlugin;
|
MenuManager *m_menuManager;
|
||||||
MenuManager *_menuManager;
|
CoreImpl *m_coreImpl;
|
||||||
|
|
||||||
QPalette _originalPalette;
|
QPalette m_originalPalette;
|
||||||
QString _lastDir;
|
QString m_lastDir;
|
||||||
|
|
||||||
QSettings *_settings;
|
QSettings *m_settings;
|
||||||
|
|
||||||
QTimer *_mainTimer;
|
QTimer *m_mainTimer;
|
||||||
QTimer *_statusBarTimer;
|
QTimer *m_statusBarTimer;
|
||||||
|
|
||||||
QTabWidget *_tabWidget;
|
QTabWidget *m_tabWidget;
|
||||||
|
|
||||||
QMenu *_fileMenu;
|
QMenu *m_fileMenu;
|
||||||
QMenu *_editMenu;
|
QMenu *m_editMenu;
|
||||||
QMenu *_viewMenu;
|
QMenu *m_viewMenu;
|
||||||
QMenu *_toolsMenu;
|
QMenu *m_toolsMenu;
|
||||||
QMenu *_helpMenu;
|
QMenu *m_helpMenu;
|
||||||
|
|
||||||
QAction *_openAction;
|
QAction *m_openAction;
|
||||||
QAction *_exitAction;
|
QAction *m_exitAction;
|
||||||
QAction *_settingsAction;
|
QAction *m_settingsAction;
|
||||||
QAction *_pluginViewAction;
|
QAction *m_pluginViewAction;
|
||||||
QAction *_aboutAction;
|
QAction *m_aboutAction;
|
||||||
QAction *_aboutQtAction;
|
QAction *m_aboutQtAction;
|
||||||
|
|
||||||
};/* class CMainWindow */
|
};/* class MainWindow */
|
||||||
|
|
||||||
} /* namespace Core */
|
} /* namespace Core */
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "settings_dialog.h"
|
#include "settings_dialog.h"
|
||||||
#include "core_plugin.h"
|
|
||||||
#include "ioptions_page.h"
|
#include "ioptions_page.h"
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
|
@ -36,7 +35,7 @@ Q_DECLARE_METATYPE(PageData);
|
||||||
|
|
||||||
namespace Core
|
namespace Core
|
||||||
{
|
{
|
||||||
CSettingsDialog::CSettingsDialog(CorePlugin *corePlugin,
|
CSettingsDialog::CSettingsDialog(ExtensionSystem::IPluginManager *pluginManager,
|
||||||
const QString &categoryId,
|
const QString &categoryId,
|
||||||
const QString &pageId,
|
const QString &pageId,
|
||||||
QWidget *parent)
|
QWidget *parent)
|
||||||
|
@ -45,7 +44,7 @@ CSettingsDialog::CSettingsDialog(CorePlugin *corePlugin,
|
||||||
{
|
{
|
||||||
_ui.setupUi(this);
|
_ui.setupUi(this);
|
||||||
|
|
||||||
_plugMan = corePlugin->pluginManager();
|
_plugMan = pluginManager;
|
||||||
|
|
||||||
QString initialCategory = categoryId;
|
QString initialCategory = categoryId;
|
||||||
QString initialPage = pageId;
|
QString initialPage = pageId;
|
||||||
|
|
|
@ -25,11 +25,10 @@
|
||||||
#include <QtCore/QList>
|
#include <QtCore/QList>
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "../../extension_system/iplugin.h"
|
#include "../../extension_system/iplugin_manager.h"
|
||||||
|
|
||||||
namespace Core
|
namespace Core
|
||||||
{
|
{
|
||||||
class CorePlugin;
|
|
||||||
class IOptionsPage;
|
class IOptionsPage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,7 +40,7 @@ class CSettingsDialog: public QDialog
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CSettingsDialog(CorePlugin *corePlugin,
|
CSettingsDialog(ExtensionSystem::IPluginManager *pluginManager,
|
||||||
const QString &initialCategory = QString(),
|
const QString &initialCategory = QString(),
|
||||||
const QString &initialPage = QString(),
|
const QString &initialPage = QString(),
|
||||||
QWidget *parent = 0);
|
QWidget *parent = 0);
|
||||||
|
|
|
@ -12,8 +12,7 @@ SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.
|
||||||
SET(OVQT_PLUG_EXAMPLE_HDR plugin1.h
|
SET(OVQT_PLUG_EXAMPLE_HDR plugin1.h
|
||||||
qnel_widget.h
|
qnel_widget.h
|
||||||
simple_viewer.h
|
simple_viewer.h
|
||||||
example_settings_page.h
|
example_settings_page.h)
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/../core/iapp_page.h)
|
|
||||||
|
|
||||||
SET(OVQT_PLUG_EXAMPLE_UIS example_settings_page.ui)
|
SET(OVQT_PLUG_EXAMPLE_UIS example_settings_page.ui)
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "plugin1.h"
|
#include "plugin1.h"
|
||||||
#include "example_settings_page.h"
|
#include "example_settings_page.h"
|
||||||
#include "simple_viewer.h"
|
#include "simple_viewer.h"
|
||||||
#include "../core/iapp_page.h"
|
#include "../core/icore.h"
|
||||||
#include "../core/core_constants.h"
|
#include "../core/core_constants.h"
|
||||||
#include "../core/imenu_manager.h"
|
#include "../core/imenu_manager.h"
|
||||||
#include "../../extension_system/iplugin_spec.h"
|
#include "../../extension_system/iplugin_spec.h"
|
||||||
|
@ -36,19 +36,20 @@ bool MyPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QStrin
|
||||||
_plugMan = pluginManager;
|
_plugMan = pluginManager;
|
||||||
|
|
||||||
addAutoReleasedObject(new CExampleSettingsPage(this));
|
addAutoReleasedObject(new CExampleSettingsPage(this));
|
||||||
addAutoReleasedObject(new CExampleAppPage(this));
|
addAutoReleasedObject(new CExampleContext(this));
|
||||||
addAutoReleasedObject(new CCoreListener(this));
|
addAutoReleasedObject(new CCoreListener(this));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyPlugin::extensionsInitialized()
|
void MyPlugin::extensionsInitialized()
|
||||||
{
|
{
|
||||||
Core::IMenuManager *menuManager = 0;
|
Core::ICore *core = Core::ICore::instance();
|
||||||
menuManager = _plugMan->getObject<Core::IMenuManager>();
|
if (core == 0)
|
||||||
if (menuManager == 0)
|
nlinfo("This not ovqt ng");
|
||||||
nlinfo("error menu manager");
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Core::IMenuManager *menuManager = core->menuManager();
|
||||||
|
//menuManager = _plugMan->getObject<Core::IMenuManager>();
|
||||||
QAction *exampleAction1 = new QAction("Example1", this);
|
QAction *exampleAction1 = new QAction("Example1", this);
|
||||||
QAction *exampleAction2 = new QAction("Example2", this);
|
QAction *exampleAction2 = new QAction("Example2", this);
|
||||||
QAction *aboutQtAction = menuManager->action(Core::Constants::ABOUT_QT);
|
QAction *aboutQtAction = menuManager->action(Core::Constants::ABOUT_QT);
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "../../extension_system/iplugin.h"
|
#include "../../extension_system/iplugin.h"
|
||||||
|
#include "../core/icontext.h"
|
||||||
#include "simple_viewer.h"
|
#include "simple_viewer.h"
|
||||||
#include "../core/iapp_page.h"
|
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include "nel/misc/app_context.h"
|
#include "nel/misc/app_context.h"
|
||||||
|
@ -58,17 +58,16 @@ private:
|
||||||
QList<QObject *> _autoReleaseObjects;
|
QList<QObject *> _autoReleaseObjects;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CExampleAppPage: public QObject, public Core::IAppPage
|
class CExampleContext: public Core::IContext
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_INTERFACES(Core::IAppPage)
|
|
||||||
public:
|
public:
|
||||||
CExampleAppPage(QObject *parent = 0): QObject(parent) {}
|
CExampleContext(QObject *parent = 0): IContext(parent) {}
|
||||||
virtual ~CExampleAppPage() {}
|
virtual ~CExampleContext() {}
|
||||||
|
|
||||||
virtual QString id() const
|
virtual QString id() const
|
||||||
{
|
{
|
||||||
return QLatin1String("ExampleAppPage");
|
return QLatin1String("ExampleContext");
|
||||||
}
|
}
|
||||||
virtual QString trName() const
|
virtual QString trName() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,16 +34,16 @@ namespace NLQT
|
||||||
|
|
||||||
QNLWidget::QNLWidget(QWidget *parent)
|
QNLWidget::QNLWidget(QWidget *parent)
|
||||||
: QWidget(parent),
|
: QWidget(parent),
|
||||||
_driver(NULL),
|
m_driver(NULL),
|
||||||
_initialized(false),
|
m_initialized(false),
|
||||||
_interval(25)
|
m_interval(25)
|
||||||
{
|
{
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
setFocusPolicy(Qt::StrongFocus);
|
setFocusPolicy(Qt::StrongFocus);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
_mainTimer = new QTimer(this);
|
m_mainTimer = new QTimer(this);
|
||||||
connect(_mainTimer, SIGNAL(timeout()), this, SLOT(updateRender()));
|
connect(m_mainTimer, SIGNAL(timeout()), this, SLOT(updateRender()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QNLWidget::~QNLWidget()
|
QNLWidget::~QNLWidget()
|
||||||
|
@ -54,49 +54,59 @@ QNLWidget::~QNLWidget()
|
||||||
void QNLWidget::init()
|
void QNLWidget::init()
|
||||||
{
|
{
|
||||||
// create the driver
|
// create the driver
|
||||||
_driver = NL3D::UDriver::createDriver(NULL, false, NULL);
|
m_driver = NL3D::UDriver::createDriver(NULL, false, NULL);
|
||||||
nlassert(_driver);
|
nlassert(m_driver);
|
||||||
|
|
||||||
// initialize the nel 3d viewport
|
// initialize the nel 3d viewport
|
||||||
_driver->setDisplay((nlWindow)winId(), NL3D::UDriver::CMode(width(), height(), 32));
|
m_driver->setDisplay((nlWindow)winId(), NL3D::UDriver::CMode(width(), height(), 32));
|
||||||
|
|
||||||
// set the cache size for the font manager(in bytes)
|
// set the cache size for the font manager(in bytes)
|
||||||
_driver->setFontManagerMaxMemory(2097152);
|
m_driver->setFontManagerMaxMemory(2097152);
|
||||||
|
|
||||||
_initialized = true;
|
m_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QNLWidget::release()
|
void QNLWidget::release()
|
||||||
{
|
{
|
||||||
_mainTimer->stop();
|
m_mainTimer->stop();
|
||||||
delete _mainTimer;
|
delete m_mainTimer;
|
||||||
if (_initialized)
|
if (m_initialized)
|
||||||
{
|
{
|
||||||
_driver->release();
|
m_driver->release();
|
||||||
delete _driver;
|
delete m_driver;
|
||||||
_driver = NULL;
|
m_driver = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QNLWidget::setInterval(int msec)
|
void QNLWidget::setInterval(int msec)
|
||||||
{
|
{
|
||||||
_interval = msec;
|
m_interval = msec;
|
||||||
_mainTimer->setInterval(msec);
|
m_mainTimer->setInterval(msec);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QNLWidget::updateRender()
|
void QNLWidget::updateRender()
|
||||||
{
|
{
|
||||||
if (isVisible())
|
if (isVisible())
|
||||||
{
|
{
|
||||||
if (_initialized)
|
if (m_initialized)
|
||||||
_driver->EventServer.pump();
|
m_driver->EventServer.pump();
|
||||||
if (_initialized && !_driver->isLost())
|
Q_EMIT updateData();
|
||||||
{
|
|
||||||
_driver->activate();
|
|
||||||
_driver->clearBuffers(NLMISC::CRGBA(125,12,58));
|
|
||||||
|
|
||||||
|
// Calc FPS
|
||||||
|
static sint64 lastTime = NLMISC::CTime::getPerformanceTime ();
|
||||||
|
sint64 newTime = NLMISC::CTime::getPerformanceTime ();
|
||||||
|
m_fps = float(1.0 / NLMISC::CTime::ticksToSecond (newTime-lastTime));
|
||||||
|
lastTime = newTime;
|
||||||
|
|
||||||
|
if (m_initialized && !m_driver->isLost())
|
||||||
|
{
|
||||||
|
//_driver->activate();
|
||||||
|
m_driver->clearBuffers(NLMISC::CRGBA(125,12,58));
|
||||||
|
Q_EMIT updatePreRender();
|
||||||
|
|
||||||
|
Q_EMIT updatePostRender();
|
||||||
// swap 3d buffers
|
// swap 3d buffers
|
||||||
_driver->swapBuffers();
|
m_driver->swapBuffers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,11 +116,11 @@ void QNLWidget::showEvent(QShowEvent *showEvent)
|
||||||
QWidget::showEvent(showEvent);
|
QWidget::showEvent(showEvent);
|
||||||
if (isVisible())
|
if (isVisible())
|
||||||
{
|
{
|
||||||
_driver->activate();
|
m_driver->activate();
|
||||||
_mainTimer->start(_interval);
|
m_mainTimer->start(m_interval);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_mainTimer->stop();
|
m_mainTimer->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(NL_OS_WINDOWS)
|
#if defined(NL_OS_WINDOWS)
|
||||||
|
@ -119,9 +129,9 @@ typedef bool (*winProc)(NL3D::IDriver *driver, HWND hWnd, UINT message, WPARAM w
|
||||||
|
|
||||||
bool QNLWidget::winEvent(MSG *message, long *result)
|
bool QNLWidget::winEvent(MSG *message, long *result)
|
||||||
{
|
{
|
||||||
if (_driver && _driver->isActive())
|
if (m_driver && m_driver->isActive())
|
||||||
{
|
{
|
||||||
NL3D::IDriver *driver = dynamic_cast<NL3D::CDriverUser *>(_driver)->getDriver();
|
NL3D::IDriver *driver = dynamic_cast<NL3D::CDriverUser *>(m_driver)->getDriver();
|
||||||
if (driver)
|
if (driver)
|
||||||
{
|
{
|
||||||
winProc proc = (winProc)driver->getWindowProc();
|
winProc proc = (winProc)driver->getWindowProc();
|
||||||
|
@ -141,9 +151,9 @@ bool QNLWidget::macEvent(EventHandlerCallRef caller, EventRef event)
|
||||||
if(caller)
|
if(caller)
|
||||||
nlerror("You are using QtCarbon! Only QtCocoa supported, please upgrade Qt");
|
nlerror("You are using QtCarbon! Only QtCocoa supported, please upgrade Qt");
|
||||||
|
|
||||||
if (_driver && _driver->isActive())
|
if (m_driver && m_driver->isActive())
|
||||||
{
|
{
|
||||||
NL3D::IDriver *driver = dynamic_cast<NL3D::CDriverUser *>(_driver)->getDriver();
|
NL3D::IDriver *driver = dynamic_cast<NL3D::CDriverUser *>(m_driver)->getDriver();
|
||||||
if (driver)
|
if (driver)
|
||||||
{
|
{
|
||||||
cocoaProc proc = (cocoaProc)driver->getWindowProc();
|
cocoaProc proc = (cocoaProc)driver->getWindowProc();
|
||||||
|
@ -160,9 +170,9 @@ typedef bool (*x11Proc)(NL3D::IDriver *drv, XEvent *e);
|
||||||
|
|
||||||
bool QNLWidget::x11Event(XEvent *event)
|
bool QNLWidget::x11Event(XEvent *event)
|
||||||
{
|
{
|
||||||
if (_driver && _driver->isActive())
|
if (m_driver && m_driver->isActive())
|
||||||
{
|
{
|
||||||
NL3D::IDriver *driver = dynamic_cast<NL3D::CDriverUser *>(_driver)->getDriver();
|
NL3D::IDriver *driver = dynamic_cast<NL3D::CDriverUser *>(m_driver)->getDriver();
|
||||||
if (driver)
|
if (driver)
|
||||||
{
|
{
|
||||||
x11Proc proc = (x11Proc)driver->getWindowProc();
|
x11Proc proc = (x11Proc)driver->getWindowProc();
|
||||||
|
|
|
@ -54,10 +54,19 @@ public:
|
||||||
/// Set the update interval renderer
|
/// Set the update interval renderer
|
||||||
void setInterval(int msec);
|
void setInterval(int msec);
|
||||||
|
|
||||||
|
float getFPS() const
|
||||||
|
{
|
||||||
|
return m_fps;
|
||||||
|
}
|
||||||
|
|
||||||
virtual QPaintEngine* paintEngine() const
|
virtual QPaintEngine* paintEngine() const
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Q_SIGNALS:
|
||||||
|
void updateData();
|
||||||
|
void updatePreRender();
|
||||||
|
void updatePostRender();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void updateRender();
|
void updateRender();
|
||||||
|
@ -80,10 +89,11 @@ private:
|
||||||
QNLWidget(const QNLWidget &);
|
QNLWidget(const QNLWidget &);
|
||||||
QNLWidget &operator=(const QNLWidget &);
|
QNLWidget &operator=(const QNLWidget &);
|
||||||
|
|
||||||
NL3D::UDriver *_driver;
|
NL3D::UDriver *m_driver;
|
||||||
QTimer *_mainTimer;
|
QTimer *m_mainTimer;
|
||||||
bool _initialized;
|
bool m_initialized;
|
||||||
int _interval;
|
int m_interval;
|
||||||
|
float m_fps;
|
||||||
|
|
||||||
}; /* class QNLWidget */
|
}; /* class QNLWidget */
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,7 @@ SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h)
|
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h)
|
||||||
|
|
||||||
SET(OVQT_PLUG_LOG_HDR log_plugin.h
|
SET(OVQT_PLUG_LOG_HDR log_plugin.h
|
||||||
log_settings_page.h
|
log_settings_page.h)
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/../core/iapp_page.h)
|
|
||||||
|
|
||||||
SET(OVQT_PLUG_LOG_UIS log_form.ui
|
SET(OVQT_PLUG_LOG_UIS log_form.ui
|
||||||
log_settings_page.ui)
|
log_settings_page.ui)
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue