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 )
setupButton( loopButton );
loopButton->setToolTip( qtr( "Click to toggle between loop one, loop all" ) );
loopButton->setCheckable( true );
loopButton->updateIcons( NORMAL );
CONNECT( THEMIM, repeatLoopChanged( int ), loopButton, updateIcons( int ) );
CONNECT( loopButton, clicked(), THEMIM, loopRepeatLoopStatus() );
widget = loopButton;
}
break;
default:
......
......@@ -235,22 +235,9 @@ void AtoB_Button::setIcons( bool timeA, bool timeB )
}
}
void LoopButton::update()
void LoopButton::updateIcons( int value )
{
/* if( model->hasRepeat() )
{
repeatButton->setIcon( 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() );
setChecked( value != NORMAL );
setIcon( ( value == REPEAT_ALL ) ? QIcon( ":/buttons/playlist/repeat_all" )
: QIcon( ":/buttons/playlist/repeat_one" ) );
}
......@@ -56,8 +56,8 @@ private slots:
class LoopButton : public QToolButton
{
Q_OBJECT
private slots:
void update();
public slots:
void updateIcons( int );
};
class AtoB_Button : public QToolButton
......
......@@ -48,6 +48,10 @@ static int VolumeChanged( vlc_object_t *, const char *,
static int RandomChanged( vlc_object_t *, const char *,
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 *,
......@@ -893,6 +897,8 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf )
var_AddCallback( THEPL, "playlist-item-append", PLItemAppended, this );
var_AddCallback( THEPL, "playlist-item-deleted", PLItemRemoved, 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 );
......@@ -932,6 +938,10 @@ MainInputManager::~MainInputManager()
var_DelCallback( THEPL, "item-current", PLItemChanged, this );
var_DelCallback( THEPL, "playlist-item-append", PLItemAppended, 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()
......@@ -967,6 +977,10 @@ void MainInputManager::customEvent( QEvent *event )
case RandomChanged_Type:
emit randomChanged( var_GetBool( THEPL, "random" ) );
return;
case LoopChanged_Type:
case RepeatChanged_Type:
notifyRepeatLoop();
return;
default:
if( type != ItemChanged_Type ) return;
}
......@@ -1042,6 +1056,28 @@ void MainInputManager::toggleRandom()
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 )
{
var_SetBool( THEPL, "play-and-exit", b_exit );
......@@ -1097,3 +1133,24 @@ static int RandomChanged
QApplication::postEvent( mim, event );
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 {
RecordingEvent_Type,
ProgramChanged_Type,
RandomChanged_Type,
LoopChanged_Type,
RepeatChanged_Type,
/* SignalChanged_Type, */
FullscreenControlToggle_Type = QEvent::User + IMEventType + 20,
......@@ -66,6 +68,11 @@ enum {
FullscreenControlPlanHide_Type,
};
enum { NORMAL, /* loop: 0, repeat: 0 */
REPEAT_ONE,/* loop: 1, repeat: 0 */
REPEAT_ALL,/* loop: 0, repeat: 1 */
};
class IMEvent : public QEvent
{
friend class InputManager;
......@@ -257,6 +264,7 @@ private:
input_thread_t *p_input;
intf_thread_t *p_intf;
void notifyRepeatLoop();
public slots:
void togglePlayPause();
void toggleRandom();
......@@ -265,12 +273,15 @@ public slots:
void prev();
void activatePlayQuit( bool );
void loopRepeatLoopStatus();
signals:
void inputChanged( input_thread_t * );
void volumeChanged();
void playlistItemAppended( int itemId, int parentId );
void playlistItemRemoved( int itemId );
void randomChanged( bool );
void repeatLoopChanged( int );
};
#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