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

Last change on this file since 188 was 188, checked in by Silvan Scherrer, 8 years ago

SMPlayer: update trunk to version 17.1.0

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