Skip to content

Commit

Permalink
fixed closeEvent by subclassing QDockWidget instead of QgsGLWidgetAda…
Browse files Browse the repository at this point in the history
…pter
  • Loading branch information
mbernasocchi authored and pka committed Jul 5, 2011
1 parent 34a7461 commit 8f40cd8
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 19 deletions.
6 changes: 2 additions & 4 deletions src/plugins/globe/globe_plugin.cpp
Expand Up @@ -113,7 +113,7 @@ void GlobePlugin::initGui()
SLOT( projectReady() ) );
connect( mQGisIface->mainWindow(), SIGNAL( newProjectCreated() ), this,
SLOT( blankProjectReady() ) );
connect( &viewer, SIGNAL( globeClosed() ), this,
connect( &mQDockWidget, SIGNAL( globeClosed() ), this,
SLOT( setGlobeNotRunning() ) );

}
Expand Down Expand Up @@ -741,9 +741,7 @@ void GlobePlugin::copyFolder( QString sourceFolder, QString destFolder )

void GlobePlugin::setGlobeNotRunning()
{
QMessageBox m;
m.setText("globe not running");
m.exec();
QgsDebugMsg( "Globe Closed" );
mIsGlobeRunning = false;
}

Expand Down
3 changes: 1 addition & 2 deletions src/plugins/globe/globe_plugin.h
Expand Up @@ -25,7 +25,6 @@
#include "globe_plugin_dialog.h"
#include "Controls"
#include <QObject>
#include <QDockWidget>
#include <osgEarth/MapNode>
#include <osgEarth/MapLayer>
#include <osgEarthUtil/EarthManipulator>
Expand Down Expand Up @@ -98,7 +97,7 @@ class GlobePlugin : public QObject, public QgisPlugin
//! OSG Viewer
QgsOsgViewer viewer;
//! Dock widget for viewer
QDockWidget mQDockWidget;
QDockWidgetGlobe mQDockWidget;
//! Settings Dialog
QgsGlobePluginDialog mSettingsDialog;
//! OSG root node
Expand Down
26 changes: 16 additions & 10 deletions src/plugins/globe/qgsosgviewer.cpp
Expand Up @@ -23,6 +23,22 @@
#include <QString>
#include <QMessageBox>

QDockWidgetGlobe::QDockWidgetGlobe(const QString &title, QWidget *parent, Qt::WindowFlags flags):
QDockWidget(title, parent, flags)
{
};

QDockWidgetGlobe::QDockWidgetGlobe(QWidget *parent, Qt::WindowFlags flags):
QDockWidget(parent, flags)
{
};

//reimplement the close event to emit a signal
void QDockWidgetGlobe::closeEvent(QCloseEvent* event)
{
emit globeClosed();
event->accept();
}

QgsGLWidgetAdapter::QgsGLWidgetAdapter( QWidget * parent, const char * name, const QGLWidget * shareWidget, WindowFlags f):
QGLWidget(parent, shareWidget, f)
Expand Down Expand Up @@ -85,13 +101,3 @@ void QgsGLWidgetAdapter::wheelEvent(QWheelEvent *event)
{
_gw->getEventQueue()->mouseScroll((event->delta()>0) ? osgGA::GUIEventAdapter::SCROLL_DOWN : osgGA::GUIEventAdapter::SCROLL_UP);
}

//reimplement the close event to emit a signal
void QgsGLWidgetAdapter::closeEvent(QCloseEvent *event)
{
QMessageBox m;
m.setText("close event");
m.exec();
emit globeClosed();
event->accept();
}
22 changes: 19 additions & 3 deletions src/plugins/globe/qgsosgviewer.h
Expand Up @@ -22,11 +22,30 @@
#include <osgViewer/Viewer>

#include <QtOpenGL/QGLWidget>
#include <QtGui/QDockWidget>
#include <QtGui/QKeyEvent>
#include <QtCore/QTimer>

using Qt::WindowFlags;

class QDockWidgetGlobe : public QDockWidget
{
Q_OBJECT

public:
QDockWidgetGlobe(const QString& title, QWidget* parent = 0, WindowFlags flags = 0);
QDockWidgetGlobe(QWidget *parent = 0, Qt::WindowFlags flags = 0);

virtual ~QDockWidgetGlobe() {}

protected:
virtual void closeEvent(QCloseEvent *event);

signals:
void globeClosed();
};


class QgsGLWidgetAdapter : public QGLWidget
{
Q_OBJECT
Expand All @@ -49,12 +68,9 @@ class QgsGLWidgetAdapter : public QGLWidget
virtual void mouseReleaseEvent( QMouseEvent* event );
virtual void mouseMoveEvent( QMouseEvent* event );
virtual void wheelEvent( QWheelEvent * event );
virtual void closeEvent(QCloseEvent *event);

osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> _gw;

signals:
void globeClosed();

};

Expand Down

0 comments on commit 8f40cd8

Please sign in to comment.