#include <QStackedLayout>
#include <QListView>
#include <QCompleter>
+#include <QDirModel>
/**************************************************************************
* Open Files and subtitles *
/* Classic UI Setup */
ui.setupUi( this );
+ /** BEGIN QFileDialog tweaking **/
/* Use a QFileDialog and customize it because we don't want to
rewrite it all. Be careful to your eyes cause there are a few hacks.
Be very careful and test correctly when you modify this. */
ADD_FILTER_ALL( fileTypes );
fileTypes.replace( QString(";*"), QString(" *"));
+ /* retrieve last known path used in file browsing */
+ char *psz_filepath = config_GetPsz( p_intf, "qt-filedialog-path" );
+ if( EMPTY_STR( psz_filepath ) )
+ {
+ psz_filepath = p_intf->p_libvlc->psz_homedir;
+ }
// Make this QFileDialog a child of tempWidget from the ui.
dialogBox = new FileOpenBox( ui.tempWidget, NULL,
- qfu( p_intf->p_libvlc->psz_homedir ), fileTypes );
+ qfu( psz_filepath ), fileTypes );
+ delete psz_filepath;
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( qfu( psz_filepath ) );
- delete psz_filepath;
- }
-
/* We don't want to see a grip in the middle of the window, do we? */
dialogBox->setSizeGripEnabled( false );
/* Add a tooltip */
dialogBox->setToolTip( qtr( "Select one or multiple files, or a folder" ) );
- // Add it to the layout
- ui.gridLayout->addWidget( dialogBox, 0, 0, 1, 3 );
-
// But hide the two OK/Cancel buttons. Enable them for debug.
QDialogButtonBox *fileDialogAcceptBox =
- findChildren<QDialogButtonBox*>()[0];
+ dialogBox->findChildren<QDialogButtonBox*>()[0];
fileDialogAcceptBox->hide();
/* Ugly hacks to get the good Widget */
//This lineEdit is the normal line in the fileDialog.
#if HAS_QT43
- lineFileEdit = findChildren<QLineEdit*>()[2];
+ lineFileEdit = dialogBox->findChildren<QLineEdit*>()[0];
#else
- lineFileEdit = findChildren<QLineEdit*>()[3];
+ // FIXME
+ lineFileEdit = dialogBox->findChildren<QLineEdit*>()[1];
#endif
- QStringList fileCompleteList ;
- QCompleter *fileCompleter = new QCompleter( fileCompleteList, this );
-
- lineFileEdit->setCompleter( fileCompleter );
-
-// lineFileEdit->hide();
-
/* Make a list of QLabel inside the QFileDialog to access the good ones */
- QList<QLabel *> listLabel = findChildren<QLabel*>();
+ QList<QLabel *> listLabel = dialogBox->findChildren<QLabel*>();
/* Hide the FileNames one. Enable it for debug */
- listLabel[4]->hide();
+ listLabel[1]->setText( qtr( "File names:" ) );
/* Change the text that was uncool in the usual box */
- listLabel[5]->setText( qtr( "Filter:" ) );
+ listLabel[2]->setText( qtr( "Filter:" ) );
+ dialogBox->layout()->setMargin( 0 );
+ dialogBox->layout()->setSizeConstraint( QLayout::SetMinimumSize );
- QListView *fileListView = findChildren<QListView*>().first();
+ /** END of QFileDialog tweaking **/
+
+ // Add the DialogBox to the layout
+ ui.gridLayout->addWidget( dialogBox, 0, 0, 1, 3 );
+
+ //TODO later: fill the fileCompleteList with previous items played.
+ QCompleter *fileCompleter = new QCompleter( fileCompleteList, this );
+ fileCompleter->setModel( new QDirModel( fileCompleter ) );
+ lineFileEdit->setCompleter( fileCompleter );
// Hide the subtitles control by default.
ui.subFrame->hide();
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( lineFileEdit, textChanged( QString ), this, updateMRL() );
+
+ CONNECT( ui.subInput, textChanged( QString ), this, updateMRL() );
CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this,
updateMRL() );
CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this,
updateMRL() );
-
- CONNECT( lineFileEdit, textChanged( QString ), this, browseFile() );
}
FileOpenPanel::~FileOpenPanel()
return THEDP->showSimpleOpen( help );
}
-void FileOpenPanel::browseFile()
-{
- QString fileString = "";
- foreach( QString file, dialogBox->selectedFiles() ) {
- fileString += "\"" + file + "\" ";
- }
- ui.fileInput->setEditText( fileString );
- updateMRL();
-}
void FileOpenPanel::browseFileSub()
{
EXT_FILTER_SUBTITLE,
dialogBox->directory().absolutePath() );
if( files.isEmpty() ) return;
- ui.subInput->setEditText( files.join(" ") );
+ ui.subInput->setText( files.join(" ") );
updateMRL();
}
void FileOpenPanel::updateMRL()
{
- msg_Dbg( p_intf, "I was here" );
- QString mrl = ui.fileInput->currentText();
+ QString mrl = "";
+ foreach( QString file, dialogBox->selectedFiles() ) {
+ mrl += "\"" + file + "\" ";
+ }
if( ui.subCheckBox->isChecked() ) {
- mrl.append( " :sub-file=" + ui.subInput->currentText() );
+ mrl.append( " :sub-file=" + ui.subInput->text() );
int align = ui.alignSubComboBox->itemData(
ui.alignSubComboBox->currentIndex() ).toInt();
mrl.append( " :subsdec-align=" + QString().setNum( align ) );
/* Function called by Open Dialog when clicke on Play/Enqueue */
void FileOpenPanel::accept()
{
- ui.fileInput->addItem( ui.fileInput->currentText());
- if ( ui.fileInput->count() > 8 ) ui.fileInput->removeItem( 0 );
+ //FIXME set the completer
}
void FileOpenBox::accept()
/* Function called by Open Dialog when clicked on cancel */
void FileOpenPanel::clear()
{
- ui.fileInput->setEditText( "" );
- ui.subInput->setEditText( "" );
+ lineFileEdit->clear();
+ ui.subInput->clear();
}
void FileOpenPanel::toggleSubtitleFrame()
{
- if ( ui.subFrame->isVisible() )
- {
- ui.subFrame->hide();
- updateGeometry();
- /* FiXME Size */
- }
- else
- {
- ui.subFrame->show();
- }
+ TOGGLEV( ui.subFrame );
/* Update the MRL */
updateMRL();
v4lFreq->setSuffix(" kHz");
setSpinBoxFreq( v4lFreq );
v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
+ v4lPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
+ 2, 0, 2, 1 );
/* v4l CONNECTs */
CuMRL( v4lVideoDevice, textChanged( QString ) );
v4l2StdBox = new QComboBox;
setfillVLCConfigCombo( "v4l2-standard", p_intf, v4l2StdBox );
v4l2PropLayout->addWidget( v4l2StdBox, 0 , 1 );
+ v4l2PropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
+ 1, 0, 3, 1 );
/* v4l2 CONNECTs */
CuMRL( v4l2VideoDevice, textChanged( QString ) );
pvrBitr->setSuffix(" kHz");
setSpinBoxFreq( pvrBitr );
pvrPropLayout->addWidget( pvrBitr, 2, 1 );
+ pvrPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
+ 3, 0, 1, 1 );
/* PVR CONNECTs */
CuMRL( pvrDevice, textChanged( QString ) );
QLineEdit *dshowVSizeLine = new QLineEdit;
dshowPropLayout->addWidget( dshowVSizeLine, 0, 1);
+ dshowPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
+ 1, 0, 3, 1 );
/* dshow CONNECTs */
CuMRL( dshowVDevice, currentIndexChanged ( int ) );
bdaBandLabel->hide();
bdaBandBox->hide();
+ bdaPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
+ 2, 0, 2, 1 );
/* bda CONNECTs */
CuMRL( bdaFreq, valueChanged ( int ) );
dvbSrate->setSuffix(" kHz");
setSpinBoxFreq( dvbSrate );
dvbPropLayout->addWidget( dvbSrate, 1, 1 );
+ dvbPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
+ 2, 0, 2, 1 );
/* DVB CONNECTs */
CuMRL( dvbCard, valueChanged ( int ) );
<string>Capture</string>
</property>
<layout class="QGridLayout" >
- <property name="margin" >
+ <property name="leftMargin" >
<number>9</number>
</property>
- <property name="spacing" >
+ <property name="topMargin" >
+ <number>9</number>
+ </property>
+ <property name="rightMargin" >
+ <number>9</number>
+ </property>
+ <property name="bottomMargin" >
+ <number>9</number>
+ </property>
+ <property name="horizontalSpacing" >
+ <number>6</number>
+ </property>
+ <property name="verticalSpacing" >
<number>6</number>
</property>
- <item row="4" column="0" colspan="2" >
+ <item row="5" column="0" colspan="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
<item row="0" column="1" >
<widget class="QComboBox" name="deviceCombo" >
<property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>1</hsizetype>
- <vsizetype>0</vsizetype>
+ <sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
- <item row="2" column="0" colspan="2" >
+ <item row="3" column="0" colspan="2" >
<widget class="QGroupBox" name="optionsBox" >
<property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>5</hsizetype>
- <vsizetype>0</vsizetype>
+ <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
- <item row="1" column="0" colspan="2" >
+ <item row="2" column="0" colspan="2" >
<widget class="QGroupBox" name="cardBox" >
<property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>3</hsizetype>
- <vsizetype>5</vsizetype>
+ <sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
- <item row="3" column="0" >
+ <item row="4" column="0" >
<widget class="QPushButton" name="advancedButton" >
<property name="toolTip" >
<string>_("Access advanced options to tweak the device")</string>
</property>
</widget>
</item>
+ <item row="1" column="0" colspan="2" >
+ <widget class="Line" name="line" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
<resources/>
<string>_("Open File")</string>
</property>
<layout class="QGridLayout" >
- <item row="1" column="1" colspan="2" >
- <widget class="QComboBox" name="fileInput" >
- <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" >
<property name="toolTip" >
<enum>QFrame::StyledPanel</enum>
</property>
<layout class="QGridLayout" >
- <item row="1" column="7" >
+ <item row="1" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</spacer>
</item>
- <item row="1" column="0" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
+ <item row="1" column="1" >
+ <widget class="QLabel" name="sizeSubLabel" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Preferred" hsizetype="Minimum" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- <property name="sizeHint" >
- <size>
- <width>16</width>
- <height>20</height>
- </size>
+ <property name="text" >
+ <string>_("Size:")</string>
</property>
- </spacer>
+ </widget>
</item>
- <item row="1" column="5" colspan="2" >
- <widget class="QComboBox" name="alignSubComboBox" >
+ <item row="1" column="2" >
+ <widget class="QComboBox" name="sizeSubComboBox" >
<property name="minimumSize" >
<size>
<width>100</width>
<height>0</height>
</size>
</property>
- <property name="currentIndex" >
- <number>-1</number>
- </property>
- <property name="insertPolicy" >
- <enum>QComboBox::NoInsert</enum>
- </property>
- <property name="minimumContentsLength" >
- <number>0</number>
- </property>
- </widget>
- </item>
- <item row="1" column="4" >
- <widget class="QLabel" name="alignSubLabel" >
- <property name="text" >
- <string>_("Alignment:")</string>
- </property>
- <property name="buddy" >
- <cstring>alignSubLabel</cstring>
- </property>
</widget>
</item>
<item row="1" column="3" >
</property>
<property name="sizeHint" >
<size>
- <width>71</width>
+ <width>30</width>
<height>26</height>
</size>
</property>
</spacer>
</item>
- <item row="1" column="2" >
- <widget class="QComboBox" name="sizeSubComboBox" >
+ <item row="1" column="4" >
+ <widget class="QLabel" name="alignSubLabel" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Preferred" hsizetype="Minimum" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string>_("Alignment:")</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="5" >
+ <widget class="QComboBox" name="alignSubComboBox" >
<property name="minimumSize" >
<size>
<width>100</width>
</property>
</widget>
</item>
- <item row="1" column="1" >
- <widget class="QLabel" name="sizeSubLabel" >
- <property name="text" >
- <string>_("Size:")</string>
+ <item row="1" column="6" colspan="2" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
</property>
- </widget>
+ <property name="sizeHint" >
+ <size>
+ <width>16</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
</item>
<item row="0" column="0" colspan="6" >
- <widget class="QComboBox" name="subInput" >
- <property name="editable" >
- <bool>true</bool>
+ <widget class="QLineEdit" name="subInput" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
</widget>
</item>
<item row="0" column="6" colspan="2" >
<widget class="QPushButton" name="subBrowseButton" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize" >
+ <size>
+ <width>100</width>
+ <height>0</height>
+ </size>
+ </property>
<property name="toolTip" >
<string>_("Select the subtitle file")</string>
</property>
</item>
</layout>
</widget>
- <layoutdefault spacing="0" margin="0" />
<tabstops>
- <tabstop>fileInput</tabstop>
<tabstop>subCheckBox</tabstop>
<tabstop>subInput</tabstop>
<tabstop>subBrowseButton</tabstop>