]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/main_interface.cpp
Qt4: remove useless alive check on input
[vlc] / modules / gui / qt4 / main_interface.cpp
index f1d5ac646309ac5237da072901e641559f218716..2f2ca1a28ef7de2fca10be73a27d4f454f80c6a9 100644 (file)
 #include <QUrl>
 #include <QSize>
 #include <QDate>
+#include <QMimeData>
 
 #include <QMenu>
 #include <QMenuBar>
 #include <QStatusBar>
 #include <QLabel>
 #include <QStackedWidget>
+#include <QFileInfo>
 
 #include <vlc_keys.h>                       /* Wheel event */
 #include <vlc_vout_display.h>               /* vout_thread_t and VOUT_ events */
@@ -75,6 +77,9 @@ static int IntfRaiseMainCB( vlc_object_t *p_this, const char *psz_variable,
                            vlc_value_t old_val, vlc_value_t new_val,
                            void *param );
 
+const QEvent::Type MainInterface::ToolbarsNeedRebuild =
+        (QEvent::Type)QEvent::registerEventType();
+
 MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
 {
     /* Variables initialisation */
@@ -93,7 +98,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     input_name           = "";
     b_interfaceFullScreen= false;
     b_hasPausedWhenMinimized = false;
-
+    i_kc_offset          = false;
 
     /* Ask for Privacy */
     FirstRun::CheckAndRun( this, p_intf );
@@ -167,7 +172,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
 #ifdef WIN32
     himl = NULL;
     p_taskbl = NULL;
-    taskbar_wmsg = RegisterWindowMessage("TaskbarButtonCreated");
+    taskbar_wmsg = RegisterWindowMessage(TEXT("TaskbarButtonCreated"));
 #endif
 
     /*********************************
@@ -217,7 +222,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
                  this, setVideoFullScreen( bool ) );
     }
 
-    CONNECT( THEDP, toolBarConfUpdated(), this, recreateToolbars() );
+    CONNECT( THEDP, toolBarConfUpdated(), this, toolBarConfUpdated() );
+    installEventFilter( this );
 
     CONNECT( this, askToQuit(), THEDP, quit() );
 
@@ -345,6 +351,8 @@ void MainInterface::recreateToolbars()
                  this, handleKeyPress( QKeyEvent * ) );
         THEMIM->requestVoutUpdate();
     }
+
+    setMinimalView( b_minimalView );
 }
 
 void MainInterface::reloadPrefs()
@@ -374,7 +382,15 @@ void MainInterface::createMainWidget( QSettings *creationSettings )
     stackCentralW = new QVLCStackedWidget( main );
 
     /* Bg Cone */
-    bgWidget = new BackgroundWidget( p_intf );
+    if ( QDate::currentDate().dayOfYear() >= QT_XMAS_JOKE_DAY
+         && var_InheritBool( p_intf, "qt-icon-change" ) )
+    {
+        bgWidget = new EasterEggBackgroundWidget( p_intf );
+        CONNECT( this, kc_pressed(), bgWidget, animate() );
+    }
+    else
+        bgWidget = new BackgroundWidget( p_intf );
+
     stackCentralW->addWidget( bgWidget );
     if ( !var_InheritBool( p_intf, "qt-bgcone" ) )
         bgWidget->setWithArt( false );
@@ -606,7 +622,7 @@ void MainInterface::toggleFSC()
 {
    if( !fullscreenControls ) return;
 
-   IMEvent *eShow = new IMEvent( FullscreenControlToggle_Type );
+   IMEvent *eShow = new IMEvent( IMEvent::FullscreenControlToggle );
    QApplication::postEvent( fullscreenControls, eShow );
 }
 
@@ -846,6 +862,14 @@ void MainInterface::togglePlaylist()
     debug();
 }
 
