]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/open.cpp
Removes trailing spaces. Removes tabs.
[vlc] / modules / gui / qt4 / components / open.cpp
index 0feed46d5eaa6d439b67c1580a949ae648b73cd9..f91ff544706038fdd9e08f54deea4650783eb1a9 100644 (file)
@@ -2,10 +2,13 @@
  * open.cpp : Panels for the open dialogs
  ****************************************************************************
  * Copyright (C) 2006-2007 the VideoLAN team
+ * Copyright (C) 2007 Société des arts technologiques
+ * Copyright (C) 2007 Savoir-faire Linux
  * $Id$
  *
  * Authors: Clément Stenac <zorglub@videolan.org>
  *          Jean-Baptiste Kempf <jb@videolan.org>
+ *          Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.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
 #include <QStackedLayout>
 #include <QListView>
 
-#ifdef HAVE_LIMITS_H
-#   include <limits.h>
-#endif
-
 /**************************************************************************
  * Open Files and subtitles                                               *
  **************************************************************************/
@@ -64,14 +63,15 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     // Make this QFileDialog a child of tempWidget from the ui.
     dialogBox = new FileOpenBox( ui.tempWidget, NULL,
             qfu( p_intf->p_libvlc->psz_homedir ), fileTypes );
-/*    dialogBox->setFileMode( QFileDialog::ExistingFiles );*/
+
+    dialogBox->setFileMode( QFileDialog::ExistingFiles );
     dialogBox->setAcceptMode( QFileDialog::AcceptOpen );
 
     /* retrieve last known path used in file browsing */
     char *psz_filepath = config_GetPsz( p_intf, "qt-filedialog-path" );
     if( psz_filepath )
     {
-        dialogBox->setDirectory( QString::fromUtf8( psz_filepath ) );
+        dialogBox->setDirectory( qfu( psz_filepath ) );
         delete psz_filepath;
     }
 
@@ -79,7 +79,7 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     dialogBox->setSizeGripEnabled( false );
 
     /* Add a tooltip */
-//  dialogBox->setToolTip( qtr( "Select one or multiple files, or a folder" ) );
+    dialogBox->setToolTip( qtr( "Select one or multiple files, or a folder" ) );
 
     // Add it to the layout
     ui.gridLayout->addWidget( dialogBox, 0, 0, 1, 3 );
@@ -91,8 +91,12 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
 
     /* Ugly hacks to get the good Widget */
     //This lineEdit is the normal line in the fileDialog.
+#if QT43
+    lineFileEdit = findChildren<QLineEdit*>()[2];
+#else
     lineFileEdit = findChildren<QLineEdit*>()[3];
-    lineFileEdit->hide();
+#endif
+//    lineFileEdit->hide();
 
     /* Make a list of QLabel inside the QFileDialog to access the good ones */
     QList<QLabel *> listLabel = findChildren<QLabel*>();
@@ -102,10 +106,11 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     /* Change the text that was uncool in the usual box */
     listLabel[5]->setText( qtr( "Filter:" ) );
 
+
+    QListView *fileListView = findChildren<QListView*>().first();
 #if WIN32
-    /* QFileDialog is quite buggy make it brerable on win32 by tweaking 
+    /* QFileDialog is quite buggy make it brerable on win32 by tweaking
        the followin */
-    QListView *fileListView = findChildren<QListView*>().first();
     fileListView->setLayoutMode(QListView::Batched);
     fileListView->setViewMode(QListView::ListMode);
     fileListView->setResizeMode(QListView::Adjust);
@@ -128,7 +133,11 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     BUTTONACT( ui.subBrowseButton, browseFileSub() );
     BUTTONACT( ui.subCheckBox, toggleSubtitleFrame());
 
+#if QT43
+    CONNECT( fileListView, clicked( QModelIndex ), this, updateMRL() );
+#else
     CONNECT( ui.fileInput, editTextChanged( QString ), this, updateMRL() );
+#endif
     CONNECT( ui.subInput, editTextChanged( QString ), this, updateMRL() );
     CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this,
                                                             updateMRL() );
