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

Last change on this file since 178 was 176, checked in by Silvan Scherrer, 9 years ago

smplayer: update trunk to version 16.4

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