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

Last change on this file since 175 was 165, checked in by Silvan Scherrer, 11 years ago

SMPlayer: update trunk to latest 0.8.7

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