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