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

Last change on this file since 149 was 142, checked in by Silvan Scherrer, 12 years ago

SMPlayer: update trunk to 0.8.5

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