2013-07-03 21:34:21 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Simple x264 Launcher
|
2016-01-01 23:59:55 +01:00
|
|
|
// Copyright (C) 2004-2016 LoRd_MuldeR <MuldeR2@GMX.de>
|
2013-07-03 21:34:21 +02:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License along
|
|
|
|
// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
//
|
|
|
|
// http://www.gnu.org/licenses/gpl-2.0.txt
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "model_preferences.h"
|
|
|
|
|
|
|
|
#include "global.h"
|
|
|
|
|
|
|
|
#include <QSettings>
|
|
|
|
#include <QDesktopServices>
|
|
|
|
#include <QMouseEvent>
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
2014-02-14 00:01:00 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#define INIT_VALUE(NAME, VAL) do \
|
|
|
|
{ \
|
|
|
|
preferences->set##NAME(VAL); \
|
|
|
|
} \
|
|
|
|
while(0)
|
|
|
|
|
|
|
|
#define STORE_VALUE(NAME) do \
|
|
|
|
{ \
|
|
|
|
settings.setValue(#NAME, (preferences->get##NAME())); \
|
|
|
|
} \
|
|
|
|
while(0)
|
|
|
|
|
|
|
|
#define LOAD_VALUE_B(NAME) do \
|
|
|
|
{ \
|
|
|
|
preferences->set##NAME(settings.value(#NAME, QVariant(defaults.get##NAME())).toBool()); \
|
|
|
|
} \
|
|
|
|
while(0)
|
|
|
|
|
|
|
|
#define LOAD_VALUE_I(NAME) do \
|
|
|
|
{ \
|
|
|
|
preferences->set##NAME(settings.value(#NAME, QVariant(defaults.get##NAME())).toInt()); \
|
|
|
|
} \
|
|
|
|
while(0)
|
|
|
|
|
|
|
|
#define LOAD_VALUE_U(NAME) do \
|
|
|
|
{ \
|
|
|
|
preferences->set##NAME(settings.value(#NAME, QVariant(defaults.get##NAME())).toUInt()); \
|
|
|
|
} \
|
|
|
|
while(0)
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-07-03 21:34:21 +02:00
|
|
|
PreferencesModel::PreferencesModel(void)
|
|
|
|
{
|
|
|
|
initPreferences(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreferencesModel::initPreferences(PreferencesModel *preferences)
|
|
|
|
{
|
2014-02-14 00:01:00 +01:00
|
|
|
INIT_VALUE(AutoRunNextJob, true );
|
|
|
|
INIT_VALUE(MaxRunningJobCount, 1 );
|
|
|
|
INIT_VALUE(ShutdownComputer, false);
|
2015-02-28 17:12:35 +01:00
|
|
|
INIT_VALUE(Prefer64BitSource, false);
|
2014-02-14 00:01:00 +01:00
|
|
|
INIT_VALUE(SaveLogFiles, false);
|
|
|
|
INIT_VALUE(SaveToSourcePath, false);
|
|
|
|
INIT_VALUE(ProcessPriority, -1 );
|
|
|
|
INIT_VALUE(EnableSounds, false);
|
|
|
|
INIT_VALUE(DisableWarnings, false);
|
|
|
|
INIT_VALUE(NoUpdateReminder, false);
|
|
|
|
INIT_VALUE(AbortOnTimeout, true );
|
|
|
|
INIT_VALUE(SkipVersionTest, false);
|
2014-05-14 17:13:42 +02:00
|
|
|
INIT_VALUE(NoSystrayWarning, false);
|
2013-07-03 21:34:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void PreferencesModel::loadPreferences(PreferencesModel *preferences)
|
|
|
|
{
|
|
|
|
const QString appDir = x264_data_path();
|
2014-02-14 00:01:00 +01:00
|
|
|
PreferencesModel defaults;
|
2013-07-03 21:34:21 +02:00
|
|
|
QSettings settings(QString("%1/preferences.ini").arg(appDir), QSettings::IniFormat);
|
2014-02-14 00:01:00 +01:00
|
|
|
settings.beginGroup("preferences");
|
2013-07-03 21:34:21 +02:00
|
|
|
|
2014-02-14 00:01:00 +01:00
|
|
|
LOAD_VALUE_B(AutoRunNextJob );
|
|
|
|
LOAD_VALUE_U(MaxRunningJobCount);
|
|
|
|
LOAD_VALUE_B(ShutdownComputer );
|
2015-02-28 17:12:35 +01:00
|
|
|
LOAD_VALUE_B(Prefer64BitSource );
|
2014-02-14 00:01:00 +01:00
|
|
|
LOAD_VALUE_B(SaveLogFiles );
|
|
|
|
LOAD_VALUE_B(SaveToSourcePath );
|
|
|
|
LOAD_VALUE_I(ProcessPriority );
|
|
|
|
LOAD_VALUE_B(EnableSounds );
|
|
|
|
LOAD_VALUE_B(DisableWarnings );
|
|
|
|
LOAD_VALUE_B(NoUpdateReminder );
|
2014-05-14 17:13:42 +02:00
|
|
|
LOAD_VALUE_B(NoSystrayWarning );
|
2013-07-03 21:34:21 +02:00
|
|
|
|
2014-02-14 00:01:00 +01:00
|
|
|
//Validation
|
|
|
|
preferences->setProcessPriority(qBound(-2, preferences->getProcessPriority(), 2));
|
|
|
|
preferences->setMaxRunningJobCount(qBound(1U, preferences->getMaxRunningJobCount(), 16U));
|
2013-07-03 21:34:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void PreferencesModel::savePreferences(PreferencesModel *preferences)
|
|
|
|
{
|
|
|
|
const QString appDir = x264_data_path();
|
|
|
|
QSettings settings(QString("%1/preferences.ini").arg(appDir), QSettings::IniFormat);
|
|
|
|
settings.beginGroup("preferences");
|
2014-02-14 00:01:00 +01:00
|
|
|
|
|
|
|
STORE_VALUE(AutoRunNextJob );
|
|
|
|
STORE_VALUE(MaxRunningJobCount);
|
|
|
|
STORE_VALUE(ShutdownComputer );
|
2015-02-28 17:12:35 +01:00
|
|
|
STORE_VALUE(Prefer64BitSource );
|
2014-02-14 00:01:00 +01:00
|
|
|
STORE_VALUE(SaveLogFiles );
|
|
|
|
STORE_VALUE(SaveToSourcePath );
|
|
|
|
STORE_VALUE(ProcessPriority );
|
|
|
|
STORE_VALUE(EnableSounds );
|
|
|
|
STORE_VALUE(DisableWarnings );
|
|
|
|
STORE_VALUE(NoUpdateReminder );
|
2014-05-14 17:13:42 +02:00
|
|
|
STORE_VALUE(NoSystrayWarning );
|
2014-02-14 00:01:00 +01:00
|
|
|
|
2013-07-03 21:34:21 +02:00
|
|
|
settings.sync();
|
|
|
|
}
|