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

Edward Wang edward.c.wang at compdigitec.com
Thu Dec 29 21:08:29 CET 2011


This patch will enable tabs in the sout dialog if possible (given the right Qt version).
Thanks,
	Edward Wang

---
 modules/gui/qt4/Modules.am       |    2 ++
 modules/gui/qt4/dialogs/sout.cpp |   13 ++++++++-----
 modules/gui/qt4/dialogs/sout.hpp |    5 ++++-
 modules/gui/qt4/ui/sout.ui       |    8 +++++++-
 4 files changed, 21 insertions(+), 7 deletions(-)

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..8b5b65a 100644
--- a/modules/gui/qt4/dialogs/sout.cpp
+++ b/modules/gui/qt4/dialogs/sout.cpp
@@ -35,6 +35,7 @@
 #include <QFileDialog>
 #include <QToolButton>
 #include <QSpinBox>
+#include <QtGlobal>
 #include <assert.h>
 
 SoutDialog::SoutDialog( QWidget *parent, intf_thread_t *_p_intf, const QString& inputMRL )
@@ -60,10 +61,12 @@ 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
+#if QT_VERSION >= 0x040500
     /* 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 ) );
+    closeTabButton = NULL;
 #else
     closeTabButton = new QToolButton( this );
     ui.destTab->setCornerWidget( closeTabButton );
@@ -108,15 +111,14 @@ SoutDialog::SoutDialog( QWidget *parent, intf_thread_t *_p_intf, const QString&
 
 void SoutDialog::tabChanged( int i )
 {
-    closeTabButton->setVisible( (i != 0) );
+    if( closeTabButton ) 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();
@@ -163,6 +165,7 @@ void SoutDialog::addDest( )
             break;
         default:
             assert(0);
+            return;
     }
 
     int index = ui.destTab->addTab( db, caption );
diff --git a/modules/gui/qt4/dialogs/sout.hpp b/modules/gui/qt4/dialogs/sout.hpp
index b15c1ee..43375db 100644
--- a/modules/gui/qt4/dialogs/sout.hpp
+++ b/modules/gui/qt4/dialogs/sout.hpp
@@ -135,7 +135,10 @@ public slots:
 private slots:
     void ok();
     void cancel();
-    void closeTab();
+    void closeTab() {
+        closeTab( ui.destTab->currentIndex() );
+    }
+    void closeTab( int );
     void tabChanged( 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/>
-- 
1.7.5.4




More information about the vlc-devel mailing list