Refactored osgQt so that QWebViewImage is now entirely implementated in the header, and osgQt itself no longer compiles it,
leaving it to only applications that require it to include the header and it's implementation and with ith the QWebKit dependency.
This commit is contained in:
@@ -337,6 +337,9 @@ class OSG_EXPORT Image : public BufferData
|
||||
virtual void operator () (osg::StateAttribute* attr, osg::NodeVisitor* nv);
|
||||
};
|
||||
|
||||
/** method for hinting whether to enable or disable focus to images acting as front ends to interactive surfaces such as a vnc or browser window. Return true if handled. */
|
||||
virtual bool sendFocusHint(bool focus) { return false; }
|
||||
|
||||
/** method for sending pointer events to images that are acting as front ends to interactive surfaces such as a vnc or browser window. Return true if handled. */
|
||||
virtual bool sendPointerEvent(int /*x*/, int /*y*/, int /*buttonMask*/) { return false; }
|
||||
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
#ifndef QWEBVIEWIMAGE
|
||||
#define QWEBVIEWIMAGE
|
||||
|
||||
// make sure this header isn't built as par of osgQt, leaving it to applications to build
|
||||
#if !defined(OSGQT_LIBRARY) && !defined(OSG_LIBRARY_STATIC)
|
||||
|
||||
#include <osgWidget/Browser>
|
||||
#include <osgQt/QGraphicsViewAdapter>
|
||||
|
||||
@@ -24,25 +27,62 @@ class OSGQT_EXPORT QWebViewImage : public osgWidget::BrowserImage
|
||||
{
|
||||
public:
|
||||
|
||||
QWebViewImage();
|
||||
QWebViewImage()
|
||||
{
|
||||
// make sure we have a valid QApplication before we start creating widgets.
|
||||
getOrCreateQApplication();
|
||||
|
||||
virtual void navigateTo(const std::string& url);
|
||||
_webView = new QWebView;
|
||||
|
||||
_webPage = new QWebPage;
|
||||
_webPage->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
|
||||
_webPage->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
|
||||
|
||||
_webView->setPage(_webPage);
|
||||
|
||||
_adapter = new QGraphicsViewAdapter(this, _webView.data());
|
||||
}
|
||||
|
||||
virtual void navigateTo(const std::string& url)
|
||||
{
|
||||
_webView->load(QUrl(url.c_str()));
|
||||
}
|
||||
|
||||
QWebView* getQWebView() { return _webView; }
|
||||
QWebPage* getQWebPage() { return _webPage; }
|
||||
QGraphicsViewAdapter* getQGraphicsViewAdapter() { return _adapter; }
|
||||
|
||||
void focusBrowser(bool focus);
|
||||
void clearWriteBuffer()
|
||||
{
|
||||
_adapter->clearWriteBuffer();
|
||||
}
|
||||
|
||||
void clearWriteBuffer();
|
||||
void render()
|
||||
{
|
||||
_adapter->render();
|
||||
}
|
||||
|
||||
void render();
|
||||
virtual bool sendFocusHint(bool focus)
|
||||
{
|
||||
QFocusEvent event(focus ? QEvent::FocusIn : QEvent::FocusOut, Qt::OtherFocusReason);
|
||||
QCoreApplication::sendEvent(_webPage, &event);
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void setFrameLastRendered(const osg::FrameStamp* frameStamp);
|
||||
virtual bool sendPointerEvent(int x, int y, int buttonMask)
|
||||
{
|
||||
return _adapter->sendPointerEvent(x,y,buttonMask);
|
||||
}
|
||||
|
||||
virtual bool sendPointerEvent(int x, int y, int buttonMask);
|
||||
virtual bool sendKeyEvent(int key, bool keyDown)
|
||||
{
|
||||
return QWebViewImage::_adapter->sendKeyEvent(key, keyDown);
|
||||
}
|
||||
|
||||
virtual bool sendKeyEvent(int key, bool keyDown);
|
||||
virtual void setFrameLastRendered(const osg::FrameStamp* frameStamp)
|
||||
{
|
||||
_adapter->setFrameLastRendered(frameStamp);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
@@ -53,4 +93,6 @@ class OSGQT_EXPORT QWebViewImage : public osgWidget::BrowserImage
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -29,18 +29,19 @@ class OSGQT_EXPORT QWidgetImage : public osg::Image
|
||||
QWidget* getQWidget() { return _widget; }
|
||||
QGraphicsViewAdapter* getQGraphicsViewAdapter() { return _adapter; }
|
||||
|
||||
void focusWidget(bool focus);
|
||||
|
||||
void clearWriteBuffer();
|
||||
|
||||
void render();
|
||||
|
||||
virtual void setFrameLastRendered(const osg::FrameStamp* frameStamp);
|
||||
virtual bool sendFocusHint(bool focus);
|
||||
|
||||
virtual bool sendPointerEvent(int x, int y, int buttonMask);
|
||||
|
||||
virtual bool sendKeyEvent(int key, bool keyDown);
|
||||
|
||||
virtual void setFrameLastRendered(const osg::FrameStamp* frameStamp);
|
||||
|
||||
protected:
|
||||
|
||||
QPointer<QGraphicsViewAdapter> _adapter;
|
||||
|
||||
Reference in New Issue
Block a user