]> git.sesse.net Git - vlc/commitdiff
Don't laugh
authorClément Stenac <zorglub@videolan.org>
Thu, 8 Jun 2006 20:54:20 +0000 (20:54 +0000)
committerClément Stenac <zorglub@videolan.org>
Thu, 8 Jun 2006 20:54:20 +0000 (20:54 +0000)
modules/gui/qt4/input_manager.cpp
modules/gui/qt4/main_interface.cpp
modules/gui/qt4/main_interface.hpp
modules/gui/qt4/ui/main_interface.ui

index 4d8dc1e31192e574b06f0d11065e8414333f4b5c..3ccff8744d5bdad0a4a632ced5455dc5ba1359a5 100644 (file)
@@ -52,8 +52,8 @@ void InputManager::update()
     if( p_input->b_dead )
     {
         emit positionUpdated( 0.0, 0, 0 );
-       emit navigationChanged( 0 );
-       emit statusChanged( 0 ); // 0 = STOPPED, 1 = PAUSE, 2 = PLAY
+        emit navigationChanged( 0 );
+        emit statusChanged( 0 ); // 0 = STOPPED, 1 = PAUSE, 2 = PLAY
     }
 
     /* Update position */
@@ -71,14 +71,14 @@ void InputManager::update()
     {
         vlc_value_t val;
         var_Change( p_input, "chapter", VLC_VAR_CHOICESCOUNT, &val, NULL );
-       if( val.i_int > 0 )
-           emit navigationChanged( 1 ); // 1 = chapter, 2 = title, 3 = NO
-       else
-           emit navigationChanged( 2 );
+    if( val.i_int > 0 )
+        emit navigationChanged( 1 ); // 1 = chapter, 2 = title, 3 = NO
+    else
+        emit navigationChanged( 2 );
     }
     else
     {
-       emit navigationChanged( 0 );
+        emit navigationChanged( 0 );
     }
 
     /* Update text */
@@ -87,13 +87,13 @@ void InputManager::update()
         p_input->input.p_item->p_meta->psz_nowplaying &&
         *p_input->input.p_item->p_meta->psz_nowplaying )
     {
-       text.sprintf( "%s - %s", 
-                     p_input->input.p_item->p_meta->psz_nowplaying,
-                     p_input->input.p_item->psz_name );
+        text.sprintf( "%s - %s",
+                  p_input->input.p_item->p_meta->psz_nowplaying,
+                  p_input->input.p_item->psz_name );
     }
     else
     {
-       text.sprintf( "%s", p_input->input.p_item->psz_name );
+        text.sprintf( "%s", p_input->input.p_item->psz_name );
     }
     emit nameChanged( text );
 
index e4eb476d460848f765a402749fb19cf5735bca15..5f8c7a83496c1ad8761c3d2411efbd7161b8f617 100644 (file)
 MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
 {
     /* Init UI */
-    slider = new InputSlider( Qt::Horizontal, this );
+    setWindowTitle( _("VLC media player") );
+    ui.setupUi( this );
+    slider = new InputSlider( Qt::Horizontal, ui.sliderBox );
+    QVBoxLayout *box_layout = new QVBoxLayout();
+    box_layout->addWidget( slider );
+    ui.sliderBox->setLayout( box_layout );
 
     /* Init input manager */
     p_input = NULL;
     main_input_manager = new InputManager( this, p_intf );
 
-//    QPushButton *button = new QPushButton( "prefs", this );
-//    connect( button, SIGNAL( clicked() ),
-//             DialogsProvider::getInstance(p_intf), SLOT( prefsDialog() ) );
-
     /* Get timer updates */
     connect( DialogsProvider::getInstance(NULL)->fixed_timer,
              SIGNAL( timeout() ), this, SLOT(updateOnTimer() ) );
@@ -48,19 +49,77 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
     connect( this, SIGNAL( inputChanged( input_thread_t * ) ),
              main_input_manager, SLOT( setInput( input_thread_t * ) ) );
 
-    /* Connect the slider and the input manager (both ways) */
+    /* Connect the input manager to the GUI elements it manages */
     connect( main_input_manager, SIGNAL(positionUpdated( float, int, int ) ),
              slider, SLOT( setPosition( float,int, int ) ) );
     connect( slider, SIGNAL( sliderDragged( float ) ),
              main_input_manager, SLOT( sliderUpdate( float ) ) );
+    connect( main_input_manager, SIGNAL( positionUpdated( float, int, int ) ),
+             this, SLOT( setDisplay( float, int, int ) ) );
 
-    /* Connect the display and the input manager */
+    /* Actions */
+    connect( ui.playButton, SLOT( clicked() ), this, SLOT( play() ) );
+    connect( ui.stopButton, SLOT( clicked() ), this, SLOT( stop() ) );
+    connect( ui.nextButton, SLOT( clicked() ), this, SLOT( next() ) );
+    connect( ui.prevButton, SLOT( clicked() ), this, SLOT( prev() ) );
 }
 
 MainInterface::~MainInterface()
 {
 }
 
