]> git.sesse.net Git - vlc/commitdiff
Qt4 - MainInterface cleaning, FIXME labelling, Simplification, put the delay of statu...
authorJean-Baptiste Kempf <jb@videolan.org>
Mon, 3 Dec 2007 14:21:35 +0000 (14:21 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Mon, 3 Dec 2007 14:21:35 +0000 (14:21 +0000)
Commit from NYC/NY/Columbia University ;)

12 files changed:
modules/gui/qt4/Modules.am
modules/gui/qt4/components/interface_widgets.cpp
modules/gui/qt4/components/interface_widgets.hpp
modules/gui/qt4/components/open_panels.cpp [moved from modules/gui/qt4/components/open.cpp with 99% similarity]
modules/gui/qt4/components/open_panels.hpp [moved from modules/gui/qt4/components/open.hpp with 100% similarity]
modules/gui/qt4/dialogs/open.cpp
modules/gui/qt4/dialogs/open.hpp
modules/gui/qt4/dialogs_provider.cpp
modules/gui/qt4/input_manager.cpp
modules/gui/qt4/input_manager.hpp
modules/gui/qt4/main_interface.cpp
modules/gui/qt4/main_interface.hpp

index 8a808765a4e167c6653f8d714814520c0e83c9e9..aa66cc58631e5da4686adc527213dcadeb1fa857 100644 (file)
@@ -36,7 +36,7 @@ nodist_SOURCES_qt4 = \
                components/preferences_widgets.moc.cpp \
                components/complete_preferences.moc.cpp \
                components/simple_preferences.moc.cpp \
-               components/open.moc.cpp \
+               components/open_panels.moc.cpp \
                components/interface_widgets.moc.cpp \
                components/playlist/panels.moc.cpp \
                components/playlist/selector.moc.cpp \
@@ -102,7 +102,7 @@ SOURCES_qt4 =       qt4.cpp \
                components/preferences_widgets.cpp \
                components/complete_preferences.cpp \
                components/simple_preferences.cpp \
-               components/open.cpp \
+               components/open_panels.cpp \
                components/interface_widgets.cpp \
                components/playlist/standardpanel.cpp \
                components/playlist/selector.cpp \
@@ -134,7 +134,7 @@ noinst_HEADERS = \
        components/preferences_widgets.hpp \
        components/complete_preferences.hpp \
        components/simple_preferences.hpp \
-       components/open.hpp \
+       components/open_panels.hpp \
        components/interface_widgets.hpp \
        components/playlist/panels.hpp \
        components/playlist/selector.hpp \
index 6a558e96c337ba6411349b889b5a1af6e6cb0836..22a05af5831edfbf1b64168bad7f38349f40c7b8 100644 (file)
@@ -339,6 +339,7 @@ void AdvControlsWidget::frame(){}
  * DA Control Widget !
  *****************************/
 ControlsWidget::ControlsWidget( intf_thread_t *_p_i,
+                                MainInterface *_p_mi,
                                 bool b_advControls,
                                 bool b_shiny ) :
                                 QFrame( NULL ), p_intf( _p_i )
