Commit b50e3a55 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[CHANGE] - nav widget sliders now update in GUI thread

parent 6606694a
......@@ -28,10 +28,14 @@
#include <QtGui/QDockWidget>
#include <QtGui/QVBoxLayout>
#include <QtGui/QKeyEvent>
#include <QtGui/QApplication>
#include "WQtNavGLWidget.h"
#include "../../graphicsEngine/WGEViewer.h"
#include "../../graphicsEngine/WGEScene.h"
#include "events/WPropertyChangedEvent.h"
#include "events/WEventTypes.h"
#include "WQtNavGLWidget.h"
WQtNavGLWidget::WQtNavGLWidget( QString title, QWidget* parent, int maxValue, std::string sliderTitle )
: QDockWidget( title, parent )
......@@ -149,10 +153,24 @@ void WQtNavGLWidget::setSliderProperty( WPropInt prop )
m_sliderProp->getCondition()->subscribeSignal( boost::bind( &WQtNavGLWidget::handleChangedPropertyValue, this ) );
}
void WQtNavGLWidget::handleChangedPropertyValue()
bool WQtNavGLWidget::event( QEvent* event )
{
if( m_slider )
// a property changed
if ( event->type() == WQT_PROPERTY_CHANGED_EVENT )
{
m_slider->setValue( m_sliderProp->get() );
if( m_slider )
{
m_slider->setValue( m_sliderProp->get() );
}
return true;
}
return QWidget::event( event );
}
void WQtNavGLWidget::handleChangedPropertyValue()
{
// post an event to handle it in the gui thread
QCoreApplication::postEvent( this, new WPropertyChangedEvent() );
}
......@@ -88,6 +88,17 @@ protected:
*/
virtual void closeEvent( QCloseEvent* event );
/**
* Custom event dispatcher. Gets called by QT's Event system every time an event got sent to this widget. This event handler
* processes property change events.
*
* \note QT Doc says: use event() for custom events.
* \param event the event that got transmitted.
*
* \return true if the event got handled properly.
*/
virtual bool event( QEvent* event );
private:
/**
......@@ -100,7 +111,11 @@ private:
*/
QString m_sliderTitle;
QSlider *m_slider; //!< A pointer to the slider widget.
/**
* The slider representing the property.
* \todo this has to be replaced by a WPropertyIntWidget!
*/
QSlider *m_slider;
/**
* My GL widget.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment