| 1 | /* smplayer, GUI front-end for mplayer.
|
|---|
| 2 | Copyright (C) 2006-2016 Ricardo Villalba <[email protected]>
|
|---|
| 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 |
|
|---|
| 50 | using namespace Global;
|
|---|
| 51 |
|
|---|
| 52 | Preferences::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 |
|
|---|
| 64 | Preferences::~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 |
|
|---|
| 74 | void 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 |
|
|---|
|
|---|