Qt4 - Set Filters. Regroup filter definitions.
authorJean-Baptiste Kempf <jb@videolan.org>
Tue, 20 Mar 2007 01:15:26 +0000 (01:15 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Tue, 20 Mar 2007 01:15:26 +0000 (01:15 +0000)
Open Dialog: status.
- Broken on Windows.... As usual...
- Filters are not correctly set. Why ? I don't understand...
- Alignement will not be better.
- Show/hide advanced panel and subtitles do not work correctly (none of them)
- Additional features will be for next release. There is plenty of things to do left.

/* GOSH I hate QT designer */

modules/gui/qt4/components/open.cpp
modules/gui/qt4/components/open.hpp
modules/gui/qt4/dialogs_provider.cpp
modules/gui/qt4/dialogs_provider.hpp
modules/gui/qt4/ui/open_file.ui

index 313c827..0ed990f 100644 (file)
@@ -51,6 +51,18 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     dialogBox->setDirectory( qfu( p_intf->p_libvlc->psz_homedir ) );
     /* We don't want to see a grip in the middle of the window, do we? */
     dialogBox->setSizeGripEnabled( false );
     dialogBox->setDirectory( qfu( p_intf->p_libvlc->psz_homedir ) );
     /* We don't want to see a grip in the middle of the window, do we? */
     dialogBox->setSizeGripEnabled( false );
+    dialogBox->setToolTip( qtr( "Select one or multiple files, or a folder" ));
+
+    /* Set Filters for file selection */
+    QString fileTypes = "";
+    ADD_FILTER_MEDIA( fileTypes );
+    ADD_FILTER_VIDEO( fileTypes );
+    ADD_FILTER_AUDIO( fileTypes );
+    ADD_FILTER_PLAYLIST( fileTypes );
+    ADD_FILTER_ALL( fileTypes );
+    fileTypes.replace(QString(";*"), QString(" *"));
+
+    dialogBox->setFilter( fileTypes );
 
     // Add it to the layout
     ui.gridLayout->addWidget( dialogBox, 0, 0, 1, 3 );
 
     // Add it to the layout
     ui.gridLayout->addWidget( dialogBox, 0, 0, 1, 3 );
@@ -79,7 +91,7 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
 
 
     BUTTONACT( ui.subBrowseButton, browseFileSub() );
 
 
     BUTTONACT( ui.subBrowseButton, browseFileSub() );
-    BUTTONACT( ui.subCheckBox, updateMRL());
+    BUTTONACT( ui.subCheckBox, toggleSubtitleFrame());
 
     CONNECT( ui.fileInput, editTextChanged(QString ), this, updateMRL());
     CONNECT( ui.subInput, editTextChanged(QString ), this, updateMRL());
 
     CONNECT( ui.fileInput, editTextChanged(QString ), this, updateMRL());
     CONNECT( ui.subInput, editTextChanged(QString ), this, updateMRL());
@@ -143,7 +155,6 @@ void FileOpenPanel::clear()
 
 bool FileOpenPanel::eventFilter(QObject *object, QEvent *event)
 {
 
 bool FileOpenPanel::eventFilter(QObject *object, QEvent *event)
 {
-    printf( "coin\n" );
     if ( ( object == dialogBox ) && ( event->type() == QEvent::Hide ) )
     {
          event->ignore();
     if ( ( object == dialogBox ) && ( event->type() == QEvent::Hide ) )
     {
          event->ignore();
@@ -154,6 +165,23 @@ bool FileOpenPanel::eventFilter(QObject *object, QEvent *event)
         return QObject::eventFilter(object, event);
 }
 
         return QObject::eventFilter(object, event);
 }
 
+void FileOpenPanel::toggleSubtitleFrame()
+{
+    if (ui.subFrame->isVisible())
+    {
+        ui.subFrame->hide();
+//        setMinimumHeight(1);
+        resize( sizeHint());
+    }
+    else
+    {
+        ui.subFrame->show();
+    }
+
+    /* Update the MRL */
+    updateMRL();
+}
+
 /**************************************************************************
  * Disk open
  **************************************************************************/
 /**************************************************************************
  * Disk open
  **************************************************************************/
index d3e6334..45a3c34 100644 (file)
@@ -74,6 +74,7 @@ public slots:
 private slots:
     void browseFile();
     void browseFileSub();
 private slots:
     void browseFile();
     void browseFileSub();
+    void toggleSubtitleFrame();
 
 };
 
 
 };
 
index a851968..84984e4 100644 (file)
@@ -196,33 +196,20 @@ QStringList DialogsProvider::showSimpleOpen(QString help, bool all,
                                             bool audio, bool video,
                                             bool subs, bool pls)
 {
                                             bool audio, bool video,
                                             bool subs, bool pls)
 {
-    QString fileTypes;
+    QString fileTypes = "";
     if( all ) {
     if( all ) {
-        fileTypes = _("Media Files");
-        fileTypes += " ( ";
-        fileTypes += EXTENSIONS_MEDIA;
-        fileTypes += ");;";
+        ADD_FILTER_MEDIA( fileTypes );
     }
     if( video ) {
     }
     if( video ) {
-        fileTypes += _("Video Files");
-        fileTypes += " ( ";
-        fileTypes += EXTENSIONS_VIDEO;
-        fileTypes += ");;";
+        ADD_FILTER_VIDEO( fileTypes );
     }
     if( audio ) {
     }
     if( audio ) {
-        fileTypes += _("Sound Files");
-        fileTypes += " ( ";
-        fileTypes += EXTENSIONS_AUDIO;
-        fileTypes += ");;";
+        ADD_FILTER_AUDIO( fileTypes );
     }
     if( pls ) {
     }
     if( pls ) {
-        fileTypes += _("PlayList Files");
-        fileTypes += " ( ";
-        fileTypes += EXTENSIONS_PLAYLIST;
-        fileTypes += ");;";
+        ADD_FILTER_PLAYLIST( fileTypes );
     }
     }
-    fileTypes += _("All Files");
-    fileTypes += " (*.*)";
+    ADD_FILTER_ALL( fileTypes );
     fileTypes.replace(QString(";*"), QString(" *"));
     return QFileDialog::getOpenFileNames( NULL,
                                           help.isNull() ?
     fileTypes.replace(QString(";*"), QString(" *"));
     return QFileDialog::getOpenFileNames( NULL,
                                           help.isNull() ?
index a71ed49..c608451 100644 (file)
 #include <vlc/vlc.h>
 #include <vlc_interface.h>
 
 #include <vlc/vlc.h>
 #include <vlc_interface.h>
 
+#define ADD_FILTER_MEDIA( string )       \
+    string += _("Media Files");      \
+    string += " ( ";                 \
+    string += EXTENSIONS_MEDIA;      \
+    string += ");;";
+#define ADD_FILTER_VIDEO( string )       \
+    string += _("Video Files");      \
+    string += " ( ";                 \
+    string += EXTENSIONS_VIDEO;      \
+    string += ");;";
+#define ADD_FILTER_AUDIO( string )       \
+    string += _("Audio Files");      \
+    string += " ( ";                 \
+    string += EXTENSIONS_AUDIO;      \
+    string += ");;";
+#define ADD_FILTER_PLAYLIST( string )\
+    string += _("Playlist Files");   \
+    string += " ( ";                 \
+    string += EXTENSIONS_PLAYLIST;   \
+    string += ");;";
+#define ADD_FILTER_ALL( string )     \
+    string += _("All Files");        \
+    string += " (*.*)";
+
+
 class QEvent;
 class QSignalMapper;
 class QVLCMenu;
 class QEvent;
 class QSignalMapper;
 class QVLCMenu;
index 017f626..f96fe4c 100644 (file)
@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>463</width>
+    <width>435</width>
     <height>249</height>
    </rect>
   </property>
     <height>249</height>
    </rect>
   </property>
    <property name="spacing" >
     <number>6</number>
    </property>
    <property name="spacing" >
     <number>6</number>
    </property>
+   <item row="1" column="1" colspan="2" >
+    <widget class="QComboBox" name="fileInput" >
+     <property name="sizePolicy" >
+      <sizepolicy>
+       <hsizetype>7</hsizetype>
+       <vsizetype>0</vsizetype>
+       <horstretch>1</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="editable" >
+      <bool>true</bool>
+     </property>
+     <property name="maxVisibleItems" >
+      <number>7</number>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="0" >
+    <widget class="QLabel" name="fileLabel" >
+     <property name="maximumSize" >
+      <size>
+       <width>85</width>
+       <height>16777215</height>
+      </size>
+     </property>
+     <property name="text" >
+      <string>File Names:</string>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="0" colspan="3" >
+    <widget class="QWidget" native="1" name="tempWidget" />
+   </item>
+   <item row="5" column="0" colspan="3" >
+    <spacer>
+     <property name="orientation" >
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" >
+      <size>
+       <width>200</width>
+       <height>2</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="2" column="2" >
+    <spacer>
+     <property name="orientation" >
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeType" >
+      <enum>QSizePolicy::Fixed</enum>
+     </property>
+     <property name="sizeHint" >
+      <size>
+       <width>273</width>
+       <height>16</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="3" column="0" colspan="2" >
+    <widget class="QCheckBox" name="subCheckBox" >
+     <property name="text" >
+      <string>Use a subtitles file</string>
+     </property>
+    </widget>
+   </item>
    <item row="4" column="0" colspan="3" >
     <widget class="QFrame" name="subFrame" >
      <property name="sizePolicy" >
    <item row="4" column="0" colspan="3" >
     <widget class="QFrame" name="subFrame" >
      <property name="sizePolicy" >
      </layout>
     </widget>
    </item>
      </layout>
     </widget>
    </item>
-   <item row="3" column="0" colspan="2" >
-    <widget class="QCheckBox" name="subCheckBox" >
-     <property name="text" >
-      <string>Use a subtitles file</string>
-     </property>
-    </widget>
-   </item>
-   <item row="2" column="2" >
-    <spacer>
-     <property name="orientation" >
-      <enum>Qt::Vertical</enum>
-     </property>
-     <property name="sizeType" >
-      <enum>QSizePolicy::Fixed</enum>
-     </property>
-     <property name="sizeHint" >
-      <size>
-       <width>273</width>
-       <height>16</height>
-      </size>
-     </property>
-    </spacer>
-   </item>
-   <item row="1" column="1" >
-    <widget class="QLabel" name="fileLabel" >
-     <property name="text" >
-      <string>File / Directory Names;</string>
-     </property>
-    </widget>
-   </item>
-   <item row="1" column="2" >
-    <widget class="QComboBox" name="fileInput" >
-     <property name="sizePolicy" >
-      <sizepolicy>
-       <hsizetype>7</hsizetype>
-       <vsizetype>0</vsizetype>
-       <horstretch>0</horstretch>
-       <verstretch>0</verstretch>
-      </sizepolicy>
-     </property>
-     <property name="editable" >
-      <bool>true</bool>
-     </property>
-     <property name="maxVisibleItems" >
-      <number>7</number>
-     </property>
-    </widget>
-   </item>
-   <item row="5" column="1" colspan="2" >
-    <spacer>
-     <property name="orientation" >
-      <enum>Qt::Vertical</enum>
-     </property>
-     <property name="sizeHint" >
-      <size>
-       <width>200</width>
-       <height>2</height>
-      </size>
-     </property>
-    </spacer>
-   </item>
-   <item row="0" column="1" colspan="2" >
-    <widget class="QWidget" native="1" name="tempWidget" />
-   </item>
-   <item row="1" column="0" >
-    <spacer>
-     <property name="orientation" >
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="sizeType" >
-      <enum>QSizePolicy::Fixed</enum>
-     </property>
-     <property name="sizeHint" >
-      <size>
-       <width>16</width>
-       <height>26</height>
-      </size>
-     </property>
-    </spacer>
-   </item>
   </layout>
  </widget>
  <layoutdefault spacing="0" margin="0" />
   </layout>
  </widget>
  <layoutdefault spacing="0" margin="0" />