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

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


On 11-12-29 08:13 PM, Jean-Baptiste Kempf wrote:
> A new class, just for a getter, used only once? Why not using 
> something simpler, like QObject::findChild ?
Can't do that, it is the QTabBar in question is protected and can only 
be accessed via a subclass, reference QT docs: 
http://developer.qt.nokia.com/doc/qt-4.8/QTabWidget.html

All other issues addressed. Sorry about the playlist thing, that was a 
fragment of my next patch that somehow got mixed in there...

---
  modules/gui/qt4/Modules.am             |    2 +
  modules/gui/qt4/dialogs/sout.cpp       |   23 ++---------------
  modules/gui/qt4/dialogs/sout.hpp       |    6 +++-
  modules/gui/qt4/ui/sout.ui             |    8 +++++-
  modules/gui/qt4/util/qvlctabwidget.hpp |   41 
++++++++++++++++++++++++++++++++
  5 files changed, 57 insertions(+), 23 deletions(-)
  create mode 100644 modules/gui/qt4/util/qvlctabwidget.hpp

diff --git a/modules/gui/qt4/Modules.am b/modules/gui/qt4/Modules.am
index 988148a..57439a7 100644
--- a/modules/gui/qt4/Modules.am
+++ b/modules/gui/qt4/Modules.am
@@ -73,6 +73,7 @@ nodist_SOURCES_qt4 = \
          util/searchlineedit.moc.cpp \
          util/qmenuview.moc.cpp \
          util/qvlcapp.moc.cpp \
+        util/qvlctabwidget.moc.cpp \
          util/pictureflow.moc.cpp \
          util/buttons/RoundButton.moc.cpp \
          util/buttons/DeckButtonsLayout.moc.cpp \
@@ -395,6 +396,7 @@ noinst_HEADERS = \
      util/searchlineedit.hpp \
      util/qvlcframe.hpp \
      util/qvlcapp.hpp \
+    util/qvlctabwidget.hpp \
      util/qmenuview.hpp \
      util/qt_dirs.hpp \
      util/registry.hpp \
diff --git a/modules/gui/qt4/dialogs/sout.cpp 
b/modules/gui/qt4/dialogs/sout.cpp
index d4a6a1e..c3a1538 100644
--- a/modules/gui/qt4/dialogs/sout.cpp
+++ b/modules/gui/qt4/dialogs/sout.cpp
@@ -60,20 +60,9 @@ 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 );
+    ui.destTab->getTabBar()->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 +95,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();
  };

diff --git a/modules/gui/qt4/ui/sout.ui b/modules/gui/qt4/ui/sout.ui
index 33b835f..84a8e21 100644
--- a/modules/gui/qt4/ui/sout.ui
+++ b/modules/gui/qt4/ui/sout.ui
@@ -66,7 +66,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
- <widget class="QTabWidget" name="destTab">
+ <widget class="QVLCTabWidget" name="destTab">
<property name="currentIndex">
<number>0</number>
</property>
@@ -243,6 +243,12 @@
<header>components/sout/sout_widgets.hpp</header>
<container>1</container>
</customwidget>
+ <customwidget>
+ <class>QVLCTabWidget</class>
+ <extends>QTabWidget</extends>
+ <header>util/qvlctabwidget.hpp</header>
+ <container>1</container>
+ </customwidget>
</customwidgets>
<resources/>
<connections/>
diff --git a/modules/gui/qt4/util/qvlctabwidget.hpp 
b/modules/gui/qt4/util/qvlctabwidget.hpp
new file mode 100644
index 0000000..17587a0
--- /dev/null
+++ b/modules/gui/qt4/util/qvlctabwidget.hpp
@@ -0,0 +1,41 @@
+/*****************************************************************************
+ * qvlctabwidget.hpp : Tab widget subclass to allow access to tabBar()
+ 
*****************************************************************************
+ * Copyright (C) 2011 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Edward Wang <edward.c.wang at compdigitec.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 
02110-1301, USA.
+ 
*****************************************************************************/
+
+#ifndef _QVLC_TABWIDGET_H_
+#define _QVLC_TABWIDGET_H_
+
+#include <QTabWidget>
+
+class QVLCTabWidget : public QTabWidget
+{
+    Q_OBJECT
+public:
+    QVLCTabWidget() : QTabWidget() {};
+    QVLCTabWidget( QWidget* parent )
+    : QTabWidget(parent) {
+
+    }
+    QTabBar* getTabBar() { return tabBar(); };
+};
+
+#endif
-- 
1.7.5.4






More information about the vlc-devel mailing list