2
2
* interface_widgets.cpp : Custom widgets for the main interface
3
3
****************************************************************************
4
4
* Copyright ( C ) 2006 the VideoLAN team
5
* $Id: 777da1627ca9135518d195acbe0424a4822facb2 $
5
* $Id: fd2430ca23390a13eec8e3ef85ce5e91b04dc60b $
7
7
* Authors: Clément Stenac <zorglub@videolan.org>
8
8
* Jean-Baptiste Kempf <jb@videolan.org>
317
317
#define setupSmallButton( aButton ){ \
318
318
aButton->setMaximumSize( QSize( 26, 26 ) ); \
319
319
aButton->setMinimumSize( QSize( 26, 26 ) ); \
320
aButton->setIconSize( QSize( 20, 20 ) ); }
320
aButton->setIconSize( QSize( 20, 20 ) ); \
321
aButton->setFocusPolicy( Qt::NoFocus ); \
322
324
/* init static variables in advanced controls */
323
325
mtime_t AdvControlsWidget::timeA = 0;
527
529
slowerButton = new QToolButton;
528
530
slowerButton->setAutoRaise( true );
529
531
slowerButton->setMaximumSize( QSize( 26, 20 ) );
532
slowerButton->setFocusPolicy( Qt::NoFocus );
531
BUTTON_SET_ACT( slowerButton, "-", qtr( "Slower" ), slower() );
534
BUTTON_SET_ACT_I( slowerButton, "", slower, qtr( "Slower" ), slower() );
533
536
fasterButton = new QToolButton;
534
537
fasterButton->setAutoRaise( true );
535
538
fasterButton->setMaximumSize( QSize( 26, 20 ) );
539
fasterButton->setFocusPolicy( Qt::NoFocus );
537
BUTTON_SET_ACT( fasterButton, "+", qtr( "Faster" ), faster() );
541
BUTTON_SET_ACT_I( fasterButton, "", faster, qtr( "Faster" ), faster() );
539
543
/* advanced Controls handling */
540
544
b_advancedVisible = b_advControls;
641
645
playButton = new QPushButton;
642
646
playButton->setSizePolicy( sizePolicy );
643
playButton->setMaximumSize( QSize( 36, 36 ) );
644
playButton->setMinimumSize( QSize( 36, 36 ) );
645
playButton->setIconSize( QSize( 30, 30 ) );
647
playButton->setMaximumSize( QSize( 32, 32 ) );
648
playButton->setMinimumSize( QSize( 32, 32 ) );
649
playButton->setIconSize( QSize( 26, 26 ) );
650
playButton->setFocusPolicy( Qt::NoFocus );
648
652
/** Prev + Stop + Next Block **/
649
653
controlButLayout = new QHBoxLayout;
1017
1021
b_slow_hide_begin(false), i_slow_hide_timeout(1),
1018
1022
b_fullscreen( false ), i_hide_timeout( 1 ), p_vout(NULL)
1024
i_mouse_last_move_x = -1;
1025
i_mouse_last_move_y = -1;
1020
1027
setWindowFlags( Qt::ToolTip );
1028
setMinimumWidth( 600 );
1022
1030
setFrameShape( QFrame::StyledPanel );
1023
1031
setFrameStyle( QFrame::Sunken );
1029
1037
/* First line */
1030
1038
slider->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum);
1031
slider->setMinimumWidth( 220 );
1032
1039
fsLayout->addWidget( slowerButton, 0, 0 );
1033
fsLayout->addWidget( slider, 0, 1, 1, 9 );
1034
fsLayout->addWidget( fasterButton, 0, 10 );
1040
fsLayout->addWidget( slider, 0, 1, 1, 11 );
1041
fsLayout->addWidget( fasterButton, 0, 12 );
1036
1044
fsLayout->addWidget( playButton, 1, 0, 1, 2 );
1037
1045
fsLayout->addLayout( controlButLayout, 1, 2 );
1042
1050
fsLayout->addWidget( advControls, 1, 6, Qt::AlignVCenter );
1044
1052
fsLayout->setColumnStretch( 7, 10 );
1045
fsLayout->addWidget( volMuteLabel, 1, 8 );
1046
fsLayout->addWidget( volumeSlider, 1, 9, 1, 2 );
1054
TimeLabel *timeLabel = new TimeLabel( p_intf );
1056
fsLayout->addWidget( timeLabel, 1, 8 );
1057
fsLayout->addWidget( volMuteLabel, 1, 9 );
1058
fsLayout->addWidget( volumeSlider, 1, 10, 1, 2 );
1048
1060
/* hiding timer */
1049
1061
p_hideTimer = new QTimer( this );
1059
1071
adjustSize (); /* need to get real width and height for moving */
1061
1073
/* center down */
1062
QDesktopWidget * p_desktop = QApplication::desktop();
1074
QWidget * p_desktop = QApplication::desktop()->screen(
1075
QApplication::desktop()->screenNumber( _p_mi ) );
1064
move( p_desktop->width() / 2 - width() / 2,
1077
QPoint pos = QPoint( p_desktop->width() / 2 - width() / 2,
1065
1078
p_desktop->height() - height() );
1080
getSettings()->beginGroup( "FullScreen" );
1081
move( getSettings()->value( "pos", pos ).toPoint() );
1082
getSettings()->endGroup();
1067
1084
#ifdef WIN32TRICK
1068
1085
setWindowOpacity( 0.0 );
1069
1086
b_fscHidden = true;
1079
1096
FullscreenControllerWidget::~FullscreenControllerWidget()
1098
getSettings()->beginGroup( "FullScreen" );
1099
getSettings()->setValue( "pos", pos() );
1100
getSettings()->endGroup();
1082
1102
vlc_mutex_destroy( &lock );
1208
1228
b_fs = b_fullscreen;
1209
1229
vlc_mutex_unlock( &lock );
1211
if( b_fs ) // FIXME I am not sure about that one
1232
if( b_fs && b_fscHidden ) // FIXME I am not sure about that one
1234
if( b_fs && !isVisible() ) // FIXME I am not sure about that one
1214
1238
case FullscreenControlHide_Type:
1293
static int FullscreenControllerWidgetFullscreenChanged( vlc_object_t *vlc_object, const char *variable,
1294
vlc_value_t old_val, vlc_value_t new_val,
1317
static int FullscreenControllerWidgetFullscreenChanged( vlc_object_t *vlc_object,
1318
const char *variable, vlc_value_t old_val,
1319
vlc_value_t new_val, void *data )
1297
1321
vout_thread_t *p_vout = (vout_thread_t *) vlc_object;
1322
msg_Dbg( p_vout, "Qt4: Fullscreen state changed" );
1298
1323
FullscreenControllerWidget *p_fs = (FullscreenControllerWidget *)data;
1300
p_fs->fullscreenChanged( p_vout, new_val.b_bool, var_GetInteger( p_vout, "mouse-hide-timeout" ) );
1325
p_fs->fullscreenChanged( p_vout, new_val.b_bool,
1326
var_GetInteger( p_vout, "mouse-hide-timeout" ) );
1302
1328
return VLC_SUCCESS;
1309
1335
FullscreenControllerWidget *p_fs = (FullscreenControllerWidget *)data;
1312
IMEvent *eShow = new IMEvent( FullscreenControlShow_Type, 0 );
1313
QApplication::postEvent( p_fs, static_cast<QEvent *>(eShow) );
1315
/* Plan hide event */
1316
IMEvent *eHide = new IMEvent( FullscreenControlPlanHide_Type, 0 );
1317
QApplication::postEvent( p_fs, static_cast<QEvent *>(eHide) );
1337
int i_mousex, i_mousey;
1338
bool b_toShow = false;
1340
/* Get the value from the Vout - Trust the vout more than Qt */
1341
i_mousex = var_GetInteger( p_fs->p_vout, "mouse-x" );
1342
i_mousey = var_GetInteger( p_fs->p_vout, "mouse-y" );
1345
if( p_fs->i_mouse_last_move_x == -1 || p_fs->i_mouse_last_move_y == -1 )
1347
p_fs->i_mouse_last_move_x = i_mousex;
1348
p_fs->i_mouse_last_move_y = i_mousey;
1351
/* All other times */
1354
/* Trigger only if move > 3 px dans une direction */
1355
if( abs( p_fs->i_mouse_last_move_x - i_mousex ) > 2 ||
1356
abs( p_fs->i_mouse_last_move_y - i_mousey ) > 2 )
1359
p_fs->i_mouse_last_move_x = i_mousex;
1360
p_fs->i_mouse_last_move_y = i_mousey;
1367
IMEvent *eShow = new IMEvent( FullscreenControlShow_Type, 0 );
1368
QApplication::postEvent( p_fs, static_cast<QEvent *>(eShow) );
1370
/* Plan hide event */
1371
IMEvent *eHide = new IMEvent( FullscreenControlPlanHide_Type, 0 );
1372
QApplication::postEvent( p_fs, static_cast<QEvent *>(eHide) );
1319
1375
return VLC_SUCCESS;
1330
1386
p_vout = p_nvout;
1388
msg_Dbg( p_vout, "Qt FS: Attaching Vout" );
1332
1389
vlc_mutex_lock( &lock );
1333
var_AddCallback( p_vout, "fullscreen", FullscreenControllerWidgetFullscreenChanged, this ); /* I miss a add and fire */
1334
fullscreenChanged( p_vout, var_GetBool( p_vout, "fullscreen" ), var_GetInteger( p_vout, "mouse-hide-timeout" ) );
1391
var_AddCallback( p_vout, "fullscreen",
1392
FullscreenControllerWidgetFullscreenChanged, this );
1393
/* I miss a add and fire */
1394
fullscreenChanged( p_vout, var_GetBool( p_vout, "fullscreen" ),
1395
var_GetInteger( p_vout, "mouse-hide-timeout" ) );
1335
1396
vlc_mutex_unlock( &lock );
1344
var_DelCallback( p_vout, "fullscreen", FullscreenControllerWidgetFullscreenChanged, this );
1405
msg_Dbg( p_vout, "Qt FS: Detaching Vout" );
1406
var_DelCallback( p_vout, "fullscreen",
1407
FullscreenControllerWidgetFullscreenChanged, this );
1345
1408
vlc_mutex_lock( &lock );
1346
1409
fullscreenChanged( p_vout, false, 0 );
1347
1410
vlc_mutex_unlock( &lock );
1353
1416
* Register and unregister callback for mouse moving
1355
void FullscreenControllerWidget::fullscreenChanged( vout_thread_t *p_vout, bool b_fs, int i_timeout )
1418
void FullscreenControllerWidget::fullscreenChanged( vout_thread_t *p_vout,
1419
bool b_fs, int i_timeout )
1421
msg_Dbg( p_vout, "Qt: Changing Fullscreen Mode" );
1357
1423
vlc_mutex_lock( &lock );
1424
/* Entering fullscreen, register callback */
1358
1425
if( b_fs && !b_fullscreen )
1360
1427
b_fullscreen = true;
1361
1428
i_hide_timeout = i_timeout;
1362
var_AddCallback( p_vout, "mouse-moved", FullscreenControllerWidgetMouseMoved, this );
1429
var_AddCallback( p_vout, "mouse-moved",
1430
FullscreenControllerWidgetMouseMoved, this );
1432
/* Quitting fullscreen, unregistering callback */
1364
1433
else if( !b_fs && b_fullscreen )
1366
1435
b_fullscreen = false;
1367
1436
i_hide_timeout = i_timeout;
1368
var_DelCallback( p_vout, "mouse-moved", FullscreenControllerWidgetMouseMoved, this );
1437
var_DelCallback( p_vout, "mouse-moved",
1438
FullscreenControllerWidgetMouseMoved, this );
1370
1440
/* Force fs hidding */
1371
1441
IMEvent *eHide = new IMEvent( FullscreenControlHide_Type, 0 );
1372
1442
QApplication::postEvent( this, static_cast<QEvent *>(eHide) );
1444
/* This is a big, a huge HACK around the windows Video Output,
1445
Since the Vout fusion the Vout Windows, with the main windows
1446
(very nice indeed for Alt-Tab), at the end of the film, when Vout quits
1447
fullscreen, MI isn't properly put in the good state again...
1449
Of course this is not good, but we will have to live with it temporarly
1451
p_intf->p_sys->p_mi->hide();
1452
p_intf->p_sys->p_mi->show();
1374
1455
vlc_mutex_unlock( &lock );
1646
TimeLabel::TimeLabel( intf_thread_t *_p_intf ) :QLabel(), p_intf( _p_intf )
1648
b_remainingTime = false;
1649
setText( " --:--/--:-- " );
1650
setAlignment( Qt::AlignRight | Qt::AlignVCenter );
1651
setToolTip( qtr( "Toggle between elapsed and remaining time" ) );
1654
CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
1655
this, setDisplayPosition( float, int, int ) );
1658
void TimeLabel::setDisplayPosition( float pos, int time, int length )
1660
char psz_length[MSTRTIME_MAX_SIZE], psz_time[MSTRTIME_MAX_SIZE];
1661
secstotimestr( psz_length, length );
1662
secstotimestr( psz_time, ( b_remainingTime && length ) ? length - time
1666
timestr.sprintf( "%s/%s", psz_time,
1667
( !length && time ) ? "--:--" : psz_length );
1669
/* Add a minus to remaining time*/
1670
if( b_remainingTime && length ) setText( " -"+timestr+" " );
1671
else setText( " "+timestr+" " );
1674
void TimeLabel::toggleTimeDisplay()
1676
b_remainingTime = !b_remainingTime;