[vlc-devel] [PATCH v2 04/11] qt: use vlc_actions
Hugo Beauzée-Luyssen
hugo at beauzee.fr
Wed Aug 9 18:16:28 CEST 2017
From: Thomas Guillem <thomas at gllm.fr>
---
modules/gui/qt/actions_manager.cpp | 35 +++++---------------
modules/gui/qt/input_manager.cpp | 65 ++++++++++----------------------------
modules/gui/qt/qt.hpp | 1 +
3 files changed, 25 insertions(+), 76 deletions(-)
diff --git a/modules/gui/qt/actions_manager.cpp b/modules/gui/qt/actions_manager.cpp
index cc67ff1c0d..9bc81da7a3 100644
--- a/modules/gui/qt/actions_manager.cpp
+++ b/modules/gui/qt/actions_manager.cpp
@@ -125,11 +125,10 @@ void ActionsManager::play()
*/
void ActionsManager::fullscreen()
{
- bool fs = var_ToggleBool( THEPL, "fullscreen" );
vout_thread_t *p_vout = THEMIM->getVout();
- if( p_vout)
+ if( p_vout )
{
- var_SetBool( p_vout, "fullscreen", fs );
+ ACTION_DO( ACTIONID_TOGGLE_FULLSCREEN, 1, p_vout );
vlc_object_release( p_vout );
}
}
@@ -139,7 +138,7 @@ void ActionsManager::snapshot()
vout_thread_t *p_vout = THEMIM->getVout();
if( p_vout )
{
- var_TriggerCallback( p_vout, "video-snapshot" );
+ ACTION_DO( ACTIONID_SNAPSHOT, 1, p_vout );
vlc_object_release( p_vout );
}
}
@@ -153,46 +152,28 @@ 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, 1, p_input );
}
void ActionsManager::frame()
{
input_thread_t *p_input = THEMIM->getInput();
- if( p_input )
- var_TriggerCallback( p_input, "frame-next" );
+ ACTION_DO( ACTIONID_FRAME_NEXT, 1, p_input );
}
void ActionsManager::toggleMuteAudio()
{
- playlist_MuteToggle( THEPL );
+ ACTION_DO( ACTIONID_VOL_MUTE, 0 );
}
void ActionsManager::AudioUp()
{
- playlist_VolumeUp( THEPL, 1, NULL );
+ ACTION_DO( ACTIONID_VOL_UP, 0 );
}
void ActionsManager::AudioDown()
{
- playlist_VolumeDown( THEPL, 1, NULL );
+ ACTION_DO( ACTIONID_VOL_DOWN, 0 );
}
void ActionsManager::skipForward()
diff --git a/modules/gui/qt/input_manager.cpp b/modules/gui/qt/input_manager.cpp
index ede449141f..ae6c638ed9 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, 0 );
}
void InputManager::faster()
{
- var_TriggerCallback( THEPL, "rate-faster" );
+ ACTION_DO( ACTIONID_FASTER, 0 );
}
void InputManager::littlefaster()
{
- var_SetInteger( p_intf->obj.libvlc, "key-action", ACTIONID_RATE_FASTER_FINE );
+ ACTION_DO( ACTIONID_RATE_FASTER_FINE, 0 );
}
void InputManager::littleslower()
{
- var_SetInteger( p_intf->obj.libvlc, "key-action", ACTIONID_RATE_SLOWER_FINE );
+ ACTION_DO( ACTIONID_RATE_SLOWER_FINE, 0 );
}
void InputManager::normalRate()
{
- var_SetFloat( THEPL, "rate", 1. );
+ ACTION_DO( ACTIONID_RATE_NORMAL, 0 );
}
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, 1, p_input );
}
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, 1, p_input );
}
void InputManager::setAtoB()
@@ -1103,45 +1093,45 @@ void MainInputManager::probeCurrentInput()
/* Playlist Control functions */
void MainInputManager::stop()
{
- playlist_Stop( THEPL );
+ ACTION_DO( ACTIONID_STOP, 0 );
}
void MainInputManager::next()
{
- playlist_Next( THEPL );
+ ACTION_DO( ACTIONID_NEXT, 0 );
}
void MainInputManager::prev()
{
- playlist_Prev( THEPL );
+ ACTION_DO( ACTIONID_PREV, 0 );
}
void MainInputManager::prevOrReset()
{
if( !p_input || var_GetInteger( p_input, "time") < INT64_C(10000) )
- playlist_Prev( THEPL );
+ ACTION_DO( ACTIONID_PREV, 0 );
else
getIM()->sliderUpdate( 0.0 );
}
void MainInputManager::togglePlayPause()
{
- playlist_TogglePause( THEPL );
+ ACTION_DO( ACTIONID_PLAY_PAUSE, 1, p_input );
}
void MainInputManager::play()
{
- playlist_Play( THEPL );
+ ACTION_DO( ACTIONID_PLAY, 1, p_input );
}
void MainInputManager::pause()
{
- playlist_Pause( THEPL );
+ ACTION_DO( ACTIONID_PAUSE, 1, p_input );
}
void MainInputManager::toggleRandom()
{
- config_PutInt( p_intf, "random", var_ToggleBool( THEPL, "random" ) );
+ ACTION_DO( ACTIONID_RANDOM, 0 );
}
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, 0 );
}
void MainInputManager::activatePlayQuit( bool b_exit )
diff --git a/modules/gui/qt/qt.hpp b/modules/gui/qt/qt.hpp
index 569945ebb0..f4708d4a40 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, nb, ...) vlc_actions_do( p_intf, (id), true, nb, ##__VA_ARGS__ )
/**
* This class may be used for scope-bound locking/unlocking
--
2.11.0
More information about the vlc-devel
mailing list