Commit c37a9dfc authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt4 - popupMenu and AlwaysOnTop. Needs testing.

Mostly patch by  Sergey Volk

parent 5b4d0319
...@@ -103,11 +103,15 @@ void DialogsProvider::customEvent( QEvent *event ) ...@@ -103,11 +103,15 @@ void DialogsProvider::customEvent( QEvent *event )
bookmarksDialog(); break; bookmarksDialog(); break;
case INTF_DIALOG_EXTENDED: case INTF_DIALOG_EXTENDED:
extendedDialog(); break; extendedDialog(); break;
/* We might want to make it better with custom functions */
case INTF_DIALOG_POPUPMENU: case INTF_DIALOG_POPUPMENU:
QVLCMenu::PopupMenu( p_intf ); break;
case INTF_DIALOG_AUDIOPOPUPMENU: case INTF_DIALOG_AUDIOPOPUPMENU:
QVLCMenu::AudioPopupMenu( p_intf ); break;
case INTF_DIALOG_VIDEOPOPUPMENU: case INTF_DIALOG_VIDEOPOPUPMENU:
QVLCMenu::VideoPopupMenu( p_intf ); break;
case INTF_DIALOG_MISCPOPUPMENU: case INTF_DIALOG_MISCPOPUPMENU:
popupMenu( de->i_dialog ); break; QVLCMenu::MiscPopupMenu( p_intf ); break;
case INTF_DIALOG_INTERACTION: case INTF_DIALOG_INTERACTION:
doInteraction( de->p_arg ); break; doInteraction( de->p_arg ); break;
case INTF_DIALOG_VLM: case INTF_DIALOG_VLM:
...@@ -457,7 +461,3 @@ void DialogsProvider::switchToSkins() ...@@ -457,7 +461,3 @@ void DialogsProvider::switchToSkins()
{ {
var_SetString( p_intf, "intf-switch", "skins2" ); var_SetString( p_intf, "intf-switch", "skins2" );
} }
void DialogsProvider::popupMenu( int i_dialog )
{
}
...@@ -136,7 +136,6 @@ public slots: ...@@ -136,7 +136,6 @@ public slots:
void openDiscDialog(); void openDiscDialog();
void PLAppendDialog(); void PLAppendDialog();
void MLAppendDialog(); void MLAppendDialog();
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 menuUpdateAction( QObject *);
......
...@@ -182,7 +182,7 @@ void InputManager::sectionPrev() ...@@ -182,7 +182,7 @@ void InputManager::sectionPrev()
{ {
if( hasInput() ) if( hasInput() )
{ {
int i_type = var_Type( p_input, "prev-chapter" ); int i_type = var_Type( p_input, "next-chapter" );
vlc_value_t val; val.b_bool = VLC_TRUE; vlc_value_t val; val.b_bool = VLC_TRUE;
var_Set( p_input, (i_type & VLC_VAR_TYPE) != 0 ? var_Set( p_input, (i_type & VLC_VAR_TYPE) != 0 ?
"prev-chapter":"prev-title", val ); "prev-chapter":"prev-title", val );
...@@ -271,6 +271,21 @@ void MainInputManager::updateInput() ...@@ -271,6 +271,21 @@ void MainInputManager::updateInput()
vlc_mutex_unlock( &p_intf->change_lock ); vlc_mutex_unlock( &p_intf->change_lock );
} }
void MainInputManager::stop()
{
playlist_Stop( THEPL );
}
void MainInputManager::next()
{
playlist_Next( THEPL );
}
void MainInputManager::prev()
{
playlist_Prev( THEPL );
}
void MainInputManager::togglePlayPause() void MainInputManager::togglePlayPause()
{ {
if( p_input == NULL ) if( p_input == NULL )
...@@ -281,7 +296,6 @@ void MainInputManager::togglePlayPause() ...@@ -281,7 +296,6 @@ void MainInputManager::togglePlayPause()
getIM()->togglePlayPause(); getIM()->togglePlayPause();
} }
static int ChangeAudio( vlc_object_t *p_this, const char *var, vlc_value_t o, static int ChangeAudio( vlc_object_t *p_this, const char *var, vlc_value_t o,
vlc_value_t n, void *param ) vlc_value_t n, void *param )
{ {
......
...@@ -94,6 +94,9 @@ private: ...@@ -94,6 +94,9 @@ private:
MainInputManager( intf_thread_t *); MainInputManager( intf_thread_t *);
public slots: public slots:
void togglePlayPause(); void togglePlayPause();
void stop();
void next();
void prev();
private slots: private slots:
void updateInput(); void updateInput();
signals: signals:
......
...@@ -58,6 +58,11 @@ ...@@ -58,6 +58,11 @@
#define DS(i) i.width(),i.height() #define DS(i) i.width(),i.height()
/* Callback prototypes */
static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
vlc_value_t old_val, vlc_value_t new_val, void *param );
static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
vlc_value_t old_val, vlc_value_t new_val, void *param );
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 *);
/* Video handling */ /* Video handling */
...@@ -81,6 +86,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -81,6 +86,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
settings = new QSettings( "VideoLAN", "VLC" ); settings = new QSettings( "VideoLAN", "VLC" );
settings->beginGroup( "MainWindow" ); settings->beginGroup( "MainWindow" );
setWindowIcon( QApplication::windowIcon() );
need_components_update = false; need_components_update = false;
bgWidget = NULL; videoWidget = NULL; playlistWidget = NULL; bgWidget = NULL; videoWidget = NULL; playlistWidget = NULL;
embeddedPlaylistWasActive = videoIsActive = false; embeddedPlaylistWasActive = videoIsActive = false;
...@@ -136,10 +143,30 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -136,10 +143,30 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
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 );
p_intf->b_interaction = VLC_TRUE; p_intf->b_interaction = VLC_TRUE;
/* Register callback for the intf-popupmenu variable */
playlist_t *p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( p_playlist != NULL )
{
var_AddCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf );
var_AddCallback( p_playlist, "intf-show", IntfShowCB, p_intf );
vlc_object_release( p_playlist );
}
} }
MainInterface::~MainInterface() MainInterface::~MainInterface()
{ {
/* Unregister callback for the intf-popupmenu variable */
playlist_t *p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( p_playlist != NULL )
{
var_DelCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf );
var_DelCallback( p_playlist, "intf-show", IntfShowCB, p_intf );
vlc_object_release( p_playlist );
}
settings->setValue( "playlist-embedded", playlistEmbeddedFlag ); settings->setValue( "playlist-embedded", playlistEmbeddedFlag );
settings->setValue( "adv-controls", advControlsEnabled ); settings->setValue( "adv-controls", advControlsEnabled );
settings->setValue( "pos", pos() ); settings->setValue( "pos", pos() );
...@@ -328,6 +355,23 @@ void MainInterface::releaseVideo( void *p_win ) ...@@ -328,6 +355,23 @@ void MainInterface::releaseVideo( void *p_win )
need_components_update = true; need_components_update = true;
} }
class SetVideoOnTopQtEvent : public QEvent
{
public:
SetVideoOnTopQtEvent( bool _onTop ) :
QEvent( (QEvent::Type)SetVideoOnTopEvent_Type ), onTop( _onTop)
{
}
bool OnTop() const
{
return onTop;
}
private:
bool onTop;
};
int MainInterface::controlVideo( void *p_window, int i_query, va_list args ) int MainInterface::controlVideo( void *p_window, int i_query, va_list args )
{ {
int i_ret = VLC_EGENERIC; int i_ret = VLC_EGENERIC;
...@@ -353,6 +397,12 @@ int MainInterface::controlVideo( void *p_window, int i_query, va_list args ) ...@@ -353,6 +397,12 @@ int MainInterface::controlVideo( void *p_window, int i_query, va_list args )
break; break;
} }
case VOUT_SET_STAY_ON_TOP: case VOUT_SET_STAY_ON_TOP:
{
int i_arg = va_arg( args, int );
QApplication::postEvent( this, new SetVideoOnTopQtEvent( i_arg ) );
i_ret = VLC_SUCCESS;
break;
}
default: default:
msg_Warn( p_intf, "unsupported control query" ); msg_Warn( p_intf, "unsupported control query" );
break; break;
...@@ -487,6 +537,15 @@ void MainInterface::customEvent( QEvent *event ) ...@@ -487,6 +537,15 @@ void MainInterface::customEvent( QEvent *event )
visualSelectorEnabled); visualSelectorEnabled);
playlist(); playlist();
} }
else if ( event->type() == SetVideoOnTopEvent_Type )
{
SetVideoOnTopQtEvent* p_event = (SetVideoOnTopQtEvent*)event;
if( p_event->OnTop() )
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
else
setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint);
show(); /* necessary to apply window flags?? */
}
} }
...@@ -560,7 +619,7 @@ void MainInterface::wheelEvent( QWheelEvent *e ) ...@@ -560,7 +619,7 @@ void MainInterface::wheelEvent( QWheelEvent *e )
void MainInterface::stop() void MainInterface::stop()
{ {
playlist_Stop( THEPL ); THEMIM->stop();
} }
void MainInterface::play() void MainInterface::play()
{ {
...@@ -575,11 +634,11 @@ void MainInterface::play() ...@@ -575,11 +634,11 @@ void MainInterface::play()
} }
void MainInterface::prev() void MainInterface::prev()
{ {
playlist_Prev( THEPL ); THEMIM->prev();
} }
void MainInterface::next() void MainInterface::next()
{ {
playlist_Next( THEPL ); THEMIM->next();
} }
void MainInterface::setDisplay( float pos, int time, int length ) void MainInterface::setDisplay( float pos, int time, int length )
...@@ -692,3 +751,34 @@ static int InteractCallback( vlc_object_t *p_this, ...@@ -692,3 +751,34 @@ static int InteractCallback( vlc_object_t *p_this,
QApplication::postEvent( THEDP, static_cast<QEvent*>(event) ); QApplication::postEvent( THEDP, static_cast<QEvent*>(event) );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
/*****************************************************************************
* PopupMenuCB: callback triggered by the intf-popupmenu playlist variable.
* We don't show the menu directly here because we don't want the
* caller to block for a too long time.
*****************************************************************************/
static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
vlc_value_t old_val, vlc_value_t new_val, void *param )
{
intf_thread_t *p_intf = (intf_thread_t *)param;
if( p_intf->pf_show_dialog )
{
p_intf->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU,
new_val.b_bool, 0 );
}
return VLC_SUCCESS;
}
/*****************************************************************************
* IntfShowCB: callback triggered by the intf-show playlist variable.
*****************************************************************************/
static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
vlc_value_t old_val, vlc_value_t new_val, void *param )
{
intf_thread_t *p_intf = (intf_thread_t *)param;
//p_intf->p_sys->b_intf_show = VLC_TRUE;
return VLC_SUCCESS;
}
...@@ -717,8 +717,9 @@ void QVLCMenu::CreateItem( QMenu *menu, const char *psz_var, ...@@ -717,8 +717,9 @@ void QVLCMenu::CreateItem( QMenu *menu, const char *psz_var,
case VLC_VAR_BOOL: case VLC_VAR_BOOL:
var_Get( p_object, psz_var, &val ); var_Get( p_object, psz_var, &val );
val.b_bool = !val.b_bool;
CreateAndConnect( menu, psz_var, TEXT_OR_VAR, "", ITEM_CHECK, CreateAndConnect( menu, psz_var, TEXT_OR_VAR, "", ITEM_CHECK,
p_object->i_object_id, val, i_type, val.b_bool ); p_object->i_object_id, val, i_type, !val.b_bool );
break; break;
} }
FREENULL( text.psz_string ); FREENULL( text.psz_string );
......
...@@ -156,6 +156,8 @@ static void Init( intf_thread_t *p_intf ) ...@@ -156,6 +156,8 @@ static void Init( intf_thread_t *p_intf )
playlist_Control( THEPL, PLAYLIST_AUTOPLAY, VLC_FALSE ); playlist_Control( THEPL, PLAYLIST_AUTOPLAY, VLC_FALSE );
} }
p_intf->pf_show_dialog = ShowDialog;
app->setQuitOnLastWindowClosed( false ); app->setQuitOnLastWindowClosed( false );
app->exec(); app->exec();
MainInputManager::killInstance(); MainInputManager::killInstance();
......
...@@ -82,6 +82,7 @@ struct intf_sys_t ...@@ -82,6 +82,7 @@ struct intf_sys_t
static int DialogEvent_Type = QEvent::User + 1; static int DialogEvent_Type = QEvent::User + 1;
static int PLUndockEvent_Type = QEvent::User + 2; static int PLUndockEvent_Type = QEvent::User + 2;
static int PLDockEvent_Type = QEvent::User + 3; static int PLDockEvent_Type = QEvent::User + 3;
static int SetVideoOnTopEvent_Type = QEvent::User + 4;
class DialogEvent : public QEvent class DialogEvent : public QEvent
{ {
......
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