@@ -491,6 +492,7 @@ ControlsWidget::ControlsWidget( intf_thread_t *_p_i,
     setupSmallButton( playlistButton );
     controlLayout->addWidget( playlistButton, 3, 11, Qt::AlignBottom );
     BUTTON_SET_IMG( playlistButton, "" , playlist.png, qtr( "Show playlist" ) );
+    CONNECT( playlistButton, clicked(), _p_mi, togglePlaylist() );
 
     /** extended Settings **/
     QPushButton *extSettingsButton = new QPushButton( "F" );
index 258119071781481b4f5666772b94be0f9a614e2f..70a90a1d1edaa3477ae6d3cdeeedcf43a18d1c8e 100644 (file)
@@ -145,7 +145,7 @@ class ControlsWidget : public QFrame
     Q_OBJECT
 public:
     /* p_intf, advanced control visible or not, blingbling or not */
-    ControlsWidget( intf_thread_t *, bool, bool );
+    ControlsWidget( intf_thread_t *, MainInterface*, bool, bool );
 //    QSize sizeHint() const;
     virtual ~ControlsWidget();
 
similarity index 99%
rename from modules/gui/qt4/components/open.cpp
rename to modules/gui/qt4/components/open_panels.cpp
index cd496d1166e270560a5da405629461bf0c762e20..cff5e85f2254988042a780ba0ca2d61dd7ca80ae 100644 (file)
@@ -28,7 +28,7 @@
 
 
 #include "qt4.hpp"
-#include "components/open.hpp"
+#include "components/open_panels.hpp"
 #include "dialogs/open.hpp"
 #include "dialogs_provider.hpp"
 #include "components/preferences_widgets.hpp"
index 3449a820b156123885ff71a6ada63bf4ea37dfe9..8c3b105008dd90c628c43967c2fb552cb4c205d4 100644 (file)
@@ -24,7 +24,6 @@
 #include "input_manager.hpp"
 
 #include "dialogs/open.hpp"
-#include "components/open.hpp"
 
 #include <QTabWidget>
 #include <QGridLayout>
index 3e083c5a0ebf16a00134eb18d91b05a0fdb4450e..782a60d3fa5a6338bee0119fd4c6a789de8441fc 100644 (file)
@@ -29,7 +29,7 @@
 #include "util/qvlcframe.hpp"
 #include "dialogs_provider.hpp"
 #include "ui/open.h"
-#include "components/open.hpp"
+#include "components/open_panels.hpp"
 
 class QString;
 class QToolButton;
index 1eb9ea778123e982a20e15f9c58a09b2d8650fdc..92d4c6f400a86d60769b956a2e14f97dfc513e54 100644 (file)
@@ -77,6 +77,7 @@ DialogsProvider::~DialogsProvider()
 void DialogsProvider::quit()
 {
     vlc_object_kill( p_intf );
+    QApplication::closeAllWindows();
     QApplication::quit();
 }
 
index 39e9b2f3ce20b43e4af058d591a51641be334d80..241999b111d96040c0d4d0d4a3edc21dfb0e8ef1 100644 (file)
@@ -79,6 +79,7 @@ void InputManager::delInput()
     }
 }
 
