Changed: #1206 Update core and example plugin. Update camera control panel.
This commit is contained in:
parent
a354581b61
commit
32bb83eb4f
16 changed files with 498 additions and 102 deletions
|
@ -52,6 +52,7 @@ CCameraItem::CCameraItem(const QString &name):
|
|||
|
||||
CCameraItem::~CCameraItem()
|
||||
{
|
||||
Modules::objView().getScene()->deleteCamera(_camera);
|
||||
}
|
||||
|
||||
void CCameraItem::setActive(bool active)
|
||||
|
@ -182,6 +183,9 @@ CCameraControl::CCameraControl(QWidget *parent)
|
|||
|
||||
CCameraControl::~CCameraControl()
|
||||
{
|
||||
for(int i = 0; i < _cameraList.size(); ++i)
|
||||
delete _cameraList[i];
|
||||
_cameraList.clear();
|
||||
}
|
||||
|
||||
void CCameraControl::setEditMode()
|
||||
|
|
|
@ -145,6 +145,7 @@ CMainWindow::~CMainWindow()
|
|||
delete _TuneTimerDialog;
|
||||
delete _ParticleControlDialog;
|
||||
delete _ParticleWorkspaceDialog;
|
||||
delete _cameraControl;
|
||||
|
||||
if (_isSoundInitialized)
|
||||
Modules::sound().releaseGraphics();
|
||||
|
|
|
@ -12,7 +12,6 @@ SET(OVQT_CORE_PLUGIN_HDR
|
|||
core_plugin.h
|
||||
main_window.h
|
||||
settings_dialog.h
|
||||
qnel_widget.h
|
||||
search_paths_settings_page.h
|
||||
plugin_view_dialog.h)
|
||||
|
||||
|
@ -37,7 +36,7 @@ SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC})
|
|||
|
||||
ADD_LIBRARY(ovqt_plugin_core MODULE ${SRC} ${OVQT_CORE_PLUGIN_MOC_SRC} ${OVQT_EXT_SYS_SRC} ${OVQT_CORE_PLUGIN_RC_SRCS} ${OVQT_CORE_PLUGIN_UI_HDRS})
|
||||
|
||||
TARGET_LINK_LIBRARIES(ovqt_plugin_core nelmisc nel3d ${QT_LIBRARIES})
|
||||
TARGET_LINK_LIBRARIES(ovqt_plugin_core nelmisc ${QT_LIBRARIES})
|
||||
|
||||
NL_DEFAULT_PROPS(ovqt_plugin_core "NeL, Tools, 3D: Object Viewer Qt Plugin: Core")
|
||||
NL_ADD_RUNTIME_FLAGS(ovqt_plugin_core)
|
||||
|
|
|
@ -15,8 +15,18 @@
|
|||
// 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/>.
|
||||
|
||||
// Project includes
|
||||
#include "core_plugin.h"
|
||||
#include "settings_dialog.h"
|
||||
#include "core_constants.h"
|
||||
#include "search_paths_settings_page.h"
|
||||
#include "../../extension_system/iplugin_spec.h"
|
||||
#include "qtwin.h"
|
||||
|
||||
// NeL includes
|
||||
#include "nel/misc/debug.h"
|
||||
|
||||
// Qt includes
|
||||
#include <QtCore/QObject>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QMainWindow>
|
||||
|
@ -24,13 +34,6 @@
|
|||
#include <QtGui/QAction>
|
||||
#include <QtGui/QMenuBar>
|
||||
|
||||
#include "../../extension_system/iplugin_spec.h"
|
||||
|
||||
#include "settings_dialog.h"
|
||||
#include "core_constants.h"
|
||||
#include "search_paths_settings_page.h"
|
||||
#include "nel/misc/debug.h"
|
||||
|
||||
using namespace Core;
|
||||
|
||||
bool CorePlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString)
|
||||
|
@ -45,8 +48,6 @@ bool CorePlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QStr
|
|||
return false;
|
||||
}
|
||||
|
||||
//_mainWindow = new CMainWindow(_plugMan);
|
||||
//_mainWindow->show();
|
||||
_plugMan->addObject(new CSearchPathsSettingsPage(wnd));
|
||||
return true;
|
||||
}
|
||||
|
@ -67,11 +68,30 @@ void CorePlugin::extensionsInitialized()
|
|||
|
||||
connect(newAction, SIGNAL(triggered()), this, SLOT(execSettings()));
|
||||
connect(newAction2, SIGNAL(triggered()), _pluginView, SLOT(show()));
|
||||
|
||||
_mainWindow = new CMainWindow(_plugMan);
|
||||
#ifdef Q_WS_X11
|
||||
_mainWindow->setAttribute(Qt::WA_TranslucentBackground);
|
||||
_mainWindow->setAttribute(Qt::WA_NoSystemBackground, false);
|
||||
QPalette pal = _mainWindow->palette();
|
||||
QColor bg = pal.window().color();
|
||||
bg.setAlpha(180);
|
||||
pal.setColor(QPalette::Window, bg);
|
||||
_mainWindow->setPalette(pal);
|
||||
_mainWindow->ensurePolished(); // workaround Oxygen filling the background
|
||||
_mainWindow->setAttribute(Qt::WA_StyledBackground, false);
|
||||
#endif
|
||||
if (QtWin::isCompositionEnabled())
|
||||
{
|
||||
QtWin::extendFrameIntoClientArea(_mainWindow);
|
||||
_mainWindow->setContentsMargins(0, 0, 0, 0);
|
||||
}
|
||||
_mainWindow->show();
|
||||
}
|
||||
|
||||
void CorePlugin::shutdown()
|
||||
{
|
||||
//delete _mainWindow;
|
||||
delete _mainWindow;
|
||||
delete _pluginView;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
virtual QIcon icon() const = 0;
|
||||
|
||||
/// The widget will be destroyed by the widget hierarchy when the main window closes
|
||||
virtual QWidget *widget(QWidget *parent) = 0;
|
||||
virtual QWidget *widget() = 0;
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
|
|
@ -38,6 +38,7 @@ CMainWindow::CMainWindow(ExtensionSystem::IPluginManager *pluginManager, QWidget
|
|||
setObjectName(Constants::MAIN_WINDOW);
|
||||
|
||||
_tabWidget = new QTabWidget(this);
|
||||
_tabWidget->setTabPosition(QTabWidget::South);
|
||||
setCentralWidget(_tabWidget);
|
||||
|
||||
QList<QObject *> listObjects = _pluginManager->allObjects();
|
||||
|
@ -56,7 +57,7 @@ CMainWindow::CMainWindow(ExtensionSystem::IPluginManager *pluginManager, QWidget
|
|||
QGridLayout *gridLayout = new QGridLayout(tabWidget);
|
||||
gridLayout->setObjectName(QString::fromUtf8("gridLayout_") + appPage->id());
|
||||
gridLayout->setContentsMargins(0, 0, 0, 0);
|
||||
gridLayout->addWidget(appPage->widget(tabWidget), 0, 0, 1, 1);
|
||||
gridLayout->addWidget(appPage->widget(), 0, 0, 1, 1);
|
||||
}
|
||||
|
||||
setDockNestingEnabled(true);
|
||||
|
|
|
@ -18,17 +18,16 @@
|
|||
#ifndef MAIN_WINDOW_H
|
||||
#define MAIN_WINDOW_H
|
||||
|
||||
// Project includes
|
||||
#include "../../extension_system/iplugin.h"
|
||||
#include "plugin_view_dialog.h"
|
||||
|
||||
// STL includes
|
||||
|
||||
// Qt includes
|
||||
#include <QtGui/QMainWindow>
|
||||
#include <QtCore/QSettings>
|
||||
|
||||
// Project includes
|
||||
#include "qnel_widget.h"
|
||||
#include "../../extension_system/iplugin.h"
|
||||
#include "plugin_view_dialog.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class CSettingsDialog;
|
||||
|
|
241
code/nel/tools/3d/object_viewer_qt/src/plugins/core/qtwin.cpp
Normal file
241
code/nel/tools/3d/object_viewer_qt/src/plugins/core/qtwin.cpp
Normal file
|
@ -0,0 +1,241 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Use, modification and distribution is allowed without limitation,
|
||||
** warranty, liability or support of any kind.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qtwin.h"
|
||||
#include <QLibrary>
|
||||
#include <QApplication>
|
||||
#include <QWidget>
|
||||
#include <QList>
|
||||
#include <QPointer>
|
||||
|
||||
#ifdef Q_WS_WIN
|
||||
|
||||
#include <qt_windows.h>
|
||||
|
||||
// Blur behind data structures
|
||||
#define DWM_BB_ENABLE 0x00000001 // fEnable has been specified
|
||||
#define DWM_BB_BLURREGION 0x00000002 // hRgnBlur has been specified
|
||||
#define DWM_BB_TRANSITIONONMAXIMIZED 0x00000004 // fTransitionOnMaximized has been specified
|
||||
#define WM_DWMCOMPOSITIONCHANGED 0x031E // Composition changed window message
|
||||
|
||||
typedef struct _DWM_BLURBEHIND
|
||||
{
|
||||
DWORD dwFlags;
|
||||
BOOL fEnable;
|
||||
HRGN hRgnBlur;
|
||||
BOOL fTransitionOnMaximized;
|
||||
} DWM_BLURBEHIND, *PDWM_BLURBEHIND;
|
||||
|
||||
typedef struct _MARGINS
|
||||
{
|
||||
int cxLeftWidth;
|
||||
int cxRightWidth;
|
||||
int cyTopHeight;
|
||||
int cyBottomHeight;
|
||||
} MARGINS, *PMARGINS;
|
||||
|
||||
typedef HRESULT (WINAPI *PtrDwmIsCompositionEnabled)(BOOL* pfEnabled);
|
||||
typedef HRESULT (WINAPI *PtrDwmExtendFrameIntoClientArea)(HWND hWnd, const MARGINS* pMarInset);
|
||||
typedef HRESULT (WINAPI *PtrDwmEnableBlurBehindWindow)(HWND hWnd, const DWM_BLURBEHIND* pBlurBehind);
|
||||
typedef HRESULT (WINAPI *PtrDwmGetColorizationColor)(DWORD *pcrColorization, BOOL *pfOpaqueBlend);
|
||||
|
||||
static PtrDwmIsCompositionEnabled pDwmIsCompositionEnabled= 0;
|
||||
static PtrDwmEnableBlurBehindWindow pDwmEnableBlurBehindWindow = 0;
|
||||
static PtrDwmExtendFrameIntoClientArea pDwmExtendFrameIntoClientArea = 0;
|
||||
static PtrDwmGetColorizationColor pDwmGetColorizationColor = 0;
|
||||
|
||||
|
||||
/*
|
||||
* Internal helper class that notifies windows if the
|
||||
* DWM compositing state changes and updates the widget
|
||||
* flags correspondingly.
|
||||
*/
|
||||
class WindowNotifier : public QWidget
|
||||
{
|
||||
public:
|
||||
WindowNotifier()
|
||||
{
|
||||
winId();
|
||||
}
|
||||
void addWidget(QWidget *widget)
|
||||
{
|
||||
widgets.append(widget);
|
||||
}
|
||||
void removeWidget(QWidget *widget)
|
||||
{
|
||||
widgets.removeAll(widget);
|
||||
}
|
||||
bool winEvent(MSG *message, long *result);
|
||||
|
||||
private:
|
||||
QWidgetList widgets;
|
||||
};
|
||||
|
||||
static bool resolveLibs()
|
||||
{
|
||||
if (!pDwmIsCompositionEnabled)
|
||||
{
|
||||
QLibrary dwmLib(QString::fromAscii("dwmapi"));
|
||||
pDwmIsCompositionEnabled =(PtrDwmIsCompositionEnabled)dwmLib.resolve("DwmIsCompositionEnabled");
|
||||
pDwmExtendFrameIntoClientArea = (PtrDwmExtendFrameIntoClientArea)dwmLib.resolve("DwmExtendFrameIntoClientArea");
|
||||
pDwmEnableBlurBehindWindow = (PtrDwmEnableBlurBehindWindow)dwmLib.resolve("DwmEnableBlurBehindWindow");
|
||||
pDwmGetColorizationColor = (PtrDwmGetColorizationColor)dwmLib.resolve("DwmGetColorizationColor");
|
||||
}
|
||||
return pDwmIsCompositionEnabled != 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Chekcs and returns true if Windows DWM composition
|
||||
* is currently enabled on the system.
|
||||
*
|
||||
* To get live notification on the availability of
|
||||
* this feature, you will currently have to
|
||||
* reimplement winEvent() on your widget and listen
|
||||
* for the WM_DWMCOMPOSITIONCHANGED event to occur.
|
||||
*
|
||||
*/
|
||||
bool QtWin::isCompositionEnabled()
|
||||
{
|
||||
#ifdef Q_WS_WIN
|
||||
if (resolveLibs())
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
BOOL isEnabled = false;
|
||||
hr = pDwmIsCompositionEnabled(&isEnabled);
|
||||
if (SUCCEEDED(hr))
|
||||
return isEnabled;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Enables Blur behind on a Widget.
|
||||
*
|
||||
* \a enable tells if the blur should be enabled or not
|
||||
*/
|
||||
bool QtWin::enableBlurBehindWindow(QWidget *widget, bool enable)
|
||||
{
|
||||
Q_ASSERT(widget);
|
||||
bool result = false;
|
||||
#ifdef Q_WS_WIN
|
||||
if (resolveLibs())
|
||||
{
|
||||
DWM_BLURBEHIND bb = {0};
|
||||
HRESULT hr = S_OK;
|
||||
bb.fEnable = enable;
|
||||
bb.dwFlags = DWM_BB_ENABLE;
|
||||
bb.hRgnBlur = NULL;
|
||||
widget->setAttribute(Qt::WA_TranslucentBackground, enable);
|
||||
widget->setAttribute(Qt::WA_NoSystemBackground, enable);
|
||||
hr = pDwmEnableBlurBehindWindow(widget->winId(), &bb);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
result = true;
|
||||
windowNotifier()->addWidget(widget);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
/*!
|
||||
* ExtendFrameIntoClientArea.
|
||||
*
|
||||
* This controls the rendering of the frame inside the window.
|
||||
* Note that passing margins of -1 (the default value) will completely
|
||||
* remove the frame from the window.
|
||||
*
|
||||
* \note you should not call enableBlurBehindWindow before calling
|
||||
* this functions
|
||||
*
|
||||
* \a enable tells if the blur should be enabled or not
|
||||
*/
|
||||
bool QtWin::extendFrameIntoClientArea(QWidget *widget, int left, int top, int right, int bottom)
|
||||
{
|
||||
|
||||
Q_ASSERT(widget);
|
||||
Q_UNUSED(left);
|
||||
Q_UNUSED(top);
|
||||
Q_UNUSED(right);
|
||||
Q_UNUSED(bottom);
|
||||
|
||||
bool result = false;
|
||||
#ifdef Q_WS_WIN
|
||||
if (resolveLibs())
|
||||
{
|
||||
QLibrary dwmLib(QString::fromAscii("dwmapi"));
|
||||
HRESULT hr = S_OK;
|
||||
MARGINS m = {left, top, right, bottom};
|
||||
hr = pDwmExtendFrameIntoClientArea(widget->winId(), &m);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
result = true;
|
||||
windowNotifier()->addWidget(widget);
|
||||
}
|
||||
widget->setAttribute(Qt::WA_TranslucentBackground, result);
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Returns the current colorizationColor for the window.
|
||||
*
|
||||
* \a enable tells if the blur should be enabled or not
|
||||
*/
|
||||
QColor QtWin::colorizatinColor()
|
||||
{
|
||||
QColor resultColor = QApplication::palette().window().color();
|
||||
|
||||
#ifdef Q_WS_WIN
|
||||
if (resolveLibs())
|
||||
{
|
||||
DWORD color = 0;
|
||||
BOOL opaque = FALSE;
|
||||
QLibrary dwmLib(QString::fromAscii("dwmapi"));
|
||||
HRESULT hr = S_OK;
|
||||
hr = pDwmGetColorizationColor(&color, &opaque);
|
||||
if (SUCCEEDED(hr))
|
||||
resultColor = QColor(color);
|
||||
}
|
||||
#endif
|
||||
return resultColor;
|
||||
}
|
||||
|
||||
#ifdef Q_WS_WIN
|
||||
WindowNotifier *QtWin::windowNotifier()
|
||||
{
|
||||
static WindowNotifier *windowNotifierInstance = 0;
|
||||
if (!windowNotifierInstance)
|
||||
windowNotifierInstance = new WindowNotifier;
|
||||
return windowNotifierInstance;
|
||||
}
|
||||
|
||||
|
||||
/* Notify all enabled windows that the DWM state changed */
|
||||
bool WindowNotifier::winEvent(MSG *message, long *result)
|
||||
{
|
||||
if (message && message->message == WM_DWMCOMPOSITIONCHANGED)
|
||||
{
|
||||
bool compositionEnabled = QtWin::isCompositionEnabled();
|
||||
Q_FOREACH(QWidget * widget, widgets)
|
||||
{
|
||||
if (widget)
|
||||
{
|
||||
widget->setAttribute(Qt::WA_NoSystemBackground, compositionEnabled);
|
||||
}
|
||||
widget->update();
|
||||
}
|
||||
}
|
||||
return QWidget::winEvent(message, result);
|
||||
}
|
||||
#endif
|
37
code/nel/tools/3d/object_viewer_qt/src/plugins/core/qtwin.h
Normal file
37
code/nel/tools/3d/object_viewer_qt/src/plugins/core/qtwin.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Use, modification and distribution is allowed without limitation,
|
||||
** warranty, liability or support of any kind.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QTWIN_H
|
||||
#define QTWIN_H
|
||||
|
||||
#include <QColor>
|
||||
#include <QWidget>
|
||||
/**
|
||||
* This is a helper class for using the Desktop Window Manager
|
||||
* functionality on Windows 7 and Windows Vista. On other platforms
|
||||
* these functions will simply not do anything.
|
||||
*/
|
||||
|
||||
class WindowNotifier;
|
||||
|
||||
class QtWin
|
||||
{
|
||||
public:
|
||||
static bool enableBlurBehindWindow(QWidget *widget, bool enable = true);
|
||||
static bool extendFrameIntoClientArea(QWidget *widget,
|
||||
int left = -1, int top = -1,
|
||||
int right = -1, int bottom = -1);
|
||||
static bool isCompositionEnabled();
|
||||
static QColor colorizatinColor();
|
||||
|
||||
private:
|
||||
static WindowNotifier *windowNotifier();
|
||||
};
|
||||
|
||||
#endif // QTWIN_H
|
|
@ -10,7 +10,10 @@ SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h)
|
||||
|
||||
SET(OVQT_PLUG_EXAMPLE_HDR plugin1.h
|
||||
qnel_widget.h
|
||||
simple_viewer.h
|
||||
example_settings_page.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../core/iapp_page.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../core/ioptions_page.h)
|
||||
|
||||
SET(OVQT_PLUG_EXAMPLE_UIS example_settings_page.ui)
|
||||
|
@ -29,7 +32,7 @@ SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC})
|
|||
|
||||
ADD_LIBRARY(ovqt_plugin_example MODULE ${SRC} ${OVQT_PLUG_EXAMPLE_MOC_SRC} ${OVQT_EXT_SYS_SRC} ${OVQT_PLUG_EXAMPLE_UI_HDRS})
|
||||
|
||||
TARGET_LINK_LIBRARIES(ovqt_plugin_example nelmisc ${QT_LIBRARIES})
|
||||
TARGET_LINK_LIBRARIES(ovqt_plugin_example nelmisc nel3d ${QT_LIBRARIES})
|
||||
|
||||
NL_DEFAULT_PROPS(ovqt_plugin_example "NeL, Tools, 3D: Object Viewer Qt Plugin: Example")
|
||||
NL_ADD_RUNTIME_FLAGS(ovqt_plugin_example)
|
||||
|
|
|
@ -1,18 +1,23 @@
|
|||
#include "plugin1.h"
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QMainWindow>
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QMenuBar>
|
||||
|
||||
|
||||
#include "../../extension_system/iplugin_spec.h"
|
||||
#include "example_settings_page.h"
|
||||
#include "nel/misc/debug.h"
|
||||
|
||||
using namespace Plugin;
|
||||
// Project includes
|
||||
#include "plugin1.h"
|
||||
#include "example_settings_page.h"
|
||||
#include "simple_viewer.h"
|
||||
#include "../core/iapp_page.h"
|
||||
#include "../../extension_system/iplugin_spec.h"
|
||||
|
||||
// NeL includes
|
||||
#include "nel/misc/debug.h"
|
||||
|
||||
// Qt includes
|
||||
#include <QtCore/QObject>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QMainWindow>
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QMenuBar>
|
||||
|
||||
namespace Plugin
|
||||
{
|
||||
|
||||
bool MyPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString)
|
||||
{
|
||||
|
@ -32,6 +37,7 @@ bool MyPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QStrin
|
|||
*errorString = tr("Not found QMenu Help.");
|
||||
return false;
|
||||
}
|
||||
_plugMan->addObject(new CExampleAppPage());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -42,7 +48,7 @@ void MyPlugin::extensionsInitialized()
|
|||
|
||||
helpMenu->addSeparator();
|
||||
QAction *newAction = helpMenu->addAction("MyPlugin");
|
||||
|
||||
|
||||
connect(newAction, SIGNAL(triggered()), this, SLOT(execMessageBox()));
|
||||
}
|
||||
|
||||
|
@ -50,7 +56,7 @@ void MyPlugin::execMessageBox()
|
|||
{
|
||||
QMainWindow *wnd = qobject_cast<QMainWindow *>(objectByName("CMainWindow"));
|
||||
nlassert(wnd);
|
||||
|
||||
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(wnd->objectName() + QString(": width=%1,height=%2").arg(wnd->width()).arg(wnd->height()));
|
||||
msgBox.exec();
|
||||
|
@ -81,30 +87,32 @@ QString MyPlugin::vendor() const
|
|||
return "dnk-88";
|
||||
}
|
||||
|
||||
QString MyPlugin::description() const
|
||||
QString MyPlugin::description() const
|
||||
{
|
||||
return "Example ovqt plugin.";
|
||||
}
|
||||
|
||||
QList<QString> MyPlugin::dependencies() const
|
||||
{
|
||||
return QList<QString>();
|
||||
}
|
||||
|
||||
QObject* MyPlugin::objectByName(const QString &name) const
|
||||
{
|
||||
|
||||
QList<QString> MyPlugin::dependencies() const
|
||||
{
|
||||
return QList<QString>();
|
||||
}
|
||||
|
||||
QObject* MyPlugin::objectByName(const QString &name) const
|
||||
{
|
||||
Q_FOREACH (QObject *qobj, _plugMan->allObjects())
|
||||
if (qobj->objectName() == name)
|
||||
return qobj;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ExtensionSystem::IPluginSpec *MyPlugin::pluginByName(const QString &name) const
|
||||
{
|
||||
return qobj;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ExtensionSystem::IPluginSpec *MyPlugin::pluginByName(const QString &name) const
|
||||
{
|
||||
Q_FOREACH (ExtensionSystem::IPluginSpec *spec, _plugMan->plugins())
|
||||
if (spec->name() == name)
|
||||
return spec;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN(MyPlugin)
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN(Plugin::MyPlugin)
|
|
@ -1,11 +1,17 @@
|
|||
#ifndef PLUGIN1_H
|
||||
#define PLUGIN1_H
|
||||
|
||||
// Project includes
|
||||
#include "../../extension_system/iplugin.h"
|
||||
#include "simple_viewer.h"
|
||||
#include "../core/iapp_page.h"
|
||||
|
||||
// NeL includes
|
||||
#include "nel/misc/app_context.h"
|
||||
|
||||
// Qt includes
|
||||
#include <QtCore/QObject>
|
||||
#include <QtGui/QIcon>
|
||||
|
||||
namespace NLMISC
|
||||
{
|
||||
|
@ -17,7 +23,7 @@ namespace ExtensionSystem
|
|||
class IPluginSpec;
|
||||
}
|
||||
|
||||
namespace Plugin
|
||||
namespace Plugin
|
||||
{
|
||||
|
||||
class MyPlugin : public QObject, public ExtensionSystem::IPlugin
|
||||
|
@ -31,26 +37,52 @@ public:
|
|||
|
||||
void setNelContext(NLMISC::INelContext *nelContext);
|
||||
|
||||
QString name() const;
|
||||
QString version() const;
|
||||
QString vendor() const;
|
||||
QString name() const;
|
||||
QString version() const;
|
||||
QString vendor() const;
|
||||
QString description() const;
|
||||
QList<QString> dependencies() const;
|
||||
|
||||
QObject *objectByName(const QString &name) const;
|
||||
QList<QString> dependencies() const;
|
||||
|
||||
QObject *objectByName(const QString &name) const;
|
||||
ExtensionSystem::IPluginSpec *pluginByName(const QString &name) const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void execMessageBox();
|
||||
|
||||
protected:
|
||||
NLMISC::CLibraryContext *_LibContext;
|
||||
protected:
|
||||
NLMISC::CLibraryContext *_LibContext;
|
||||
|
||||
private:
|
||||
ExtensionSystem::IPluginManager *_plugMan;
|
||||
|
||||
};
|
||||
|
||||
class CExampleAppPage: public QObject, public Core::IAppPage
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(Core::IAppPage)
|
||||
public:
|
||||
CExampleAppPage(QObject *parent = 0): QObject(parent) {}
|
||||
virtual ~CExampleAppPage() {}
|
||||
|
||||
virtual QString id() const
|
||||
{
|
||||
return QLatin1String("ExampleAppPage");
|
||||
}
|
||||
virtual QString trName() const
|
||||
{
|
||||
return tr("SimpleViewer");
|
||||
}
|
||||
virtual QIcon icon() const
|
||||
{
|
||||
return QIcon();
|
||||
}
|
||||
virtual QWidget *widget()
|
||||
{
|
||||
return new CSimpleViewer();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Plugin
|
||||
|
||||
#endif // PLUGIN1_H
|
||||
|
|
|
@ -38,6 +38,9 @@ QNLWidget::QNLWidget(QWidget *parent)
|
|||
_initialized(false),
|
||||
_interval(25)
|
||||
{
|
||||
setMouseTracking(true);
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
|
||||
init();
|
||||
_mainTimer = new QTimer(this);
|
||||
connect(_mainTimer, SIGNAL(timeout()), this, SLOT(updateRender()));
|
||||
|
@ -110,39 +113,6 @@ void QNLWidget::showEvent(QShowEvent *showEvent)
|
|||
_mainTimer->stop();
|
||||
}
|
||||
|
||||
#if defined(NL_OS_WINDOWS) || defined(NL_OS_MAC)
|
||||
// Qt does not provide wheel events through winEvent() and macEvent() (but it
|
||||
// does through x11Event(), which is inconsistent...)
|
||||
// Workaround is to handle wheel events like implemented below.
|
||||
//
|
||||
// TODO: this is not a clean solution, because all but wheel events are
|
||||
// handled using winEvent(), x11Event(), macEvent(). But this seems to be a
|
||||
// limitation of current (4.7.1) Qt versions. (see e.g. qapplication_mac.mm)
|
||||
void QNLWidget::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
// Get relative positions.
|
||||
float fX = 1.0f - (float)event->pos().x() / this->width();
|
||||
float fY = 1.0f - (float)event->pos().y() / this->height();
|
||||
|
||||
// Get the buttons currently pressed.
|
||||
uint32 buttons = NLMISC::noButton;
|
||||
if(event->buttons() & Qt::LeftButton) buttons |= NLMISC::leftButton;
|
||||
if(event->buttons() & Qt::RightButton) buttons |= NLMISC::rightButton;
|
||||
if(event->buttons() & Qt::MidButton) buttons |= NLMISC::middleButton;
|
||||
if(event->modifiers() & Qt::ControlModifier) buttons |= NLMISC::ctrlButton;
|
||||
if(event->modifiers() & Qt::ShiftModifier) buttons |= NLMISC::shiftButton;
|
||||
if(event->modifiers() & Qt::AltModifier) buttons |= NLMISC::altButton;
|
||||
|
||||
if(event->delta() > 0)
|
||||
_driver->EventServer.postEvent(
|
||||
new NLMISC::CEventMouseWheel(-fX, fY, (NLMISC::TMouseButton)buttons, true, NULL));
|
||||
else
|
||||
_driver->EventServer.postEvent(
|
||||
new NLMISC::CEventMouseWheel(-fX, fY, (NLMISC::TMouseButton)buttons, false, NULL));
|
||||
}
|
||||
#endif // defined(NL_OS_WINDOWS) || defined(NL_OS_MAC)
|
||||
|
||||
|
||||
#if defined(NL_OS_WINDOWS)
|
||||
|
||||
typedef bool (*winProc)(NL3D::IDriver *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
|
@ -65,10 +65,6 @@ private Q_SLOTS:
|
|||
protected:
|
||||
virtual void showEvent(QShowEvent *showEvent);
|
||||
|
||||
#if defined(NL_OS_WINDOWS) || defined(NL_OS_MAC)
|
||||
virtual void wheelEvent(QWheelEvent *event);
|
||||
#endif
|
||||
|
||||
#if defined(NL_OS_WINDOWS)
|
||||
virtual bool winEvent(MSG *message, long *result);
|
||||
#elif defined(NL_OS_MAC)
|
|
@ -0,0 +1,42 @@
|
|||
// 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>
|
||||
//
|
||||
// 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 "simple_viewer.h"
|
||||
|
||||
// Qt includes
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QGridLayout>
|
||||
|
||||
// NeL includes
|
||||
|
||||
// Project includes
|
||||
|
||||
namespace Plugin
|
||||
{
|
||||
|
||||
CSimpleViewer::CSimpleViewer(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
QGridLayout *gridLayout = new QGridLayout(this);
|
||||
gridLayout->setObjectName(QString::fromUtf8("gridLayoutSimpleViewer"));
|
||||
gridLayout->setContentsMargins(0, 0, 0, 0);
|
||||
NLQT::QNLWidget *_nelWidget = new NLQT::QNLWidget(this);
|
||||
gridLayout->addWidget(_nelWidget, 0, 0, 1, 1);
|
||||
}
|
||||
|
||||
|
||||
} /* namespace Plugin */
|
|
@ -0,0 +1,43 @@
|
|||
// 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>
|
||||
//
|
||||
// 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 SIMPLE_VIEWER_H
|
||||
#define SIMPLE_VIEWER_H
|
||||
|
||||
// Project includes
|
||||
#include "qnel_widget.h"
|
||||
|
||||
// Qt includes
|
||||
#include <QtCore/QObject>
|
||||
|
||||
class QWidget;
|
||||
|
||||
namespace Plugin
|
||||
{
|
||||
|
||||
class CSimpleViewer : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CSimpleViewer(QWidget *parent = 0);
|
||||
virtual ~CSimpleViewer() {}
|
||||
};
|
||||
|
||||
} // namespace Plugin
|
||||
|
||||
#endif // SIMPLE_VIEWER_H
|
Loading…
Reference in a new issue