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 @@ ...@@ -26,6 +26,11 @@
#include "qt4.hpp" #include "qt4.hpp"
#include "components/open.hpp" #include "components/open.hpp"
#include "dialogs_provider.hpp" #include "dialogs_provider.hpp"
#include "util/customwidgets.hpp"
#include <QFileDialog>
#include <QDialogButtonBox>
#include <QLineEdit>
/************************************************************************** /**************************************************************************
* File open * File open
...@@ -33,10 +38,39 @@ ...@@ -33,10 +38,39 @@
FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) : FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
OpenPanel( _parent, _p_intf ) OpenPanel( _parent, _p_intf )
{ {
/* Classic UI Setup */
ui.setupUi( this ); 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.subBrowseButton, browseFileSub() );
BUTTONACT( ui.subGroupBox, updateMRL()); BUTTONACT( ui.subGroupBox, updateMRL());
...@@ -44,6 +78,7 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) : ...@@ -44,6 +78,7 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
CONNECT( ui.subInput, editTextChanged(QString ), this, updateMRL()); CONNECT( ui.subInput, editTextChanged(QString ), this, updateMRL());
CONNECT( ui.alignSubComboBox, currentIndexChanged(int), this, updateMRL()); CONNECT( ui.alignSubComboBox, currentIndexChanged(int), this, updateMRL());
CONNECT( ui.sizeSubComboBox, currentIndexChanged(int), this, updateMRL()); CONNECT( ui.sizeSubComboBox, currentIndexChanged(int), this, updateMRL());
CONNECT( lineFileEdit, textChanged( QString ), this, browseFile());
} }
FileOpenPanel::~FileOpenPanel() FileOpenPanel::~FileOpenPanel()
...@@ -57,14 +92,10 @@ QStringList FileOpenPanel::browse(QString help) ...@@ -57,14 +92,10 @@ QStringList FileOpenPanel::browse(QString help)
void FileOpenPanel::browseFile() void FileOpenPanel::browseFile()
{ {
QString fileString = ""; QString fileString = "";
QStringList files = browse( qtr("Open File") ); foreach( QString file, dialogBox->selectedFiles() ) {
foreach( QString file, files) { fileString += "\"" + file + "\" ";
fileString += "\"" + file + "\" ";
} }
ui.fileInput->setEditText( fileString ); ui.fileInput->setEditText( fileString );
ui.fileInput->addItem( fileString );
if ( ui.fileInput->count() > 8 ) ui.fileInput->removeItem(0);
updateMRL(); updateMRL();
} }
...@@ -83,14 +114,24 @@ void FileOpenPanel::updateMRL() ...@@ -83,14 +114,24 @@ void FileOpenPanel::updateMRL()
mrl.append( " :subsdec-align=" + ui.alignSubComboBox->currentText() ); mrl.append( " :subsdec-align=" + ui.alignSubComboBox->currentText() );
mrl.append( " :sub-rel-fontsize=" + ui.sizeSubComboBox->currentText() ); mrl.append( " :sub-rel-fontsize=" + ui.sizeSubComboBox->currentText() );
} }
emit mrlUpdated(mrl); emit mrlUpdated( mrl );
emit methodChanged( "file-caching" ); 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() void FileOpenPanel::clear()
{ {
ui.fileInput->setEditText( ""); ui.fileInput->setEditText( "" );
ui.subInput->setEditText( ""); ui.subInput->setEditText( "" );
} }
......
...@@ -33,6 +33,9 @@ ...@@ -33,6 +33,9 @@
#include "ui/open_net.h" #include "ui/open_net.h"
#include "ui/open_capture.h" #include "ui/open_capture.h"
class QFileDialog;
class QLineEdit;
class OpenPanel: public QWidget class OpenPanel: public QWidget
{ {
Q_OBJECT; Q_OBJECT;
...@@ -59,9 +62,12 @@ public: ...@@ -59,9 +62,12 @@ public:
FileOpenPanel( QWidget *, intf_thread_t * ); FileOpenPanel( QWidget *, intf_thread_t * );
virtual ~FileOpenPanel(); virtual ~FileOpenPanel();
virtual void clear() ; virtual void clear() ;
virtual void accept() ;
private: private:
Ui::OpenFile ui; Ui::OpenFile ui;
QStringList browse( QString ); QStringList browse( QString );
QFileDialog *dialogBox;
QLineEdit *lineFileEdit;
public slots: public slots:
virtual void updateMRL(); virtual void updateMRL();
private slots: private slots:
......
...@@ -42,6 +42,7 @@ OpenDialog::OpenDialog( QWidget *parent, intf_thread_t *_p_intf, bool modal ) : ...@@ -42,6 +42,7 @@ OpenDialog::OpenDialog( QWidget *parent, intf_thread_t *_p_intf, bool modal ) :
setModal( modal ); setModal( modal );
ui.setupUi( this ); ui.setupUi( this );
setWindowTitle( qtr("Open" ) ); setWindowTitle( qtr("Open" ) );
resize( 500, 300);
fileOpenPanel = new FileOpenPanel( this , p_intf ); fileOpenPanel = new FileOpenPanel( this , p_intf );
diskOpenPanel = new DiskOpenPanel( this , p_intf ); diskOpenPanel = new DiskOpenPanel( this , p_intf );
......
...@@ -60,21 +60,11 @@ ...@@ -60,21 +60,11 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<item row="0" column="2" > <item row="2" column="1" colspan="2" >
<widget class="QLabel" name="label" > <widget class="QLineEdit" name="slaveText" >
<property name="text" >
<string>ms</string>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_2" >
<property name="enabled" > <property name="enabled" >
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="text" >
<string>Extra media</string>
</property>
</widget> </widget>
</item> </item>
<item row="0" column="0" > <item row="0" column="0" >
...@@ -92,6 +82,30 @@ ...@@ -92,6 +82,30 @@
</property> </property>
</widget> </widget>
</item> </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" > <item row="0" column="1" >
<widget class="QSpinBox" name="cacheSpinBox" > <widget class="QSpinBox" name="cacheSpinBox" >
<property name="sizePolicy" > <property name="sizePolicy" >
...@@ -102,29 +116,28 @@ ...@@ -102,29 +116,28 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="alignment" >
<set>Qt::AlignRight</set>
</property>
<property name="maximum" > <property name="maximum" >
<number>999999</number> <number>999999</number>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0" > <item row="2" column="3" >
<widget class="QLabel" name="advancedLabel" > <widget class="QToolButton" name="slaveBrowseButton" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" > <property name="text" >
<string>Customize</string> <string>Browse</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1" colspan="2" > <item row="3" column="1" colspan="3" >
<widget class="QLineEdit" name="advancedLineInput" /> <widget class="QLineEdit" name="advancedLineInput" />
</item> </item>
<item row="2" column="1" colspan="2" > <item row="1" column="0" colspan="4" >
<widget class="QLineEdit" name="slaveText" >
<property name="enabled" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3" >
<widget class="QCheckBox" name="slaveCheckbox" > <widget class="QCheckBox" name="slaveCheckbox" >
<property name="text" > <property name="text" >
<string>Play another media synchronously (extra audio file, ...)</string> <string>Play another media synchronously (extra audio file, ...)</string>
...@@ -226,5 +239,21 @@ ...@@ -226,5 +239,21 @@
</hint> </hint>
</hints> </hints>
</connection> </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> </connections>
</ui> </ui>
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>487</width> <width>539</width>
<height>254</height> <height>246</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle" >
...@@ -32,28 +32,74 @@ ...@@ -32,28 +32,74 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </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" > <widget class="QLabel" name="label" >
<property name="text" > <property name="text" >
<string>Disk device</string> <string>Disk device</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1" > <item row="0" column="3" >
<widget class="QRadioButton" name="vcdRadioButton" > <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" > <property name="text" >
<string>SVCD/VCD</string> <string>DVD</string>
</property>
<property name="checked" >
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1" colspan="2" > <item row="2" column="2" colspan="5" >
<widget class="QComboBox" name="deviceCombo" > <widget class="QComboBox" name="deviceCombo" >
<property name="editable" > <property name="editable" >
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </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" > <widget class="QRadioButton" name="audioCDRadioButton" >
<property name="text" > <property name="text" >
<string>Audio CD</string> <string>Audio CD</string>
...@@ -61,12 +107,35 @@ ...@@ -61,12 +107,35 @@
</widget> </widget>
</item> </item>
<item row="0" column="0" > <item row="0" column="0" >
<widget class="QRadioButton" name="dvdRadioButton" > <spacer>
<property name="text" > <property name="orientation" >
<string>DVD</string> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="checked" > <property name="sizeHint" >
<bool>true</bool> <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> </property>
</widget> </widget>
</item> </item>
...@@ -102,6 +171,9 @@ ...@@ -102,6 +171,9 @@
</item> </item>
<item row="1" column="1" > <item row="1" column="1" >
<widget class="QSpinBox" name="chapterSpin" > <widget class="QSpinBox" name="chapterSpin" >
<property name="alignment" >
<set>Qt::AlignRight</set>
</property>
<property name="suffix" > <property name="suffix" >
<string/> <string/>
</property> </property>
...@@ -128,6 +200,9 @@ ...@@ -128,6 +200,9 @@
<property name="autoFillBackground" > <property name="autoFillBackground" >
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="alignment" >
<set>Qt::AlignRight</set>
</property>
<property name="suffix" > <property name="suffix" >
<string/> <string/>
</property> </property>
...@@ -149,8 +224,8 @@ ...@@ -149,8 +224,8 @@
</property> </property>
<property name="sizeHint" > <property name="sizeHint" >
<size> <size>
<width>20</width> <width>469</width>
<height>40</height> <height>16</height>
</size> </size>
</property> </property>
</spacer> </spacer>
......
...@@ -6,20 +6,20 @@ ...@@ -6,20 +6,20 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>487</width> <width>400</width>
<height>181</height> <height>210</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy>
<hsizetype>3</hsizetype> <hsizetype>7</hsizetype>
<vsizetype>3</vsizetype> <vsizetype>3</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="windowTitle" > <property name="windowTitle" >
<string>Form</string> <string>Open File</string>
</property> </property>
<layout class="QGridLayout" > <layout class="QGridLayout" >
<property name="margin" > <property name="margin" >
...@@ -28,20 +28,23 @@ ...@@ -28,20 +28,23 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<item row="2" column="1" > <item row="1" column="0" >
<spacer> <spacer>
<property name="orientation" > <property name="orientation" >
<enum>Qt::Vertical</enum> <enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" >
<size> <size>
<width>20</width> <width>3</width>
<height>40</height> <height>20</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="0" colspan="3" > <item row="3" column="0" colspan="3" >
<widget class="QGroupBox" name="subGroupBox" > <widget class="QGroupBox" name="subGroupBox" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy>
...@@ -62,10 +65,10 @@ ...@@ -62,10 +65,10 @@
</property> </property>
<layout class="QGridLayout" > <layout class="QGridLayout" >
<property name="margin" > <property name="margin" >
<number>9</number> <number>6</number>
</property> </property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>5</number>
</property> </property>
<item row="0" column="4" > <item row="0" column="4" >
<widget class="QPushButton" name="subBrowseButton" > <widget class="QPushButton" name="subBrowseButton" >
...@@ -191,21 +194,10 @@ ...@@ -191,21 +194,10 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="0" column="0" > <item row="0" column="1" colspan="2" >
<widget class="QLabel" name="label" > <widget class="QWidget" native="1" name="tempWidget" />
<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> </item>
<item row="0" column="1" > <item row="1" column="2" >
<widget class="QComboBox" name="fileInput" > <widget class="QComboBox" name="fileInput" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy>
...@@ -223,8 +215,45 @@ ...@@ -223,8 +215,45 @@
</property> </property>
</widget> </widget>
</item> </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> </layout>
</widget> </widget>
<layoutdefault spacing="0" margin="0" />
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>
...@@ -67,7 +67,14 @@ ...@@ -67,7 +67,14 @@
</widget> </widget>
</item> </item>
<item row="1" column="1" > <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>
<item row="0" column="1" > <item row="0" column="1" >
<widget class="QLineEdit" name="preferredLanguage" /> <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