+//FIXME break that
 void InputManager::update()
 {
     /// \todo Emit the signals only if it changed
@@ -122,14 +123,15 @@ void InputManager::update()
     {
         val.i_int = 0;
         var_Change( p_input, "chapter", VLC_VAR_CHOICESCOUNT, &val, NULL );
-        if( val.i_int > 0 )
+        emit navigationChanged( (val.i_int > 0) ? 1 : 2 );
+        /*if( val.i_int > 0 )
         {
             emit navigationChanged( 1 ); // 1 = chapter, 2 = title, 0 = NO
         }
         else
         {
             emit navigationChanged( 2 );
-        }
+        }*/
     }
     else
     {
@@ -180,24 +182,23 @@ void InputManager::update()
 
 void InputManager::sliderUpdate( float new_pos )
 {
-    if( hasInput() )
-        var_SetFloat( p_input, "position", new_pos );
+    if( hasInput() ) var_SetFloat( p_input, "position", new_pos );
 }
 
 void InputManager::togglePlayPause()
 {
     vlc_value_t state;
     var_Get( p_input, "state", &state );
-    if( state.i_int != PAUSE_S )
-    {
+    state.i_int = ( ( state.i_int != PAUSE_S ) ? PAUSE_S : PLAYING_S );
+    /*{
         /* A stream is being played, pause it */
-        state.i_int = PAUSE_S;
+       /* state.i_int = PAUSE_S;
     }
     else
     {
         /* Stream is paused, resume it */
-        state.i_int = PLAYING_S;
-    }
+        /*state.i_int = PLAYING_S;
+    }*/
     var_Set( p_input, "state", state );
     emit statusChanged( state.i_int );
 }
index 26f1ea90b90905e096de2d8021d2bb27791431be..fcfa4df5683fce6d95fd2c1249c237fe623d47fb 100644 (file)
@@ -42,11 +42,11 @@ public:
     bool hasVideo() { return b_has_video; }
     bool b_has_audio, b_has_video, b_had_audio, b_had_video;
 private:
-    intf_thread_t *p_intf;
+    intf_thread_t  *p_intf;
     input_thread_t *p_input;
-    int i_old_playing_status;
-    QString old_name;
-    int i_rate;
+    int             i_old_playing_status;
+    QString         old_name;
+    int             i_rate;
 public slots:
     void togglePlayPause();
     void update(); ///< Periodic updates
@@ -89,11 +89,12 @@ public:
     InputManager *getIM() { return im; };
 
 private:
-    InputManager *im;
-    intf_thread_t *p_intf;
-    input_thread_t *p_input;
-    static MainInputManager *instance;
     MainInputManager( intf_thread_t *);
+
+    InputManager            *im;
+    intf_thread_t           *p_intf;
+    input_thread_t          *p_input;
+    static MainInputManager *instance;
 public slots:
     void togglePlayPause();
     void stop();
@@ -105,5 +106,4 @@ signals:
     void inputChanged( input_thread_t *);
 };
 
-
 #endif
index e81f36c5628e3b2f3e3d9aa5027fe366b232173e..de2635dc5192e227959ea478b42aec5b91457eb9 100644 (file)
@@ -84,9 +84,9 @@ static int DoControl( intf_thread_t *p_intf, void *p_win, int i_q, va_list a )
 MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
 {
     /* Variables initialisation */
-    need_components_update = false;
+    // need_components_update = false;
     bgWidget = NULL; videoWidget = NULL; playlistWidget = NULL;
-    embeddedPlaylistWasActive = videoIsActive = false;
+    videoIsActive = false;
     input_name = "";
 
     /**
@@ -95,17 +95,18 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     if( config_GetInt( p_intf, "privacy-ask") )
     {
         QList<ConfigControl *> controls;
-        privacyDialog( controls );
-
-        QList<ConfigControl *>::Iterator i;
-        for(  i = controls.begin() ; i != controls.end() ; i++ )
+        if( privacyDialog( controls ) == QDialog::Accepted )
         {
-            ConfigControl *c = qobject_cast<ConfigControl *>(*i);
-            c->doApply( p_intf );
-        }
+            QList<ConfigControl *>::Iterator i;
+            for(  i = controls.begin() ; i != controls.end() ; i++ )
+            {
+                ConfigControl *c = qobject_cast<ConfigControl *>(*i);
+                c->doApply( p_intf );
+            }
 
-        config_PutInt( p_intf,  "privacy-ask" , 0 );
-        config_SaveConfigFile( p_intf, NULL );
+            config_PutInt( p_intf,  "privacy-ask" , 0 );
+            config_SaveConfigFile( p_intf, NULL );
+        }
     }
 
     /**
@@ -122,15 +123,16 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
 
     /* Set The Video In emebedded Mode or not */
     videoEmbeddedFlag = false;
-    if( config_GetInt( p_intf, "embedded-video" ) )
-        videoEmbeddedFlag = true;
+    if( config_GetInt( p_intf, "embedded-video" ) ) videoEmbeddedFlag = true;
 
+    /* Are we in the enhanced always-video mode or not ? */
     alwaysVideoFlag = false;
     if( videoEmbeddedFlag && config_GetInt( p_intf, "qt-always-video" ) )
         alwaysVideoFlag = true;
 
     /* Set the other interface settings */
-    visualSelectorEnabled = settings->value( "visual-selector", false ).toBool();
+    //FIXME I don't like that code
+    visualSelectorEnabled = settings->value( "visual-selector", false ).toBool(); 
     notificationEnabled = config_GetInt( p_intf, "qt-notification" )
                           ? true : false;
 
@@ -142,7 +144,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
 
     /* Create a Dock to get the playlist */
     dockPL = new QDockWidget( qtr("Playlist"), this );
-    dockPL->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::MinimumExpanding );
+    dockPL->setSizePolicy( QSizePolicy::Preferred,
+                           QSizePolicy::MinimumExpanding );
     dockPL->setFeatures( QDockWidget::AllDockWidgetFeatures );
     dockPL->setAllowedAreas( Qt::LeftDockWidgetArea
                            | Qt::RightDockWidgetArea
@@ -216,7 +219,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     /* Init input manager */
     MainInputManager::getInstance( p_intf );
     ON_TIMEOUT( updateOnTimer() );
-    //ON_TIMEOUT( debug() );
+    //ON_TIMEOUT( debug() ):;
 
     /********************
      * Various CONNECTs *
@@ -281,7 +284,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     // DEBUG FIXME
     hide();
 
-
     updateGeometry();
     settings->endGroup();
 }
@@ -341,31 +343,28 @@ void MainInterface::setVLCWindowsTitle( QString aTitle )
 void MainInterface::handleMainUi( QSettings *settings )
 {
     /* Create the main Widget and the mainLayout */
-    QWidget *main = new QWidget( this );
-    mainLayout = new QVBoxLayout( main );
+    QWidget *main = new QWidget;
     setCentralWidget( main );
+    mainLayout = new QVBoxLayout( main );
 
     /* Margins, spacing */
     main->setContentsMargins( 0, 0, 0, 0 );
     mainLayout->setMargin( 0 );
 
     /* Create the CONTROLS Widget */
-    bool b_shiny = config_GetInt( p_intf, "qt-blingbling" );
-    controls = new ControlsWidget( p_intf,
+    /* bool b_shiny = config_GetInt( p_intf, "qt-blingbling" ); */
+    controls = new ControlsWidget( p_intf, this, 
                    settings->value( "adv-controls", false ).toBool(),
-                   b_shiny );
-
-    /* Configure the Controls, the playlist button doesn't trigger THEDP
-       but the toggle from this MainInterface */
-    BUTTONACT( controls->playlistButton, togglePlaylist() );
+                   config_GetInt( p_intf, "qt-blingbling" ) );
 
     /* Add the controls Widget to the main Widget */
-    mainLayout->addWidget( controls );
+    mainLayout->insertWidget( 0, controls );
 
     /* Create the Speed Control Widget */
     speedControl = new SpeedControlWidget( p_intf );
     speedControlMenu = new QMenu( this );
-    QWidgetAction *widgetAction = new QWidgetAction( this );
+
+    QWidgetAction *widgetAction = new QWidgetAction( speedControl );
     widgetAction->setDefaultWidget( speedControl );
     speedControlMenu->addAction( widgetAction );
 
@@ -382,7 +381,7 @@ void MainInterface::handleMainUi( QSettings *settings )
     {
         bgWidget = new BackgroundWidget( p_intf );
         bgWidget->widgetSize = settings->value( "backgroundSize",
-                                           QSize( 300, 300 ) ).toSize();
+                                           QSize( 300, 200 ) ).toSize();
         bgWidget->resize( bgWidget->widgetSize );
         bgWidget->updateGeometry();
         mainLayout->insertWidget( 0, bgWidget );
@@ -405,7 +404,7 @@ void MainInterface::handleMainUi( QSettings *settings )
     updateGeometry();
 }
 
-void MainInterface::privacyDialog( QList<ConfigControl *> controls )
+int MainInterface::privacyDialog( QList<ConfigControl *> controls )
 {
     QDialog *privacy = new QDialog( this );
 
@@ -467,7 +466,7 @@ void MainInterface::privacyDialog( QList<ConfigControl *> controls )
     gLayout->addWidget( ok, 2, 2 );
 
     CONNECT( ok, clicked(), privacy, accept() );
-    privacy->exec();
+    return privacy->exec();
 }
 
 //FIXME remove me at the end...
@@ -506,7 +505,7 @@ QSize MainInterface::sizeHint() const
 }
 
 #if 0
