source: smplayer/vendor/current/src/preferences.cpp

Last change on this file was 186, checked in by Silvan Scherrer, 8 years ago

SMPlayer: update vendor to 17.1.0

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