+const Qt::Key MainInterface::kc[10] =
+{
+    Qt::Key_Up, Qt::Key_Up,
+    Qt::Key_Down, Qt::Key_Down,
+    Qt::Key_Left, Qt::Key_Right, Qt::Key_Left, Qt::Key_Right,
+    Qt::Key_B, Qt::Key_A
+};
+
 void MainInterface::dockPlaylist( bool p_docked )
 {
     if( b_plDocked == p_docked ) return;
@@ -926,7 +950,13 @@ int MainInterface::getControlsVisibilityStatus()
 {
     if( !controls ) return 0;
     return( (controls->isVisible() ? CONTROLS_VISIBLE : CONTROLS_HIDDEN )
-                + CONTROLS_ADVANCED * controls->b_advancedVisible );
+            + CONTROLS_ADVANCED * controls->b_advancedVisible );
+}
+
+StandardPLPanel *MainInterface::getPlaylistView()
+{
+    if( !playlistWidget ) return NULL;
+    else return playlistWidget->mainView;
 }
 
 void MainInterface::setStatusBarVisibility( bool b_visible )
@@ -1234,7 +1264,7 @@ void MainInterface::dropEvent(QDropEvent *event)
  */
 void MainInterface::dropEventPlay( QDropEvent *event, bool b_play, bool b_playlist )
 {
-    if( event->possibleActions() & ( Qt::CopyAction | Qt::MoveAction ) )
+    if( event->possibleActions() & ( Qt::CopyAction | Qt::MoveAction | Qt::LinkAction ) )
        event->setDropAction( Qt::CopyAction );
     else
         return;
@@ -1259,11 +1289,29 @@ void MainInterface::dropEventPlay( QDropEvent *event, bool b_play, bool b_playli
         if( url.isValid() )
         {
             QString mrl = toURI( url.toEncoded().constData() );
-            playlist_Add( THEPL, qtu(mrl), NULL,
+            QFileInfo info( url.toLocalFile() );
+            if( info.exists() && info.isSymLink() )
+            {
+                QString target = info.symLinkTarget();
+                QUrl url;
+                if( QFile::exists( target ) )
+                {
+                    url = QUrl::fromLocalFile( target );
+                }
+                else
+                {
+                    url.setUrl( target );
+                }
+                mrl = toURI( url.toEncoded().constData() );
+            }
+            if( mrl.length() > 0 )
+            {
+                playlist_Add( THEPL, qtu(mrl), NULL,
                           PLAYLIST_APPEND | (first ? PLAYLIST_GO: PLAYLIST_PREPARSE),
                           PLAYLIST_END, b_playlist, pl_Unlocked );
-            first = false;
-            RecentsMRL::getInstance( p_intf )->addRecent( mrl );
+                first = false;
+                RecentsMRL::getInstance( p_intf )->addRecent( mrl );
+            }
         }
     }
 
@@ -1299,6 +1347,18 @@ void MainInterface::dragLeaveEvent(QDragLeaveEvent *event)
 void MainInterface::keyPressEvent( QKeyEvent *e )
 {
     handleKeyPress( e );
+
+    /* easter eggs sequence handling */
+    if ( e->key() == kc[ i_kc_offset ] )
+        i_kc_offset++;
+    else
+        i_kc_offset = 0;
+
+    if ( i_kc_offset == (sizeof( kc ) / sizeof( Qt::Key )) )
+    {
+        i_kc_offset = 0;
+        emit kc_pressed();
+    }
 }
 
 void MainInterface::handleKeyPress( QKeyEvent *e )
@@ -1335,6 +1395,22 @@ void MainInterface::closeEvent( QCloseEvent *e )
     e->accept();
 }
 
+bool MainInterface::eventFilter( QObject *obj, QEvent *event )
+{
+    if ( event->type() == MainInterface::ToolbarsNeedRebuild ) {
+        event->accept();
+        recreateToolbars();
+        return true;
+    } else {
+        return QObject::eventFilter( obj, event );
+    }
+}
+
+void MainInterface::toolBarConfUpdated()
+{
+    QApplication::postEvent( this, new QEvent( MainInterface::ToolbarsNeedRebuild ) );
+}
+
 void MainInterface::setInterfaceFullScreen( bool fs )
 {
     if( fs )