+void MainInterface::stop()
+{
+    /// \todo store playlist globally
+    playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
+                                VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+    if( !p_playlist ) return;
+    playlist_Stop( p_playlist );
+    vlc_object_release( p_playlist );
+}
+void MainInterface::play()
+{
+    /// \todo store playlist globally
+    playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
+                                VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+    if( !p_playlist ) return;
+    playlist_Play( p_playlist );
+    vlc_object_release( p_playlist );
+}
+void MainInterface::prev()
+{
+    /// \todo store playlist globally
+    playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
+                                VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+    if( !p_playlist ) return;
+    playlist_Prev( p_playlist );
+    vlc_object_release( p_playlist );
+}
+void MainInterface::next()
+{
+    /// \todo store playlist globally
+    playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
+                                VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+    if( !p_playlist ) return;
+    playlist_Next( p_playlist );
+    vlc_object_release( p_playlist );
+}
+
+
+
+
+
+
+void MainInterface::setDisplay( float pos, int time, int length )
+{
+    char psz_length[MSTRTIME_MAX_SIZE], psz_time[MSTRTIME_MAX_SIZE];
+    secstotimestr( psz_length, length );
+    secstotimestr( psz_time, time );
+    QString title;
+    title.sprintf( "%s/%s", psz_time, psz_length );
+    ui.sliderBox->setTitle( title );
+}
+
 void MainInterface::updateOnTimer()
 {
     if( p_intf->b_die )
index 2f9e5bb285513697d84f867abaf118b70509273c..db095eb735b4811bb0875e66906c2a841ff4be35 100644 (file)
@@ -24,6 +24,7 @@
 #define _MAIN_INTERFACE_H_
 
 #include <vlc/intf.h>
+#include "ui/main_interface.h"
 #include "util/qvlcframe.hpp"
 
 class InputManager;
@@ -43,8 +44,15 @@ private:
     InputSlider *slider;
     /// Main input associated to the playlist
     input_thread_t *p_input;
+
+    Ui::MainInterfaceUI ui;
 private slots:
+    void setDisplay( float, int, int );
     void updateOnTimer();
+    void play();
+    void stop();
+    void prev();
+    void next();
 signals:
     void inputChanged( input_thread_t *);
 };
index 820e4981afa9180334a5b02589d0f5c4e2d6e4d2..dc83d0911e4d6c916c1196c03f82444e665052bf 100644 (file)
@@ -8,12 +8,12 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>560</width>
-    <height>300</height>
+    <width>450</width>
+    <height>80</height>
    </rect>
   </property>
   <property name="windowTitle" >
-   <string>Form</string>
+   <string>VLC media player</string>
   </property>
   <layout class="QVBoxLayout" >
    <property name="margin" >
       <number>0</number>
      </property>
      <property name="spacing" >
-      <number>6</number>
+      <number>0</number>
      </property>
      <item>
-      <widget class="QFrame" name="sliderFrame" />
-     </item>
-     <item>
-      <spacer>
-       <property name="orientation" >
-        <enum>Qt::Horizontal</enum>
+      <widget class="QGroupBox" name="sliderBox" >
+       <property name="sizePolicy" >
+        <sizepolicy>
+         <hsizetype>5</hsizetype>
+         <vsizetype>5</vsizetype>
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
        </property>
-       <property name="sizeHint" >
-        <size>
-         <width>40</width>
-         <height>20</height>
-        </size>
+       <property name="title" >
+        <string>0:00:00/0:00:00</string>
        </property>
-      </spacer>
+      </widget>
      </item>
      <item>
-      <widget class="QFrame" name="volumeFrame" />
+      <widget class="QFrame" name="frame" >
+       <property name="sizePolicy" >
+        <sizepolicy>
+         <hsizetype>0</hsizetype>
+         <vsizetype>5</vsizetype>
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="frameShape" >
+        <enum>QFrame::StyledPanel</enum>
+       </property>
+       <property name="frameShadow" >
+        <enum>QFrame::Raised</enum>
+       </property>
+      </widget>
      </item>
     </layout>
    </item>
      </property>
      <item>
       <widget class="QPushButton" name="prevButton" >
+       <property name="sizePolicy" >
+        <sizepolicy>
+         <hsizetype>4</hsizetype>
+         <vsizetype>0</vsizetype>
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
        <property name="text" >
         <string>Prev</string>
        </property>
       </widget>
      </item>
      <item>
-      <widget class="QPushButton" name="playButton_2" >
+      <widget class="QPushButton" name="playButton" >
+       <property name="sizePolicy" >
+        <sizepolicy>
+         <hsizetype>4</hsizetype>
+         <vsizetype>0</vsizetype>
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
        <property name="text" >
         <string>Play</string>
        </property>
      </item>
      <item>
       <widget class="QPushButton" name="stopButton" >
+       <property name="sizePolicy" >
+        <sizepolicy>
+         <hsizetype>4</hsizetype>
+         <vsizetype>0</vsizetype>
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
        <property name="text" >
         <string>Stop</string>
        </property>
      </item>
      <item>
       <widget class="QPushButton" name="nextButton" >
+       <property name="sizePolicy" >
+        <sizepolicy>
+         <hsizetype>4</hsizetype>
+         <vsizetype>0</vsizetype>
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
        <property name="text" >
         <string>Next</string>
        </property>