]> git.sesse.net Git - vlc/commitdiff
Implement disc chapter selection widget
authorClément Stenac <zorglub@videolan.org>
Sun, 26 Nov 2006 21:35:08 +0000 (21:35 +0000)
committerClément Stenac <zorglub@videolan.org>
Sun, 26 Nov 2006 21:35:08 +0000 (21:35 +0000)
modules/gui/qt4/input_manager.cpp
modules/gui/qt4/input_manager.hpp
modules/gui/qt4/main_interface.cpp
modules/gui/qt4/main_interface.hpp
modules/gui/qt4/ui/main_interface.ui

index 9bb90080f8ecbd7a63308ece688586f5c5062e42..c1dd61a7162d94cca425426adfebd3e7ab2736df 100644 (file)
@@ -107,7 +107,9 @@ 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, 0 = NO
+        }
         else
             emit navigationChanged( 2 );
     }
@@ -166,6 +168,34 @@ void InputManager::togglePlayPause()
     emit statusChanged( state.i_int );
 }
 
+void InputManager::sectionPrev()
+{
+    if( hasInput() )
+    {
+        int i_type = var_Type( p_input, "prev-chapter" );
+        vlc_value_t val; val.b_bool = VLC_TRUE;
+        var_Set( p_input, (i_type & VLC_VAR_TYPE) != 0 ?
+                            "prev-chapter":"prev-title", val );
+    }
+}
+
+void InputManager::sectionNext()
+{
+    if( hasInput() )
+    {
+        int i_type = var_Type( p_input, "prev-chapter" );
+        vlc_value_t val; val.b_bool = VLC_TRUE;
+        var_Set( p_input, (i_type & VLC_VAR_TYPE) != 0 ?
+                            "next-chapter":"next-title", val );
+    }
+}
+
+void InputManager::sectionMenu()
+{
+    if( hasInput() )
+        var_SetInteger( p_input, "title 0", 2);
+}
+
 void InputManager::slower()
 {
     if( hasInput() )
index f35602677c719c51d9cad962303316e70da48262..2905f35859a24d07da2c2c145acb5c399330ed36 100644 (file)
@@ -53,11 +53,16 @@ public slots:
     void slower();
     void faster();
     void normalRate();
+    void sectionNext();
+    void sectionPrev();
+    void sectionMenu();
 signals:
     /// Send new position, new time and new length
     void positionUpdated( float , int, int );
     void nameChanged( QString );
+    /// Used to signal whether we should show navigation buttons
     void navigationChanged( int );
+    /// Play/pause status
     void statusChanged( int );
     void audioStarted();
     void videoStarted();
index 37f11bd6167c3bd81656856e131310d44e4305f5..f795c9aa075c6f05e5159c78e04688451e86bfec 100644 (file)
@@ -126,9 +126,17 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
              this, setDisplay( float, int, int ) );
     CONNECT( THEMIM->getIM(), nameChanged( QString ), this,setName( QString ) );
     CONNECT( THEMIM->getIM(), statusChanged( int ), this, setStatus( int ) );
+    CONNECT( THEMIM->getIM(), navigationChanged( int ), this, setNavigation(int) );
     CONNECT( slider, sliderDragged( float ),
              THEMIM->getIM(), sliderUpdate( float ) );
 
+    CONNECT( ui.prevSectionButton, clicked(), THEMIM->getIM(),
+             sectionPrev() );
+    CONNECT( ui.nextSectionButton, clicked(), THEMIM->getIM(),
+             sectionNext() );
+    CONNECT( ui.menuButton, clicked(), THEMIM->getIM(),
+             sectionMenu() );
+
     var_Create( p_intf, "interaction", VLC_VAR_ADDRESS );
     var_AddCallback( p_intf, "interaction", InteractCallback, this );
     p_intf->b_interaction = VLC_TRUE;
