[vlc-devel] commit: Fix behaviour of the button logic for teletext and use the images. (Jean-Paul Saman )

git version control git at videolan.org
Fri Jun 20 16:37:53 CEST 2008


vlc | branch: master | Jean-Paul Saman <jpsaman at videolan.org> | Fri Jun 20 13:55:54 2008 +0200| [69afa8556007dbb6424cacffb174aa3bb84733f1]

Fix behaviour of the button logic for teletext and use the images.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=69afa8556007dbb6424cacffb174aa3bb84733f1
---

 modules/gui/qt4/components/interface_widgets.cpp |   53 +++++++++++++++++++---
 modules/gui/qt4/components/interface_widgets.hpp |    6 +++
 modules/gui/qt4/input_manager.cpp                |   20 ++++++++
 modules/gui/qt4/input_manager.hpp                |    1 +
 modules/gui/qt4/pixmaps/tvtelx-transparent.png   |  Bin 0 -> 336 bytes
 modules/gui/qt4/pixmaps/tvtelx.png               |  Bin 274 -> 325 bytes
 modules/gui/qt4/vlc.qrc                          |    3 +
 7 files changed, 77 insertions(+), 6 deletions(-)

diff --git a/modules/gui/qt4/components/interface_widgets.cpp b/modules/gui/qt4/components/interface_widgets.cpp
index d5cdcf6..e01ea52 100644
--- a/modules/gui/qt4/components/interface_widgets.cpp
+++ b/modules/gui/qt4/components/interface_widgets.cpp
@@ -460,6 +460,7 @@ ControlsWidget::ControlsWidget( intf_thread_t *_p_i,
              sectionNext() );
     CONNECT( menuButton, clicked(), THEMIM->getIM(),
              sectionMenu() );
+
     /**
      * Telextext QFrame
      * TODO: Merge with upper menu in a StackLayout
@@ -469,17 +470,16 @@ ControlsWidget::ControlsWidget( intf_thread_t *_p_i,
     telexLayout->setSpacing( 0 );
     telexLayout->setMargin( 0 );
 
-    QToolButton *telexOn = new QToolButton;
-    telexOn->setText( qtr( "On" ) );
+    QPushButton  *telexOn = new QPushButton;
     setupSmallButton( telexOn );
     telexLayout->addWidget( telexOn );
 
-    QToolButton *telexTransparent = new QToolButton;
-    telexTransparent->setText( qtr( "Transparent" ) );
+    telexTransparent = new QPushButton;
     setupSmallButton( telexTransparent );
     telexLayout->addWidget( telexTransparent );
+    b_telexTransparent = false;
 
-    QSpinBox *telexPage = new QSpinBox;
+    telexPage = new QSpinBox;
     telexPage->setRange( 0, 999 );
     telexPage->setValue( 100 );
     telexPage->setAccelerated( true );
@@ -489,12 +489,20 @@ ControlsWidget::ControlsWidget( intf_thread_t *_p_i,
     telexLayout->addWidget( telexPage );
 
     controlLayout->addWidget( telexFrame, 1, 10, 2, 3, Qt::AlignBottom );
-    telexFrame->hide();
+    telexFrame->hide(); /* default hidden */
 
     CONNECT( telexPage, valueChanged( int ), THEMIM->getIM(),
              telexGotoPage( int ) );
+
+    BUTTON_SET_ACT_I( telexOn, "", tv.png, qtr( "Teletext on" ),
+                      toggleTeletext() );
     CONNECT( telexOn, clicked( bool ), THEMIM->getIM(),
              telexToggle( bool ) );
