Commit efed5df6 authored by Clément Stenac's avatar Clément Stenac

* compiles-but-untested complete implementation of menus and popups

* handle play/pause status
parent 054049cf
...@@ -45,6 +45,9 @@ DialogsProvider::DialogsProvider( intf_thread_t *_p_intf ) : ...@@ -45,6 +45,9 @@ DialogsProvider::DialogsProvider( intf_thread_t *_p_intf ) :
connect( menusMapper, SIGNAL( mapped(QObject *) ), this, connect( menusMapper, SIGNAL( mapped(QObject *) ), this,
SLOT(menuAction( QObject *)) ); SLOT(menuAction( QObject *)) );
menusUpdateMapper = new QSignalMapper();
connect( menusMapper, SIGNAL( mapped(QObject *) ), this,
SLOT(menuUpdateAction( QObject *)) );
} }
DialogsProvider::~DialogsProvider() DialogsProvider::~DialogsProvider()
...@@ -152,6 +155,12 @@ void DialogsProvider::menuAction( QObject *data ) ...@@ -152,6 +155,12 @@ void DialogsProvider::menuAction( QObject *data )
QVLCMenu::DoAction( p_intf, data ); QVLCMenu::DoAction( p_intf, data );
} }
void DialogsProvider::menuUpdateAction( QObject *data )
{
MenuFunc * f = qobject_cast<MenuFunc *>(data);
f->doFunc( p_intf );
}
void DialogsProvider::simpleOpenDialog() void DialogsProvider::simpleOpenDialog()
{ {
} }
......
...@@ -56,6 +56,7 @@ public: ...@@ -56,6 +56,7 @@ public:
protected: protected:
friend class QVLCMenu; friend class QVLCMenu;
QSignalMapper *menusMapper; QSignalMapper *menusMapper;
QSignalMapper *menusUpdateMapper;
void customEvent( QEvent *); void customEvent( QEvent *);
private: private:
DialogsProvider( intf_thread_t *); DialogsProvider( intf_thread_t *);
...@@ -73,6 +74,7 @@ public slots: ...@@ -73,6 +74,7 @@ public slots:
void popupMenu( int ); void popupMenu( int );
void doInteraction( intf_dialog_args_t * ); void doInteraction( intf_dialog_args_t * );
void menuAction( QObject *); void menuAction( QObject *);
void menuUpdateAction( QObject *);
void streamingDialog(); void streamingDialog();
}; };
......
...@@ -34,10 +34,10 @@ ...@@ -34,10 +34,10 @@
InputManager::InputManager( QObject *parent, intf_thread_t *_p_intf) : InputManager::InputManager( QObject *parent, intf_thread_t *_p_intf) :
QObject( parent ), p_intf( _p_intf ) QObject( parent ), p_intf( _p_intf )
{ {
i_old_playing_status = END_S;
p_input = NULL; p_input = NULL;
/* Subscribe to updates */ /* Subscribe to updates */
connect( DialogsProvider::getInstance( p_intf )->fixed_timer, connect( THEDP->fixed_timer, SIGNAL( timeout() ), this, SLOT( update() ) );
SIGNAL( timeout() ), this, SLOT( update() ) );
} }
InputManager::~InputManager() InputManager::~InputManager()
...@@ -103,6 +103,14 @@ void InputManager::update() ...@@ -103,6 +103,14 @@ void InputManager::update()
} }
emit nameChanged( text ); emit nameChanged( text );
/* Update playing status */
var_Get( p_input, "state", &val );
val.i_int = val.i_int == PAUSE_S ? PAUSE_S : PLAYING_S;
if( i_old_playing_status != val.i_int )
{
i_old_playing_status = val.i_int;
emit statusChanged( val.i_int == PAUSE_S ? PAUSE_S : PLAYING_S );
}
} }
void InputManager::sliderUpdate( float new_pos ) void InputManager::sliderUpdate( float new_pos )
...@@ -111,6 +119,24 @@ void InputManager::sliderUpdate( float new_pos ) ...@@ -111,6 +119,24 @@ void InputManager::sliderUpdate( float new_pos )
var_SetFloat( p_input, "position", new_pos ); var_SetFloat( p_input, "position", new_pos );
} }
void InputManager::togglePlayPause()
{
vlc_value_t state;
var_Get( p_input, "state", &state );
if( state.i_int != PAUSE_S )
{
/* A stream is being played, pause it */
state.i_int = PAUSE_S;
}
else
{
/* Stream is paused, resume it */
state.i_int = PLAYING_S;
}
var_Set( p_input, "state", state );
emit statusChanged( state.i_int );
}
/********************************************************************** /**********************************************************************
* MainInputManager implementation. Wrap an input manager and * MainInputManager implementation. Wrap an input manager and
* take care of updating the main playlist input * take care of updating the main playlist input
...@@ -157,3 +183,13 @@ void MainInputManager::updateInput() ...@@ -157,3 +183,13 @@ void MainInputManager::updateInput()
} }
vlc_mutex_unlock( &p_intf->change_lock ); vlc_mutex_unlock( &p_intf->change_lock );
} }
void MainInputManager::togglePlayPause()
{
if( p_input == NULL )
{
playlist_Play( THEPL );
return;
}
getIM()->togglePlayPause();
}
...@@ -37,8 +37,10 @@ public: ...@@ -37,8 +37,10 @@ public:
private: private:
intf_thread_t *p_intf; intf_thread_t *p_intf;
input_thread_t *p_input; input_thread_t *p_input;
int i_old_playing_status;
public slots: public slots:
void togglePlayPause();
void update(); ///< Periodic updates void update(); ///< Periodic updates
void setInput( input_thread_t * ); ///< Our controlled input changed void setInput( input_thread_t * ); ///< Our controlled input changed
void sliderUpdate( float ); ///< User dragged the slider. We get new pos void sliderUpdate( float ); ///< User dragged the slider. We get new pos
...@@ -70,6 +72,8 @@ private: ...@@ -70,6 +72,8 @@ private:
input_thread_t *p_input; input_thread_t *p_input;
static MainInputManager *instance; static MainInputManager *instance;
MainInputManager( intf_thread_t *); MainInputManager( intf_thread_t *);
public slots:
void togglePlayPause();
private slots: private slots:
void updateInput(); void updateInput();
signals: signals:
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <QCloseEvent> #include <QCloseEvent>
#include <assert.h> #include <assert.h>
#include <QPushButton> #include <QPushButton>
#include "menus.hpp"
static int InteractCallback( vlc_object_t *, const char *, vlc_value_t, static int InteractCallback( vlc_object_t *, const char *, vlc_value_t,
vlc_value_t, void *); vlc_value_t, void *);
...@@ -57,10 +58,9 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -57,10 +58,9 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
ui.volLowLabel->setPixmap( QPixmap( ":/pixmaps/volume-low.png" ) ); ui.volLowLabel->setPixmap( QPixmap( ":/pixmaps/volume-low.png" ) );
ui.volHighLabel->setPixmap( QPixmap( ":/pixmaps/volume-high.png" ) ); ui.volHighLabel->setPixmap( QPixmap( ":/pixmaps/volume-high.png" ) );
//QVLCMenu::createMenuBar(); QVLCMenu::createMenuBar( menuBar(), p_intf );
resize (500, 131 ); resize (500, 131 );
fprintf( stderr, "Before creating the video widget, size is %ix%i\n", size().width(), size().height() );
// if( config_GetInt( p_intf, "embedded" ) ) // if( config_GetInt( p_intf, "embedded" ) )
{ {
...@@ -99,19 +99,18 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -99,19 +99,18 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
MainInputManager::getInstance( p_intf ); MainInputManager::getInstance( p_intf );
/* Get timer updates */ /* Get timer updates */
connect( DialogsProvider::getInstance(NULL)->fixed_timer, connect( THEDP->fixed_timer, SIGNAL( timeout() ),
SIGNAL( timeout() ), this, SLOT(updateOnTimer() ) ); this, SLOT(updateOnTimer() ) );
/* Connect the input manager to the GUI elements it manages */ /* Connect the input manager to the GUI elements it manages */
connect( MainInputManager::getInstance( p_intf )->getIM(), connect( THEMIM->getIM(),SIGNAL(positionUpdated( float, int, int ) ),
SIGNAL(positionUpdated( float, int, int ) ),
slider, SLOT( setPosition( float,int, int ) ) ); slider, SLOT( setPosition( float,int, int ) ) );
connect( slider, SIGNAL( sliderDragged( float ) ), connect( THEMIM->getIM(), SIGNAL( positionUpdated( float, int, int ) ),
MainInputManager::getInstance( p_intf )->getIM(),
SLOT( sliderUpdate( float ) ) );
connect( MainInputManager::getInstance( p_intf )->getIM(),
SIGNAL( positionUpdated( float, int, int ) ),
this, SLOT( setDisplay( float, int, int ) ) ); this, SLOT( setDisplay( float, int, int ) ) );
connect( THEMIM->getIM(), SIGNAL( statusChanged( int ) ),
this, SLOT( setStatus( int ) ) );
connect( slider, SIGNAL( sliderDragged( float ) ),
THEMIM->getIM(),SLOT( sliderUpdate( float ) ) );
/* Actions */ /* Actions */
connect( ui.playButton, SLOT( clicked() ), this, SLOT( play() ) ); connect( ui.playButton, SLOT( clicked() ), this, SLOT( play() ) );
...@@ -119,8 +118,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -119,8 +118,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
connect( ui.nextButton, SLOT( clicked() ), this, SLOT( next() ) ); connect( ui.nextButton, SLOT( clicked() ), this, SLOT( next() ) );
connect( ui.prevButton, SLOT( clicked() ), this, SLOT( prev() ) ); connect( ui.prevButton, SLOT( clicked() ), this, SLOT( prev() ) );
connect( ui.playlistButton, SLOT(clicked() ), connect( ui.playlistButton, SLOT(clicked()),
DialogsProvider::getInstance( p_intf ), SLOT( playlistDialog() ) ); THEDP, SLOT( playlistDialog() ) );
var_Create( p_intf, "interaction", VLC_VAR_ADDRESS ); var_Create( p_intf, "interaction", VLC_VAR_ADDRESS );
var_AddCallback( p_intf, "interaction", InteractCallback, this ); var_AddCallback( p_intf, "interaction", InteractCallback, this );
...@@ -143,16 +142,8 @@ MainInterface::~MainInterface() ...@@ -143,16 +142,8 @@ MainInterface::~MainInterface()
void MainInterface::resizeEvent( QResizeEvent *e ) void MainInterface::resizeEvent( QResizeEvent *e )
{ {
fprintf( stderr, "Resized to %ix%i\n", e->size().width(), e->size().height() ); videoSize.setHeight( e->size().height() - addSize.height() );
videoSize.setWidth( e->size().width() - addSize.width() );
fprintf( stderr, "MI constraints %ix%i -> %ix%i\n",
p_intf->p_sys->p_mi->minimumSize().width(),
p_intf->p_sys->p_mi->minimumSize().height(),
p_intf->p_sys->p_mi->maximumSize().width(),
p_intf->p_sys->p_mi->maximumSize().height() );
videoSize.setHeight( e->size().height() - addSize.height() );
videoSize.setWidth( e->size().width() - addSize.width() );
p_intf->p_sys->p_video->updateGeometry() ; p_intf->p_sys->p_video->updateGeometry() ;
} }
...@@ -162,7 +153,14 @@ void MainInterface::stop() ...@@ -162,7 +153,14 @@ void MainInterface::stop()
} }
void MainInterface::play() void MainInterface::play()
{ {
playlist_Play( THEPL ); if( !THEPL->i_size || !THEPL->i_enabled )
{
/* The playlist is empty, open a file requester */
THEDP->openDialog();
setStatus( 0 );
return;
}
THEMIM->togglePlayPause();
} }
void MainInterface::prev() void MainInterface::prev()
{ {
...@@ -183,6 +181,15 @@ void MainInterface::setDisplay( float pos, int time, int length ) ...@@ -183,6 +181,15 @@ void MainInterface::setDisplay( float pos, int time, int length )
ui.sliderBox->setTitle( title ); ui.sliderBox->setTitle( title );
} }
void MainInterface::setStatus( int status )
{
fprintf( stderr, "Status is now %i\n", status );
if( status == 2 ) // Playing
ui.playButton->setIcon( QIcon( ":/pixmaps/pause.png" ) );
else
ui.playButton->setIcon( QIcon( ":/pixmaps/play.png" ) );
}
void MainInterface::updateOnTimer() void MainInterface::updateOnTimer()
{ {
if( p_intf->b_die ) if( p_intf->b_die )
...@@ -206,7 +213,6 @@ static int InteractCallback( vlc_object_t *p_this, ...@@ -206,7 +213,6 @@ static int InteractCallback( vlc_object_t *p_this,
MainInterface *p_interface = (MainInterface*)param; MainInterface *p_interface = (MainInterface*)param;
DialogEvent *event = new DialogEvent( INTF_DIALOG_INTERACTION, 0, p_arg ); DialogEvent *event = new DialogEvent( INTF_DIALOG_INTERACTION, 0, p_arg );
QApplication::postEvent( DialogsProvider::getInstance( NULL ), QApplication::postEvent( THEDP, static_cast<QEvent*>(event) );
static_cast<QEvent*>(event) );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -53,6 +53,7 @@ private: ...@@ -53,6 +53,7 @@ private:
input_thread_t *p_input; input_thread_t *p_input;
Ui::MainInterfaceUI ui; Ui::MainInterfaceUI ui;
private slots: private slots:
void setStatus( int );
void setDisplay( float, int, int ); void setDisplay( float, int, int );
void updateOnTimer(); void updateOnTimer();
void play(); void play();
......
This diff is collapsed.
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
using namespace std; using namespace std;
class QMenu; class QMenu;
class QPoint; class QMenuBar;
class MenuItemData : public QObject class MenuItemData : public QObject
{ {
...@@ -58,27 +58,55 @@ class QVLCMenu : public QObject ...@@ -58,27 +58,55 @@ class QVLCMenu : public QObject
{ {
Q_OBJECT; Q_OBJECT;
public: public:
static void createMenuBar( QMenuBar *, intf_thread_t * );
/* Individual menu builders */ /* Menus */
static QMenu *FileMenu(); static QMenu *FileMenu();
static QMenu *ToolsMenu( intf_thread_t *, bool with_intf = true );
static void AudioPopupMenu( intf_thread_t *, const QPoint& );
static void VideoPopupMenu( intf_thread_t *, const QPoint& );
static QMenu *NavigMenu( intf_thread_t * , QMenu * ); static QMenu *NavigMenu( intf_thread_t * , QMenu * );
static QMenu *VideoMenu( intf_thread_t * , QMenu * ); static QMenu *VideoMenu( intf_thread_t * , QMenu * );
static QMenu *AudioMenu( intf_thread_t * , QMenu * ); static QMenu *AudioMenu( intf_thread_t * , QMenu * );
static QMenu *InterfacesMenu( intf_thread_t *p_intf, QMenu * );
/* Popups */
static void AudioPopupMenu( intf_thread_t * );
static void VideoPopupMenu( intf_thread_t * );
static void MiscPopupMenu( intf_thread_t * );
static void PopupMenu( intf_thread_t * );
static void DoAction( intf_thread_t *, QObject * );
private:
/* Generic automenu methods */ /* Generic automenu methods */
static QMenu * Populate( intf_thread_t *, QMenu *current, static QMenu * Populate( intf_thread_t *, QMenu *current,
vector<const char*>&, vector<int>& ); vector<const char*>&, vector<int>&,
bool append = false );
static void CreateAndConnect( QMenu *, const char *, QString, QString, static void CreateAndConnect( QMenu *, const char *, QString, QString,
int, int, vlc_value_t, int, bool c = false ); int, int, vlc_value_t, int, bool c = false );
static void CreateItem( QMenu *, const char *, vlc_object_t * ); static void CreateItem( QMenu *, const char *, vlc_object_t *, bool );
static QMenu *CreateChoicesMenu( const char *, vlc_object_t *, bool ); static int CreateChoicesMenu( QMenu *,const char *, vlc_object_t *, bool );
static void DoAction( intf_thread_t *, QObject * ); };
class MenuFunc : public QObject
{
public:
MenuFunc( QMenu *_menu, int _id ) { menu = _menu; id = _id; };
void doFunc( intf_thread_t *p_intf)
{
switch( id )
{
case 1:
QVLCMenu::VideoMenu( p_intf, menu ); break;
case 2:
QVLCMenu::AudioMenu( p_intf, menu ); break;
case 3:
QVLCMenu::NavigMenu( p_intf, menu ); break;
case 4:
QVLCMenu::InterfacesMenu( p_intf, menu ); break;
}
};
int id; QMenu *menu;
}; };
#endif #endif
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <QEvent> #include <QEvent>
class QApplication; class QApplication;
class QMenu;
class MainInterface; class MainInterface;
class DialogsProvider; class DialogsProvider;
class VideoWidget; class VideoWidget;
...@@ -41,10 +42,13 @@ struct intf_sys_t ...@@ -41,10 +42,13 @@ struct intf_sys_t
VideoWidget *p_video; VideoWidget *p_video;
int i_saved_height, i_saved_width; int i_saved_height, i_saved_width;
QMenu * p_popup_menu;
}; };
#define THEPL p_intf->p_sys->p_playlist #define THEPL p_intf->p_sys->p_playlist
#define THEDP DialogsProvider::getInstance() #define THEDP DialogsProvider::getInstance()
#define THEMIM MainInputManager::getInstance( NULL )
static int DialogEvent_Type = QEvent::User + 1; static int DialogEvent_Type = QEvent::User + 1;
......
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