Commit 93a51f20 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt4 - Open: New way and interface for File Open using an integration of...

Qt4 - Open: New way and interface for File Open using an integration of QFileDialog inside the FileOpenPanel. The integration should be alright.
Be careful for your eyes when reading the code, it can burn them :)
Anyway, there are still a few bugs (the main one is the disapearing of QFileDialog on acceptance) and some alignment issues.

I got NO idea how this behaves under Windows... A special code may be needed.


parent 801314fc
......@@ -26,6 +26,11 @@
#include "qt4.hpp"
#include "components/open.hpp"
#include "dialogs_provider.hpp"
#include "util/customwidgets.hpp"
#include <QFileDialog>
#include <QDialogButtonBox>
#include <QLineEdit>
/**************************************************************************
* File open
......@@ -33,10 +38,39 @@
FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
OpenPanel( _parent, _p_intf )
{
/* Classic UI Setup */
ui.setupUi( this );
/* 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. */
// Make this QFileDialog a child of tempWidget from the ui.
dialogBox = new QFileDialog( ui.tempWidget );
dialogBox->setFileMode( QFileDialog::ExistingFiles );
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 );
// Add it to the layout
ui.gridLayout->addWidget( dialogBox, 0, 0, 1, 3 );
// But hide the two OK/Cancel buttons. Enable them for debug.
findChild<QDialogButtonBox*>()->hide();
/* Ugly hacks to get the good Widget */
//This lineEdit is the normal line in the fileDialog.
lineFileEdit = findChildren<QLineEdit*>()[3];
lineFileEdit->hide();
/* Make a list of QLabel inside the QFileDialog to access the good ones */
QList<QLabel *> listLabel = findChildren<QLabel*>();
/* Hide the FileNames one. Enable it for debug */
listLabel[4]->hide();
/* Change the text that was uncool in the usual box */
listLabel[5]->setText( qtr( "Filter:" ) );
BUTTONACT( ui.fileBrowseButton, browseFile() );
BUTTONACT( ui.subBrowseButton, browseFileSub() );
BUTTONACT( ui.subGroupBox, updateMRL());
......@@ -44,6 +78,7 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
CONNECT( ui.subInput, editTextChanged(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()
......@@ -57,14 +92,10 @@ QStringList FileOpenPanel::browse(QString help)
void FileOpenPanel::browseFile()
{
QString fileString = "";
QStringList files = browse( qtr("Open File") );
foreach( QString file, files) {
foreach( QString file, dialogBox->selectedFiles() ) {
fileString += "\"" + file + "\" ";
}
ui.fileInput->setEditText( fileString );
ui.fileInput->addItem( fileString );
if ( ui.fileInput->count() > 8 ) ui.fileInput->removeItem(0);
updateMRL();
}
......@@ -83,14 +114,24 @@ void FileOpenPanel::updateMRL()
mrl.append( " :subsdec-align=" + ui.alignSubComboBox->currentText() );
mrl.append( " :sub-rel-fontsize=" + ui.sizeSubComboBox->currentText() );
}
emit mrlUpdated(mrl);
emit mrlUpdated( mrl );
emit methodChanged( "file-caching" );
}
/* 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);
}
/* Function called by Open Dialog when clicked on cancel */
void FileOpenPanel::clear()
{
ui.fileInput->setEditText( "");
ui.subInput->setEditText( "");
ui.fileInput->setEditText( "" );
ui.subInput->setEditText( "" );
}
......
......@@ -33,6 +33,9 @@
#include "ui/open_net.h"
#include "ui/open_capture.h"
class QFileDialog;
class QLineEdit;
class OpenPanel: public QWidget
{
Q_OBJECT;
......@@ -59,9 +62,12 @@ public:
FileOpenPanel( QWidget *, intf_thread_t * );
virtual ~FileOpenPanel();
virtual void clear() ;
virtual void accept() ;
private:
Ui::OpenFile ui;
QStringList browse( QString );
QFileDialog *dialogBox;
QLineEdit *lineFileEdit;
public slots:
virtual void updateMRL();
private slots:
......
......@@ -42,6 +42,7 @@ OpenDialog::OpenDialog( QWidget *parent, intf_thread_t *_p_intf, bool modal ) :
setModal( modal );
ui.setupUi( this );
setWindowTitle( qtr("Open" ) );
resize( 500, 300);
fileOpenPanel = new FileOpenPanel( this , p_intf );
diskOpenPanel = new DiskOpenPanel( this , p_intf );
......
......@@ -60,21 +60,11 @@
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="2" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>ms</string>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_2" >
<item row="2" column="1" colspan="2" >
<widget class="QLineEdit" name="slaveText" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Extra media</string>
</property>
</widget>
</item>
<item row="0" column="0" >
......@@ -92,6 +82,30 @@
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>ms</string>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="advancedLabel" >
<property name="text" >
<string>Customize</string>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_2" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Extra media</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QSpinBox" name="cacheSpinBox" >
<property name="sizePolicy" >
......@@ -102,29 +116,28 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alignment" >
<set>Qt::AlignRight</set>
</property>
<property name="maximum" >
<number>999999</number>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="advancedLabel" >
<item row="2" column="3" >
<widget class="QToolButton" name="slaveBrowseButton" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Customize</string>
<string>Browse</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2" >
<item row="3" column="1" colspan="3" >
<widget class="QLineEdit" name="advancedLineInput" />
</item>
<item row="2" column="1" colspan="2" >
<widget class="QLineEdit" name="slaveText" >
<property name="enabled" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3" >
<item row="1" column="0" colspan="4" >
<widget class="QCheckBox" name="slaveCheckbox" >
<property name="text" >
<string>Play another media synchronously (extra audio file, ...)</string>
......@@ -226,5 +239,21 @@
</hint>
</hints>
</connection>
<connection>
<sender>slaveCheckbox</sender>
<signal>clicked(bool)</signal>
<receiver>slaveBrowseButton</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>219</x>
<y>102</y>
</hint>
<hint type="destinationlabel" >
<x>386</x>
<y>131</y>
</hint>
</hints>
</connection>
</connections>
</ui>
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>487</width>
<height>254</height>
<width>539</width>
<height>246</height>
</rect>
</property>
<property name="windowTitle" >
......@@ -32,28 +32,74 @@
<property name="spacing" >
<number>6</number>
</property>
<item row="1" column="0" >
<item row="0" column="4" >
<widget class="QRadioButton" name="vcdRadioButton" >
<property name="text" >
<string>SVCD/VCD</string>
</property>
</widget>
</item>
<item row="0" column="5" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0" colspan="2" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Disk device</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QRadioButton" name="vcdRadioButton" >
<item row="0" column="3" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1" colspan="2" >
<widget class="QRadioButton" name="dvdRadioButton" >
<property name="layoutDirection" >
<enum>Qt::LeftToRight</enum>
</property>
<property name="text" >
<string>SVCD/VCD</string>
<string>DVD</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2" >
<item row="2" column="2" colspan="5" >
<widget class="QComboBox" name="deviceCombo" >
<property name="editable" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2" >
<item row="2" column="7" >
<widget class="QToolButton" name="toolButton" >
<property name="text" >
<string>Browse</string>
</property>
</widget>
</item>
<item row="0" column="6" >
<widget class="QRadioButton" name="audioCDRadioButton" >
<property name="text" >
<string>Audio CD</string>
......@@ -61,12 +107,35 @@
</widget>
</item>
<item row="0" column="0" >
<widget class="QRadioButton" name="dvdRadioButton" >
<property name="text" >
<string>DVD</string>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="checked" >
<bool>true</bool>
<property name="sizeHint" >
<size>
<width>21</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="7" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1" colspan="6" >
<widget class="Line" name="line" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
......@@ -102,6 +171,9 @@
</item>
<item row="1" column="1" >
<widget class="QSpinBox" name="chapterSpin" >
<property name="alignment" >
<set>Qt::AlignRight</set>
</property>
<property name="suffix" >
<string/>
</property>
......@@ -128,6 +200,9 @@
<property name="autoFillBackground" >
<bool>false</bool>
</property>
<property name="alignment" >
<set>Qt::AlignRight</set>
</property>
<property name="suffix" >
<string/>
</property>
......@@ -149,8 +224,8 @@
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
<width>469</width>
<height>16</height>
</size>
</property>
</spacer>
......
......@@ -6,20 +6,20 @@
<rect>
<x>0</x>
<y>0</y>
<width>487</width>
<height>181</height>
<width>400</width>
<height>210</height>
</rect>
</property>
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>3</hsizetype>
<hsizetype>7</hsizetype>
<vsizetype>3</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle" >
<string>Form</string>
<string>Open File</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
......@@ -28,20 +28,23 @@
<property name="spacing" >
<number>6</number>
</property>
<item row="2" column="1" >
<item row="1" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
<width>3</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="3" >
<item row="3" column="0" colspan="3" >
<widget class="QGroupBox" name="subGroupBox" >
<property name="sizePolicy" >
<sizepolicy>
......@@ -62,10 +65,10 @@
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
<number>6</number>
</property>
<property name="spacing" >
<number>6</number>
<number>5</number>
</property>
<item row="0" column="4" >
<widget class="QPushButton" name="subBrowseButton" >
......@@ -191,21 +194,10 @@
</layout>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>File</string>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="QPushButton" name="fileBrowseButton" >
<property name="text" >
<string>Browse</string>
</property>
</widget>
<item row="0" column="1" colspan="2" >
<widget class="QWidget" native="1" name="tempWidget" />
</item>
<item row="0" column="1" >
<item row="1" column="2" >
<widget class="QComboBox" name="fileInput" >
<property name="sizePolicy" >
<sizepolicy>
......@@ -223,8 +215,45 @@
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLabel" name="fileLabel" >
<property name="text" >
<string>File / Directory Names;</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="4" column="1" colspan="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>525</width>
<height>31</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<layoutdefault spacing="0" margin="0" />
<resources/>
<connections/>
</ui>
......@@ -67,7 +67,14 @@
</widget>
</item>
<item row="1" column="1" >
<widget class="QComboBox" name="encoding" />
<widget class="QComboBox" name="encoding" >
<property name="maxVisibleItems" >
<number>12</number>
</property>
<property name="frame" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLineEdit" name="preferredLanguage" />
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment