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 ) :
connect( menusMapper, SIGNAL( mapped(QObject *) ), this,
SLOT(menuAction( QObject *)) );
menusUpdateMapper = new QSignalMapper();
connect( menusMapper, SIGNAL( mapped(QObject *) ), this,
SLOT(menuUpdateAction( QObject *)) );
}
DialogsProvider::~DialogsProvider()
......@@ -152,6 +155,12 @@ void DialogsProvider::menuAction( QObject *data )
QVLCMenu::DoAction( p_intf, data );
}
void DialogsProvider::menuUpdateAction( QObject *data )
{
MenuFunc * f = qobject_cast<MenuFunc *>(data);
f->doFunc( p_intf );
}
void DialogsProvider::simpleOpenDialog()
{
}
......
......@@ -56,6 +56,7 @@ public:
protected:
friend class QVLCMenu;
QSignalMapper *menusMapper;
QSignalMapper *menusUpdateMapper;
void customEvent( QEvent *);
private:
DialogsProvider( intf_thread_t *);
......@@ -73,6 +74,7 @@ public slots:
void popupMenu( int );
void doInteraction( intf_dialog_args_t * );
void menuAction( QObject *);
void menuUpdateAction( QObject *);
void streamingDialog();
};
......
......@@ -34,10 +34,10 @@
InputManager::InputManager( QObject *parent, intf_thread_t *_p_intf) :
QObject( parent ), p_intf( _p_intf )
{
i_old_playing_status = END_S;
p_input = NULL;
/* Subscribe to updates */
connect( DialogsProvider::getInstance( p_intf )->fixed_timer,
SIGNAL( timeout() ), this, SLOT( update() ) );
connect( THEDP->fixed_timer, SIGNAL( timeout() ), this, SLOT( update() ) );
}
InputManager::~InputManager()
......@@ -103,6 +103,14 @@ void InputManager::update()
}
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 )
......@@ -111,6 +119,24 @@ void InputManager::sliderUpdate( float 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
* take care of updating the main playlist input
......@@ -157,3 +183,13 @@ void MainInputManager::updateInput()
}
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:
private:
intf_thread_t *p_intf;
input_thread_t *p_input;
int i_old_playing_status;
public slots:
void togglePlayPause();
void update(); ///< Periodic updates
void setInput( input_thread_t * ); ///< Our controlled input changed
void sliderUpdate( float ); ///< User dragged the slider. We get new pos
......@@ -70,6 +72,8 @@ private:
input_thread_t *p_input;
static MainInputManager *instance;
MainInputManager( intf_thread_t *);
public slots:
void togglePlayPause();
private slots:
void updateInput();
signals:
......
......@@ -30,6 +30,7 @@
#include <QCloseEvent>
#include <assert.h>
#include <QPushButton>
#include "menus.hpp"
static int InteractCallback( vlc_object_t *, const char *, vlc_value_t,
vlc_value_t, void *);
......@@ -57,10 +58,9 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
ui.volLowLabel->setPixmap( QPixmap( ":/pixmaps/volume-low.png" ) );
ui.volHighLabel->setPixmap( QPixmap( ":/pixmaps/volume-high.png" ) );
//QVLCMenu::createMenuBar();
QVLCMenu::createMenuBar( menuBar(), p_intf );
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" ) )
{
......@@ -99,19 +99,18 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
MainInputManager::getInstance( p_intf );
/* Get timer updates */
connect( DialogsProvider::getInstance(NULL)->fixed_timer,
SIGNAL( timeout() ), this, SLOT(updateOnTimer() ) );
connect( THEDP->fixed_timer, SIGNAL( timeout() ),
this, SLOT(updateOnTimer() ) );
/* Connect the input manager to the GUI elements it manages */
connect( MainInputManager::getInstance( p_intf )->getIM(),
SIGNAL(positionUpdated( float, int, int ) ),
connect( THEMIM->getIM(),SIGNAL(positionUpdated( float, int, int ) ),
slider, SLOT( setPosition( float,int, int ) ) );
connect( slider, SIGNAL( sliderDragged( float ) ),
MainInputManager::getInstance( p_intf )->getIM(),
SLOT( sliderUpdate( float ) ) );
connect( MainInputManager::getInstance( p_intf )->getIM(),
SIGNAL( positionUpdated( float, int, int ) ),
connect( THEMIM->getIM(), SIGNAL( positionUpdated( 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 */
connect( ui.playButton, SLOT( clicked() ), this, SLOT( play() ) );
......@@ -119,8 +118,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
connect( ui.nextButton, SLOT( clicked() ), this, SLOT( next() ) );
connect( ui.prevButton, SLOT( clicked() ), this, SLOT( prev() ) );
connect( ui.playlistButton, SLOT(clicked() ),
DialogsProvider::getInstance( p_intf ), SLOT( playlistDialog() ) );
connect( ui.playlistButton, SLOT(clicked()),
THEDP, SLOT( playlistDialog() ) );
var_Create( p_intf, "interaction", VLC_VAR_ADDRESS );
var_AddCallback( p_intf, "interaction", InteractCallback, this );
......@@ -143,16 +142,8 @@ MainInterface::~MainInterface()
void MainInterface::resizeEvent( QResizeEvent *e )
{
fprintf( stderr, "Resized to %ix%i\n", e->size().width(), e->size().height() );
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() );
videoSize.setHeight( e->size().height() - addSize.height() );
videoSize.setWidth( e->size().width() - addSize.width() );
p_intf->p_sys->p_video->updateGeometry() ;
}
......@@ -162,7 +153,14 @@ void MainInterface::stop()
}
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()
{
......@@ -183,6 +181,15 @@ void MainInterface::setDisplay( float pos, int time, int length )
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()
{
if( p_intf->b_die )
......@@ -206,7 +213,6 @@ static int InteractCallback( vlc_object_t *p_this,
MainInterface *p_interface = (MainInterface*)param;
DialogEvent *event = new DialogEvent( INTF_DIALOG_INTERACTION, 0, p_arg );
QApplication::postEvent( DialogsProvider::getInstance( NULL ),
static_cast<QEvent*>(event) );
QApplication::postEvent( THEDP, static_cast<QEvent*>(event) );
return VLC_SUCCESS;
}
......@@ -53,6 +53,7 @@ private:
input_thread_t *p_input;
Ui::MainInterfaceUI ui;
private slots:
void setStatus( int );
void setDisplay( float, int, int );
void updateOnTimer();
void play();
......
This diff is collapsed.
......@@ -30,7 +30,7 @@
using namespace std;
class QMenu;
class QPoint;
class QMenuBar;
class MenuItemData : public QObject
{
......@@ -58,27 +58,55 @@ class QVLCMenu : public QObject
{
Q_OBJECT;
public:
static void createMenuBar( QMenuBar *, intf_thread_t * );
/* Individual menu builders */
/* Menus */
static QMenu *FileMenu();
static void AudioPopupMenu( intf_thread_t *, const QPoint& );
static void VideoPopupMenu( intf_thread_t *, const QPoint& );
static QMenu *ToolsMenu( intf_thread_t *, bool with_intf = true );
static QMenu *NavigMenu( intf_thread_t * , QMenu * );
static QMenu *VideoMenu( 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 */
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,
int, int, vlc_value_t, int, bool c = false );
static void CreateItem( QMenu *, const char *, vlc_object_t * );
static QMenu *CreateChoicesMenu( const char *, vlc_object_t *, bool );
static void CreateItem( QMenu *, 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
......@@ -28,6 +28,7 @@
#include <QEvent>
class QApplication;
class QMenu;
class MainInterface;
class DialogsProvider;
class VideoWidget;
......@@ -41,10 +42,13 @@ struct intf_sys_t
VideoWidget *p_video;
int i_saved_height, i_saved_width;
QMenu * p_popup_menu;
};
#define THEPL p_intf->p_sys->p_playlist
#define THEDP DialogsProvider::getInstance()
#define THEMIM MainInputManager::getInstance( NULL )
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