]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/main_interface.cpp
Always create a new object with the parent object
[vlc] / modules / gui / qt4 / main_interface.cpp
index b7c7147e42da7b811253f60cfcb51e6276ad72d7..b88f58680170894a9a8d879597f7034f89e82fdf 100644 (file)
@@ -122,15 +122,20 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     settings = getSettings();
     settings->beginGroup( "MainWindow" );
 
+#ifdef WIN32
+    /* Volume keys */
+    p_intf->p_sys->disable_volume_keys = var_InheritBool( p_intf, "qt-disable-volume-keys" );
+#endif
+
     /* */
     b_plDocked = getSettings()->value( "pl-dock-status", true ).toBool();
 
     settings->endGroup( );
 
-    /**************
-     * Status Bar *
-     **************/
-    createStatusBar();
+    /*********************************
+     * Create the Systray Management *
+     *********************************/
+    initSystray();
 
     /**************************
      *  UI and Widgets design
@@ -145,10 +150,12 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
              this, destroyPopupMenu() );
 
     createMainWidget( settings );
-    /*********************************
-     * Create the Systray Management *
-     *********************************/
-    initSystray();
+
+    /**************
+     * Status Bar *
+     **************/
+    createStatusBar();
+    setStatusBarVisibility( getSettings()->value( "MainWindow/status-bar-visible", false ).toBool() );
 
     /********************
      * Input Manager    *
@@ -193,7 +200,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
 #ifndef HAVE_MAEMO
     if( sysTray )
     {
-        CONNECT( THEMIM->getIM(), statusChanged( int ),
+        CONNECT( THEMIM->getIM(), playingStatusChanged( int ),
                  this, updateSystrayTooltipStatus( int ) );
     }
 #endif
@@ -202,7 +209,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
 
     /* VideoWidget connects for asynchronous calls */
     b_videoFullScreen = false;
-    b_videoOnTop = false;
     connect( this, SIGNAL(askGetVideo(WId*,int*,int*,unsigned*,unsigned *)),
              this, SLOT(getVideoSlot(WId*,int*,int*,unsigned*,unsigned*)),
              Qt::BlockingQueuedConnection );
@@ -246,7 +252,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
 
     /**** FINAL SIZING and placement of interface */
     settings->beginGroup( "MainWindow" );
-    QVLCTools::restoreWidgetPosition( settings, this, QSize(400, 100) );
+    QVLCTools::restoreWidgetPosition( settings, this, QSize(600, 420) );
     settings->endGroup();
 
     b_interfaceFullScreen = isFullScreen();
@@ -259,6 +265,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     /* Switch to minimal view if needed, must be called after the show() */
     if( b_minimalView )
         toggleMinimalView( true );
+
+    b_hasPausedWhenMinimized = false;
 }
 
 MainInterface::~MainInterface()
@@ -297,6 +305,7 @@ MainInterface::~MainInterface()
 
     settings->setValue( "adv-controls",
                         getControlsVisibilityStatus() & CONTROLS_ADVANCED );
+    settings->setValue( "status-bar-visible", b_statusbarVisible );
 
     /* Save the stackCentralW sizes */
     settings->setValue( "bgSize", stackWidgetsSizes[bgWidget] );
@@ -373,6 +382,11 @@ void MainInterface::createMainWidget( QSettings *settings )
     /* Bg Cone */
     bgWidget = new BackgroundWidget( p_intf );
     stackCentralW->addWidget( bgWidget );
+    if ( !var_InheritBool( p_intf, "qt-bgcone" ) )
+        bgWidget->setWithArt( false );
+    else
+        if ( var_InheritBool( p_intf, "qt-bgcone-expands" ) )
+            bgWidget->setExpandstoHeight( true );
 
     /* And video Outputs */
     if( b_videoEmbedded )
@@ -383,7 +397,7 @@ void MainInterface::createMainWidget( QSettings *settings )
     mainLayout->insertWidget( 1, stackCentralW );
 
     settings->beginGroup( "MainWindow" );
-    stackWidgetsSizes[bgWidget] = settings->value( "bgSize", QSize( 400, 0 ) ).toSize();
+    stackWidgetsSizes[bgWidget] = settings->value( "bgSize", QSize( 600, 0 ) ).toSize();
     /* Resize even if no-auto-resize, because we are at creation */
     resizeStack( stackWidgetsSizes[bgWidget].width(), stackWidgetsSizes[bgWidget].height() );
 
@@ -538,7 +552,7 @@ void MainInterface::destroyPopupMenu()
     QVLCMenu::PopupMenu( p_intf, false );
 }
 
-void MainInterface::popupMenu( const QPoint &p )
+void MainInterface::popupMenu( const QPoint & )
 {
     QVLCMenu::PopupMenu( p_intf, true );
 }
@@ -547,7 +561,7 @@ void MainInterface::toggleFSC()
 {
    if( !fullscreenControls ) return;
 
-   IMEvent *eShow = new IMEvent( FullscreenControlToggle_Type, 0 );
+   IMEvent *eShow = new IMEvent( FullscreenControlToggle_Type );
    QApplication::postEvent( fullscreenControls, eShow );
 }
 
