1 ///////////////////////////////////////////////////////////////////////////////
2 // Simple x264 Launcher
3 // Copyright (C) 2004-2014 LoRd_MuldeR <MuldeR2@GMX.de>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
22 #include "model_preferences.h"
29 #include <QDesktopServices>
30 #include <QMouseEvent>
31 #include <QMessageBox>
33 PreferencesModel::PreferencesModel(void)
35 initPreferences(this);
38 void PreferencesModel::initPreferences(PreferencesModel *preferences)
40 memset(preferences, 0, sizeof(PreferencesModel));
42 preferences->m_autoRunNextJob = true;
43 preferences->m_maxRunningJobCount = 1;
44 preferences->m_shutdownComputer = false;
45 preferences->m_use10BitEncoding = false;
46 preferences->m_useAvisyth64Bit = false;
47 preferences->m_saveLogFiles = false;
48 preferences->m_saveToSourcePath = false;
49 preferences->m_processPriority = -1;
50 preferences->m_enableSounds = false;
51 preferences->m_disableWarnings = false;
52 preferences->m_noUpdateReminder = false;
55 void PreferencesModel::loadPreferences(PreferencesModel *preferences)
57 const QString appDir = x264_data_path();
58 QSettings settings(QString("%1/preferences.ini").arg(appDir), QSettings::IniFormat);
60 PreferencesModel defaults;
62 settings.beginGroup("preferences");
63 preferences->m_autoRunNextJob = settings.value("auto_run_next_job", QVariant(defaults.m_autoRunNextJob)).toBool();
64 preferences->m_maxRunningJobCount = qBound(1U, settings.value("max_running_job_count", QVariant(defaults.m_maxRunningJobCount)).toUInt(), 16U);
65 preferences->m_shutdownComputer = settings.value("shutdown_computer_on_completion", QVariant(defaults.m_shutdownComputer)).toBool();
66 preferences->m_use10BitEncoding = settings.value("use_10bit_encoding", QVariant(defaults.m_use10BitEncoding)).toBool();
67 preferences->m_useAvisyth64Bit = settings.value("use_64bit_avisynth", QVariant(defaults.m_useAvisyth64Bit)).toBool();
68 preferences->m_saveLogFiles = settings.value("save_log_files", QVariant(defaults.m_saveLogFiles)).toBool();
69 preferences->m_saveToSourcePath = settings.value("save_to_source_path", QVariant(defaults.m_saveToSourcePath)).toBool();
70 preferences->m_processPriority = settings.value("process_priority", QVariant(defaults.m_processPriority)).toInt();
71 preferences->m_enableSounds = settings.value("enable_sounds", QVariant(defaults.m_enableSounds)).toBool();
72 preferences->m_disableWarnings = settings.value("disable_warnings", QVariant(defaults.m_disableWarnings)).toBool();
73 preferences->m_noUpdateReminder = settings.value("disable_update_reminder", QVariant(defaults.m_disableWarnings)).toBool();
76 void PreferencesModel::savePreferences(PreferencesModel *preferences)
78 const QString appDir = x264_data_path();
79 QSettings settings(QString("%1/preferences.ini").arg(appDir), QSettings::IniFormat);
81 settings.beginGroup("preferences");
82 settings.setValue("auto_run_next_job", preferences->m_autoRunNextJob);
83 settings.setValue("shutdown_computer_on_completion", preferences->m_shutdownComputer);
84 settings.setValue("max_running_job_count", preferences->m_maxRunningJobCount);
85 settings.setValue("use_10bit_encoding", preferences->m_use10BitEncoding);
86 settings.setValue("use_64bit_avisynth", preferences->m_useAvisyth64Bit);
87 settings.setValue("save_log_files", preferences->m_saveLogFiles);
88 settings.setValue("save_to_source_path", preferences->m_saveToSourcePath);
89 settings.setValue("process_priority", preferences->m_processPriority);
90 settings.setValue("enable_sounds", preferences->m_enableSounds);
91 settings.setValue("disable_warnings", preferences->m_disableWarnings);
92 settings.setValue("disable_update_reminder", preferences->m_noUpdateReminder);