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

Last change on this file since 104 was 93, checked in by Silvan Scherrer, 15 years ago

smplayer: 0.6.9

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