1 /*  smplayer, GUI front-end for mplayer.
2     Copyright (C) 2006-2021 Ricardo Villalba <ricardo@smplayer.info>
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 
20 #ifndef PREFERENCES_H
21 #define PREFERENCES_H
22 
23 /* Global settings */
24 
25 #include <QString>
26 #include <QStringList>
27 #include <QSize>
28 #include "config.h"
29 #include "audioequalizerlist.h"
30 #include "assstyles.h"
31 
32 #ifdef UPDATE_CHECKER
33 #include "updatecheckerdata.h"
34 #endif
35 
36 class Recents;
37 class URLHistory;
38 class Filters;
39 
40 class Preferences {
41 
42 public:
43 	enum OSD { None = 0, Seek = 1, SeekTimer = 2, SeekTimerTotal = 3 };
44 	enum OnTop { NeverOnTop = 0, AlwaysOnTop = 1, WhilePlayingOnTop = 2 };
45 	enum Resize { Never = 0, Always = 1, Afterload = 2 };
46 	enum Priority { Realtime = 0, High = 1, AboveNormal = 2, Normal = 3,
47                     BelowNormal = 4, Idle = 5 };
48 	enum WheelFunction { DoNothing = 1, Seeking = 2, Volume = 4, Zoom = 8,
49                          ChangeSpeed = 16 };
50 	enum DragFunction { DragDisabled = 0, MoveWindow = 1, Gestures = 2 };
51 	enum OptionState { Detect = -1, Disabled = 0, Enabled = 1 };
52 	enum H264LoopFilter { LoopDisabled = 0, LoopEnabled = 1, LoopDisabledOnHD = 2 };
53 	enum AutoAddToPlaylistFilter { NoFiles = 0, VideoFiles = 1, AudioFiles = 2, MultimediaFiles = 3, ConsecutiveFiles = 4 };
54 	enum Streaming { NoStreaming = 0, StreamingAuto = 1, StreamingYT = 2, StreamingYTDL = 3 };
55 
56 	Q_DECLARE_FLAGS(WheelFunctions, WheelFunction);
57 
58 	Preferences();
59 	virtual ~Preferences();
60 
61 	virtual void reset();
62 
63 	void save();
64 	void load();
65 
66 	double monitor_aspect_double();
67 	void setupScreenshotFolder();
68 
69 
70 
71     /* *******
72        General
73        ******* */
74 
75 	int config_version;
76 
77 	QString mplayer_bin;
78 	QString vo; // video output
79 	QString ao; // audio output
80 
81 	bool use_screenshot;
82 #ifdef MPV_SUPPORT
83 	QString screenshot_template;
84 	QString screenshot_format;
85 #endif
86 	QString screenshot_directory;
87 #ifdef CAPTURE_STREAM
88 	QString capture_directory;
89 #endif
90 
91 	// Possibility to remember all media settings
92 	bool remember_media_settings;
93 	bool remember_time_pos;
94 	bool remember_stream_settings;
95 
96 #if SIMPLE_TRACK_SELECTION
97 	QString alang;
98 	QString slang;
99 #else
100 	QString audio_lang; 		// Preferred audio language
101 	QString subtitle_lang;		// Preferred subtitle language
102 #endif
103 
104 	// Video
105 	bool use_direct_rendering;
106 	bool use_double_buffer;
107 	bool use_soft_video_eq;
108 	bool use_slices;
109 	int autoq; 	//!< Postprocessing quality
110 
111 #ifdef ADD_BLACKBORDERS_FS
112 	bool add_blackborders_on_fullscreen;
113 #endif
114 
115 #ifdef SCREENSAVER_OFF
116 	bool disable_screensaver;
117 #endif
118 #if defined(Q_OS_WIN) && defined(AVOID_SCREENSAVER)
119 	bool avoid_screensaver;
120 #endif
121 
122 #ifdef OS_UNIX_NOT_MAC
123 	bool wayland_workarounds;
124 
125 	struct VDPAU_settings {
126 		bool ffh264vdpau;
127 		bool ffmpeg12vdpau;
128 		bool ffwmv3vdpau;
129 		bool ffvc1vdpau;
130 		bool ffodivxvdpau;
131 		bool ffhevcvdpau;
132 		bool disable_video_filters;
133 	} vdpau;
134 #endif
135 
136 	// Audio
137 	bool use_soft_vol;
138 	int softvol_max;
139 	OptionState use_scaletempo;
140 	bool use_hwac3; // -afm hwac3
141 	bool use_audio_equalizer;
142 
143 	// Global volume options
144 	bool global_volume;
145 	int volume;
146 	bool mute;
147 
148 	// Global equalizer
149 	bool global_audio_equalizer;
150 	AudioEqualizerList audio_equalizer;
151 
152 	bool autosync;
153 	int autosync_factor;
154 
155 	// For the -mc option
156 	bool use_mc;
157 	double mc_value;
158 
159 	// When playing a mp4 file, it will use a m4a file for audio if a there's a file with same name but extension m4a
160 	bool autoload_m4a;
161 	int min_step; //<! Step to increase of decrease the controls for color, contrast, brightness and so on
162 
163 	// Misc
164 	int osd;
165 	double osd_scale; // mpv
166 	double subfont_osd_scale; // mplayer
167 	int osd_delay; //<! Delay in ms to show the OSD.
168 #ifdef MPV_SUPPORT
169 	bool osd_fractions; //<! Show OSD times with milliseconds.
170 #endif
171 	int osd_bar_pos;
172 	int osd_show_filename_duration;
173 
174 	QString file_settings_method; //!< Method to be used for saving file settings
175 
176 	bool tablet_mode;
177 	#ifdef Q_OS_WIN
178 	QString tablet_mode_change_answer;
179 	#endif
180 
181 
182     /* ***************
183        Drives (CD/DVD)
184        *************** */
185 
186 	QString dvd_device;
187 	QString cdrom_device;
188 #ifdef BLURAY_SUPPORT
189 	QString bluray_device;
190 #endif
191 
192 #ifdef Q_OS_WIN
193 	bool enable_audiocd_on_windows;
194 #endif
195 
196 	int vcd_initial_title;
197 
198 #if DVDNAV_SUPPORT
199 	bool use_dvdnav; //!< Opens DVDs using dvdnav: instead of dvd:
200 #endif
201 
202 
203     /* ***********
204        Performance
205        *********** */
206 
207 #ifdef Q_OS_WIN
208 	int priority;
209 #endif
210 	bool frame_drop;
211 	bool hard_frame_drop;
212 	bool coreavc;
213 	H264LoopFilter h264_skip_loop_filter;
214 	int HD_height; //!< An HD is a video which height is equal or greater than this.
215 
216 #ifdef OBSOLETE_FAST_AUDIO_CHANGE
217 	OptionState fast_audio_change; // If activated, not restart mplayer
218 #endif
219 
220 #if !SMART_DVD_CHAPTERS
221 	bool fast_chapter_change;
222 #endif
223 
224 	int threads; //!< number of threads to use for decoding (-lavdopts threads <1-8>)
225 	QString hwdec; //!< hardware video decoding (mpv only)
226 
227 	bool cache_auto;
228 	int cache_for_files;
229 	int cache_for_streams;
230 	int cache_for_dvds;
231 	int cache_for_vcds;
232 	int cache_for_audiocds;
233 #ifdef TV_SUPPORT
234 	int cache_for_tv;
235 #endif
236 
237 
238 	/* *********
239 	   Subtitles
240 	   ********* */
241 
242 	QString subcp; // -subcp
243 	bool use_enca;
244 	QString enca_lang;
245 	int subfuzziness;
246 	bool autoload_sub;
247 
248 	bool use_ass_subtitles;
249 	bool enable_ass_styles;
250 	int ass_line_spacing;
251 
252 	bool use_forced_subs_only;
253 
254 	bool sub_visibility;
255 
256 	bool subtitles_on_screenshots;
257 
258 	OptionState change_sub_scale_should_restart;
259 
260 	//! If true, loading an external subtitle will be done
261 	//! by using the sub_load slave command. Otherwise
262 	//! mplayer will be restarted.
263 	bool fast_load_sub;
264 
265 	// ASS styles
266 	AssStyles ass_styles;
267 	bool force_ass_styles; // Use ass styles even for ass files
268 	QString user_forced_ass_style; //!< Specifies a style defined by the user to be used with -ass-force-style
269 
270 	//! If false, options requiring freetype won't be used
271 	bool freetype_support;
272 #ifdef FONTS_HACK
273 	bool use_windowsfontdir;
274 #endif
275 
276 
277     /* ********
278        Advanced
279        ******** */
280 
281 #if USE_ADAPTER
282 	int adapter; //Screen for overlay. If -1 it won't be used.
283 #endif
284 
285 #if USE_COLORKEY
286 	unsigned int color_key;
287 #endif
288 
289 	bool use_mplayer_window;
290 
291 	QString monitor_aspect;
292 
293 	bool use_idx; //!< Use -idx
294 	bool use_lavf_demuxer;
295 
296 	// Let the user pass options to mplayer
297 	QString mplayer_additional_options;
298 	QString mplayer_additional_video_filters;
299 	QString mplayer_additional_audio_filters;
300 
301 	// Logs
302 #ifdef LOG_MPLAYER
303 	bool log_mplayer;
304 	bool verbose_log;
305 	bool autosave_mplayer_log;
306 	QString mplayer_log_saveto;
307 #endif
308 #ifdef LOG_SMPLAYER
309 	bool log_smplayer;
310 	QString log_filter;
311 	bool save_smplayer_log;
312 #endif
313 
314 #if REPAINT_BACKGROUND_OPTION
315 	//! If true, mplayerlayer erases its background
316 	bool repaint_video_background;
317 #endif
318 
319 	//! If true it will autoload edl files with the same name of the file
320     //! to play
321 	bool use_edl_files;
322 
323 #ifdef MPLAYER_SUPPORT
324 	//! If true it will pass to mplayer the -playlist option
325 	bool use_playlist_option;
326 #endif
327 
328 	//! Preferred connection method: ipv4 or ipv6
329 	bool prefer_ipv4;
330 
331 	//! Windows only. If true, smplayer will pass short filenames to mplayer.
332 	//! To workaround a bug in mplayer.
333 	bool use_short_pathnames;
334 
335 	//! If false, -brightness, -contrast and so on, won't be passed to
336 	//! mplayer. It seems that some graphic cards don't support those options.
337 	bool change_video_equalizer_on_startup;
338 
339 	//! If true, smplayer will use the prefix pausing_keep_force to keep
340 	//! the pause on slave commands. This experimental prefix was added
341 	//! in mplayer svn r27665.
342 	bool use_pausing_keep_force;
343 
344 	OptionState use_correct_pts; //!< Pass -correct-pts to mplayer
345 
346 	QString actions_to_run; //!< List of actions to run every time a video loads.
347 
348 	//! Show file tag in window title
349 	bool show_tag_in_window_title;
350 
351 	int time_to_kill_mplayer;
352 
353 #ifdef MPRIS2
354 	bool use_mpris2;
355 #endif
356 
357 #ifdef MPV_SUPPORT
358 	QString mpv_osd_media_info;
359 #endif
360 #ifdef MPLAYER_SUPPORT
361 	QString mplayer_osd_media_info;
362 #endif
363 
364 #ifdef MPV_SUPPORT
365 	bool emulate_mplayer_ab_section;
366 #endif
367 
368 	bool use_native_open_dialog;
369 
370 
371 	/* *********
372 	   GUI stuff
373 	   ********* */
374 
375 	bool fullscreen;
376 	bool start_in_fullscreen;
377 	bool compact_mode;
378 	OnTop stay_on_top;
379 	int size_factor;
380 
381 	int resize_method; 	//!< Mainwindow resize method
382 
383 #if STYLE_SWITCHING
384 	QString style; 	//!< SMPlayer look
385 #endif
386 
387 	bool center_window; //!< Center the main window when playback starts
388 	bool center_window_if_outside; //!< Center the main window after an autoresize if it's outside of the screen
389 
390 #ifdef GLOBALSHORTCUTS
391 	bool use_global_shortcuts;
392 	int global_shortcuts_grabbed_keys;
393 #endif
394 
395 	// Function of mouse buttons:
396 	QString mouse_left_click_function;
397 	QString mouse_right_click_function;
398 	QString mouse_double_click_function;
399 	QString mouse_middle_click_function;
400 	QString mouse_xbutton1_click_function;
401 	QString mouse_xbutton2_click_function;
402 	int wheel_function;
403 
404 	WheelFunctions wheel_function_cycle;
405 	bool wheel_function_seeking_reverse;
406 
407 	int drag_function;
408 
409 	// Configurable seeking
410 	int seeking1; // By default 10s
411 	int seeking2; // By default 1m
412 	int seeking3; // By default 10m
413 	int seeking4; // For mouse wheel, by default 30s
414 
415 	bool update_while_seeking;
416 #if ENABLE_DELAYED_DRAGGING
417 	int time_slider_drag_delay;
418 #endif
419 #if SEEKBAR_RESOLUTION
420 	//! If true, seeking will be done using a
421 	//! percentage (with fractions) instead of time.
422 	bool relative_seeking;
423 #endif
424 	bool precise_seeking; //! Enable precise_seeking (only available with mpv)
425 
426 	bool reset_stop; //! Pressing the stop button resets the position
427 
428 	//! If true, the left click in the video is delayed some ms
429 	//! to check if the user double clicked
430 	bool delay_left_click;
431 
432 	QString language;
433 	QString iconset;
434 
435 	//! Number of times to show the balloon remembering that the program
436 	//! is still running in the system tray.
437 	int balloon_count;
438 
439 	//! If true, the position of the main window will be saved before
440 	//! entering in fullscreen and will restore when going back to
441 	//! window mode.
442 	bool restore_pos_after_fullscreen;
443 
444 	bool save_window_size_on_exit;
445 
446 	//! Close the main window when a file or playlist finish
447 	bool close_on_finish;
448 
449 #ifdef AUTO_SHUTDOWN_PC
450 	bool auto_shutdown_pc;
451 #endif
452 
453 	QString default_font;
454 
455 	//!< Pause the current file when the main window is not visible
456 	bool pause_when_hidden;
457 
458 	//!< Allow frre movement of the video window
459 	bool allow_video_movement;
460 
461 	QString gui; //!< The name of the GUI to use
462 
463 #if USE_MINIMUMSIZE
464 	int gui_minimum_width;
465 #endif
466 	QSize default_size; // Default size of the main window
467 
468 #if ALLOW_TO_HIDE_VIDEO_WINDOW_ON_AUDIO_FILES
469 	bool hide_video_window_on_audio_files;
470 #endif
471 
472 	bool report_mplayer_crashes;
473 
474 #if REPORT_OLD_MPLAYER
475 	bool reported_mplayer_is_old;
476 #endif
477 
478 	bool auto_add_to_playlist; //!< Add files to open to playlist
479 	AutoAddToPlaylistFilter media_to_add_to_playlist;
480 
481 	// If false, the shortcuts from the main window won't work
482 	// in the playlist.
483 	// This option works only when the playlist use a docked widget
484 	// and the window is floating.
485 	bool use_player_shortcuts_in_playlist;
486 
487 	// If true, the playlist can be docked in the main window
488 	// otherwise it will be just a regular window.
489 	bool dockable_playlist;
490 
491 #if LOGO_ANIMATION
492 	bool animated_logo;
493 #endif
494 
495 
496     /* ********
497        TV (dvb)
498        ******** */
499 #ifdef TV_SUPPORT
500 	bool check_channels_conf_on_startup;
501 	int initial_tv_deinterlace;
502 	QString last_dvb_channel;
503 	QString last_tv_channel;
504 #endif
505 
506 
507     /* ********
508        Network
509        ******** */
510 
511 	// Streaming
512 	int streaming_type;
513 #ifdef MPV_SUPPORT
514 	QString ytdl_quality;
515 #endif
516 	#ifdef YOUTUBE_SUPPORT
517 	int yt_resolution;
518 	QString yt_user_agent;
519 	QString yt_ytdl_bin;
520 	QString yt_override_format;
521 	bool yt_use_dash;
522 	bool yt_use_60fps;
523 	bool yt_use_av1;
524 	#endif
525 
526 	// Proxy
527 	bool use_proxy;
528 	int proxy_type;
529 	QString proxy_host;
530 	int proxy_port;
531 	QString proxy_username;
532 	QString proxy_password;
533 
534 
535     /* ***********
536        Directories
537        *********** */
538 
539 	QString latest_dir; //!< Directory of the latest file loaded
540 	QString last_dvd_directory;
541 	bool save_dirs; // Save or not the latest dirs
542 
543     /* **************
544        Initial values
545        ************** */
546 
547 	double initial_sub_scale;
548 	double initial_sub_scale_ass;
549 	int initial_volume;
550 	int initial_contrast;
551 	int initial_brightness;
552 	int initial_hue;
553 	int initial_saturation;
554 	int initial_gamma;
555 
556 	AudioEqualizerList initial_audio_equalizer;
557 
558 	//! Default value for zoom (1.0 = no zoom)
559 	double initial_zoom_factor;
560 
561 	//! Default value for position of subtitles on screen
562 	//! 100 = 100% at the bottom
563 	int initial_sub_pos;
564 
565 #ifdef INITIAL_BLACKBORDERS
566 	bool initial_blackborders;
567 #endif
568 
569 	bool initial_postprocessing; //!< global postprocessing filter
570 	bool initial_volnorm;
571 
572 	int initial_deinterlace;
573 
574 	int initial_audio_channels;
575 	int initial_stereo_mode;
576 
577 #if SELECT_TRACKS_ON_STARTUP
578 	int initial_audio_track;
579 	int initial_subtitle_track;
580 #endif
581 
582 
583     /* ************
584        MPlayer info
585        ************ */
586 
587 	int mplayer_detected_version; 	//!< Latest version of mplayer parsed
588 
589 	//! Version of mplayer supplied by the user which will be used if
590 	//! the version can't be parsed from mplayer output
591 	int mplayer_user_supplied_version;
592 
593 #ifdef MPLAYER2_SUPPORT
594 	bool mplayer_is_mplayer2; //! True if the detected version is mplayer2
595 	QString mplayer2_detected_version;
596 #endif
597 
598 
599     /* *********
600        Instances
601        ********* */
602 #ifdef SINGLE_INSTANCE
603 	bool use_single_instance;
604 #endif
605 
606 
607     /* ****************
608        Floating control
609        **************** */
610 
611 	int floating_control_margin;
612 	int floating_control_width;
613 	bool floating_control_animated;
614 	bool floating_display_in_compact_mode;
615 	int floating_activation_area;
616 	int floating_hide_delay;
617 
618 
619     /* *******
620        History
621        ******* */
622 
623 	Recents * history_recents;
624 	URLHistory * history_urls;
625 
626 
627     /* *******
628        Filters
629        ******* */
630 	Filters * filters;
631 
632 
633     /* *********
634        SMPlayer info
635        ********* */
636 
637 #ifdef CHECK_UPGRADED
638 	QString smplayer_stable_version;
639 	bool check_if_upgraded;
640 #endif
641 #ifdef FONTCACHE_DIALOG
642 	QString smplayer_version;
643 #endif
644 
645 
646     /* *********
647        Update
648        ********* */
649 
650 #ifdef UPDATE_CHECKER
651 	UpdateCheckerData update_checker_data;
652 #endif
653 };
654 
655 Q_DECLARE_OPERATORS_FOR_FLAGS(Preferences::WheelFunctions)
656 
657 #endif
658