From 905e5d8ae88a2d56f346fc33590dbe69bb07a5eb Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Kempf <jb@videolan.org>
Date: Mon, 16 Apr 2007 22:52:35 +0000
Subject: [PATCH] Qt4 - Open Dialog. Use #defines for tab naming to avoid
 miscomprehensions. Cosmectics.

---
 modules/gui/qt4/components/open.cpp  |  8 ++++----
 modules/gui/qt4/components/open.hpp  |  6 +++---
 modules/gui/qt4/dialogs/open.cpp     | 28 +++++++++++++++-------------
 modules/gui/qt4/dialogs/open.hpp     |  2 +-
 modules/gui/qt4/dialogs_provider.cpp | 10 +++++-----
 modules/gui/qt4/dialogs_provider.hpp |  4 ++++
 6 files changed, 32 insertions(+), 26 deletions(-)

diff --git a/modules/gui/qt4/components/open.cpp b/modules/gui/qt4/components/open.cpp
index a3fd97fea8f5..2450a6370c40 100644
--- a/modules/gui/qt4/components/open.cpp
+++ b/modules/gui/qt4/components/open.cpp
@@ -216,7 +216,7 @@ void FileOpenPanel::toggleSubtitleFrame()
 /**************************************************************************
  * Disk open
  **************************************************************************/
-DiskOpenPanel::DiskOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
+DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
                                 OpenPanel( _parent, _p_intf )
 {
     ui.setupUi( this );
@@ -230,16 +230,16 @@ DiskOpenPanel::DiskOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     CONNECT( ui.chapterSpin, valueChanged(int), this, updateMRL());
 }
 
-DiskOpenPanel::~DiskOpenPanel()
+DiscOpenPanel::~DiscOpenPanel()
 {}
 
-void DiskOpenPanel::clear()
+void DiscOpenPanel::clear()
 {
     ui.titleSpin->setValue(0);
     ui.chapterSpin->setValue(0);
 }
 
-void DiskOpenPanel::updateMRL()
+void DiscOpenPanel::updateMRL()
 {
     QString mrl = "";
     /* DVD */
diff --git a/modules/gui/qt4/components/open.hpp b/modules/gui/qt4/components/open.hpp
index 7cf2bb1f70d0..257ae381abb5 100644
--- a/modules/gui/qt4/components/open.hpp
+++ b/modules/gui/qt4/components/open.hpp
@@ -103,12 +103,12 @@ private slots:
     void updateAddress();
 };
 
