controller.cpp 32.7 KB
Newer Older
1
/*****************************************************************************
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
2
 * Controller.cpp : Controller for the main interface
3
 ****************************************************************************
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
4
 * Copyright (C) 2006-2009 the VideoLAN team
5
6
 * $Id$
 *
7
 * Authors: Jean-Baptiste Kempf <jb@videolan.org>
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 *          Ilkka Ollakka <ileoo@videolan.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * ( at your option ) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <vlc_vout.h>
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
30
#include <vlc_keys.h>
31

32
33
#include "components/controller.hpp"
#include "components/controller_widget.hpp"
34
#include "components/interface_widgets.hpp"
35

36
#include "dialogs_provider.hpp" /* Opening Dialogs */
37
#include "input_manager.hpp"
38
#include "actions_manager.hpp"
39

40
41
42
#include "util/input_slider.hpp" /* InputSlider */
#include "util/customwidgets.hpp" /* qEventToKey */

43
#include <QSpacerItem>
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
44
#include <QToolButton>
45
#include <QHBoxLayout>
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
46
#include <QSignalMapper>
47
#include <QTimer>
48

49
50
//#define DEBUG_LAYOUT 1

51
52
53
54
/**********************************************************************
 * TEH controls
 **********************************************************************/

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
55
/******
56
57
58
59
 * This is an abstract Toolbar/Controller
 * This has helper to create any toolbar, any buttons and to manage the actions
 *
 *****/
60
61
AbstractController::AbstractController( intf_thread_t * _p_i, QWidget *_parent )
                   : QFrame( _parent )
62
{
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
63
    p_intf = _p_i;
64
    advControls = NULL;
65

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
66
    /* Main action provider */
67
    toolbarActionsMapper = new QSignalMapper( this );
68
69
    CONNECT( toolbarActionsMapper, mapped( int ),
             ActionsManager::getInstance( p_intf  ), doAction( int ) );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
70
    CONNECT( THEMIM->getIM(), statusChanged( int ), this, setStatus( int ) );
71
72
}

73
/* Reemit some signals on status Change to activate some buttons */
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
74
void AbstractController::setStatus( int status )
75
{
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
76
77
78
    bool b_hasInput = THEMIM->getIM()->hasInput();
    /* Activate the interface buttons according to the presence of the input */
    emit inputExists( b_hasInput );
79

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
80
    emit inputPlaying( status == PLAYING_S );
81

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
82
83
    emit inputIsRecordable( b_hasInput &&
                            var_GetBool( THEMIM->getInput(), "can-record" ) );
84
85
86

    emit inputIsTrickPlayable( b_hasInput &&
                            var_GetBool( THEMIM->getInput(), "can-rewind" ) );
87
88
}

89
/* Generic button setup */
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
90
void AbstractController::setupButton( QAbstractButton *aButton )
91
{
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
92
93
94
    static QSizePolicy sizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
    sizePolicy.setHorizontalStretch( 0 );
    sizePolicy.setVerticalStretch( 0 );
95

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
96
97
98
99
    aButton->setSizePolicy( sizePolicy );
    aButton->setFixedSize( QSize( 26, 26 ) );
    aButton->setIconSize( QSize( 20, 20 ) );
    aButton->setFocusPolicy( Qt::NoFocus );
100
101
}

102
103
/* Open the generic config line for the toolbar, parse it
 * and create the widgets accordingly */
104
void AbstractController::parseAndCreate( const QString& config,
105
                                         QBoxLayout *controlLayout )
106
{
107
    QStringList list = config.split( ";", QString::SkipEmptyParts ) ;
108
109
    for( int i = 0; i < list.size(); i++ )
    {
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
        QStringList list2 = list.at( i ).split( "-" );
        if( list2.size() < 1 )
        {
            msg_Warn( p_intf, "Parsing error. Report this" );
            continue;
        }

        bool ok;
        int i_option = WIDGET_NORMAL;
        buttonType_e i_type = (buttonType_e)list2.at( 0 ).toInt( &ok );
        if( !ok )
        {
            msg_Warn( p_intf, "Parsing error 0. Please report this" );
            continue;
        }

        if( list2.size() > 1 )
        {
            i_option = list2.at( 1 ).toInt( &ok );
            if( !ok )
            {
                msg_Warn( p_intf, "Parsing error 1. Please report this" );
                continue;
            }
        }

        createAndAddWidget( controlLayout, -1, i_type, i_option );
137
138
139
    }
}

140
141
142
143
144
145
146
147
void AbstractController::createAndAddWidget( QBoxLayout *controlLayout,
                                             int i_index,
                                             buttonType_e i_type,
                                             int i_option )
{
    /* Special case for SPACERS, who aren't QWidgets */
    if( i_type == WIDGET_SPACER )
    {
148
        controlLayout->insertSpacing( i_index, 12 );
149
150
151
152
153
        return;
    }

    if(  i_type == WIDGET_SPACER_EXTEND )
    {
154
        controlLayout->insertStretch( i_index, 12 );
155
156
157
158
159
160
161
162
163
164
        return;
    }

    QWidget *widg = createWidget( i_type, i_option );
    if( !widg ) return;

    controlLayout->insertWidget( i_index, widg );
}


Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
165
166
167
168
169
#define CONNECT_MAP( a ) CONNECT( a, clicked(),  toolbarActionsMapper, map() )
#define SET_MAPPING( a, b ) toolbarActionsMapper->setMapping( a , b )
#define CONNECT_MAP_SET( a, b ) \
    CONNECT_MAP( a ); \
    SET_MAPPING( a, b );
