]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/main_interface.cpp
qt4: add the hability to put the *interface* in fullscreen (hotkey: F11)
[vlc] / modules / gui / qt4 / main_interface.cpp
index bbb3a9fc0258f7cf4f923425af985db553c9a706..3c5943fc7d8c7ca774c93241c9b3753eb1f86d5c 100644 (file)
@@ -51,6 +51,7 @@
 #include <QToolBar>
 #include <QGroupBox>
 #include <QDate>
+#include <QProgressBar>
 
 #include <assert.h>
 #include <vlc_keys.h>
@@ -91,6 +92,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     bgWidget = NULL; videoWidget = NULL; playlistWidget = NULL;
     videoIsActive = false;
     input_name = "";
+    playlistVisible = false;
 
     /* Ask for privacy */
     privacy();
@@ -149,6 +151,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     /* Widgets Creation*/
     b_remainingTime = false;
     timeLabel = new TimeLabel;
+    timeLabel->setText( " --:--/--:-- " );
+    timeLabel->setAlignment( Qt::AlignRight );
     nameLabel = new QLabel;
     nameLabel->setTextInteractionFlags( Qt::TextSelectableByMouse
                                       | Qt::TextSelectableByKeyboard );
@@ -160,10 +164,14 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     speedLabel->setFrameStyle( QFrame::Sunken | QFrame::Panel );
     nameLabel->setFrameStyle( QFrame::Sunken | QFrame::StyledPanel);
 
+    pgBar = new QProgressBar;
+    pgBar->hide();
+
     /* and adding those */
     statusBar()->addWidget( nameLabel, 8 );
     statusBar()->addPermanentWidget( speedLabel, 0 );