-class DiskOpenPanel: public OpenPanel
+class DiscOpenPanel: public OpenPanel
 {
     Q_OBJECT;
 public:
-    DiskOpenPanel( QWidget *, intf_thread_t * );
-    virtual ~DiskOpenPanel();
+    DiscOpenPanel( QWidget *, intf_thread_t * );
+    virtual ~DiscOpenPanel();
     virtual void clear() ;
 private:
     Ui::OpenDisk ui;
diff --git a/modules/gui/qt4/dialogs/open.cpp b/modules/gui/qt4/dialogs/open.cpp
index 451f693bfbd1..c3f3dc2e7e98 100644
--- a/modules/gui/qt4/dialogs/open.cpp
+++ b/modules/gui/qt4/dialogs/open.cpp
@@ -48,30 +48,32 @@ OpenDialog::OpenDialog( QWidget *parent, intf_thread_t *_p_intf, bool modal,
     resize( 500, 300);
 
     /* Tab definition and creation */
-    fileOpenPanel = new FileOpenPanel( ui.Tab , p_intf );
-    diskOpenPanel = new DiskOpenPanel( ui.Tab , p_intf );
-    netOpenPanel = new NetOpenPanel( ui.Tab , p_intf );
+    fileOpenPanel = new FileOpenPanel( ui.Tab, p_intf );
+    discOpenPanel = new DiscOpenPanel( ui.Tab, p_intf );
+    netOpenPanel = new NetOpenPanel( ui.Tab, p_intf );
     captureOpenPanel = new CaptureOpenPanel( ui.Tab, p_intf );
 
-    ui.Tab->addTab( fileOpenPanel, qtr( "&File" ) );
-    ui.Tab->addTab( diskOpenPanel, qtr( "&Disc" ) );
-    ui.Tab->addTab( netOpenPanel, qtr( "&Network" ) );
-    ui.Tab->addTab( captureOpenPanel, qtr( "Capture &Device" ) );
+    ui.Tab->insertTab( OPEN_FILE_TAB, fileOpenPanel, qtr( "&File" ) );
+    ui.Tab->insertTab( OPEN_DISC_TAB, discOpenPanel, qtr( "&Disc" ) );
+    ui.Tab->insertTab( OPEN_NETWORK_TAB, netOpenPanel, qtr( "&Network" ) );
+    ui.Tab->insertTab( OPEN_CAPTURE_TAB, captureOpenPanel,
+                                qtr( "Capture &Device" ) );
 
     /* Hide the advancedPanel */
     ui.advancedFrame->hide();
 
     /* Buttons Creation */
-    QSizePolicy buttonSizePolicy(static_cast<QSizePolicy::Policy>(7), static_cast<QSizePolicy::Policy>(1));
+    QSizePolicy buttonSizePolicy( static_cast<QSizePolicy::Policy>(7),
+                                  static_cast<QSizePolicy::Policy>(1) );
     buttonSizePolicy.setHorizontalStretch(0);
     buttonSizePolicy.setVerticalStretch(0);
 
     playButton = new QToolButton();
     playButton->setText( qtr( "&Play" ) );
     playButton->setSizePolicy( buttonSizePolicy );
-    playButton->setMinimumSize(QSize(90, 0));
-    playButton->setPopupMode(QToolButton::MenuButtonPopup);
-    playButton->setToolButtonStyle(Qt::ToolButtonTextOnly);
+    playButton->setMinimumSize( QSize(90, 0) );
+    playButton->setPopupMode( QToolButton::MenuButtonPopup );
+    playButton->setToolButtonStyle( Qt::ToolButtonTextOnly );
 
     cancelButton = new QToolButton();
     cancelButton->setText( qtr( "&Cancel" ) );
@@ -96,7 +98,7 @@ OpenDialog::OpenDialog( QWidget *parent, intf_thread_t *_p_intf, bool modal,
 
     CONNECT( fileOpenPanel, mrlUpdated( QString ), this, updateMRL(QString) );
     CONNECT( netOpenPanel, mrlUpdated( QString ), this, updateMRL(QString) );
-    CONNECT( diskOpenPanel, mrlUpdated( QString ), this, updateMRL(QString) );
+    CONNECT( discOpenPanel, mrlUpdated( QString ), this, updateMRL(QString) );
     CONNECT( captureOpenPanel, mrlUpdated( QString ), this,
             updateMRL(QString) );
 
@@ -104,7 +106,7 @@ OpenDialog::OpenDialog( QWidget *parent, intf_thread_t *_p_intf, bool modal,
              this, newMethod(QString) );
     CONNECT( netOpenPanel, methodChanged( QString ),
              this, newMethod(QString) );
-    CONNECT( diskOpenPanel, methodChanged( QString ),
+    CONNECT( discOpenPanel, methodChanged( QString ),
              this, newMethod(QString) );
 
     CONNECT( ui.slaveText, textChanged(QString), this, updateMRL());
diff --git a/modules/gui/qt4/dialogs/open.hpp b/modules/gui/qt4/dialogs/open.hpp
index 4b0026eea087..571b88e4b066 100644
--- a/modules/gui/qt4/dialogs/open.hpp
+++ b/modules/gui/qt4/dialogs/open.hpp
@@ -72,7 +72,7 @@ private:
     Ui::Open ui;
     FileOpenPanel *fileOpenPanel;
     NetOpenPanel *netOpenPanel;
-    DiskOpenPanel *diskOpenPanel;
+    DiscOpenPanel *discOpenPanel;
     CaptureOpenPanel *captureOpenPanel;
 
     QString storedMethod;
diff --git a/modules/gui/qt4/dialogs_provider.cpp b/modules/gui/qt4/dialogs_provider.cpp
index da304ad4ea6d..8642c577a101 100644
--- a/modules/gui/qt4/dialogs_provider.cpp
+++ b/modules/gui/qt4/dialogs_provider.cpp
@@ -177,23 +177,23 @@ void DialogsProvider::bookmarksDialog()
 
 void DialogsProvider::openDialog()
 {
-    openDialog( 0 );
+    openDialog( OPEN_FILE_TAB );
 }
 void DialogsProvider::openFileDialog()
 {
-    openDialog( 0 );
+    openDialog( OPEN_FILE_TAB );
 }
 void DialogsProvider::openDiscDialog()
 {
-    openDialog( 1 );
+    openDialog( OPEN_DISC_TAB );
 }
 void DialogsProvider::openNetDialog()
 {
-    openDialog( 2 );
+    openDialog( OPEN_NETWORK_TAB );
 }
 void DialogsProvider::openCaptureDialog()
 {
-    openDialog( 3 );
+    openDialog( OPEN_CAPTURE_TAB );
 }
 void DialogsProvider::openDialog( int i_tab )
 {
diff --git a/modules/gui/qt4/dialogs_provider.hpp b/modules/gui/qt4/dialogs_provider.hpp
index b7b1918baa14..342fe5b71807 100644
--- a/modules/gui/qt4/dialogs_provider.hpp
+++ b/modules/gui/qt4/dialogs_provider.hpp
@@ -68,6 +68,10 @@
     string += _("All Files");        \
     string += " (*.*)";
 
+#define OPEN_FILE_TAB           0x0
+#define OPEN_DISC_TAB           0x1
+#define OPEN_NETWORK_TAB        0x2
+#define OPEN_CAPTURE_TAB        0x3
 
 class QEvent;
 class QSignalMapper;
-- 
GitLab