-/* This is dead code and need to be removed AT THE END */
+/* FIXME This is dead code and need to be removed AT THE END */
 void MainInterface::resizeEvent( QResizeEvent *e )
 {
     if( videoWidget )
@@ -765,7 +764,8 @@ void MainInterface::setDisplayPosition( float pos, int time, int length )
 
 void MainInterface::toggleTimeDisplay()
 {
-    b_remainingTime = ( b_remainingTime ? false : true );
+    b_remainingTime = !b_remainingTime;
+    //b_remainingTime = ( b_remainingTime ? false : true );
 }
 
 void MainInterface::setName( QString name )
@@ -795,14 +795,14 @@ void MainInterface::setRate( int rate )
     speedControl->updateControls( rate );
 }
 
+//FIXME Remove this function at the end...
 void MainInterface::updateOnTimer()
 {
-    /* \todo Make this event-driven */
-    if( intf_ShouldDie( p_intf ) )
+ /*   if( intf_ShouldDie( p_intf ) )
     {
         QApplication::closeAllWindows();
         QApplication::quit();
-    }
+    }*/
 #if 0
     if( need_components_update )
     {
@@ -843,6 +843,7 @@ void MainInterface::createSystray()
  */
 void MainInterface::toggleUpdateSystrayMenu()
 {
+    /* If hidden, show it */
     if( isHidden() )
     {
         show();
@@ -850,11 +851,13 @@ void MainInterface::toggleUpdateSystrayMenu()
     }
     else if( isMinimized() )
     {
+        /* Minimized */
         showNormal();
         activateWindow();
     }
     else
     {
+        /* Visible */
 #ifdef WIN32
         /* check if any visible window is above vlc in the z-order,
          * but ignore the ones always on top */
@@ -891,7 +894,7 @@ void MainInterface::handleSystrayClick(
         case QSystemTrayIcon::MiddleClick:
             sysTray->showMessage( qtr( "VLC media player" ),
                     qtr( "Control menu for the player" ),
-                    QSystemTrayIcon::Information, 4000 );
+                    QSystemTrayIcon::Information, 3000 );
             break;
     }
 }
@@ -912,7 +915,7 @@ void MainInterface::updateSystrayTooltipName( QString name )
         if( notificationEnabled && ( isHidden() || isMinimized() ) )
         {
             sysTray->showMessage( qtr( "VLC media player" ), name,
-                    QSystemTrayIcon::NoIcon, 4000 );
+                    QSystemTrayIcon::NoIcon, 3000 );
         }
     }
 }
@@ -926,6 +929,7 @@ void MainInterface::updateSystrayTooltipStatus( int i_status )
     switch( i_status )
     {
         case  0:
+        case  END_S:
             {
                 sysTray->setToolTip( qtr( "VLC media player" ) );
                 break;
@@ -1047,6 +1051,8 @@ void MainInterface::closeEvent( QCloseEvent *e )
 {
     hide();
     vlc_object_kill( p_intf );
+    QApplication::closeAllWindows();
+    QApplication::quit();
 }
 
 /*****************************************************************************
index 43d62be2a15135414ceeb80b783626c2a61f264c..00887a6e2f51aed0ff0661cd422ff499db8f7274 100644 (file)
@@ -99,14 +99,13 @@ private:
     void handleSystray();
 
     void createSystray();
-    void privacyDialog( QList<ConfigControl *> controls );
+    int privacyDialog( QList<ConfigControl *> controls );
 
     /* Video */
     VideoWidget         *videoWidget;
     virtual void keyPressEvent( QKeyEvent *);
     virtual void wheelEvent( QWheelEvent * );
 
-    bool                 embeddedPlaylistWasActive;
     bool                 videoIsActive;
     QSize                savedVideoSize;