[vlc-devel] [PATCH] Qt4: Port convert dialog to QWizard

Edward Wang edward.c.wang at compdigitec.com
Thu Dec 29 19:15:41 CET 2011


Porting the wizard has a few other advantages, one of them being that it
makes the interface consistent with the recently updated stream out dialog, secondly
it shows the MRL and allows user to change it (just like stream out
dialog).

Thanks,
    Edward Wang


---
 modules/gui/qt4/Modules.am          |    8 +-
 modules/gui/qt4/dialogs/convert.cpp |  121 +++++------------
 modules/gui/qt4/dialogs/convert.hpp |   16 +--
 modules/gui/qt4/ui/convert.ui       |  240 +++++++++++++++++++++++++++++++++++
 4 files changed, 288 insertions(+), 97 deletions(-)
 create mode 100644 modules/gui/qt4/ui/convert.ui

diff --git a/modules/gui/qt4/Modules.am b/modules/gui/qt4/Modules.am
index 56510f5..988148a 100644
--- a/modules/gui/qt4/Modules.am
+++ b/modules/gui/qt4/Modules.am
@@ -99,7 +99,8 @@ nodist_SOURCES_qt4 = \
 		ui/update.h \
 		dialogs/ml_configuration.moc.cpp \
 		components/playlist/ml_model.moc.cpp \
-		ui/sout.h
+		ui/sout.h \
+		ui/convert.h

 DEPS_res = \
 	pixmaps/arrow_down_dark.png \
@@ -425,6 +426,7 @@ EXTRA_DIST += \
 	ui/about.ui \
 	ui/update.ui \
 	ui/sout.ui \
+	ui/convert.ui \
 	ui/vlm.ui \
 	$(DEPS_res)

diff --git a/modules/gui/qt4/dialogs/convert.cpp b/modules/gui/qt4/dialogs/convert.cpp
index 4bed9fe..24a0b4b 100644
--- a/modules/gui/qt4/dialogs/convert.cpp
+++ b/modules/gui/qt4/dialogs/convert.cpp
@@ -39,120 +39,71 @@

 ConvertDialog::ConvertDialog( QWidget *parent, intf_thread_t *_p_intf,
                               const QString& inputMRL )
-              : QVLCDialog( parent, _p_intf )
+              : QWizard( parent )
 {
+    p_intf = _p_intf;
+    mrl = "";
+
     setWindowTitle( qtr( "Convert" ) );
     setWindowRole( "vlc-convert" );

-    QGridLayout *mainLayout = new QGridLayout( this );
-    SoutInputBox *inputBox = new SoutInputBox( this );
-    inputBox->setMRL( inputMRL );
-    mainLayout->addWidget( inputBox, 0, 0, 1, -1  );
+    ui.setupUi( this );
+    ui.helpEdit->setPlainText( qtr("This wizard will allow you to convert "
+            "your media into different formats.\n"
+            "You should start by checking that source matches what you want "
+            "your input to be and then press the \"Next\" "
+            "button to continue.\n") );
+
+    ui.mrlEdit->setToolTip ( qtr( "Transcoding string.\n"
+                "This is automatically generated "
+                 "when you change the above settings,\n"
+                 "but you can change it manually." ) ) ;

     /**
      * Destination
      **/
-    QGroupBox *destBox = new QGroupBox( qtr( "Destination" ) );
-    QGridLayout *destLayout = new QGridLayout( destBox );
-
-    QLabel *destLabel = new QLabel( qtr( "Destination file:" ) );
-    destLayout->addWidget( destLabel, 0, 0);
-
-    fileLine = new QLineEdit;
-    fileLine->setMinimumWidth( 300 );
-    fileLine->setFocus( Qt::ActiveWindowFocusReason );
-    destLabel->setBuddy( fileLine );
-
-    QPushButton *fileSelectButton = new QPushButton( qtr( "Browse" ) );
-    destLayout->addWidget( fileLine, 0, 1 );
-    destLayout->addWidget( fileSelectButton, 0, 2);
-    BUTTONACT( fileSelectButton, fileBrowse() );
-
-    displayBox = new QCheckBox( qtr( "Display the output" ) );
-    displayBox->setToolTip( qtr( "This display the resulting media, but can "
-                               "slow things down." ) );
-    destLayout->addWidget( displayBox, 2, 0, 1, -1 );
-
-    mainLayout->addWidget( destBox, 1, 0, 1, -1  );
-
-
-    /* Profile Editor */
-    QGroupBox *settingBox = new QGroupBox( qtr( "Settings" ) );
-    QGridLayout *settingLayout = new QGridLayout( settingBox );
-
-    profile = new VLCProfileSelector( this );
-    settingLayout->addWidget( profile, 0, 0, 1, -1 );
-
-    deinterBox = new QCheckBox( qtr( "Deinterlace" ) );
-    settingLayout->addWidget( deinterBox, 1, 0 );
-
-    dumpBox = new QCheckBox( qtr( "Dump raw input" ) );
-    settingLayout->addWidget( dumpBox, 1, 1 );
+    ui.inputBox->setMRL( inputMRL );

-    mainLayout->addWidget( settingBox, 3, 0, 1, -1  );
+    ui.fileLine->setFocus( Qt::ActiveWindowFocusReason );
+    BUTTONACT( ui.destSelectButton, destBrowse() );
+    CONNECT( ui.displayCheckBox, clicked(), this, updateMRL() );
+    CONNECT( ui.displayCheckBox, clicked(), this, updateMRL() );
+    CONNECT( ui.deinterBox, clicked(), this, updateMRL() );
+    CONNECT( ui.dumpBox, clicked(), this, updateMRL() );

-    /* Buttons */
-    QPushButton *okButton = new QPushButton( qtr( "&Start" ) );
-    QPushButton *cancelButton = new QPushButton( qtr( "&Cancel" ) );
-    QDialogButtonBox *buttonBox = new QDialogButtonBox;
-
-    okButton->setDefault( true );
-    buttonBox->addButton( okButton, QDialogButtonBox::AcceptRole );
-    buttonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
-
-    mainLayout->addWidget( buttonBox, 5, 3 );
-
-    BUTTONACT(okButton,close());
-    BUTTONACT(cancelButton,cancel());
-
-    CONNECT(dumpBox,toggled(bool),this,dumpChecked(bool));
+    setButtonText( QWizard::FinishButton, qtr("Convert") );
 }

