Commit 6b65c19e authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt: allow loop/repeat button to be in a toolbar (part 2)

Action and states consistency
parent 99748d1f
...@@ -372,6 +372,10 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options ) ...@@ -372,6 +372,10 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
setupButton( loopButton ); setupButton( loopButton );
loopButton->setToolTip( qtr( "Click to toggle between loop one, loop all" ) ); loopButton->setToolTip( qtr( "Click to toggle between loop one, loop all" ) );
loopButton->setCheckable( true ); loopButton->setCheckable( true );
loopButton->updateIcons( NORMAL );
CONNECT( THEMIM, repeatLoopChanged( int ), loopButton, updateIcons( int ) );
CONNECT( loopButton, clicked(), THEMIM, loopRepeatLoopStatus() );
widget = loopButton;
} }
break; break;
default: default:
......
...@@ -235,22 +235,9 @@ void AtoB_Button::setIcons( bool timeA, bool timeB ) ...@@ -235,22 +235,9 @@ void AtoB_Button::setIcons( bool timeA, bool timeB )
} }
} }
void LoopButton::update() void LoopButton::updateIcons( int value )
{ {
/* if( model->hasRepeat() ) setChecked( value != NORMAL );
{ setIcon( ( value == REPEAT_ALL ) ? QIcon( ":/buttons/playlist/repeat_all" )
repeatButton->setIcon( QIcon( ":/buttons/playlist/repeat_one" ) ); : QIcon( ":/buttons/playlist/repeat_one" ) );
repeatButton->setChecked( true );
}
else if( model->hasLoop() )
{
repeatButton->setIcon( QIcon( ":/buttons/playlist/repeat_all" ) );
repeatButton->setChecked( true );
}
else
{
repeatButton->setIcon( QIcon( ":/buttons/playlist/repeat_one" ) );
repeatButton->setChecked( false );
}*/
//BUTTONACT( repeatButton, toggleRepeat() );
} }
...@@ -56,8 +56,8 @@ private slots: ...@@ -56,8 +56,8 @@ private slots:
class LoopButton : public QToolButton class LoopButton : public QToolButton
{ {
Q_OBJECT Q_OBJECT
private slots: public slots:
void update(); void updateIcons( int );
}; };
class AtoB_Button : public QToolButton class AtoB_Button : public QToolButton
......
...@@ -48,6 +48,10 @@ static int VolumeChanged( vlc_object_t *, const char *, ...@@ -48,6 +48,10 @@ static int VolumeChanged( vlc_object_t *, const char *,
static int RandomChanged( vlc_object_t *, const char *, static int RandomChanged( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * ); vlc_value_t, vlc_value_t, void * );
static int LoopChanged( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
static int RepeatChanged( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
static int InputEvent( vlc_object_t *, const char *, static int InputEvent( vlc_object_t *, const char *,
...@@ -893,6 +897,8 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf ) ...@@ -893,6 +897,8 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf )
var_AddCallback( THEPL, "playlist-item-append", PLItemAppended, this ); var_AddCallback( THEPL, "playlist-item-append", PLItemAppended, this );
var_AddCallback( THEPL, "playlist-item-deleted", PLItemRemoved, this ); var_AddCallback( THEPL, "playlist-item-deleted", PLItemRemoved, this );
var_AddCallback( THEPL, "random", RandomChanged, this ); var_AddCallback( THEPL, "random", RandomChanged, this );
var_AddCallback( THEPL, "repeat", RepeatChanged, this );
var_AddCallback( THEPL, "loop", LoopChanged, this );
var_AddCallback( p_intf->p_libvlc, "volume-change", VolumeChanged, this ); var_AddCallback( p_intf->p_libvlc, "volume-change", VolumeChanged, this );
...@@ -932,6 +938,10 @@ MainInputManager::~MainInputManager() ...@@ -932,6 +938,10 @@ MainInputManager::~MainInputManager()
var_DelCallback( THEPL, "item-current", PLItemChanged, this ); var_DelCallback( THEPL, "item-current", PLItemChanged, this );
var_DelCallback( THEPL, "playlist-item-append", PLItemAppended, this ); var_DelCallback( THEPL, "playlist-item-append", PLItemAppended, this );
var_DelCallback( THEPL, "playlist-item-deleted", PLItemRemoved, this ); var_DelCallback( THEPL, "playlist-item-deleted", PLItemRemoved, this );
var_DelCallback( THEPL, "random", RandomChanged, this );
var_DelCallback( THEPL, "repeat", RepeatChanged, this );
var_DelCallback( THEPL, "loop", LoopChanged, this );
} }
vout_thread_t* MainInputManager::getVout() vout_thread_t* MainInputManager::getVout()
...@@ -967,6 +977,10 @@ void MainInputManager::customEvent( QEvent *event ) ...@@ -967,6 +977,10 @@ void MainInputManager::customEvent( QEvent *event )
case RandomChanged_Type: case RandomChanged_Type:
emit randomChanged( var_GetBool( THEPL, "random" ) ); emit randomChanged( var_GetBool( THEPL, "random" ) );
return; return;
case LoopChanged_Type:
case RepeatChanged_Type:
notifyRepeatLoop();
return;
default: default:
if( type != ItemChanged_Type ) return; if( type != ItemChanged_Type ) return;
} }
...@@ -1042,6 +1056,28 @@ void MainInputManager::toggleRandom() ...@@ -1042,6 +1056,28 @@ void MainInputManager::toggleRandom()
var_ToggleBool( THEPL, "random" ); var_ToggleBool( THEPL, "random" );
} }
void MainInputManager::notifyRepeatLoop()
{
int i_value = var_GetBool( THEPL, "loop" ) * REPEAT_ONE
+ var_GetBool( THEPL, "repeat" ) * REPEAT_ALL;
emit repeatLoopChanged( i_value );
}
void MainInputManager::loopRepeatLoopStatus()
{
/* Toggle Normal -> Loop -> Repeat -> Normal ... */
if( var_GetBool( THEPL, "repeat" ) )
var_SetBool( THEPL, "repeat", false );
else if( var_GetBool( THEPL, "loop" ) )
{
var_SetBool( THEPL, "loop", false );
var_SetBool( THEPL, "repeat", true );
}
else
var_SetBool( THEPL, "loop", true );
}
void MainInputManager::activatePlayQuit( bool b_exit ) void MainInputManager::activatePlayQuit( bool b_exit )
{ {
var_SetBool( THEPL, "play-and-exit", b_exit ); var_SetBool( THEPL, "play-and-exit", b_exit );
...@@ -1097,3 +1133,24 @@ static int RandomChanged ...@@ -1097,3 +1133,24 @@ static int RandomChanged
QApplication::postEvent( mim, event ); QApplication::postEvent( mim, event );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
/* Probably could be merged with next callback */
static int LoopChanged
( vlc_object_t * obj, const char *var, vlc_value_t old, vlc_value_t cur, void *data )
{
MainInputManager *mim = static_cast<MainInputManager*>(data);
IMEvent *event = new IMEvent( LoopChanged_Type );
QApplication::postEvent( mim, event );
return VLC_SUCCESS;
}
static int RepeatChanged
( vlc_object_t * obj, const char *var, vlc_value_t old, vlc_value_t cur, void *data )
{
MainInputManager *mim = static_cast<MainInputManager*>(data);
IMEvent *event = new IMEvent( RepeatChanged_Type );
QApplication::postEvent( mim, event );
return VLC_SUCCESS;
}
...@@ -58,6 +58,8 @@ enum { ...@@ -58,6 +58,8 @@ enum {
RecordingEvent_Type, RecordingEvent_Type,
ProgramChanged_Type, ProgramChanged_Type,
RandomChanged_Type, RandomChanged_Type,
LoopChanged_Type,
RepeatChanged_Type,
/* SignalChanged_Type, */ /* SignalChanged_Type, */
FullscreenControlToggle_Type = QEvent::User + IMEventType + 20, FullscreenControlToggle_Type = QEvent::User + IMEventType + 20,
...@@ -66,6 +68,11 @@ enum { ...@@ -66,6 +68,11 @@ enum {
FullscreenControlPlanHide_Type, FullscreenControlPlanHide_Type,
}; };
enum { NORMAL, /* loop: 0, repeat: 0 */
REPEAT_ONE,/* loop: 1, repeat: 0 */
REPEAT_ALL,/* loop: 0, repeat: 1 */
};
class IMEvent : public QEvent class IMEvent : public QEvent
{ {
friend class InputManager; friend class InputManager;
...@@ -257,6 +264,7 @@ private: ...@@ -257,6 +264,7 @@ private:
input_thread_t *p_input; input_thread_t *p_input;
intf_thread_t *p_intf; intf_thread_t *p_intf;
void notifyRepeatLoop();
public slots: public slots:
void togglePlayPause(); void togglePlayPause();
void toggleRandom(); void toggleRandom();
...@@ -265,12 +273,15 @@ public slots: ...@@ -265,12 +273,15 @@ public slots:
void prev(); void prev();
void activatePlayQuit( bool ); void activatePlayQuit( bool );
void loopRepeatLoopStatus();
signals: signals:
void inputChanged( input_thread_t * ); void inputChanged( input_thread_t * );
void volumeChanged(); void volumeChanged();
void playlistItemAppended( int itemId, int parentId ); void playlistItemAppended( int itemId, int parentId );
void playlistItemRemoved( int itemId ); void playlistItemRemoved( int itemId );
void randomChanged( bool ); void randomChanged( bool );
void repeatLoopChanged( int );
}; };
#endif #endif
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