source: smplayer/trunk/src/prefgeneral.cpp@ 156

Last change on this file since 156 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: 34.4 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 "prefgeneral.h"
21#include "preferences.h"
22#include "filedialog.h"
23#include "images.h"
24#include "mediasettings.h"
25#include "paths.h"
26#include "vdpauproperties.h"
27
28#if USE_ALSA_DEVICES || USE_DSOUND_DEVICES
29#include "deviceinfo.h"
30#endif
31
32PrefGeneral::PrefGeneral(QWidget * parent, Qt::WindowFlags f)
33 : PrefWidget(parent, f )
34{
35 setupUi(this);
36
37 mplayerbin_edit->setDialogType(FileChooser::GetFileName);
38 screenshot_edit->setDialogType(FileChooser::GetDirectory);
39
40 // Read driver info from InfoReader:
41 InfoReader * i = InfoReader::obj();
42 vo_list = i->voList();
43 ao_list = i->aoList();
44
45#if USE_DSOUND_DEVICES
46 dsound_devices = DeviceInfo::dsoundDevices();
47#endif
48
49#if USE_ALSA_DEVICES
50 alsa_devices = DeviceInfo::alsaDevices();
51#endif
52#if USE_XV_ADAPTORS
53 xv_adaptors = DeviceInfo::xvAdaptors();
54#endif
55
56 // Screensaver
57#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
58 screensaver_check->hide();
59#else
60 screensaver_group->hide();
61#endif
62
63#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
64 vdpau_button->hide();
65#endif
66
67 // Channels combo
68 channels_combo->addItem( "2", MediaSettings::ChStereo );
69 channels_combo->addItem( "4", MediaSettings::ChSurround );
70 channels_combo->addItem( "6", MediaSettings::ChFull51 );
71 channels_combo->addItem( "7", MediaSettings::ChFull61 );
72 channels_combo->addItem( "8", MediaSettings::ChFull71 );
73
74 connect(vo_combo, SIGNAL(currentIndexChanged(int)),
75 this, SLOT(vo_combo_changed(int)));
76 connect(ao_combo, SIGNAL(currentIndexChanged(int)),
77 this, SLOT(ao_combo_changed(int)));
78
79 retranslateStrings();
80}
81
82PrefGeneral::~PrefGeneral()
83{
84}
85
86QString PrefGeneral::sectionName() {
87 return tr("General");
88}
89
90QPixmap PrefGeneral::sectionIcon() {
91 return Images::icon("pref_general", 22);
92}
93
94void PrefGeneral::retranslateStrings() {
95 retranslateUi(this);
96
97 channels_combo->setItemText(0, tr("2 (Stereo)") );
98 channels_combo->setItemText(1, tr("4 (4.0 Surround)") );
99 channels_combo->setItemText(2, tr("6 (5.1 Surround)") );
100 channels_combo->setItemText(3, tr("7 (6.1 Surround)") );
101 channels_combo->setItemText(4, tr("8 (7.1 Surround)") );
102
103 int deinterlace_item = deinterlace_combo->currentIndex();
104 deinterlace_combo->clear();
105 deinterlace_combo->addItem( tr("None"), MediaSettings::NoDeinterlace );
106 deinterlace_combo->addItem( tr("Lowpass5"), MediaSettings::L5 );
107 deinterlace_combo->addItem( tr("Yadif (normal)"), MediaSettings::Yadif );
108 deinterlace_combo->addItem( tr("Yadif (double framerate)"), MediaSettings::Yadif_1 );
109 deinterlace_combo->addItem( tr("Linear Blend"), MediaSettings::LB );
110 deinterlace_combo->addItem( tr("Kerndeint"), MediaSettings::Kerndeint );
111 deinterlace_combo->setCurrentIndex(deinterlace_item);
112
113 int filesettings_method_item = filesettings_method_combo->currentIndex();
114 filesettings_method_combo->clear();
115 filesettings_method_combo->addItem( tr("one ini file"), "normal");
116 filesettings_method_combo->addItem( tr("multiple ini files"), "hash");
117 filesettings_method_combo->setCurrentIndex(filesettings_method_item);
118
119 updateDriverCombos();
120
121 // Icons
122 /*
123 resize_window_icon->setPixmap( Images::icon("resize_window") );
124 volume_icon->setPixmap( Images::icon("speaker") );
125 */
126
127 mplayerbin_edit->setCaption(tr("Select the mplayer executable"));
128#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
129 mplayerbin_edit->setFilter(tr("Executables") +" (*.exe)");
130#else
131 mplayerbin_edit->setFilter(tr("All files") +" (*)");
132#endif
133 screenshot_edit->setCaption(tr("Select a directory"));
134
135 preferred_desc->setText(
136 tr("Here you can type your preferred language for the audio "
137 "and subtitle streams. When a media with multiple audio or "
138 "subtitle streams is found, SMPlayer will try to use your "
139 "preferred language. This only will work with media that offer "
140 "info about the language of audio and subtitle streams, like DVDs "
141 "or mkv files.<br>These fields accept regular expressions. "
142 "Example: <b>es|esp|spa</b> will select the track if it matches with "
143 "<i>es</i>, <i>esp</i> or <i>spa</i>."));
144
145 createHelp();
146}
147
148void PrefGeneral::setData(Preferences * pref) {
149 setMplayerPath( pref->mplayer_bin );
150
151 setUseScreenshots( pref->use_screenshot );
152 setScreenshotDir( pref->screenshot_directory );
153
154 QString vo = pref->vo;
155 if (vo.isEmpty()) {
156#ifdef Q_OS_WIN
157 if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA) {
158 vo = "direct3d,";
159 } else {
160 vo = "directx,";
161 }
162#else
163#ifdef Q_OS_OS2
164 vo = "kva";
165#else
166 vo = "xv,";
167#endif
168#endif
169 }
170 setVO( vo );
171
172 QString ao = pref->ao;
173
174#ifdef Q_OS_OS2
175 if (ao.isEmpty()) {
176 if (pref->mplayer_detected_version >= MPLAYER_KAI_VERSION) {
177 ao = "kai";
178 } else {
179 ao = "dart";
180 }
181 }
182#endif
183
184 setAO( ao );
185
186 setRememberSettings( !pref->dont_remember_media_settings );
187 setRememberTimePos( !pref->dont_remember_time_pos );
188 setFileSettingsMethod( pref->file_settings_method );
189 setAudioLang( pref->audio_lang );
190 setSubtitleLang( pref->subtitle_lang );
191 setAudioTrack( pref->initial_audio_track );
192 setSubtitleTrack( pref->initial_subtitle_track );
193 setCloseOnFinish( pref->close_on_finish );
194 setPauseWhenHidden( pref->pause_when_hidden );
195
196 setEq2( pref->use_soft_video_eq );
197 setUseAudioEqualizer( pref->use_audio_equalizer );
198 setGlobalVolume( pref->global_volume );
199 setSoftVol( pref->use_soft_vol );
200 setAc3DTSPassthrough( pref->use_hwac3 );
201 setInitialVolNorm( pref->initial_volnorm );
202 setAmplification( pref->softvol_max );
203 setInitialPostprocessing( pref->initial_postprocessing );
204 setInitialDeinterlace( pref->initial_deinterlace );
205 setInitialZoom( pref->initial_zoom_factor );
206 setDirectRendering( pref->use_direct_rendering );
207 setDoubleBuffer( pref->use_double_buffer );
208 setUseSlices( pref->use_slices );
209 setStartInFullscreen( pref->start_in_fullscreen );
210 setBlackbordersOnFullscreen( pref->add_blackborders_on_fullscreen );
211 setAutoq( pref->autoq );
212
213#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
214 setAvoidScreensaver( pref->avoid_screensaver );
215 setTurnScreensaverOff( pref->turn_screensaver_off );
216#else
217 setDisableScreensaver( pref->disable_screensaver );
218#endif
219
220#if !defined(Q_OS_WIN) && !defined(Q_OS_OS2)
221 vdpau = pref->vdpau;
222#endif
223
224 setAudioChannels( pref->initial_audio_channels );
225 setScaleTempoFilter( pref->use_scaletempo );
226
227 setAutoSyncActivated( pref->autosync );
228 setAutoSyncFactor( pref->autosync_factor );
229
230 setMcActivated( pref->use_mc );
231 setMc( pref->mc_value );
232}
233
234void PrefGeneral::getData(Preferences * pref) {
235 requires_restart = false;
236 filesettings_method_changed = false;
237
238 if (pref->mplayer_bin != mplayerPath()) {
239 requires_restart = true;
240 pref->mplayer_bin = mplayerPath();
241
242 qDebug("PrefGeneral::getData: mplayer binary has changed, getting version number");
243 // Forces to get info from mplayer to update version number
244 InfoReader i( pref->mplayer_bin );
245 i.getInfo();
246 // Update the drivers list at the same time
247 //setDrivers( i.voList(), i.aoList() );
248#ifdef Q_OS_OS2
249 vo_list = i.voList();
250 ao_list = i.aoList();
251 updateDriverCombos();
252#endif
253 }
254
255 TEST_AND_SET(pref->use_screenshot, useScreenshots());
256 TEST_AND_SET(pref->screenshot_directory, screenshotDir());
257 TEST_AND_SET(pref->vo, VO());
258 TEST_AND_SET(pref->ao, AO());
259
260 bool dont_remember_ms = !rememberSettings();
261 TEST_AND_SET(pref->dont_remember_media_settings, dont_remember_ms);
262
263 bool dont_remember_time = !rememberTimePos();
264 TEST_AND_SET(pref->dont_remember_time_pos, dont_remember_time);
265
266 if (pref->file_settings_method != fileSettingsMethod()) {
267 pref->file_settings_method = fileSettingsMethod();
268 filesettings_method_changed = true;
269 }
270
271 pref->audio_lang = audioLang();
272 pref->subtitle_lang = subtitleLang();
273
274 pref->initial_audio_track = audioTrack();
275 pref->initial_subtitle_track = subtitleTrack();
276
277 pref->close_on_finish = closeOnFinish();
278 pref->pause_when_hidden = pauseWhenHidden();
279
280 TEST_AND_SET(pref->use_soft_video_eq, eq2());
281 TEST_AND_SET(pref->use_soft_vol, softVol());
282 pref->global_volume = globalVolume();
283 TEST_AND_SET(pref->use_audio_equalizer, useAudioEqualizer());
284 TEST_AND_SET(pref->use_hwac3, Ac3DTSPassthrough());
285 pref->initial_volnorm = initialVolNorm();
286 TEST_AND_SET(pref->softvol_max, amplification());
287 pref->initial_postprocessing = initialPostprocessing();
288 pref->initial_deinterlace = initialDeinterlace();
289 pref->initial_zoom_factor = initialZoom();
290 TEST_AND_SET(pref->use_direct_rendering, directRendering());
291 TEST_AND_SET(pref->use_double_buffer, doubleBuffer());
292 TEST_AND_SET(pref->use_slices, useSlices());
293 pref->start_in_fullscreen = startInFullscreen();
294 if (pref->add_blackborders_on_fullscreen != blackbordersOnFullscreen()) {
295 pref->add_blackborders_on_fullscreen = blackbordersOnFullscreen();
296 if (pref->fullscreen) requires_restart = true;
297 }
298 TEST_AND_SET(pref->autoq, autoq());
299
300#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
301 pref->avoid_screensaver = avoidScreensaver();
302 TEST_AND_SET(pref->turn_screensaver_off, turnScreensaverOff());
303#else
304 TEST_AND_SET(pref->disable_screensaver, disableScreensaver());
305#endif
306
307#if !defined(Q_OS_WIN) && !defined(Q_OS_OS2)
308 pref->vdpau = vdpau;
309#endif
310
311 pref->initial_audio_channels = audioChannels();
312 TEST_AND_SET(pref->use_scaletempo, scaleTempoFilter());
313
314 TEST_AND_SET(pref->autosync, autoSyncActivated());
315 TEST_AND_SET(pref->autosync_factor, autoSyncFactor());
316
317 TEST_AND_SET(pref->use_mc, mcActivated());
318 TEST_AND_SET(pref->mc_value, mc());
319}
320
321void PrefGeneral::updateDriverCombos() {
322 int vo_current = vo_combo->currentIndex();
323 int ao_current = ao_combo->currentIndex();
324
325 vo_combo->clear();
326 ao_combo->clear();
327
328 QString vo;
329 for ( int n = 0; n < vo_list.count(); n++ ) {
330 vo = vo_list[n].name();
331#ifdef Q_OS_WIN
332 if ( vo == "directx" ) {
333 vo_combo->addItem( "directx (" + tr("fast") + ")", "directx" );
334 vo_combo->addItem( "directx (" + tr("slow") + ")", "directx:noaccel" );
335 }
336 else
337#else
338#ifdef Q_OS_OS2
339 if ( vo == "kva") {
340 vo_combo->addItem( "kva (" + tr("fast") + ")", "kva" );
341 vo_combo->addItem( "kva (" + tr("snap mode") + ")", "kva:snap" );
342 vo_combo->addItem( "kva (" + tr("slower dive mode") + ")", "kva:dive" );
343 }
344 else
345#else
346 /*
347 if (vo == "xv") vo_combo->addItem( "xv (" + tr("fastest") + ")", vo);
348 else
349 */
350#if USE_XV_ADAPTORS
351 if ((vo == "xv") && (!xv_adaptors.isEmpty())) {
352 vo_combo->addItem(vo, vo);
353 for (int n=0; n < xv_adaptors.count(); n++) {
354 vo_combo->addItem( "xv (" + xv_adaptors[n].ID().toString() + " - " + xv_adaptors[n].desc() + ")",
355 "xv:adaptor=" + xv_adaptors[n].ID().toString() );
356 }
357 }
358 else
359#endif // USE_XV_ADAPTORS
360#endif
361#endif
362 if (vo == "x11") vo_combo->addItem( "x11 (" + tr("slow") + ")", vo);
363 else
364 if (vo == "gl") {
365 vo_combo->addItem( vo, vo);
366 vo_combo->addItem( "gl (" + tr("fast") + ")", "gl:yuv=2:force-pbo");
367 vo_combo->addItem( "gl (" + tr("fast - ATI cards") + ")", "gl:yuv=2:force-pbo:ati-hack");
368 vo_combo->addItem( "gl (yuv)", "gl:yuv=3");
369 }
370 else
371 if (vo == "gl2") {
372 vo_combo->addItem( vo, vo);
373 vo_combo->addItem( "gl2 (yuv)", "gl2:yuv=3");
374 }
375 else
376 if (vo == "gl_tiled") {
377 vo_combo->addItem( vo, vo);
378 vo_combo->addItem( "gl_tiled (yuv)", "gl_tiled:yuv=3");
379 }
380 else
381 if (vo == "null" || vo == "png" || vo == "jpeg" || vo == "gif89a" ||
382 vo == "tga" || vo == "pnm" || vo == "md5sum" )
383 {
384 ; // Nothing to do
385 }
386 else
387 vo_combo->addItem( vo, vo );
388 }
389 vo_combo->addItem( tr("User defined..."), "user_defined" );
390
391 QString ao;
392 for ( int n = 0; n < ao_list.count(); n++) {
393 ao = ao_list[n].name();
394 ao_combo->addItem( ao, ao );
395#ifdef Q_OS_OS2
396 if ( ao == "kai") {
397 ao_combo->addItem( "kai (" + tr("uniaud mode") + ")", "kai:uniaud" );
398 ao_combo->addItem( "kai (" + tr("dart mode") + ")", "kai:dart" );
399 }
400#endif
401#if USE_ALSA_DEVICES
402 if ((ao == "alsa") && (!alsa_devices.isEmpty())) {
403 for (int n=0; n < alsa_devices.count(); n++) {
404 ao_combo->addItem( "alsa (" + alsa_devices[n].ID().toString() + " - " + alsa_devices[n].desc() + ")",
405 "alsa:device=hw=" + alsa_devices[n].ID().toString() );
406 }
407 }
408#endif
409#if USE_DSOUND_DEVICES
410 if ((ao == "dsound") && (!dsound_devices.isEmpty())) {
411 for (int n=0; n < dsound_devices.count(); n++) {
412 ao_combo->addItem( "dsound (" + dsound_devices[n].ID().toString() + " - " + dsound_devices[n].desc() + ")",
413 "dsound:device=" + dsound_devices[n].ID().toString() );
414 }
415 }
416#endif
417 }
418 ao_combo->addItem( tr("User defined..."), "user_defined" );
419
420 vo_combo->setCurrentIndex( vo_current );
421 ao_combo->setCurrentIndex( ao_current );
422}
423
424void PrefGeneral::setMplayerPath( QString path ) {
425 mplayerbin_edit->setText( path );
426}
427
428QString PrefGeneral::mplayerPath() {
429 return mplayerbin_edit->text();
430}
431
432void PrefGeneral::setUseScreenshots(bool b) {
433 use_screenshots_check->setChecked(b);
434}
435
436bool PrefGeneral::useScreenshots() {
437 return use_screenshots_check->isChecked();
438}
439
440void PrefGeneral::setScreenshotDir( QString path ) {
441 screenshot_edit->setText( path );
442}
443
444QString PrefGeneral::screenshotDir() {
445 return screenshot_edit->text();
446}
447
448void PrefGeneral::setVO( QString vo_driver ) {
449 int idx = vo_combo->findData( vo_driver );
450 if (idx != -1) {
451 vo_combo->setCurrentIndex(idx);
452 } else {
453 vo_combo->setCurrentIndex(vo_combo->findData("user_defined"));
454 vo_user_defined_edit->setText(vo_driver);
455 }
456 vo_combo_changed(vo_combo->currentIndex());
457}
458
459void PrefGeneral::setAO( QString ao_driver ) {
460 int idx = ao_combo->findData( ao_driver );
461 if (idx != -1) {
462 ao_combo->setCurrentIndex(idx);
463 } else {
464 ao_combo->setCurrentIndex(ao_combo->findData("user_defined"));
465 ao_user_defined_edit->setText(ao_driver);
466 }
467 ao_combo_changed(ao_combo->currentIndex());
468}
469
470QString PrefGeneral::VO() {
471 QString vo = vo_combo->itemData(vo_combo->currentIndex()).toString();
472 if (vo == "user_defined") {
473 vo = vo_user_defined_edit->text();
474 /*
475 if (vo.isEmpty()) {
476 vo = vo_combo->itemData(0).toString();
477 qDebug("PrefGeneral::VO: user defined vo is empty, using %s", vo.toUtf8().constData());
478 }
479 */
480 }
481 return vo;
482}
483
484QString PrefGeneral::AO() {
485 QString ao = ao_combo->itemData(ao_combo->currentIndex()).toString();
486 if (ao == "user_defined") {
487 ao = ao_user_defined_edit->text();
488 /*
489 if (ao.isEmpty()) {
490 ao = ao_combo->itemData(0).toString();
491 qDebug("PrefGeneral::AO: user defined ao is empty, using %s", ao.toUtf8().constData());
492 }
493 */
494 }
495 return ao;
496}
497
498void PrefGeneral::setRememberSettings(bool b) {
499 remember_all_check->setChecked(b);
500 //rememberAllButtonToggled(b);
501}
502
503bool PrefGeneral::rememberSettings() {
504 return remember_all_check->isChecked();
505}
506
507void PrefGeneral::setRememberTimePos(bool b) {
508 remember_time_check->setChecked(b);
509}
510
511bool PrefGeneral::rememberTimePos() {
512 return remember_time_check->isChecked();
513}
514
515void PrefGeneral::setFileSettingsMethod(QString method) {
516 int index = filesettings_method_combo->findData(method);
517 if (index < 0) index = 0;
518 filesettings_method_combo->setCurrentIndex(index);
519}
520
521QString PrefGeneral::fileSettingsMethod() {
522 return filesettings_method_combo->itemData(filesettings_method_combo->currentIndex()).toString();
523}
524
525void PrefGeneral::setAudioLang(QString lang) {
526 audio_lang_edit->setText(lang);
527}
528
529QString PrefGeneral::audioLang() {
530 return audio_lang_edit->text();
531}
532
533void PrefGeneral::setSubtitleLang(QString lang) {
534 subtitle_lang_edit->setText(lang);
535}
536
537QString PrefGeneral::subtitleLang() {
538 return subtitle_lang_edit->text();
539}
540
541void PrefGeneral::setAudioTrack(int track) {
542 audio_track_spin->setValue(track);
543}
544
545int PrefGeneral::audioTrack() {
546 return audio_track_spin->value();
547}
548
549void PrefGeneral::setSubtitleTrack(int track) {
550 subtitle_track_spin->setValue(track);
551}
552
553int PrefGeneral::subtitleTrack() {
554 return subtitle_track_spin->value();
555}
556
557void PrefGeneral::setCloseOnFinish(bool b) {
558 close_on_finish_check->setChecked(b);
559}
560
561bool PrefGeneral::closeOnFinish() {
562 return close_on_finish_check->isChecked();
563}
564
565void PrefGeneral::setPauseWhenHidden(bool b) {
566 pause_if_hidden_check->setChecked(b);
567}
568
569bool PrefGeneral::pauseWhenHidden() {
570 return pause_if_hidden_check->isChecked();
571}
572
573
574void PrefGeneral::setEq2(bool b) {
575 eq2_check->setChecked(b);
576}
577
578bool PrefGeneral::eq2() {
579 return eq2_check->isChecked();
580}
581
582void PrefGeneral::setSoftVol(bool b) {
583 softvol_check->setChecked(b);
584}
585
586void PrefGeneral::setGlobalVolume(bool b) {
587 global_volume_check->setChecked(b);
588}
589
590bool PrefGeneral::globalVolume() {
591 return global_volume_check->isChecked();
592}
593
594bool PrefGeneral::softVol() {
595 return softvol_check->isChecked();
596}
597
598void PrefGeneral::setAutoSyncFactor(int factor) {
599 autosync_spin->setValue(factor);
600}
601
602int PrefGeneral::autoSyncFactor() {
603 return autosync_spin->value();
604}
605
606void PrefGeneral::setAutoSyncActivated(bool b) {
607 autosync_check->setChecked(b);
608}
609
610bool PrefGeneral::autoSyncActivated() {
611 return autosync_check->isChecked();
612}
613
614void PrefGeneral::setMc(double value) {
615 mc_spin->setValue(value);
616}
617
618double PrefGeneral::mc() {
619 return mc_spin->value();
620}
621
622void PrefGeneral::setMcActivated(bool b) {
623 use_mc_check->setChecked(b);
624}
625
626bool PrefGeneral::mcActivated() {
627 return use_mc_check->isChecked();
628}
629
630void PrefGeneral::setUseAudioEqualizer(bool b) {
631 audio_equalizer_check->setChecked(b);
632}
633
634bool PrefGeneral::useAudioEqualizer() {
635 return audio_equalizer_check->isChecked();
636}
637
638void PrefGeneral::setAc3DTSPassthrough(bool b) {
639 hwac3_check->setChecked(b);
640}
641
642bool PrefGeneral::Ac3DTSPassthrough() {
643 return hwac3_check->isChecked();
644}
645
646void PrefGeneral::setInitialVolNorm(bool b) {
647 volnorm_check->setChecked(b);
648}
649
650bool PrefGeneral::initialVolNorm() {
651 return volnorm_check->isChecked();
652}
653
654void PrefGeneral::setInitialPostprocessing(bool b) {
655 postprocessing_check->setChecked(b);
656}
657
658bool PrefGeneral::initialPostprocessing() {
659 return postprocessing_check->isChecked();
660}
661
662void PrefGeneral::setInitialDeinterlace(int ID) {
663 int pos = deinterlace_combo->findData(ID);
664 if (pos != -1) {
665 deinterlace_combo->setCurrentIndex(pos);
666 } else {
667 qWarning("PrefGeneral::setInitialDeinterlace: ID: %d not found in combo", ID);
668 }
669}
670
671int PrefGeneral::initialDeinterlace() {
672 if (deinterlace_combo->currentIndex() != -1) {
673 return deinterlace_combo->itemData( deinterlace_combo->currentIndex() ).toInt();
674 } else {
675 qWarning("PrefGeneral::initialDeinterlace: no item selected");
676 return 0;
677 }
678}
679
680void PrefGeneral::setInitialZoom(double v) {
681 zoom_spin->setValue(v);
682}
683
684double PrefGeneral::initialZoom() {
685 return zoom_spin->value();
686}
687
688void PrefGeneral::setDirectRendering(bool b) {
689 direct_rendering_check->setChecked(b);
690}
691
692bool PrefGeneral::directRendering() {
693 return direct_rendering_check->isChecked();
694}
695
696void PrefGeneral::setDoubleBuffer(bool b) {
697 double_buffer_check->setChecked(b);
698}
699
700bool PrefGeneral::doubleBuffer() {
701 return double_buffer_check->isChecked();
702}
703
704void PrefGeneral::setUseSlices(bool b) {
705 use_slices_check->setChecked(b);
706}
707
708bool PrefGeneral::useSlices() {
709 return use_slices_check->isChecked();
710}
711
712void PrefGeneral::setAmplification(int n) {
713 softvol_max_spin->setValue(n);
714}
715
716int PrefGeneral::amplification() {
717 return softvol_max_spin->value();
718}
719
720void PrefGeneral::setAudioChannels(int ID) {
721 int pos = channels_combo->findData(ID);
722 if (pos != -1) {
723 channels_combo->setCurrentIndex(pos);
724 } else {
725 qWarning("PrefGeneral::setAudioChannels: ID: %d not found in combo", ID);
726 }
727}
728
729int PrefGeneral::audioChannels() {
730 if (channels_combo->currentIndex() != -1) {
731 return channels_combo->itemData( channels_combo->currentIndex() ).toInt();
732 } else {
733 qWarning("PrefGeneral::audioChannels: no item selected");
734 return 0;
735 }
736}
737
738void PrefGeneral::setStartInFullscreen(bool b) {
739 start_fullscreen_check->setChecked(b);
740}
741
742bool PrefGeneral::startInFullscreen() {
743 return start_fullscreen_check->isChecked();
744}
745
746#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
747void PrefGeneral::setAvoidScreensaver(bool b) {
748 avoid_screensaver_check->setChecked(b);
749}
750
751bool PrefGeneral::avoidScreensaver() {
752 return avoid_screensaver_check->isChecked();
753}
754
755void PrefGeneral::setTurnScreensaverOff(bool b) {
756 turn_screensaver_off_check->setChecked(b);
757}
758
759bool PrefGeneral::turnScreensaverOff() {
760 return turn_screensaver_off_check->isChecked();
761}
762#else
763void PrefGeneral::setDisableScreensaver(bool b) {
764 screensaver_check->setChecked(b);
765}
766
767bool PrefGeneral::disableScreensaver() {
768 return screensaver_check->isChecked();
769}
770#endif
771
772void PrefGeneral::setBlackbordersOnFullscreen(bool b) {
773 blackborders_on_fs_check->setChecked(b);
774}
775
776bool PrefGeneral::blackbordersOnFullscreen() {
777 return blackborders_on_fs_check->isChecked();
778}
779
780void PrefGeneral::setAutoq(int n) {
781 autoq_spin->setValue(n);
782}
783
784int PrefGeneral::autoq() {
785 return autoq_spin->value();
786}
787
788void PrefGeneral::setScaleTempoFilter(Preferences::OptionState value) {
789 scaletempo_combo->setState(value);
790}
791
792Preferences::OptionState PrefGeneral::scaleTempoFilter() {
793 return scaletempo_combo->state();
794}
795
796void PrefGeneral::vo_combo_changed(int idx) {
797 qDebug("PrefGeneral::vo_combo_changed: %d", idx);
798 bool visible = (vo_combo->itemData(idx).toString() == "user_defined");
799 vo_user_defined_edit->setShown(visible);
800 vo_user_defined_edit->setFocus();
801
802#ifndef Q_OS_WIN
803 bool vdpau_button_visible = (vo_combo->itemData(idx).toString() == "vdpau");
804 vdpau_button->setShown(vdpau_button_visible);
805#endif
806}
807
808void PrefGeneral::ao_combo_changed(int idx) {
809 qDebug("PrefGeneral::ao_combo_changed: %d", idx);
810 bool visible = (ao_combo->itemData(idx).toString() == "user_defined");
811 ao_user_defined_edit->setShown(visible);
812 ao_user_defined_edit->setFocus();
813}
814
815#ifndef Q_OS_WIN
816void PrefGeneral::on_vdpau_button_clicked() {
817 qDebug("PrefGeneral::on_vdpau_button_clicked");
818
819 VDPAUProperties d(this);
820
821 d.setffh264vdpau(vdpau.ffh264vdpau);
822 d.setffmpeg12vdpau(vdpau.ffmpeg12vdpau);
823 d.setffwmv3vdpau(vdpau.ffwmv3vdpau);
824 d.setffvc1vdpau(vdpau.ffvc1vdpau);
825 d.setffodivxvdpau(vdpau.ffodivxvdpau);
826
827 d.setDisableFilters(vdpau.disable_video_filters);
828
829 if (d.exec() == QDialog::Accepted) {
830 vdpau.ffh264vdpau = d.ffh264vdpau();
831 vdpau.ffmpeg12vdpau = d.ffmpeg12vdpau();
832 vdpau.ffwmv3vdpau = d.ffwmv3vdpau();
833 vdpau.ffvc1vdpau = d.ffvc1vdpau();
834 vdpau.ffodivxvdpau = d.ffodivxvdpau();
835
836 vdpau.disable_video_filters = d.disableFilters();
837 }
838}
839#endif
840
841void PrefGeneral::createHelp() {
842 clearHelp();
843
844 addSectionTitle(tr("General"));
845
846 setWhatsThis(mplayerbin_edit, tr("MPlayer executable"),
847 tr("Here you must specify the mplayer "
848 "executable that SMPlayer will use.<br>"
849 "SMPlayer requires at least MPlayer 1.0rc1 (although a recent "
850 "revision from SVN is highly recommended).") + "<br><b>" +
851 tr("If this setting is wrong, SMPlayer won't be able to play "
852 "anything!") + "</b>");
853
854 setWhatsThis(remember_all_check, tr("Remember settings"),
855 tr("Usually SMPlayer will remember the settings for each file you "
856 "play (audio track selected, volume, filters...). Disable this "
857 "option if you don't like this feature.") );
858
859 setWhatsThis(remember_time_check, tr("Remember time position"),
860 tr("If you check this option, SMPlayer will remember the last position "
861 "of the file when you open it again. This option works only with "
862 "regular files (not with DVDs, CDs, URLs...).") );
863
864 setWhatsThis(filesettings_method_combo, tr("Method to store the file settings"),
865 tr("This option allows to change the way the file settings would be "
866 "stored. The following options are available:") +"<ul><li>" +
867 tr("<b>one ini file</b>: the settings for all played files will be "
868 "saved in a single ini file (%1)").arg(QString("<i>"+Paths::iniPath()+"/smplayer.ini</i>")) + "</li><li>" +
869 tr("<b>multiple ini files</b>: one ini file will be used for each played file. "
870 "Those ini files will be saved in the folder %1").arg(QString("<i>"+Paths::iniPath()+"/file_settings</i>")) + "</li></ul>" +
871 tr("The latter method could be faster if there is info for a lot of files.") );
872
873 setWhatsThis(use_screenshots_check, tr("Enable screenshots"),
874 tr("You can use this option to enable or disable the possibility to "
875 "take screenshots.") );
876
877 setWhatsThis(screenshot_edit, tr("Screenshots folder"),
878 tr("Here you can specify a folder where the screenshots taken by "
879 "SMPlayer will be stored. If the folder is not valid the "
880 "screenshot feature will be disabled.") );
881
882 setWhatsThis(close_on_finish_check, tr("Close when finished"),
883 tr("If this option is checked, the main window will be automatically "
884 "closed when the current file/playlist finishes.") );
885
886 setWhatsThis(pause_if_hidden_check, tr("Pause when minimized"),
887 tr("If this option is enabled, the file will be paused when the "
888 "main window is hidden. When the window is restored, playback "
889 "will be resumed.") );
890
891 // Video tab
892 addSectionTitle(tr("Video"));
893
894 setWhatsThis(vo_combo, tr("Video output driver"),
895 tr("Select the video output driver. %1 provides the best performance.")
896#ifdef Q_OS_WIN
897 .arg("<b><i>directx</i></b>")
898#else
899#ifdef Q_OS_OS2
900 .arg("<b><i>kva</i></b>")
901#else
902 .arg("<b><i>xv</i></b>")
903#endif
904#endif
905 );
906
907#if !defined(Q_OS_WIN) && !defined(Q_OS_OS2)
908 /*
909 setWhatsThis(vdpau_filters_check, tr("Disable video filters when using vdpau"),
910 tr("Usually video filters won't work when using vdpau as video output "
911 "driver, so it's wise to keep this option checked.") );
912 */
913#endif
914
915 setWhatsThis(postprocessing_check, tr("Enable postprocessing by default"),
916 tr("Postprocessing will be used by default on new opened files.") );
917
918 setWhatsThis(autoq_spin, tr("Postprocessing quality"),
919 tr("Dynamically changes the level of postprocessing depending on the "
920 "available spare CPU time. The number you specify will be the "
921 "maximum level used. Usually you can use some big number.") );
922
923 setWhatsThis(deinterlace_combo, tr("Deinterlace by default"),
924 tr("Select the deinterlace filter that you want to be used for new "
925 "videos opened.") +" "+
926 tr("<b>Note:</b> This option won't be used for TV channels.") );
927
928 setWhatsThis(zoom_spin, tr("Default zoom"),
929 tr("This option sets the default zoom which will be used for "
930 "new videos.") );
931
932 setWhatsThis(eq2_check, tr("Software video equalizer"),
933 tr("You can check this option if video equalizer is not supported by "
934 "your graphic card or the selected video output driver.<br>"
935 "<b>Note:</b> this option can be incompatible with some video "
936 "output drivers.") );
937
938 setWhatsThis(direct_rendering_check, tr("Direct rendering"),
939 tr("If checked, turns on direct rendering (not supported by all "
940 "codecs and video outputs)<br>"
941 "<b>Warning:</b> May cause OSD/SUB corruption!") );
942
943 setWhatsThis(double_buffer_check, tr("Double buffering"),
944 tr("Double buffering fixes flicker by storing two frames in memory, "
945 "and displaying one while decoding another. If disabled it can "
946 "affect OSD negatively, but often removes OSD flickering.") );
947
948 setWhatsThis(use_slices_check, tr("Draw video using slices"),
949 tr("Enable/disable drawing video by 16-pixel height slices/bands. "
950 "If disabled, the whole frame is drawn in a single run. "
951 "May be faster or slower, depending on video card and available "
952 "cache. It has effect only with libmpeg2 and libavcodec codecs.") );
953
954 setWhatsThis(start_fullscreen_check, tr("Start videos in fullscreen"),
955 tr("If this option is checked, all videos will start to play in "
956 "fullscreen mode.") );
957
958 setWhatsThis(blackborders_on_fs_check, tr("Add black borders on fullscreen"),
959 tr("If this option is enabled, black borders will be added to the "
960 "image in fullscreen mode. This allows subtitles to be displayed "
961 "on the black borders.") /* + "<br>" +
962 tr("This option will be ignored if MPlayer uses its own window, as "
963 "some video drivers (like gl) are already able to display the "
964 "subtitles automatically in the black borders.") */ );
965
966#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
967 setWhatsThis(turn_screensaver_off_check, tr("Switch screensaver off"),
968 tr("This option switches the screensaver off just before starting to "
969 "play a file and switches it on when playback finishes. If this "
970 "option is enabled, the screensaver won't appear even if playing "
971 "audio files or when a file is paused."));
972
973 setWhatsThis(avoid_screensaver_check, tr("Avoid screensaver"),
974 tr("When this option is checked, SMPlayer will try to prevent the "
975 "screensaver to be shown when playing a video file. The screensaver "
976 "will be allowed to be shown if playing an audio file or in pause "
977 "mode. This option only works if the SMPlayer window is in "
978 "the foreground."));
979#else
980 setWhatsThis(screensaver_check, tr("Disable screensaver"),
981 tr("Check this option to disable the screensaver while playing.<br>"
982 "The screensaver will enabled again when play finishes.")
983 );
984#endif
985
986 // Audio tab
987 addSectionTitle(tr("Audio"));
988
989 setWhatsThis(ao_combo, tr("Audio output driver"),
990 tr("Select the audio output driver.")
991#ifndef Q_OS_WIN
992#ifdef Q_OS_OS2
993 + " " +
994 tr("%1 is the recommended one. %2 is only available on older MPlayer (before version %3)")
995 .arg("<b><i>kai</i></b>")
996 .arg("<b><i>dart</i></b>")
997 .arg(MPLAYER_KAI_VERSION)
998#else
999 + " " +
1000 tr("%1 is the recommended one. Try to avoid %2 and %3, they are slow "
1001 "and can have an impact on performance.")
1002 .arg("<b><i>alsa</i></b>")
1003 .arg("<b><i>esd</i></b>")
1004 .arg("<b><i>arts</i></b>")
1005#endif
1006#endif
1007 );
1008
1009 setWhatsThis(audio_equalizer_check, tr("Enable the audio equalizer"),
1010 tr("Check this option if you want to use the audio equalizer.") );
1011
1012 setWhatsThis(hwac3_check, tr("AC3/DTS pass-through S/PDIF"),
1013 tr("Uses hardware AC3 passthrough.") + "<br>" +
1014 tr("<b>Note:</b> none of the audio filters will be used when this "
1015 "option is enabled.") );
1016
1017 setWhatsThis(channels_combo, tr("Channels by default"),
1018 tr("Requests the number of playback channels. MPlayer "
1019 "asks the decoder to decode the audio into as many channels as "
1020 "specified. Then it is up to the decoder to fulfill the "
1021 "requirement. This is usually only important when playing "
1022 "videos with AC3 audio (like DVDs). In that case liba52 does "
1023 "the decoding by default and correctly downmixes the audio "
1024 "into the requested number of channels. "
1025 "<b>Note</b>: This option is honored by codecs (AC3 only), "
1026 "filters (surround) and audio output drivers (OSS at least).") );
1027
1028 setWhatsThis(scaletempo_combo, tr("High speed playback without altering pitch"),
1029 tr("Allows to change the playback speed without altering pitch. "
1030 "Requires at least MPlayer dev-SVN-r24924.") );
1031
1032 setWhatsThis(global_volume_check, tr("Global volume"),
1033 tr("If this option is checked, the same volume will be used for "
1034 "all files you play. If the option is not checked each "
1035 "file uses its own volume.") + "<br>" +
1036 tr("This option also applies for the mute control.") );
1037
1038 setWhatsThis(softvol_check, tr("Software volume control"),
1039 tr("Check this option to use the software mixer, instead of "
1040 "using the sound card mixer.") );
1041
1042 setWhatsThis(softvol_max_spin, tr("Max. Amplification"),
1043 tr("Sets the maximum amplification level in percent (default: 110). "
1044 "A value of 200 will allow you to adjust the volume up to a "
1045 "maximum of double the current level. With values below 100 the "
1046 "initial volume (which is 100%) will be above the maximum, which "
1047 "e.g. the OSD cannot display correctly.") );
1048
1049 setWhatsThis(volnorm_check, tr("Volume normalization by default"),
1050 tr("Maximizes the volume without distorting the sound.") );
1051
1052 setWhatsThis(autosync_check, tr("Audio/video auto synchronization"),
1053 tr("Gradually adjusts the A/V sync based on audio delay "
1054 "measurements.") );
1055
1056 setWhatsThis(mc_spin, tr("A-V sync correction"),
1057 tr("Maximum A-V sync correction per frame (in seconds)") );
1058
1059 addSectionTitle(tr("Preferred audio and subtitles"));
1060
1061 setWhatsThis(audio_lang_edit, tr("Preferred audio language"),
1062 tr("Here you can type your preferred language for the audio streams. "
1063 "When a media with multiple audio streams is found, SMPlayer will "
1064 "try to use your preferred language.<br>"
1065 "This only will work with media that offer info about the language "
1066 "of the audio streams, like DVDs or mkv files.<br>"
1067 "This field accepts regular expressions. Example: <b>es|esp|spa</b> "
1068 "will select the audio track if it matches with <i>es</i>, "
1069 "<i>esp</i> or <i>spa</i>.") );
1070
1071 setWhatsThis(subtitle_lang_edit, tr("Preferred subtitle language"),
1072 tr("Here you can type your preferred language for the subtitle stream. "
1073 "When a media with multiple subtitle streams is found, SMPlayer will "
1074 "try to use your preferred language.<br>"
1075 "This only will work with media that offer info about the language "
1076 "of the subtitle streams, like DVDs or mkv files.<br>"
1077 "This field accepts regular expressions. Example: <b>es|esp|spa</b> "
1078 "will select the subtitle stream if it matches with <i>es</i>, "
1079 "<i>esp</i> or <i>spa</i>.") );
1080
1081 setWhatsThis(audio_track_spin, tr("Audio track"),
1082 tr("Specifies the default audio track which will be used when playing "
1083 "new files. If the track doesn't exist, the first one will be used. "
1084 "<br><b>Note:</b> the <i>\"preferred audio language\"</i> has "
1085 "preference over this option.") );
1086
1087 setWhatsThis(subtitle_track_spin, tr("Subtitle track"),
1088 tr("Specifies the default subtitle track which will be used when "
1089 "playing new files. If the track doesn't exist, the first one "
1090 "will be used. <br><b>Note:</b> the <i>\"preferred subtitle "
1091 "language\"</i> has preference over this option.") );
1092
1093}
1094
1095#include "moc_prefgeneral.cpp"
Note: See TracBrowser for help on using the repository browser.