source: smplayer/trunk/src/prefadvanced.cpp@ 121

Last change on this file since 121 was 119, checked in by Silvan Scherrer, 14 years ago

SMPlayer: latest svn update

  • Property svn:eol-style set to LF
File size: 15.2 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2011 Ricardo Villalba <rvm@escomposlinux.org>
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
20#include "prefadvanced.h"
21#include "images.h"
22#include "preferences.h"
23#include "paths.h"
24#include <QColorDialog>
25
26PrefAdvanced::PrefAdvanced(QWidget * parent, Qt::WindowFlags f)
27 : PrefWidget(parent, f )
28{
29 setupUi(this);
30
31#ifndef Q_OS_WIN
32 shortnames_check->hide();
33#endif
34
35#if !USE_COLORKEY
36 colorkey_label->hide();
37 colorkey_view->hide();
38 changeButton->hide();
39#endif
40
41#if !REPAINT_BACKGROUND_OPTION
42 repaint_video_background_check->hide();
43#endif
44
45 // Monitor aspect
46 monitoraspect_combo->addItem("Auto");
47 monitoraspect_combo->addItem("4:3");
48 monitoraspect_combo->addItem("16:9");
49 monitoraspect_combo->addItem("5:4");
50 monitoraspect_combo->addItem("16:10");
51
52 retranslateStrings();
53}
54
55PrefAdvanced::~PrefAdvanced()
56{
57}
58
59QString PrefAdvanced::sectionName() {
60 return tr("Advanced");
61}
62
63QPixmap PrefAdvanced::sectionIcon() {
64 return Images::icon("pref_advanced");
65}
66
67
68void PrefAdvanced::retranslateStrings() {
69 retranslateUi(this);
70
71 monitor_aspect_icon->setPixmap( Images::icon("monitor") );
72
73 monitoraspect_combo->setItemText(0, tr("Auto") );
74
75 createHelp();
76}
77
78void PrefAdvanced::setData(Preferences * pref) {
79 setMonitorAspect( pref->monitor_aspect );
80
81#if REPAINT_BACKGROUND_OPTION
82 setRepaintVideoBackground( pref->repaint_video_background );
83#endif
84 setUseMplayerWindow( pref->use_mplayer_window );
85 setMplayerAdditionalArguments( pref->mplayer_additional_options );
86 setMplayerAdditionalVideoFilters( pref->mplayer_additional_video_filters );
87 setMplayerAdditionalAudioFilters( pref->mplayer_additional_audio_filters );
88#if USE_COLORKEY
89 setColorKey( pref->color_key );
90#endif
91 setPreferIpv4( pref->prefer_ipv4 );
92 setUseIdx( pref->use_idx );
93 setUseCorrectPts( pref->use_correct_pts );
94 setActionsToRun( pref->actions_to_run );
95 setShowTagInTitle( pref->show_tag_in_window_title );
96
97 setLogMplayer( pref->log_mplayer );
98 setMplayerLogVerbose( pref->verbose_log );
99 setLogSmplayer( pref->log_smplayer );
100 setLogFilter( pref->log_filter );
101
102 setSaveMplayerLog( pref->autosave_mplayer_log );
103 setMplayerLogName( pref->mplayer_log_saveto );
104
105 setSaveSmplayerLog( pref->save_smplayer_log );
106
107 setUseShortNames( pref->use_short_pathnames );
108}
109
110void PrefAdvanced::getData(Preferences * pref) {
111 requires_restart = false;
112
113#if REPAINT_BACKGROUND_OPTION
114 repaint_video_background_changed = false;
115#endif
116
117 monitor_aspect_changed = false;
118#if USE_COLORKEY
119 colorkey_changed = false;
120#endif
121 pref->prefer_ipv4 = preferIpv4();
122 TEST_AND_SET(pref->use_idx, useIdx());
123 TEST_AND_SET(pref->use_correct_pts, useCorrectPts());
124 pref->actions_to_run = actionsToRun();
125 //TEST_AND_SET(pref->show_tag_in_window_title, showTagInTitle());
126 pref->show_tag_in_window_title = showTagInTitle(); // TODO: detect change and apply
127
128 if (pref->monitor_aspect != monitorAspect()) {
129 pref->monitor_aspect = monitorAspect();
130 monitor_aspect_changed = true;
131 requires_restart = true;
132 }
133
134#if REPAINT_BACKGROUND_OPTION
135 if (pref->repaint_video_background != repaintVideoBackground()) {
136 pref->repaint_video_background = repaintVideoBackground();
137 repaint_video_background_changed = true;
138 }
139#endif
140
141 TEST_AND_SET(pref->use_mplayer_window, useMplayerWindow());
142 TEST_AND_SET(pref->mplayer_additional_options, mplayerAdditionalArguments());
143 TEST_AND_SET(pref->mplayer_additional_video_filters, mplayerAdditionalVideoFilters());
144 TEST_AND_SET(pref->mplayer_additional_audio_filters, mplayerAdditionalAudioFilters());
145#if USE_COLORKEY
146 if (pref->color_key != colorKey()) {
147 pref->color_key = colorKey();
148 colorkey_changed = true;
149 requires_restart = true;
150 }
151#endif
152 pref->log_mplayer = logMplayer();
153 TEST_AND_SET( pref->verbose_log, mplayerLogVerbose() );
154 pref->log_smplayer = logSmplayer();
155 pref->log_filter = logFilter();
156 pref->autosave_mplayer_log = saveMplayerLog();
157 pref->mplayer_log_saveto = mplayerLogName();
158
159 pref->save_smplayer_log = saveSmplayerLog();
160
161 pref->use_short_pathnames = useShortNames();
162}
163
164void PrefAdvanced::setMonitorAspect(QString asp) {
165 if (asp.isEmpty())
166 monitoraspect_combo->setCurrentIndex( 0 );
167 else
168 monitoraspect_combo->setCurrentText(asp);
169 //monitoraspect_combo->setEditText(asp);
170}
171
172QString PrefAdvanced::monitorAspect() {
173 if (monitoraspect_combo->currentIndex() == 0 )
174 return "";
175 else
176 return monitoraspect_combo->currentText();
177}
178
179#if REPAINT_BACKGROUND_OPTION
180void PrefAdvanced::setRepaintVideoBackground(bool b) {
181 repaint_video_background_check->setChecked(b);
182}
183
184bool PrefAdvanced::repaintVideoBackground() {
185 return repaint_video_background_check->isChecked();
186}
187#endif
188
189void PrefAdvanced::setUseMplayerWindow(bool v) {
190 mplayer_use_window_check->setChecked(v);
191}
192
193bool PrefAdvanced::useMplayerWindow() {
194 return mplayer_use_window_check->isChecked();
195}
196
197void PrefAdvanced::setUseShortNames(bool b) {
198 shortnames_check->setChecked(b);
199}
200
201bool PrefAdvanced::useShortNames() {
202 return shortnames_check->isChecked();
203}
204
205void PrefAdvanced::setMplayerAdditionalArguments(QString args) {
206 mplayer_args_edit->setText(args);
207}
208
209QString PrefAdvanced::mplayerAdditionalArguments() {
210 return mplayer_args_edit->text();
211}
212
213void PrefAdvanced::setMplayerAdditionalVideoFilters(QString s) {
214 mplayer_vfilters_edit->setText(s);
215}
216
217QString PrefAdvanced::mplayerAdditionalVideoFilters() {
218 return mplayer_vfilters_edit->text();
219}
220
221void PrefAdvanced::setMplayerAdditionalAudioFilters(QString s) {
222 mplayer_afilters_edit->setText(s);
223}
224
225QString PrefAdvanced::mplayerAdditionalAudioFilters() {
226 return mplayer_afilters_edit->text();
227}
228
229#if USE_COLORKEY
230void PrefAdvanced::setColorKey(unsigned int c) {
231 QString color = QString::number(c, 16);
232 while (color.length() < 6) color = "0"+color;
233 colorkey_view->setText( "#" + color );
234}
235
236unsigned int PrefAdvanced::colorKey() {
237 QString c = colorkey_view->text();
238 if (c.startsWith("#")) c = c.mid(1);
239
240 bool ok;
241 unsigned int color = c.toUInt(&ok, 16);
242
243 if (!ok)
244 qWarning("PrefAdvanced::colorKey: cannot convert color to uint");
245
246 qDebug("PrefAdvanced::colorKey: color: %s", QString::number(color,16).toUtf8().data() );
247
248 return color;
249}
250#endif
251
252void PrefAdvanced::setPreferIpv4(bool b) {
253 if (b)
254 ipv4_button->setChecked(true);
255 else
256 ipv6_button->setChecked(true);
257}
258
259bool PrefAdvanced::preferIpv4() {
260 return ipv4_button->isChecked();
261}
262
263void PrefAdvanced::setUseIdx(bool b) {
264 idx_check->setChecked(b);
265}
266
267bool PrefAdvanced::useIdx() {
268 return idx_check->isChecked();
269}
270
271void PrefAdvanced::setUseCorrectPts(Preferences::OptionState value) {
272 correct_pts_combo->setState(value);
273}
274
275Preferences::OptionState PrefAdvanced::useCorrectPts() {
276 return correct_pts_combo->state();
277}
278
279void PrefAdvanced::setActionsToRun(QString actions) {
280 actions_to_run_edit->setText(actions);
281}
282
283QString PrefAdvanced::actionsToRun() {
284 return actions_to_run_edit->text();
285}
286
287void PrefAdvanced::setShowTagInTitle(bool b) {
288 show_tag_in_title_check->setChecked(b);
289}
290
291bool PrefAdvanced::showTagInTitle() {
292 return show_tag_in_title_check->isChecked();
293}
294
295void PrefAdvanced::on_changeButton_clicked() {
296 //bool ok;
297 //int color = colorkey_view->text().toUInt(&ok, 16);
298 QColor color( colorkey_view->text() );
299 QColor c = QColorDialog::getColor ( color, this );
300 if (c.isValid()) {
301 //colorkey_view->setText( QString::number( c.rgb(), 16 ) );
302 colorkey_view->setText( c.name() );
303 }
304}
305
306// Log options
307void PrefAdvanced::setLogMplayer(bool b) {
308 log_mplayer_check->setChecked(b);
309}
310
311bool PrefAdvanced::logMplayer() {
312 return log_mplayer_check->isChecked();
313}
314
315void PrefAdvanced::setMplayerLogVerbose(bool b) {
316 verbose_check->setChecked(b);
317}
318
319bool PrefAdvanced::mplayerLogVerbose() {
320 return verbose_check->isChecked();
321}
322
323void PrefAdvanced::setLogSmplayer(bool b) {
324 log_smplayer_check->setChecked(b);
325}
326
327bool PrefAdvanced::logSmplayer() {
328 return log_smplayer_check->isChecked();
329}
330
331void PrefAdvanced::setLogFilter(QString filter) {
332 log_filter_edit->setText(filter);
333}
334
335QString PrefAdvanced::logFilter() {
336 return log_filter_edit->text();
337}
338
339
340void PrefAdvanced::setSaveMplayerLog(bool b) {
341 log_mplayer_save_check->setChecked(b);
342}
343
344bool PrefAdvanced::saveMplayerLog() {
345 return log_mplayer_save_check->isChecked();
346}
347
348void PrefAdvanced::setMplayerLogName(QString filter) {
349 log_mplayer_save_name->setText(filter);
350}
351
352QString PrefAdvanced::mplayerLogName() {
353 return log_mplayer_save_name->text();
354}
355
356void PrefAdvanced::setSaveSmplayerLog(bool b) {
357 log_smplayer_save_check->setChecked(b);
358}
359
360bool PrefAdvanced::saveSmplayerLog(){
361 return log_smplayer_save_check->isChecked();
362}
363
364
365void PrefAdvanced::createHelp() {
366 clearHelp();
367
368 addSectionTitle(tr("Advanced"));
369
370 setWhatsThis(monitoraspect_combo, tr("Monitor aspect"),
371 tr("Select the aspect ratio of your monitor.") );
372
373 setWhatsThis(mplayer_use_window_check, tr("Run MPlayer in its own window"),
374 tr("If you check this option, the MPlayer video window won't be "
375 "embedded in SMPlayer's main window but instead it will use its "
376 "own window. Note that mouse and keyboard events will be handled "
377 "directly by MPlayer, that means key shortcuts and mouse clicks "
378 "probably won't work as expected when the MPlayer window has the "
379 "focus.") );
380
381 setWhatsThis(idx_check, tr("Rebuild index if needed"),
382 tr("Rebuilds index of files if no index was found, allowing seeking. "
383 "Useful with broken/incomplete downloads, or badly created files. "
384 "This option only works if the underlying media supports "
385 "seeking (i.e. not with stdin, pipe, etc).<br> "
386 "<b>Note:</b> the creation of the index may take some time.") );
387
388 setWhatsThis(correct_pts_combo, tr("Correct pts"),
389 tr("Switches MPlayer to an experimental mode where timestamps for "
390 "video frames are calculated differently and video filters which "
391 "add new frames or modify timestamps of existing ones are "
392 "supported. The more accurate timestamps can be visible for "
393 "example when playing subtitles timed to scene changes with the "
394 "SSA/ASS library enabled. Without correct pts the subtitle timing "
395 "will typically be off by some frames. This option does not work "
396 "correctly with some demuxers and codecs.") );
397
398#ifdef Q_OS_WIN
399 setWhatsThis(shortnames_check, tr("Pass short filenames (8+3) to MPlayer"),
400 tr("Currently MPlayer can't open filenames which contains characters "
401 "outside the local codepage. Checking this option will make "
402 "SMPlayer to pass to MPlayer the short version of the filenames, "
403 "and thus it will able to open them.") );
404#endif
405
406#if REPAINT_BACKGROUND_OPTION
407 setWhatsThis(repaint_video_background_check,
408 tr("Repaint the background of the video window"),
409 tr("Checking this option may reduce flickering, but it also might "
410 "produce that the video won't be displayed properly.") );
411#endif
412
413#if USE_COLORKEY
414 setWhatsThis(colorkey_view, tr("Colorkey"),
415 tr("If you see parts of the video over any other window, you can "
416 "change the colorkey to fix it. Try to select a color close to "
417 "black.") );
418#endif
419
420 setWhatsThis(actions_to_run_edit, tr("Actions list"),
421 tr("Here you can specify a list of <i>actions</i> which will be "
422 "run every time a file is opened. You'll find all available "
423 "actions in the key shortcut editor in the <b>Keyboard and mouse</b> "
424 "section. The actions must be separated by spaces. Checkable "
425 "actions can be followed by <i>true</i> or <i>false</i> to "
426 "enable or disable the action.") +"<br>"+
427 tr("Example:") +" <i>auto_zoom compact true</i><br>" +
428 tr("Limitation: the actions are run only when a file is opened and "
429 "not when the mplayer process is restarted (e.g. you select an "
430 "audio or video filter).") );
431
432 setWhatsThis(show_tag_in_title_check, tr("Show tag info in window title"),
433 tr("If this option is enabled, information from tags will be "
434 "shown in window title. "
435 "Otherwise only the filename will be shown.") );
436
437 addSectionTitle(tr("Options for MPlayer"));
438
439 setWhatsThis(mplayer_args_edit, tr("Options"),
440 tr("Here you can type options for MPlayer. Write them separated "
441 "by spaces.") );
442
443 setWhatsThis(mplayer_vfilters_edit, tr("Video filters"),
444 tr("Here you can add video filters for MPlayer. Write them separated "
445 "by commas. Don't use spaces!") );
446
447 setWhatsThis(mplayer_afilters_edit, tr("Audio filters"),
448 tr("Here you can add audio filters for MPlayer. Write them separated "
449 "by commas. Don't use spaces!") );
450
451 addSectionTitle(tr("Network"));
452
453 setWhatsThis(ipv4_button, tr("IPv4"),
454 tr("Use IPv4 on network connections. Falls back on IPv6 automatically."));
455
456 setWhatsThis(ipv6_button, tr("IPv6"),
457 tr("Use IPv6 on network connections. Falls back on IPv4 automatically."));
458
459 addSectionTitle(tr("Logs"));
460
461 setWhatsThis(log_smplayer_check, tr("Log SMPlayer output"),
462 tr("If this option is checked, SMPlayer will store the debugging "
463 "messages that SMPlayer outputs "
464 "(you can see the log in <b>Options -> View logs -> SMPlayer</b>). "
465 "This information can be very useful for the developer in case "
466 "you find a bug." ) );
467
468 setWhatsThis(log_smplayer_save_check, tr("Save SMPlayer log to file"),
469 tr("If this option is checked, the SMPlayer log wil be recorded to %1")
470 .arg( "<i>"+ Paths::configPath() + "/smplayer_log.txt</i>" ) );
471
472 setWhatsThis(log_mplayer_check, tr("Log MPlayer output"),
473 tr("If checked, SMPlayer will store the output of MPlayer "
474 "(you can see it in <b>Options -> View logs -> MPlayer</b>). "
475 "In case of problems this log can contain important information, "
476 "so it's recommended to keep this option checked.") );
477
478 setWhatsThis(log_mplayer_save_check, tr("Autosave MPlayer log"),
479 tr("If this option is checked, the MPlayer log will be saved to the "
480 "specified file every time a new file starts to play. "
481 "It's intended for external applications, so they can get "
482 "info about the file you're playing.") );
483
484 setWhatsThis(log_mplayer_save_name, tr("Autosave MPlayer log filename"),
485 tr("Enter here the path and filename that will be used to save the "
486 "MPlayer log.") );
487
488 setWhatsThis(log_filter_edit, tr("Filter for SMPlayer logs"),
489 tr("This option allows to filter the SMPlayer messages that will "
490 "be stored in the log. Here you can write any regular expression.<br>"
491 "For instance: <i>^Core::.*</i> will display only the lines "
492 "starting with <i>Core::</i>") );
493
494}
495
496#include "moc_prefadvanced.cpp"
Note: See TracBrowser for help on using the repository browser.