1 /*****************************************************************************
2 * main_interface.cpp : Main interface
3 ****************************************************************************
4 * Copyright (C) 2006-2007 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
25 #include "main_interface.hpp"
26 #include "input_manager.hpp"
27 #include "util/input_slider.hpp"
28 #include "util/qvlcframe.hpp"
29 #include "util/customwidgets.hpp"
30 #include "dialogs_provider.hpp"
31 #include "components/interface_widgets.hpp"
32 #include "dialogs/playlist.hpp"
36 #include <QCloseEvent>
37 #include <QPushButton>
41 #include <QSystemTrayIcon>
57 #define VISIBLE(i) (i && i->isVisible())
59 #define SET_WIDTH(i,j) i->widgetSize.setWidth(j)
60 #define SET_HEIGHT(i,j) i->widgetSize.setHeight(j)
61 #define SET_WH( i,j,k) i->widgetSize.setWidth(j); i->widgetSize.setHeight(k);
63 #define DS(i) i.width(),i.height()
65 /* Callback prototypes */
66 static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
67 vlc_value_t old_val, vlc_value_t new_val, void *param );
68 static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
69 vlc_value_t old_val, vlc_value_t new_val, void *param );
70 static int InteractCallback( vlc_object_t *, const char *, vlc_value_t,
73 static void *DoRequest( intf_thread_t *p_intf, vout_thread_t *p_vout,
74 int *pi1, int *pi2, unsigned int*pi3,unsigned int*pi4)
76 return p_intf->p_sys->p_mi->requestVideo( p_vout, pi1, pi2, pi3, pi4 );
78 static void DoRelease( intf_thread_t *p_intf, void *p_win )
80 return p_intf->p_sys->p_mi->releaseVideo( p_win );
82 static int DoControl( intf_thread_t *p_intf, void *p_win, int i_q, va_list a )
84 return p_intf->p_sys->p_mi->controlVideo( p_win, i_q, a );
87 MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
90 settings = new QSettings( "VideoLAN", "VLC" );
91 settings->beginGroup( "MainWindow" );
93 setWindowIcon( QApplication::windowIcon() );
95 need_components_update = false;
96 bgWidget = NULL; videoWidget = NULL; playlistWidget = NULL;
97 embeddedPlaylistWasActive = videoIsActive = false;
101 videoEmbeddedFlag = false;
102 if( config_GetInt( p_intf, "embedded-video" ) ) videoEmbeddedFlag = true;
104 alwaysVideoFlag = false;
105 if( videoEmbeddedFlag && config_GetInt( p_intf, "qt-always-video" ))
106 alwaysVideoFlag = true;
108 playlistEmbeddedFlag = settings->value("playlist-embedded", true).toBool();
109 advControlsEnabled= settings->value( "adv-controls", false ).toBool();
110 visualSelectorEnabled= settings->value( "visual-selector", false ).toBool();
113 setVLCWindowsTitle();
114 handleMainUi( settings );
115 QVLCMenu::createMenuBar( this, p_intf, playlistEmbeddedFlag,
116 advControlsEnabled, visualSelectorEnabled );
117 timeLabel = new QLabel( 0 );
118 nameLabel = new QLabel( 0 );
119 statusBar()->addWidget( nameLabel, 4 );
120 statusBar()->addPermanentWidget( timeLabel, 1 );
122 setFocusPolicy( Qt::StrongFocus );
123 setAcceptDrops(true);
125 /* Init input manager */
126 MainInputManager::getInstance( p_intf );
127 ON_TIMEOUT( updateOnTimer() );
130 CONNECT( ui.volumeSlider, valueChanged(int), this, updateVolume(int) );
132 /* Connect the input manager to the GUI elements it manages */
133 CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
134 slider, setPosition( float,int, int ) );
135 CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
136 this, setDisplay( float, int, int ) );
138 /* Naming in the controller */
139 CONNECT( THEMIM->getIM(), nameChanged( QString ), this,
140 setName( QString ) );
141 if( config_GetInt( p_intf, "qt-system-tray" ) )
143 CONNECT( THEMIM->getIM(), nameChanged( QString ), this,
144 updateSystrayTooltipName(QString));
146 if( config_GetInt( p_intf, "qt-name-in-title" ) )
148 CONNECT( THEMIM->getIM(), nameChanged( QString ), this,
149 setVLCWindowsTitle( QString ) );
153 CONNECT( THEMIM->getIM(), statusChanged( int ), this, setStatus( int ) );
154 CONNECT( THEMIM->getIM(), navigationChanged( int ),
155 this, setNavigation(int) );
156 if( config_GetInt( p_intf, "qt-system-tray" ) )
158 CONNECT( THEMIM->getIM(), statusChanged( int ), this,
159 updateSystrayTooltipStatus(int));
161 CONNECT( slider, sliderDragged( float ),
162 THEMIM->getIM(), sliderUpdate( float ) );
165 CONNECT( ui.prevSectionButton, clicked(), THEMIM->getIM(),
167 CONNECT( ui.nextSectionButton, clicked(), THEMIM->getIM(),
169 CONNECT( ui.menuButton, clicked(), THEMIM->getIM(),
172 var_Create( p_intf, "interaction", VLC_VAR_ADDRESS );
173 var_AddCallback( p_intf, "interaction", InteractCallback, this );
174 p_intf->b_interaction = VLC_TRUE;
176 /* Register callback for the intf-popupmenu variable */
177 playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
178 VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
179 if( p_playlist != NULL )
181 var_AddCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf );
182 var_AddCallback( p_playlist, "intf-show", IntfShowCB, p_intf );
183 vlc_object_release( p_playlist );
185 if( QSystemTrayIcon::isSystemTrayAvailable() &&
186 ( config_GetInt( p_intf, "qt-start-mininimized") == 1))
191 if( QSystemTrayIcon::isSystemTrayAvailable() &&
192 ( config_GetInt( p_intf, "qt-system-tray") == 1))
197 MainInterface::~MainInterface()
199 /* Unregister callback for the intf-popupmenu variable */
200 playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
201 VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
202 if( p_playlist != NULL )
204 var_DelCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf );
205 var_DelCallback( p_playlist, "intf-show", IntfShowCB, p_intf );
206 vlc_object_release( p_playlist );
209 settings->setValue( "playlist-embedded", playlistEmbeddedFlag );
210 settings->setValue( "adv-controls", advControlsEnabled );
211 settings->setValue( "pos", pos() );
212 settings->endGroup();
214 p_intf->b_interaction = VLC_FALSE;
215 var_DelCallback( p_intf, "interaction", InteractCallback, this );
217 p_intf->pf_request_window = NULL;
218 p_intf->pf_release_window = NULL;
219 p_intf->pf_control_window = NULL;
222 void MainInterface::setVLCWindowsTitle( QString aTitle )
224 if( aTitle.isEmpty() )
226 this->setWindowTitle( qtr( "VLC media player" ) );
230 this->setWindowTitle( aTitle + " - " + qtr( "VLC media player" ) );
234 void MainInterface::handleMainUi( QSettings *settings )
236 QWidget *main = new QWidget( this );
237 setCentralWidget( main );
238 ui.setupUi( centralWidget() );
240 slider = new InputSlider( Qt::Horizontal, NULL );
241 ui.vboxLayout->insertWidget( 0, slider );
242 ui.discFrame->hide();
243 BUTTON_SET_IMG( ui.prevSectionButton, "", previous.png, "" );
244 BUTTON_SET_IMG( ui.nextSectionButton, "", next.png, "" );
245 BUTTON_SET_IMG( ui.menuButton, "", previous.png, "" );
247 BUTTON_SET_ACT_I( ui.prevButton, "" , previous.png,
248 qtr("Previous"), prev() );
249 BUTTON_SET_ACT_I( ui.nextButton, "", next.png, qtr("Next"), next() );
250 BUTTON_SET_ACT_I( ui.playButton, "", play.png, qtr("Play"), play() );
251 BUTTON_SET_ACT_I( ui.stopButton, "", stop.png, qtr("Stop"), stop() );
254 ui.volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-low.png" ) );
255 ui.volumeSlider->setMaximum( 100 );
256 ui.volMuteLabel->setToolTip( qtr( "Mute" ) );
257 VolumeClickHandler *h = new VolumeClickHandler( p_intf, this );
258 ui.volMuteLabel->installEventFilter(h);
259 ui.volumeSlider->setFocusPolicy( Qt::NoFocus );
261 BUTTON_SET_IMG( ui.playlistButton, "" , playlist_icon.png,
262 playlistEmbeddedFlag ? qtr( "Show playlist" ) :
263 qtr( "Open playlist" ) );
264 BUTTONACT( ui.playlistButton, playlist() );
266 /* Set initial size */
267 resize ( PREF_W, PREF_H );
269 addSize = QSize( ui.vboxLayout->margin() * 2, PREF_H );
271 advControls = new ControlsWidget( p_intf );
272 ui.vboxLayout->insertWidget( 0, advControls );
273 advControls->updateGeometry();
274 if( !advControlsEnabled ) advControls->hide();
275 need_components_update = true;
277 visualSelector = new VisualSelector( p_intf );
278 ui.vboxLayout->insertWidget( 0, visualSelector );
279 visualSelector->hide();
281 if( alwaysVideoFlag )
283 bgWidget = new BackgroundWidget( p_intf );
284 bgWidget->widgetSize = settings->value( "backgroundSize",
285 QSize( 200, 200 ) ).toSize();
286 bgWidget->resize( bgWidget->widgetSize );
287 bgWidget->updateGeometry();
288 ui.vboxLayout->insertWidget( 0, bgWidget );
291 if( videoEmbeddedFlag )
293 videoWidget = new VideoWidget( p_intf );
294 videoWidget->widgetSize = QSize( 1, 1 );
295 videoWidget->resize( videoWidget->widgetSize );
296 ui.vboxLayout->insertWidget( 0, videoWidget );
298 p_intf->pf_request_window = ::DoRequest;
299 p_intf->pf_release_window = ::DoRelease;
300 p_intf->pf_control_window = ::DoControl;
302 setMinimumSize( PREF_W, addSize.height() );
305 void MainInterface::createSystrayMenu()
307 QIcon iconVLC = QIcon( QPixmap( ":/vlc128.png" ) );
308 sysTray = new QSystemTrayIcon( iconVLC, this );
309 systrayMenu = new QMenu( qtr( "VLC media player" ), this );
310 systrayMenu->setIcon( iconVLC );
311 sysTray->setToolTip( qtr( "VLC media player" ));
312 QVLCMenu::updateSystrayMenu( this, p_intf, true );
314 CONNECT( sysTray, activated( QSystemTrayIcon::ActivationReason ),
315 this, handleSystrayClick( QSystemTrayIcon::ActivationReason ) );
318 void MainInterface::updateSystrayMenu( int status )
320 QVLCMenu::updateSystrayMenu( this, p_intf ) ;
323 void MainInterface::toggleUpdateSystrayMenu()
326 QVLCMenu::updateSystrayMenu( this, p_intf );
329 void MainInterface::handleSystrayClick( QSystemTrayIcon::ActivationReason reason )
333 case QSystemTrayIcon::Trigger:
334 toggleUpdateSystrayMenu();
336 case QSystemTrayIcon::MiddleClick:
337 sysTray->showMessage( qtr( "VLC media player" ),
338 qtr( "Control menu for the player" ),
339 QSystemTrayIcon::Information, 4000 );
345 void MainInterface::updateSystrayTooltipName( QString name )
349 sysTray->setToolTip( qtr( "VLC media player" ) );
353 sysTray->setToolTip( name );
357 void MainInterface::updateSystrayTooltipStatus( int i_status )
363 sysTray->setToolTip( qtr( "VLC media player" ) );
368 sysTray->setToolTip( input_name );
369 //+ " - " + qtr( "Playing" ) );
374 sysTray->setToolTip( input_name + " - "
380 /**********************************************************************
381 * Handling of the components
382 **********************************************************************/
383 void MainInterface::calculateInterfaceSize()
385 int width = 0, height = 0;
386 if( VISIBLE( bgWidget ) )
388 width = bgWidget->widgetSize.width();
389 height = bgWidget->widgetSize.height();
390 assert( !(playlistWidget && playlistWidget->isVisible() ) );
392 else if( VISIBLE( playlistWidget ) )
394 width = playlistWidget->widgetSize.width();
395 height = playlistWidget->widgetSize.height();
397 else if( videoIsActive )
399 width = videoWidget->widgetSize.width() ;
400 height = videoWidget->widgetSize.height();
404 width = PREF_W - addSize.width();
405 height = PREF_H - addSize.height();
407 if( VISIBLE( visualSelector ) )
408 height += visualSelector->height();
409 if( VISIBLE( advControls) )
411 height += advControls->sizeHint().height();
413 mainSize = QSize( width + addSize.width(), height + addSize.height() );
416 void MainInterface::resizeEvent( QResizeEvent *e )
418 videoWidget->widgetSize.setWidth( e->size().width() - addSize.width() );
419 if( videoWidget && videoIsActive && videoWidget->widgetSize.height() > 1 )
421 SET_WH( videoWidget, e->size().width() - addSize.width(),
422 e->size().height() - addSize.height() );
423 videoWidget->updateGeometry();
425 if( VISIBLE( playlistWidget ) )
427 SET_WH( playlistWidget , e->size().width() - addSize.width(),
428 e->size().height() - addSize.height() );
429 playlistWidget->updateGeometry();
433 void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x,
434 int *pi_y, unsigned int *pi_width,
435 unsigned int *pi_height )
437 void *ret = videoWidget->request( p_nvout,pi_x, pi_y, pi_width, pi_height );
440 videoIsActive = true;
441 if( VISIBLE( playlistWidget ) )
443 embeddedPlaylistWasActive = true;
444 // playlistWidget->hide();
446 bool bgWasVisible = false;
447 if( VISIBLE( bgWidget) )
452 if( THEMIM->getIM()->hasVideo() || !bgWasVisible )
454 videoWidget->widgetSize = QSize( *pi_width, *pi_height );
456 else /* Background widget available, use its size */
458 /* Ok, our visualizations are bad, so don't do this for the moment
459 * use the requested size anyway */
460 // videoWidget->widgetSize = bgWidget->widgeTSize;
461 videoWidget->widgetSize = QSize( *pi_width, *pi_height );
463 // videoWidget->updateGeometry(); /// FIXME: Needed ?
464 need_components_update = true;
469 void MainInterface::releaseVideo( void *p_win )
471 videoWidget->release( p_win );
472 videoWidget->widgetSize = QSize( 0, 0 );
473 videoWidget->resize( videoWidget->widgetSize );
475 if( embeddedPlaylistWasActive )
476 ;//playlistWidget->show();
480 videoIsActive = false;
481 need_components_update = true;
484 class SetVideoOnTopQtEvent : public QEvent
487 SetVideoOnTopQtEvent( bool _onTop ) :
488 QEvent( (QEvent::Type)SetVideoOnTopEvent_Type ), onTop( _onTop)
501 int MainInterface::controlVideo( void *p_window, int i_query, va_list args )
503 int i_ret = VLC_EGENERIC;
508 unsigned int *pi_width = va_arg( args, unsigned int * );
509 unsigned int *pi_height = va_arg( args, unsigned int * );
510 *pi_width = videoWidget->widgetSize.width();
511 *pi_height = videoWidget->widgetSize.height();
517 unsigned int i_width = va_arg( args, unsigned int );
518 unsigned int i_height = va_arg( args, unsigned int );
519 videoWidget->widgetSize = QSize( i_width, i_height );
520 // videoWidget->updateGeometry();
521 need_components_update = true;
525 case VOUT_SET_STAY_ON_TOP:
527 int i_arg = va_arg( args, int );
528 QApplication::postEvent( this, new SetVideoOnTopQtEvent( i_arg ) );
533 msg_Warn( p_intf, "unsupported control query" );
539 void MainInterface::advanced()
541 if( !VISIBLE( advControls ) )
544 advControlsEnabled = true;
549 advControlsEnabled = false;
551 doComponentsUpdate();
554 void MainInterface::visual()
556 if( !VISIBLE( visualSelector) )
558 visualSelector->show();
559 if( !THEMIM->getIM()->hasVideo() )
561 /* Show the background widget */
563 visualSelectorEnabled = true;
567 /* Stop any currently running visualization */
568 visualSelector->hide();
569 visualSelectorEnabled = false;
571 doComponentsUpdate();
574 void MainInterface::playlist()
576 // Toggle the playlist dialog
577 if( !playlistEmbeddedFlag )
583 THEDP->playlistDialog();
587 if( !playlistWidget )
589 PlaylistDialog::killInstance();
590 playlistWidget = new PlaylistWidget( p_intf );
591 ui.vboxLayout->insertWidget( 0, playlistWidget );
592 playlistWidget->widgetSize = settings->value( "playlistSize",
593 QSize( 650, 310 ) ).toSize();
594 playlistWidget->hide();
596 if( VISIBLE( playlistWidget ) )
598 playlistWidget->hide();
601 videoWidget->widgetSize = savedVideoSize;
602 videoWidget->resize( videoWidget->widgetSize );
603 videoWidget->updateGeometry();
608 playlistWidget->show();
611 savedVideoSize = videoWidget->widgetSize;
612 videoWidget->widgetSize.setHeight( 0 );
613 videoWidget->resize( videoWidget->widgetSize );
614 videoWidget->updateGeometry();
616 if( VISIBLE( bgWidget ) ) bgWidget->hide();
618 doComponentsUpdate();
621 /* Video widget cannot do this synchronously as it runs in another thread */
622 /* Well, could it, actually ? Probably dangerous ... */
623 void MainInterface::doComponentsUpdate()
625 calculateInterfaceSize();
629 void MainInterface::undockPlaylist()
633 playlistWidget->hide();
634 playlistWidget->deleteLater();
635 ui.vboxLayout->removeWidget( playlistWidget );
636 playlistWidget = NULL;
637 playlistEmbeddedFlag = false;
640 QVLCMenu::createMenuBar( this, p_intf, false, advControlsEnabled,
641 visualSelectorEnabled);
645 videoWidget->widgetSize = savedVideoSize;
646 videoWidget->resize( videoWidget->widgetSize );
647 videoWidget->updateGeometry();
650 doComponentsUpdate();
651 THEDP->playlistDialog();
655 void MainInterface::customEvent( QEvent *event )
657 if( event->type() == PLDockEvent_Type )
659 PlaylistDialog::killInstance();
660 playlistEmbeddedFlag = true;
662 QVLCMenu::createMenuBar(this, p_intf, true, advControlsEnabled,
663 visualSelectorEnabled);
666 else if ( event->type() == SetVideoOnTopEvent_Type )
668 SetVideoOnTopQtEvent* p_event = (SetVideoOnTopQtEvent*)event;
669 if( p_event->OnTop() )
670 setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
672 setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint);
673 show(); /* necessary to apply window flags?? */
678 /************************************************************************
680 ************************************************************************/
681 void MainInterface::dropEvent(QDropEvent *event)
683 const QMimeData *mimeData = event->mimeData();
685 /* D&D of a subtitles file, add it on the fly */
686 if( mimeData->urls().size() == 1 )
688 if( THEMIM->getIM()->hasInput() )
690 if( input_AddSubtitles( THEMIM->getInput(),
691 qtu( mimeData->urls()[0].toString() ),
694 event->acceptProposedAction();
700 foreach( QUrl url, mimeData->urls() ) {
701 QString s = url.toString();
702 if( s.length() > 0 ) {
703 playlist_Add( THEPL, qtu(s), NULL,
704 PLAYLIST_APPEND | (first ? PLAYLIST_GO:0),
705 PLAYLIST_END, VLC_TRUE, VLC_FALSE );
709 event->acceptProposedAction();
711 void MainInterface::dragEnterEvent(QDragEnterEvent *event)
713 event->acceptProposedAction();
715 void MainInterface::dragMoveEvent(QDragMoveEvent *event)
717 event->acceptProposedAction();
719 void MainInterface::dragLeaveEvent(QDragLeaveEvent *event)
724 /************************************************************************
726 ************************************************************************/
727 void MainInterface::keyPressEvent( QKeyEvent *e )
729 int i_vlck = qtEventToVLCKey( e );
732 var_SetInteger( p_intf->p_libvlc, "key-pressed", i_vlck );
739 void MainInterface::wheelEvent( QWheelEvent *e )
741 int i_vlckey = qtWheelEventToVLCKey( e );
742 var_SetInteger( p_intf->p_libvlc, "key-pressed", i_vlckey );
746 void MainInterface::stop()
751 void MainInterface::play()
753 if( playlist_IsEmpty(THEPL) )
755 /* The playlist is empty, open a file requester */
756 THEDP->openFileDialog();
760 THEMIM->togglePlayPause();
763 void MainInterface::prev()
768 void MainInterface::next()
773 void MainInterface::setDisplay( float pos, int time, int length )
775 char psz_length[MSTRTIME_MAX_SIZE], psz_time[MSTRTIME_MAX_SIZE];
776 secstotimestr( psz_length, length );
777 secstotimestr( psz_time, time );
779 title.sprintf( "%s/%s", psz_time, psz_length );
780 timeLabel->setText( " "+title+" " );
783 void MainInterface::setName( QString name )
786 nameLabel->setText( " " + name+" " );
790 void MainInterface::setStatus( int status )
792 if( status == 1 ) // Playing
793 ui.playButton->setIcon( QIcon( ":/pixmaps/pause.png" ) );
795 ui.playButton->setIcon( QIcon( ":/pixmaps/play.png" ) );
796 updateSystrayMenu( status );
799 #define HELP_MENU N_("Menu")
800 #define HELP_PCH N_("Previous chapter")
801 #define HELP_NCH N_("Next chapter")
802 #define HELP_PTR N_("Previous track")
803 #define HELP_NTR N_("Next track")
805 void MainInterface::setNavigation( int navigation )
807 // 1 = chapter, 2 = title, 0 = no
808 if( navigation == 0 )
810 ui.discFrame->hide();
811 } else if( navigation == 1 ) {
812 ui.prevSectionButton->show();
813 ui.prevSectionButton->setToolTip( qfu(HELP_PCH) );
814 ui.nextSectionButton->show();
815 ui.nextSectionButton->setToolTip( qfu(HELP_NCH) );
816 ui.menuButton->show();
817 ui.discFrame->show();
819 ui.prevSectionButton->show();
820 ui.prevSectionButton->setToolTip( qfu(HELP_PCH) );
821 ui.nextSectionButton->show();
822 ui.nextSectionButton->setToolTip( qfu(HELP_NCH) );
823 ui.menuButton->hide();
824 ui.discFrame->show();
828 static bool b_my_volume;
830 void MainInterface::updateOnTimer()
832 /* \todo Make this event-driven */
833 advControls->enableInput( THEMIM->getIM()->hasInput() );
834 advControls->enableVideo( THEMIM->getIM()->hasVideo() );
836 if( intf_ShouldDie( p_intf ) )
838 QApplication::closeAllWindows();
839 QApplication::quit();
841 if( need_components_update )
843 doComponentsUpdate();
844 need_components_update = false;
847 audio_volume_t i_volume;
848 aout_VolumeGet( p_intf, &i_volume );
849 i_volume = (i_volume * 200 )/ AOUT_VOLUME_MAX ;
850 int i_gauge = ui.volumeSlider->value();
852 if( i_volume - i_gauge > 1 || i_gauge - i_volume > 1 )
855 ui.volumeSlider->setValue( i_volume );
860 void MainInterface::closeEvent( QCloseEvent *e )
863 vlc_object_kill( p_intf );
866 void MainInterface::updateVolume( int sliderVolume )
870 int i_res = sliderVolume * AOUT_VOLUME_MAX /
871 (2*ui.volumeSlider->maximum() );
872 aout_VolumeSet( p_intf, i_res );
876 static int InteractCallback( vlc_object_t *p_this,
877 const char *psz_var, vlc_value_t old_val,
878 vlc_value_t new_val, void *param )
880 intf_dialog_args_t *p_arg = new intf_dialog_args_t;
881 p_arg->p_dialog = (interaction_dialog_t *)(new_val.p_address);
882 DialogEvent *event = new DialogEvent( INTF_DIALOG_INTERACTION, 0, p_arg );
883 QApplication::postEvent( THEDP, static_cast<QEvent*>(event) );
887 /*****************************************************************************
888 * PopupMenuCB: callback triggered by the intf-popupmenu playlist variable.
889 * We don't show the menu directly here because we don't want the
890 * caller to block for a too long time.
891 *****************************************************************************/
892 static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
893 vlc_value_t old_val, vlc_value_t new_val, void *param )
895 intf_thread_t *p_intf = (intf_thread_t *)param;
897 if( p_intf->pf_show_dialog )
899 p_intf->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU,
906 /*****************************************************************************
907 * IntfShowCB: callback triggered by the intf-show playlist variable.
908 *****************************************************************************/
909 static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
910 vlc_value_t old_val, vlc_value_t new_val, void *param )
912 intf_thread_t *p_intf = (intf_thread_t *)param;
913 //p_intf->p_sys->b_intf_show = VLC_TRUE;