]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/main_interface.cpp
Fixed input_AddSubtitle(s) coherency.
[vlc] / modules / gui / qt4 / main_interface.cpp
index c9aecc43e05113eb336307cf0f2f40ed0eef189b..a153800d0ad4561bd887a8e708a6c7b5fb327571 100644 (file)
@@ -31,6 +31,7 @@
 #include "main_interface.hpp"
 #include "input_manager.hpp"
 #include "util/qvlcframe.hpp"
+#include "util/qvlcapp.hpp"
 #include "util/customwidgets.hpp"
 #include "dialogs_provider.hpp"
 #include "components/interface_widgets.hpp"
@@ -39,6 +40,7 @@
 #include "dialogs/extended.hpp"
 #include "dialogs/playlist.hpp"
 #include "menus.hpp"
+#include "recents.hpp"
 
 #include <QMenuBar>
 #include <QCloseEvent>
@@ -132,9 +134,13 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
      * Menu Bar and Status Bar
      **************************/
     QVLCMenu::createMenuBar( this, p_intf, visualSelectorEnabled );
+
     /* StatusBar Creation */
     createStatusBar();
 
+    /* Recents menu updates */
+    CONNECT( RecentsMRL::getInstance( p_intf ), updated(),
+             this, updateRecentsMenu() );
 
     /********************
      * Input Manager    *
@@ -146,8 +152,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
      **************************/
     /* Connect the input manager to the GUI elements it manages */
 
-    /* It is also connected to the control->slider, see the ControlsWidget */
-    /* Change the SpeedRate in the Status */
+    /* Change the SpeedRate in the Status Bar */
     CONNECT( THEMIM->getIM(), rateChanged( int ), this, setRate( int ) );
 
     /**
@@ -186,11 +191,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     /* END CONNECTS ON IM */
 
 
-    /** OnTimeOut **/
-    /* TODO Remove this function, but so far, there is no choice because there
-       is no intf-should-die variable #1365 */
-    ON_TIMEOUT( updateOnTimer() );
-
     /************
      * Callbacks
      ************/
@@ -205,8 +205,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
 
 
     /* VideoWidget connects to avoid different threads speaking to each other */
-    CONNECT( this, askReleaseVideo( void ),
-             this, releaseVideoSlot( void ) );
+    CONNECT( this, askReleaseVideo( void ),
+             this, releaseVideoSlot( void ) );
     if( videoWidget )
         CONNECT( this, askVideoToResize( unsigned int, unsigned int ),
                  videoWidget, SetSizing( unsigned int, unsigned int ) );
@@ -374,15 +374,15 @@ void MainInterface::handleMainUi( QSettings *settings )
     mainLayout->setMargin( 0 );
 
     /* Create the CONTROLS Widget */
-    bool b_shiny = config_GetInt( p_intf, "qt-blingbling" );
-    controls = new ControlsWidget( p_intf, this,
-                   settings->value( "adv-controls", false ).toBool(),
-                   b_shiny );
+    controls = new ControlsWidget( p_intf,
+                   settings->value( "adv-controls", false ).toBool(), this );
     CONNECT( controls, advancedControlsToggled( bool ),
              this, doComponentsUpdate() );
+    InputControlsWidget *inputC = new InputControlsWidget( p_intf, this );
 
     /* Add the controls Widget to the main Widget */
     mainLayout->insertWidget( 0, controls, 0, Qt::AlignBottom );
+    mainLayout->insertWidget( 0, inputC, 0, Qt::AlignBottom );
 
     /* Create the Speed Control Widget */
     speedControl = new SpeedControlWidget( p_intf );
@@ -431,11 +431,7 @@ void MainInterface::handleMainUi( QSettings *settings )
     /* Create the FULLSCREEN CONTROLS Widget */
     if( config_GetInt( p_intf, "qt-fs-controller" ) )
     {
-        fullscreenControls = new FullscreenControllerWidget( p_intf, this,
-                settings->value( "adv-controls", false ).toBool(),
-                b_shiny );
-        CONNECT( fullscreenControls, advancedControlsToggled( bool ),
-                this, doComponentsUpdate() );
+        fullscreenControls = new FullscreenControllerWidget( p_intf );
     }
 }
 
@@ -655,17 +651,16 @@ void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x,
 }
 
 /* Call from the WindowClose function */
-void MainInterface::releaseVideo( void *p_win )
+void MainInterface::releaseVideo( void )
 {
     if( fullscreenControls ) fullscreenControls->detachVout();
-    if( p_win )
-        emit askReleaseVideo( p_win );
+    emit askReleaseVideo( );
 }
 
 /* Function that is CONNECTED to the previous emit */
