source: smplayer/trunk/src/preferences.cpp@ 170

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

SMPlayer: updated trunk to 14.9.0

  • Property svn:eol-style set to LF
File size: 47.2 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#include "preferences.h"
20#include "global.h"
21#include "paths.h"
22#include "mediasettings.h"
23#include "recents.h"
24#include "urlhistory.h"
25#include "filters.h"
26#include "autohidewidget.h"
27
28#include <QSettings>
29#include <QFileInfo>
30#include <QRegExp>
31#include <QDir>
32#include <QLocale>
33
34#if QT_VERSION >= 0x050000
35#include <QStandardPaths>
36#endif
37
38#if QT_VERSION >= 0x040400
39#include <QDesktopServices>
40#endif
41
42#ifdef YOUTUBE_SUPPORT
43#include "retrieveyoutubeurl.h"
44#endif
45
46#define CURRENT_CONFIG_VERSION 4
47
48using namespace Global;
49
50Preferences::Preferences() {
51 history_recents = new Recents;
52 history_urls = new URLHistory;
53 filters = new Filters;
54
55 reset();
56
57#ifndef NO_USE_INI_FILES
58 load();
59#endif
60}
61
62Preferences::~Preferences() {
63#ifndef NO_USE_INI_FILES
64 save();
65#endif
66
67 delete history_recents;
68 delete history_urls;
69 delete filters;
70}
71
72void Preferences::reset() {
73 /* *******
74 General
75 ******* */
76
77 config_version = CURRENT_CONFIG_VERSION;
78
79#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
80 mplayer_bin= "mplayer/mplayer.exe";
81#else
82 mplayer_bin = "mplayer";
83#endif
84
85 vo = "";
86 ao = "";
87
88 use_screenshot = true;
89 screenshot_directory="";
90#ifdef PORTABLE_APP
91 screenshot_directory= "./screenshots";
92#else
93 #if QT_VERSION < 0x040400
94 QString default_screenshot_path = Paths::configPath() + "/screenshots";
95 if (QFile::exists(default_screenshot_path)) {
96 screenshot_directory = default_screenshot_path;
97 }
98 #endif
99#endif
100
101 dont_remember_media_settings = false;
102 dont_remember_time_pos = false;
103
104 audio_lang = "";
105 subtitle_lang = "";
106
107 use_direct_rendering = false;
108 use_double_buffer = true;
109
110 use_soft_video_eq = false;
111 use_slices = false;
112 autoq = 6;
113 add_blackborders_on_fullscreen = false;
114
115#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
116 #ifdef SCREENSAVER_OFF
117 turn_screensaver_off = false;
118 #endif
119 #ifdef AVOID_SCREENSAVER
120 avoid_screensaver = true;
121 #endif
122#else
123 disable_screensaver = true;
124#endif
125
126#ifndef Q_OS_WIN
127 vdpau.ffh264vdpau = true;
128 vdpau.ffmpeg12vdpau = true;
129 vdpau.ffwmv3vdpau = true;
130 vdpau.ffvc1vdpau = true;
131 vdpau.ffodivxvdpau = false;
132 vdpau.disable_video_filters = true;
133#endif
134
135 use_soft_vol = true;
136 softvol_max = 110; // 110 = default value in mplayer
137 use_scaletempo = Detect;
138 use_hwac3 = false;
139 use_audio_equalizer = true;
140
141 global_volume = true;
142 volume = 50;
143 mute = false;
144
145 global_audio_equalizer = true;
146 audio_equalizer << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0; // FIXME: use initial_audio_equalizer (but it's set later)
147
148 autosync = false;
149 autosync_factor = 100;
150
151 use_mc = false;
152 mc_value = 0;
153
154 autoload_m4a = true;
155 min_step = 4;
156
157 osd = None;
158 osd_delay = 2200;
159
160 file_settings_method = "hash"; // Possible values: normal & hash
161
162
163 /* ***************
164 Drives (CD/DVD)
165 *************** */
166
167 dvd_device = "";
168 cdrom_device = "";
169#ifdef BLURAY_SUPPORT
170 bluray_device = "";
171#endif
172
173#ifndef Q_OS_WIN
174 // Try to set default values
175 if (QFile::exists("/dev/dvd")) dvd_device = "/dev/dvd";
176 if (QFile::exists("/dev/cdrom")) cdrom_device = "/dev/cdrom";
177#endif
178
179#ifdef Q_OS_WIN
180 enable_audiocd_on_windows = false;
181#endif
182
183 vcd_initial_title = 2; // Most VCD's start at title #2
184
185#if DVDNAV_SUPPORT
186 use_dvdnav = false;
187#endif
188
189
190 /* ***********
191 Performance
192 *********** */
193
194 priority = AboveNormal; // Option only for windows
195 frame_drop = false;
196 hard_frame_drop = false;
197 coreavc = false;
198 h264_skip_loop_filter = LoopEnabled;
199 HD_height = 720;
200
201 // MPlayer 1.0rc1 require restart, new versions don't
202 fast_audio_change = Detect;
203#if !SMART_DVD_CHAPTERS
204 fast_chapter_change = false;
205#endif
206
207 threads = 1;
208
209 cache_for_files = 2048;
210 cache_for_streams = 2048;
211 cache_for_dvds = 0; // not recommended to use cache for dvds
212 cache_for_vcds = 1024;
213 cache_for_audiocds = 1024;
214 cache_for_tv = 3000;
215
216#ifdef YOUTUBE_SUPPORT
217 yt_quality = RetrieveYoutubeUrl::MP4_720p;
218 //yt_user_agent = "Mozilla/5.0 (X11; Linux x86_64; rv:5.0.1) Gecko/20100101 Firefox/5.0.1";
219 yt_user_agent = "";
220 yt_use_https_main = false;
221 yt_use_https_vi = false;
222#endif
223
224
225 /* *********
226 Subtitles
227 ********* */
228
229 font_file = "";
230 font_name = "";
231 use_fontconfig = false;
232 subcp = "ISO-8859-1";
233 use_enca = false;
234 enca_lang = QString(QLocale::system().name()).section("_",0,0);
235 font_autoscale = 1;
236 subfuzziness = 1;
237 autoload_sub = true;
238
239 use_ass_subtitles = true;
240 ass_line_spacing = 0;
241
242 use_forced_subs_only = false;
243
244 sub_visibility = true;
245
246 subtitles_on_screenshots = false;
247
248 use_new_sub_commands = Detect;
249 change_sub_scale_should_restart = Detect;
250
251 fast_load_sub = true;
252
253 // ASS styles
254 // Nothing to do, default values are given in
255 // AssStyles constructor
256
257 force_ass_styles = false;
258 user_forced_ass_style.clear();
259
260 freetype_support = true;
261#ifdef Q_OS_WIN
262 use_windowsfontdir = false;
263#endif
264
265
266 /* ********
267 Advanced
268 ******** */
269
270#if USE_ADAPTER
271 adapter = -1;
272#endif
273
274#if USE_COLORKEY
275 color_key = 0x020202;
276#endif
277
278 use_mplayer_window = false;
279
280 monitor_aspect=""; // Autodetect
281
282 use_idx = false;
283 use_lavf_demuxer = false;
284
285 mplayer_additional_options="";
286 #ifdef PORTABLE_APP
287 mplayer_additional_options="-nofontconfig";
288 #endif
289 mplayer_additional_video_filters="";
290 mplayer_additional_audio_filters="";
291
292#ifdef LOG_MPLAYER
293 log_mplayer = true;
294 verbose_log = false;
295 autosave_mplayer_log = false;
296 mplayer_log_saveto = "";
297#endif
298#ifdef LOG_SMPLAYER
299 log_smplayer = true;
300 log_filter = ".*";
301 save_smplayer_log = false;
302#endif
303
304#if REPAINT_BACKGROUND_OPTION
305 // "Repaint video background" in the preferences dialog
306 #ifndef Q_OS_WIN
307 repaint_video_background = false;
308 #else
309 repaint_video_background = true;
310 #endif
311#endif
312
313 use_edl_files = true;
314
315 prefer_ipv4 = true;
316
317 use_short_pathnames = false;
318
319 change_video_equalizer_on_startup = true;
320
321 use_pausing_keep_force = true;
322
323 use_correct_pts = Detect;
324
325 actions_to_run = "";
326
327 show_tag_in_window_title = true;
328
329 time_to_kill_mplayer = 1000;
330
331
332 /* *********
333 GUI stuff
334 ********* */
335
336 fullscreen = false;
337 start_in_fullscreen = false;
338 compact_mode = false;
339 stay_on_top = NeverOnTop;
340 size_factor = 100; // 100%
341
342 resize_method = Never;
343
344#if STYLE_SWITCHING
345 style="";
346#endif
347
348 move_when_dragging = false;
349
350
351#if DVDNAV_SUPPORT
352 mouse_left_click_function = "dvdnav_mouse";
353#else
354 mouse_left_click_function = "";
355#endif
356 mouse_right_click_function = "show_context_menu";
357 mouse_double_click_function = "fullscreen";
358 mouse_middle_click_function = "mute";
359 mouse_xbutton1_click_function = "";
360 mouse_xbutton2_click_function = "";
361 wheel_function = Seeking;
362 wheel_function_cycle = Seeking | Volume | Zoom | ChangeSpeed;
363 wheel_function_seeking_reverse = false;
364
365 seeking1 = 10;
366 seeking2 = 60;
367 seeking3 = 10*60;
368 seeking4 = 30;
369
370 update_while_seeking = false;
371#if ENABLE_DELAYED_DRAGGING
372 time_slider_drag_delay = 100;
373#endif
374#if SEEKBAR_RESOLUTION
375 relative_seeking = false;
376#endif
377 precise_seeking = true;
378
379 reset_stop = false;
380 delay_left_click = false;
381
382 language = "";
383
384 balloon_count = 5;
385
386#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
387 restore_pos_after_fullscreen = true;
388#else
389 restore_pos_after_fullscreen = false;
390#endif
391
392 save_window_size_on_exit = true;
393
394 close_on_finish = false;
395
396#ifdef AUTO_SHUTDOWN_PC
397 auto_shutdown_pc = false;
398#endif
399
400 default_font = "";
401
402 pause_when_hidden = false;
403
404 allow_video_movement = false;
405
406#ifdef SKINS
407 gui = "SkinGUI";
408 iconset = "Gonzo";
409#else
410 gui = "DefaultGUI";
411 iconset = "";
412#endif
413
414#if USE_MINIMUMSIZE
415 gui_minimum_width = 0; // 0 == disabled
416#endif
417 default_size = QSize(683, 509);
418
419#if ALLOW_TO_HIDE_VIDEO_WINDOW_ON_AUDIO_FILES
420 hide_video_window_on_audio_files = true;
421#endif
422
423 report_mplayer_crashes = true;
424
425#if REPORT_OLD_MPLAYER
426 reported_mplayer_is_old = false;
427#endif
428
429 auto_add_to_playlist = true;
430 media_to_add_to_playlist = NoFiles;
431
432#if LOGO_ANIMATION
433 animated_logo = true;
434#endif
435
436
437 /* ********
438 TV (dvb)
439 ******** */
440
441 check_channels_conf_on_startup = true;
442 initial_tv_deinterlace = MediaSettings::Yadif_1;
443 last_dvb_channel = "";
444 last_tv_channel = "";
445
446
447 /* ***********
448 Directories
449 *********** */
450
451 latest_dir = QDir::homePath();
452 last_dvd_directory="";
453 save_dirs = true;
454
455 /* **************
456 Initial values
457 ************** */
458
459 initial_sub_scale = 5;
460 initial_sub_scale_ass = 1;
461 initial_volume = 40;
462 initial_contrast = 0;
463 initial_brightness = 0;
464 initial_hue = 0;
465 initial_saturation = 0;
466 initial_gamma = 0;
467
468 initial_audio_equalizer << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0;
469
470 initial_zoom_factor = 1.0;
471 initial_sub_pos = 100; // 100%
472
473 initial_postprocessing = false;
474 initial_volnorm = false;
475
476 initial_deinterlace = MediaSettings::NoDeinterlace;
477
478 initial_audio_channels = MediaSettings::ChDefault;
479 initial_stereo_mode = MediaSettings::Stereo;
480
481 initial_audio_track = 1;
482 initial_subtitle_track = 1;
483
484
485 /* ************
486 MPlayer info
487 ************ */
488
489 mplayer_detected_version = -1; //None version parsed yet
490 mplayer_user_supplied_version = -1;
491 mplayer_is_mplayer2 = false;
492 mplayer2_detected_version = QString::null;
493
494
495 /* *********
496 Instances
497 ********* */
498#ifdef SINGLE_INSTANCE
499 use_single_instance = true;
500#endif
501
502
503 /* ****************
504 Floating control
505 **************** */
506
507 floating_control_margin = 0;
508 floating_control_width = 70; //70 %
509 floating_control_animated = true;
510 floating_display_in_compact_mode = false;
511 floating_activation_area = AutohideWidget::Anywhere;
512 floating_hide_delay = 3000;
513
514
515 /* *******
516 History
517 ******* */
518
519 history_recents->clear();
520 history_urls->clear();
521
522
523 /* *******
524 Filters
525 ******* */
526
527 filters->init();
528
529
530 /* *********
531 SMPlayer info
532 ********* */
533
534#ifdef CHECK_UPGRADED
535 smplayer_stable_version = "";
536 check_if_upgraded = true;
537#endif
538#ifdef FONTCACHE_DIALOG
539 smplayer_version = "";
540#endif
541}
542
543#ifndef NO_USE_INI_FILES
544void Preferences::save() {
545 qDebug("Preferences::save");
546
547 QSettings * set = settings;
548
549
550 /* *******
551 General
552 ******* */
553
554 set->beginGroup("General");
555
556 set->setValue("config_version", config_version);
557
558 set->setValue("mplayer_bin", mplayer_bin);
559 set->setValue("driver/vo", vo);
560 set->setValue("driver/audio_output", ao);
561
562 set->setValue("use_screenshot", use_screenshot);
563 #if QT_VERSION >= 0x040400
564 set->setValue("screenshot_folder", screenshot_directory);
565 #else
566 set->setValue("screenshot_directory", screenshot_directory);
567 #endif
568
569 set->setValue("dont_remember_media_settings", dont_remember_media_settings);
570 set->setValue("dont_remember_time_pos", dont_remember_time_pos);
571
572 set->setValue("audio_lang", audio_lang);
573 set->setValue("subtitle_lang", subtitle_lang);
574
575 set->setValue("use_direct_rendering", use_direct_rendering);
576 set->setValue("use_double_buffer", use_double_buffer);
577 set->setValue("use_soft_video_eq", use_soft_video_eq);
578 set->setValue("use_slices", use_slices );
579 set->setValue("autoq", autoq);
580 set->setValue("add_blackborders_on_fullscreen", add_blackborders_on_fullscreen);
581
582#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
583 #ifdef SCREENSAVER_OFF
584 set->setValue("turn_screensaver_off", turn_screensaver_off);
585 #endif
586 #ifdef AVOID_SCREENSAVER
587 set->setValue("avoid_screensaver", avoid_screensaver);
588 #endif
589#else
590 set->setValue("disable_screensaver", disable_screensaver);
591#endif
592
593#ifndef Q_OS_WIN
594 set->setValue("vdpau_ffh264vdpau", vdpau.ffh264vdpau);
595 set->setValue("vdpau_ffmpeg12vdpau", vdpau.ffmpeg12vdpau);
596 set->setValue("vdpau_ffwmv3vdpau", vdpau.ffwmv3vdpau);
597 set->setValue("vdpau_ffvc1vdpau", vdpau.ffvc1vdpau);
598 set->setValue("vdpau_ffodivxvdpau", vdpau.ffodivxvdpau);
599 set->setValue("vdpau_disable_video_filters", vdpau.disable_video_filters);
600#endif
601
602 set->setValue("use_soft_vol", use_soft_vol);
603 set->setValue("softvol_max", softvol_max);
604 set->setValue("use_scaletempo", use_scaletempo);
605 set->setValue("use_hwac3", use_hwac3 );
606 set->setValue("use_audio_equalizer", use_audio_equalizer );
607
608 set->setValue("global_volume", global_volume);
609 set->setValue("volume", volume);
610 set->setValue("mute", mute);
611
612 set->setValue("global_audio_equalizer", global_audio_equalizer);
613 set->setValue("audio_equalizer", audio_equalizer);
614
615 set->setValue("autosync", autosync);
616 set->setValue("autosync_factor", autosync_factor);
617
618 set->setValue("use_mc", use_mc);
619 set->setValue("mc_value", mc_value);
620
621 set->setValue("autoload_m4a", autoload_m4a);
622 set->setValue("min_step", min_step);
623
624 set->setValue("osd", osd);
625 set->setValue("osd_delay", osd_delay);
626
627 set->setValue("file_settings_method", file_settings_method);
628
629 set->endGroup(); // General
630
631
632 /* ***************
633 Drives (CD/DVD)
634 *************** */
635
636 set->beginGroup( "drives");
637
638 set->setValue("dvd_device", dvd_device);
639 set->setValue("cdrom_device", cdrom_device);
640#ifdef BLURAY_SUPPORT
641 set->setValue("bluray_device", bluray_device);
642#endif
643
644#ifdef Q_OS_WIN
645 set->setValue("enable_audiocd_on_windows", enable_audiocd_on_windows);
646#endif
647
648 set->setValue("vcd_initial_title", vcd_initial_title);
649
650#if DVDNAV_SUPPORT
651 set->setValue("use_dvdnav", use_dvdnav);
652#endif
653
654 set->endGroup(); // drives
655
656
657 /* ***********
658 Performance
659 *********** */
660
661 set->beginGroup( "performance");
662
663 set->setValue("priority", priority);
664 set->setValue("frame_drop", frame_drop);
665 set->setValue("hard_frame_drop", hard_frame_drop);
666 set->setValue("coreavc", coreavc);
667 set->setValue("h264_skip_loop_filter", h264_skip_loop_filter);
668 set->setValue("HD_height", HD_height);
669
670 set->setValue("fast_audio_change", fast_audio_change);
671#if !SMART_DVD_CHAPTERS
672 set->setValue("fast_chapter_change", fast_chapter_change);
673#endif
674
675 set->setValue("threads", threads);
676
677 set->setValue("cache_for_files", cache_for_files);
678 set->setValue("cache_for_streams", cache_for_streams);
679 set->setValue("cache_for_dvds", cache_for_dvds);
680 set->setValue("cache_for_vcds", cache_for_vcds);
681 set->setValue("cache_for_audiocds", cache_for_audiocds);
682 set->setValue("cache_for_tv", cache_for_tv);
683
684 set->endGroup(); // performance
685
686#ifdef YOUTUBE_SUPPORT
687 set->beginGroup("youtube");
688 set->setValue("quality", yt_quality);
689 set->setValue("user_agent", yt_user_agent);
690 set->setValue("yt_use_https_main", yt_use_https_main);
691 set->setValue("yt_use_https_vi", yt_use_https_vi);
692 set->endGroup();
693#endif
694
695
696 /* *********
697 Subtitles
698 ********* */
699
700 set->beginGroup("subtitles");
701
702 set->setValue("font_file", font_file);
703 set->setValue("font_name", font_name);
704
705 set->setValue("use_fontconfig", use_fontconfig);
706 set->setValue("subcp", subcp);
707 set->setValue("use_enca", use_enca);
708 set->setValue("enca_lang", enca_lang);
709 set->setValue("font_autoscale", font_autoscale);
710 set->setValue("subfuzziness", subfuzziness);
711 set->setValue("autoload_sub", autoload_sub);
712
713 set->setValue("use_ass_subtitles", use_ass_subtitles);
714 set->setValue("ass_line_spacing", ass_line_spacing);
715 set->setValue("use_forced_subs_only", use_forced_subs_only);
716
717 set->setValue("sub_visibility", sub_visibility);
718
719 set->setValue("subtitles_on_screenshots", subtitles_on_screenshots);
720
721 set->setValue("use_new_sub_commands", use_new_sub_commands);
722 set->setValue("change_sub_scale_should_restart", change_sub_scale_should_restart);
723
724 set->setValue("fast_load_sub", fast_load_sub);
725
726 // ASS styles
727 ass_styles.save(set);
728 set->setValue("force_ass_styles", force_ass_styles);
729 set->setValue("user_forced_ass_style", user_forced_ass_style);
730
731 set->setValue("freetype_support", freetype_support);
732#ifdef Q_OS_WIN
733 set->setValue("use_windowsfontdir", use_windowsfontdir);
734#endif
735
736 set->endGroup(); // subtitles
737
738
739 /* ********
740 Advanced
741 ******** */
742
743 set->beginGroup( "advanced");
744
745#if USE_ADAPTER
746 set->setValue("adapter", adapter);
747#endif
748
749#if USE_COLORKEY
750 set->setValue("color_key", QString::number(color_key,16));
751#endif
752
753 set->setValue("use_mplayer_window", use_mplayer_window);
754
755 set->setValue("monitor_aspect", monitor_aspect);
756
757 set->setValue("use_idx", use_idx);
758 set->setValue("use_lavf_demuxer", use_lavf_demuxer);
759
760 set->setValue("mplayer_additional_options", mplayer_additional_options);
761 set->setValue("mplayer_additional_video_filters", mplayer_additional_video_filters);
762 set->setValue("mplayer_additional_audio_filters", mplayer_additional_audio_filters);
763
764#ifdef LOG_MPLAYER
765 set->setValue("log_mplayer", log_mplayer);
766 set->setValue("verbose_log", verbose_log);
767 set->setValue("autosave_mplayer_log", autosave_mplayer_log);
768 set->setValue("mplayer_log_saveto", mplayer_log_saveto);
769#endif
770#ifdef LOG_SMPLAYER
771 set->setValue("log_smplayer", log_smplayer);
772 set->setValue("log_filter", log_filter);
773 set->setValue("save_smplayer_log", save_smplayer_log);
774#endif
775
776#if REPAINT_BACKGROUND_OPTION
777 set->setValue("repaint_video_background", repaint_video_background);
778#endif
779
780 set->setValue("use_edl_files", use_edl_files);
781
782 set->setValue("prefer_ipv4", prefer_ipv4);
783
784 set->setValue("use_short_pathnames", use_short_pathnames);
785
786 set->setValue("change_video_equalizer_on_startup", change_video_equalizer_on_startup);
787
788 set->setValue("use_pausing_keep_force", use_pausing_keep_force);
789
790 set->setValue("correct_pts", use_correct_pts);
791
792 set->setValue("actions_to_run", actions_to_run);
793
794 set->setValue("show_tag_in_window_title", show_tag_in_window_title);
795
796 set->setValue("time_to_kill_mplayer", time_to_kill_mplayer);
797
798 set->endGroup(); // advanced
799
800
801 /* *********
802 GUI stuff
803 ********* */
804
805 set->beginGroup("gui");
806
807 set->setValue("fullscreen", fullscreen);
808 set->setValue("start_in_fullscreen", start_in_fullscreen);
809
810 set->setValue("compact_mode", compact_mode);
811 set->setValue("stay_on_top", (int) stay_on_top);
812 set->setValue("size_factor", size_factor);
813 set->setValue("resize_method", resize_method);
814
815#if STYLE_SWITCHING
816 set->setValue("style", style);
817#endif
818
819 set->setValue("move_when_dragging", move_when_dragging);
820
821 set->setValue("mouse_left_click_function", mouse_left_click_function);
822 set->setValue("mouse_right_click_function", mouse_right_click_function);
823 set->setValue("mouse_double_click_function", mouse_double_click_function);
824 set->setValue("mouse_middle_click_function", mouse_middle_click_function);
825 set->setValue("mouse_xbutton1_click_function", mouse_xbutton1_click_function);
826 set->setValue("mouse_xbutton2_click_function", mouse_xbutton2_click_function);
827 set->setValue("mouse_wheel_function", wheel_function);
828 set->setValue("wheel_function_cycle", (int) wheel_function_cycle);
829 set->setValue("wheel_function_seeking_reverse", wheel_function_seeking_reverse);
830
831 set->setValue("seeking1", seeking1);
832 set->setValue("seeking2", seeking2);
833 set->setValue("seeking3", seeking3);
834 set->setValue("seeking4", seeking4);
835
836 set->setValue("update_while_seeking", update_while_seeking);
837#if ENABLE_DELAYED_DRAGGING
838 set->setValue("time_slider_drag_delay", time_slider_drag_delay);
839#endif
840#if SEEKBAR_RESOLUTION
841 set->setValue("relative_seeking", relative_seeking);
842#endif
843 set->setValue("precise_seeking", precise_seeking);
844
845 set->setValue("reset_stop", reset_stop);
846 set->setValue("delay_left_click", delay_left_click);
847
848 set->setValue("language", language);
849 set->setValue("iconset", iconset);
850
851 set->setValue("balloon_count", balloon_count);
852
853 set->setValue("restore_pos_after_fullscreen", restore_pos_after_fullscreen);
854 set->setValue("save_window_size_on_exit", save_window_size_on_exit);
855
856 set->setValue("close_on_finish", close_on_finish);
857
858#ifdef AUTO_SHUTDOWN_PC
859 set->setValue("auto_shutdown_pc", auto_shutdown_pc);
860#endif
861
862 set->setValue("default_font", default_font);
863
864 set->setValue("pause_when_hidden", pause_when_hidden);
865
866 set->setValue("allow_video_movement", allow_video_movement);
867
868 set->setValue("gui", gui);
869
870#if USE_MINIMUMSIZE
871 set->setValue("gui_minimum_width", gui_minimum_width);
872#endif
873 set->setValue("default_size", default_size);
874
875#if ALLOW_TO_HIDE_VIDEO_WINDOW_ON_AUDIO_FILES
876 set->setValue("hide_video_window_on_audio_files", hide_video_window_on_audio_files);
877#endif
878
879 set->setValue("report_mplayer_crashes", report_mplayer_crashes);
880
881#if REPORT_OLD_MPLAYER
882 set->setValue("reported_mplayer_is_old", reported_mplayer_is_old);
883#endif
884
885 set->setValue("auto_add_to_playlist", auto_add_to_playlist);
886 set->setValue("media_to_add_to_playlist", media_to_add_to_playlist);
887
888#if LOGO_ANIMATION
889 set->setValue("animated_logo", animated_logo);
890#endif
891
892 set->endGroup(); // gui
893
894
895 /* ********
896 TV (dvb)
897 ******** */
898
899 set->beginGroup( "tv");
900 set->setValue("check_channels_conf_on_startup", check_channels_conf_on_startup);
901 set->setValue("initial_tv_deinterlace", initial_tv_deinterlace);
902 set->setValue("last_dvb_channel", last_dvb_channel);
903 set->setValue("last_tv_channel", last_tv_channel);
904 set->endGroup(); // tv
905
906 /* ***********
907 Directories
908 *********** */
909
910 set->beginGroup( "directories");
911 if (save_dirs) {
912 set->setValue("latest_dir", latest_dir);
913 set->setValue("last_dvd_directory", last_dvd_directory);
914 } else {
915 set->setValue("latest_dir", "");
916 set->setValue("last_dvd_directory", "");
917 }
918 set->setValue("save_dirs", save_dirs);
919 set->endGroup(); // directories
920
921
922 /* **************
923 Initial values
924 ************** */
925
926 set->beginGroup( "defaults");
927
928 set->setValue("initial_sub_scale", initial_sub_scale);
929 set->setValue("initial_sub_scale_ass", initial_sub_scale_ass);
930 set->setValue("initial_volume", initial_volume);
931 set->setValue("initial_contrast", initial_contrast);
932 set->setValue("initial_brightness", initial_brightness);
933 set->setValue("initial_hue", initial_hue);
934 set->setValue("initial_saturation", initial_saturation);
935 set->setValue("initial_gamma", initial_gamma);
936
937 set->setValue("initial_audio_equalizer", initial_audio_equalizer);
938
939 set->setValue("initial_zoom_factor", initial_zoom_factor);
940 set->setValue("initial_sub_pos", initial_sub_pos);
941
942 set->setValue("initial_volnorm", initial_volnorm);
943 set->setValue("initial_postprocessing", initial_postprocessing);
944
945 set->setValue("initial_deinterlace", initial_deinterlace);
946
947 set->setValue("initial_audio_channels", initial_audio_channels);
948 set->setValue("initial_stereo_mode", initial_stereo_mode);
949
950 set->setValue("initial_audio_track", initial_audio_track);
951 set->setValue("initial_subtitle_track", initial_subtitle_track);
952
953 set->endGroup(); // defaults
954
955
956 /* ************
957 MPlayer info
958 ************ */
959
960 set->beginGroup( "mplayer_info");
961 set->setValue("mplayer_detected_version", mplayer_detected_version);
962 set->setValue("mplayer_user_supplied_version", mplayer_user_supplied_version);
963 set->setValue("is_mplayer2", mplayer_is_mplayer2);
964 set->setValue("mplayer2_detected_version", mplayer2_detected_version);
965 set->endGroup(); // mplayer_info
966
967
968 /* *********
969 Instances
970 ********* */
971#ifdef SINGLE_INSTANCE
972 set->beginGroup("instances");
973 set->setValue("single_instance_enabled", use_single_instance);
974 set->endGroup(); // instances
975#endif
976
977
978 /* ****************
979 Floating control
980 **************** */
981
982 set->beginGroup("floating_control");
983 set->setValue("margin", floating_control_margin);
984 set->setValue("width", floating_control_width);
985 set->setValue("animated", floating_control_animated);
986 set->setValue("display_in_compact_mode", floating_display_in_compact_mode);
987 set->setValue("activation_area", floating_activation_area);
988 set->setValue("hide_delay", floating_hide_delay);
989 set->endGroup(); // floating_control
990
991
992 /* *******
993 History
994 ******* */
995
996 set->beginGroup("history");
997 set->setValue("recents", history_recents->toStringList());
998 set->setValue("recents/max_items", history_recents->maxItems());
999 set->setValue("urls", history_urls->toStringList());
1000 set->setValue("urls/max_items", history_urls->maxItems());
1001 set->endGroup(); // history
1002
1003
1004 /* *******
1005 Filters
1006 ******* */
1007
1008 filters->save(set);
1009
1010
1011 /* *********
1012 SMPlayer info
1013 ********* */
1014
1015 set->beginGroup("smplayer");
1016#ifdef CHECK_UPGRADED
1017 set->setValue("stable_version", smplayer_stable_version);
1018 set->setValue("check_if_upgraded", check_if_upgraded);
1019#endif
1020#ifdef FONTCACHE_DIALOG
1021 set->setValue("version", smplayer_version);
1022#endif
1023 set->endGroup();
1024
1025
1026 /* *********
1027 Update
1028 ********* */
1029
1030#ifdef UPDATE_CHECKER
1031 update_checker_data.save(set);
1032#endif
1033
1034 set->sync();
1035}
1036
1037void Preferences::load() {
1038 qDebug("Preferences::load");
1039
1040 QSettings * set = settings;
1041
1042
1043 /* *******
1044 General
1045 ******* */
1046
1047 set->beginGroup("General");
1048
1049 config_version = set->value("config_version", 0).toInt();
1050
1051 mplayer_bin = set->value("mplayer_bin", mplayer_bin).toString();
1052 vo = set->value("driver/vo", vo).toString();
1053 ao = set->value("driver/audio_output", ao).toString();
1054
1055 use_screenshot = set->value("use_screenshot", use_screenshot).toBool();
1056 #if QT_VERSION >= 0x040400
1057 screenshot_directory = set->value("screenshot_folder", screenshot_directory).toString();
1058 setupScreenshotFolder();
1059 #else
1060 screenshot_directory = set->value("screenshot_directory", screenshot_directory).toString();
1061 #endif
1062
1063 dont_remember_media_settings = set->value("dont_remember_media_settings", dont_remember_media_settings).toBool();
1064 dont_remember_time_pos = set->value("dont_remember_time_pos", dont_remember_time_pos).toBool();
1065
1066 audio_lang = set->value("audio_lang", audio_lang).toString();
1067 subtitle_lang = set->value("subtitle_lang", subtitle_lang).toString();
1068
1069 use_direct_rendering = set->value("use_direct_rendering", use_direct_rendering).toBool();
1070 use_double_buffer = set->value("use_double_buffer", use_double_buffer).toBool();
1071
1072 use_soft_video_eq = set->value("use_soft_video_eq", use_soft_video_eq).toBool();
1073 use_slices = set->value("use_slices", use_slices ).toBool();
1074 autoq = set->value("autoq", autoq).toInt();
1075 add_blackborders_on_fullscreen = set->value("add_blackborders_on_fullscreen", add_blackborders_on_fullscreen).toBool();
1076
1077#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
1078 #ifdef SCREENSAVER_OFF
1079 turn_screensaver_off = set->value("turn_screensaver_off", turn_screensaver_off).toBool();
1080 #endif
1081 #ifdef AVOID_SCREENSAVER
1082 avoid_screensaver = set->value("avoid_screensaver", avoid_screensaver).toBool();
1083 #endif
1084#else
1085 disable_screensaver = set->value("disable_screensaver", disable_screensaver).toBool();
1086#endif
1087
1088#ifndef Q_OS_WIN
1089 vdpau.ffh264vdpau = set->value("vdpau_ffh264vdpau", vdpau.ffh264vdpau).toBool();
1090 vdpau.ffmpeg12vdpau = set->value("vdpau_ffmpeg12vdpau", vdpau.ffmpeg12vdpau).toBool();
1091 vdpau.ffwmv3vdpau = set->value("vdpau_ffwmv3vdpau", vdpau.ffwmv3vdpau).toBool();
1092 vdpau.ffvc1vdpau = set->value("vdpau_ffvc1vdpau", vdpau.ffvc1vdpau).toBool();
1093 vdpau.ffodivxvdpau = set->value("vdpau_ffodivxvdpau", vdpau.ffodivxvdpau).toBool();
1094 vdpau.disable_video_filters = set->value("vdpau_disable_video_filters", vdpau.disable_video_filters).toBool();
1095#endif
1096
1097 use_soft_vol = set->value("use_soft_vol", use_soft_vol).toBool();
1098 softvol_max = set->value("softvol_max", softvol_max).toInt();
1099 use_scaletempo = (OptionState) set->value("use_scaletempo", use_scaletempo).toInt();
1100 use_hwac3 = set->value("use_hwac3", use_hwac3 ).toBool();
1101 use_audio_equalizer = set->value("use_audio_equalizer", use_audio_equalizer ).toBool();
1102
1103 global_volume = set->value("global_volume", global_volume).toBool();
1104 volume = set->value("volume", volume).toInt();
1105 mute = set->value("mute", mute).toBool();
1106
1107 global_audio_equalizer = set->value("global_audio_equalizer", global_audio_equalizer).toBool();
1108 audio_equalizer = set->value("audio_equalizer", audio_equalizer).toList();
1109
1110 autosync = set->value("autosync", autosync).toBool();
1111 autosync_factor = set->value("autosync_factor", autosync_factor).toInt();
1112
1113 use_mc = set->value("use_mc", use_mc).toBool();
1114 mc_value = set->value("mc_value", mc_value).toDouble();
1115
1116 autoload_m4a = set->value("autoload_m4a", autoload_m4a).toBool();
1117 min_step = set->value("min_step", min_step).toInt();
1118
1119 osd = set->value("osd", osd).toInt();
1120 osd_delay = set->value("osd_delay", osd_delay).toInt();
1121
1122 file_settings_method = set->value("file_settings_method", file_settings_method).toString();
1123
1124 set->endGroup(); // General
1125
1126
1127 /* ***************
1128 Drives (CD/DVD)
1129 *************** */
1130
1131 set->beginGroup( "drives");
1132
1133 dvd_device = set->value("dvd_device", dvd_device).toString();
1134 cdrom_device = set->value("cdrom_device", cdrom_device).toString();
1135#ifdef BLURAY_SUPPORT
1136 bluray_device = set->value("bluray_device", bluray_device).toString();
1137#endif
1138
1139#ifdef Q_OS_WIN
1140 enable_audiocd_on_windows = set->value("enable_audiocd_on_windows", enable_audiocd_on_windows).toBool();
1141#endif
1142
1143 vcd_initial_title = set->value("vcd_initial_title", vcd_initial_title ).toInt();
1144
1145#if DVDNAV_SUPPORT
1146 use_dvdnav = set->value("use_dvdnav", use_dvdnav).toBool();
1147#endif
1148
1149 set->endGroup(); // drives
1150
1151
1152 /* ***********
1153 Performance
1154 *********** */
1155
1156 set->beginGroup( "performance");
1157
1158 priority = set->value("priority", priority).toInt();
1159 frame_drop = set->value("frame_drop", frame_drop).toBool();
1160 hard_frame_drop = set->value("hard_frame_drop", hard_frame_drop).toBool();
1161 coreavc = set->value("coreavc", coreavc).toBool();
1162 h264_skip_loop_filter = (H264LoopFilter) set->value("h264_skip_loop_filter", h264_skip_loop_filter).toInt();
1163 HD_height = set->value("HD_height", HD_height).toInt();
1164
1165 fast_audio_change = (OptionState) set->value("fast_audio_change", fast_audio_change).toInt();
1166#if !SMART_DVD_CHAPTERS
1167 fast_chapter_change = set->value("fast_chapter_change", fast_chapter_change).toBool();
1168#endif
1169
1170 threads = set->value("threads", threads).toInt();
1171
1172 cache_for_files = set->value("cache_for_files", cache_for_files).toInt();
1173 cache_for_streams = set->value("cache_for_streams", cache_for_streams).toInt();
1174 cache_for_dvds = set->value("cache_for_dvds", cache_for_dvds).toInt();
1175 cache_for_vcds = set->value("cache_for_vcds", cache_for_vcds).toInt();
1176 cache_for_audiocds = set->value("cache_for_audiocds", cache_for_audiocds).toInt();
1177 cache_for_tv = set->value("cache_for_tv", cache_for_tv).toInt();
1178
1179 set->endGroup(); // performance
1180
1181#ifdef YOUTUBE_SUPPORT
1182 set->beginGroup("youtube");
1183 yt_quality = set->value("quality", yt_quality).toInt();
1184 yt_user_agent = set->value("user_agent", yt_user_agent).toString();
1185 yt_use_https_main = set->value("yt_use_https_main", yt_use_https_main).toBool();
1186 yt_use_https_vi = set->value("yt_use_https_vi", yt_use_https_vi).toBool();
1187 set->endGroup();
1188#endif
1189
1190
1191 /* *********
1192 Subtitles
1193 ********* */
1194
1195 set->beginGroup("subtitles");
1196
1197 font_file = set->value("font_file", font_file).toString();
1198 font_name = set->value("font_name", font_name).toString();
1199
1200 use_fontconfig = set->value("use_fontconfig", use_fontconfig).toBool();
1201 subcp = set->value("subcp", subcp).toString();
1202 use_enca = set->value("use_enca", use_enca).toBool();
1203 enca_lang = set->value("enca_lang", enca_lang).toString();
1204 font_autoscale = set->value("font_autoscale", font_autoscale).toInt();
1205 subfuzziness = set->value("subfuzziness", subfuzziness).toInt();
1206 autoload_sub = set->value("autoload_sub", autoload_sub).toBool();
1207
1208 use_ass_subtitles = set->value("use_ass_subtitles", use_ass_subtitles).toBool();
1209 ass_line_spacing = set->value("ass_line_spacing", ass_line_spacing).toInt();
1210
1211 use_forced_subs_only = set->value("use_forced_subs_only", use_forced_subs_only).toBool();
1212
1213 sub_visibility = set->value("sub_visibility", sub_visibility).toBool();
1214
1215 subtitles_on_screenshots = set->value("subtitles_on_screenshots", subtitles_on_screenshots).toBool();
1216
1217 use_new_sub_commands = (OptionState) set->value("use_new_sub_commands", use_new_sub_commands).toInt();
1218 change_sub_scale_should_restart = (OptionState) set->value("change_sub_scale_should_restart", change_sub_scale_should_restart).toInt();
1219
1220 fast_load_sub = set->value("fast_load_sub", fast_load_sub).toBool();
1221
1222 // ASS styles
1223 ass_styles.load(set);
1224 force_ass_styles = set->value("force_ass_styles", force_ass_styles).toBool();
1225 user_forced_ass_style = set->value("user_forced_ass_style", user_forced_ass_style).toString();
1226
1227 freetype_support = set->value("freetype_support", freetype_support).toBool();
1228#ifdef Q_OS_WIN
1229 use_windowsfontdir = set->value("use_windowsfontdir", use_windowsfontdir).toBool();
1230#endif
1231
1232 set->endGroup(); // subtitles
1233
1234
1235 /* ********
1236 Advanced
1237 ******** */
1238
1239 set->beginGroup( "advanced");
1240
1241#if USE_ADAPTER
1242 adapter = set->value("adapter", adapter).toInt();
1243#endif
1244
1245#if USE_COLORKEY
1246 bool ok;
1247 QString color = set->value("color_key", QString::number(color_key,16)).toString();
1248 unsigned int temp_color_key = color.toUInt(&ok, 16);
1249 if (ok)
1250 color_key = temp_color_key;
1251 //color_key = set->value("color_key", color_key).toInt();
1252#endif
1253
1254 use_mplayer_window = set->value("use_mplayer_window", use_mplayer_window).toBool();
1255
1256 monitor_aspect = set->value("monitor_aspect", monitor_aspect).toString();
1257
1258 use_idx = set->value("use_idx", use_idx).toBool();
1259 use_lavf_demuxer = set->value("use_lavf_demuxer", use_lavf_demuxer).toBool();
1260
1261 mplayer_additional_options = set->value("mplayer_additional_options", mplayer_additional_options).toString();
1262 mplayer_additional_video_filters = set->value("mplayer_additional_video_filters", mplayer_additional_video_filters).toString();
1263 mplayer_additional_audio_filters = set->value("mplayer_additional_audio_filters", mplayer_additional_audio_filters).toString();
1264
1265#ifdef LOG_MPLAYER
1266 log_mplayer = set->value("log_mplayer", log_mplayer).toBool();
1267 verbose_log = set->value("verbose_log", verbose_log).toBool();
1268 autosave_mplayer_log = set->value("autosave_mplayer_log", autosave_mplayer_log).toBool();
1269 mplayer_log_saveto = set->value("mplayer_log_saveto", mplayer_log_saveto).toString();
1270#endif
1271#ifdef LOG_SMPLAYER
1272 log_smplayer = set->value("log_smplayer", log_smplayer).toBool();
1273 log_filter = set->value("log_filter", log_filter).toString();
1274 save_smplayer_log = set->value("save_smplayer_log", save_smplayer_log).toBool();
1275#endif
1276
1277#if REPAINT_BACKGROUND_OPTION
1278 repaint_video_background = set->value("repaint_video_background", repaint_video_background).toBool();
1279#endif
1280
1281 use_edl_files = set->value("use_edl_files", use_edl_files).toBool();
1282
1283 prefer_ipv4 = set->value("prefer_ipv4", prefer_ipv4).toBool();
1284
1285 use_short_pathnames = set->value("use_short_pathnames", use_short_pathnames).toBool();
1286
1287 use_pausing_keep_force = set->value("use_pausing_keep_force", use_pausing_keep_force).toBool();
1288
1289 use_correct_pts = (OptionState) set->value("correct_pts", use_correct_pts).toInt();
1290
1291 actions_to_run = set->value("actions_to_run", actions_to_run).toString();
1292
1293 show_tag_in_window_title = set->value("show_tag_in_window_title", show_tag_in_window_title).toBool();
1294
1295 time_to_kill_mplayer = set->value("time_to_kill_mplayer", time_to_kill_mplayer).toInt();
1296
1297 set->endGroup(); // advanced
1298
1299
1300 /* *********
1301 GUI stuff
1302 ********* */
1303
1304 set->beginGroup("gui");
1305
1306 fullscreen = set->value("fullscreen", fullscreen).toBool();
1307 start_in_fullscreen = set->value("start_in_fullscreen", start_in_fullscreen).toBool();
1308
1309 compact_mode = set->value("compact_mode", compact_mode).toBool();
1310 stay_on_top = (Preferences::OnTop) set->value("stay_on_top", (int) stay_on_top).toInt();
1311 size_factor = set->value("size_factor", size_factor).toInt();
1312 resize_method = set->value("resize_method", resize_method).toInt();
1313
1314#if STYLE_SWITCHING
1315 style = set->value("style", style).toString();
1316#endif
1317
1318 move_when_dragging = set->value("move_when_dragging", move_when_dragging).toBool();
1319
1320 mouse_left_click_function = set->value("mouse_left_click_function", mouse_left_click_function).toString();
1321 mouse_right_click_function = set->value("mouse_right_click_function", mouse_right_click_function).toString();
1322 mouse_double_click_function = set->value("mouse_double_click_function", mouse_double_click_function).toString();
1323 mouse_middle_click_function = set->value("mouse_middle_click_function", mouse_middle_click_function).toString();
1324 mouse_xbutton1_click_function = set->value("mouse_xbutton1_click_function", mouse_xbutton1_click_function).toString();
1325 mouse_xbutton2_click_function = set->value("mouse_xbutton2_click_function", mouse_xbutton2_click_function).toString();
1326 wheel_function = set->value("mouse_wheel_function", wheel_function).toInt();
1327 {
1328 int wheel_function_cycle_int = set->value("wheel_function_cycle", (int) wheel_function_cycle).toInt();
1329 wheel_function_cycle = (WheelFunctions) wheel_function_cycle_int;
1330 }
1331 wheel_function_seeking_reverse = set->value("wheel_function_seeking_reverse", wheel_function_seeking_reverse).toBool();
1332
1333 seeking1 = set->value("seeking1", seeking1).toInt();
1334 seeking2 = set->value("seeking2", seeking2).toInt();
1335 seeking3 = set->value("seeking3", seeking3).toInt();
1336 seeking4 = set->value("seeking4", seeking4).toInt();
1337
1338 update_while_seeking = set->value("update_while_seeking", update_while_seeking).toBool();
1339#if ENABLE_DELAYED_DRAGGING
1340 time_slider_drag_delay = set->value("time_slider_drag_delay", time_slider_drag_delay).toInt();
1341#endif
1342#if SEEKBAR_RESOLUTION
1343 relative_seeking = set->value("relative_seeking", relative_seeking).toBool();
1344#endif
1345 precise_seeking = set->value("precise_seeking", precise_seeking).toBool();
1346
1347 reset_stop = set->value("reset_stop", reset_stop).toBool();
1348 delay_left_click = set->value("delay_left_click", delay_left_click).toBool();
1349
1350 language = set->value("language", language).toString();
1351 iconset= set->value("iconset", iconset).toString();
1352
1353 balloon_count = set->value("balloon_count", balloon_count).toInt();
1354
1355 restore_pos_after_fullscreen = set->value("restore_pos_after_fullscreen", restore_pos_after_fullscreen).toBool();
1356 save_window_size_on_exit = set->value("save_window_size_on_exit", save_window_size_on_exit).toBool();
1357
1358 close_on_finish = set->value("close_on_finish", close_on_finish).toBool();
1359
1360#ifdef AUTO_SHUTDOWN_PC
1361 auto_shutdown_pc = set->value("auto_shutdown_pc", auto_shutdown_pc).toBool();
1362#endif
1363
1364 default_font = set->value("default_font", default_font).toString();
1365
1366 pause_when_hidden = set->value("pause_when_hidden", pause_when_hidden).toBool();
1367
1368 allow_video_movement = set->value("allow_video_movement", allow_video_movement).toBool();
1369
1370 gui = set->value("gui", gui).toString();
1371
1372#if USE_MINIMUMSIZE
1373 gui_minimum_width = set->value("gui_minimum_width", gui_minimum_width).toInt();
1374#endif
1375 default_size = set->value("default_size", default_size).toSize();
1376
1377#if ALLOW_TO_HIDE_VIDEO_WINDOW_ON_AUDIO_FILES
1378 hide_video_window_on_audio_files = set->value("hide_video_window_on_audio_files", hide_video_window_on_audio_files).toBool();
1379#endif
1380
1381 report_mplayer_crashes = set->value("report_mplayer_crashes", report_mplayer_crashes).toBool();
1382
1383#if REPORT_OLD_MPLAYER
1384 reported_mplayer_is_old = set->value("reported_mplayer_is_old", reported_mplayer_is_old).toBool();
1385#endif
1386
1387 auto_add_to_playlist = set->value("auto_add_to_playlist", auto_add_to_playlist).toBool();
1388 media_to_add_to_playlist = (AutoAddToPlaylistFilter) set->value("media_to_add_to_playlist", media_to_add_to_playlist).toInt();
1389
1390#if LOGO_ANIMATION
1391 animated_logo = set->value("animated_logo", animated_logo).toBool();
1392#endif
1393
1394 set->endGroup(); // gui
1395
1396
1397 /* ********
1398 TV (dvb)
1399 ******** */
1400
1401 set->beginGroup( "tv");
1402 check_channels_conf_on_startup = set->value("check_channels_conf_on_startup", check_channels_conf_on_startup).toBool();
1403 initial_tv_deinterlace = set->value("initial_tv_deinterlace", initial_tv_deinterlace).toInt();
1404 last_dvb_channel = set->value("last_dvb_channel", last_dvb_channel).toString();
1405 last_tv_channel = set->value("last_tv_channel", last_tv_channel).toString();
1406 set->endGroup(); // tv
1407
1408
1409 /* ***********
1410 Directories
1411 *********** */
1412
1413 set->beginGroup( "directories");
1414 save_dirs = set->value("save_dirs", save_dirs).toBool();
1415 if (save_dirs) {
1416 latest_dir = set->value("latest_dir", latest_dir).toString();
1417 last_dvd_directory = set->value("last_dvd_directory", last_dvd_directory).toString();
1418 }
1419 set->endGroup(); // directories
1420
1421
1422 /* **************
1423 Initial values
1424 ************** */
1425
1426 set->beginGroup( "defaults");
1427
1428 initial_sub_scale = set->value("initial_sub_scale", initial_sub_scale).toDouble();
1429 initial_sub_scale_ass = set->value("initial_sub_scale_ass", initial_sub_scale_ass).toDouble();
1430 initial_volume = set->value("initial_volume", initial_volume).toInt();
1431 initial_contrast = set->value("initial_contrast", initial_contrast).toInt();
1432 initial_brightness = set->value("initial_brightness", initial_brightness).toInt();
1433 initial_hue = set->value("initial_hue", initial_hue).toInt();
1434 initial_saturation = set->value("initial_saturation", initial_saturation).toInt();
1435 initial_gamma = set->value("initial_gamma", initial_gamma).toInt();
1436
1437 initial_audio_equalizer = set->value("initial_audio_equalizer", initial_audio_equalizer).toList();
1438
1439 initial_zoom_factor = set->value("initial_zoom_factor", initial_zoom_factor).toDouble();
1440 initial_sub_pos = set->value("initial_sub_pos", initial_sub_pos).toInt();
1441
1442 initial_volnorm = set->value("initial_volnorm", initial_volnorm).toBool();
1443 initial_postprocessing = set->value("initial_postprocessing", initial_postprocessing).toBool();
1444
1445 initial_deinterlace = set->value("initial_deinterlace", initial_deinterlace).toInt();
1446
1447 initial_audio_channels = set->value("initial_audio_channels", initial_audio_channels).toInt();
1448 initial_stereo_mode = set->value("initial_stereo_mode", initial_stereo_mode).toInt();
1449
1450 initial_audio_track = set->value("initial_audio_track", initial_audio_track).toInt();
1451 initial_subtitle_track = set->value("initial_subtitle_track", initial_subtitle_track).toInt();
1452
1453 set->endGroup(); // defaults
1454
1455
1456 /* ************
1457 MPlayer info
1458 ************ */
1459
1460 set->beginGroup( "mplayer_info");
1461 mplayer_detected_version = set->value("mplayer_detected_version", mplayer_detected_version).toInt();
1462 mplayer_user_supplied_version = set->value("mplayer_user_supplied_version", mplayer_user_supplied_version).toInt();
1463 mplayer_is_mplayer2 = set->value("is_mplayer2", mplayer_is_mplayer2).toBool();
1464 mplayer2_detected_version = set->value("mplayer2_detected_version", mplayer2_detected_version).toString();
1465
1466 set->endGroup(); // mplayer_info
1467
1468
1469 /* *********
1470 Instances
1471 ********* */
1472#ifdef SINGLE_INSTANCE
1473 set->beginGroup("instances");
1474 use_single_instance = set->value("single_instance_enabled", use_single_instance).toBool();
1475 set->endGroup(); // instances
1476#endif
1477
1478
1479 /* ****************
1480 Floating control
1481 **************** */
1482
1483 set->beginGroup("floating_control");
1484 floating_control_margin = set->value("margin", floating_control_margin).toInt();
1485 floating_control_width = set->value("width", floating_control_width).toInt();
1486 floating_control_animated = set->value("animated", floating_control_animated).toBool();
1487 floating_display_in_compact_mode = set->value("display_in_compact_mode", floating_display_in_compact_mode).toBool();
1488 floating_activation_area = set->value("activation_area", floating_activation_area).toInt();
1489 floating_hide_delay = set->value("hide_delay", floating_hide_delay).toInt();
1490 set->endGroup(); // floating_control
1491
1492
1493 /* *******
1494 History
1495 ******* */
1496
1497 set->beginGroup("history");
1498
1499 history_recents->setMaxItems( set->value("recents/max_items", history_recents->maxItems()).toInt() );
1500 history_recents->fromStringList( set->value("recents", history_recents->toStringList()).toStringList() );
1501
1502 history_urls->setMaxItems( set->value("urls/max_items", history_urls->maxItems()).toInt() );
1503 history_urls->fromStringList( set->value("urls", history_urls->toStringList()).toStringList() );
1504
1505 set->endGroup(); // history
1506
1507
1508 /* *******
1509 Filters
1510 ******* */
1511
1512 filters->load(set);
1513
1514
1515 /* *********
1516 SMPlayer info
1517 ********* */
1518
1519#ifdef CHECK_UPGRADED
1520 set->beginGroup("smplayer");
1521 smplayer_stable_version = set->value("stable_version", smplayer_stable_version).toString();
1522 check_if_upgraded = set->value("check_if_upgraded", check_if_upgraded).toBool();
1523#endif
1524#ifdef FONTCACHE_DIALOG
1525 smplayer_version = set->value("version", smplayer_version).toString();
1526#endif
1527 set->endGroup();
1528
1529
1530 /* *********
1531 Update
1532 ********* */
1533
1534#ifdef UPDATE_CHECKER
1535 update_checker_data.load(set);
1536#endif
1537
1538
1539 qDebug("Preferences::load: config_version: %d, CURRENT_CONFIG_VERSION: %d", config_version, CURRENT_CONFIG_VERSION);
1540 // Fix some values if config is old
1541 if (config_version < CURRENT_CONFIG_VERSION) {
1542 qDebug("Preferences::load: config version is old, updating it");
1543 /*
1544 if (config_version <= 2) {
1545 use_slices = false;
1546 }
1547 if (config_version <= 3) {
1548 osd = None;
1549 frame_drop = false;
1550 cache_for_files = 2048;
1551 cache_for_streams = 2048;
1552 time_to_kill_mplayer = 1000;
1553 }
1554 */
1555 if (config_version <= 4) {
1556 use_slices = false;
1557 osd = None;
1558 frame_drop = false;
1559 cache_for_files = 2048;
1560 cache_for_streams = 2048;
1561 time_to_kill_mplayer = 1000;
1562
1563 resize_method = Never;
1564 move_when_dragging = false;
1565 }
1566 config_version = CURRENT_CONFIG_VERSION;
1567 }
1568
1569#ifdef Q_OS_WIN
1570 // Check if the mplayer binary exists and try to fix it
1571 if (!QFile::exists(mplayer_bin)) {
1572 qWarning("mplayer_bin '%s' doesn' exist", mplayer_bin.toLatin1().constData());
1573 bool fixed = false;
1574 if (QFile::exists("mplayer/mplayer.exe")) {
1575 mplayer_bin = "mplayer/mplayer.exe";
1576 fixed = true;
1577 } else
1578 if (QFile::exists("mplayer/mplayer2.exe")) {
1579 mplayer_bin = "mplayer/mplayer2.exe";
1580 fixed = true;
1581 }
1582 if (fixed) {
1583 qWarning("mplayer_bin changed to '%s'", mplayer_bin.toLatin1().constData());
1584 }
1585 }
1586#endif
1587}
1588
1589#endif // NO_USE_INI_FILES
1590
1591double Preferences::monitor_aspect_double() {
1592 qDebug("Preferences::monitor_aspect_double");
1593
1594 QRegExp exp("(\\d+)[:/](\\d+)");
1595 if (exp.indexIn( monitor_aspect ) != -1) {
1596 int w = exp.cap(1).toInt();
1597 int h = exp.cap(2).toInt();
1598 qDebug(" monitor_aspect parsed successfully: %d:%d", w, h);
1599 return (double) w/h;
1600 }
1601
1602 bool ok;
1603 double res = monitor_aspect.toDouble(&ok);
1604 if (ok) {
1605 qDebug(" monitor_aspect parsed successfully: %f", res);
1606 return res;
1607 } else {
1608 qDebug(" warning: monitor_aspect couldn't be parsed!");
1609 qDebug(" monitor_aspect set to 0");
1610 return 0;
1611 }
1612}
1613
1614void Preferences::setupScreenshotFolder() {
1615#if QT_VERSION >= 0x040400
1616 if (screenshot_directory.isEmpty()) {
1617 #if QT_VERSION >= 0x050000
1618 QString pdir = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
1619 if (pdir.isEmpty()) pdir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
1620 if (pdir.isEmpty()) pdir = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
1621 #else
1622 QString pdir = QDesktopServices::storageLocation(QDesktopServices::PicturesLocation);
1623 if (pdir.isEmpty()) pdir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
1624 if (pdir.isEmpty()) pdir = QDesktopServices::storageLocation(QDesktopServices::HomeLocation);
1625 #endif
1626 if (pdir.isEmpty()) pdir = "/tmp";
1627 if (!QFile::exists(pdir)) {
1628 qWarning("Preferences::setupScreenshotFolder: folder '%s' does not exist. Using /tmp as fallback", pdir.toUtf8().constData());
1629 pdir = "/tmp";
1630 }
1631 QString default_screenshot_path = pdir + "/smplayer_screenshots";
1632 if (!QFile::exists(default_screenshot_path)) {
1633 qDebug("Preferences::setupScreenshotFolder: creating '%s'", default_screenshot_path.toUtf8().constData());
1634 if (!QDir().mkdir(default_screenshot_path)) {
1635 qWarning("Preferences::setupScreenshotFolder: failed to create '%s'", default_screenshot_path.toUtf8().constData());
1636 }
1637 }
1638 if (QFile::exists(default_screenshot_path)) {
1639 screenshot_directory = default_screenshot_path;
1640 }
1641 }
1642#endif
1643}
Note: See TracBrowser for help on using the repository browser.