@@ -169,6 +178,7 @@ void FileOpenPanel::browseFileSub()
 
 void FileOpenPanel::updateMRL()
 {
+    msg_Dbg( p_intf, "I was here" );
     QString mrl = ui.fileInput->currentText();
 
     if( ui.subCheckBox->isChecked() ) {
@@ -345,7 +355,6 @@ void DiscOpenPanel::updateMRL()
 }
 
 
-
 /**************************************************************************
  * Open Network streams and URL pages                                     *
  **************************************************************************/
@@ -381,10 +390,10 @@ void NetOpenPanel::updateProtocol( int idx ) {
     QString addr = ui.addressText->text();
     QString proto = ui.protocolCombo->itemData( idx ).toString();
 
-    ui.timeShift->setEnabled( idx >= 4 );
-    ui.ipv6->setEnabled( idx == 4 );
-    ui.addressText->setEnabled( idx != 4 );
-    ui.portSpin->setEnabled( idx >= 4 );
+    ui.timeShift->setEnabled( idx >= 5 );
+    ui.ipv6->setEnabled( idx == 5 );
+    ui.addressText->setEnabled( idx != 5 );
+    ui.portSpin->setEnabled( idx >= 5 );
 
     /* If we already have a protocol in the address, replace it */
     if( addr.contains( "://")) {
@@ -404,13 +413,14 @@ void NetOpenPanel::updateMRL() {
     QString addr = ui.addressText->text();
     int proto = ui.protocolCombo->currentIndex();
 
-    if( addr.contains( "://") && proto != 4 ) {
+    if( addr.contains( "://") && proto != 5 ) {
         mrl = addr;
     } else {
         switch( proto ) {
         case 0:
-        case 1:
             mrl = "http://" + addr;
+        case 1:
+            mrl = "https://" + addr;
             emit methodChanged("http-caching");
             break;
         case 3:
@@ -478,8 +488,6 @@ CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
 
 #define CuMRL( widget, slot ) CONNECT( widget , slot , this, updateMRL() );
 
-#define setMaxBound( spinbox ) spinbox->setRange ( 0, INT_MAX );
-
     /*******
      * V4L *
      *******/
@@ -512,6 +520,7 @@ CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     v4lFreq = new QSpinBox;
     v4lFreq->setAlignment( Qt::AlignRight );
     v4lFreq->setSuffix(" kHz");
+    setSpinBoxFreq( v4lFreq );
     v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
 
     /* v4l CONNECTs */
@@ -520,6 +529,58 @@ CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     CuMRL( v4lFreq, valueChanged ( int ) );
     CuMRL( v4lNormBox,  currentIndexChanged ( int ) );
 
+    /*******
+     * JACK *
+     *******/
+    addModuleAndLayouts( JACK_DEVICE, jack, "JACK Audio Connection Kit" );
+
+    /* Jack Main panel */
+    /* Channels */
+    QLabel *jackChannelsLabel = new QLabel( qtr( "Channels :" ) );
+    jackDevLayout->addWidget( jackChannelsLabel, 1, 0 );
+
+    jackChannels = new QSpinBox;
+    setSpinBoxFreq( jackChannels );
+    jackChannels->setMaximum(255);
+    jackChannels->setValue(2);
+    jackChannels->setAlignment( Qt::AlignRight );
+    jackDevLayout->addWidget( jackChannels, 1, 1 );
+
+    /* Jack Props panel */
+    /* Selected ports */
+    QLabel *jackPortsLabel = new QLabel( qtr( "Selected ports :" ) );
+    jackPropLayout->addWidget( jackPortsLabel, 0 , 0 );
+
+    jackPortsSelected = new QLineEdit( qtr( ".*") );
+    jackPortsSelected->setAlignment( Qt::AlignRight );
+    jackPropLayout->addWidget( jackPortsSelected, 0, 1 );
+    /* Caching */
+    QLabel *jackCachingLabel = new QLabel( qtr( "Input caching :" ) );
+    jackPropLayout->addWidget( jackCachingLabel, 1 , 0 );
+    jackCaching = new QSpinBox;
+    setSpinBoxFreq( jackCaching );
+    jackCaching->setSuffix( " ms" );
+    jackCaching->setValue(1000);
+    jackCaching->setAlignment( Qt::AlignRight );
+    jackPropLayout->addWidget( jackCaching, 1 , 1 );
+    /* Pace */
+    jackPace = new QCheckBox(qtr( "Use VLC pace" ));
+    jackPropLayout->addWidget( jackPace, 2, 1 );
+    /* Auto Connect */
+    jackConnect = new QCheckBox( qtr( "Auto connnection" ));
+    jackPropLayout->addWidget( jackConnect, 3, 1 );
+    /* Jack CONNECTs */
+    CuMRL( jackChannels, valueChanged( int ) );
+    CuMRL( jackCaching, valueChanged( int ) );
+    CuMRL( jackPace, stateChanged( int ) );
+    CuMRL( jackConnect, stateChanged( int ) );
+    CuMRL( jackPortsSelected, textChanged( QString ) );
+
     /************
      * PVR      *
      ************/
@@ -552,7 +613,7 @@ CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     pvrFreq = new QSpinBox;
     pvrFreq->setAlignment( Qt::AlignRight );
     pvrFreq->setSuffix(" kHz");
-    setMaxBound( pvrFreq );
+    setSpinBoxFreq( pvrFreq );
     pvrPropLayout->addWidget( pvrFreq, 1, 1 );
 
     QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
@@ -561,7 +622,7 @@ CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     pvrBitr = new QSpinBox;
     pvrBitr->setAlignment( Qt::AlignRight );
     pvrBitr->setSuffix(" kHz");
-    setMaxBound( pvrBitr );
+    setSpinBoxFreq( pvrBitr );
     pvrPropLayout->addWidget( pvrBitr, 2, 1 );
 
     /* PVR CONNECTs */
@@ -643,7 +704,7 @@ CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     bdaFreq->setAlignment( Qt::AlignRight );
     bdaFreq->setSuffix(" kHz");
     bdaFreq->setSingleStep( 1000 );
-    setMaxBound( bdaFreq )
+    setSpinBoxFreq( bdaFreq )
     bdaPropLayout->addWidget( bdaFreq, 0, 1 );
 
     bdaSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
@@ -652,7 +713,7 @@ CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     bdaSrate = new QSpinBox;
     bdaSrate->setAlignment( Qt::AlignRight );
     bdaSrate->setSuffix(" kHz");
-    setMaxBound( bdaSrate );
+    setSpinBoxFreq( bdaSrate );
     bdaPropLayout->addWidget( bdaSrate, 1, 1 );
 
     bdaBandLabel = new QLabel( qtr( "Bandwidth" ) );
@@ -710,7 +771,7 @@ CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     dvbFreq = new QSpinBox;
     dvbFreq->setAlignment( Qt::AlignRight );
     dvbFreq->setSuffix(" kHz");
-    setMaxBound( dvbFreq  );
+    setSpinBoxFreq( dvbFreq  );
     dvbPropLayout->addWidget( dvbFreq, 0, 1 );
 
     QLabel *dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
@@ -719,7 +780,7 @@ CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     dvbSrate = new QSpinBox;
     dvbSrate->setAlignment( Qt::AlignRight );
     dvbSrate->setSuffix(" kHz");
-    setMaxBound( dvbSrate );
+    setSpinBoxFreq( dvbSrate );
     dvbPropLayout->addWidget( dvbSrate, 1, 1 );
 
     /* DVB CONNECTs */
@@ -731,12 +792,22 @@ CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     BUTTONACT( dvbt, updateButtons() );
     BUTTONACT( dvbc, updateButtons() );
 
+    /**********
+     * Screen *
+     **********/
+    addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop" );
+    QLabel *screenLabel = new QLabel( "This option will open your own "
+            "desktop in order to save or stream it.");
+    screenLabel->setWordWrap( true );
+    screenDevLayout->addWidget( screenLabel, 0, 0 );
+
     /* General connects */
     connect( ui.deviceCombo, SIGNAL( activated( int ) ),
                      stackedDevLayout, SLOT( setCurrentIndex( int ) ) );
     connect( ui.deviceCombo, SIGNAL( activated( int ) ),
                      stackedPropLayout, SLOT( setCurrentIndex( int ) ) );
     CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
+    CONNECT( ui.deviceCombo, activated( int ), this, updateButtons() );
 
 #undef addModule
 }
@@ -752,7 +823,6 @@ void CaptureOpenPanel::updateMRL()
     QString mrl = "";
     int i_devicetype = ui.deviceCombo->itemData(
             ui.deviceCombo->currentIndex() ).toInt();
-    msg_Dbg( p_intf, "Capture Type: %i", i_devicetype );
     switch( i_devicetype )
     {
     case V4L_DEVICE:
@@ -762,6 +832,20 @@ void CaptureOpenPanel::updateMRL()
         mrl += " :v4l-norm=" + QString("%1").arg( v4lNormBox->currentIndex() );
         mrl += " :v4l-frequency=" + QString("%1").arg( v4lFreq->value() );
         break;
+    case JACK_DEVICE:
+        mrl = "jack://";
+        mrl += "channels=" + QString("%1").arg( jackChannels->value() );
+        mrl += ":ports=" + jackPortsSelected->text();
+        mrl += " --jack-input-caching=" + QString("%1").arg( jackCaching->value() );
+        if ( jackPace->isChecked() )
+        {
+                mrl += " --jack-input-use-vlc-pace";
+        }
+        if ( jackConnect->isChecked() )
+        {
+                mrl += " --jack-input-auto-connect";
+        }
+        break;
     case PVR_DEVICE:
         mrl = "pvr://";
         mrl += " :pvr-device=" + pvrDevice->text();
@@ -791,16 +875,29 @@ void CaptureOpenPanel::updateMRL()
                 QString("%1").arg( bdaBandBox->itemData(
                     bdaBandBox->currentIndex() ).toInt() );
         break;
-  case DSHOW_DEVICE:
+    case DSHOW_DEVICE:
+        break;
+    case SCREEN_DEVICE:
+        mrl = "screen://";
+        updateButtons();
         break;
     }
     emit mrlUpdated( mrl );
 }
 
+/**
+ * Update the Buttons (show/hide) for the GUI as all device type don't
+ * use the same ui. elements.
+ **/
 void CaptureOpenPanel::updateButtons()
 {
+    /*  Be sure to display the ui Elements in case they were hidden by
+     *  some Device Type (like Screen://) */
+    ui.optionsBox->show();
+    ui.advancedButton->show();
+    /* Get the current Device Number */
     int i_devicetype = ui.deviceCombo->itemData(
-            ui.deviceCombo->currentIndex() ).toInt();
+                                ui.deviceCombo->currentIndex() ).toInt();
     msg_Dbg( p_intf, "Capture Type: %i", i_devicetype );
     switch( i_devicetype )
     {
@@ -824,5 +921,9 @@ void CaptureOpenPanel::updateButtons()
             bdaBandLabel->show();
         }
         break;
+    case SCREEN_DEVICE:
+        ui.optionsBox->hide();
+        ui.advancedButton->hide();
+        break;
     }
 }