@@ -578,6 +592,10 @@ WId MainInterface::getVideo( int *pi_x, int *pi_y,
 void MainInterface::getVideoSlot( WId *p_id, int *pi_x, int *pi_y,
                                   unsigned *pi_width, unsigned *pi_height )
 {
+    /* Hidden or minimized, activate */
+    if( isHidden() || isMinimized() )
+        toggleUpdateSystrayMenu();
+
     /* Request the videoWidget */
     WId ret = videoWidget->request( pi_x, pi_y,
                                     pi_width, pi_height, !b_autoresize );
@@ -661,16 +679,14 @@ void MainInterface::setVideoFullScreen( bool fs )
  * Emit askVideoOnTop() to invoke this from other thread. */
 void MainInterface::setVideoOnTop( bool on_top )
 {
-    b_videoOnTop = on_top;
-
     Qt::WindowFlags oldflags = windowFlags(), newflags;
 
-    if( b_videoOnTop )
+    if( on_top )
         newflags = oldflags | Qt::WindowStaysOnTopHint;
     else
         newflags = oldflags & ~Qt::WindowStaysOnTopHint;
+    if( newflags != oldflags && !b_videoFullScreen )
 
-    if( newflags != oldflags )
     {
         setWindowFlags( newflags );
         show(); /* necessary to apply window flags */
@@ -724,7 +740,7 @@ void MainInterface::createPlaylist()
     if( b_plDocked )
     {
         stackCentralW->addWidget( playlistWidget );
-        stackWidgetsSizes[playlistWidget] = settings->value( "playlistSize", QSize( 500, 250 ) ).toSize();
+        stackWidgetsSizes[playlistWidget] = settings->value( "playlistSize", QSize( 600, 300 ) ).toSize();
     }
     else
     {
@@ -809,7 +825,7 @@ void MainInterface::setMinimalView( bool b_minimal )
 {
     menuBar()->setVisible( !b_minimal );
     controls->setVisible( !b_minimal );
-    statusBar()->setVisible( !b_minimal );
+    statusBar()->setVisible( !b_minimal && b_statusbarVisible );
     inputC->setVisible( !b_minimal );
 }
 
@@ -855,6 +871,13 @@ int MainInterface::getControlsVisibilityStatus()
                 + CONTROLS_ADVANCED * controls->b_advancedVisible );
 }
 
+void MainInterface::setStatusBarVisibility( bool b_visible )
+{
+    statusBar()->setVisible( b_visible );
+    b_statusbarVisible = b_visible;
+    if( controls ) controls->setGripVisible( !b_statusbarVisible );
+}
+
 #if 0
 void MainInterface::visual()
 {
@@ -935,8 +958,8 @@ void MainInterface::showBuffering( float f_cache )
 void MainInterface::createSystray()
 {
     QIcon iconVLC;
-    if( QDate::currentDate().dayOfYear() >= QT_CHRISTMAS_TROLL_DAY )
-        iconVLC =  QIcon( ":/logo/vlc128-christmas.png" );
+    if( QDate::currentDate().dayOfYear() >= QT_XMAS_JOKE_DAY && var_InheritBool( p_intf, "qt-icon-change" ) )
+        iconVLC =  QIcon( ":/logo/vlc128-xmas.png" );
     else
         iconVLC =  QIcon( ":/logo/vlc128.png" );
     sysTray = new QSystemTrayIcon( iconVLC, this );
@@ -949,7 +972,7 @@ void MainInterface::createSystray()
     sysTray->show();
 
     CONNECT( sysTray, activated( QSystemTrayIcon::ActivationReason ),
-            this, handleSystrayClick( QSystemTrayIcon::ActivationReason ) );
+             this, handleSystrayClick( QSystemTrayIcon::ActivationReason ) );
 }
 
 /**
@@ -1085,6 +1108,39 @@ void MainInterface::updateSystrayTooltipStatus( int i_status )
 }
 #endif
 
+void MainInterface::changeEvent(QEvent *event)
+{
+    if( event->type() == QEvent::WindowStateChange )
+    {
+        QWindowStateChangeEvent *windowStateChangeEvent = static_cast<QWindowStateChangeEvent*>(event);
+        Qt::WindowStates newState = windowState();
+        Qt::WindowStates oldState = windowStateChangeEvent->oldState();
+
+        if( newState & Qt::WindowMinimized )
+        {
+            b_hasPausedWhenMinimized = false;
+
+            if( THEMIM->getIM()->playingStatus() == PLAYING_S &&
+                THEMIM->getIM()->hasVideo() &&
+                !THEMIM->getIM()->hasVisualisation() &&
+                var_InheritBool( p_intf, "qt-pause-minimized" ) )
+            {
+                b_hasPausedWhenMinimized = true;
+                THEMIM->pause();
+            }
+        }
+        else if( oldState & Qt::WindowMinimized && !( newState & Qt::WindowMinimized ) )
+        {
+            if( b_hasPausedWhenMinimized )
+            {
+                THEMIM->play();
+            }
+        }
+    }
+
+    QWidget::changeEvent(event);
+}
+
 /************************************************************************
  * D&D Events
  ************************************************************************/
@@ -1217,6 +1273,8 @@ void MainInterface::toggleInterfaceFullScreen()
 static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
                         vlc_value_t old_val, vlc_value_t new_val, void *param )
 {
+    VLC_UNUSED( p_this ); VLC_UNUSED( psz_variable ); VLC_UNUSED( old_val );
+
     intf_thread_t *p_intf = (intf_thread_t *)param;
 
     if( p_intf->pf_show_dialog )
@@ -1234,6 +1292,9 @@ static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
 static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
                        vlc_value_t old_val, vlc_value_t new_val, void *param )
 {
+    VLC_UNUSED( p_this ); VLC_UNUSED( psz_variable ); VLC_UNUSED( old_val );
+    VLC_UNUSED( new_val );
+
     intf_thread_t *p_intf = (intf_thread_t *)param;
     p_intf->p_sys->p_mi->toggleFSC();