]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs/sout.hpp
Qt: Sout/Convert, display the input MRL.
[vlc] / modules / gui / qt4 / dialogs / sout.hpp
1 /*****************************************************************************
2  * sout.hpp : Stream output dialog ( old-style, ala WX )
3  ****************************************************************************
4  * Copyright ( C ) 2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@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 #ifndef _SOUT_DIALOG_H_
25 #define _SOUT_DIALOG_H_
26
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #include <vlc_common.h> /* Gettext functions */
32
33 #include "ui/sout.h"
34 #include "util/qvlcframe.hpp"
35
36 class QPushButton;
37 class QCheckBox;
38 class QGridLayout;
39 class QTextEdit;
40
41 class SoutMrl
42 {
43 public:
44     SoutMrl( const QString head = "")
45     {
46         mrl = head;
47         b_first = true;
48         b_has_bracket = false;
49     }
50
51     QString getMrl()
52     {
53         return mrl;
54     }
55
56     void begin( QString module )
57     {
58         if( !b_first )
59             mrl += ":";
60         b_first = false;
61
62         mrl += module;
63         b_has_bracket = false;
64     }
65     void end()
66     {
67         if( b_has_bracket )
68             mrl += "}";
69     }
70     void option( const QString option, const QString value = "" )
71     {
72         if( !b_has_bracket )
73             mrl += "{";
74         else
75             mrl += ",";
76         b_has_bracket = true;
77
78         mrl += option;
79
80         if( !value.isEmpty() )
81         {
82             char *psz = config_StringEscape( qtu(value) );
83             if( psz )
84             {
85                 mrl += "=\"" + qfu( psz ) + "\"";
86                 free( psz );
87             }
88         }
89     }
90     void option( const QString name, const int i_value, const int i_precision = 10 )
91     {
92         option( name, QString::number( i_value, i_precision ) );
93     }
94     void option( const QString name, const double f_value )
95     {
96         option( name, QString::number( f_value ) );
97     }
98
99     void option( const QString name, const QString base, const int i_value, const int i_precision = 10 )
100     {
101         option( name, base + ":" + QString::number( i_value, i_precision ) );
102     }
103
104 private:
105     QString mrl;
106     bool b_has_bracket;
107     bool b_first;
108 };
109
110
111 class SoutDialog : public QVLCDialog
112 {
113     Q_OBJECT;
114 public:
115     static SoutDialog* getInstance( QWidget *parent, intf_thread_t *p_intf,
116                                     QString mrl = "" )
117     {
118         if( !instance )
119             instance = new SoutDialog( parent, p_intf, mrl );
120         else
121         {
122             /* Recenter the dialog on the parent */
123             instance->setParent( parent, Qt::Dialog );
124         }
125         return instance;
126     }
127
128     virtual ~SoutDialog(){}
129
130     QString getMrl(){ return mrl; }
131
132 private:
133     Ui::Sout ui;
134     static SoutDialog *instance;
135     SoutDialog( QWidget* parent, intf_thread_t *, QString mrl );
136     QPushButton *okButton;
137     QString mrl;
138
139 public slots:
140     void updateMRL();
141
142 private slots:
143     void ok();
144     void cancel();
145     void setOptions();
146     void fileBrowse();
147     void setRawOptions( bool );
148     void changeUDPandRTPmess( bool );
149     void RTPtoggled( bool );
150     void next();
151 };
152
153 #endif