@@ -157,6 +165,10 @@ void MainInterface::handleMainUi( QSettings *settings )
 
     slider = new InputSlider( Qt::Horizontal, NULL );
     ui.hboxLayout->insertWidget( 0, slider );
+    ui.discFrame->hide();
+    BUTTON_SET_IMG( ui.prevSectionButton, "", previous.png, "" );
+    BUTTON_SET_IMG( ui.nextSectionButton, "", next.png, "" );
+    BUTTON_SET_IMG( ui.menuButton, "", previous.png, "" );
 
     BUTTON_SET_ACT_I( ui.prevButton, "" , previous.png,
                       qtr("Previous"), prev() );
@@ -590,6 +602,35 @@ void MainInterface::setStatus( int status )
         ui.playButton->setIcon( QIcon( ":/pixmaps/play.png" ) );
 }
 
+#define HELP_MENU N_("Menu")
+#define HELP_PCH N_("Previous chapter")
+#define HELP_NCH N_("Next chapter")
+#define HELP_PTR N_("Previous track")
+#define HELP_NTR N_("Next track")
+
+void MainInterface::setNavigation( int navigation )
+{
+    // 1 = chapter, 2 = title, 0 = no
+    if( navigation == 0 )
+    {
+        ui.discFrame->hide();
+    } else if( navigation == 1 ) {
+        ui.prevSectionButton->show();
+        ui.prevSectionButton->setToolTip( qfu(HELP_PCH) );
+        ui.nextSectionButton->show();
+        ui.nextSectionButton->setToolTip( qfu(HELP_NCH) );
+        ui.menuButton->show();
+        ui.discFrame->show();
+    } else {
+        ui.prevSectionButton->show();
+        ui.prevSectionButton->setToolTip( qfu(HELP_PCH) );
+        ui.nextSectionButton->show();
+        ui.nextSectionButton->setToolTip( qfu(HELP_NCH) );
+        ui.menuButton->hide();
+        ui.discFrame->show();
+    }
+}
+
 static bool b_my_volume;
 
 void MainInterface::updateOnTimer()
index 52e86938abeec76698d31474dd4be0e7fe5ee450..0f63a7093194804b7ff0821a17f629562db72040 100644 (file)
@@ -99,6 +99,7 @@ private:
 public slots:
     void undockPlaylist();
 private slots:
+    void setNavigation( int );
     void setStatus( int );
     void setName( QString );
     void setDisplay( float, int, int );
index 9b23c2ee20fd5c18853a57505e957f59be04bc58..f39856bc4d3131e010bda9d0d7d5c151d8727cd2 100644 (file)
@@ -1,15 +1,12 @@
 <ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
  <class>MainInterfaceUI</class>
  <widget class="QWidget" name="MainInterfaceUI" >
   <property name="geometry" >
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>426</width>
-    <height>73</height>
+    <width>819</width>
+    <height>384</height>
    </rect>
   </property>
   <property name="sizePolicy" >
      </item>
      <item>
       <widget class="QFrame" name="discFrame" >
-       <property name="sizePolicy" >
-        <sizepolicy>
-         <hsizetype>0</hsizetype>
-         <vsizetype>0</vsizetype>
-         <horstretch>0</horstretch>
-         <verstretch>0</verstretch>
-        </sizepolicy>
-       </property>
+       <layout class="QHBoxLayout" >
+        <property name="margin" >
+         <number>9</number>
+        </property>
+        <property name="spacing" >
+         <number>6</number>
+        </property>
+        <item>
+         <widget class="QPushButton" name="menuButton" >
+          <property name="text" >
+           <string/>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QPushButton" name="prevSectionButton" >
+          <property name="text" >
+           <string/>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QPushButton" name="nextSectionButton" >
+          <property name="text" >
+           <string/>
+          </property>
+         </widget>
+        </item>
+       </layout>
       </widget>
      </item>
     </layout>
    </item>
   </layout>
  </widget>
- <pixmapfunction></pixmapfunction>
  <resources/>
  <connections/>
 </ui>