-void ConvertDialog::fileBrowse()
+void ConvertDialog::destBrowse()
 {
     QString fileName = QFileDialog::getSaveFileName( this, qtr( "Save file..." ),
             "",
  qtr( "Containers (*.ps *.ts *.mpg *.ogg *.asf *.mp4 *.mov *.wav *.raw *.flv *.webm)" ) );
-    fileLine->setText( toNativeSeparators( fileName ) );
-}
-
-void ConvertDialog::cancel()
-{
-    reject();
+    ui.fileLine->setText( toNativeSeparators( fileName ) );
+    updateMRL();
 }

-void ConvertDialog::close()
+void ConvertDialog::updateMRL()
 {
-    hide();
-
-    if( dumpBox->isChecked() )
+    if( ui.dumpBox->isChecked() )
     {
-        mrl = "demux=dump :demuxdump-file=" + fileLine->text();
+        mrl = "demux=dump :demuxdump-file=" + ui.fileLine->text();
     }
     else
     {
-        mrl = "sout=#" + profile->getTranscode();
-        if( deinterBox->isChecked() )
+        mrl = "sout=#" + ui.profile->getTranscode();
+        if( ui.deinterBox->isChecked() )
         {
             mrl.remove( '}' );
             mrl += ",deinterlace}";
         }
         mrl += ":";
-        if( displayBox->isChecked() )
+        if( ui.displayCheckBox->isChecked() )
             mrl += "duplicate{dst=display,dst=";
-        mrl += "std{access=file,mux=" + profile->getMux()
-             + ",dst='" + fileLine->text() + "'}";
-        if( displayBox->isChecked() )
+        mrl += "std{access=file,mux=" + ui.profile->getMux()
+             + ",dst='" + ui.fileLine->text() + "'}";
+        if( ui.displayCheckBox->isChecked() )
             mrl += "}";
     }
-
-    msg_Warn( p_intf, "Transcode MRL: %s", qtu( mrl ) );
-    accept();
-}
-
-void ConvertDialog::dumpChecked( bool checked )
-{
-    deinterBox->setEnabled( !checked );
-    displayBox->setEnabled( !checked );
-    profile->setEnabled( !checked );
+    ui.mrlEdit->setPlainText( mrl );
 }
diff --git a/modules/gui/qt4/dialogs/convert.hpp b/modules/gui/qt4/dialogs/convert.hpp
index de87981..753929c 100644
--- a/modules/gui/qt4/dialogs/convert.hpp
+++ b/modules/gui/qt4/dialogs/convert.hpp
@@ -24,13 +24,14 @@
 #ifndef QVLC_CONVERT_DIALOG_H_
 #define QVLC_CONVERT_DIALOG_H_ 1

+#include "ui/convert.h"
 #include "util/qvlcframe.hpp"

 class QLineEdit;
 class QCheckBox;
 class VLCProfileSelector;

-class ConvertDialog : public QVLCDialog
+class ConvertDialog : public QWizard
 {
     Q_OBJECT
 public:
@@ -40,16 +41,13 @@ public:
     QString getMrl() {return mrl;}

 private:
-    QLineEdit *fileLine;
-
-    QCheckBox *displayBox, *deinterBox, *dumpBox;
-    VLCProfileSelector *profile;
+    Ui::Convert ui;
+    intf_thread_t* p_intf;
     QString mrl;
+
 private slots:
-    virtual void close();
-    virtual void cancel();
-    void fileBrowse();
-    void dumpChecked(bool);
+    virtual void updateMRL();
+    void destBrowse();
 };

 #endif
