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( "vlc", "vlc-qt-interface" );
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 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, setDisplayPosition( float, int, int ) );
188 CONNECT( THEMIM->getIM(), rateChanged( int ), this, setRate( int ) );
190 /** Connects on nameChanged() */
191 /* Naming in the controller statusbar */
192 CONNECT( THEMIM->getIM(), nameChanged( QString ), this,
193 setName( QString ) );
194 /* and in the systray */
197 CONNECT( THEMIM->getIM(), nameChanged( QString ), this,
198 updateSystrayTooltipName( QString ) );
200 /* and in the title of the controller */
201 if( config_GetInt( p_intf, "qt-name-in-title" ) )
203 CONNECT( THEMIM->getIM(), nameChanged( QString ), this,
204 setVLCWindowsTitle( QString ) );
207 /** CONNECTS on PLAY_STATUS **/
208 /* Status on the main controller */
209 CONNECT( THEMIM->getIM(), statusChanged( int ), this, setStatus( int ) );
210 /* and in the systray */
213 CONNECT( THEMIM->getIM(), statusChanged( int ), this,
214 updateSystrayTooltipStatus( int ) );
220 var_Create( p_intf, "interaction", VLC_VAR_ADDRESS );
221 var_AddCallback( p_intf, "interaction", InteractCallback, this );
222 p_intf->b_interaction = VLC_TRUE;
224 /* Register callback for the intf-popupmenu variable */
225 playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
226 VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
227 if( p_playlist != NULL )
229 var_AddCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf );
230 var_AddCallback( p_playlist, "intf-show", IntfShowCB, p_intf );
231 vlc_object_release( p_playlist );
235 MainInterface::~MainInterface()
237 /* Unregister callback for the intf-popupmenu variable */
238 playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
239 VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
240 if( p_playlist != NULL )
242 var_DelCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf );
243 var_DelCallback( p_playlist, "intf-show", IntfShowCB, p_intf );
244 vlc_object_release( p_playlist );
247 settings->setValue( "playlist-embedded", playlistEmbeddedFlag );
248 settings->setValue( "adv-controls", getControlsVisibilityStatus() & 0x1 );
249 settings->setValue( "pos", pos() );
250 settings->endGroup();
252 p_intf->b_interaction = VLC_FALSE;
253 var_DelCallback( p_intf, "interaction", InteractCallback, this );
255 p_intf->pf_request_window = NULL;
256 p_intf->pf_release_window = NULL;
257 p_intf->pf_control_window = NULL;
260 /*****************************
262 *****************************/
265 * Give the decorations of the Main Window a correct Name.
266 * If nothing is given, set it to VLC...
268 void MainInterface::setVLCWindowsTitle( QString aTitle )
270 if( aTitle.isEmpty() )
272 setWindowTitle( qtr( "VLC media player" ) );
276 setWindowTitle( aTitle + " - " + qtr( "VLC media player" ) );
281 void MainInterface::handleMainUi( QSettings *settings )
283 /* Create the main Widget and the mainLayout */
284 QWidget *main = new QWidget( this );
285 mainLayout = new QVBoxLayout( main );
286 setCentralWidget( main );
288 /* Margins, spacing */
289 main->setContentsMargins( 0, 0, 0, 0 );
290 mainLayout->setMargin( 0 );
292 /* Create the CONTROLS Widget */
293 controls = new ControlsWidget( p_intf,
294 settings->value( "adv-controls", false ).toBool() );
296 /* Configure the Controls */
297 BUTTON_SET_IMG( controls->playlistButton, "" , playlist_icon.png,
298 playlistEmbeddedFlag ? qtr( "Show playlist" ) :
299 qtr( "Open playlist" ) );
300 BUTTONACT( controls->playlistButton, togglePlaylist() );
302 /* Add the controls Widget to the main Widget */
303 mainLayout->addWidget( controls );
306 /* Set initial size */
307 resize( PREF_W, PREF_H );
308 addSize = QSize( mainLayout->margin() * 2, PREF_H );
311 visualSelector = new VisualSelector( p_intf );
312 mainLayout->insertWidget( 0, visualSelector );
313 visualSelector->hide();
315 /* And video Outputs */
316 if( alwaysVideoFlag )
318 bgWidget = new BackgroundWidget( p_intf );
319 bgWidget->widgetSize = settings->value( "backgroundSize",
320 QSize( 300, 300 ) ).toSize();
321 bgWidget->resize( bgWidget->widgetSize );
322 bgWidget->updateGeometry();
323 mainLayout->insertWidget( 0, bgWidget );
326 if( videoEmbeddedFlag )
328 videoWidget = new VideoWidget( p_intf );
329 videoWidget->widgetSize = QSize( 1, 1 );
330 //videoWidget->resize( videoWidget->widgetSize );
331 mainLayout->insertWidget( 0, videoWidget );
333 p_intf->pf_request_window = ::DoRequest;
334 p_intf->pf_release_window = ::DoRelease;
335 p_intf->pf_control_window = ::DoControl;
338 /* Finish the sizing */
339 setMinimumSize( PREF_W, addSize.height() );
342 /**********************************************************************
343 * Handling of sizing of the components
344 **********************************************************************/
345 void MainInterface::calculateInterfaceSize()
347 int width = 0, height = 0;
348 if( VISIBLE( bgWidget ) )
350 width = bgWidget->widgetSize.width();
351 height = bgWidget->widgetSize.height();
352 assert( !(playlistWidget && playlistWidget->isVisible() ) );
354 else if( VISIBLE( playlistWidget ) )
356 width = playlistWidget->widgetSize.width();
357 height = playlistWidget->widgetSize.height();
359 else if( videoIsActive )
361 width = videoWidget->widgetSize.width() ;
362 height = videoWidget->widgetSize.height();
366 width = PREF_W - addSize.width();
367 height = PREF_H - addSize.height();
369 if( VISIBLE( visualSelector ) )
370 height += visualSelector->height();
371 /* if( VISIBLE( advControls) )
373 height += advControls->sizeHint().height();
375 mainSize = QSize( width + addSize.width(), height + addSize.height() );
378 void MainInterface::resizeEvent( QResizeEvent *e )
380 videoWidget->widgetSize.setWidth( e->size().width() - addSize.width() );
381 if( videoWidget && videoIsActive && videoWidget->widgetSize.height() > 1 )
383 SET_WH( videoWidget, e->size().width() - addSize.width(),
384 e->size().height() - addSize.height() );
385 videoWidget->updateGeometry();
387 if( VISIBLE( playlistWidget ) )
389 SET_WH( playlistWidget , e->size().width() - addSize.width(),
390 e->size().height() - addSize.height() );
391 playlistWidget->updateGeometry();
395 /****************************************************************************
396 * Small right-click menus
397 ****************************************************************************/
398 void MainInterface::showSpeedMenu( QPoint pos )
401 menu.addAction( "Not Implemented Yet" );
402 menu.exec( QCursor::pos() );
405 void MainInterface::showTimeMenu( QPoint pos )
408 menu.addAction( qtr("Elapsed Time") , this, SLOT( setElapsedTime() ) );
409 menu.addAction( qtr("Remaining Time") , this, SLOT( setRemainTime() ) );
410 menu.exec( QCursor::pos() );
413 /****************************************************************************
415 ****************************************************************************/
416 void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x,
417 int *pi_y, unsigned int *pi_width,
418 unsigned int *pi_height )
420 void *ret = videoWidget->request( p_nvout,pi_x, pi_y, pi_width, pi_height );
423 videoIsActive = true;
424 if( VISIBLE( playlistWidget ) )
426 embeddedPlaylistWasActive = true;
427 // playlistWidget->hide();
429 bool bgWasVisible = false;
430 if( VISIBLE( bgWidget) )
435 if( THEMIM->getIM()->hasVideo() || !bgWasVisible )
437 videoWidget->widgetSize = QSize( *pi_width, *pi_height );
439 else /* Background widget available, use its size */
441 /* Ok, our visualizations are bad, so don't do this for the moment
442 * use the requested size anyway */
443 // videoWidget->widgetSize = bgWidget->widgeTSize;
444 videoWidget->widgetSize = QSize( *pi_width, *pi_height );
446 videoWidget->updateGeometry(); // Needed for deinterlace
447 need_components_update = true;
452 void MainInterface::releaseVideo( void *p_win )
454 videoWidget->release( p_win );
455 videoWidget->widgetSize = QSize( 0, 0 );
456 videoWidget->resize( videoWidget->widgetSize );
458 if( embeddedPlaylistWasActive )
459 playlistWidget->show();
463 videoIsActive = false;
464 need_components_update = true;
467 class SetVideoOnTopQtEvent : public QEvent
470 SetVideoOnTopQtEvent( bool _onTop ) :
471 QEvent( (QEvent::Type)SetVideoOnTopEvent_Type ), onTop( _onTop)
484 int MainInterface::controlVideo( void *p_window, int i_query, va_list args )
486 int i_ret = VLC_EGENERIC;
491 unsigned int *pi_width = va_arg( args, unsigned int * );
492 unsigned int *pi_height = va_arg( args, unsigned int * );
493 *pi_width = videoWidget->widgetSize.width();
494 *pi_height = videoWidget->widgetSize.height();
500 unsigned int i_width = va_arg( args, unsigned int );
501 unsigned int i_height = va_arg( args, unsigned int );
502 videoWidget->widgetSize = QSize( i_width, i_height );
503 // videoWidget->updateGeometry();
504 need_components_update = true;
508 case VOUT_SET_STAY_ON_TOP:
510 int i_arg = va_arg( args, int );
511 QApplication::postEvent( this, new SetVideoOnTopQtEvent( i_arg ) );
516 msg_Warn( p_intf, "unsupported control query" );
522 /*****************************************************************************
523 * Playlist, Visualisation and Menus handling
524 *****************************************************************************/
526 * Toggle the playlist widget or dialog
528 void MainInterface::togglePlaylist()
530 // Toggle the playlist dialog if not embedded and return
531 if( !playlistEmbeddedFlag )
537 THEDP->playlistDialog();
541 // Create the playlist Widget and destroy the existing dialog
542 if( !playlistWidget )
544 PlaylistDialog::killInstance();
545 playlistWidget = new PlaylistWidget( p_intf );
546 mainLayout->insertWidget( 0, playlistWidget );
547 playlistWidget->widgetSize = settings->value( "playlistSize",
548 QSize( 650, 310 ) ).toSize();
549 playlistWidget->hide();
551 CONNECT( playlistWidget, artSet( QString ), bgWidget, setArt(QString) );
554 // And toggle visibility
555 if( VISIBLE( playlistWidget ) )
557 playlistWidget->hide();
558 if( bgWidget ) bgWidget->show();
561 videoWidget->widgetSize = savedVideoSize;
562 videoWidget->resize( videoWidget->widgetSize );
563 videoWidget->updateGeometry();
564 if( bgWidget ) bgWidget->hide();
569 playlistWidget->show();
572 savedVideoSize = videoWidget->widgetSize;
573 videoWidget->widgetSize.setHeight( 0 );
574 videoWidget->resize( videoWidget->widgetSize );
575 videoWidget->updateGeometry();
577 if( VISIBLE( bgWidget ) ) bgWidget->hide();
580 doComponentsUpdate();
583 void MainInterface::undockPlaylist()
587 playlistWidget->hide();
588 playlistWidget->deleteLater();
589 mainLayout->removeWidget( playlistWidget );
590 playlistWidget = NULL;
591 playlistEmbeddedFlag = false;
594 QVLCMenu::createMenuBar( this, p_intf, false, visualSelectorEnabled);
598 videoWidget->widgetSize = savedVideoSize;
599 videoWidget->resize( videoWidget->widgetSize );
600 videoWidget->updateGeometry();
603 doComponentsUpdate();
604 THEDP->playlistDialog();
609 void MainInterface::visual()
611 if( !VISIBLE( visualSelector) )
613 visualSelector->show();
614 if( !THEMIM->getIM()->hasVideo() )
616 /* Show the background widget */
618 visualSelectorEnabled = true;
622 /* Stop any currently running visualization */
623 visualSelector->hide();
624 visualSelectorEnabled = false;
626 doComponentsUpdate();
630 void MainInterface::toggleMenus()
632 msg_Dbg( p_intf, "I HAS HERE, HIDING YOUR MENUZ: \\_o<~~ coin coin" );
634 TOGGLEV( statusBar() );
638 /* Video widget cannot do this synchronously as it runs in another thread */
639 /* Well, could it, actually ? Probably dangerous ... */
640 void MainInterface::doComponentsUpdate()
642 calculateInterfaceSize();
646 void MainInterface::toggleAdvanced()
648 controls->toggleAdvanced();
651 int MainInterface::getControlsVisibilityStatus()
653 return( (controls->isVisible() ? 0x2 : 0x0 )
654 + controls->b_advancedVisible );
657 /************************************************************************
659 ************************************************************************/
660 void MainInterface::setDisplayPosition( float pos, int time, int length )
662 char psz_length[MSTRTIME_MAX_SIZE], psz_time[MSTRTIME_MAX_SIZE];
663 secstotimestr( psz_length, length );
664 secstotimestr( psz_time, b_remainingTime ? length - time : time );
665 QString title; title.sprintf( "%s/%s", psz_time, psz_length );
666 if( b_remainingTime ) timeLabel->setText( " -"+title+" " );
667 else timeLabel->setText( " "+title+" " );
670 void MainInterface::toggleTimeDisplay()
672 b_remainingTime = ( b_remainingTime ? false : true );
675 void MainInterface::setElapsedTime(){ b_remainingTime = false; }
676 void MainInterface::setRemainTime(){ b_remainingTime = true; }
678 void MainInterface::setName( QString name )
681 nameLabel->setText( " " + name+" " );
684 void MainInterface::setStatus( int status )
686 controls->setStatus( status );
688 updateSystrayMenu( status );
691 void MainInterface::setRate( int rate )
694 str.setNum( ( 1000/(double)rate), 'f', 2 );
696 speedLabel->setText( str );
699 void MainInterface::updateOnTimer()
701 /* \todo Make this event-driven */
702 if( intf_ShouldDie( p_intf ) )
704 QApplication::closeAllWindows();
705 QApplication::quit();
707 if( need_components_update )
709 doComponentsUpdate();
710 need_components_update = false;
713 controls->updateOnTimer();
716 /*****************************************************************************
717 * Systray Icon and Systray Menu
718 *****************************************************************************/
721 * Create a SystemTray icon and a menu that would go with it.
722 * Connects to a click handler on the icon.
724 void MainInterface::createSystray()
726 QIcon iconVLC = QIcon( QPixmap( ":/vlc128.png" ) );
727 sysTray = new QSystemTrayIcon( iconVLC, this );
728 sysTray->setToolTip( qtr( "VLC media player" ));
730 systrayMenu = new QMenu( qtr( "VLC media player" ), this );
731 systrayMenu->setIcon( iconVLC );
733 QVLCMenu::updateSystrayMenu( this, p_intf, true );
736 CONNECT( sysTray, activated( QSystemTrayIcon::ActivationReason ),
737 this, handleSystrayClick( QSystemTrayIcon::ActivationReason ) );
741 * Update the menu of the Systray Icon.
742 * May be unneedded, since it just calls QVLCMenu::update
745 void MainInterface::updateSystrayMenu( int status )
747 QVLCMenu::updateSystrayMenu( this, p_intf ) ;
751 * Updates the Systray Icon's menu and toggle the main interface
753 void MainInterface::toggleUpdateSystrayMenu()
763 /* check if any visible window is above vlc in the z-order,
764 * but ignore the ones always on top */
767 wi.cbSize = sizeof( WINDOWINFO );
768 for( hwnd = GetNextWindow( internalWinId(), GW_HWNDPREV );
769 hwnd && !IsWindowVisible( hwnd );
770 hwnd = GetNextWindow( hwnd, GW_HWNDPREV ) );
771 if( !hwnd || !GetWindowInfo( hwnd, &wi ) ||
772 (wi.dwExStyle&WS_EX_TOPMOST) )
774 if( isActiveWindow() )
784 QVLCMenu::updateSystrayMenu( this, p_intf );
787 void MainInterface::handleSystrayClick(
788 QSystemTrayIcon::ActivationReason reason )
792 case QSystemTrayIcon::Trigger:
793 toggleUpdateSystrayMenu();
795 case QSystemTrayIcon::MiddleClick:
796 sysTray->showMessage( qtr( "VLC media player" ),
797 qtr( "Control menu for the player" ),
798 QSystemTrayIcon::Information, 4000 );
804 * Updates the name of the systray Icon tooltip.
805 * Doesn't check if the systray exists, check before you call it.
806 * FIXME !!! Fusion with next function ?
808 void MainInterface::updateSystrayTooltipName( QString name )
812 sysTray->setToolTip( qtr( "VLC media player" ) );
816 sysTray->setToolTip( name );
817 if( notificationEnabled )
819 sysTray->showMessage( qtr( "VLC media player" ), name,
820 QSystemTrayIcon::NoIcon, 4000 );
826 * Updates the status of the systray Icon tooltip.
827 * Doesn't check if the systray exists, check before you call it.
829 void MainInterface::updateSystrayTooltipStatus( int i_status )
835 sysTray->setToolTip( qtr( "VLC media player" ) );
840 sysTray->setToolTip( input_name );
841 //+ " - " + qtr( "Playing" ) );
846 sysTray->setToolTip( input_name + " - "
853 /************************************************************************
855 ************************************************************************/
856 void MainInterface::dropEvent(QDropEvent *event)
858 const QMimeData *mimeData = event->mimeData();
860 /* D&D of a subtitles file, add it on the fly */
861 if( mimeData->urls().size() == 1 )
863 if( THEMIM->getIM()->hasInput() )
865 if( input_AddSubtitles( THEMIM->getInput(),
866 qtu( mimeData->urls()[0].toString() ),
869 event->acceptProposedAction();
875 foreach( QUrl url, mimeData->urls() ) {
876 QString s = url.toString();
877 if( s.length() > 0 ) {
878 playlist_Add( THEPL, qtu(s), NULL,
879 PLAYLIST_APPEND | (first ? PLAYLIST_GO:0),
880 PLAYLIST_END, VLC_TRUE, VLC_FALSE );
884 event->acceptProposedAction();
886 void MainInterface::dragEnterEvent(QDragEnterEvent *event)
888 event->acceptProposedAction();
890 void MainInterface::dragMoveEvent(QDragMoveEvent *event)
892 event->acceptProposedAction();
894 void MainInterface::dragLeaveEvent(QDragLeaveEvent *event)
899 /************************************************************************
901 ************************************************************************/
902 void MainInterface::customEvent( QEvent *event )
904 if( event->type() == PLDockEvent_Type )
906 PlaylistDialog::killInstance();
907 playlistEmbeddedFlag = true;
909 QVLCMenu::createMenuBar(this, p_intf, true, visualSelectorEnabled);
912 else if ( event->type() == SetVideoOnTopEvent_Type )
914 SetVideoOnTopQtEvent* p_event = (SetVideoOnTopQtEvent*)event;
915 if( p_event->OnTop() )
916 setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
918 setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint);
919 show(); /* necessary to apply window flags?? */
923 bool MainInterface::eventFilter(QObject *obj, QEvent *event)
925 if( (obj == timeLabel) && (event->type() == QEvent::MouseButtonPress) ) toggleTimeDisplay();
929 void MainInterface::keyPressEvent( QKeyEvent *e )
931 int i_vlck = qtEventToVLCKey( e );
934 var_SetInteger( p_intf->p_libvlc, "key-pressed", i_vlck );
941 void MainInterface::wheelEvent( QWheelEvent *e )
943 int i_vlckey = qtWheelEventToVLCKey( e );
944 var_SetInteger( p_intf->p_libvlc, "key-pressed", i_vlckey );
948 void MainInterface::closeEvent( QCloseEvent *e )
951 vlc_object_kill( p_intf );
954 /*****************************************************************************
956 *****************************************************************************/
957 static int InteractCallback( vlc_object_t *p_this,
958 const char *psz_var, vlc_value_t old_val,
959 vlc_value_t new_val, void *param )
961 intf_dialog_args_t *p_arg = new intf_dialog_args_t;
962 p_arg->p_dialog = (interaction_dialog_t *)(new_val.p_address);
963 DialogEvent *event = new DialogEvent( INTF_DIALOG_INTERACTION, 0, p_arg );
964 QApplication::postEvent( THEDP, static_cast<QEvent*>(event) );
968 /*****************************************************************************
969 * PopupMenuCB: callback triggered by the intf-popupmenu playlist variable.
970 * We don't show the menu directly here because we don't want the
971 * caller to block for a too long time.
972 *****************************************************************************/
973 static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
974 vlc_value_t old_val, vlc_value_t new_val, void *param )
976 intf_thread_t *p_intf = (intf_thread_t *)param;
978 if( p_intf->pf_show_dialog )
980 p_intf->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU,
987 /*****************************************************************************
988 * IntfShowCB: callback triggered by the intf-show playlist variable.
989 *****************************************************************************/
990 static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
991 vlc_value_t old_val, vlc_value_t new_val, void *param )
993 intf_thread_t *p_intf = (intf_thread_t *)param;
994 //p_intf->p_sys->b_intf_show = VLC_TRUE;