170
#define BUTTON_SET_BAR( a_button ) \
Christophe Mutricy's avatar
Christophe Mutricy committed
171
    a_button->setToolTip( qtr( tooltipL[button] ) ); \
172
173
    a_button->setIcon( QIcon( iconL[button] ) );
#define BUTTON_SET_BAR2( button, image, tooltip ) \
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
174
175
176
177
178
179
180
181
182
183
    button->setToolTip( tooltip );          \
    button->setIcon( QIcon( ":/"#image ) );

#define ENABLE_ON_VIDEO( a ) \
    CONNECT( THEMIM->getIM(), voutChanged( bool ), a, setEnabled( bool ) ); \
    a->setEnabled( THEMIM->getIM()->hasVideo() ); /* TODO: is this necessary? when input is started before the interface? */

#define ENABLE_ON_INPUT( a ) \
    CONNECT( this, inputExists( bool ), a, setEnabled( bool ) ); \
    a->setEnabled( THEMIM->getIM()->hasInput() ); /* TODO: is this necessary? when input is started before the interface? */
184
185
186
187

#define NORMAL_BUTTON( name )                           \
    QToolButton * name ## Button = new QToolButton;     \
    setupButton( name ## Button );                      \
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
188
    CONNECT_MAP_SET( name ## Button, name ## _ACTION ); \
189
    BUTTON_SET_BAR( name ## Button );                   \
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
190
    widget = name ## Button;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
191

192
QWidget *AbstractController::createWidget( buttonType_e button, int options )
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
193
{
194

195
196
    bool b_flat  = options & WIDGET_FLAT;
    bool b_big   = options & WIDGET_BIG;
197
    bool b_shiny = options & WIDGET_SHINY;
198
    bool b_special = false;
199

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
200
201
202
203
    QWidget *widget = NULL;
    switch( button )
    {
    case PLAY_BUTTON: {
204
        PlayButton *playButton = new PlayButton;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
205
        setupButton( playButton );
206
        BUTTON_SET_BAR(  playButton );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
207
208
209
210
211
212
213
        CONNECT_MAP_SET( playButton, PLAY_ACTION );
        CONNECT( this, inputPlaying( bool ),
                 playButton, updateButton( bool ));
        widget = playButton;
        }
        break;
    case STOP_BUTTON:{
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
214
        NORMAL_BUTTON( STOP );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
215
216
        }
        break;
217
    case OPEN_BUTTON:{
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
218
        NORMAL_BUTTON( OPEN );
219
220
        }
        break;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
221
    case PREVIOUS_BUTTON:{
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
222
        NORMAL_BUTTON( PREVIOUS );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
223
224
        }
        break;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
225
226
    case NEXT_BUTTON: {
        NORMAL_BUTTON( NEXT );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
227
228
229
        }
        break;
    case SLOWER_BUTTON:{
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
230
231
        NORMAL_BUTTON( SLOWER );
        ENABLE_ON_INPUT( SLOWERButton );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
232
233
234
        }
        break;
    case FASTER_BUTTON:{
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
235
236
        NORMAL_BUTTON( FASTER );
        ENABLE_ON_INPUT( FASTERButton );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
237
238
239
        }
        break;
    case FRAME_BUTTON: {
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
240
241
        NORMAL_BUTTON( FRAME );
        ENABLE_ON_VIDEO( FRAMEButton );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
242
243
        }
        break;
244
245
246
    case FULLSCREEN_BUTTON:
    case DEFULLSCREEN_BUTTON:
        {
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
247
248
        NORMAL_BUTTON( FULLSCREEN );
        ENABLE_ON_VIDEO( FULLSCREENButton );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
249
250
251
        }
        break;
    case EXTENDED_BUTTON:{
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
252
        NORMAL_BUTTON( EXTENDED );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
253
254
255
        }
        break;
    case PLAYLIST_BUTTON:{
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
256
        NORMAL_BUTTON( PLAYLIST );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
257
258
259
        }
        break;
    case SNAPSHOT_BUTTON:{
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
260
261
        NORMAL_BUTTON( SNAPSHOT );
        ENABLE_ON_VIDEO( SNAPSHOTButton );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
262
263
264
        }
        break;
    case RECORD_BUTTON:{
265
        QToolButton *recordButton = new QToolButton;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
266
267
        setupButton( recordButton );
        CONNECT_MAP_SET( recordButton, RECORD_ACTION );
268
        BUTTON_SET_BAR(  recordButton );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
269
        ENABLE_ON_INPUT( recordButton );
270
271
272
        recordButton->setCheckable( true );
        CONNECT( THEMIM->getIM(), recordingStateChanged( bool ),
                 recordButton, setChecked( bool ) );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
273
274
275
276
        widget = recordButton;
        }
        break;
    case ATOB_BUTTON: {
277
        AtoB_Button *ABButton = new AtoB_Button;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
278
        setupButton( ABButton );
279
        ABButton->setShortcut( qtr("Shift+L") );
280
        BUTTON_SET_BAR( ABButton );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
281
282
283
284
285
286
287
288
289
        ENABLE_ON_INPUT( ABButton );
        CONNECT_MAP_SET( ABButton, ATOB_ACTION );
        CONNECT( THEMIM->getIM(), AtoBchanged( bool, bool),
                 ABButton, setIcons( bool, bool ) );
        widget = ABButton;
        }
        break;
    case INPUT_SLIDER: {
        InputSlider *slider = new InputSlider( Qt::Horizontal, NULL );
290

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
291
292
293
294
295
        /* Update the position when the IM has changed */
        CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
                slider, setPosition( float, int, int ) );
        /* And update the IM, when the position has changed */
        CONNECT( slider, sliderDragged( float ),
296
                 THEMIM->getIM(), sliderUpdate( float ) );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
297
298
299
300
301
        widget = slider;
        }
        break;
    case MENU_BUTTONS:
        widget = discFrame();
302
        widget->hide();
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
303
304
305
        break;
    case TELETEXT_BUTTONS:
        widget = telexFrame();
306
        widget->hide();
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
307
        break;
308
309
    case VOLUME_SPECIAL:
        b_special = true;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
310
311
    case VOLUME:
        {
312
            SoundWidget *snd = new SoundWidget( this, p_intf, b_shiny, b_special );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
313
            widget = snd;
314
315
316
317
318
319
        }
        break;
    case TIME_LABEL:
        {
            TimeLabel *timeLabel = new TimeLabel( p_intf );
            widget = timeLabel;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
320
321
        }
        break;
322
323
    case SPLITTER:
        {
324
            QFrame *line = new QFrame;
325
326
327
328
329
330
331
332
333
            line->setFrameShape( QFrame::VLine );
            line->setFrameShadow( QFrame::Raised );
            line->setLineWidth( 0 );
            line->setMidLineWidth( 1 );
            widget = line;
        }
        break;
    case ADVANCED_CONTROLLER:
        {
334
            advControls = new AdvControlsWidget( p_intf, this );
335
336
            widget = advControls;
        }
337
        break;
338
    case REVERSE_BUTTON:{
339
        QToolButton *reverseButton = new QToolButton;
340
341
        setupButton( reverseButton );
        CONNECT_MAP_SET( reverseButton, REVERSE_ACTION );
342
        BUTTON_SET_BAR(  reverseButton );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
343
344
345
        reverseButton->setCheckable( true );
        /* You should, of COURSE change this to the correct event,
           when/if we have one, that tells us if trickplay is possible . */
346
        CONNECT( this, inputIsTrickPlayable( bool ), reverseButton, setVisible( bool ) );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
347
        reverseButton->setVisible( false );
348
349
350
        widget = reverseButton;
        }
        break;
351
    case SKIP_BACK_BUTTON: {
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
352
353
        NORMAL_BUTTON( SKIP_BACK );
        ENABLE_ON_INPUT( SKIP_BACKButton );
354
355
356
        }
        break;
    case SKIP_FW_BUTTON: {
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
357
358
        NORMAL_BUTTON( SKIP_FW );
        ENABLE_ON_INPUT( SKIP_FWButton );
359
360
        }
        break;
361
    case QUIT_BUTTON: {
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
362
363
364
365
366
        NORMAL_BUTTON( QUIT );
        }
        break;
    case RANDOM_BUTTON: {
        NORMAL_BUTTON( RANDOM );
367
        RANDOMButton->setCheckable( true );
368
        RANDOMButton->setChecked( var_GetBool( THEPL, "random" ) );
369
370
        CONNECT( THEMIM, randomChanged( bool ),
                 RANDOMButton, setChecked( bool ) );
371
372
        }
        break;
373
374
375
376
377
    case LOOP_BUTTON:{
        LoopButton *loopButton = new LoopButton;
        setupButton( loopButton );
        loopButton->setToolTip( qtr( "Click to toggle between loop one, loop all" ) );
        loopButton->setCheckable( true );
378
379
380
381
        loopButton->updateIcons( NORMAL );
        CONNECT( THEMIM, repeatLoopChanged( int ), loopButton, updateIcons( int ) );
        CONNECT( loopButton, clicked(), THEMIM, loopRepeatLoopStatus() );
        widget = loopButton;
382
383
        }
        break;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
384
    default:
385
        msg_Warn( p_intf, "This should not happen %i", button );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
386
        break;
387
388
    }

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
389
390
    /* Customize Buttons */
    if( b_flat || b_big )
391
    {
392
393
        QFrame *frame = qobject_cast<QFrame *>(widget);
        if( frame )
394
        {
395
396
397
398
399
400
401
402
403
            QList<QToolButton *> allTButtons = frame->findChildren<QToolButton *>();
            for( int i = 0; i < allTButtons.size(); i++ )
                applyAttributes( allTButtons[i], b_flat, b_big );
        }
        else
        {
            QToolButton *tmpButton = qobject_cast<QToolButton *>(widget);
            if( tmpButton )
                applyAttributes( tmpButton, b_flat, b_big );
404
405
        }
    }
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
406
    return widget;
407
}
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
408
#undef NORMAL_BUTTON
409

410
411
412
413
414
415
416
417
418
419
420
421
422
423
void AbstractController::applyAttributes( QToolButton *tmpButton, bool b_flat, bool b_big )
{
    if( tmpButton )
    {
        if( b_flat )
            tmpButton->setAutoRaise( b_flat );
        if( b_big )
        {
            tmpButton->setFixedSize( QSize( 32, 32 ) );
            tmpButton->setIconSize( QSize( 26, 26 ) );
        }
    }
}

424
QFrame *AbstractController::discFrame()
425
426
{
    /** Disc and Menus handling */
427
    QFrame *discFrame = new QFrame( this );
428
429

    QHBoxLayout *discLayout = new QHBoxLayout( discFrame );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
430
    discLayout->setSpacing( 0 ); discLayout->setMargin( 0 );
431

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
432
433
    QToolButton *prevSectionButton = new QToolButton( discFrame );
    setupButton( prevSectionButton );
434
    BUTTON_SET_BAR2( prevSectionButton, toolbar/dvd_prev,
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
435
            qtr("Previous Chapter/Title" ) );
436
437
    discLayout->addWidget( prevSectionButton );

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
438
439
    QToolButton *menuButton = new QToolButton( discFrame );
    setupButton( menuButton );
440
    discLayout->addWidget( menuButton );
441
    BUTTON_SET_BAR2( menuButton, toolbar/dvd_menu, qtr( "Menu" ) );
442

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
443
444
    QToolButton *nextSectionButton = new QToolButton( discFrame );
    setupButton( nextSectionButton );
445
    discLayout->addWidget( nextSectionButton );
446
    BUTTON_SET_BAR2( nextSectionButton, toolbar/dvd_next,
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
447
            qtr("Next Chapter/Title" ) );
448

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
449
450
451
452
453
454
    /* Change the navigation button display when the IM
       navigation changes */
    CONNECT( THEMIM->getIM(), titleChanged( bool ),
            discFrame, setVisible( bool ) );
    CONNECT( THEMIM->getIM(), chapterChanged( bool ),
            menuButton, setVisible( bool ) );
455
456
    /* Changes the IM navigation when triggered on the nav buttons */
    CONNECT( prevSectionButton, clicked(), THEMIM->getIM(),
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
457
            sectionPrev() );
458
    CONNECT( nextSectionButton, clicked(), THEMIM->getIM(),
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
459
            sectionNext() );
460
    CONNECT( menuButton, clicked(), THEMIM->getIM(),
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
461
            sectionMenu() );
462
463
    connect( THEMIM->getIM(), SIGNAL( titleChanged( bool ) ),
             this, SIGNAL( sizeChanged() ) );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
464
465
466

    return discFrame;
}
467

468
QFrame *AbstractController::telexFrame()
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
469
{
470
471
472
    /**
     * Telextext QFrame
     **/
473
    QFrame *telexFrame = new QFrame;
474
    QHBoxLayout *telexLayout = new QHBoxLayout( telexFrame );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
475
476
477
    telexLayout->setSpacing( 0 ); telexLayout->setMargin( 0 );
    CONNECT( THEMIM->getIM(), teletextPossible( bool ),
             telexFrame, setVisible( bool ) );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
478
479
    connect( THEMIM->getIM(), SIGNAL( teletextPossible( bool ) ),
             this, SIGNAL( sizeChanged() ) );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
480
481

    /* On/Off button */
482
    QToolButton *telexOn = new QToolButton;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
483
    setupButton( telexOn );
484
    BUTTON_SET_BAR2( telexOn, toolbar/tv, qtr( "Teletext Activation" ) );
Laurent Aimar's avatar
Laurent Aimar committed
485
486
487
    telexOn->setEnabled( false );
    telexOn->setCheckable( true );

488
489
    telexLayout->addWidget( telexOn );

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
490
491
492
    /* Teletext Activation and set */
    CONNECT( telexOn, clicked( bool ),
             THEMIM->getIM(), activateTeletext( bool ) );
Laurent Aimar's avatar
Laurent Aimar committed
493
494
    CONNECT( THEMIM->getIM(), teletextPossible( bool ),
             telexOn, setEnabled( bool ) );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
495
496

    /* Transparency button */
497
    QToolButton *telexTransparent = new QToolButton;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
498
    setupButton( telexTransparent );
499
    BUTTON_SET_BAR2( telexTransparent, toolbar/tvtelx,
500
                     qtr( "Toggle Transparency " ) );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
501
    telexTransparent->setEnabled( false );
502
    telexTransparent->setCheckable( true );
503
504
    telexLayout->addWidget( telexTransparent );

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
505
506
507
508
    /* Transparency change and set */
    CONNECT( telexTransparent, clicked( bool ),
            THEMIM->getIM(), telexSetTransparency( bool ) );
    CONNECT( THEMIM->getIM(), teletextTransparencyActivated( bool ),
509
             telexTransparent, setChecked( bool ) );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
510
511
512


    /* Page setting */
513
    QSpinBox *telexPage = new QSpinBox( telexFrame );
514
515
516
517
518
519
520
    telexPage->setRange( 0, 999 );
    telexPage->setValue( 100 );
    telexPage->setAccelerated( true );
    telexPage->setWrapping( true );
    telexPage->setAlignment( Qt::AlignRight );
    telexPage->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum );
    telexPage->setEnabled( false );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
521
    telexLayout->addWidget( telexPage );
522

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
523
524
525
526
527
    /* Page change and set */
    CONNECT( telexPage, valueChanged( int ),
            THEMIM->getIM(), telexSetPage( int ) );
    CONNECT( THEMIM->getIM(), newTelexPageSet( int ),
            telexPage, setValue( int ) );
528

529
530
531
    CONNECT( THEMIM->getIM(), teletextActivated( bool ), telexPage, setEnabled( bool ) );
    CONNECT( THEMIM->getIM(), teletextActivated( bool ), telexTransparent, setEnabled( bool ) );
    CONNECT( THEMIM->getIM(), teletextActivated( bool ), telexOn, setChecked( bool ) );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
532
533
534
535
    return telexFrame;
}
#undef CONNECT_MAP
#undef SET_MAPPING
536
#undef CONNECT_MAP_SET
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
537
#undef BUTTON_SET_BAR
ivoire's avatar
ivoire committed
538
#undef BUTTON_SET_BAR2
539
540
#undef ENABLE_ON_VIDEO
#undef ENABLE_ON_INPUT
541

542
#include <QHBoxLayout>
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
543
544
545
546
/*****************************
 * DA Control Widget !
 *****************************/
ControlsWidget::ControlsWidget( intf_thread_t *_p_i,
547
548
549
                                bool b_advControls,
                                QWidget *_parent ) :
                                AbstractController( _p_i, _parent )
550
{
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
551
552
    /* advanced Controls handling */
    b_advancedVisible = b_advControls;
553
554
555
#if DEBUG_LAYOUT
    setStyleSheet( " background: red ");
#endif
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
556

557
    QVBoxLayout *controlLayout = new QVBoxLayout( this );
558
    controlLayout->setContentsMargins( 4, 1, 4, 0 );
559
560
    controlLayout->setSpacing( 0 );
    QHBoxLayout *controlLayout1 = new QHBoxLayout;
561
    controlLayout1->setSpacing( 0 ); controlLayout1->setMargin( 0 );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
562

563
564
    QString line1 = getSettings()->value( "MainToolbar1", MAIN_TB1_DEFAULT )
                                        .toString();
565
    parseAndCreate( line1, controlLayout1 );
566

567
    QHBoxLayout *controlLayout2 = new QHBoxLayout;
568
    controlLayout2->setSpacing( 0 ); controlLayout2->setMargin( 0 );
569
570
    QString line2 = getSettings()->value( "MainToolbar2", MAIN_TB2_DEFAULT )
                                        .toString();
571
    parseAndCreate( line2, controlLayout2 );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
572

573
    if( !b_advancedVisible && advControls ) advControls->hide();
574
575
576

    controlLayout->addLayout( controlLayout1 );
    controlLayout->addLayout( controlLayout2 );
577
578
}

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
579
580
581
ControlsWidget::~ControlsWidget()
{}

582
583
void ControlsWidget::toggleAdvanced()
{
584
585
586
    if( !advControls ) return;

    if( !b_advancedVisible )
587
588
589
590
591
592
593
594
595
596
597
598
    {
        advControls->show();
        b_advancedVisible = true;
    }
    else
    {
        advControls->hide();
        b_advancedVisible = false;
    }
    emit advancedControlsToggled( b_advancedVisible );
}

599
600
AdvControlsWidget::AdvControlsWidget( intf_thread_t *_p_i, QWidget *_parent ) :
                                     AbstractController( _p_i, _parent )
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
601
{
602
    controlLayout = new QHBoxLayout( this );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
603
604
    controlLayout->setMargin( 0 );
    controlLayout->setSpacing( 0 );
605
606
607
608
#if DEBUG_LAYOUT
    setStyleSheet( " background: orange ");
#endif

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
609

610
    QString line = getSettings()->value( "AdvToolbar", ADV_TB_DEFAULT )
611
        .toString();
612
    parseAndCreate( line, controlLayout );
613
}
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
614

615
616
InputControlsWidget::InputControlsWidget( intf_thread_t *_p_i, QWidget *_parent ) :
                                     AbstractController( _p_i, _parent )
617
{
618
    controlLayout = new QHBoxLayout( this );
619
620
    controlLayout->setMargin( 0 );
    controlLayout->setSpacing( 0 );
621
622
623
#if DEBUG_LAYOUT
    setStyleSheet( " background: green ");
#endif
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
624

625
    QString line = getSettings()->value( "InputToolbar", INPT_TB_DEFAULT ).toString();
626
    parseAndCreate( line, controlLayout );
627
}
628
629
630
/**********************************************************************
 * Fullscrenn control widget
 **********************************************************************/
631
632
FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i, QWidget *_parent )
                           : AbstractController( _p_i, _parent )
633
{
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
634
635
636
    i_mouse_last_x      = -1;
    i_mouse_last_y      = -1;
    b_mouse_over        = false;
637
638
    i_mouse_last_move_x = -1;
    i_mouse_last_move_y = -1;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
639
640
641
642
643
644
#if HAVE_TRANSPARENCY
    b_slow_hide_begin   = false;
    i_slow_hide_timeout = 1;
#endif
    b_fullscreen        = false;
    i_hide_timeout      = 1;
645
    i_screennumber      = -1;
646

647
648
    vout.clear();

649
650
651
652
653
654
655
    setWindowFlags( Qt::ToolTip );
    setMinimumWidth( 600 );

    setFrameShape( QFrame::StyledPanel );
    setFrameStyle( QFrame::Sunken );
    setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );

656
    QVBoxLayout *controlLayout2 = new QVBoxLayout( this );
657
    controlLayout2->setContentsMargins( 4, 6, 4, 2 );
658
659

    /* First line */
660
    InputControlsWidget *inputC = new InputControlsWidget( p_intf, this );
661
    controlLayout2->addWidget( inputC );
662

663
    controlLayout = new QHBoxLayout;
664
    QString line = getSettings()->value( "MainWindow/FSCtoolbar", FSC_TB_DEFAULT ).toString();
665
    parseAndCreate( line, controlLayout );
666
    controlLayout2->addLayout( controlLayout );
667
668
669
670
671
672
673
674
675
676
677
678
679

    /* hiding timer */
    p_hideTimer = new QTimer( this );
    CONNECT( p_hideTimer, timeout(), this, hideFSC() );
    p_hideTimer->setSingleShot( true );

    /* slow hiding timer */
#if HAVE_TRANSPARENCY
    p_slowHideTimer = new QTimer( this );
    CONNECT( p_slowHideTimer, timeout(), this, slowHideFSC() );
#endif

    vlc_mutex_init_recursive( &lock );
680

681
682
683
684
    CONNECT( THEMIM->getIM(), voutListChanged( vout_thread_t **, int ),
             this, setVoutList( vout_thread_t **, int ) );

    /* First Move */
685
    QRect rect1 = getSettings()->value( "FullScreen/screen" ).toRect();
686
    QPoint pos1 = getSettings()->value( "FullScreen/pos" ).toPoint();
687
688
689
    int number =  config_GetInt( p_intf, "qt-fullscreen-screennumber" );
    if( number == -1 || number > QApplication::desktop()->numScreens() )
        number = QApplication::desktop()->screenNumber( p_intf->p_sys->p_mi );
690
691
692

    QRect rect = QApplication::desktop()->screenGeometry( number );
    if( rect == rect1 && rect.contains( pos1, true ) )
693
694
695
696
697
698
699
700
701
702
    {
        move( pos1 );
        i_screennumber = number;
        screenRes = QApplication::desktop()->screenGeometry(number);
    }
    else
    {
        centerFSC( number );
    }

703
704
705
706
}

FullscreenControllerWidget::~FullscreenControllerWidget()
{
707
708
709
710
711
    QPoint pos1 = pos();
    QRect rect1 = QApplication::desktop()->screenGeometry( pos1 );
    getSettings()->setValue( "FullScreen/pos", pos1 );
    getSettings()->setValue( "FullScreen/screen", rect1 );

712
    setVoutList( NULL, 0 );
713
714
715
    vlc_mutex_destroy( &lock );
}

716
717
718
void FullscreenControllerWidget::centerFSC( int number )
{
    screenRes = QApplication::desktop()->screenGeometry(number);
719

720
    /* screen has changed, calculate new position */
721
722
    QPoint pos = QPoint( screenRes.x() + (screenRes.width() / 2) - (sizeHint().width() / 2),
            screenRes.y() + screenRes.height() - sizeHint().height());
723
    move( pos );
724

725
726
727
    i_screennumber = number;
}

728
729
730
731
732
733
/**
 * Show fullscreen controller
 */
void FullscreenControllerWidget::showFSC()
{
    adjustSize();
734

735
    int number = QApplication::desktop()->screenNumber( p_intf->p_sys->p_mi );
736

737
738
    if( number != i_screennumber ||
        screenRes != QApplication::desktop()->screenGeometry(number) )
739
    {
740
        centerFSC( number );
741
        msg_Dbg( p_intf, "Recentering the Fullscreen Controller" );
742
    }
743

744
#if HAVE_TRANSPARENCY
745
    setWindowOpacity( config_GetFloat( p_intf, "qt-fs-opacity" )  );
746
#endif
747
748

    show();
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
}

/**
 * Plane to hide fullscreen controller
 */
void FullscreenControllerWidget::planHideFSC()
{
    vlc_mutex_lock( &lock );
    int i_timeout = i_hide_timeout;
    vlc_mutex_unlock( &lock );

    p_hideTimer->start( i_timeout );

#if HAVE_TRANSPARENCY
    b_slow_hide_begin = true;
    i_slow_hide_timeout = i_timeout;
    p_slowHideTimer->start( i_slow_hide_timeout / 2 );
#endif
}

/**
 * Hidding fullscreen controller slowly
 * Linux: need composite manager
 * Windows: it is blinking, so it can be enabled by define TRASPARENCY
 */
void FullscreenControllerWidget::slowHideFSC()
{
#if HAVE_TRANSPARENCY
    if( b_slow_hide_begin )
    {
        b_slow_hide_begin = false;

        p_slowHideTimer->stop();
        /* the last part of time divided to 100 pieces */
        p_slowHideTimer->start( (int)( i_slow_hide_timeout / 2 / ( windowOpacity() * 100 ) ) );

    }
    else
    {
         if ( windowOpacity() > 0.0 )
         {
             /* we should use 0.01 because of 100 pieces ^^^
                but than it cannt be done in time */
             setWindowOpacity( windowOpacity() - 0.02 );
         }

         if ( windowOpacity() <= 0.0 )
             p_slowHideTimer->stop();
    }
#endif
}

/**
 * event handling
 * events: show, hide, start timer for hidding
 */
void FullscreenControllerWidget::customEvent( QEvent *event )
{
    bool b_fs;

    switch( event->type() )
    {
811
        /* This is used when the 'i' hotkey is used, to force quick toggle */
812
813
814
815
        case FullscreenControlToggle_Type:
            vlc_mutex_lock( &lock );
            b_fs = b_fullscreen;
            vlc_mutex_unlock( &lock );
816

817
            if( b_fs )
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
818
            {
819
820
821
822
823
824
825
                if( isHidden() )
                {
                    p_hideTimer->stop();
                    showFSC();
                }
                else
                    hideFSC();
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
826
            }
827
            break;
828
        /* Event called to Show the FSC on mouseChanged() */
829
830
831
832
833
        case FullscreenControlShow_Type:
            vlc_mutex_lock( &lock );
            b_fs = b_fullscreen;
            vlc_mutex_unlock( &lock );

834
            if( b_fs )
835
                showFSC();
836

837
            break;
838
        /* Start the timer to hide later, called usually with above case */
839
840
841
842
        case FullscreenControlPlanHide_Type:
            if( !b_mouse_over ) // Only if the mouse is not over FSC
                planHideFSC();
            break;
843
844
845
846
        /* Hide */
        case FullscreenControlHide_Type:
            hideFSC();
            break;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
847
848
        default:
            break;
849
850
851
852
853
854
855
856
857
    }
}

/**
 * On mouse move
 * moving with FSC
 */
void FullscreenControllerWidget::mouseMoveEvent( QMouseEvent *event )
{
858
    if( event->buttons() == Qt::LeftButton )
859
    {
860
861
862
        if( i_mouse_last_x == -1 || i_mouse_last_y == -1 )
            return;

863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
        int i_moveX = event->globalX() - i_mouse_last_x;
        int i_moveY = event->globalY() - i_mouse_last_y;

        move( x() + i_moveX, y() + i_moveY );

        i_mouse_last_x = event->globalX();
        i_mouse_last_y = event->globalY();
    }
}

/**
 * On mouse press
 * store position of cursor
 */
void FullscreenControllerWidget::mousePressEvent( QMouseEvent *event )
{
    i_mouse_last_x = event->globalX();
    i_mouse_last_y = event->globalY();
881
    event->accept();
882
883
}

884
885
886
887
void FullscreenControllerWidget::mouseReleaseEvent( QMouseEvent *event )
{
    i_mouse_last_x = -1;
    i_mouse_last_y = -1;
888
    event->accept();
889
890
}

891
892
893
894
895
896
897
898
899
900
/**
 * On mouse go above FSC
 */
void FullscreenControllerWidget::enterEvent( QEvent *event )
{
    b_mouse_over = true;

    p_hideTimer->stop();
#if HAVE_TRANSPARENCY
    p_slowHideTimer->stop();
901
    setWindowOpacity( DEFAULT_OPACITY );
902
#endif
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
903
    event->accept();
904
905
906
907
908
909
910
911
912
913
}

/**
 * On mouse go out from FSC
 */
void FullscreenControllerWidget::leaveEvent( QEvent *event )
{
    planHideFSC();

    b_mouse_over = false;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
914
    event->accept();
915
916
917
918
919
920
921
}

/**
 * When you get pressed key, send it to video output
 */
void FullscreenControllerWidget::keyPressEvent( QKeyEvent *event )
{
922
    emit keyPressed( event );
923
924
925
926
927
928
929
930
}

/* */
static int FullscreenControllerWidgetFullscreenChanged( vlc_object_t *vlc_object,
                const char *variable, vlc_value_t old_val,
                vlc_value_t new_val,  void *data )
{
    vout_thread_t *p_vout = (vout_thread_t *) vlc_object;
931

932
933
934
    msg_Dbg( p_vout, "Qt4: Fullscreen state changed" );
    FullscreenControllerWidget *p_fs = (FullscreenControllerWidget *)data;

935
    p_fs->fullscreenChanged( p_vout, new_val.b_bool, var_GetInteger( p_vout, "mouse-hide-timeout" ) );
936
937
938
939
940
941
942
943

    return VLC_SUCCESS;
}
/* */
static int FullscreenControllerWidgetMouseMoved( vlc_object_t *vlc_object, const char *variable,
                                                 vlc_value_t old_val, vlc_value_t new_val,
                                                 void *data )
{
944
    vout_thread_t *p_vout = (vout_thread_t *)vlc_object;
945
946
947
    FullscreenControllerWidget *p_fs = (FullscreenControllerWidget *)data;

    /* Get the value from the Vout - Trust the vout more than Qt */
948
949
    const int i_mousex = var_GetInteger( p_vout, "mouse-x" );
    const int i_mousey = var_GetInteger( p_vout, "mouse-y" );
950

951
    p_fs->mouseChanged( p_vout, i_mousex, i_mousey );
952
953
954
955
956

    return VLC_SUCCESS;
}

/**
957
 * It is call to update the list of vout handled by the fullscreen controller
958
 */
959
void FullscreenControllerWidget::setVoutList( vout_thread_t **pp_vout, int i_vout )
960
{
961
962
    QList<vout_thread_t*> del;
    QList<vout_thread_t*> add;
963

964
    QList<vout_thread_t*> set;
965

966
967
968
    /* */
    for( int i = 0; i < i_vout; i++ )
        set += pp_vout[i];
969

970
971
972
973
974
975
976
    /* Vout to remove */
    vlc_mutex_lock( &lock );
    foreach( vout_thread_t *p_vout, vout )
    {
        if( !set.contains( p_vout ) )
            del += p_vout;
    }
977
    vlc_mutex_unlock( &lock );
978

979
    foreach( vout_thread_t *p_vout, del )
980
981
    {
        var_DelCallback( p_vout, "fullscreen",
982
                         FullscreenControllerWidgetFullscreenChanged, this );
983
984
        vlc_mutex_lock( &lock );
        fullscreenChanged( p_vout, false, 0 );
985
        vout.removeAll( p_vout );
986
        vlc_mutex_unlock( &lock );
987
988

        vlc_object_release( VLC_OBJECT(p_vout) );
989
990
    }

991
992
993
994
995
996
997
998
999
1000
1001
    /* Vout to track */
    vlc_mutex_lock( &lock );
    foreach( vout_thread_t *p_vout, set )
    {
        if( !vout.contains( p_vout ) )
            add += p_vout;
    }
    vlc_mutex_unlock( &lock );

    foreach( vout_thread_t *p_vout, add )
    {
1002
        vlc_object_hold( VLC_OBJECT(p_vout) );
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013

        vlc_mutex_lock( &lock );
        vout.append( p_vout );
        var_AddCallback( p_vout, "fullscreen",
                         FullscreenControllerWidgetFullscreenChanged, this );
        /* I miss a add and fire */
        fullscreenChanged( p_vout, var_GetBool( p_vout, "fullscreen" ),
                           var_GetInteger( p_vout, "mouse-hide-timeout" ) );
        vlc_mutex_unlock( &lock );
    }
}
1014
1015
1016
1017
1018
1019
/**
 * Register and unregister callback for mouse moving
 */
void FullscreenControllerWidget::fullscreenChanged( vout_thread_t *p_vout,
        bool b_fs, int i_timeout )
{
1020
    /* FIXME - multiple vout (ie multiple mouse position ?) and thread safety if multiple vout ? */
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
    msg_Dbg( p_vout, "Qt: Entering Fullscreen" );

    vlc_mutex_lock( &lock );
    /* Entering fullscreen, register callback */
    if( b_fs && !b_fullscreen )
    {
        b_fullscreen = true;
        i_hide_timeout = i_timeout;
        var_AddCallback( p_vout, "mouse-moved",
                FullscreenControllerWidgetMouseMoved, this );
    }
    /* Quitting fullscreen, unregistering callback */
    else if( !b_fs && b_fullscreen )
    {
        b_fullscreen = false;
        i_hide_timeout = i_timeout;
        var_DelCallback( p_vout, "mouse-moved",
                FullscreenControllerWidgetMouseMoved, this );

        /* Force fs hidding */
        IMEvent *eHide = new IMEvent( FullscreenControlHide_Type, 0 );
1042
        QApplication::postEvent( this, eHide );
1043
1044
1045
    }
    vlc_mutex_unlock( &lock );
}
1046

1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
/**
 * Mouse change callback (show/hide the controller on mouse movement)
 */
void FullscreenControllerWidget::mouseChanged( vout_thread_t *p_vout, int i_mousex, int i_mousey )
{
    bool b_toShow;

    /* FIXME - multiple vout (ie multiple mouse position ?) and thread safety if multiple vout ? */

    b_toShow = false;
    if( ( i_mouse_last_move_x == -1 || i_mouse_last_move_y == -1 ) ||
        ( abs( i_mouse_last_move_x - i_mousex ) > 2 ||
          abs( i_mouse_last_move_y - i_mousey ) > 2 ) )
    {
        i_mouse_last_move_x = i_mousex;
        i_mouse_last_move_y = i_mousey;
        b_toShow = true;
    }

    if( b_toShow )
    {
        /* Show event */
        IMEvent *eShow = new IMEvent( FullscreenControlShow_Type, 0 );
1070
        QApplication::postEvent( this, eShow );
1071
1072
1073

        /* Plan hide event */
        IMEvent *eHide = new IMEvent( FullscreenControlPlanHide_Type, 0 );
1074
        QApplication::postEvent( this, eHide );
1075
1076
    }
}
1077