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() );
104 setWindowOpacity( config_GetFloat( p_intf, "qt-opacity" ) );
106 /* Set The Video In emebedded Mode or not */
107 videoEmbeddedFlag = false;
108 if( config_GetInt( p_intf, "embedded-video" ) )
109 videoEmbeddedFlag = true;
111 alwaysVideoFlag = false;
112 if( videoEmbeddedFlag && config_GetInt( p_intf, "qt-always-video" ) )
113 alwaysVideoFlag = true;
115 /* Set the other interface settings */
116 playlistEmbeddedFlag = settings->value( "playlist-embedded", true).toBool();
117 visualSelectorEnabled = settings->value( "visual-selector", false ).toBool();
118 notificationEnabled = config_GetInt( p_intf, "qt-notification" )
120 /**************************
121 * UI and Widgets design
122 **************************/
123 setVLCWindowsTitle();
124 handleMainUi( settings );
127 QVLCMenu::createMenuBar( this, p_intf, playlistEmbeddedFlag,
128 isAdvancedVisible(), visualSelectorEnabled );
132 * TODO: clicking on the elapsed time should switch to the remaining time
135 * TODO: do we add a label for the current Volume ?
137 b_remainingTime = false;
138 timeLabel = new QLabel;
139 nameLabel = new QLabel;
140 speedLabel = new QLabel( "1.0x" );
141 timeLabel->setFrameStyle( QFrame::Sunken | QFrame::Panel );
142 speedLabel->setFrameStyle( QFrame::Sunken | QFrame::Panel );
143 statusBar()->addWidget( nameLabel, 8 );
144 statusBar()->addPermanentWidget( speedLabel, 0 );
145 statusBar()->addPermanentWidget( timeLabel, 2 );
146 speedLabel->setContextMenuPolicy ( Qt::CustomContextMenu );
147 timeLabel->setContextMenuPolicy ( Qt::CustomContextMenu );
148 timeLabel->installEventFilter( this );
149 CONNECT( speedLabel, customContextMenuRequested( QPoint ),
150 this, showSpeedMenu( QPoint ) );
151 CONNECT( timeLabel, customContextMenuRequested( QPoint ),
152 this, showTimeMenu( QPoint ) );
154 /**********************
155 * Systray Management *
156 **********************/
158 bool b_createSystray = false;
159 bool b_systrayAvailable = QSystemTrayIcon::isSystemTrayAvailable();
160 if( config_GetInt( p_intf, "qt-start-minimized") )
162 if( b_systrayAvailable ){
163 b_createSystray = true;
166 else msg_Warn( p_intf, "You can't minize if you haven't a system "
169 if( config_GetInt( p_intf, "qt-system-tray") )
170 b_createSystray = true;
172 if( b_systrayAvailable && b_createSystray )
175 /* Init input manager */
176 MainInputManager::getInstance( p_intf );
177 ON_TIMEOUT( updateOnTimer() );
183 /* Connect the input manager to the GUI elements it manages */
184 /* It is also connected to the control->slider, see the ControlsWidget */
185 CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
186 this, setDisplay( float, int, int ) );
188 /** Connects on nameChanged() */
189 /* Naming in the controller statusbar */
190 CONNECT( THEMIM->getIM(), nameChanged( QString ), this,
191 setName( QString ) );
192 /* and in the systray */
195 CONNECT( THEMIM->getIM(), nameChanged( QString ), this,
196 updateSystrayTooltipName( QString ) );
198 /* and in the title of the controller */
199 if( config_GetInt( p_intf, "qt-name-in-title" ) )
201 CONNECT( THEMIM->getIM(), nameChanged( QString ), this,
202 setVLCWindowsTitle( QString ) );
205 /** CONNECTS on PLAY_STATUS **/
206 /* Status on the main controller */
207 CONNECT( THEMIM->getIM(), statusChanged( int ), this, setStatus( int ) );
208 /* and in the systray */
211 CONNECT( THEMIM->getIM(), statusChanged( int ), this,
212 updateSystrayTooltipStatus( int ) );
218 var_Create( p_intf, "interaction", VLC_VAR_ADDRESS );
219 var_AddCallback( p_intf, "interaction", InteractCallback, this );
220 p_intf->b_interaction = VLC_TRUE;
222 /* Register callback for the intf-popupmenu variable */
223 playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
224 VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
225 if( p_playlist != NULL )
227 var_AddCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf );
228 var_AddCallback( p_playlist, "intf-show", IntfShowCB, p_intf );
229 vlc_object_release( p_playlist );
233 MainInterface::~MainInterface()
235 /* Unregister callback for the intf-popupmenu variable */
236 playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
237 VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
238 if( p_playlist != NULL )
240 var_DelCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf );
241 var_DelCallback( p_playlist, "intf-show", IntfShowCB, p_intf );
242 vlc_object_release( p_playlist );
245 settings->setValue( "playlist-embedded", playlistEmbeddedFlag );
246 settings->setValue( "adv-controls", isAdvancedVisible() );
247 settings->setValue( "pos", pos() );
248 settings->endGroup();
250 p_intf->b_interaction = VLC_FALSE;
251 var_DelCallback( p_intf, "interaction", InteractCallback, this );
253 p_intf->pf_request_window = NULL;
254 p_intf->pf_release_window = NULL;
255 p_intf->pf_control_window = NULL;
258 /*****************************
260 *****************************/
263 * Give the decorations of the Main Window a correct Name.
264 * If nothing is given, set it to VLC...
266 void MainInterface::setVLCWindowsTitle( QString aTitle )
268 if( aTitle.isEmpty() )
270 setWindowTitle( qtr( "VLC media player" ) );
274 setWindowTitle( aTitle + " - " + qtr( "VLC media player" ) );
279 void MainInterface::handleMainUi( QSettings *settings )
281 /* Create the main Widget and the mainLayout */
282 QWidget *main = new QWidget( this );
283 mainLayout = new QVBoxLayout( main );
284 setCentralWidget( main );
286 /* Margins, spacing */
287 main->setContentsMargins( 0, 0, 0, 0 );
288 mainLayout->setMargin( 0 );
290 /* Create the CONTROLS Widget */
291 controls = new ControlsWidget( p_intf,
292 settings->value( "adv-controls", false ).toBool() );
294 /* Configure the Controls */
295 BUTTON_SET_IMG( controls->playlistButton, "" , playlist_icon.png,
296 playlistEmbeddedFlag ? qtr( "Show playlist" ) :
297 qtr( "Open playlist" ) );
298 BUTTONACT( controls->playlistButton, togglePlaylist() );
300 /* Add the controls Widget to the main Widget */
301 mainLayout->addWidget( controls );
304 /* Set initial size */
305 resize( PREF_W, PREF_H );
306 addSize = QSize( mainLayout->margin() * 2, PREF_H );
309 visualSelector = new VisualSelector( p_intf );
310 mainLayout->insertWidget( 0, visualSelector );
311 visualSelector->hide();
313 /* And video Outputs */
314 if( alwaysVideoFlag )
316 bgWidget = new BackgroundWidget( p_intf );
317 bgWidget->widgetSize = settings->value( "backgroundSize",
318 QSize( 300, 300 ) ).toSize();
319 bgWidget->resize( bgWidget->widgetSize );
320 bgWidget->updateGeometry();
321 mainLayout->insertWidget( 0, bgWidget );
324 if( videoEmbeddedFlag )
326 videoWidget = new VideoWidget( p_intf );
327 videoWidget->widgetSize = QSize( 1, 1 );
328 //videoWidget->resize( videoWidget->widgetSize );
329 mainLayout->insertWidget( 0, videoWidget );
331 p_intf->pf_request_window = ::DoRequest;
332 p_intf->pf_release_window = ::DoRelease;
333 p_intf->pf_control_window = ::DoControl;
336 /* Finish the sizing */
337 setMinimumSize( PREF_W, addSize.height() );
340 /**********************************************************************
341 * Handling of sizing of the components
342 **********************************************************************/
343 void MainInterface::calculateInterfaceSize()
345 int width = 0, height = 0;
346 if( VISIBLE( bgWidget ) )
348 width = bgWidget->widgetSize.width();
349 height = bgWidget->widgetSize.height();
350 assert( !(playlistWidget && playlistWidget->isVisible() ) );
352 else if( VISIBLE( playlistWidget ) )
354 width = playlistWidget->widgetSize.width();
355 height = playlistWidget->widgetSize.height();
357 else if( videoIsActive )
359 width = videoWidget->widgetSize.width() ;
360 height = videoWidget->widgetSize.height();
364 width = PREF_W - addSize.width();
365 height = PREF_H - addSize.height();
367 if( VISIBLE( visualSelector ) )
368 height += visualSelector->height();
369 /* if( VISIBLE( advControls) )
371 height += advControls->sizeHint().height();
373 mainSize = QSize( width + addSize.width(), height + addSize.height() );
376 void MainInterface::resizeEvent( QResizeEvent *e )
378 videoWidget->widgetSize.setWidth( e->size().width() - addSize.width() );
379 if( videoWidget && videoIsActive && videoWidget->widgetSize.height() > 1 )
381 SET_WH( videoWidget, e->size().width() - addSize.width(),
382 e->size().height() - addSize.height() );
383 videoWidget->updateGeometry();
385 if( VISIBLE( playlistWidget ) )
387 SET_WH( playlistWidget , e->size().width() - addSize.width(),
388 e->size().height() - addSize.height() );
389 playlistWidget->updateGeometry();
393 /****************************************************************************
394 * Small right-click menus
395 ****************************************************************************/
396 void MainInterface::showSpeedMenu( QPoint pos )
399 menu.addAction( "Not Implemented Yet" );
400 menu.exec( QCursor::pos() );
403 void MainInterface::showTimeMenu( QPoint pos )
406 menu.addAction( qtr("Elapsed Time") , this, SLOT( setElapsedTime() ) );
407 menu.addAction( qtr("Remaining Time") , this, SLOT( setRemainTime() ) );
408 menu.exec( QCursor::pos() );
411 /****************************************************************************
413 ****************************************************************************/
414 void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x,
415 int *pi_y, unsigned int *pi_width,
416 unsigned int *pi_height )
418 void *ret = videoWidget->request( p_nvout,pi_x, pi_y, pi_width, pi_height );
421 videoIsActive = true;
422 if( VISIBLE( playlistWidget ) )
424 embeddedPlaylistWasActive = true;
425 // playlistWidget->hide();
427 bool bgWasVisible = false;
428 if( VISIBLE( bgWidget) )
433 if( THEMIM->getIM()->hasVideo() || !bgWasVisible )
435 videoWidget->widgetSize = QSize( *pi_width, *pi_height );
437 else /* Background widget available, use its size */
439 /* Ok, our visualizations are bad, so don't do this for the moment
440 * use the requested size anyway */
441 // videoWidget->widgetSize = bgWidget->widgeTSize;
442 videoWidget->widgetSize = QSize( *pi_width, *pi_height );
444 // videoWidget->updateGeometry(); /// FIXME: Needed ?
445 need_components_update = true;
450 void MainInterface::releaseVideo( void *p_win )
452 videoWidget->release( p_win );
453 videoWidget->widgetSize = QSize( 0, 0 );
454 videoWidget->resize( videoWidget->widgetSize );
456 if( embeddedPlaylistWasActive )
457 playlistWidget->show();
461 videoIsActive = false;
462 need_components_update = true;
465 class SetVideoOnTopQtEvent : public QEvent
468 SetVideoOnTopQtEvent( bool _onTop ) :
469 QEvent( (QEvent::Type)SetVideoOnTopEvent_Type ), onTop( _onTop)
482 int MainInterface::controlVideo( void *p_window, int i_query, va_list args )
484 int i_ret = VLC_EGENERIC;
489 unsigned int *pi_width = va_arg( args, unsigned int * );
490 unsigned int *pi_height = va_arg( args, unsigned int * );
491 *pi_width = videoWidget->widgetSize.width();
492 *pi_height = videoWidget->widgetSize.height();
498 unsigned int i_width = va_arg( args, unsigned int );
499 unsigned int i_height = va_arg( args, unsigned int );
500 videoWidget->widgetSize = QSize( i_width, i_height );
501 // videoWidget->updateGeometry();
502 need_components_update = true;
506 case VOUT_SET_STAY_ON_TOP:
508 int i_arg = va_arg( args, int );
509 QApplication::postEvent( this, new SetVideoOnTopQtEvent( i_arg ) );
514 msg_Warn( p_intf, "unsupported control query" );
520 /*****************************************************************************
521 * Playlist, Visualisation and Menus handling
522 *****************************************************************************/
524 * Toggle the playlist widget or dialog
526 void MainInterface::togglePlaylist()
528 // Toggle the playlist dialog if not embedded and return
529 if( !playlistEmbeddedFlag )
535 THEDP->playlistDialog();
539 // Create the playlist Widget and destroy the existing dialog
540 if( !playlistWidget )
542 PlaylistDialog::killInstance();
543 playlistWidget = new PlaylistWidget( p_intf );
544 mainLayout->insertWidget( 0, playlistWidget );
545 playlistWidget->widgetSize = settings->value( "playlistSize",
546 QSize( 650, 310 ) ).toSize();
547 playlistWidget->hide();
549 CONNECT( playlistWidget, artSet( QString ), bgWidget, setArt(QString) );
552 // And toggle visibility
553 if( VISIBLE( playlistWidget ) )
555 playlistWidget->hide();
556 if( bgWidget ) bgWidget->show();
559 videoWidget->widgetSize = savedVideoSize;
560 videoWidget->resize( videoWidget->widgetSize );
561 videoWidget->updateGeometry();
562 if( bgWidget ) bgWidget->hide();
567 playlistWidget->show();
570 savedVideoSize = videoWidget->widgetSize;
571 videoWidget->widgetSize.setHeight( 0 );
572 videoWidget->resize( videoWidget->widgetSize );
573 videoWidget->updateGeometry();
575 if( VISIBLE( bgWidget ) ) bgWidget->hide();
578 doComponentsUpdate();
581 void MainInterface::undockPlaylist()
585 playlistWidget->hide();
586 playlistWidget->deleteLater();
587 mainLayout->removeWidget( playlistWidget );
588 playlistWidget = NULL;
589 playlistEmbeddedFlag = false;
592 QVLCMenu::createMenuBar( this, p_intf, false, isAdvancedVisible(),
593 visualSelectorEnabled);
597 videoWidget->widgetSize = savedVideoSize;
598 videoWidget->resize( videoWidget->widgetSize );
599 videoWidget->updateGeometry();
602 doComponentsUpdate();
603 THEDP->playlistDialog();
608 void MainInterface::visual()
610 if( !VISIBLE( visualSelector) )
612 visualSelector->show();
613 if( !THEMIM->getIM()->hasVideo() )
615 /* Show the background widget */
617 visualSelectorEnabled = true;
621 /* Stop any currently running visualization */
622 visualSelector->hide();
623 visualSelectorEnabled = false;
625 doComponentsUpdate();
629 void MainInterface::toggleMenus()
631 msg_Dbg( p_intf, "I HAS HERE, HIDING YOUR MENUZ: \\_o<~~ coin coin" );
633 TOGGLEV( statusBar() );
637 /* Video widget cannot do this synchronously as it runs in another thread */
638 /* Well, could it, actually ? Probably dangerous ... */
639 void MainInterface::doComponentsUpdate()
641 calculateInterfaceSize();
645 void MainInterface::toggleAdvanced()
647 controls->toggleAdvanced();
650 bool MainInterface::isAdvancedVisible()
652 return controls->b_advancedVisible;
655 /************************************************************************
657 ************************************************************************/
658 void MainInterface::setDisplay( float pos, int time, int length )
660 char psz_length[MSTRTIME_MAX_SIZE], psz_time[MSTRTIME_MAX_SIZE];
661 secstotimestr( psz_length, length );
662 secstotimestr( psz_time, b_remainingTime ? length - time : time );
663 QString title; title.sprintf( "%s/%s", psz_time, psz_length );
664 if( b_remainingTime ) timeLabel->setText( " -"+title+" " );
665 else timeLabel->setText( " "+title+" " );
668 void MainInterface::toggleTimeDisplay()
670 b_remainingTime = ( b_remainingTime ? false : true );
673 void MainInterface::setElapsedTime(){ b_remainingTime = false; }
674 void MainInterface::setRemainTime(){ b_remainingTime = true; }
676 void MainInterface::setName( QString name )
679 nameLabel->setText( " " + name+" " );
682 void MainInterface::setStatus( int status )
684 controls->setStatus( status );
686 updateSystrayMenu( status );
689 void MainInterface::updateOnTimer()
691 /* \todo Make this event-driven */
692 if( intf_ShouldDie( p_intf ) )
694 QApplication::closeAllWindows();
695 QApplication::quit();
697 if( need_components_update )
699 doComponentsUpdate();
700 need_components_update = false;
703 controls->updateOnTimer();
706 /*****************************************************************************
707 * Systray Icon and Systray Menu
708 *****************************************************************************/
711 * Create a SystemTray icon and a menu that would go with it.
712 * Connects to a click handler on the icon.
714 void MainInterface::createSystray()
716 QIcon iconVLC = QIcon( QPixmap( ":/vlc128.png" ) );
717 sysTray = new QSystemTrayIcon( iconVLC, this );
718 sysTray->setToolTip( qtr( "VLC media player" ));
720 systrayMenu = new QMenu( qtr( "VLC media player" ), this );
721 systrayMenu->setIcon( iconVLC );
723 QVLCMenu::updateSystrayMenu( this, p_intf, true );
726 CONNECT( sysTray, activated( QSystemTrayIcon::ActivationReason ),
727 this, handleSystrayClick( QSystemTrayIcon::ActivationReason ) );
731 * Update the menu of the Systray Icon.
732 * May be unneedded, since it just calls QVLCMenu::update
735 void MainInterface::updateSystrayMenu( int status )
737 QVLCMenu::updateSystrayMenu( this, p_intf ) ;
741 * Updates the Systray Icon's menu and toggle the main interface
743 void MainInterface::toggleUpdateSystrayMenu()
753 /* check if any visible window is above vlc in the z-order,
754 * but ignore the ones always on top */
757 wi.cbSize = sizeof( WINDOWINFO );
758 for( hwnd = GetNextWindow( internalWinId(), GW_HWNDPREV );
759 hwnd && !IsWindowVisible( hwnd );
760 hwnd = GetNextWindow( hwnd, GW_HWNDPREV ) );
761 if( !hwnd || !GetWindowInfo( hwnd, &wi ) ||
762 (wi.dwExStyle&WS_EX_TOPMOST) )
764 if( isActiveWindow() )
774 QVLCMenu::updateSystrayMenu( this, p_intf );
777 void MainInterface::handleSystrayClick(
778 QSystemTrayIcon::ActivationReason reason )
782 case QSystemTrayIcon::Trigger:
783 toggleUpdateSystrayMenu();
785 case QSystemTrayIcon::MiddleClick:
786 sysTray->showMessage( qtr( "VLC media player" ),
787 qtr( "Control menu for the player" ),
788 QSystemTrayIcon::Information, 4000 );
794 * Updates the name of the systray Icon tooltip.
795 * Doesn't check if the systray exists, check before you call it.
796 * FIXME !!! Fusion with next function ?
798 void MainInterface::updateSystrayTooltipName( QString name )
802 sysTray->setToolTip( qtr( "VLC media player" ) );
806 sysTray->setToolTip( name );
807 if( notificationEnabled )
809 sysTray->showMessage( qtr( "VLC media player" ), name,
810 QSystemTrayIcon::NoIcon, 4000 );
816 * Updates the status of the systray Icon tooltip.
817 * Doesn't check if the systray exists, check before you call it.
819 void MainInterface::updateSystrayTooltipStatus( int i_status )
825 sysTray->setToolTip( qtr( "VLC media player" ) );
830 sysTray->setToolTip( input_name );
831 //+ " - " + qtr( "Playing" ) );
836 sysTray->setToolTip( input_name + " - "
843 /************************************************************************
845 ************************************************************************/
846 void MainInterface::dropEvent(QDropEvent *event)
848 const QMimeData *mimeData = event->mimeData();
850 /* D&D of a subtitles file, add it on the fly */
851 if( mimeData->urls().size() == 1 )
853 if( THEMIM->getIM()->hasInput() )
855 if( input_AddSubtitles( THEMIM->getInput(),
856 qtu( mimeData->urls()[0].toString() ),
859 event->acceptProposedAction();
865 foreach( QUrl url, mimeData->urls() ) {
866 QString s = url.toString();
867 if( s.length() > 0 ) {
868 playlist_Add( THEPL, qtu(s), NULL,
869 PLAYLIST_APPEND | (first ? PLAYLIST_GO:0),
870 PLAYLIST_END, VLC_TRUE, VLC_FALSE );
874 event->acceptProposedAction();
876 void MainInterface::dragEnterEvent(QDragEnterEvent *event)
878 event->acceptProposedAction();
880 void MainInterface::dragMoveEvent(QDragMoveEvent *event)
882 event->acceptProposedAction();
884 void MainInterface::dragLeaveEvent(QDragLeaveEvent *event)
889 /************************************************************************
891 ************************************************************************/
892 void MainInterface::customEvent( QEvent *event )
894 if( event->type() == PLDockEvent_Type )
896 PlaylistDialog::killInstance();
897 playlistEmbeddedFlag = true;
899 QVLCMenu::createMenuBar(this, p_intf, true, isAdvancedVisible(),
900 visualSelectorEnabled);
903 else if ( event->type() == SetVideoOnTopEvent_Type )
905 SetVideoOnTopQtEvent* p_event = (SetVideoOnTopQtEvent*)event;
906 if( p_event->OnTop() )
907 setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
909 setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint);
910 show(); /* necessary to apply window flags?? */
914 bool MainInterface::eventFilter(QObject *obj, QEvent *event)
916 if( (obj == timeLabel) && (event->type() == QEvent::MouseButtonPress) ) toggleTimeDisplay();
920 void MainInterface::keyPressEvent( QKeyEvent *e )
922 int i_vlck = qtEventToVLCKey( e );
925 var_SetInteger( p_intf->p_libvlc, "key-pressed", i_vlck );
932 void MainInterface::wheelEvent( QWheelEvent *e )
934 int i_vlckey = qtWheelEventToVLCKey( e );
935 var_SetInteger( p_intf->p_libvlc, "key-pressed", i_vlckey );
939 void MainInterface::closeEvent( QCloseEvent *e )
942 vlc_object_kill( p_intf );
945 /*****************************************************************************
947 *****************************************************************************/
948 static int InteractCallback( vlc_object_t *p_this,
949 const char *psz_var, vlc_value_t old_val,
950 vlc_value_t new_val, void *param )
952 intf_dialog_args_t *p_arg = new intf_dialog_args_t;
953 p_arg->p_dialog = (interaction_dialog_t *)(new_val.p_address);
954 DialogEvent *event = new DialogEvent( INTF_DIALOG_INTERACTION, 0, p_arg );
955 QApplication::postEvent( THEDP, static_cast<QEvent*>(event) );
959 /*****************************************************************************
960 * PopupMenuCB: callback triggered by the intf-popupmenu playlist variable.
961 * We don't show the menu directly here because we don't want the
962 * caller to block for a too long time.
963 *****************************************************************************/
964 static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
965 vlc_value_t old_val, vlc_value_t new_val, void *param )
967 intf_thread_t *p_intf = (intf_thread_t *)param;
969 if( p_intf->pf_show_dialog )
971 p_intf->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU,
978 /*****************************************************************************
979 * IntfShowCB: callback triggered by the intf-show playlist variable.
980 *****************************************************************************/
981 static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
982 vlc_value_t old_val, vlc_value_t new_val, void *param )
984 intf_thread_t *p_intf = (intf_thread_t *)param;
985 //p_intf->p_sys->b_intf_show = VLC_TRUE;