-    statusBar()->addPermanentWidget( timeLabel, 2 );
+    statusBar()->addPermanentWidget( pgBar, 0 );
+    statusBar()->addPermanentWidget( timeLabel, 0 );
 
     /* timeLabel behaviour:
        - double clicking opens the goto time dialog
@@ -285,24 +293,45 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
 
     move( settings->value( "pos", QPoint( 0, 0 ) ).toPoint() );
 
-    resize( settings->value( "size", QSize( 350, 60 ) ).toSize() );
-    updateGeometry();
+    QSize newSize = settings->value( "size", QSize( 350, 60 ) ).toSize();
+    if( newSize.isValid() )
+    {
+        resize( newSize );
+    }
+    else
+    {
+        msg_Warn( p_intf, "Invalid size in constructor" );
+    }
 
+    int tgPlay = settings->value( "playlist-visible", 0 ).toInt();
     settings->endGroup();
+
+    if( tgPlay )
+    {
+        togglePlaylist();
+    }
+
+    updateGeometry();
+
 }
 
 MainInterface::~MainInterface()
 {
+    msg_Dbg( p_intf, "Destroying the main interface" );
+
     if( playlistWidget ) playlistWidget->savingSettings( settings );
     if( ExtendedDialog::exists() )
         ExtendedDialog::getInstance( p_intf )->savingSettings();
 
     settings->beginGroup( "MainWindow" );
-    settings->setValue( "playlist-floats", dockPL->isFloating() );
+    settings->setValue( "playlist-floats", (int)(dockPL->isFloating()) );
+    settings->setValue( "playlist-visible", (int)playlistVisible );
     settings->setValue( "adv-controls",
                         getControlsVisibilityStatus() & CONTROLS_ADVANCED );
     settings->setValue( "pos", pos() );
     settings->setValue( "size", size() );
+    if( bgWidget )
+        settings->setValue( "backgroundSize", bgWidget->size() );
 
     settings->endGroup();
     delete settings;
@@ -323,6 +352,7 @@ MainInterface::~MainInterface()
     p_intf->pf_request_window = NULL;
     p_intf->pf_release_window = NULL;
     p_intf->pf_control_window = NULL;
+    p_intf->p_sys->p_mi = NULL;
 }
 
 /*****************************
@@ -386,9 +416,8 @@ void MainInterface::handleMainUi( QSettings *settings )
     if( alwaysVideoFlag )
     {
         bgWidget = new BackgroundWidget( p_intf );
-        bgWidget->widgetSize = settings->value( "backgroundSize",
-                                           QSize( 300, 200 ) ).toSize();
-        bgWidget->resize( bgWidget->widgetSize );
+        bgWidget->resize(
+             settings->value( "backgroundSize", QSize( 300, 150 ) ).toSize() );
         bgWidget->updateGeometry();
         mainLayout->insertWidget( 0, bgWidget );
         CONNECT( this, askBgWidgetToToggle(), bgWidget, toggle() );
@@ -397,9 +426,6 @@ void MainInterface::handleMainUi( QSettings *settings )
     if( videoEmbeddedFlag )
     {
         videoWidget = new VideoWidget( p_intf );
-        //videoWidget->widgetSize = QSize( 16, 16 );
-        //videoWidget->hide();
-        //videoWidget->resize( videoWidget->widgetSize );
         mainLayout->insertWidget( 0, videoWidget );
 
         p_intf->pf_request_window  = ::DoRequest;
@@ -446,13 +472,12 @@ int MainInterface::privacyDialog( QList<ConfigControl *> controls )
     QGridLayout *blablaLayout = new QGridLayout( blabla );
     QLabel *text = new QLabel( qtr(
         "<p>The <i>VideoLAN Team</i> doesn't like when an application goes "
-        "online without authorisation.</p>\n "
+        "online without authorization.</p>\n "
         "<p><i>VLC media player</i> can request limited information on "
-        "Internet, espically to get CD Covers and songs metadata or to know "
+        "the Internet, especially to get CD covers and songs metadata or to know "
         "if updates are available.</p>\n"
         "<p><i>VLC media player</i> <b>DOES NOT</b> send or collect <b>ANY</b> "
-        "information, even anonymously about your "
-        "usage.</p>\n"
+        "information, even anonymously, about your usage.</p>\n"
         "<p>Therefore please check the following options, the default being "
         "almost no access on the web.</p>\n") );
     text->setWordWrap( true );
@@ -489,8 +514,9 @@ int MainInterface::privacyDialog( QList<ConfigControl *> controls )
 
     CONFIG_GENERIC( "album-art", IntegerList ); line++;
     CONFIG_GENERIC_NOBOOL( "fetch-meta", Bool ); line++;
+#ifdef UPDATE_CHECK
     CONFIG_GENERIC_NOBOOL( "qt-updates-notif", Bool );
-
+#endif
     QPushButton *ok = new QPushButton( qtr( "Ok" ) );
 
     gLayout->addWidget( ok, 2, 2 );
@@ -502,8 +528,8 @@ int MainInterface::privacyDialog( QList<ConfigControl *> controls )
 //FIXME remove me at the end...
 void MainInterface::debug()
 {
-    msg_Dbg( p_intf, "size: %i - %i", controls->size().height(), controls->size().width() );
-    msg_Dbg( p_intf, "sizeHint: %i - %i", controls->sizeHint().height(), controls->sizeHint().width() );
+    msg_Dbg( p_intf, "size: %i - %i", size().height(), size().width() );
+    msg_Dbg( p_intf, "sizeHint: %i - %i", sizeHint().height(), sizeHint().width() );
 }
 
 /**********************************************************************
@@ -520,16 +546,19 @@ void MainInterface::debug()
 */
 QSize MainInterface::sizeHint() const
 {
-    int nwidth = controls->sizeHint().width();
-    int nheight = controls->sizeHint().height();
-                + menuBar()->size().height()
-                + statusBar()->size().height();
+    int nwidth  = controls->sizeHint().width();
+    int nheight = controls->isVisible() ?
+                  controls->size().height()
+                  + menuBar()->size().height()
+                  + statusBar()->size().height()
+                  : 0 ;
 
     msg_Dbg( p_intf, "1 %i %i", nheight, nwidth );
     if( VISIBLE( bgWidget ) )
     {
         nheight += bgWidget->size().height();
         nwidth  = bgWidget->size().width();
+        msg_Dbg( p_intf, "1b %i %i", nheight, nwidth );
     }
     else if( videoIsActive )
     {
@@ -537,10 +566,10 @@ QSize MainInterface::sizeHint() const
         nwidth  = videoWidget->size().width();
         msg_Dbg( p_intf, "2 %i %i", nheight, nwidth );
     }
-    if( !dockPL->isFloating() && dockPL->widget() )
+    if( !dockPL->isFloating() && dockPL->isVisible() && dockPL->widget()  )
     {
         nheight += dockPL->size().height();
-        nwidth = MAX( nwidth, dockPL->size().width() );
+        nwidth = __MAX( nwidth, dockPL->size().width() );
         msg_Dbg( p_intf, "3 %i %i", nheight, nwidth );
     }
     msg_Dbg( p_intf, "4 %i %i", nheight, nwidth );
@@ -661,8 +690,8 @@ int MainInterface::controlVideo( void *p_window, int i_query, va_list args )
         {
             unsigned int *pi_width  = va_arg( args, unsigned int * );
             unsigned int *pi_height = va_arg( args, unsigned int * );
-            *pi_width = videoWidget->widgetSize.width();
-            *pi_height = videoWidget->widgetSize.height();
+            *pi_width = videoWidget->width();
+            *pi_height = videoWidget->height();
             i_ret = VLC_SUCCESS;
             break;
         }
@@ -702,7 +731,7 @@ void MainInterface::togglePlaylist()
     If no playlist exist, then create one and attach it to the DockPL*/
     if( !playlistWidget )
     {
-        playlistWidget = new PlaylistWidget( p_intf, settings );
+        playlistWidget = new PlaylistWidget( p_intf, settings, dockPL );
 
         /* Add it to the parent DockWidget */
         dockPL->setWidget( playlistWidget );
@@ -711,31 +740,37 @@ void MainInterface::togglePlaylist()
         addDockWidget( Qt::BottomDockWidgetArea, dockPL );
 
         /* Make the playlist floating is requested. Default is not. */
-        //FIXME
-        if( settings->value( "playlist-floats", false ).toBool() );
+        settings->beginGroup( "MainWindow" );
+        if( settings->value( "playlist-floats", 1 ).toInt() )
         {
             msg_Dbg( p_intf, "we don't want the playlist inside");
             dockPL->setFloating( true );
         }
+        settings->endGroup();
+        settings->beginGroup( "playlist" );
+        dockPL->move( settings->value( "pos", QPoint( 0,0 ) ).toPoint() );
+        QSize newSize = settings->value( "size", QSize( 400, 300 ) ).toSize();
+        if( newSize.isValid() )
+            dockPL->resize( newSize );
+        settings->endGroup();
+
         dockPL->show();
+        playlistVisible = true;
     }
     else
     {
     /* toggle the visibility of the playlist */
        TOGGLEV( dockPL );
-       //resize(sizeHint());
+       resize( sizeHint() );
+       playlistVisible = !playlistVisible;
     }
-#if 0
-    doComponentsUpdate();
-#endif
-    updateGeometry();
 }
 
 /* Function called from the menu to undock the playlist */
 void MainInterface::undockPlaylist()
 {
     dockPL->setFloating( true );
-    updateGeometry();
+    resize( sizeHint() );
 }
 
 void MainInterface::toggleMinimalView()
