]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/main_interface.cpp
[Qt] Add an icon when dragging.
[vlc] / modules / gui / qt4 / main_interface.cpp
index 7836abd692411b8200cff830cd5933fd58f57e05..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 ) );
 
     /**
@@ -200,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 ) );
@@ -370,12 +375,14 @@ void MainInterface::handleMainUi( QSettings *settings )
 
     /* Create the CONTROLS Widget */
     controls = new ControlsWidget( p_intf,
-                   settings->value( "adv-controls", false ).toBool() );
+                   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 );
@@ -644,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 )
     {
@@ -768,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 */
@@ -921,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) )
@@ -1026,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 ) )
@@ -1046,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();
@@ -1079,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() )
@@ -1088,11 +1098,6 @@ void MainInterface::customEvent( QEvent *event )
             setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint);
         show(); /* necessary to apply window flags?? */
     }
-    if ( event->type() == MainInterfaceClose_Type )
-    {
-        QApplication::closeAllWindows();
-        QApplication::quit();
-    }
 }
 
 void MainInterface::keyPressEvent( QKeyEvent *e )
@@ -1183,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 );
+}