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>
58 #define SET_WIDTH(i,j) i->widgetSize.setWidth(j)
59 #define SET_HEIGHT(i,j) i->widgetSize.setHeight(j)
60 #define SET_WH( i,j,k) i->widgetSize.setWidth(j); i->widgetSize.setHeight(k);
62 #define DS(i) i.width(),i.height()
64 /* Callback prototypes */
65 static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
66 vlc_value_t old_val, vlc_value_t new_val, void *param );
67 static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
68 vlc_value_t old_val, vlc_value_t new_val, void *param );
69 static int InteractCallback( vlc_object_t *, const char *, vlc_value_t,
72 static void *DoRequest( intf_thread_t *p_intf, vout_thread_t *p_vout,
73 int *pi1, int *pi2, unsigned int*pi3,unsigned int*pi4)
75 return p_intf->p_sys->p_mi->requestVideo( p_vout, pi1, pi2, pi3, pi4 );
77 static void DoRelease( intf_thread_t *p_intf, void *p_win )
79 return p_intf->p_sys->p_mi->releaseVideo( p_win );
81 static int DoControl( intf_thread_t *p_intf, void *p_win, int i_q, va_list a )
83 return p_intf->p_sys->p_mi->controlVideo( p_win, i_q, a );
86 MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
88 /* Variables initialisation */
89 need_components_update = false;
90 bgWidget = NULL; videoWidget = NULL; playlistWidget = NULL;
91 embeddedPlaylistWasActive = videoIsActive = false;
95 * Configuration and settings
97 settings = new QSettings( "VideoLAN", "VLC" );
98 settings->beginGroup( "MainWindow" );
101 setFocusPolicy( Qt::StrongFocus );
102 setAcceptDrops(true);
103 setWindowIcon( QApplication::windowIcon() );
105 /* Set The Video In emebedded Mode or not */
106 videoEmbeddedFlag = false;
107 if( config_GetInt( p_intf, "embedded-video" ) )
108 videoEmbeddedFlag = true;
110 alwaysVideoFlag = false;
111 if( videoEmbeddedFlag && config_GetInt( p_intf, "qt-always-video" ) )
112 alwaysVideoFlag = true;
114 /* Set the other interface settings */
115 playlistEmbeddedFlag = settings->value("playlist-embedded", true).toBool();
116 visualSelectorEnabled= settings->value( "visual-selector", false ).toBool();
118 /**************************
119 * UI and Widgets design
120 **************************/
121 setVLCWindowsTitle();
122 handleMainUi( settings );
125 QVLCMenu::createMenuBar( this, p_intf, playlistEmbeddedFlag,
126 isAdvancedVisible(), visualSelectorEnabled );
130 * TODO: clicking on the elapsed time should switch to the remaining time
133 * TODO: do we add a label for the current Volume ?
135 timeLabel = new QLabel;
136 nameLabel = new QLabel;
137 speedLabel = new QLabel( "1.0x" );
138 timeLabel->setFrameStyle( QFrame::Sunken | QFrame::Panel );
139 speedLabel->setFrameStyle( QFrame::Sunken | QFrame::Panel );
140 statusBar()->addWidget( nameLabel, 8 );
141 statusBar()->addPermanentWidget( speedLabel, 0 );
142 statusBar()->addPermanentWidget( timeLabel, 2 );
143 speedLabel->setContextMenuPolicy ( Qt::CustomContextMenu );
144 timeLabel->setContextMenuPolicy ( Qt::CustomContextMenu );
145 CONNECT( speedLabel, customContextMenuRequested( QPoint ),
146 this, showSpeedMenu( QPoint ) );
147 CONNECT( timeLabel, customContextMenuRequested( QPoint ),
148 this, showTimeMenu( QPoint ) );
150 /**********************
151 * Systray Management *
152 **********************/
154 bool b_createSystray = false;
155 bool b_systrayAvailable = QSystemTrayIcon::isSystemTrayAvailable();
156 if( config_GetInt( p_intf, "qt-start-minimized") )
158 if( b_systrayAvailable ){
159 b_createSystray = true;
162 else msg_Warn( p_intf, "You can't minize if you haven't a system "
165 if( config_GetInt( p_intf, "qt-system-tray") )
166 b_createSystray = true;
168 if( b_systrayAvailable && b_createSystray )
171 /* Init input manager */
172 MainInputManager::getInstance( p_intf );
173 ON_TIMEOUT( updateOnTimer() );
179 /* Connect the input manager to the GUI elements it manages */
180 /* It is also connected to the control->slider, see the ControlsWidget */
181 CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
182 this, setDisplay( float, int, int ) );
184 /** Connects on nameChanged() */
185 /* Naming in the controller statusbar */
186 CONNECT( THEMIM->getIM(), nameChanged( QString ), this,
187 setName( QString ) );
188 /* and in the systray */
191 CONNECT( THEMIM->getIM(), nameChanged( QString ), this,
192 updateSystrayTooltipName( QString ) );
194 /* and in the title of the controller */
195 if( config_GetInt( p_intf, "qt-name-in-title" ) )
197 CONNECT( THEMIM->getIM(), nameChanged( QString ), this,
198 setVLCWindowsTitle( QString ) );
201 /** CONNECTS on PLAY_STATUS **/
202 /* Status on the main controller */
203 CONNECT( THEMIM->getIM(), statusChanged( int ), this, setStatus( int ) );
204 /* and in the systray */
207 CONNECT( THEMIM->getIM(), statusChanged( int ), this,
208 updateSystrayTooltipStatus( int ) );
214 var_Create( p_intf, "interaction", VLC_VAR_ADDRESS );
215 var_AddCallback( p_intf, "interaction", InteractCallback, this );
216 p_intf->b_interaction = VLC_TRUE;
218 /* Register callback for the intf-popupmenu variable */
219 playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
220 VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
221 if( p_playlist != NULL )
223 var_AddCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf );
224 var_AddCallback( p_playlist, "intf-show", IntfShowCB, p_intf );
225 vlc_object_release( p_playlist );
229 MainInterface::~MainInterface()
231 /* Unregister callback for the intf-popupmenu variable */
232 playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
233 VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
234 if( p_playlist != NULL )
236 var_DelCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf );
237 var_DelCallback( p_playlist, "intf-show", IntfShowCB, p_intf );
238 vlc_object_release( p_playlist );
241 settings->setValue( "playlist-embedded", playlistEmbeddedFlag );
242 settings->setValue( "adv-controls", isAdvancedVisible() );
243 settings->setValue( "pos", pos() );
244 settings->endGroup();
246 p_intf->b_interaction = VLC_FALSE;
247 var_DelCallback( p_intf, "interaction", InteractCallback, this );
249 p_intf->pf_request_window = NULL;
250 p_intf->pf_release_window = NULL;
251 p_intf->pf_control_window = NULL;
254 /*****************************
256 *****************************/
259 * Give the decorations of the Main Window a correct Name.
260 * If nothing is given, set it to VLC...
262 void MainInterface::setVLCWindowsTitle( QString aTitle )
264 if( aTitle.isEmpty() )
266 setWindowTitle( qtr( "VLC media player" ) );
270 setWindowTitle( aTitle + " - " + qtr( "VLC media player" ) );
274 void MainInterface::handleMainUi( QSettings *settings )
276 /* Create the main Widget and the mainLayout */
277 QWidget *main = new QWidget( this );
278 mainLayout = new QVBoxLayout( main );
279 setCentralWidget( main );
281 /* Margins, spacing */
282 main->setContentsMargins( 0, 0, 0, 0 );
283 mainLayout->setMargin( 0 );
285 /* Create the CONTROLS Widget */
286 controls = new ControlsWidget( p_intf,
287 settings->value( "adv-controls", false ).toBool() );
289 /* Configure the Controls */
290 BUTTON_SET_IMG( controls->playlistButton, "" , playlist_icon.png,
291 playlistEmbeddedFlag ? qtr( "Show playlist" ) :
292 qtr( "Open playlist" ) );
293 BUTTONACT( controls->playlistButton, togglePlaylist() );
295 /* Add the controls Widget to the main Widget */
296 mainLayout->addWidget( controls );
299 /* Set initial size */
300 resize( PREF_W, PREF_H );
301 addSize = QSize( mainLayout->margin() * 2, PREF_H );
304 visualSelector = new VisualSelector( p_intf );
305 mainLayout->insertWidget( 0, visualSelector );
306 visualSelector->hide();
308 /* And video Outputs */
309 if( alwaysVideoFlag )
311 bgWidget = new BackgroundWidget( p_intf );
312 bgWidget->widgetSize = settings->value( "backgroundSize",
313 QSize( 300, 300 ) ).toSize();
314 bgWidget->resize( bgWidget->widgetSize );
315 bgWidget->updateGeometry();
316 mainLayout->insertWidget( 0, bgWidget );
319 if( videoEmbeddedFlag )
321 videoWidget = new VideoWidget( p_intf );
322 videoWidget->widgetSize = QSize( 1, 1 );
323 //videoWidget->resize( videoWidget->widgetSize );
324 mainLayout->insertWidget( 0, videoWidget );
326 p_intf->pf_request_window = ::DoRequest;
327 p_intf->pf_release_window = ::DoRelease;
328 p_intf->pf_control_window = ::DoControl;
331 /* Finish the sizing */
332 setMinimumSize( PREF_W, addSize.height() );
335 /**********************************************************************
336 * Handling of sizing of the components
337 **********************************************************************/
338 void MainInterface::calculateInterfaceSize()
340 int width = 0, height = 0;
341 if( VISIBLE( bgWidget ) )
343 width = bgWidget->widgetSize.width();
344 height = bgWidget->widgetSize.height();
345 assert( !(playlistWidget && playlistWidget->isVisible() ) );
347 else if( VISIBLE( playlistWidget ) )
349 width = playlistWidget->widgetSize.width();
350 height = playlistWidget->widgetSize.height();
352 else if( videoIsActive )
354 width = videoWidget->widgetSize.width() ;
355 height = videoWidget->widgetSize.height();
359 width = PREF_W - addSize.width();
360 height = PREF_H - addSize.height();
362 if( VISIBLE( visualSelector ) )
363 height += visualSelector->height();
364 /* if( VISIBLE( advControls) )
366 height += advControls->sizeHint().height();
368 mainSize = QSize( width + addSize.width(), height + addSize.height() );
371 void MainInterface::resizeEvent( QResizeEvent *e )
373 videoWidget->widgetSize.setWidth( e->size().width() - addSize.width() );
374 if( videoWidget && videoIsActive && videoWidget->widgetSize.height() > 1 )
376 SET_WH( videoWidget, e->size().width() - addSize.width(),
377 e->size().height() - addSize.height() );
378 videoWidget->updateGeometry();
380 if( VISIBLE( playlistWidget ) )
382 SET_WH( playlistWidget , e->size().width() - addSize.width(),
383 e->size().height() - addSize.height() );
384 playlistWidget->updateGeometry();
388 /****************************************************************************
389 * Small right-click menus
390 ****************************************************************************/
391 void MainInterface::showSpeedMenu( QPoint pos )
394 menu.addAction( "Not Implemented Yet" );
395 menu.exec( QCursor::pos() );
398 void MainInterface::showTimeMenu( QPoint pos )
401 menu.addAction( "Not Implemented Yet" );
402 menu.exec( QCursor::pos() );
405 /****************************************************************************
407 ****************************************************************************/
408 void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x,
409 int *pi_y, unsigned int *pi_width,
410 unsigned int *pi_height )
412 void *ret = videoWidget->request( p_nvout,pi_x, pi_y, pi_width, pi_height );
415 videoIsActive = true;
416 if( VISIBLE( playlistWidget ) )
418 embeddedPlaylistWasActive = true;
419 // playlistWidget->hide();
421 bool bgWasVisible = false;
422 if( VISIBLE( bgWidget) )
427 if( THEMIM->getIM()->hasVideo() || !bgWasVisible )
429 videoWidget->widgetSize = QSize( *pi_width, *pi_height );
431 else /* Background widget available, use its size */
433 /* Ok, our visualizations are bad, so don't do this for the moment
434 * use the requested size anyway */
435 // videoWidget->widgetSize = bgWidget->widgeTSize;
436 videoWidget->widgetSize = QSize( *pi_width, *pi_height );
438 // videoWidget->updateGeometry(); /// FIXME: Needed ?
439 need_components_update = true;
444 void MainInterface::releaseVideo( void *p_win )
446 videoWidget->release( p_win );
447 videoWidget->widgetSize = QSize( 0, 0 );
448 videoWidget->resize( videoWidget->widgetSize );
450 if( embeddedPlaylistWasActive )
451 playlistWidget->show();
455 videoIsActive = false;
456 need_components_update = true;
459 class SetVideoOnTopQtEvent : public QEvent
462 SetVideoOnTopQtEvent( bool _onTop ) :
463 QEvent( (QEvent::Type)SetVideoOnTopEvent_Type ), onTop( _onTop)
476 int MainInterface::controlVideo( void *p_window, int i_query, va_list args )
478 int i_ret = VLC_EGENERIC;
483 unsigned int *pi_width = va_arg( args, unsigned int * );
484 unsigned int *pi_height = va_arg( args, unsigned int * );
485 *pi_width = videoWidget->widgetSize.width();
486 *pi_height = videoWidget->widgetSize.height();
492 unsigned int i_width = va_arg( args, unsigned int );
493 unsigned int i_height = va_arg( args, unsigned int );
494 videoWidget->widgetSize = QSize( i_width, i_height );
495 // videoWidget->updateGeometry();
496 need_components_update = true;
500 case VOUT_SET_STAY_ON_TOP:
502 int i_arg = va_arg( args, int );
503 QApplication::postEvent( this, new SetVideoOnTopQtEvent( i_arg ) );
508 msg_Warn( p_intf, "unsupported control query" );
514 /*****************************************************************************
515 * Playlist, Visualisation and Menus handling
516 *****************************************************************************/
518 * Toggle the playlist widget or dialog
520 void MainInterface::togglePlaylist()
522 // Toggle the playlist dialog if not embedded and return
523 if( !playlistEmbeddedFlag )
529 THEDP->playlistDialog();
533 // Create the playlist Widget and destroy the existing dialog
534 if( !playlistWidget )
536 PlaylistDialog::killInstance();
537 playlistWidget = new PlaylistWidget( p_intf );
538 mainLayout->insertWidget( 0, playlistWidget );
539 playlistWidget->widgetSize = settings->value( "playlistSize",
540 QSize( 650, 310 ) ).toSize();
541 playlistWidget->hide();
543 CONNECT( playlistWidget, artSet( QString ), bgWidget, setArt(QString) );
546 // And toggle visibility
547 if( VISIBLE( playlistWidget ) )
549 playlistWidget->hide();
550 if( bgWidget ) bgWidget->show();
553 videoWidget->widgetSize = savedVideoSize;
554 videoWidget->resize( videoWidget->widgetSize );
555 videoWidget->updateGeometry();
556 if( bgWidget ) bgWidget->hide();
561 playlistWidget->show();
564 savedVideoSize = videoWidget->widgetSize;
565 videoWidget->widgetSize.setHeight( 0 );
566 videoWidget->resize( videoWidget->widgetSize );
567 videoWidget->updateGeometry();
569 if( VISIBLE( bgWidget ) ) bgWidget->hide();
572 doComponentsUpdate();
575 void MainInterface::undockPlaylist()
579 playlistWidget->hide();
580 playlistWidget->deleteLater();
581 mainLayout->removeWidget( playlistWidget );
582 playlistWidget = NULL;
583 playlistEmbeddedFlag = false;
586 QVLCMenu::createMenuBar( this, p_intf, false, isAdvancedVisible(),
587 visualSelectorEnabled);
591 videoWidget->widgetSize = savedVideoSize;
592 videoWidget->resize( videoWidget->widgetSize );
593 videoWidget->updateGeometry();
596 doComponentsUpdate();
597 THEDP->playlistDialog();
602 void MainInterface::visual()
604 if( !VISIBLE( visualSelector) )
606 visualSelector->show();
607 if( !THEMIM->getIM()->hasVideo() )
609 /* Show the background widget */
611 visualSelectorEnabled = true;
615 /* Stop any currently running visualization */
616 visualSelector->hide();
617 visualSelectorEnabled = false;
619 doComponentsUpdate();
623 void MainInterface::toggleMenus()
625 if( menuBar()->isVisible() ) menuBar()->hide();
626 else menuBar()->show();
627 msg_Dbg( p_intf, "I was there: \\_o<~~ coin coin" );
630 /* Video widget cannot do this synchronously as it runs in another thread */
631 /* Well, could it, actually ? Probably dangerous ... */
632 void MainInterface::doComponentsUpdate()
634 calculateInterfaceSize();
638 void MainInterface::toggleAdvanced()
640 controls->toggleAdvanced();
643 bool MainInterface::isAdvancedVisible()
645 return controls->b_advancedVisible;
648 /************************************************************************
650 ************************************************************************/
651 void MainInterface::setDisplay( float pos, int time, int length )
653 char psz_length[MSTRTIME_MAX_SIZE], psz_time[MSTRTIME_MAX_SIZE];
654 secstotimestr( psz_length, length );
655 secstotimestr( psz_time, time );
657 title.sprintf( "%s/%s", psz_time, psz_length );
658 timeLabel->setText( " "+title+" " );
661 void MainInterface::setName( QString name )
664 nameLabel->setText( " " + name+" " );
667 void MainInterface::setStatus( int status )
669 controls->setStatus( status );
671 updateSystrayMenu( status );
674 void MainInterface::updateOnTimer()
676 /* \todo Make this event-driven */
677 if( intf_ShouldDie( p_intf ) )
679 QApplication::closeAllWindows();
680 QApplication::quit();
682 if( need_components_update )
684 doComponentsUpdate();
685 need_components_update = false;
688 controls->updateOnTimer();
691 /*****************************************************************************
692 * Systray Icon and Systray Menu
693 *****************************************************************************/
696 * Create a SystemTray icon and a menu that would go with it.
697 * Connects to a click handler on the icon.
699 void MainInterface::createSystray()
701 QIcon iconVLC = QIcon( QPixmap( ":/vlc128.png" ) );
702 sysTray = new QSystemTrayIcon( iconVLC, this );
703 sysTray->setToolTip( qtr( "VLC media player" ));
705 systrayMenu = new QMenu( qtr( "VLC media player" ), this );
706 systrayMenu->setIcon( iconVLC );
708 QVLCMenu::updateSystrayMenu( this, p_intf, true );
711 CONNECT( sysTray, activated( QSystemTrayIcon::ActivationReason ),
712 this, handleSystrayClick( QSystemTrayIcon::ActivationReason ) );
716 * Update the menu of the Systray Icon.
717 * May be unneedded, since it just calls QVLCMenu::update
720 void MainInterface::updateSystrayMenu( int status )
722 QVLCMenu::updateSystrayMenu( this, p_intf ) ;
726 * Updates the Systray Icon's menu and toggle the main interface
728 void MainInterface::toggleUpdateSystrayMenu()
738 /* check if any visible window is above vlc in the z-order,
739 * but ignore the ones always on top */
742 wi.cbSize = sizeof( WINDOWINFO );
743 for( hwnd = GetNextWindow( internalWinId(), GW_HWNDPREV );
744 hwnd && !IsWindowVisible( hwnd );
745 hwnd = GetNextWindow( hwnd, GW_HWNDPREV ) );
746 if( !hwnd || !GetWindowInfo( hwnd, &wi ) ||
747 (wi.dwExStyle&WS_EX_TOPMOST) )
749 if( isActiveWindow() )
759 QVLCMenu::updateSystrayMenu( this, p_intf );
762 void MainInterface::handleSystrayClick(
763 QSystemTrayIcon::ActivationReason reason )
767 case QSystemTrayIcon::Trigger:
768 toggleUpdateSystrayMenu();
770 case QSystemTrayIcon::MiddleClick:
771 sysTray->showMessage( qtr( "VLC media player" ),
772 qtr( "Control menu for the player" ),
773 QSystemTrayIcon::Information, 4000 );
779 * Updates the name of the systray Icon tooltip.
780 * Doesn't check if the systray exists, check before you call it.
781 * FIXME !!! Fusion with next function ?
783 void MainInterface::updateSystrayTooltipName( QString name )
787 sysTray->setToolTip( qtr( "VLC media player" ) );
791 sysTray->setToolTip( name );
792 sysTray->showMessage( qtr( "VLC media player" ), name,
793 QSystemTrayIcon::NoIcon, 4000 );
798 * Updates the status of the systray Icon tooltip.
799 * Doesn't check if the systray exists, check before you call it.
801 void MainInterface::updateSystrayTooltipStatus( int i_status )
807 sysTray->setToolTip( qtr( "VLC media player" ) );
812 sysTray->setToolTip( input_name );
813 //+ " - " + qtr( "Playing" ) );
818 sysTray->setToolTip( input_name + " - "
825 /************************************************************************
827 ************************************************************************/
828 void MainInterface::dropEvent(QDropEvent *event)
830 const QMimeData *mimeData = event->mimeData();
832 /* D&D of a subtitles file, add it on the fly */
833 if( mimeData->urls().size() == 1 )
835 if( THEMIM->getIM()->hasInput() )
837 if( input_AddSubtitles( THEMIM->getInput(),
838 qtu( mimeData->urls()[0].toString() ),
841 event->acceptProposedAction();
847 foreach( QUrl url, mimeData->urls() ) {
848 QString s = url.toString();
849 if( s.length() > 0 ) {
850 playlist_Add( THEPL, qtu(s), NULL,
851 PLAYLIST_APPEND | (first ? PLAYLIST_GO:0),
852 PLAYLIST_END, VLC_TRUE, VLC_FALSE );
856 event->acceptProposedAction();
858 void MainInterface::dragEnterEvent(QDragEnterEvent *event)
860 event->acceptProposedAction();
862 void MainInterface::dragMoveEvent(QDragMoveEvent *event)
864 event->acceptProposedAction();
866 void MainInterface::dragLeaveEvent(QDragLeaveEvent *event)
871 /************************************************************************
873 ************************************************************************/
874 void MainInterface::customEvent( QEvent *event )
876 if( event->type() == PLDockEvent_Type )
878 PlaylistDialog::killInstance();
879 playlistEmbeddedFlag = true;
881 QVLCMenu::createMenuBar(this, p_intf, true, isAdvancedVisible(),
882 visualSelectorEnabled);
885 else if ( event->type() == SetVideoOnTopEvent_Type )
887 SetVideoOnTopQtEvent* p_event = (SetVideoOnTopQtEvent*)event;
888 if( p_event->OnTop() )
889 setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
891 setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint);
892 show(); /* necessary to apply window flags?? */
896 void MainInterface::keyPressEvent( QKeyEvent *e )
898 int i_vlck = qtEventToVLCKey( e );
901 var_SetInteger( p_intf->p_libvlc, "key-pressed", i_vlck );
908 void MainInterface::wheelEvent( QWheelEvent *e )
910 int i_vlckey = qtWheelEventToVLCKey( e );
911 var_SetInteger( p_intf->p_libvlc, "key-pressed", i_vlckey );
915 void MainInterface::closeEvent( QCloseEvent *e )
918 vlc_object_kill( p_intf );
921 /*****************************************************************************
923 *****************************************************************************/
924 static int InteractCallback( vlc_object_t *p_this,
925 const char *psz_var, vlc_value_t old_val,
926 vlc_value_t new_val, void *param )
928 intf_dialog_args_t *p_arg = new intf_dialog_args_t;
929 p_arg->p_dialog = (interaction_dialog_t *)(new_val.p_address);
930 DialogEvent *event = new DialogEvent( INTF_DIALOG_INTERACTION, 0, p_arg );
931 QApplication::postEvent( THEDP, static_cast<QEvent*>(event) );
935 /*****************************************************************************
936 * PopupMenuCB: callback triggered by the intf-popupmenu playlist variable.
937 * We don't show the menu directly here because we don't want the
938 * caller to block for a too long time.
939 *****************************************************************************/
940 static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
941 vlc_value_t old_val, vlc_value_t new_val, void *param )
943 intf_thread_t *p_intf = (intf_thread_t *)param;
945 if( p_intf->pf_show_dialog )
947 p_intf->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU,
954 /*****************************************************************************
955 * IntfShowCB: callback triggered by the intf-show playlist variable.
956 *****************************************************************************/
957 static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
958 vlc_value_t old_val, vlc_value_t new_val, void *param )
960 intf_thread_t *p_intf = (intf_thread_t *)param;
961 //p_intf->p_sys->b_intf_show = VLC_TRUE;