]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs/convert.cpp
5a989ffddb3490b11c1d1f7d2c03db5aa6bffbb5
[vlc] / modules / gui / qt4 / dialogs / convert.cpp
1 /*****************************************************************************
2  * Convert.cpp : Convertion dialogs
3  ****************************************************************************
4  * Copyright (C) 2009 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Jean-Baptiste Kempf <jb (at) videolan.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #ifdef HAVE_CONFIG_H
25 # include "config.h"
26 #endif
27
28 #include "dialogs/sout.hpp"
29 #include "dialogs/convert.hpp"
30 #include "components/sout/sout_widgets.hpp"
31
32 #include "util/qt_dirs.hpp"
33
34 #include <QLabel>
35 #include <QGroupBox>
36 #include <QDialogButtonBox>
37 #include <QFileDialog>
38 #include <QCheckBox>
39
40 ConvertDialog::ConvertDialog( QWidget *parent, intf_thread_t *_p_intf,
41                               QString inputMRL )
42               : QVLCDialog( parent, _p_intf )
43 {
44     setWindowTitle( qtr( "Convert" ) );
45
46     QGridLayout *mainLayout = new QGridLayout( this );
47     SoutInputBox *inputBox = new SoutInputBox( this );
48     inputBox->setMRL( inputMRL );
49     mainLayout->addWidget( inputBox, 0, 0, 1, -1  );
50
51     /**
52      * Destination
53      **/
54     QGroupBox *destBox = new QGroupBox( qtr( "Destination" ) );
55     QGridLayout *destLayout = new QGridLayout( destBox );
56
57     QLabel *destLabel = new QLabel( qtr( "Target file:" ) );
58     destLayout->addWidget( destLabel, 0, 0);
59
60     fileLine = new QLineEdit;
61     fileLine->setMinimumWidth( 300 );
62     fileLine->setFocus( Qt::ActiveWindowFocusReason );
63     destLabel->setBuddy( fileLine );
64
65     QPushButton *fileSelectButton = new QPushButton( qtr( "Browse" ) );
66     destLayout->addWidget( fileLine, 0, 1 );
67     destLayout->addWidget( fileSelectButton, 0, 2);
68     BUTTONACT( fileSelectButton, fileBrowse() );
69
70     displayBox = new QCheckBox( qtr( "Display the output" ) );
71     displayBox->setToolTip( qtr( "This display the resulting media, but can "
72                                "slow things down." ) );
73     destLayout->addWidget( displayBox, 2, 0, 1, -1 );
74
75     mainLayout->addWidget( destBox, 1, 0, 1, -1  );
76
77
78     /* Profile Editor */
79     QGroupBox *settingBox = new QGroupBox( qtr( "Settings" ) );
80     QGridLayout *settingLayout = new QGridLayout( settingBox );
81
82     profile = new VLCProfileSelector( this );
83     settingLayout->addWidget( profile, 0, 0 );
84
85     deinterBox = new QCheckBox( qtr( "Deinterlace" ) );
86     settingLayout->addWidget( deinterBox, 1, 0 );
87
88     mainLayout->addWidget( settingBox, 3, 0, 1, -1  );
89
90     /* Buttons */
91     QPushButton *okButton = new QPushButton( qtr( "&Start" ) );
92     QPushButton *cancelButton = new QPushButton( qtr( "&Cancel" ) );
93     QDialogButtonBox *buttonBox = new QDialogButtonBox;
94
95     okButton->setDefault( true );
96     buttonBox->addButton( okButton, QDialogButtonBox::AcceptRole );
97     buttonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
98
99     mainLayout->addWidget( buttonBox, 5, 3 );
100
101     BUTTONACT( okButton, close() );
102     BUTTONACT( cancelButton, cancel() );
103 }
104
105 void ConvertDialog::fileBrowse()
106 {
107     QString fileName = QFileDialog::getSaveFileName( this, qtr( "Save file..." ),
108             "",
109  qtr( "Containers (*.ps *.ts *.mpg *.ogg *.asf *.mp4 *.mov *.wav *.raw *.flv)" ) );
110     fileLine->setText( toNativeSeparators( fileName ) );
111 }
112
113 void ConvertDialog::cancel()
114 {
115     reject();
116 }
117
118 void ConvertDialog::close()
119 {
120     hide();
121
122     mrl = "sout=#" + profile->getTranscode();
123     if( deinterBox->isChecked() )
124     {
125         mrl.remove( '}' );
126         mrl += ",deinterlace}";
127     }
128     mrl += ":duplicate{";
129     if( displayBox->isChecked() ) mrl += "dst=display,";
130     mrl += "dst=std{access=file,mux=" + profile->getMux() +
131             ",dst='" + fileLine->text() + "'}";
132
133     msg_Dbg( p_intf, "Transcode MRL: %s", qtu( mrl ) );
134     accept();
135 }