@@ -743,16 +778,16 @@ void MainInterface::toggleMinimalView()
     TOGGLEV( menuBar() );
     TOGGLEV( controls );
     TOGGLEV( statusBar() );
-    updateGeometry();
+    doComponentsUpdate();
 }
 
 /* Video widget cannot do this synchronously as it runs in another thread */
 /* Well, could it, actually ? Probably dangerous ... */
 void MainInterface::doComponentsUpdate()
 {
+    resize( sizeHint() );
     msg_Dbg( p_intf, "Updating the geometry" );
     updateGeometry();
-    resize( sizeHint() );
 }
 
 /* toggling advanced controls buttons */
@@ -800,13 +835,13 @@ void MainInterface::setDisplayPosition( float pos, int time, int length )
     secstotimestr( psz_time, ( b_remainingTime && length ) ? length - time
                                                            : time );
 
-    QString title;
-    title.sprintf( "%s/%s", psz_time,
+    QString timestr;
+    timestr.sprintf( "%s/%s", psz_time,
                             ( !length && time ) ? "--:--" : psz_length );
 
     /* Add a minus to remaining time*/
-    if( b_remainingTime && length ) timeLabel->setText( " -"+title+" " );
-    else timeLabel->setText( " "+title+" " );
+    if( b_remainingTime && length ) timeLabel->setText( " -"+timestr+" " );
+    else timeLabel->setText( " "+timestr+" " );
 }
 
 void MainInterface::toggleTimeDisplay()
@@ -855,8 +890,6 @@ void MainInterface::updateOnTimer()
         need_components_update = false;
     }
 #endif
-
-    controls->updateOnTimer();
 }
 
 /*****************************************************************************
@@ -1099,9 +1132,15 @@ void MainInterface::wheelEvent( QWheelEvent *e )
 void MainInterface::closeEvent( QCloseEvent *e )
 {
     hide();
-    vlc_object_kill( p_intf );
-    QApplication::closeAllWindows();
-    QApplication::quit();
+    THEDP->quit();
+}
+
+void MainInterface::toggleFullScreen( void )
+{
+    if( isFullScreen() )
+        showNormal();
+    else
+        showFullScreen();
 }
 
 /*****************************************************************************
@@ -1127,6 +1166,7 @@ static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
                         vlc_value_t old_val, vlc_value_t new_val, void *param )
 {
     intf_thread_t *p_intf = (intf_thread_t *)param;
+    msg_Dbg( p_this, "Menu Requested" ); // DEBUG to track the non disparition of the menu...
 
     if( p_intf->pf_show_dialog )
     {
@@ -1144,6 +1184,7 @@ static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
                        vlc_value_t old_val, vlc_value_t new_val, void *param )
 {
     intf_thread_t *p_intf = (intf_thread_t *)param;
+    msg_Dbg( p_this, "Intf Show Requested" ); // DEBUG to track the non disparition of the menu...
     //p_intf->p_sys->b_intf_show = VLC_TRUE;
 
     return VLC_SUCCESS;