[vlc-devel] [PATCH] Qt4: Enable tabs in sout dialog

Edward Wang edward.c.wang at compdigitec.com
Fri Dec 30 02:37:42 CET 2011


On 11-12-29 08:27 PM, Jean-Baptiste Kempf wrote:
> That doesn't mean it isn't accessible with QObject::findChild. Did you 
> try it and it fails? Best regards, 
Thank you very much for the tip, I didn't know you could access private 
and protected objects in Qt this way! Although it sorta defeats the 
point of OOP...

---
  modules/gui/qt4/dialogs/sout.cpp |   24 ++++--------------------
  modules/gui/qt4/dialogs/sout.hpp |    6 ++++--
  2 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/modules/gui/qt4/dialogs/sout.cpp 
b/modules/gui/qt4/dialogs/sout.cpp
index d4a6a1e..9c29389 100644
--- a/modules/gui/qt4/dialogs/sout.cpp
+++ b/modules/gui/qt4/dialogs/sout.cpp
@@ -60,20 +60,10 @@ SoutDialog::SoutDialog( QWidget *parent, 
intf_thread_t *_p_intf, const QString&
                   "when you change the above settings,\n"
                   "but you can change it manually." ) ) ;

-#if 0
-    /* This needs Qt4.5 to be cool */
      ui.destTab->setTabsClosable( true );
+    QTabBar* tb = ui.destTab->findChild<QTabBar*>();
+    tb->tabButton(0, QTabBar::RightSide)->hide();
      CONNECT( ui.destTab, tabCloseRequested( int ), this, closeTab( int 
) );
-#else
-    closeTabButton = new QToolButton( this );
-    ui.destTab->setCornerWidget( closeTabButton );
-    closeTabButton->hide();
-    closeTabButton->setAutoRaise( true );
-    closeTabButton->setIcon( QIcon( ":/toolbar/clear" ) );
-    closeTabButton->setToolTip( qtr("Clear") );
-    BUTTONACT( closeTabButton, closeTab() );
-#endif
-    CONNECT( ui.destTab, currentChanged( int ), this, tabChanged( int ) );
      ui.destTab->setTabIcon( 0, QIcon( 
":/buttons/playlist/playlist_add" ) );

      ui.destBox->addItem( qtr( "File" ) );
@@ -106,17 +96,11 @@ SoutDialog::SoutDialog( QWidget *parent, 
intf_thread_t *_p_intf, const QString&
  #undef CB
  }

-void SoutDialog::tabChanged( int i )
-{
-    closeTabButton->setVisible( (i != 0) );
-}
-
-void SoutDialog::closeTab()
+void SoutDialog::closeTab( int i )
  {
-    int i = ui.destTab->currentIndex();
      if( i == 0 ) return;

-    QWidget *temp = ui.destTab->currentWidget();
+    QWidget* temp = ui.destTab->widget( i );
      ui.destTab->removeTab( i );
      delete temp;
      updateMRL();
diff --git a/modules/gui/qt4/dialogs/sout.hpp 
b/modules/gui/qt4/dialogs/sout.hpp
index b15c1ee..d61b2e4 100644
--- a/modules/gui/qt4/dialogs/sout.hpp
+++ b/modules/gui/qt4/dialogs/sout.hpp
@@ -135,8 +135,10 @@ public slots:
  private slots:
      void ok();
      void cancel();
-    void closeTab();
-    void tabChanged( int );
+    void closeTab() {
+        closeTab( ui.destTab->currentIndex() );
+    }
+    void closeTab( int );
      void addDest();
  };

-- 
1.7.5.4



More information about the vlc-devel mailing list