-void MainInterface::releaseVideoSlot( void *p_win )
+void MainInterface::releaseVideoSlot( void )
 {
-    videoWidget->release( p_win );
+    videoWidget->release( );
 
     if( bgWasVisible )
     {
@@ -779,7 +774,7 @@ void MainInterface::toggleMinimalView()
     if( i_visualmode != QT_ALWAYS_VIDEO_MODE &&
         i_visualmode != QT_MINIMAL_MODE )
     { /* NORMAL MODE then */
-        if( videoWidget->isHidden() ) emit askBgWidgetToToggle();
+        if( !videoWidget || videoWidget->isHidden() ) emit askBgWidgetToToggle();
         else
         {
             /* If video is visible, then toggle the status of bgWidget */
@@ -817,7 +812,7 @@ void MainInterface::doComponentsUpdate()
 void MainInterface::toggleAdvanced()
 {
     controls->toggleAdvanced();
-    if( fullscreenControls ) fullscreenControls->toggleAdvanced();
+//    if( fullscreenControls ) fullscreenControls->toggleAdvanced();
 }
 
 /* Get the visibility status of the controls (hidden or not, advanced or not) */
@@ -865,16 +860,6 @@ void MainInterface::setStatus( int status )
 {
     msg_Dbg( p_intf, "Updating the stream status: %i", status );
 
-    /* Forward the status to the controls to toggle Play/Pause */
-    controls->setStatus( status );
-    controls->updateInput();
-
-    if( fullscreenControls )
-    {
-        fullscreenControls->setStatus( status );
-        fullscreenControls->updateInput();
-    }
-
     speedControl->setEnable( THEMIM->getIM()->hasInput() );
 
     /* And in the systray for the menu */
@@ -892,16 +877,6 @@ void MainInterface::setRate( int rate )
     speedControl->updateControls( rate );
 }
 
-void MainInterface::updateOnTimer()
-{
-    /* No event for dying */
-    if( !vlc_object_alive( p_intf ) )
-    {
-        QApplication::closeAllWindows();
-        QApplication::quit();
-    }
-}
-
 /*****************************************************************************
  * Systray Icon and Systray Menu
  *****************************************************************************/
@@ -952,12 +927,15 @@ void MainInterface::toggleUpdateSystrayMenu()
         /* Visible */
 #ifdef WIN32
         /* check if any visible window is above vlc in the z-order,
-         * but ignore the ones always on top */
+         * but ignore the ones always on top
+         * and the ones which can't be activated */
         WINDOWINFO wi;
         HWND hwnd;
         wi.cbSize = sizeof( WINDOWINFO );
         for( hwnd = GetNextWindow( internalWinId(), GW_HWNDPREV );
-                hwnd && !IsWindowVisible( hwnd );
+                hwnd && ( !IsWindowVisible( hwnd ) ||
+                    ( GetWindowInfo( hwnd, &wi ) &&
+                      (wi.dwExStyle&WS_EX_NOACTIVATE) ) );
                 hwnd = GetNextWindow( hwnd, GW_HWNDPREV ) );
         if( !hwnd || !GetWindowInfo( hwnd, &wi ) ||
                 (wi.dwExStyle&WS_EX_TOPMOST) )
@@ -1057,7 +1035,7 @@ void MainInterface::dropEventPlay( QDropEvent *event, bool b_play )
      {
         if( THEMIM->getIM()->hasInput() )
         {
-            if( input_AddSubtitles( THEMIM->getInput(),
+            if( !input_AddSubtitle( THEMIM->getInput(),
                                     qtu( toNativeSeparators(
                                          mimeData->urls()[0].toLocalFile() ) ),
                                     true ) )
@@ -1077,6 +1055,7 @@ void MainInterface::dropEventPlay( QDropEvent *event, bool b_play )
                           PLAYLIST_APPEND | (first ? PLAYLIST_GO: 0),
                           PLAYLIST_END, true, false );
             first = false;
+            RecentsMRL::getInstance( p_intf )->addRecent( s );
         }
      }
      event->acceptProposedAction();
@@ -1110,7 +1089,7 @@ void MainInterface::customEvent( QEvent *event )
     }
 #endif
     /*else */
-    if ( event->type() == SetVideoOnTopEvent_Type )
+    if ( event->type() == (int)SetVideoOnTopEvent_Type )
     {
         SetVideoOnTopQtEvent* p_event = (SetVideoOnTopQtEvent*)event;
         if( p_event->OnTop() )
@@ -1209,3 +1188,12 @@ static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
     /* Show event */
      return VLC_SUCCESS;
 }
+
+/*****************************************************************************
+ * updateRecentsMenu: event called by RecentsMRL
+ *****************************************************************************/
+
+void MainInterface::updateRecentsMenu()
+{
+    QVLCMenu::updateRecents( p_intf );
+}