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

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

SMPlayer: update trunk to latest 0.8.7

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