1 | /* smplayer, GUI front-end for mplayer.
|
---|
2 | Copyright (C) 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net>
|
---|
3 |
|
---|
4 | This program is free software; you can redistribute it and/or modify
|
---|
5 | it under the terms of the GNU General Public License as published by
|
---|
6 | the Free Software Foundation; either version 2 of the License, or
|
---|
7 | (at your option) any later version.
|
---|
8 |
|
---|
9 | This program is distributed in the hope that it will be useful,
|
---|
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
12 | GNU General Public License for more details.
|
---|
13 |
|
---|
14 | You should have received a copy of the GNU General Public License
|
---|
15 | along with this program; if not, write to the Free Software
|
---|
16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
17 | */
|
---|
18 |
|
---|
19 | #include "filepropertiesdialog.h"
|
---|
20 | #include <QListWidget>
|
---|
21 | #include <QLineEdit>
|
---|
22 | #include <QTextEdit>
|
---|
23 | #include <QPushButton>
|
---|
24 | #include "images.h"
|
---|
25 | #include "infofile.h"
|
---|
26 | #include "playerid.h"
|
---|
27 |
|
---|
28 | #if QT_VERSION >= 0x050000
|
---|
29 | #include "myscroller.h"
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | FilePropertiesDialog::FilePropertiesDialog( QWidget* parent, Qt::WindowFlags f )
|
---|
33 | : QDialog(parent, f)
|
---|
34 | {
|
---|
35 | setupUi(this);
|
---|
36 |
|
---|
37 | // Setup buttons
|
---|
38 | okButton = buttonBox->button(QDialogButtonBox::Ok);
|
---|
39 | cancelButton = buttonBox->button(QDialogButtonBox::Cancel);
|
---|
40 | applyButton = buttonBox->button(QDialogButtonBox::Apply);
|
---|
41 | connect( applyButton, SIGNAL(clicked()), this, SLOT(apply()) );
|
---|
42 |
|
---|
43 | #if ALLOW_DEMUXER_CODEC_CHANGE
|
---|
44 | codecs_set = false;
|
---|
45 | #else
|
---|
46 | // Hide unused tabs
|
---|
47 | int i = tabWidget->indexOf(demuxer_page);
|
---|
48 | if (i != -1) tabWidget->removeTab(i);
|
---|
49 | i = tabWidget->indexOf(vc_page);
|
---|
50 | if (i != -1) tabWidget->removeTab(i);
|
---|
51 | i = tabWidget->indexOf(ac_page);
|
---|
52 | if (i != -1) tabWidget->removeTab(i);
|
---|
53 | #endif
|
---|
54 |
|
---|
55 | #if QT_VERSION >= 0x050000
|
---|
56 | MyScroller::setScroller(info_edit);
|
---|
57 | MyScroller::setScroller(demuxer_listbox->viewport());
|
---|
58 | MyScroller::setScroller(vc_listbox->viewport());
|
---|
59 | MyScroller::setScroller(ac_listbox->viewport());
|
---|
60 | #endif
|
---|
61 |
|
---|
62 | retranslateStrings();
|
---|
63 | }
|
---|
64 |
|
---|
65 | FilePropertiesDialog::~FilePropertiesDialog() {
|
---|
66 | }
|
---|
67 |
|
---|
68 | void FilePropertiesDialog::setMediaData(MediaData md) {
|
---|
69 | media_data = md;
|
---|
70 | showInfo();
|
---|
71 | }
|
---|
72 |
|
---|
73 | void FilePropertiesDialog::showInfo() {
|
---|
74 | InfoFile info;
|
---|
75 | info_edit->setText( info.getInfo(media_data) );
|
---|
76 | }
|
---|
77 |
|
---|
78 | void FilePropertiesDialog::retranslateStrings() {
|
---|
79 | retranslateUi(this);
|
---|
80 |
|
---|
81 | setWindowIcon( Images::icon("logo") );
|
---|
82 |
|
---|
83 | showInfo();
|
---|
84 |
|
---|
85 | // Qt 4.2 doesn't update the buttons' text
|
---|
86 | #if QT_VERSION < 0x040300
|
---|
87 | okButton->setText( tr("OK") );
|
---|
88 | cancelButton->setText( tr("Cancel") );
|
---|
89 | applyButton->setText( tr("Apply") );
|
---|
90 | #endif
|
---|
91 |
|
---|
92 | #if ALLOW_DEMUXER_CODEC_CHANGE
|
---|
93 | int tab_idx = 4;
|
---|
94 | #else
|
---|
95 | int tab_idx = 1;
|
---|
96 | #endif
|
---|
97 | tabWidget->setTabText(tab_idx, tr("O&ptions for %1").arg(PLAYER_NAME) );
|
---|
98 | groupBox->setTitle( tr("Additional Options for %1").arg(PLAYER_NAME) );
|
---|
99 | options_info_label->setText( tr("Here you can pass extra options to %1.").arg(PLAYER_NAME) +"<br>"+
|
---|
100 | tr("Write them separated by spaces.") + "<br>" + tr("Example:") + " -volume 50 -fps 25" );
|
---|
101 | }
|
---|
102 |
|
---|
103 | void FilePropertiesDialog::accept() {
|
---|
104 | qDebug("FilePropertiesDialog::accept");
|
---|
105 |
|
---|
106 | hide();
|
---|
107 | setResult( QDialog::Accepted );
|
---|
108 | emit applied();
|
---|
109 | }
|
---|
110 |
|
---|
111 | void FilePropertiesDialog::apply() {
|
---|
112 | qDebug("FilePropertiesDialog::apply");
|
---|
113 |
|
---|
114 | setResult( QDialog::Accepted );
|
---|
115 | emit applied();
|
---|
116 | }
|
---|
117 |
|
---|
118 | #if ALLOW_DEMUXER_CODEC_CHANGE
|
---|
119 | void FilePropertiesDialog::setCodecs(InfoList vc, InfoList ac, InfoList demuxer)
|
---|
120 | {
|
---|
121 | vclist = vc;
|
---|
122 | aclist = ac;
|
---|
123 | demuxerlist = demuxer;
|
---|
124 |
|
---|
125 | qSort(vclist);
|
---|
126 | qSort(aclist);
|
---|
127 | qSort(demuxerlist);
|
---|
128 |
|
---|
129 | vc_listbox->clear();
|
---|
130 | ac_listbox->clear();
|
---|
131 | demuxer_listbox->clear();
|
---|
132 |
|
---|
133 | InfoList::iterator it;
|
---|
134 |
|
---|
135 | for ( it = vclist.begin(); it != vclist.end(); ++it ) {
|
---|
136 | vc_listbox->addItem( (*it).name() +" - "+ (*it).desc() );
|
---|
137 | }
|
---|
138 |
|
---|
139 | for ( it = aclist.begin(); it != aclist.end(); ++it ) {
|
---|
140 | ac_listbox->addItem( (*it).name() +" - "+ (*it).desc() );
|
---|
141 | }
|
---|
142 |
|
---|
143 | for ( it = demuxerlist.begin(); it != demuxerlist.end(); ++it ) {
|
---|
144 | demuxer_listbox->addItem( (*it).name() +" - "+ (*it).desc() );
|
---|
145 | }
|
---|
146 |
|
---|
147 | codecs_set = true;
|
---|
148 | }
|
---|
149 |
|
---|
150 | void FilePropertiesDialog::setDemuxer(QString demuxer, QString original_demuxer) {
|
---|
151 | qDebug("FilePropertiesDialog::setDemuxer");
|
---|
152 | if (!original_demuxer.isEmpty()) orig_demuxer = original_demuxer;
|
---|
153 | int pos = find(demuxer, demuxerlist );
|
---|
154 | if (pos != -1) demuxer_listbox->setCurrentRow(pos);
|
---|
155 |
|
---|
156 | qDebug(" * demuxer: '%s', pos: %d", demuxer.toUtf8().data(), pos );
|
---|
157 | }
|
---|
158 |
|
---|
159 | QString FilePropertiesDialog::demuxer() {
|
---|
160 | int pos = demuxer_listbox->currentRow();
|
---|
161 | if ( pos < 0 )
|
---|
162 | return "";
|
---|
163 | else
|
---|
164 | return demuxerlist[pos].name();
|
---|
165 | }
|
---|
166 |
|
---|
167 | void FilePropertiesDialog::setVideoCodec(QString vc, QString original_vc) {
|
---|
168 | qDebug("FilePropertiesDialog::setVideoCodec");
|
---|
169 | if (!original_vc.isEmpty()) orig_vc = original_vc;
|
---|
170 | int pos = find(vc, vclist );
|
---|
171 | if (pos != -1) vc_listbox->setCurrentRow(pos);
|
---|
172 |
|
---|
173 | qDebug(" * vc: '%s', pos: %d", vc.toUtf8().data(), pos );
|
---|
174 | }
|
---|
175 |
|
---|
176 | QString FilePropertiesDialog::videoCodec() {
|
---|
177 | int pos = vc_listbox->currentRow();
|
---|
178 | if ( pos < 0 )
|
---|
179 | return "";
|
---|
180 | else
|
---|
181 | return vclist[pos].name();
|
---|
182 | }
|
---|
183 |
|
---|
184 | void FilePropertiesDialog::setAudioCodec(QString ac, QString original_ac) {
|
---|
185 | qDebug("FilePropertiesDialog::setAudioCodec");
|
---|
186 | if (!original_ac.isEmpty()) orig_ac = original_ac;
|
---|
187 | int pos = find(ac, aclist );
|
---|
188 | if (pos != -1) ac_listbox->setCurrentRow(pos);
|
---|
189 |
|
---|
190 | qDebug(" * ac: '%s', pos: %d", ac.toUtf8().data(), pos );
|
---|
191 | }
|
---|
192 |
|
---|
193 | QString FilePropertiesDialog::audioCodec() {
|
---|
194 | int pos = ac_listbox->currentRow();
|
---|
195 | if ( pos < 0 )
|
---|
196 | return "";
|
---|
197 | else
|
---|
198 | return aclist[pos].name();
|
---|
199 | }
|
---|
200 |
|
---|
201 | void FilePropertiesDialog::on_resetDemuxerButton_clicked() {
|
---|
202 | setDemuxer( orig_demuxer );
|
---|
203 | }
|
---|
204 |
|
---|
205 | void FilePropertiesDialog::on_resetACButton_clicked() {
|
---|
206 | setAudioCodec( orig_ac );
|
---|
207 | }
|
---|
208 |
|
---|
209 | void FilePropertiesDialog::on_resetVCButton_clicked() {
|
---|
210 | setVideoCodec( orig_vc );
|
---|
211 | }
|
---|
212 |
|
---|
213 | int FilePropertiesDialog::find(QString s, InfoList &list) {
|
---|
214 | qDebug("FilePropertiesDialog::find");
|
---|
215 |
|
---|
216 | int n=0;
|
---|
217 | InfoList::iterator it;
|
---|
218 |
|
---|
219 | for ( it = list.begin(); it != list.end(); ++it ) {
|
---|
220 | //qDebug(" * item: '%s', s: '%s'", (*it).name().toUtf8().data(), s.toUtf8().data());
|
---|
221 | if ((*it).name() == s) return n;
|
---|
222 | n++;
|
---|
223 | }
|
---|
224 | return -1;
|
---|
225 | }
|
---|
226 | #endif
|
---|
227 |
|
---|
228 | void FilePropertiesDialog::setMplayerAdditionalArguments(QString args) {
|
---|
229 | mplayer_args_edit->setText(args);
|
---|
230 | }
|
---|
231 |
|
---|
232 | QString FilePropertiesDialog::mplayerAdditionalArguments() {
|
---|
233 | return mplayer_args_edit->text();
|
---|
234 | }
|
---|
235 |
|
---|
236 | void FilePropertiesDialog::setMplayerAdditionalVideoFilters(QString s) {
|
---|
237 | mplayer_vfilters_edit->setText(s);
|
---|
238 | }
|
---|
239 |
|
---|
240 | QString FilePropertiesDialog::mplayerAdditionalVideoFilters() {
|
---|
241 | return mplayer_vfilters_edit->text();
|
---|
242 | }
|
---|
243 |
|
---|
244 | void FilePropertiesDialog::setMplayerAdditionalAudioFilters(QString s) {
|
---|
245 | mplayer_afilters_edit->setText(s);
|
---|
246 | }
|
---|
247 |
|
---|
248 | QString FilePropertiesDialog::mplayerAdditionalAudioFilters() {
|
---|
249 | return mplayer_afilters_edit->text();
|
---|
250 | }
|
---|
251 |
|
---|
252 | // Language change stuff
|
---|
253 | void FilePropertiesDialog::changeEvent(QEvent *e) {
|
---|
254 | if (e->type() == QEvent::LanguageChange) {
|
---|
255 | retranslateStrings();
|
---|
256 | } else {
|
---|
257 | QDialog::changeEvent(e);
|
---|
258 | }
|
---|
259 | }
|
---|
260 |
|
---|
261 | #include "moc_filepropertiesdialog.cpp"
|
---|