Commit 0bfccfad authored by Clément Stenac's avatar Clément Stenac

First benefits of QT ! A slider ! (Refs:#80)

parent 8f973a0b
......@@ -65,4 +65,6 @@ void InputManager::update()
void InputManager::sliderUpdate( float new_pos )
{
fprintf( stderr, "Seek to %f\n", new_pos );
var_SetFloat( p_input, "position", new_pos );
}
......@@ -22,6 +22,7 @@
#include "main_interface.hpp"
#include "input_manager.hpp"
#include "util/input_slider.hpp"
#include "dialogs_provider.hpp"
#include <QCloseEvent>
#include <assert.h>
......@@ -32,6 +33,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) :
fprintf( stderr, "QT Main interface\n" );
/* Init UI */
slider = new InputSlider( Qt::Horizontal, this ); slider->init();
/* Init input manager */
p_input = NULL;
......@@ -48,7 +50,11 @@ void MainInterface::init()
main_input_manager, SLOT( setInput( input_thread_t * ) ) );
/* Connect the slider and the input manager */
// both ways
QObject::connect( main_input_manager, SIGNAL(positionUpdated(
float, int, int ) ), slider, SLOT( setPosition( float,int,
int ) ) );
QObject::connect( slider, SIGNAL( sliderDragged( float ) ),
main_input_manager, SLOT( sliderUpdate( float ) ) );
/* Connect the display and the input manager */
}
......
......@@ -28,6 +28,7 @@
class InputManager;
class QCloseEvent;
class InputSlider;
class MainInterface : public QWidget
{
......@@ -40,6 +41,7 @@ protected:
void closeEvent( QCloseEvent *);
private:
InputManager *main_input_manager;
InputSlider *slider;
intf_thread_t *p_intf;
/// Main input associated to the playlist
input_thread_t *p_input;
......
......@@ -25,10 +25,11 @@
void InputSlider::init()
{
mymove = false;
setMinimum( 0 );
setMaximum( 1000 );
setSingleStep( 2 );
setPageStep( 100 );
setPageStep( 1000 );
setTracking( true );
QObject::connect( this, SIGNAL( valueChanged(int) ), this,
SLOT( userDrag( int ) ) );
......@@ -36,11 +37,18 @@ void InputSlider::init()
void InputSlider::setPosition( float pos, int a, int b )
{
fprintf( stderr, "Set pos %f\n", pos );
mymove = true;
setValue( (int)(pos * 1000.0 ) );
mymove = false;
}
void InputSlider::userDrag( int new_value )
{
float f_pos = (float)(new_value)/1000.0;
emit positionUpdated( f_pos );
if( !mymove )
{
fprintf( stderr, "Emitting %f\n", f_pos );
emit sliderDragged( f_pos );
}
}
......@@ -34,11 +34,13 @@ public:
{};
virtual ~InputSlider() {};
void init();
private:
bool mymove;
public slots:
void setPosition( float, int, int );
private slots:
void userDrag( int );
signals:
void positionUpdated( float );
void sliderDragged( float );
};
#endif
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