+    telexTransparent->setEnabled( false );
+    telexPage->setEnabled( false );
+
+    BUTTON_SET_ACT_I( telexTransparent, "", tvtelx.png, qtr( "Teletext" ),
+                      toggleTeletextTransparency() );
     CONNECT( telexTransparent, clicked( bool ),
              THEMIM->getIM(), telexSetTransparency( bool ) );
     CONNECT( THEMIM->getIM(), teletextEnabled( bool ),
@@ -627,6 +635,39 @@ ControlsWidget::ControlsWidget( intf_thread_t *_p_i,
 ControlsWidget::~ControlsWidget()
 {}
 
+void ControlsWidget::toggleTeletext()
+{
+    bool b_enabled = THEMIM->teletextState();
+    if( b_telexEnabled )
+    {
+        telexTransparent->setEnabled( false );
+        telexPage->setEnabled( false );
+        b_telexEnabled = false;
+    }
+    else if( b_enabled )
+    {
+        telexTransparent->setEnabled( true );
+        telexPage->setEnabled( true );
+        b_telexEnabled = true;
+    }
+}
+
+void ControlsWidget::toggleTeletextTransparency()
+{
+    if( b_telexTransparent )
+    {
+        telexTransparent->setIcon( QIcon( ":/pixmaps/tvtelx.png" ) );
+        telexTransparent->setToolTip( qtr( "Teletext" ) );
+        b_telexTransparent = false;
+    }
+    else
+    {
+        telexTransparent->setIcon( QIcon( ":/pixmaps/tvtelx-transparent.png" ) );
+        telexTransparent->setToolTip( qtr( "Transparent" ) );
+        b_telexTransparent = true;
+    }
+}
+
 void ControlsWidget::stop()
 {
     THEMIM->stop();
diff --git a/modules/gui/qt4/components/interface_widgets.hpp b/modules/gui/qt4/components/interface_widgets.hpp
index 1c50464..a64d266 100644
--- a/modules/gui/qt4/components/interface_widgets.hpp
+++ b/modules/gui/qt4/components/interface_widgets.hpp
@@ -195,6 +195,8 @@ protected:
     InputSlider         *slider;
     QPushButton         *prevSectionButton, *nextSectionButton, *menuButton;
     QPushButton         *playButton, *fullscreenButton, *extSettingsButton;
+    QPushButton         *telexTransparent;
+    QSpinBox            *telexPage;
     QToolButton         *slowerButton, *fasterButton;
     QHBoxLayout         *controlButLayout;
     AdvControlsWidget   *advControls;
@@ -203,6 +205,8 @@ protected:
     VolumeClickHandler  *hVolLabel;
 
     bool                 b_advancedVisible;
+    bool                 b_telexTransparent;
+    bool                 b_telexEnabled;
 protected slots:
     void play();
     void stop();
@@ -216,6 +220,8 @@ protected slots:
     void faster();
     void slower();
     void toggleAdvanced();
+    void toggleTeletext();
+    void toggleTeletextTransparency();
 signals:
     void advancedControlsToggled( bool );
 };
diff --git a/modules/gui/qt4/input_manager.cpp b/modules/gui/qt4/input_manager.cpp
index a5140a9..b7b510c 100644
--- a/modules/gui/qt4/input_manager.cpp
+++ b/modules/gui/qt4/input_manager.cpp
@@ -610,6 +610,26 @@ void MainInputManager::togglePlayPause()
     getIM()->togglePlayPause();
 }
 
+bool MainInputManager::teletextState()
+{
+    im = getIM();
+    if( im->hasInput() )
+    {
+        vlc_value_t val;
+        vlc_object_t *p_vbi;
+        p_vbi = (vlc_object_t *) vlc_object_find_name( getInput(),
+                    "zvbi", FIND_ANYWHERE );
+        if( p_vbi )
+        {
+            vlc_object_release( p_vbi );
+            return true;
+        }
+        var_Change( getInput(), "spu-es", VLC_VAR_CHOICESCOUNT, &val, NULL );
+        return (val.i_int > 0);
+    }
+    return false;
+}
+
 /* Static callbacks */
 
 /* IM */
diff --git a/modules/gui/qt4/input_manager.hpp b/modules/gui/qt4/input_manager.hpp
index b5ea638..402dfe6 100644
--- a/modules/gui/qt4/input_manager.hpp
+++ b/modules/gui/qt4/input_manager.hpp
@@ -149,6 +149,7 @@ private:
     intf_thread_t           *p_intf;
     static MainInputManager *instance;
 public slots:
+    bool teletextState();
     void togglePlayPause();
     void stop();
     void next();
diff --git a/modules/gui/qt4/pixmaps/tvtelx-transparent.png b/modules/gui/qt4/pixmaps/tvtelx-transparent.png
new file mode 100644
index 0000000..4b3c164
Binary files /dev/null and b/modules/gui/qt4/pixmaps/tvtelx-transparent.png differ
diff --git a/modules/gui/qt4/pixmaps/tvtelx.png b/modules/gui/qt4/pixmaps/tvtelx.png
index 0a26f09..34a6a23 100644
Binary files a/modules/gui/qt4/pixmaps/tvtelx.png and b/modules/gui/qt4/pixmaps/tvtelx.png differ
diff --git a/modules/gui/qt4/vlc.qrc b/modules/gui/qt4/vlc.qrc
index 1857650..4d27d37 100644
--- a/modules/gui/qt4/vlc.qrc
+++ b/modules/gui/qt4/vlc.qrc
@@ -43,6 +43,9 @@
   <file>pixmaps/playlist_shuffle_off.png</file>
   <file>pixmaps/playlist_shuffle_on.png</file>
   <file>pixmaps/play.png</file>
+  <file>pixmaps/tvtelx-transparent.png</file>
+  <file>pixmaps/tvtelx.png</file>
+  <file>pixmaps/tv.png</file>
   <file>pixmaps/previous_16px.png</file>
   <file>pixmaps/previous.png</file>
   <file>pixmaps/record_16px.png</file>




More information about the vlc-devel mailing list