diff --git a/modules/gui/qt4/ui/convert.ui b/modules/gui/qt4/ui/convert.ui
new file mode 100644
index 0000000..0c43b18
--- /dev/null
+++ b/modules/gui/qt4/ui/convert.ui
@@ -0,0 +1,240 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <author>Edward Wang</author>
+ <class>Convert</class>
+ <widget class="QWizard" name="Convert">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>529</width>
+    <height>344</height>
+   </rect>
+  </property>
+  <property name="minimumSize">
+   <size>
+    <width>400</width>
+    <height>200</height>
+   </size>
+  </property>
+  <property name="windowTitle">
+   <string>Stream Output</string>
+  </property>
+  <property name="wizardStyle">
+   <enum>QWizard::ClassicStyle</enum>
+  </property>
+  <widget class="QWizardPage" name="sourceWizardPage">
+   <property name="title">
+    <string>Source</string>
+   </property>
+   <property name="subTitle">
+    <string>Set up media source to convert</string>
+   </property>
+   <layout class="QGridLayout" name="gridLayout">
+    <item row="0" column="0">
+     <layout class="QVBoxLayout" name="verticalLayout">
+      <item>
+       <widget class="QPlainTextEdit" name="helpEdit">
+        <property name="readOnly">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="SoutInputBox" name="inputBox">
+        <property name="title">
+         <string/>
+        </property>
+        <property name="flat">
+         <bool>true</bool>
+        </property>
+        <property name="checkable">
+         <bool>false</bool>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QWizardPage" name="transcodeWizardPage">
+   <property name="title">
+    <string>Transcoding Options</string>
+   </property>
+   <property name="subTitle">
+    <string>Select and choose transcoding profile</string>
+   </property>
+   <layout class="QVBoxLayout" name="verticalLayout_3">
+    <item>
+     <widget class="VLCProfileSelector" name="profile" native="true"/>
+    </item>
+    <item>
+     <layout class="QHBoxLayout" name="horizontalLayout_2">
+      <item>
+       <widget class="QCheckBox" name="deinterBox">
+        <property name="text">
+         <string>De-interlace</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QCheckBox" name="dumpBox">
+        <property name="toolTip">
+         <string>Copy the source to the destination with no processing</string>
+        </property>
+        <property name="text">
+         <string>Dump raw input</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QWizardPage" name="destinationWizardPage">
+   <property name="title">
+    <string>Destination Setup</string>
+   </property>
+   <property name="subTitle">
+    <string>Select destination file</string>
+   </property>
+   <layout class="QVBoxLayout" name="verticalLayout_7">
+    <item>
+     <layout class="QVBoxLayout" name="verticalLayout_6">
+      <item>
+       <layout class="QHBoxLayout" name="horizontalLayout">
+        <property name="sizeConstraint">
+         <enum>QLayout::SetDefaultConstraint</enum>
+        </property>
+        <item>
+         <widget class="QLineEdit" name="fileLine"/>
+        </item>
+        <item>
+         <widget class="QPushButton" name="destSelectButton">
+          <property name="text">
+           <string>Browse...</string>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </item>
+      <item>
+       <widget class="QCheckBox" name="displayCheckBox">
+        <property name="toolTip">
+         <string>Display the media during conversion, but could cause the conversion to take longer.</string>
+        </property>
+        <property name="text">
+         <string>Display the output</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <spacer name="verticalSpacer">
+        <property name="orientation">
+         <enum>Qt::Vertical</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>20</width>
+          <height>40</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+     </layout>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QWizardPage" name="optionsWizardPage">
+   <property name="title">
+    <string>Review</string>
+   </property>
+   <property name="subTitle">
+    <string>Review generated transcoding string</string>
+   </property>
+   <layout class="QVBoxLayout" name="verticalLayout_2">
+    <item>
+     <widget class="QGroupBox" name="groupBox_4">
+      <property name="title">
+       <string>Generated stream output string</string>
+      </property>
+      <layout class="QVBoxLayout" name="verticalLayout_5">
+       <item>
+        <widget class="QTextEdit" name="mrlEdit">
+         <property name="acceptRichText">
+          <bool>false</bool>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </widget>
+    </item>
+   </layout>
+  </widget>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>VLCProfileSelector</class>
+   <extends>QWidget</extends>
+   <header>components/sout/profile_selector.hpp</header>
+   <container>1</container>
+  </customwidget>
+  <customwidget>
+   <class>SoutInputBox</class>
+   <extends>QGroupBox</extends>
+   <header>components/sout/sout_widgets.hpp</header>
+   <container>1</container>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>dumpBox</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>profile</receiver>
+   <slot>setDisabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>386</x>
+     <y>109</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>264</x>
+     <y>86</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>dumpBox</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>deinterBox</receiver>
+   <slot>setDisabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>386</x>
+     <y>109</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>142</x>
+     <y>109</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>dumpBox</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>displayCheckBox</receiver>
+   <slot>setDisabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>386</x>
+     <y>109</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>264</x>
+     <y>128</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
--
1.7.5.4




More information about the vlc-devel mailing list