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

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

SMPlayer: update trunk to version 17.1.0

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