1 /*****************************************************************************
2 * main_interface.cpp : Main interface
3 ****************************************************************************
4 * Copyright (C) 2006-2007 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Jean-Baptiste Kempf <jb@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
26 #include "main_interface.hpp"
27 #include "input_manager.hpp"
28 #include "util/qvlcframe.hpp"
29 #include "util/customwidgets.hpp"
30 #include "dialogs_provider.hpp"
31 #include "components/interface_widgets.hpp"
32 #include "dialogs/playlist.hpp"
36 #include <QCloseEvent>
37 #include <QPushButton>
41 #include <QSystemTrayIcon>
57 #define VISIBLE(i) (i && i->isVisible())
59 #define SET_WIDTH(i,j) i->widgetSize.setWidth(j)
60 #define SET_HEIGHT(i,j) i->widgetSize.setHeight(j)
61 #define SET_WH( i,j,k) i->widgetSize.setWidth(j); i->widgetSize.setHeight(k);
63 #define DS(i) i.width(),i.height()
67 /* Callback prototypes */
68 static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
69 vlc_value_t old_val, vlc_value_t new_val, void *param );
70 static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
71 vlc_value_t old_val, vlc_value_t new_val, void *param );
72 static int InteractCallback( vlc_object_t *, const char *, vlc_value_t,
75 static void *DoRequest( intf_thread_t *p_intf, vout_thread_t *p_vout,
76 int *pi1, int *pi2, unsigned int*pi3,unsigned int*pi4)
78 return p_intf->p_sys->p_mi->requestVideo( p_vout, pi1, pi2, pi3, pi4 );
80 static void DoRelease( intf_thread_t *p_intf, void *p_win )
82 return p_intf->p_sys->p_mi->releaseVideo( p_win );
84 static int DoControl( intf_thread_t *p_intf, void *p_win, int i_q, va_list a )
86 return p_intf->p_sys->p_mi->controlVideo( p_win, i_q, a );
89 MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
91 /* Variables initialisation */
92 need_components_update = false;
93 bgWidget = NULL; videoWidget = NULL; playlistWidget = NULL;
94 embeddedPlaylistWasActive = videoIsActive = false;
96 bool b_createSystray = false;
100 * Configuration and settings
102 settings = new QSettings( "VideoLAN", "VLC" );
103 settings->beginGroup( "MainWindow" );
106 setFocusPolicy( Qt::StrongFocus );
107 setAcceptDrops(true);
108 setWindowIcon( QApplication::windowIcon() );
110 /* Set The Video In emebedded Mode or not */
111 videoEmbeddedFlag = false;
112 if( config_GetInt( p_intf, "embedded-video" ) )
113 videoEmbeddedFlag = true;
115 alwaysVideoFlag = false;
116 if( videoEmbeddedFlag && config_GetInt( p_intf, "qt-always-video" ) )
117 alwaysVideoFlag = true;
119 /* Set the other interface settings */
120 playlistEmbeddedFlag = settings->value("playlist-embedded", true).toBool();
121 advControlsEnabled= settings->value( "adv-controls", false ).toBool();
122 visualSelectorEnabled= settings->value( "visual-selector", false ).toBool();
126 palette2.setColor(this->backgroundRole(), Qt::magenta);
127 setPalette(palette2);
133 setVLCWindowsTitle();
134 handleMainUi( settings );
137 QVLCMenu::createMenuBar( this, p_intf, playlistEmbeddedFlag,
138 advControlsEnabled, visualSelectorEnabled );
141 timeLabel = new QLabel;
142 nameLabel = new QLabel;
143 speedLabel = new QLabel( "1.0x" );
144 timeLabel->setFrameStyle( QFrame::Sunken | QFrame::Panel );
145 speedLabel->setFrameStyle( QFrame::Sunken | QFrame::Panel );
146 statusBar()->addWidget( nameLabel, 8 );
147 statusBar()->addPermanentWidget( speedLabel, 0 );
148 statusBar()->addPermanentWidget( timeLabel, 2 );
149 speedLabel->setContextMenuPolicy ( Qt::CustomContextMenu );
150 timeLabel->setContextMenuPolicy ( Qt::CustomContextMenu );
151 CONNECT( speedLabel, customContextMenuRequested( QPoint ),
152 this, showSpeedMenu( QPoint ) );
153 CONNECT( timeLabel, customContextMenuRequested( QPoint ),
154 this, showTimeMenu( QPoint ) );
158 if( config_GetInt( p_intf, "qt-start-minimized") )
161 b_createSystray = true;
163 if( config_GetInt( p_intf, "qt-system-tray") )
164 b_createSystray = true;
165 if (QSystemTrayIcon::isSystemTrayAvailable() && b_createSystray )
168 /* Init input manager */
169 MainInputManager::getInstance( p_intf );
170 ON_TIMEOUT( updateOnTimer() );
176 /* Connect the input manager to the GUI elements it manages */
177 /* It is also connected to the control->slider */
178 CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
179 this, setDisplay( float, int, int ) );
181 /* Naming in the controller */
182 CONNECT( THEMIM->getIM(), nameChanged( QString ), this,
183 setName( QString ) );
184 if( config_GetInt( p_intf, "qt-system-tray" ) && sysTray )
186 CONNECT( THEMIM->getIM(), nameChanged( QString ), this,
187 updateSystrayTooltipName( QString ) );
189 if( config_GetInt( p_intf, "qt-name-in-title" ) )
191 CONNECT( THEMIM->getIM(), nameChanged( QString ), this,
192 setVLCWindowsTitle( QString ) );
196 CONNECT( THEMIM->getIM(), statusChanged( int ), this, setStatus( int ) );
197 if( config_GetInt( p_intf, "qt-system-tray" ) && sysTray )
199 CONNECT( THEMIM->getIM(), statusChanged( int ), this,
200 updateSystrayTooltipStatus( int ) );
206 var_Create( p_intf, "interaction", VLC_VAR_ADDRESS );
207 var_AddCallback( p_intf, "interaction", InteractCallback, this );
208 p_intf->b_interaction = VLC_TRUE;
210 /* Register callback for the intf-popupmenu variable */
211 playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
212 VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
213 if( p_playlist != NULL )
215 var_AddCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf );
216 var_AddCallback( p_playlist, "intf-show", IntfShowCB, p_intf );
217 vlc_object_release( p_playlist );
221 MainInterface::~MainInterface()
223 /* Unregister callback for the intf-popupmenu variable */
224 playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
225 VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
226 if( p_playlist != NULL )
228 var_DelCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf );
229 var_DelCallback( p_playlist, "intf-show", IntfShowCB, p_intf );
230 vlc_object_release( p_playlist );
233 settings->setValue( "playlist-embedded", playlistEmbeddedFlag );
234 settings->setValue( "adv-controls", advControlsEnabled );
235 settings->setValue( "pos", pos() );
236 settings->endGroup();
238 p_intf->b_interaction = VLC_FALSE;
239 var_DelCallback( p_intf, "interaction", InteractCallback, this );
241 p_intf->pf_request_window = NULL;
242 p_intf->pf_release_window = NULL;
243 p_intf->pf_control_window = NULL;
246 /*****************************
248 *****************************/
251 * Give the decorations of the Main Window a correct Name.
252 * If nothing is given, set it to VLC...
254 void MainInterface::setVLCWindowsTitle( QString aTitle )
256 if( aTitle.isEmpty() )
258 setWindowTitle( qtr( "VLC media player" ) );
262 setWindowTitle( aTitle + " - " + qtr( "VLC media player" ) );
266 void MainInterface::handleMainUi( QSettings *settings )
268 QWidget *main = new QWidget( this );
269 mainLayout = new QVBoxLayout( main );
270 setCentralWidget( main );
272 /* Margins, spacing */
273 main->setContentsMargins( 0, 0, 0, 0 );
274 mainLayout->setMargin( 0 );
277 controls = new ControlsWidget( p_intf );
279 /* Configure the UI */
280 BUTTON_SET_IMG( controls->playlistButton, "" , playlist_icon.png,
281 playlistEmbeddedFlag ? qtr( "Show playlist" ) :
282 qtr( "Open playlist" ) );
283 BUTTONACT( controls->playlistButton, playlist() );
287 palette.setColor(main->backgroundRole(), Qt::green);
288 main->setPalette(palette);
291 /* Add the controls Widget */
292 mainLayout->addWidget( controls );
294 /* Set initial size */
295 resize ( PREF_W, PREF_H );
297 addSize = QSize( mainLayout->margin() * 2, PREF_H );
299 /* advanced Controls handling */
300 advControls = new AdvControlsWidget( p_intf );
301 mainLayout->insertWidget( 0, advControls );
302 advControls->updateGeometry();
303 if( !advControlsEnabled ) advControls->hide();
304 need_components_update = true;
307 visualSelector = new VisualSelector( p_intf );
308 mainLayout->insertWidget( 0, visualSelector );
309 visualSelector->hide();
311 /* And video Outputs */
312 if( alwaysVideoFlag )
314 bgWidget = new BackgroundWidget( p_intf );
315 bgWidget->widgetSize = settings->value( "backgroundSize",
316 QSize( 300, 300 ) ).toSize();
317 bgWidget->resize( bgWidget->widgetSize );
318 bgWidget->updateGeometry();
319 mainLayout->insertWidget( 0, bgWidget );
322 if( videoEmbeddedFlag )
324 videoWidget = new VideoWidget( p_intf );
325 videoWidget->widgetSize = QSize( 1, 1 );
326 //videoWidget->resize( videoWidget->widgetSize );
327 mainLayout->insertWidget( 0, videoWidget );
329 p_intf->pf_request_window = ::DoRequest;
330 p_intf->pf_release_window = ::DoRelease;
331 p_intf->pf_control_window = ::DoControl;
334 /* Finish the sizing */
335 setMinimumSize( PREF_W, addSize.height() );
338 /**********************************************************************
339 * Handling of the components
340 **********************************************************************/
341 void MainInterface::calculateInterfaceSize()
343 int width = 0, height = 0;
344 if( VISIBLE( bgWidget ) )
346 width = bgWidget->widgetSize.width();
347 height = bgWidget->widgetSize.height();
348 assert( !(playlistWidget && playlistWidget->isVisible() ) );
350 else if( VISIBLE( playlistWidget ) )
352 width = playlistWidget->widgetSize.width();
353 height = playlistWidget->widgetSize.height();
355 else if( videoIsActive )
357 width = videoWidget->widgetSize.width() ;
358 height = videoWidget->widgetSize.height();
362 width = PREF_W - addSize.width();
363 height = PREF_H - addSize.height();
365 if( VISIBLE( visualSelector ) )
366 height += visualSelector->height();
367 if( VISIBLE( advControls) )
369 height += advControls->sizeHint().height();
371 mainSize = QSize( width + addSize.width(), height + addSize.height() );
374 void MainInterface::resizeEvent( QResizeEvent *e )
376 videoWidget->widgetSize.setWidth( e->size().width() - addSize.width() );
377 if( videoWidget && videoIsActive && videoWidget->widgetSize.height() > 1 )
379 SET_WH( videoWidget, e->size().width() - addSize.width(),
380 e->size().height() - addSize.height() );
381 videoWidget->updateGeometry();
383 if( VISIBLE( playlistWidget ) )
385 SET_WH( playlistWidget , e->size().width() - addSize.width(),
386 e->size().height() - addSize.height() );
387 playlistWidget->updateGeometry();
390 /****************************************************************************
391 * Small right-click menus
392 ****************************************************************************/
393 void MainInterface::showSpeedMenu( QPoint pos )
396 menu.addAction( "Not Implemented Yet" );
397 menu.exec( QCursor::pos() );
400 void MainInterface::showTimeMenu( QPoint pos )
403 menu.addAction( "Not Implemented Yet" );
404 menu.exec( QCursor::pos() );
407 /*****************************************************************************
408 * Systray Icon and Systray Menu
409 *****************************************************************************/
412 * Create a SystemTray icon and a menu that would go with it.
413 * Connects to a click handler on the icon.
415 void MainInterface::createSystray()
417 QIcon iconVLC = QIcon( QPixmap( ":/vlc128.png" ) );
418 sysTray = new QSystemTrayIcon( iconVLC, this );
419 sysTray->setToolTip( qtr( "VLC media player" ));
421 systrayMenu = new QMenu( qtr( "VLC media player" ), this );
422 systrayMenu->setIcon( iconVLC );
424 QVLCMenu::updateSystrayMenu( this, p_intf, true );
427 CONNECT( sysTray, activated( QSystemTrayIcon::ActivationReason ),
428 this, handleSystrayClick( QSystemTrayIcon::ActivationReason ) );
432 * Update the menu of the Systray Icon.
433 * May be unneedded, since it just calls QVLCMenu::update
436 void MainInterface::updateSystrayMenu( int status )
438 QVLCMenu::updateSystrayMenu( this, p_intf ) ;
442 * Updates the Systray Icon's menu and toggle the main interface
444 void MainInterface::toggleUpdateSystrayMenu()
454 /* check if any visible window is above vlc in the z-order,
455 * but ignore the ones always on top */
458 wi.cbSize = sizeof( WINDOWINFO );
459 for( hwnd = GetNextWindow( internalWinId(), GW_HWNDPREV );
460 hwnd && !IsWindowVisible( hwnd );
461 hwnd = GetNextWindow( hwnd, GW_HWNDPREV ) );
462 if( !hwnd || !GetWindowInfo( hwnd, &wi ) ||
463 (wi.dwExStyle&WS_EX_TOPMOST) )
465 if( isActiveWindow() )
475 QVLCMenu::updateSystrayMenu( this, p_intf );
478 void MainInterface::handleSystrayClick(
479 QSystemTrayIcon::ActivationReason reason )
483 case QSystemTrayIcon::Trigger:
484 toggleUpdateSystrayMenu();
486 case QSystemTrayIcon::MiddleClick:
487 sysTray->showMessage( qtr( "VLC media player" ),
488 qtr( "Control menu for the player" ),
489 QSystemTrayIcon::Information, 4000 );
495 * Updates the name of the systray Icon tooltip.
496 * Doesn't check if the systray exists, check before you call it.
497 * FIXME !!! Fusion with next function ?
499 void MainInterface::updateSystrayTooltipName( QString name )
503 sysTray->setToolTip( qtr( "VLC media player" ) );
507 sysTray->setToolTip( name );
512 * Updates the status of the systray Icon tooltip.
513 * Doesn't check if the systray exists, check before you call it.
515 void MainInterface::updateSystrayTooltipStatus( int i_status )
521 sysTray->setToolTip( qtr( "VLC media player" ) );
526 sysTray->setToolTip( input_name );
527 //+ " - " + qtr( "Playing" ) );
532 sysTray->setToolTip( input_name + " - "
538 void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x,
539 int *pi_y, unsigned int *pi_width,
540 unsigned int *pi_height )
542 void *ret = videoWidget->request( p_nvout,pi_x, pi_y, pi_width, pi_height );
545 videoIsActive = true;
546 if( VISIBLE( playlistWidget ) )
548 embeddedPlaylistWasActive = true;
549 // playlistWidget->hide();
551 bool bgWasVisible = false;
552 if( VISIBLE( bgWidget) )
557 if( THEMIM->getIM()->hasVideo() || !bgWasVisible )
559 videoWidget->widgetSize = QSize( *pi_width, *pi_height );
561 else /* Background widget available, use its size */
563 /* Ok, our visualizations are bad, so don't do this for the moment
564 * use the requested size anyway */
565 // videoWidget->widgetSize = bgWidget->widgeTSize;
566 videoWidget->widgetSize = QSize( *pi_width, *pi_height );
568 // videoWidget->updateGeometry(); /// FIXME: Needed ?
569 need_components_update = true;
574 void MainInterface::releaseVideo( void *p_win )
576 videoWidget->release( p_win );
577 videoWidget->widgetSize = QSize( 0, 0 );
578 videoWidget->resize( videoWidget->widgetSize );
580 if( embeddedPlaylistWasActive )
581 playlistWidget->show();
585 videoIsActive = false;
586 need_components_update = true;
589 class SetVideoOnTopQtEvent : public QEvent
592 SetVideoOnTopQtEvent( bool _onTop ) :
593 QEvent( (QEvent::Type)SetVideoOnTopEvent_Type ), onTop( _onTop)
606 int MainInterface::controlVideo( void *p_window, int i_query, va_list args )
608 int i_ret = VLC_EGENERIC;
613 unsigned int *pi_width = va_arg( args, unsigned int * );
614 unsigned int *pi_height = va_arg( args, unsigned int * );
615 *pi_width = videoWidget->widgetSize.width();
616 *pi_height = videoWidget->widgetSize.height();
622 unsigned int i_width = va_arg( args, unsigned int );
623 unsigned int i_height = va_arg( args, unsigned int );
624 videoWidget->widgetSize = QSize( i_width, i_height );
625 // videoWidget->updateGeometry();
626 need_components_update = true;
630 case VOUT_SET_STAY_ON_TOP:
632 int i_arg = va_arg( args, int );
633 QApplication::postEvent( this, new SetVideoOnTopQtEvent( i_arg ) );
638 msg_Warn( p_intf, "unsupported control query" );
644 void MainInterface::advanced()
646 if( !VISIBLE( advControls ) )
649 advControlsEnabled = true;
654 advControlsEnabled = false;
656 doComponentsUpdate();
659 void MainInterface::visual()
661 if( !VISIBLE( visualSelector) )
663 visualSelector->show();
664 if( !THEMIM->getIM()->hasVideo() )
666 /* Show the background widget */
668 visualSelectorEnabled = true;
672 /* Stop any currently running visualization */
673 visualSelector->hide();
674 visualSelectorEnabled = false;
676 doComponentsUpdate();
679 void MainInterface::playlist()
681 // Toggle the playlist dialog
682 if( !playlistEmbeddedFlag )
688 THEDP->playlistDialog();
692 if( !playlistWidget )
694 PlaylistDialog::killInstance();
695 playlistWidget = new PlaylistWidget( p_intf );
696 mainLayout->insertWidget( 0, playlistWidget );
697 playlistWidget->widgetSize = settings->value( "playlistSize",
698 QSize( 650, 310 ) ).toSize();
699 playlistWidget->hide();
701 CONNECT( playlistWidget, artSet( QString ), bgWidget, setArt(QString) );
703 if( VISIBLE( playlistWidget ) )
705 playlistWidget->hide();
706 if( bgWidget ) bgWidget->show();
709 videoWidget->widgetSize = savedVideoSize;
710 videoWidget->resize( videoWidget->widgetSize );
711 videoWidget->updateGeometry();
712 if( bgWidget ) bgWidget->hide();
717 playlistWidget->show();
720 savedVideoSize = videoWidget->widgetSize;
721 videoWidget->widgetSize.setHeight( 0 );
722 videoWidget->resize( videoWidget->widgetSize );
723 videoWidget->updateGeometry();
725 if( VISIBLE( bgWidget ) ) bgWidget->hide();
727 doComponentsUpdate();
730 /* Video widget cannot do this synchronously as it runs in another thread */
731 /* Well, could it, actually ? Probably dangerous ... */
732 void MainInterface::doComponentsUpdate()
734 calculateInterfaceSize();
738 void MainInterface::undockPlaylist()
742 playlistWidget->hide();
743 playlistWidget->deleteLater();
744 mainLayout->removeWidget( playlistWidget );
745 playlistWidget = NULL;
746 playlistEmbeddedFlag = false;
749 QVLCMenu::createMenuBar( this, p_intf, false, advControlsEnabled,
750 visualSelectorEnabled);
754 videoWidget->widgetSize = savedVideoSize;
755 videoWidget->resize( videoWidget->widgetSize );
756 videoWidget->updateGeometry();
759 doComponentsUpdate();
760 THEDP->playlistDialog();
764 void MainInterface::toggleMenus()
766 if( menuBar()->isVisible() ) menuBar()->hide();
767 else menuBar()->show();
768 msg_Dbg( p_intf, "I was there: \\_o<~~ coin coin" );
771 void MainInterface::customEvent( QEvent *event )
773 if( event->type() == PLDockEvent_Type )
775 PlaylistDialog::killInstance();
776 playlistEmbeddedFlag = true;
778 QVLCMenu::createMenuBar(this, p_intf, true, advControlsEnabled,
779 visualSelectorEnabled);
782 else if ( event->type() == SetVideoOnTopEvent_Type )
784 SetVideoOnTopQtEvent* p_event = (SetVideoOnTopQtEvent*)event;
785 if( p_event->OnTop() )
786 setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
788 setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint);
789 show(); /* necessary to apply window flags?? */
794 /************************************************************************
796 ************************************************************************/
797 void MainInterface::dropEvent(QDropEvent *event)
799 const QMimeData *mimeData = event->mimeData();
801 /* D&D of a subtitles file, add it on the fly */
802 if( mimeData->urls().size() == 1 )
804 if( THEMIM->getIM()->hasInput() )
806 if( input_AddSubtitles( THEMIM->getInput(),
807 qtu( mimeData->urls()[0].toString() ),
810 event->acceptProposedAction();
816 foreach( QUrl url, mimeData->urls() ) {
817 QString s = url.toString();
818 if( s.length() > 0 ) {
819 playlist_Add( THEPL, qtu(s), NULL,
820 PLAYLIST_APPEND | (first ? PLAYLIST_GO:0),
821 PLAYLIST_END, VLC_TRUE, VLC_FALSE );
825 event->acceptProposedAction();
827 void MainInterface::dragEnterEvent(QDragEnterEvent *event)
829 event->acceptProposedAction();
831 void MainInterface::dragMoveEvent(QDragMoveEvent *event)
833 event->acceptProposedAction();
835 void MainInterface::dragLeaveEvent(QDragLeaveEvent *event)
840 /************************************************************************
842 ************************************************************************/
843 void MainInterface::keyPressEvent( QKeyEvent *e )
845 int i_vlck = qtEventToVLCKey( e );
848 var_SetInteger( p_intf->p_libvlc, "key-pressed", i_vlck );
855 void MainInterface::wheelEvent( QWheelEvent *e )
857 int i_vlckey = qtWheelEventToVLCKey( e );
858 var_SetInteger( p_intf->p_libvlc, "key-pressed", i_vlckey );
862 void MainInterface::setDisplay( float pos, int time, int length )
864 char psz_length[MSTRTIME_MAX_SIZE], psz_time[MSTRTIME_MAX_SIZE];
865 secstotimestr( psz_length, length );
866 secstotimestr( psz_time, time );
868 title.sprintf( "%s/%s", psz_time, psz_length );
869 timeLabel->setText( " "+title+" " );
872 void MainInterface::setName( QString name )
875 nameLabel->setText( " " + name+" " );
878 void MainInterface::setStatus( int status )
880 controls->setStatus( status );
882 updateSystrayMenu( status );
885 void MainInterface::updateOnTimer()
887 /* \todo Make this event-driven */
888 // TO MOVE TO controls
889 advControls->enableInput( THEMIM->getIM()->hasInput() );
890 controls->enableInput( THEMIM->getIM()->hasInput() );
891 advControls->enableVideo( THEMIM->getIM()->hasVideo() );
892 controls->enableVideo( THEMIM->getIM()->hasVideo() );
894 if( intf_ShouldDie( p_intf ) )
896 QApplication::closeAllWindows();
897 QApplication::quit();
899 if( need_components_update )
901 doComponentsUpdate();
902 need_components_update = false;
905 controls->updateOnTimer();
908 void MainInterface::closeEvent( QCloseEvent *e )
911 vlc_object_kill( p_intf );
914 static int InteractCallback( vlc_object_t *p_this,
915 const char *psz_var, vlc_value_t old_val,
916 vlc_value_t new_val, void *param )
918 intf_dialog_args_t *p_arg = new intf_dialog_args_t;
919 p_arg->p_dialog = (interaction_dialog_t *)(new_val.p_address);
920 DialogEvent *event = new DialogEvent( INTF_DIALOG_INTERACTION, 0, p_arg );
921 QApplication::postEvent( THEDP, static_cast<QEvent*>(event) );
925 /*****************************************************************************
926 * PopupMenuCB: callback triggered by the intf-popupmenu playlist variable.
927 * We don't show the menu directly here because we don't want the
928 * caller to block for a too long time.
929 *****************************************************************************/
930 static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
931 vlc_value_t old_val, vlc_value_t new_val, void *param )
933 intf_thread_t *p_intf = (intf_thread_t *)param;
935 if( p_intf->pf_show_dialog )
937 p_intf->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU,
944 /*****************************************************************************
945 * IntfShowCB: callback triggered by the intf-show playlist variable.
946 *****************************************************************************/
947 static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
948 vlc_value_t old_val, vlc_value_t new_val, void *param )
950 intf_thread_t *p_intf = (intf_thread_t *)param;
951 //p_intf->p_sys->b_intf_show = VLC_TRUE;