]> git.sesse.net Git - vlc/blob - modules/gui/qt4/main_interface.cpp
Win32: fix version checks
[vlc] / modules / gui / qt4 / main_interface.cpp
1 /*****************************************************************************
2  * main_interface.cpp : Main interface
3  ****************************************************************************
4  * Copyright (C) 2006-2009 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *          Jean-Baptiste Kempf <jb@videolan.org>
9  *          Ilkka Ollakka <ileoo@videolan.org>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24  *****************************************************************************/
25
26 #ifdef HAVE_CONFIG_H
27 # include "config.h"
28 #endif
29
30 #include "qt4.hpp"
31
32 #include "main_interface.hpp"
33 #include "input_manager.hpp"
34 #include "actions_manager.hpp"
35
36 #include "util/customwidgets.hpp"
37 #include "util/qt_dirs.hpp"
38
39 #include "components/interface_widgets.hpp"
40 #include "components/controller.hpp"
41 #include "components/playlist/playlist.hpp"
42 #include "dialogs/external.hpp"
43
44 #include "menus.hpp"
45 #include "recents.hpp"
46
47 #include <QCloseEvent>
48 #include <QKeyEvent>
49
50 #include <QUrl>
51 #include <QSize>
52 #include <QDate>
53
54 #include <QMenu>
55 #include <QMenuBar>
56 #include <QStatusBar>
57 #include <QLabel>
58 #include <QGroupBox>
59 #include <QPushButton>
60
61 #ifdef WIN32
62  #include <vlc_windows_interfaces.h>
63  #include <QBitmap>
64 #endif
65
66 #include <assert.h>
67
68 #include <vlc_keys.h> /* Wheel event */
69 #include <vlc_vout_window.h>
70 #include <vlc_vout.h>
71
72 /* Callback prototypes */
73 static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
74                         vlc_value_t old_val, vlc_value_t new_val, void *param );
75 static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
76                        vlc_value_t old_val, vlc_value_t new_val, void *param );
77
78 MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
79 {
80     /* Variables initialisation */
81     // need_components_update = false;
82     bgWidget             = NULL;
83     videoWidget          = NULL;
84     playlistWidget       = NULL;
85     sysTray              = NULL;
86     videoIsActive        = false;
87     playlistVisible      = false;
88     input_name           = "";
89     fullscreenControls   = NULL;
90     cryptedLabel         = NULL;
91     controls             = NULL;
92     inputC               = NULL;
93     b_shouldHide         = false;
94
95     bgWasVisible         = false;
96     i_bg_height          = 0;
97
98     /* Ask for privacy */
99     askForPrivacy();
100
101     /**
102      *  Configuration and settings
103      *  Pre-building of interface
104      **/
105     /* Main settings */
106     setFocusPolicy( Qt::StrongFocus );
107     setAcceptDrops( true );
108     setWindowRole( "vlc-main" );
109     setWindowIcon( QApplication::windowIcon() );
110     setWindowOpacity( config_GetFloat( p_intf, "qt-opacity" ) );
111
112     /* Set The Video In emebedded Mode or not */
113     videoEmbeddedFlag = config_GetInt( p_intf, "embedded-video" );
114
115     /* Does the interface resize to video size or the opposite */
116     b_keep_size = !config_GetInt( p_intf, "qt-video-autoresize" );
117
118     /* Are we in the enhanced always-video mode or not ? */
119     i_visualmode = config_GetInt( p_intf, "qt-display-mode" );
120
121     /* Set the other interface settings */
122     settings = getSettings();
123     settings->beginGroup( "MainWindow" );
124
125     /**
126      * Retrieve saved sizes for main window
127      *   mainBasedSize = based window size for normal mode
128      *                  (no video, no background)
129      *   mainVideoSize = window size with video (all modes)
130      **/
131     mainBasedSize = settings->value( "mainBasedSize", QSize( 350, 120 ) ).toSize();
132     mainVideoSize = settings->value( "mainVideoSize", QSize( 400, 300 ) ).toSize();
133
134     /* Do we want anoying popups or not */
135     notificationEnabled = (bool)config_GetInt( p_intf, "qt-notification" );
136
137     /**************
138      * Status Bar *
139      **************/
140     createStatusBar();
141
142     /**************************
143      *  UI and Widgets design
144      **************************/
145     setVLCWindowsTitle();
146     createMainWidget( settings );
147
148     /************
149      * Menu Bar *
150      ************/
151     QVLCMenu::createMenuBar( this, p_intf );
152     CONNECT( THEMIM->getIM(), voutListChanged( vout_thread_t **, int ),
153              this, destroyPopupMenu() );
154
155 #if 0
156     /* Create a Dock to get the playlist */
157     dockPL = new QDockWidget( qtr( "Playlist" ), this );
158     dockPL->setSizePolicy( QSizePolicy::Preferred,
159                            QSizePolicy::Expanding );
160     dockPL->setFeatures( QDockWidget::AllDockWidgetFeatures );
161     dockPL->setAllowedAreas( Qt::LeftDockWidgetArea
162                            | Qt::RightDockWidgetArea
163                            | Qt::BottomDockWidgetArea );
164     dockPL->hide();
165 #endif
166
167     /********************
168      * Input Manager    *
169      ********************/
170     MainInputManager::getInstance( p_intf );
171
172     /*********************************
173      * Create the Systray Management *
174      *********************************/
175     initSystray();
176
177     /**************************
178      * Various CONNECTs on IM *
179      **************************/
180     /* Connect the input manager to the GUI elements it manages */
181
182     /**
183      * Connects on nameChanged()
184      * Those connects are not merged because different options can trigger
185      * them down.
186      */
187     /* Naming in the controller statusbar */
188     CONNECT( THEMIM->getIM(), nameChanged( const QString& ),
189              this, setName( const QString& ) );
190     /* and in the systray */
191     if( sysTray )
192     {
193         CONNECT( THEMIM->getIM(), nameChanged( const QString& ), this,
194                  updateSystrayTooltipName( const QString& ) );
195     }
196     /* and in the title of the controller */
197     if( config_GetInt( p_intf, "qt-name-in-title" ) )
198     {
199         CONNECT( THEMIM->getIM(), nameChanged( const QString& ), this,
200              setVLCWindowsTitle( const QString& ) );
201     }
202
203     /**
204      * CONNECTS on PLAY_STATUS
205      **/
206     /* Status on the systray */
207     if( sysTray )
208     {
209         CONNECT( THEMIM->getIM(), statusChanged( int ),
210                  this, updateSystrayTooltipStatus( int ) );
211     }
212
213
214     /* END CONNECTS ON IM */
215
216     /************
217      * Callbacks
218      ************/
219     var_AddCallback( p_intf->p_libvlc, "intf-show", IntfShowCB, p_intf );
220
221     /* Register callback for the intf-popupmenu variable */
222     var_AddCallback( p_intf->p_libvlc, "intf-popupmenu", PopupMenuCB, p_intf );
223
224
225     /* VideoWidget connects for asynchronous calls */
226     connect( this, SIGNAL(askGetVideo(WId*,int*,int*,unsigned*,unsigned *)),
227              this, SLOT(getVideoSlot(WId*,int*,int*,unsigned*,unsigned*)),
228              Qt::BlockingQueuedConnection );
229     connect( this, SIGNAL(askReleaseVideo( void )),
230              this, SLOT(releaseVideoSlot( void )),
231              Qt::BlockingQueuedConnection );
232
233     if( videoWidget )
234     {
235         CONNECT( this, askVideoToResize( unsigned int, unsigned int ),
236                  videoWidget, SetSizing( unsigned int, unsigned int ) );
237         CONNECT( this, askVideoSetFullScreen( bool ),
238                  videoWidget, SetFullScreen( bool ) );
239         CONNECT( videoWidget, keyPressed( QKeyEvent * ),
240                  this, handleKeyPress( QKeyEvent * ) );
241     }
242
243     CONNECT( this, askUpdate(), this, doComponentsUpdate() );
244     CONNECT( THEDP, toolBarConfUpdated(), this, recreateToolbars() );
245
246     /* Size and placement of interface */
247     settings->beginGroup( "MainWindow" );
248     QVLCTools::restoreWidgetPosition( settings, this, QSize(380, 60) );
249
250     /* resize to previously saved main window size if appicable */
251     if( b_keep_size )
252     {
253        if( i_visualmode == QT_ALWAYS_VIDEO_MODE ||
254            i_visualmode == QT_MINIMAL_MODE )
255        {
256            resize( mainVideoSize );
257        }
258        else
259        {
260            resize( mainBasedSize );
261        }
262     }
263
264     bool b_visible = settings->value( "playlist-visible", 0 ).toInt();
265     settings->endGroup();
266
267     /* Playlist */
268     if( b_visible ) togglePlaylist();
269
270     /* Enable the popup menu in the MI */
271     setContextMenuPolicy( Qt::CustomContextMenu );
272     CONNECT( this, customContextMenuRequested( const QPoint& ),
273              this, popupMenu( const QPoint& ) );
274
275     /* Final sizing and showing */
276     setMinimumWidth( __MAX( controls->sizeHint().width(),
277                             menuBar()->sizeHint().width() ) );
278     setVisible( !b_shouldHide );
279
280     /* And switch to minimal view if needed
281        Must be called after the show() */
282     if( i_visualmode == QT_MINIMAL_MODE )
283         toggleMinimalView( true );
284
285     /* Update the geometry : It is useful if you switch between
286        qt-display-modes ?*/
287     updateGeometry();
288     resize( sizeHint() );
289
290 #ifdef WIN32
291     createTaskBarButtons();
292 #endif
293 }
294
295 MainInterface::~MainInterface()
296 {
297     msg_Dbg( p_intf, "Destroying the main interface" );
298
299     /* Unsure we hide the videoWidget before destroying it */
300     if( videoIsActive ) videoWidget->hide();
301
302     /* Save playlist state */
303     if( playlistWidget )
304     {
305         if( !isDocked() )
306             QVLCTools::saveWidgetPosition( p_intf, "Playlist", playlistWidget );
307
308         delete playlistWidget;
309     }
310
311 #ifdef WIN32
312     if( himl )
313         ImageList_Destroy( himl );
314     if(p_taskbl)
315         p_taskbl->vt->Release(p_taskbl);
316     CoUninitialize();
317 #endif
318
319     /* Be sure to kill the actionsManager... FIXME */
320     ActionsManager::killInstance();
321
322     /* Delete the FSC controller */
323     delete fullscreenControls;
324
325     /* Save states */
326     settings->beginGroup( "MainWindow" );
327     settings->setValue( "pl-dock-status", (int)i_pl_dock );
328     settings->setValue( "playlist-visible", (int)playlistVisible );
329     settings->setValue( "adv-controls",
330                         getControlsVisibilityStatus() & CONTROLS_ADVANCED );
331
332     settings->setValue( "mainBasedSize", mainBasedSize );
333     settings->setValue( "mainVideoSize", mainVideoSize );
334
335     if( bgWidget )
336         settings->setValue( "backgroundSize", bgWidget->size() );
337
338     /* Save this size */
339     QVLCTools::saveWidgetPosition(settings, this);
340     settings->endGroup();
341
342
343     /* Unregister callbacks */
344     var_DelCallback( p_intf->p_libvlc, "intf-show", IntfShowCB, p_intf );
345     var_DelCallback( p_intf->p_libvlc, "intf-popupmenu", PopupMenuCB, p_intf );
346
347     p_intf->p_sys->p_mi = NULL;
348 }
349
350 /*****************************
351  *   Main UI handling        *
352  *****************************/
353 void MainInterface::recreateToolbars()
354 {
355     msg_Dbg( p_intf, "Recreating the toolbars" );
356     settings->beginGroup( "MainWindow" );
357     delete controls;
358     delete inputC;
359     controls = new ControlsWidget( p_intf, false, this ); /* FIXME */
360     CONNECT( controls, advancedControlsToggled( bool ),
361              this, doComponentsUpdate() );
362     CONNECT( controls, sizeChanged(),
363              this, doComponentsUpdate() );
364     inputC = new InputControlsWidget( p_intf, this );
365
366     mainLayout->addWidget( inputC, 2, 0, 1, -1, Qt::AlignBottom );
367     mainLayout->addWidget( controls, settings->value( "ToolbarPos", 0 ).toInt() ? 0: 3,
368                               0, 1, -1, Qt::AlignBottom );
369     settings->endGroup();
370 }
371
372 void MainInterface::createMainWidget( QSettings *settings )
373 {
374     /* Create the main Widget and the mainLayout */
375     QWidget *main = new QWidget;
376     setCentralWidget( main );
377     mainLayout = new QGridLayout( main );
378
379     /* Margins, spacing */
380     main->setContentsMargins( 0, 0, 0, 0 );
381     main->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
382     mainLayout->setSpacing( 0 );
383     mainLayout->setMargin( 0 );
384
385     /* Visualisation */
386     /* Disabled for now, they SUCK */
387     #if 0
388     visualSelector = new VisualSelector( p_intf );
389     mainLayout->insertWidget( 0, visualSelector );
390     visualSelector->hide();
391     #endif
392
393     /* Bg Cone */
394     bgWidget = new BackgroundWidget( p_intf );
395     bgWidget->resize(
396             settings->value( "backgroundSize", QSize( 300, 200 ) ).toSize() );
397     bgWidget->updateGeometry();
398
399     if( i_visualmode != QT_ALWAYS_VIDEO_MODE &&
400         i_visualmode != QT_MINIMAL_MODE )
401     {
402         bgWidget->hide();
403     }
404
405     /* And video Outputs */
406     if( videoEmbeddedFlag )
407         videoWidget = new VideoWidget( p_intf );
408
409     /* Create the CONTROLS Widget */
410     controls = new ControlsWidget( p_intf,
411                    settings->value( "adv-controls", false ).toBool(), this );
412     CONNECT( controls, advancedControlsToggled( bool ),
413              this, doComponentsUpdate() );
414     CONNECT( controls, sizeChanged(),
415              this, doComponentsUpdate() );
416     inputC = new InputControlsWidget( p_intf, this );
417
418
419     /* Add the controls Widget to the main Widget */
420     if( videoWidget ){
421         mainLayout->addWidget( videoWidget, 0, 0, 1, -1 );
422         mainLayout->setRowStretch( 0, 10 );
423     }
424     mainLayout->addWidget( bgWidget, 1, 0, 1, -1 );
425     //mainLayout->setRowStretch( 1, 10 );
426     mainLayout->addWidget( inputC, 2, 0, 1, -1, Qt::AlignBottom );
427     mainLayout->addWidget( controls, settings->value( "ToolbarPos", 0 ).toInt() ? 0: 3,
428                            0, 1, -1, Qt::AlignBottom );
429
430     /* Finish the sizing */
431     main->updateGeometry();
432
433     getSettings()->endGroup();
434 #ifdef WIN32
435     if ( depth() > 8 )
436 #endif
437     /* Create the FULLSCREEN CONTROLS Widget */
438     if( config_GetInt( p_intf, "qt-fs-controller" ) )
439     {
440         fullscreenControls = new FullscreenControllerWidget( p_intf, this );
441         CONNECT( fullscreenControls, keyPressed( QKeyEvent * ),
442                  this, handleKeyPress( QKeyEvent * ) );
443     }
444 }
445
446 inline void MainInterface::createStatusBar()
447 {
448     /****************
449      *  Status Bar  *
450      ****************/
451     /* Widgets Creation*/
452     QStatusBar *statusBarr = statusBar();
453
454     TimeLabel *timeLabel = new TimeLabel( p_intf );
455     nameLabel = new QLabel( this );
456     nameLabel->setTextInteractionFlags( Qt::TextSelectableByMouse
457                                       | Qt::TextSelectableByKeyboard );
458     SpeedLabel *speedLabel = new SpeedLabel( p_intf, "1.00x", this );
459
460     /* Styling those labels */
461     timeLabel->setFrameStyle( QFrame::Sunken | QFrame::Panel );
462     speedLabel->setFrameStyle( QFrame::Sunken | QFrame::Panel );
463     nameLabel->setFrameStyle( QFrame::Sunken | QFrame::StyledPanel);
464
465     /* and adding those */
466     statusBarr->addWidget( nameLabel, 8 );
467     statusBarr->addPermanentWidget( speedLabel, 0 );
468     statusBarr->addPermanentWidget( timeLabel, 0 );
469
470     /* timeLabel behaviour:
471        - double clicking opens the goto time dialog
472        - right-clicking and clicking just toggle between remaining and
473          elapsed time.*/
474     CONNECT( timeLabel, timeLabelDoubleClicked(), THEDP, gotoTimeDialog() );
475
476     CONNECT( THEMIM->getIM(), encryptionChanged( bool ),
477              this, showCryptedLabel( bool ) );
478 }
479
480 #ifdef WIN32
481 void MainInterface::createTaskBarButtons()
482 {
483     /*Here is the code for the taskbar thumb buttons
484     FIXME:We need pretty buttons in 16x16 px that are handled correctly by masks in Qt
485     FIXME:the play button's picture doesn't changed to pause when clicked
486     */
487     OSVERSIONINFO winVer;
488     winVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
489     if( GetVersionEx(&winVer) && winVer.dwMajorVersion > 5 )
490     {
491         if(himl = ImageList_Create( 15, //cx
492                                     18, //cy
493                                     ILC_COLOR,//flags
494                                     4,//initial nb of images
495                                     0//nb of images that can be added
496                                     ))
497         {
498             QPixmap img   = QPixmap(":/toolbar/previous_b");
499             QPixmap img2  = QPixmap(":/toolbar/pause_b");
500             QPixmap img3  = QPixmap(":/toolbar/play_b");
501             QPixmap img4  = QPixmap(":/toolbar/next_b");
502             QBitmap mask  = img.createMaskFromColor(Qt::transparent);
503             QBitmap mask2 = img2.createMaskFromColor(Qt::transparent);
504             QBitmap mask3 = img3.createMaskFromColor(Qt::transparent);
505             QBitmap mask4 = img4.createMaskFromColor(Qt::transparent);
506
507             if(-1 == ImageList_Add(himl, img.toWinHBITMAP(QPixmap::PremultipliedAlpha),mask.toWinHBITMAP()))
508                 msg_Err( p_intf, "ImageList_Add failed" );
509             if(-1 == ImageList_Add(himl, img2.toWinHBITMAP(QPixmap::PremultipliedAlpha),mask2.toWinHBITMAP()))
510                 msg_Err( p_intf, "ImageList_Add failed" );
511             if(-1 == ImageList_Add(himl, img3.toWinHBITMAP(QPixmap::PremultipliedAlpha),mask3.toWinHBITMAP()))
512                 msg_Err( p_intf, "ImageList_Add failed" );
513             if(-1 == ImageList_Add(himl, img4.toWinHBITMAP(QPixmap::PremultipliedAlpha),mask4.toWinHBITMAP()))
514                 msg_Err( p_intf, "ImageList_Add failed" );
515         }
516
517         CoInitialize( 0 );
518
519         if( S_OK == CoCreateInstance( &clsid_ITaskbarList,
520                     NULL, CLSCTX_INPROC_SERVER,
521                     &IID_ITaskbarList3,
522                     (void **)&p_taskbl) )
523         {
524             p_taskbl->vt->HrInit(p_taskbl);
525
526             int msg_value = RegisterWindowMessage("TaskbarButtonCreated");
527             //msg_Info( p_intf, "msg value: %04x", msg_value );
528
529             // Define an array of two buttons. These buttons provide images through an
530             // image list and also provide tooltips.
531             DWORD dwMask = THB_BITMAP | THB_FLAGS;
532
533             THUMBBUTTON thbButtons[2];
534             thbButtons[0].dwMask = dwMask;
535             thbButtons[0].iId = 0;
536             thbButtons[0].iBitmap = 0;
537             thbButtons[0].dwFlags = THBF_HIDDEN;
538
539             thbButtons[1].dwMask = dwMask;
540             thbButtons[1].iId = 1;
541             thbButtons[1].iBitmap = 2;
542             thbButtons[1].dwFlags = THBF_HIDDEN;
543
544             thbButtons[2].dwMask = dwMask;
545             thbButtons[2].iId = 2;
546             thbButtons[2].iBitmap = 3;
547             thbButtons[2].dwFlags = THBF_HIDDEN;
548
549             HRESULT hr = p_taskbl->vt->ThumbBarSetImageList(p_taskbl, GetForegroundWindow(), himl );
550             if(S_OK != hr)
551                 msg_Err( p_intf, "ThumbBarSetImageList failed with error %08x", hr );
552             if(S_OK != p_taskbl->vt->ThumbBarAddButtons(p_taskbl, GetForegroundWindow(), 3, thbButtons))
553                 msg_Err( p_intf, "ThumbBarAddButtons failed with error %08x", GetLastError() );
554
555             CONNECT( THEMIM->getIM(), statusChanged( int ), this, changeThumbbarButtons( int ) );
556         }
557     }
558     else
559     {
560         himl = NULL;
561         p_taskbl = NULL;
562     }
563 }
564 #endif
565
566
567 inline void MainInterface::initSystray()
568 {
569     bool b_systrayAvailable = QSystemTrayIcon::isSystemTrayAvailable();
570     bool b_systrayWanted = config_GetInt( p_intf, "qt-system-tray" );
571
572     if( config_GetInt( p_intf, "qt-start-minimized") > 0 )
573     {
574         if( b_systrayAvailable )
575         {
576             b_systrayWanted = true;
577             b_shouldHide = true;
578         }
579         else
580             msg_Err( p_intf, "cannot start minimized without system tray bar" );
581     }
582
583     if( b_systrayAvailable && b_systrayWanted )
584             createSystray();
585 }
586
587 inline void MainInterface::askForPrivacy()
588 {
589     /**
590      * Ask for the network policy on FIRST STARTUP
591      **/
592     if( config_GetInt( p_intf, "qt-privacy-ask") )
593     {
594         QList<ConfigControl *> controls;
595         if( privacyDialog( &controls ) == QDialog::Accepted )
596         {
597             QList<ConfigControl *>::Iterator i;
598             for(  i = controls.begin() ; i != controls.end() ; i++ )
599             {
600                 ConfigControl *c = qobject_cast<ConfigControl *>(*i);
601                 c->doApply( p_intf );
602             }
603
604             config_PutInt( p_intf,  "qt-privacy-ask" , 0 );
605             /* We have to save here because the user may not launch Prefs */
606             config_SaveConfigFile( p_intf, NULL );
607         }
608     }
609 }
610
611 int MainInterface::privacyDialog( QList<ConfigControl *> *controls )
612 {
613     QDialog *privacy = new QDialog( this );
614
615     privacy->setWindowTitle( qtr( "Privacy and Network Policies" ) );
616     privacy->setWindowRole( "vlc-privacy" );
617
618     QGridLayout *gLayout = new QGridLayout( privacy );
619
620     QGroupBox *blabla = new QGroupBox( qtr( "Privacy and Network Warning" ) );
621     QGridLayout *blablaLayout = new QGridLayout( blabla );
622     QLabel *text = new QLabel( qtr(
623         "<p>The <i>VideoLAN Team</i> doesn't like when an application goes "
624         "online without authorization.</p>\n "
625         "<p><i>VLC media player</i> can retreive limited information from "
626         "the Internet in order to get CD covers or to check "
627         "for available updates.</p>\n"
628         "<p><i>VLC media player</i> <b>DOES NOT</b> send or collect <b>ANY</b> "
629         "information, even anonymously, about your usage.</p>\n"
630         "<p>Therefore please select from the following options, the default being "
631         "almost no access to the web.</p>\n") );
632     text->setWordWrap( true );
633     text->setTextFormat( Qt::RichText );
634
635     blablaLayout->addWidget( text, 0, 0 ) ;
636
637     QGroupBox *options = new QGroupBox;
638     QGridLayout *optionsLayout = new QGridLayout( options );
639
640     gLayout->addWidget( blabla, 0, 0, 1, 3 );
641     gLayout->addWidget( options, 1, 0, 1, 3 );
642     module_config_t *p_config;
643     ConfigControl *control;
644     int line = 0;
645
646 #define CONFIG_GENERIC( option, type )                            \
647     p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
648     if( p_config )                                                \
649     {                                                             \
650         control =  new type ## ConfigControl( VLC_OBJECT(p_intf), \
651                 p_config, options, false, optionsLayout, line );  \
652         controls->append( control );                               \
653     }
654
655 #define CONFIG_GENERIC_NOBOOL( option, type )                     \
656     p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
657     if( p_config )                                                \
658     {                                                             \
659         control =  new type ## ConfigControl( VLC_OBJECT(p_intf), \
660                 p_config, options, optionsLayout, line );  \
661         controls->append( control );                               \
662     }
663
664     CONFIG_GENERIC( "album-art", IntegerList ); line++;
665 #ifdef UPDATE_CHECK
666     CONFIG_GENERIC_NOBOOL( "qt-updates-notif", Bool ); line++;
667 #endif
668
669     QPushButton *ok = new QPushButton( qtr( "OK" ) );
670
671     gLayout->addWidget( ok, 2, 2 );
672
673     CONNECT( ok, clicked(), privacy, accept() );
674     return privacy->exec();
675 }
676
677
678 /**********************************************************************
679  * Handling of sizing of the components
680  **********************************************************************/
681
682 /* This function is probably wrong, but we don't have many many choices...
683    Since we can't know from the playlist Widget if we are inside a dock or not,
684    because the playlist Widget can be called by THEDP, as a separate windows for
685    the skins.
686    Maybe the other solution is to redefine the sizeHint() of the playlist and
687    ask _parent->isFloating()...
688    If you think this would be better, please FIXME it...
689 */
690
691 QSize MainInterface::sizeHint() const
692 {
693     if( b_keep_size )
694     {
695         if( i_visualmode == QT_ALWAYS_VIDEO_MODE ||
696             i_visualmode == QT_MINIMAL_MODE )
697         {
698                 return mainVideoSize;
699         }
700         else
701         {
702             if( VISIBLE( bgWidget) ||
703                 ( videoIsActive && videoWidget->isVisible() )
704               )
705                 return mainVideoSize;
706             else
707                 return mainBasedSize;
708         }
709     }
710
711     int nwidth  = controls->sizeHint().width();
712     int nheight = controls->isVisible() ?
713                   controls->size().height()
714                   + inputC->size().height()
715                   + menuBar()->size().height()
716                   + statusBar()->size().height()
717                   : 0 ;
718
719     if( VISIBLE( bgWidget ) )
720     {
721         if( i_bg_height )
722             nheight += i_bg_height;
723         else
724             nheight += bgWidget->size().height();
725         nwidth  = __MAX( nwidth, bgWidget->size().width() );
726     }
727     else if( videoIsActive && videoWidget->isVisible() )
728     {
729         nheight += videoWidget->sizeHint().height();
730         nwidth  = __MAX( nwidth, videoWidget->sizeHint().width() );
731     }
732 #if 0
733     if( !dockPL->isFloating() && dockPL->isVisible() && dockPL->widget()  )
734     {
735         nheight += dockPL->size().height();
736         nwidth = __MAX( nwidth, dockPL->size().width() );
737         msg_Warn( p_intf, "3 %i %i", nheight, nwidth );
738     }
739 #endif
740     return QSize( nwidth, nheight );
741 }
742
743 /* Video widget cannot do this synchronously as it runs in another thread */
744 /* Well, could it, actually ? Probably dangerous ... */
745
746 /* This function is called:
747    - toggling of minimal View
748    - through askUpdate() by Vout thread request video and resize video (zoom)
749    - Advanced buttons toggled
750  */
751 void MainInterface::doComponentsUpdate()
752 {
753     if( isFullScreen() || isMaximized() ) return;
754
755     msg_Dbg( p_intf, "Updating the geometry" );
756     /* Here we resize to sizeHint() and not adjustsize because we want
757        the videoWidget to be exactly the correctSize */
758     resize( sizeHint() );
759     //    adjustSize()  ;
760 #ifndef NDEBUG
761     debug();
762 #endif
763 }
764
765 void MainInterface::debug()
766 {
767 #ifndef NDEBUG
768     msg_Dbg( p_intf, "size: %i - %i", size().height(), size().width() );
769     msg_Dbg( p_intf, "sizeHint: %i - %i", sizeHint().height(), sizeHint().width() );
770     if( videoWidget && videoWidget->isVisible() )
771     {
772         msg_Dbg( p_intf, "size: %i - %i", size().height(), size().width() );
773         msg_Dbg( p_intf, "sizeHint: %i - %i", sizeHint().height(), sizeHint().width() );
774     }
775 #endif
776 }
777
778 void MainInterface::destroyPopupMenu()
779 {
780     QVLCMenu::PopupMenu(p_intf, false );
781 }
782
783
784 void MainInterface::toggleFSC()
785 {
786    if( !fullscreenControls ) return;
787
788    IMEvent *eShow = new IMEvent( FullscreenControlToggle_Type, 0 );
789    QApplication::postEvent( fullscreenControls, eShow );
790 }
791
792 void MainInterface::popupMenu( const QPoint &p )
793 {
794     /* Ow, that's ugly: don't show the popup menu if cursor over
795      * the main menu bar or the status bar */
796     if( !childAt( p ) || ( ( childAt( p ) != menuBar() )
797                         && ( childAt( p )->parentWidget() != statusBar() ) ) )
798         QVLCMenu::PopupMenu( p_intf, true );
799 }
800
801 /****************************************************************************
802  * Video Handling
803  ****************************************************************************/
804
805 /* This event is used to deal with the fullscreen and always on top
806    issue conflict (bug in wx) */
807 class SetVideoOnTopQtEvent : public QEvent
808 {
809 public:
810     SetVideoOnTopQtEvent( bool _onTop ) :
811       QEvent( (QEvent::Type)SetVideoOnTopEvent_Type ), onTop( _onTop)
812     {}
813
814     bool OnTop() const { return onTop; }
815
816 private:
817     bool onTop;
818 };
819
820 /**
821  * NOTE:
822  * You must note change the state of this object or other Qt4 UI objects,
823  * from the video output thread - only from the Qt4 UI main loop thread.
824  * All window provider queries must be handled through signals or events.
825  * That's why we have all those emit statements...
826  */
827 WId MainInterface::getVideo( int *pi_x, int *pi_y,
828                              unsigned int *pi_width, unsigned int *pi_height )
829 {
830     if( !videoWidget )
831         return 0;
832
833     /* This is a blocking call signal. Results are returned through pointers.
834      * Beware of deadlocks! */
835     WId id;
836     emit askGetVideo( &id, pi_x, pi_y, pi_width, pi_height );
837     return id;
838 }
839
840 void MainInterface::getVideoSlot( WId *p_id, int *pi_x, int *pi_y,
841                                   unsigned *pi_width, unsigned *pi_height )
842 {
843     /* Request the videoWidget */
844     WId ret = videoWidget->request( pi_x, pi_y,
845                                     pi_width, pi_height, b_keep_size );
846     *p_id = ret;
847     if( ret ) /* The videoWidget is available */
848     {
849         /* Did we have a bg ? Hide it! */
850         if( VISIBLE( bgWidget) )
851         {
852             bgWasVisible = true;
853             bgWidget->toggle();
854         }
855         else
856             bgWasVisible = false;
857
858         /* ask videoWidget to show */
859         videoWidget->SetSizing( *pi_width, *pi_height );
860
861         /* Consider the video active now */
862         videoIsActive = true;
863
864         emit askUpdate();
865     }
866 }
867
868 /* Asynchronous call from the WindowClose function */
869 void MainInterface::releaseVideo( void )
870 {
871     emit askReleaseVideo( );
872 }
873
874 /* Function that is CONNECTED to the previous emit */
875 void MainInterface::releaseVideoSlot( void )
876 {
877     videoWidget->release( );
878
879     if( bgWasVisible )
880     {
881         /* Reset the bg state */
882         bgWasVisible = false;
883         bgWidget->show();
884     }
885
886     videoIsActive = false;
887
888     /* Try to resize, except when you are in Fullscreen mode */
889     doComponentsUpdate();
890 }
891
892 /* Asynchronous call from WindowControl function */
893 int MainInterface::controlVideo( int i_query, va_list args )
894 {
895     switch( i_query )
896     {
897     case VOUT_WINDOW_SET_SIZE:
898     {
899         unsigned int i_width  = va_arg( args, unsigned int );
900         unsigned int i_height = va_arg( args, unsigned int );
901         emit askVideoToResize( i_width, i_height );
902         emit askUpdate();
903         return VLC_SUCCESS;
904     }
905     case VOUT_WINDOW_SET_ON_TOP:
906     {
907         int i_arg = va_arg( args, int );
908         QApplication::postEvent( this, new SetVideoOnTopQtEvent( i_arg ) );
909         return VLC_SUCCESS;
910     }
911     case VOUT_WINDOW_SET_FULLSCREEN:
912     {
913         bool b_fs = va_arg( args, int );
914         emit askVideoSetFullScreen( b_fs );
915         return VLC_SUCCESS;
916     }
917     default:
918         msg_Warn( p_intf, "unsupported control query" );
919         return VLC_EGENERIC;
920     }
921 }
922
923 /*****************************************************************************
924  * Playlist, Visualisation and Menus handling
925  *****************************************************************************/
926 /**
927  * Toggle the playlist widget or dialog
928  **/
929 void MainInterface::togglePlaylist()
930 {
931     /* CREATION
932     If no playlist exist, then create one and attach it to the DockPL*/
933     if( !playlistWidget )
934     {
935         playlistWidget = new PlaylistWidget( p_intf );
936
937         i_pl_dock = PL_UNDOCKED;
938 /*        i_pl_dock = (pl_dock_e)getSettings()
939                          ->value( "pl-dock-status", PL_UNDOCKED ).toInt(); */
940
941         if( i_pl_dock == PL_UNDOCKED )
942         {
943             playlistWidget->setWindowFlags( Qt::Window );
944
945             /* This will restore the geometry but will not work for position,
946                because of parenting */
947             QVLCTools::restoreWidgetPosition( p_intf, "Playlist",
948                     playlistWidget, QSize( 600, 300 ) );
949         }
950         else
951         {
952          //   mainLayout->insertWidget( 4, playlistWidget );
953         }
954         playlistVisible = true;
955
956         playlistWidget->show();
957     }
958     else
959     {
960     /* toggle the visibility of the playlist */
961        TOGGLEV( playlistWidget );
962        playlistVisible = !playlistVisible;
963        //doComponentsUpdate(); //resize( sizeHint() );
964     }
965 }
966
967 /* Function called from the menu to undock the playlist */
968 void MainInterface::undockPlaylist()
969 {
970 //    dockPL->setFloating( true );
971 //    adjustSize();
972 }
973
974 void MainInterface::dockPlaylist( pl_dock_e i_pos )
975 {
976 }
977
978 void MainInterface::toggleMinimalView( bool b_switch )
979 {
980     if( i_visualmode != QT_ALWAYS_VIDEO_MODE &&
981         i_visualmode != QT_MINIMAL_MODE )
982     { /* NORMAL MODE then */
983         if( !videoWidget || videoWidget->isHidden() )
984         {
985             bgWidget->toggle();
986         }
987         else
988         {
989             /* If video is visible, then toggle the status of bgWidget */
990             bgWasVisible = !bgWasVisible;
991         }
992     }
993
994     i_bg_height = bgWidget->height();
995
996     menuBar()->setVisible( !b_switch );
997     controls->setVisible( !b_switch );
998     statusBar()->setVisible( !b_switch );
999     inputC->setVisible( !b_switch );
1000
1001     doComponentsUpdate();
1002
1003     emit minimalViewToggled( b_switch );
1004 }
1005
1006 /* toggling advanced controls buttons */
1007 void MainInterface::toggleAdvanced()
1008 {
1009     controls->toggleAdvanced();
1010 //    if( fullscreenControls ) fullscreenControls->toggleAdvanced();
1011 }
1012
1013 /* Get the visibility status of the controls (hidden or not, advanced or not) */
1014 int MainInterface::getControlsVisibilityStatus()
1015 {
1016     return( (controls->isVisible() ? CONTROLS_VISIBLE : CONTROLS_HIDDEN )
1017                 + CONTROLS_ADVANCED * controls->b_advancedVisible );
1018 }
1019
1020 #if 0
1021 void MainInterface::visual()
1022 {
1023     if( !VISIBLE( visualSelector) )
1024     {
1025         visualSelector->show();
1026         if( !THEMIM->getIM()->hasVideo() )
1027         {
1028             /* Show the background widget */
1029         }
1030         visualSelectorEnabled = true;
1031     }
1032     else
1033     {
1034         /* Stop any currently running visualization */
1035         visualSelector->hide();
1036         visualSelectorEnabled = false;
1037     }
1038     doComponentsUpdate();
1039 }
1040 #endif
1041
1042 /************************************************************************
1043  * Other stuff
1044  ************************************************************************/
1045 void MainInterface::setName( const QString& name )
1046 {
1047     input_name = name; /* store it for the QSystray use */
1048     /* Display it in the status bar, but also as a Tooltip in case it doesn't
1049        fit in the label */
1050     nameLabel->setText( " " + name + " " );
1051     nameLabel->setToolTip( " " + name +" " );
1052 }
1053
1054 /**
1055  * Give the decorations of the Main Window a correct Name.
1056  * If nothing is given, set it to VLC...
1057  **/
1058 void MainInterface::setVLCWindowsTitle( const QString& aTitle )
1059 {
1060     if( aTitle.isEmpty() )
1061     {
1062         setWindowTitle( qtr( "VLC media player" ) );
1063     }
1064     else
1065     {
1066         setWindowTitle( aTitle + " - " + qtr( "VLC media player" ) );
1067     }
1068 }
1069
1070 void MainInterface::showCryptedLabel( bool b_show )
1071 {
1072     if( cryptedLabel == NULL )
1073     {
1074         cryptedLabel = new QLabel;
1075         // The lock icon is not the right one for DRM protection/scrambled.
1076         //cryptedLabel->setPixmap( QPixmap( ":/lock" ) );
1077         cryptedLabel->setText( "DRM" );
1078         statusBar()->addWidget( cryptedLabel );
1079     }
1080
1081     cryptedLabel->setVisible( b_show );
1082 }
1083
1084 /*****************************************************************************
1085  * Systray Icon and Systray Menu
1086  *****************************************************************************/
1087
1088 /**
1089  * Create a SystemTray icon and a menu that would go with it.
1090  * Connects to a click handler on the icon.
1091  **/
1092 void MainInterface::createSystray()
1093 {
1094     QIcon iconVLC;
1095     if( QDate::currentDate().dayOfYear() >= 354 )
1096         iconVLC =  QIcon( QPixmap( ":/logo/vlc128-christmas.png" ) );
1097     else
1098         iconVLC =  QIcon( QPixmap( ":/logo/vlc128.png" ) );
1099     sysTray = new QSystemTrayIcon( iconVLC, this );
1100     sysTray->setToolTip( qtr( "VLC media player" ));
1101
1102     systrayMenu = new QMenu( qtr( "VLC media player" ), this );
1103     systrayMenu->setIcon( iconVLC );
1104
1105     QVLCMenu::updateSystrayMenu( this, p_intf, true );
1106     sysTray->show();
1107
1108     CONNECT( sysTray, activated( QSystemTrayIcon::ActivationReason ),
1109             this, handleSystrayClick( QSystemTrayIcon::ActivationReason ) );
1110 }
1111
1112 /**
1113  * Updates the Systray Icon's menu and toggle the main interface
1114  */
1115 void MainInterface::toggleUpdateSystrayMenu()
1116 {
1117     /* If hidden, show it */
1118     if( isHidden() )
1119     {
1120         show();
1121         activateWindow();
1122     }
1123     else if( isMinimized() )
1124     {
1125         /* Minimized */
1126         showNormal();
1127         activateWindow();
1128     }
1129     else
1130     {
1131         /* Visible (possibly under other windows) */
1132 #ifdef WIN32
1133         /* check if any visible window is above vlc in the z-order,
1134          * but ignore the ones always on top
1135          * and the ones which can't be activated */
1136         WINDOWINFO wi;
1137         HWND hwnd;
1138         wi.cbSize = sizeof( WINDOWINFO );
1139         for( hwnd = GetNextWindow( internalWinId(), GW_HWNDPREV );
1140                 hwnd && ( !IsWindowVisible( hwnd ) ||
1141                     ( GetWindowInfo( hwnd, &wi ) &&
1142                       (wi.dwExStyle&WS_EX_NOACTIVATE) ) );
1143                 hwnd = GetNextWindow( hwnd, GW_HWNDPREV ) );
1144             if( !hwnd || !GetWindowInfo( hwnd, &wi ) ||
1145                 (wi.dwExStyle&WS_EX_TOPMOST) )
1146             {
1147                 hide();
1148             }
1149             else
1150             {
1151                 activateWindow();
1152             }
1153 #else
1154         hide();
1155 #endif
1156     }
1157     QVLCMenu::updateSystrayMenu( this, p_intf );
1158 }
1159
1160 void MainInterface::handleSystrayClick(
1161                                     QSystemTrayIcon::ActivationReason reason )
1162 {
1163     switch( reason )
1164     {
1165         case QSystemTrayIcon::Trigger:
1166         case QSystemTrayIcon::DoubleClick:
1167             toggleUpdateSystrayMenu();
1168             break;
1169         case QSystemTrayIcon::MiddleClick:
1170             sysTray->showMessage( qtr( "VLC media player" ),
1171                     qtr( "Control menu for the player" ),
1172                     QSystemTrayIcon::Information, 3000 );
1173             break;
1174         default:
1175             break;
1176     }
1177 }
1178
1179 /**
1180  * Updates the name of the systray Icon tooltip.
1181  * Doesn't check if the systray exists, check before you call it.
1182  **/
1183 void MainInterface::updateSystrayTooltipName( const QString& name )
1184 {
1185     if( name.isEmpty() )
1186     {
1187         sysTray->setToolTip( qtr( "VLC media player" ) );
1188     }
1189     else
1190     {
1191         sysTray->setToolTip( name );
1192         if( notificationEnabled && ( isHidden() || isMinimized() ) )
1193         {
1194             sysTray->showMessage( qtr( "VLC media player" ), name,
1195                     QSystemTrayIcon::NoIcon, 3000 );
1196         }
1197     }
1198
1199     QVLCMenu::updateSystrayMenu( this, p_intf );
1200 }
1201
1202 /**
1203  * Updates the status of the systray Icon tooltip.
1204  * Doesn't check if the systray exists, check before you call it.
1205  **/
1206 void MainInterface::updateSystrayTooltipStatus( int i_status )
1207 {
1208     switch( i_status )
1209     {
1210         case  0:
1211         case  END_S:
1212             {
1213                 sysTray->setToolTip( qtr( "VLC media player" ) );
1214                 break;
1215             }
1216         case PLAYING_S:
1217             {
1218                 sysTray->setToolTip( input_name );
1219                 break;
1220             }
1221         case PAUSE_S:
1222             {
1223                 sysTray->setToolTip( input_name + " - "
1224                         + qtr( "Paused") );
1225                 break;
1226             }
1227     }
1228     QVLCMenu::updateSystrayMenu( this, p_intf );
1229 }
1230
1231 /************************************************************************
1232  * D&D Events
1233  ************************************************************************/
1234 void MainInterface::dropEvent(QDropEvent *event)
1235 {
1236     dropEventPlay( event, true );
1237 }
1238
1239 void MainInterface::dropEventPlay( QDropEvent *event, bool b_play )
1240 {
1241      event->setDropAction( Qt::CopyAction );
1242      if( !event->possibleActions() & Qt::CopyAction )
1243          return;
1244
1245      const QMimeData *mimeData = event->mimeData();
1246
1247      /* D&D of a subtitles file, add it on the fly */
1248      if( mimeData->urls().size() == 1 )
1249      {
1250         if( THEMIM->getIM()->hasInput() )
1251         {
1252             if( !input_AddSubtitle( THEMIM->getInput(),
1253                                     qtu( toNativeSeparators(
1254                                          mimeData->urls()[0].toLocalFile() ) ),
1255                                     true ) )
1256             {
1257                 event->accept();
1258                 return;
1259             }
1260         }
1261      }
1262      bool first = b_play;
1263      foreach( const QUrl &url, mimeData->urls() )
1264      {
1265         QString s = toNativeSeparators( url.toLocalFile() );
1266
1267         if( s.length() > 0 ) {
1268             char* psz_uri = make_URI( qtu(s) );
1269             playlist_Add( THEPL, psz_uri, NULL,
1270                           PLAYLIST_APPEND | (first ? PLAYLIST_GO: PLAYLIST_PREPARSE),
1271                           PLAYLIST_END, true, pl_Unlocked );
1272             free( psz_uri );
1273             first = false;
1274             RecentsMRL::getInstance( p_intf )->addRecent( s );
1275         }
1276      }
1277      event->accept();
1278 }
1279 void MainInterface::dragEnterEvent(QDragEnterEvent *event)
1280 {
1281      event->acceptProposedAction();
1282 }
1283 void MainInterface::dragMoveEvent(QDragMoveEvent *event)
1284 {
1285      event->acceptProposedAction();
1286 }
1287 void MainInterface::dragLeaveEvent(QDragLeaveEvent *event)
1288 {
1289      event->accept();
1290 }
1291
1292 /************************************************************************
1293  * Events stuff
1294  ************************************************************************/
1295 void MainInterface::customEvent( QEvent *event )
1296 {
1297 #if 0
1298     if( event->type() == PLDockEvent_Type )
1299     {
1300         PlaylistDialog::killInstance();
1301         playlistEmbeddedFlag = true;
1302         menuBar()->clear();
1303         QVLCMenu::createMenuBar(this, p_intf, true, visualSelectorEnabled);
1304         togglePlaylist();
1305     }
1306 #endif
1307     /*else */
1308     if ( event->type() == (int)SetVideoOnTopEvent_Type )
1309     {
1310         SetVideoOnTopQtEvent* p_event = (SetVideoOnTopQtEvent*)event;
1311         if( p_event->OnTop() )
1312             setWindowFlags( windowFlags() | Qt::WindowStaysOnTopHint );
1313         else
1314             setWindowFlags( windowFlags() & ~Qt::WindowStaysOnTopHint );
1315         show(); /* necessary to apply window flags */
1316     }
1317 }
1318
1319 void MainInterface::keyPressEvent( QKeyEvent *e )
1320 {
1321     handleKeyPress( e );
1322 }
1323
1324 void MainInterface::handleKeyPress( QKeyEvent *e )
1325 {
1326     if( ( e->modifiers() &  Qt::ControlModifier ) && ( e->key() == Qt::Key_H )
1327           && !menuBar()->isVisible() )
1328     {
1329         toggleMinimalView( false );
1330         e->accept();
1331     }
1332
1333     int i_vlck = qtEventToVLCKey( e );
1334     if( i_vlck > 0 )
1335     {
1336         var_SetInteger( p_intf->p_libvlc, "key-pressed", i_vlck );
1337         e->accept();
1338     }
1339     else
1340         e->ignore();
1341 }
1342
1343 void MainInterface::resizeEvent( QResizeEvent * event )
1344 {
1345     if( b_keep_size )
1346     {
1347         if( i_visualmode == QT_ALWAYS_VIDEO_MODE ||
1348             i_visualmode == QT_MINIMAL_MODE )
1349         {
1350                 mainVideoSize = size();
1351         }
1352         else
1353         {
1354             if( VISIBLE( bgWidget) ||
1355                 ( videoIsActive && videoWidget->isVisible() )
1356               )
1357                 mainVideoSize = size();
1358             else
1359                 mainBasedSize = size();
1360         }
1361     }
1362 }
1363
1364 void MainInterface::wheelEvent( QWheelEvent *e )
1365 {
1366     int i_vlckey = qtWheelEventToVLCKey( e );
1367     var_SetInteger( p_intf->p_libvlc, "key-pressed", i_vlckey );
1368     e->accept();
1369 }
1370
1371 void MainInterface::closeEvent( QCloseEvent *e )
1372 {
1373     e->accept();
1374     hide();
1375     THEDP->quit();
1376 }
1377
1378 void MainInterface::toggleFullScreen( void )
1379 {
1380     if( isFullScreen() )
1381     {
1382         showNormal();
1383         emit askUpdate(); // Needed if video was launched after the F11
1384         emit fullscreenInterfaceToggled( false );
1385     }
1386     else
1387     {
1388         showFullScreen();
1389         emit fullscreenInterfaceToggled( true );
1390     }
1391
1392 }
1393
1394 //moc doesn't know about #ifdef, so we have to build this method for every platform
1395 void MainInterface::changeThumbbarButtons( int i_status)
1396 {
1397 #ifdef WIN32
1398     // Define an array of two buttons. These buttons provide images through an
1399     // image list and also provide tooltips.
1400     DWORD dwMask = THB_BITMAP | THB_FLAGS;
1401
1402     THUMBBUTTON thbButtons[3];
1403     //prev
1404     thbButtons[0].dwMask = dwMask;
1405     thbButtons[0].iId = 0;
1406     thbButtons[0].iBitmap = 0;
1407
1408     //play/pause
1409     thbButtons[1].dwMask = dwMask;
1410     thbButtons[1].iId = 1;
1411
1412     //next
1413     thbButtons[2].dwMask = dwMask;
1414     thbButtons[2].iId = 2;
1415     thbButtons[2].iBitmap = 3;
1416
1417     switch( i_status )
1418     {
1419         case  0:
1420         case  END_S:
1421             {
1422                 thbButtons[0].dwFlags = THBF_HIDDEN;
1423                 thbButtons[1].dwFlags = THBF_HIDDEN;
1424                 thbButtons[2].dwFlags = THBF_HIDDEN;
1425                 break;
1426             }
1427         case PLAYING_S:
1428             {
1429                 thbButtons[0].dwFlags = THBF_ENABLED;
1430                 thbButtons[1].dwFlags = THBF_ENABLED;
1431                 thbButtons[2].dwFlags = THBF_ENABLED;
1432                 thbButtons[1].iBitmap = 1;
1433                 break;
1434             }
1435         case PAUSE_S:
1436             {
1437                 //thbButtons[0].dwFlags = THBF_ENABLED;
1438                 //thbButtons[1].dwFlags = THBF_ENABLED;
1439                 //thbButtons[2].dwFlags = THBF_ENABLED;
1440                 thbButtons[1].iBitmap = 2;
1441                 break;
1442             }
1443     }
1444
1445     HRESULT hr =  p_taskbl->vt->ThumbBarUpdateButtons(p_taskbl, GetForegroundWindow(), 3, thbButtons);
1446     if(S_OK != hr)
1447         msg_Err( p_intf, "ThumbBarUpdateButtons failed with error %08x", hr );
1448 #else
1449     ;
1450 #endif
1451 }
1452
1453 /*****************************************************************************
1454  * PopupMenuCB: callback triggered by the intf-popupmenu playlist variable.
1455  *  We don't show the menu directly here because we don't want the
1456  *  caller to block for a too long time.
1457  *****************************************************************************/
1458 static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
1459                         vlc_value_t old_val, vlc_value_t new_val, void *param )
1460 {
1461     intf_thread_t *p_intf = (intf_thread_t *)param;
1462
1463     if( p_intf->pf_show_dialog )
1464     {
1465         p_intf->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU,
1466                                 new_val.b_bool, NULL );
1467     }
1468
1469     return VLC_SUCCESS;
1470 }
1471
1472 /*****************************************************************************
1473  * IntfShowCB: callback triggered by the intf-show libvlc variable.
1474  *****************************************************************************/
1475 static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
1476                        vlc_value_t old_val, vlc_value_t new_val, void *param )
1477 {
1478     intf_thread_t *p_intf = (intf_thread_t *)param;
1479     p_intf->p_sys->p_mi->toggleFSC();
1480
1481     /* Show event */
1482      return VLC_SUCCESS;
1483 }
1484