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

Edward Wang edward.c.wang at compdigitec.com
Thu Dec 29 23:45:01 CET 2011


On 11-12-29 05:27 PM, Jean-Baptiste Kempf wrote:
> I already dismissed this kind of patch because it added the close on 
> the first tab. But it seems you found a way..
Sorry, the previous patch had missed a file, you can now safely commit 
this patch...

---
  modules/gui/qt4/Modules.am             |    2 +
  modules/gui/qt4/dialogs/sout.cpp       |   12 +++++----
  modules/gui/qt4/dialogs/sout.hpp       |    5 +++-
  modules/gui/qt4/dialogs_provider.cpp   |    2 +-
  modules/gui/qt4/ui/sout.ui             |    8 +++++-
  modules/gui/qt4/util/qvlctabwidget.hpp |   41 
++++++++++++++++++++++++++++++++
  6 files changed, 62 insertions(+), 8 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..13e107f 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();
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/dialogs_provider.cpp 
b/modules/gui/qt4/dialogs_provider.cpp
index b8f5cf4..ae36c05 100644
--- a/modules/gui/qt4/dialogs_provider.cpp
+++ b/modules/gui/qt4/dialogs_provider.cpp
@@ -449,7 +449,7 @@ void DialogsProvider::addFromSimple( bool pl, bool go)
      {
          QString url = toURI( toNativeSeparators( file ) );
          playlist_Add( THEPL, qtu( url ), NULL, PLAYLIST_APPEND | mode,
-                      PLAYLIST_END, pl, pl_Unlocked );
+                      3, pl, pl_Unlocked );
          RecentsMRL::getInstance( p_intf )->addRecent( url );
          mode = PLAYLIST_PREPARSE;
      }
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