[vlc-devel] [PATCH 15/22] qt: use vlc_actions

Rémi Denis-Courmont remi at remlab.net
Thu Aug 3 16:42:40 CEST 2017


Le 3 août 2017 16:10:48 GMT+03:00, "Hugo Beauzée-Luyssen" <hugo at beauzee.fr> a écrit :
>From: Thomas Guillem <thomas at gllm.fr>
>
>---
> modules/gui/qt/actions_manager.cpp | 45 ++++----------------------
>modules/gui/qt/input_manager.cpp   | 65
>++++++++++----------------------------
> modules/gui/qt/qt.hpp              |  1 +
> 3 files changed, 24 insertions(+), 87 deletions(-)
>
>diff --git a/modules/gui/qt/actions_manager.cpp
>b/modules/gui/qt/actions_manager.cpp
>index cc67ff1c0d..bcf1e88e66 100644
>--- a/modules/gui/qt/actions_manager.cpp
>+++ b/modules/gui/qt/actions_manager.cpp
>@@ -125,23 +125,12 @@ void ActionsManager::play()
>  */
> void ActionsManager::fullscreen()
> {
>-    bool fs = var_ToggleBool( THEPL, "fullscreen" );
>-    vout_thread_t *p_vout = THEMIM->getVout();
>-    if( p_vout)
>-    {
>-        var_SetBool( p_vout, "fullscreen", fs );
>-        vlc_object_release( p_vout );
>-    }
>+    ACTION_DO( ACTIONID_TOGGLE_FULLSCREEN );
> }
> 
> void ActionsManager::snapshot()
> {
>-    vout_thread_t *p_vout = THEMIM->getVout();
>-    if( p_vout )
>-    {
>-        var_TriggerCallback( p_vout, "video-snapshot" );
>-        vlc_object_release( p_vout );
>-    }
>+    ACTION_DO( ACTIONID_SNAPSHOT );
> }
> 
> void ActionsManager::playlist()
>@@ -152,47 +141,27 @@ void ActionsManager::playlist()
> 
> void ActionsManager::record()
> {
>-    input_thread_t *p_input = THEMIM->getInput();
>-    if( p_input )
>-    {
>-        /* This method won't work fine if the stream can't be cut
>anywhere */
>-        var_ToggleBool( p_input, "record" );
>-#if 0
>-        else
>-        {
>-            /* 'record' access-filter is not loaded, we open Save
>dialog */
>-            input_item_t *p_item = input_GetItem( p_input );
>-            if( !p_item )
>-                return;
>-
>-            char *psz = input_item_GetURI( p_item );
>-            if( psz )
>-                THEDP->streamingDialog( NULL, qfu(psz), true );
>-        }
>-#endif
>-    }
>+    ACTION_DO( ACTIONID_RECORD );
> }
> 
> void ActionsManager::frame()
> {
>-    input_thread_t *p_input = THEMIM->getInput();
>-    if( p_input )
>-        var_TriggerCallback( p_input, "frame-next" );
>+    ACTION_DO( ACTIONID_FRAME_NEXT );
> }
> 
> void ActionsManager::toggleMuteAudio()
> {
>-    playlist_MuteToggle( THEPL );
>+    ACTION_DO( ACTIONID_VOL_MUTE );
> }
> 
> void ActionsManager::AudioUp()
> {
>-    playlist_VolumeUp( THEPL, 1, NULL );
>+    ACTION_DO( ACTIONID_VOL_UP );
> }
> 
> void ActionsManager::AudioDown()
> {
>-    playlist_VolumeDown( THEPL, 1, NULL );
>+    ACTION_DO( ACTIONID_VOL_DOWN );
> }
> 
> void ActionsManager::skipForward()
>diff --git a/modules/gui/qt/input_manager.cpp
>b/modules/gui/qt/input_manager.cpp
>index ede449141f..0cbcc88b63 100644
>--- a/modules/gui/qt/input_manager.cpp
>+++ b/modules/gui/qt/input_manager.cpp
>@@ -894,27 +894,27 @@ void InputManager::reverse()
> 
> void InputManager::slower()
> {
>-    var_TriggerCallback( THEPL, "rate-slower" );
>+    ACTION_DO( ACTIONID_SLOWER );
> }
> 
> void InputManager::faster()
> {
>-    var_TriggerCallback( THEPL, "rate-faster" );
>+    ACTION_DO( ACTIONID_FASTER );
> }
> 
> void InputManager::littlefaster()
> {
>-    var_SetInteger( p_intf->obj.libvlc, "key-action",
>ACTIONID_RATE_FASTER_FINE );
>+    ACTION_DO( ACTIONID_RATE_FASTER_FINE );
> }
> 
> void InputManager::littleslower()
> {
>-    var_SetInteger( p_intf->obj.libvlc, "key-action",
>ACTIONID_RATE_SLOWER_FINE );
>+    ACTION_DO( ACTIONID_RATE_SLOWER_FINE );
> }
> 
> void InputManager::normalRate()
> {
>-    var_SetFloat( THEPL, "rate", 1. );
>+    ACTION_DO( ACTIONID_RATE_NORMAL );
> }
> 
> void InputManager::setRate( int new_rate )
>@@ -925,22 +925,12 @@ void InputManager::setRate( int new_rate )
> 
> void InputManager::jumpFwd()
> {
>-    int i_interval = var_InheritInteger( p_input, "short-jump-size" );
>-    if( i_interval > 0 && hasInput() )
>-    {
>-        mtime_t val = CLOCK_FREQ * i_interval;
>-        var_SetInteger( p_input, "time-offset", val );
>-    }
>+    ACTION_DO( ACTIONID_JUMP_FORWARD_SHORT );
> }
> 
> void InputManager::jumpBwd()
> {
>-    int i_interval = var_InheritInteger( p_input, "short-jump-size" );
>-    if( i_interval > 0 && hasInput() )
>-    {
>-        mtime_t val = -CLOCK_FREQ * i_interval;
>-        var_SetInteger( p_input, "time-offset", val );
>-    }
>+    ACTION_DO( ACTIONID_JUMP_BACKWARD_SHORT );
> }
> 
> void InputManager::setAtoB()
>@@ -1103,45 +1093,45 @@ void MainInputManager::probeCurrentInput()
> /* Playlist Control functions */
> void MainInputManager::stop()
> {
>-   playlist_Stop( THEPL );
>+    ACTION_DO( ACTIONID_STOP );
> }
> 
> void MainInputManager::next()
> {
>-   playlist_Next( THEPL );
>+    ACTION_DO( ACTIONID_NEXT );
> }
> 
> void MainInputManager::prev()
> {
>-   playlist_Prev( THEPL );
>+    ACTION_DO( ACTIONID_PREV );
> }
> 
> void MainInputManager::prevOrReset()
> {
>    if( !p_input || var_GetInteger( p_input, "time") < INT64_C(10000) )
>-        playlist_Prev( THEPL );
>+        ACTION_DO( ACTIONID_PREV );
>     else
>         getIM()->sliderUpdate( 0.0 );
> }
> 
> void MainInputManager::togglePlayPause()
> {
>-    playlist_TogglePause( THEPL );
>+    ACTION_DO( ACTIONID_PLAY_PAUSE );
> }
> 
> void MainInputManager::play()
> {
>-    playlist_Play( THEPL );
>+    ACTION_DO( ACTIONID_PLAY );
> }
> 
> void MainInputManager::pause()
> {
>-    playlist_Pause( THEPL );
>+    ACTION_DO( ACTIONID_PAUSE );
> }
> 
> void MainInputManager::toggleRandom()
> {
>-    config_PutInt( p_intf, "random", var_ToggleBool( THEPL, "random" )
>);
>+    ACTION_DO( ACTIONID_RANDOM );
> }
> 
> void MainInputManager::notifyRandom(bool value)
>@@ -1161,30 +1151,7 @@ void MainInputManager::notifyRepeatLoop(bool)
> 
> void MainInputManager::loopRepeatLoopStatus()
> {
>-    /* Toggle Normal -> Loop -> Repeat -> Normal ... */
>-    bool loop = var_GetBool( THEPL, "loop" );
>-    bool repeat = var_GetBool( THEPL, "repeat" );
>-
>-    if( repeat )
>-    {
>-        loop = false;
>-        repeat = false;
>-    }
>-    else if( loop )
>-    {
>-        loop = false;
>-        repeat = true;
>-    }
>-    else
>-    {
>-        loop = true;
>-        //repeat = false;
>-    }
>-
>-    var_SetBool( THEPL, "loop", loop );
>-    var_SetBool( THEPL, "repeat", repeat );
>-    config_PutInt( p_intf, "loop", loop );
>-    config_PutInt( p_intf, "repeat", repeat );
>+    ACTION_DO( ACTIONID_LOOP );
> }
> 
> void MainInputManager::activatePlayQuit( bool b_exit )
>diff --git a/modules/gui/qt/qt.hpp b/modules/gui/qt/qt.hpp
>index 569945ebb0..d1b68f98d6 100644
>--- a/modules/gui/qt/qt.hpp
>+++ b/modules/gui/qt/qt.hpp
>@@ -88,6 +88,7 @@ struct intf_sys_t
> };
> 
> #define THEPL p_intf->p_sys->p_playlist
>+#define ACTION_DO(id) vlc_actions_do( p_intf, (id), true)
> 
> /**
>  * This class may be used for scope-bound locking/unlocking
>-- 
>2.11.0
>
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel

This looks like a step backward: You are removing context.
-- 
Rémi Denis-Courmont
Typed on an inconvenient virtual keyboard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20170803/a14036f0/attachment.html>


More information about the vlc-devel mailing list