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