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>
46 #include <QWidgetAction>
47 #include <QDockWidget>
62 #define SET_WIDTH(i,j) i->widgetSize.setWidth(j)
63 #define SET_HEIGHT(i,j) i->widgetSize.setHeight(j)
64 #define SET_WH( i,j,k) i->widgetSize.setWidth(j); i->widgetSize.setHeight(k);
66 #define DS(i) i.width(),i.height()
68 /* Callback prototypes */
69 static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
70 vlc_value_t old_val, vlc_value_t new_val, void *param );
71 static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
72 vlc_value_t old_val, vlc_value_t new_val, void *param );
73 static int InteractCallback( vlc_object_t *, const char *, vlc_value_t,
76 static void *DoRequest( intf_thread_t *p_intf, vout_thread_t *p_vout,
77 int *pi1, int *pi2, unsigned int*pi3,unsigned int*pi4)
79 return p_intf->p_sys->p_mi->requestVideo( p_vout, pi1, pi2, pi3, pi4 );
81 static void DoRelease( intf_thread_t *p_intf, void *p_win )
83 return p_intf->p_sys->p_mi->releaseVideo( p_win );
85 static int DoControl( intf_thread_t *p_intf, void *p_win, int i_q, va_list a )
87 return p_intf->p_sys->p_mi->controlVideo( p_win, i_q, a );
90 MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
92 /* Variables initialisation */
93 need_components_update = false;
94 bgWidget = NULL; videoWidget = NULL; playlistWidget = NULL;
95 embeddedPlaylistWasActive = videoIsActive = false;
99 * Configuration and settings
101 settings = new QSettings( "vlc", "vlc-qt-interface" );
102 settings->beginGroup( "MainWindow" );
105 setFocusPolicy( Qt::StrongFocus );
106 setAcceptDrops(true);
107 setWindowIcon( QApplication::windowIcon() );
108 setWindowOpacity( config_GetFloat( p_intf, "qt-opacity" ) );
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 visualSelectorEnabled = settings->value( "visual-selector", false ).toBool();
122 notificationEnabled = config_GetInt( p_intf, "qt-notification" )
124 /**************************
125 * UI and Widgets design
126 **************************/
127 setVLCWindowsTitle();
128 handleMainUi( settings );
130 #if 0 /* dock part */
131 QDockWidget *dock = new QDockWidget( this );
132 PlaylistWidget *plw = new PlaylistWidget( p_intf );
133 dock->setWidget( plw );
134 addDockWidget( Qt::RightDockWidgetArea, dock );
136 QToolBar *tb = new QToolBar(this);
137 tb->addAction( "playlist", dock, SLOT( hide() ) );
138 addToolBar(Qt::RightToolBarArea, tb);
142 QVLCMenu::createMenuBar( this, p_intf, playlistEmbeddedFlag,
143 visualSelectorEnabled );
147 * TODO: clicking on the elapsed time should switch to the remaining time
150 * TODO: do we add a label for the current Volume ?
152 b_remainingTime = false;
153 timeLabel = new TimeLabel;
154 nameLabel = new QLabel;
155 speedLabel = new QLabel( "1.00x" );
156 timeLabel->setFrameStyle( QFrame::Sunken | QFrame::Panel );
157 speedLabel->setFrameStyle( QFrame::Sunken | QFrame::Panel );
158 statusBar()->addWidget( nameLabel, 8 );
159 statusBar()->addPermanentWidget( speedLabel, 0 );
160 statusBar()->addPermanentWidget( timeLabel, 2 );
161 speedLabel->setContextMenuPolicy ( Qt::CustomContextMenu );
162 timeLabel->setContextMenuPolicy ( Qt::CustomContextMenu );
163 CONNECT( timeLabel, timeLabelClicked(), this, toggleTimeDisplay() );
164 CONNECT( timeLabel, timeLabelDoubleClicked(), THEDP, gotoTimeDialog() );
165 CONNECT( speedLabel, customContextMenuRequested( QPoint ),
166 this, showSpeedMenu( QPoint ) );
167 CONNECT( timeLabel, customContextMenuRequested( QPoint ),
168 this, toggleTimeDisplay() );
170 /**********************
171 * Systray Management *
172 **********************/
174 bool b_createSystray = false;
175 bool b_systrayAvailable = QSystemTrayIcon::isSystemTrayAvailable();
176 if( config_GetInt( p_intf, "qt-start-minimized") )
178 if( b_systrayAvailable ){
179 b_createSystray = true;
182 else msg_Warn( p_intf, "You can't minize if you haven't a system "
185 if( config_GetInt( p_intf, "qt-system-tray") )
186 b_createSystray = true;
188 if( b_systrayAvailable && b_createSystray )
191 /* Init input manager */
192 MainInputManager::getInstance( p_intf );
193 ON_TIMEOUT( updateOnTimer() );
199 /* Connect the input manager to the GUI elements it manages */
200 /* It is also connected to the control->slider, see the ControlsWidget */
201 CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
202 this, setDisplayPosition( float, int, int ) );
204 CONNECT( THEMIM->getIM(), rateChanged( int ), this, setRate( int ) );
206 /** Connects on nameChanged() */
207 /* Naming in the controller statusbar */
208 CONNECT( THEMIM->getIM(), nameChanged( QString ), this,
209 setName( QString ) );
210 /* and in the systray */
213 CONNECT( THEMIM->getIM(), nameChanged( QString ), this,
214 updateSystrayTooltipName( QString ) );
216 /* and in the title of the controller */
217 if( config_GetInt( p_intf, "qt-name-in-title" ) )
219 CONNECT( THEMIM->getIM(), nameChanged( QString ), this,
220 setVLCWindowsTitle( QString ) );
223 /** CONNECTS on PLAY_STATUS **/
224 /* Status on the main controller */
225 CONNECT( THEMIM->getIM(), statusChanged( int ), this, setStatus( int ) );
226 /* and in the systray */
229 CONNECT( THEMIM->getIM(), statusChanged( int ), this,
230 updateSystrayTooltipStatus( int ) );
236 var_Create( p_intf, "interaction", VLC_VAR_ADDRESS );
237 var_AddCallback( p_intf, "interaction", InteractCallback, this );
238 p_intf->b_interaction = VLC_TRUE;
240 /* Register callback for the intf-popupmenu variable */
241 playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
242 VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
243 if( p_playlist != NULL )
245 var_AddCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf );
246 var_AddCallback( p_playlist, "intf-show", IntfShowCB, p_intf );
247 vlc_object_release( p_playlist );
251 MainInterface::~MainInterface()
253 /* Unregister callback for the intf-popupmenu variable */
254 playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
255 VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
256 if( p_playlist != NULL )
258 var_DelCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf );
259 var_DelCallback( p_playlist, "intf-show", IntfShowCB, p_intf );
260 vlc_object_release( p_playlist );
263 settings->setValue( "playlist-embedded", playlistEmbeddedFlag );
264 settings->setValue( "adv-controls", getControlsVisibilityStatus() & 0x1 );
265 settings->setValue( "pos", pos() );
266 settings->endGroup();
268 p_intf->b_interaction = VLC_FALSE;
269 var_DelCallback( p_intf, "interaction", InteractCallback, this );
271 p_intf->pf_request_window = NULL;
272 p_intf->pf_release_window = NULL;
273 p_intf->pf_control_window = NULL;
276 /*****************************
278 *****************************/
281 * Give the decorations of the Main Window a correct Name.
282 * If nothing is given, set it to VLC...
284 void MainInterface::setVLCWindowsTitle( QString aTitle )
286 if( aTitle.isEmpty() )
288 setWindowTitle( qtr( "VLC media player" ) );
292 setWindowTitle( aTitle + " - " + qtr( "VLC media player" ) );
297 void MainInterface::handleMainUi( QSettings *settings )
299 /* Create the main Widget and the mainLayout */
300 QWidget *main = new QWidget( this );
301 mainLayout = new QVBoxLayout( main );
302 setCentralWidget( main );
304 /* Margins, spacing */
305 main->setContentsMargins( 0, 0, 0, 0 );
306 mainLayout->setMargin( 0 );
308 /* Create the CONTROLS Widget */
309 controls = new ControlsWidget( p_intf,
310 settings->value( "adv-controls", false ).toBool() );
312 /* Configure the Controls */
313 BUTTON_SET_IMG( controls->playlistButton, "" , playlist_icon.png,
314 playlistEmbeddedFlag ? qtr( "Show playlist" ) :
315 qtr( "Open playlist" ) );
316 BUTTONACT( controls->playlistButton, togglePlaylist() );
318 /* Add the controls Widget to the main Widget */
319 mainLayout->addWidget( controls );
321 /* Create the Speed Control Widget */
322 speedControl = new SpeedControlWidget( p_intf );
323 speedControlMenu = new QMenu( this );
324 QWidgetAction *widgetAction = new QWidgetAction( this );
325 widgetAction->setDefaultWidget( speedControl );
326 speedControlMenu->addAction( widgetAction );
328 /* Set initial size */
329 resize( PREF_W, PREF_H );
330 addSize = QSize( mainLayout->margin() * 2, PREF_H );
333 visualSelector = new VisualSelector( p_intf );
334 mainLayout->insertWidget( 0, visualSelector );
335 visualSelector->hide();
337 /* And video Outputs */
338 if( alwaysVideoFlag )
340 bgWidget = new BackgroundWidget( p_intf );
341 bgWidget->widgetSize = settings->value( "backgroundSize",
342 QSize( 300, 300 ) ).toSize();
343 bgWidget->resize( bgWidget->widgetSize );
344 bgWidget->updateGeometry();
345 mainLayout->insertWidget( 0, bgWidget );
348 if( videoEmbeddedFlag )
350 videoWidget = new VideoWidget( p_intf );
351 videoWidget->widgetSize = QSize( 1, 1 );
352 //videoWidget->resize( videoWidget->widgetSize );
353 mainLayout->insertWidget( 0, videoWidget );
355 p_intf->pf_request_window = ::DoRequest;
356 p_intf->pf_release_window = ::DoRelease;
357 p_intf->pf_control_window = ::DoControl;
360 /* Finish the sizing */
361 setMinimumSize( PREF_W, addSize.height() );
364 /**********************************************************************
365 * Handling of sizing of the components
366 **********************************************************************/
367 void MainInterface::calculateInterfaceSize()
369 int width = 0, height = 0;
370 if( VISIBLE( bgWidget ) )
372 width = bgWidget->widgetSize.width();
373 height = bgWidget->widgetSize.height();
374 assert( !(playlistWidget && playlistWidget->isVisible() ) );
376 else if( VISIBLE( playlistWidget ) )
378 width = playlistWidget->widgetSize.width();
379 height = playlistWidget->widgetSize.height();
381 else if( videoIsActive )
383 width = videoWidget->widgetSize.width() ;
384 height = videoWidget->widgetSize.height();
388 width = PREF_W - addSize.width();
389 height = PREF_H - addSize.height();
391 if( VISIBLE( visualSelector ) )
392 height += visualSelector->height();
393 /* if( VISIBLE( advControls) )
395 height += advControls->sizeHint().height();
397 mainSize = QSize( width + addSize.width(), height + addSize.height() );
400 void MainInterface::resizeEvent( QResizeEvent *e )
403 videoWidget->widgetSize.setWidth( e->size().width() - addSize.width() );
404 if( videoWidget && videoIsActive && videoWidget->widgetSize.height() > 1 )
406 SET_WH( videoWidget, e->size().width() - addSize.width(),
407 e->size().height() - addSize.height() );
408 videoWidget->updateGeometry();
410 if( VISIBLE( playlistWidget ) )
412 SET_WH( playlistWidget , e->size().width() - addSize.width(),
413 e->size().height() - addSize.height() );
414 playlistWidget->updateGeometry();
418 /****************************************************************************
419 * Small right-click menus
420 ****************************************************************************/
421 void MainInterface::showSpeedMenu( QPoint pos )
423 speedControlMenu->exec( QCursor::pos() - pos + QPoint( 0, speedLabel->height() ) );
426 /****************************************************************************
428 ****************************************************************************/
429 void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x,
430 int *pi_y, unsigned int *pi_width,
431 unsigned int *pi_height )
433 void *ret = videoWidget->request( p_nvout,pi_x, pi_y, pi_width, pi_height );
436 videoIsActive = true;
437 if( VISIBLE( playlistWidget ) )
439 embeddedPlaylistWasActive = true;
440 // playlistWidget->hide();
442 bool bgWasVisible = false;
443 if( VISIBLE( bgWidget) )
448 if( THEMIM->getIM()->hasVideo() || !bgWasVisible )
450 videoWidget->widgetSize = QSize( *pi_width, *pi_height );
452 else /* Background widget available, use its size */
454 /* Ok, our visualizations are bad, so don't do this for the moment
455 * use the requested size anyway */
456 // videoWidget->widgetSize = bgWidget->widgeTSize;
457 videoWidget->widgetSize = QSize( *pi_width, *pi_height );
459 videoWidget->updateGeometry(); // Needed for deinterlace
460 need_components_update = true;
465 void MainInterface::releaseVideo( void *p_win )
467 videoWidget->release( p_win );
468 videoWidget->widgetSize = QSize( 0, 0 );
469 videoWidget->resize( videoWidget->widgetSize );
471 if( embeddedPlaylistWasActive )
472 playlistWidget->show();
476 videoIsActive = false;
477 need_components_update = true;
480 class SetVideoOnTopQtEvent : public QEvent
483 SetVideoOnTopQtEvent( bool _onTop ) :
484 QEvent( (QEvent::Type)SetVideoOnTopEvent_Type ), onTop( _onTop)
497 int MainInterface::controlVideo( void *p_window, int i_query, va_list args )
499 int i_ret = VLC_EGENERIC;
504 unsigned int *pi_width = va_arg( args, unsigned int * );
505 unsigned int *pi_height = va_arg( args, unsigned int * );
506 *pi_width = videoWidget->widgetSize.width();
507 *pi_height = videoWidget->widgetSize.height();
513 unsigned int i_width = va_arg( args, unsigned int );
514 unsigned int i_height = va_arg( args, unsigned int );
515 videoWidget->widgetSize = QSize( i_width, i_height );
516 // videoWidget->updateGeometry();
517 need_components_update = true;
521 case VOUT_SET_STAY_ON_TOP:
523 int i_arg = va_arg( args, int );
524 QApplication::postEvent( this, new SetVideoOnTopQtEvent( i_arg ) );
529 msg_Warn( p_intf, "unsupported control query" );
535 /*****************************************************************************
536 * Playlist, Visualisation and Menus handling
537 *****************************************************************************/
539 * Toggle the playlist widget or dialog
541 void MainInterface::togglePlaylist()
543 // Toggle the playlist dialog if not embedded and return
544 if( !playlistEmbeddedFlag )
550 THEDP->playlistDialog();
554 // Create the playlist Widget and destroy the existing dialog
555 if( !playlistWidget )
557 PlaylistDialog::killInstance();
558 playlistWidget = new PlaylistWidget( p_intf );
559 mainLayout->insertWidget( 0, playlistWidget );
560 playlistWidget->widgetSize = settings->value( "playlistSize",
561 QSize( 650, 310 ) ).toSize();
562 playlistWidget->hide();
564 CONNECT( playlistWidget, artSet( QString ), bgWidget, setArt(QString) );
567 // And toggle visibility
568 if( VISIBLE( playlistWidget ) )
570 playlistWidget->hide();
571 if( bgWidget ) bgWidget->show();
574 videoWidget->widgetSize = savedVideoSize;
575 videoWidget->resize( videoWidget->widgetSize );
576 videoWidget->updateGeometry();
577 if( bgWidget ) bgWidget->hide();
582 playlistWidget->show();
585 savedVideoSize = videoWidget->widgetSize;
586 videoWidget->widgetSize.setHeight( 0 );
587 videoWidget->resize( videoWidget->widgetSize );
588 videoWidget->updateGeometry();
590 if( VISIBLE( bgWidget ) ) bgWidget->hide();
593 doComponentsUpdate();
596 void MainInterface::undockPlaylist()
600 playlistWidget->hide();
601 playlistWidget->deleteLater();
602 mainLayout->removeWidget( playlistWidget );
603 playlistWidget = NULL;
604 playlistEmbeddedFlag = false;
607 QVLCMenu::createMenuBar( this, p_intf, false, visualSelectorEnabled);
611 videoWidget->widgetSize = savedVideoSize;
612 videoWidget->resize( videoWidget->widgetSize );
613 videoWidget->updateGeometry();
616 doComponentsUpdate();
617 THEDP->playlistDialog();
622 void MainInterface::visual()
624 if( !VISIBLE( visualSelector) )
626 visualSelector->show();
627 if( !THEMIM->getIM()->hasVideo() )
629 /* Show the background widget */
631 visualSelectorEnabled = true;
635 /* Stop any currently running visualization */
636 visualSelector->hide();
637 visualSelectorEnabled = false;
639 doComponentsUpdate();
643 void MainInterface::toggleMenus()
646 TOGGLEV( statusBar() );
650 /* Video widget cannot do this synchronously as it runs in another thread */
651 /* Well, could it, actually ? Probably dangerous ... */
652 void MainInterface::doComponentsUpdate()
654 calculateInterfaceSize();
658 void MainInterface::toggleAdvanced()
660 controls->toggleAdvanced();
663 int MainInterface::getControlsVisibilityStatus()
665 return( (controls->isVisible() ? 0x2 : 0x0 )
666 + controls->b_advancedVisible );
669 /************************************************************************
671 ************************************************************************/
672 void MainInterface::setDisplayPosition( float pos, int time, int length )
674 char psz_length[MSTRTIME_MAX_SIZE], psz_time[MSTRTIME_MAX_SIZE];
675 secstotimestr( psz_length, length );
676 secstotimestr( psz_time, b_remainingTime ? length - time : time );
677 QString title; title.sprintf( "%s/%s", psz_time, psz_length );
678 if( b_remainingTime ) timeLabel->setText( " -"+title+" " );
679 else timeLabel->setText( " "+title+" " );
682 void MainInterface::toggleTimeDisplay()
684 msg_Dbg( p_intf, "Hello" );
685 b_remainingTime = ( b_remainingTime ? false : true );
688 void MainInterface::setName( QString name )
691 nameLabel->setText( " " + name+" " );
694 void MainInterface::setStatus( int status )
696 controls->setStatus( status );
698 updateSystrayMenu( status );
701 void MainInterface::setRate( int rate )
704 str.setNum( ( 1000 / (double)rate), 'f', 2 );
706 speedLabel->setText( str );
707 speedControl->updateControls( rate );
710 void MainInterface::updateOnTimer()
712 /* \todo Make this event-driven */
713 if( intf_ShouldDie( p_intf ) )
715 QApplication::closeAllWindows();
716 QApplication::quit();
718 if( need_components_update )
720 doComponentsUpdate();
721 need_components_update = false;
724 controls->updateOnTimer();
727 /*****************************************************************************
728 * Systray Icon and Systray Menu
729 *****************************************************************************/
732 * Create a SystemTray icon and a menu that would go with it.
733 * Connects to a click handler on the icon.
735 void MainInterface::createSystray()
737 QIcon iconVLC = QIcon( QPixmap( ":/vlc128.png" ) );
738 sysTray = new QSystemTrayIcon( iconVLC, this );
739 sysTray->setToolTip( qtr( "VLC media player" ));
741 systrayMenu = new QMenu( qtr( "VLC media player" ), this );
742 systrayMenu->setIcon( iconVLC );
744 QVLCMenu::updateSystrayMenu( this, p_intf, true );
747 CONNECT( sysTray, activated( QSystemTrayIcon::ActivationReason ),
748 this, handleSystrayClick( QSystemTrayIcon::ActivationReason ) );
752 * Update the menu of the Systray Icon.
753 * May be unneedded, since it just calls QVLCMenu::update
756 void MainInterface::updateSystrayMenu( int status )
758 QVLCMenu::updateSystrayMenu( this, p_intf ) ;
762 * Updates the Systray Icon's menu and toggle the main interface
764 void MainInterface::toggleUpdateSystrayMenu()
771 else if( isMinimized() )
779 /* check if any visible window is above vlc in the z-order,
780 * but ignore the ones always on top */
783 wi.cbSize = sizeof( WINDOWINFO );
784 for( hwnd = GetNextWindow( internalWinId(), GW_HWNDPREV );
785 hwnd && !IsWindowVisible( hwnd );
786 hwnd = GetNextWindow( hwnd, GW_HWNDPREV ) );
787 if( !hwnd || !GetWindowInfo( hwnd, &wi ) ||
788 (wi.dwExStyle&WS_EX_TOPMOST) )
790 if( isActiveWindow() )
800 QVLCMenu::updateSystrayMenu( this, p_intf );
803 void MainInterface::handleSystrayClick(
804 QSystemTrayIcon::ActivationReason reason )
808 case QSystemTrayIcon::Trigger:
809 toggleUpdateSystrayMenu();
811 case QSystemTrayIcon::MiddleClick:
812 sysTray->showMessage( qtr( "VLC media player" ),
813 qtr( "Control menu for the player" ),
814 QSystemTrayIcon::Information, 4000 );
820 * Updates the name of the systray Icon tooltip.
821 * Doesn't check if the systray exists, check before you call it.
822 * FIXME !!! Fusion with next function ?
824 void MainInterface::updateSystrayTooltipName( QString name )
828 sysTray->setToolTip( qtr( "VLC media player" ) );
832 sysTray->setToolTip( name );
833 if( notificationEnabled && ( isHidden() || isMinimized() ) )
835 sysTray->showMessage( qtr( "VLC media player" ), name,
836 QSystemTrayIcon::NoIcon, 4000 );
842 * Updates the status of the systray Icon tooltip.
843 * Doesn't check if the systray exists, check before you call it.
845 void MainInterface::updateSystrayTooltipStatus( int i_status )
851 sysTray->setToolTip( qtr( "VLC media player" ) );
856 sysTray->setToolTip( input_name );
857 //+ " - " + qtr( "Playing" ) );
862 sysTray->setToolTip( input_name + " - "
869 /************************************************************************
871 ************************************************************************/
872 void MainInterface::dropEvent(QDropEvent *event)
874 const QMimeData *mimeData = event->mimeData();
876 /* D&D of a subtitles file, add it on the fly */
877 if( mimeData->urls().size() == 1 )
879 if( THEMIM->getIM()->hasInput() )
881 if( input_AddSubtitles( THEMIM->getInput(),
882 qtu( mimeData->urls()[0].toString() ),
885 event->acceptProposedAction();
891 foreach( QUrl url, mimeData->urls() ) {
892 QString s = url.toString();
893 if( s.length() > 0 ) {
894 playlist_Add( THEPL, qtu(s), NULL,
895 PLAYLIST_APPEND | (first ? PLAYLIST_GO:0),
896 PLAYLIST_END, VLC_TRUE, VLC_FALSE );
900 event->acceptProposedAction();
902 void MainInterface::dragEnterEvent(QDragEnterEvent *event)
904 event->acceptProposedAction();
906 void MainInterface::dragMoveEvent(QDragMoveEvent *event)
908 event->acceptProposedAction();
910 void MainInterface::dragLeaveEvent(QDragLeaveEvent *event)
915 /************************************************************************
917 ************************************************************************/
918 void MainInterface::customEvent( QEvent *event )
920 if( event->type() == PLDockEvent_Type )
922 PlaylistDialog::killInstance();
923 playlistEmbeddedFlag = true;
925 QVLCMenu::createMenuBar(this, p_intf, true, visualSelectorEnabled);
928 else if ( event->type() == SetVideoOnTopEvent_Type )
930 SetVideoOnTopQtEvent* p_event = (SetVideoOnTopQtEvent*)event;
931 if( p_event->OnTop() )
932 setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
934 setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint);
935 show(); /* necessary to apply window flags?? */
939 void MainInterface::keyPressEvent( QKeyEvent *e )
941 int i_vlck = qtEventToVLCKey( e );
944 var_SetInteger( p_intf->p_libvlc, "key-pressed", i_vlck );
951 void MainInterface::wheelEvent( QWheelEvent *e )
953 int i_vlckey = qtWheelEventToVLCKey( e );
954 var_SetInteger( p_intf->p_libvlc, "key-pressed", i_vlckey );
958 void MainInterface::closeEvent( QCloseEvent *e )
961 vlc_object_kill( p_intf );
964 /*****************************************************************************
966 *****************************************************************************/
967 static int InteractCallback( vlc_object_t *p_this,
968 const char *psz_var, vlc_value_t old_val,
969 vlc_value_t new_val, void *param )
971 intf_dialog_args_t *p_arg = new intf_dialog_args_t;
972 p_arg->p_dialog = (interaction_dialog_t *)(new_val.p_address);
973 DialogEvent *event = new DialogEvent( INTF_DIALOG_INTERACTION, 0, p_arg );
974 QApplication::postEvent( THEDP, static_cast<QEvent*>(event) );
978 /*****************************************************************************
979 * PopupMenuCB: callback triggered by the intf-popupmenu playlist variable.
980 * We don't show the menu directly here because we don't want the
981 * caller to block for a too long time.
982 *****************************************************************************/
983 static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
984 vlc_value_t old_val, vlc_value_t new_val, void *param )
986 intf_thread_t *p_intf = (intf_thread_t *)param;
988 if( p_intf->pf_show_dialog )
990 p_intf->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU,
997 /*****************************************************************************
998 * IntfShowCB: callback triggered by the intf-show playlist variable.
999 *****************************************************************************/
1000 static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
1001 vlc_value_t old_val, vlc_value_t new_val, void *param )
1003 intf_thread_t *p_intf = (intf_thread_t *)param;
1004 //p_intf->p_sys->b_intf_show = VLC_TRUE;