]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/main_interface.cpp
Qt4: fix a minor (but annoying) UI glitch on restart
[vlc] / modules / gui / qt4 / main_interface.cpp
index 93588b4facd05a70dc930c9457cb72961c9d59a1..17810d90963031d0e7e49a929697a052bf04b00f 100644 (file)
@@ -102,6 +102,9 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     setWindowRole( "vlc-main" );
     setWindowIcon( QApplication::windowIcon() );
     setWindowOpacity( var_InheritFloat( p_intf, "qt-opacity" ) );
+#ifdef Q_WS_MAC
+    setAttribute( Qt::WA_MacBrushedMetal );
+#endif
 
     /* Is video in embedded in the UI or not */
     b_videoEmbedded = var_InheritBool( p_intf, "embedded-video" );
@@ -286,12 +289,7 @@ MainInterface::~MainInterface()
     settings->setValue( "pl-dock-status", b_plDocked );
     /* Save playlist state */
     if( playlistWidget )
-    {
-        settings->setValue( "playlist-visible",
-                            isPlDocked() ?
-                            playlistVisible :
-                            playlistWidget->isVisible() /* FIXME */ );
-    }
+        settings->setValue( "playlist-visible", playlistVisible );
 
     settings->setValue( "adv-controls",
                         getControlsVisibilityStatus() & CONTROLS_ADVANCED );
@@ -470,6 +468,14 @@ inline void MainInterface::createStatusBar()
 
     CONNECT( THEMIM->getIM(), seekRequested( float ),
              timeLabel, setDisplayPosition( float ) );
+
+    /* This shouldn't be necessary, but for somehow reason, the statusBarr
+       starts at height of 20px and when a text is shown it needs more space.
+       But, as the QMainWindow policy doesn't allow statusBar to change QMW's
+       geometry, we need to force a height. If you have a better idea, please
+       tell me -- jb
+     */
+    statusBarr->setFixedHeight( statusBarr->sizeHint().height() + 2 );
 }
 
 /**********************************************************************
@@ -973,7 +979,11 @@ void MainInterface::handleSystrayClick(
     {
         case QSystemTrayIcon::Trigger:
         case QSystemTrayIcon::DoubleClick:
+#ifdef Q_WS_MAC
+            QVLCMenu::updateSystrayMenu( this, p_intf );
+#else
             toggleUpdateSystrayMenu();
+#endif
             break;
         case QSystemTrayIcon::MiddleClick:
             sysTray->showMessage( qtr( "VLC media player" ),
@@ -1040,8 +1050,9 @@ void MainInterface::dropEvent(QDropEvent *event)
 
 void MainInterface::dropEventPlay( QDropEvent *event, bool b_play )
 {
-    event->setDropAction( Qt::CopyAction );
-    if( !event->possibleActions() & Qt::CopyAction )
+    if( event->possibleActions() & Qt::CopyAction )
+       event->setDropAction( Qt::CopyAction );
+    else
         return;
 
     const QMimeData *mimeData = event->mimeData();
@@ -1061,18 +1072,30 @@ void MainInterface::dropEventPlay( QDropEvent *event, bool b_play )
     bool first = b_play;
     foreach( const QUrl &url, mimeData->urls() )
     {
-        QString s = toNativeSeparators( url.toLocalFile() );
-
-        if( s.length() > 0 ) {
-            char* psz_uri = make_URI( qtu(s) );
+        if( url.isValid() )
+        {
+            char* psz_uri = make_URI( qtu( url.toString() ), NULL );
             playlist_Add( THEPL, psz_uri, NULL,
                           PLAYLIST_APPEND | (first ? PLAYLIST_GO: PLAYLIST_PREPARSE),
                           PLAYLIST_END, true, pl_Unlocked );
             free( psz_uri );
             first = false;
-            RecentsMRL::getInstance( p_intf )->addRecent( s );
+            RecentsMRL::getInstance( p_intf )->addRecent( url.toString() );
         }
     }
+
+    /* Browsers give content as text if you dnd the addressbar,
+       so check if mimedata has valid url in text and use it
+       if we didn't get any normal Urls()*/
+    if( !mimeData->hasUrls() && mimeData->hasText() &&
+        QUrl(mimeData->text()).isValid() )
+    {
+        char *psz_uri = make_URI( qtu( mimeData->text() ), NULL );
+        playlist_Add( THEPL, psz_uri, NULL,
+                      PLAYLIST_APPEND | (first ? PLAYLIST_GO: PLAYLIST_PREPARSE),
+                      PLAYLIST_END, true, pl_Unlocked );
+        free( psz_uri );
+    }
     event->accept();
 }
 void MainInterface::dragEnterEvent(QDragEnterEvent *event)
@@ -1131,9 +1154,9 @@ void MainInterface::closeEvent( QCloseEvent *e )
 void MainInterface::setInterfaceFullScreen( bool fs )
 {
     if( fs )
-        showFullScreen();
+        setWindowState( windowState() | Qt::WindowFullScreen );
     else
-        showNormal();
+        setWindowState( windowState() & ~Qt::WindowFullScreen );
 }
 void MainInterface::toggleInterfaceFullScreen()
 {