Refactored SysinfoModel and PreferencesModel. Also made those classes thread-safe!
This commit is contained in:
parent
c873bf8527
commit
6982596882
@ -74,5 +74,5 @@ QString ENC_BINARY(const SysinfoModel *sysinfo, const OptionsModel *options)
|
||||
|
||||
QString AVS_BINARY(const SysinfoModel *sysinfo, const PreferencesModel *preferences)
|
||||
{
|
||||
return QString("%1/toolset/%2/avs2yuv_%2.exe").arg(sysinfo->getAppPath(), preferences->useAvisyth64Bit() ? "x64": "x86");
|
||||
return QString("%1/toolset/%2/avs2yuv_%2.exe").arg(sysinfo->getAppPath(), preferences->getUseAvisyth64Bit() ? "x64": "x86");
|
||||
}
|
||||
|
@ -486,7 +486,7 @@ void JobListModel::updateStatus(const QUuid &jobId, JobStatus newStatus)
|
||||
m_status.insert(jobId, newStatus);
|
||||
emit dataChanged(createIndex(index, 0), createIndex(index, 1));
|
||||
|
||||
if(m_preferences->enableSounds())
|
||||
if(m_preferences->getEnableSounds())
|
||||
{
|
||||
switch(newStatus)
|
||||
{
|
||||
|
@ -23,13 +23,45 @@
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include <QSettings>
|
||||
#include <QDesktopServices>
|
||||
#include <QMouseEvent>
|
||||
#include <QMessageBox>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#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)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PreferencesModel::PreferencesModel(void)
|
||||
{
|
||||
initPreferences(this);
|
||||
@ -37,55 +69,60 @@ PreferencesModel::PreferencesModel(void)
|
||||
|
||||
void PreferencesModel::initPreferences(PreferencesModel *preferences)
|
||||
{
|
||||
memset(preferences, 0, sizeof(PreferencesModel));
|
||||
INIT_VALUE(AutoRunNextJob, true );
|
||||
INIT_VALUE(MaxRunningJobCount, 1 );
|
||||
INIT_VALUE(ShutdownComputer, false);
|
||||
INIT_VALUE(UseAvisyth64Bit, false);
|
||||
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);
|
||||
|
||||
preferences->m_autoRunNextJob = true;
|
||||
preferences->m_maxRunningJobCount = 1;
|
||||
preferences->m_shutdownComputer = false;
|
||||
preferences->m_useAvisyth64Bit = false;
|
||||
preferences->m_saveLogFiles = false;
|
||||
preferences->m_saveToSourcePath = false;
|
||||
preferences->m_processPriority = -1;
|
||||
preferences->m_enableSounds = false;
|
||||
preferences->m_disableWarnings = false;
|
||||
preferences->m_noUpdateReminder = false;
|
||||
}
|
||||
|
||||
void PreferencesModel::loadPreferences(PreferencesModel *preferences)
|
||||
{
|
||||
const QString appDir = x264_data_path();
|
||||
QSettings settings(QString("%1/preferences.ini").arg(appDir), QSettings::IniFormat);
|
||||
|
||||
PreferencesModel defaults;
|
||||
|
||||
QSettings settings(QString("%1/preferences.ini").arg(appDir), QSettings::IniFormat);
|
||||
settings.beginGroup("preferences");
|
||||
preferences->m_autoRunNextJob = settings.value("auto_run_next_job", QVariant(defaults.m_autoRunNextJob)).toBool();
|
||||
preferences->m_maxRunningJobCount = qBound(1U, settings.value("max_running_job_count", QVariant(defaults.m_maxRunningJobCount)).toUInt(), 16U);
|
||||
preferences->m_shutdownComputer = settings.value("shutdown_computer_on_completion", QVariant(defaults.m_shutdownComputer)).toBool();
|
||||
preferences->m_useAvisyth64Bit = settings.value("use_64bit_avisynth", QVariant(defaults.m_useAvisyth64Bit)).toBool();
|
||||
preferences->m_saveLogFiles = settings.value("save_log_files", QVariant(defaults.m_saveLogFiles)).toBool();
|
||||
preferences->m_saveToSourcePath = settings.value("save_to_source_path", QVariant(defaults.m_saveToSourcePath)).toBool();
|
||||
preferences->m_processPriority = settings.value("process_priority", QVariant(defaults.m_processPriority)).toInt();
|
||||
preferences->m_enableSounds = settings.value("enable_sounds", QVariant(defaults.m_enableSounds)).toBool();
|
||||
preferences->m_disableWarnings = settings.value("disable_warnings", QVariant(defaults.m_disableWarnings)).toBool();
|
||||
preferences->m_noUpdateReminder = settings.value("disable_update_reminder", QVariant(defaults.m_disableWarnings)).toBool();
|
||||
|
||||
LOAD_VALUE_B(AutoRunNextJob );
|
||||
LOAD_VALUE_U(MaxRunningJobCount);
|
||||
LOAD_VALUE_B(ShutdownComputer );
|
||||
LOAD_VALUE_B(UseAvisyth64Bit );
|
||||
LOAD_VALUE_B(SaveLogFiles );
|
||||
LOAD_VALUE_B(SaveToSourcePath );
|
||||
LOAD_VALUE_I(ProcessPriority );
|
||||
LOAD_VALUE_B(EnableSounds );
|
||||
LOAD_VALUE_B(DisableWarnings );
|
||||
LOAD_VALUE_B(NoUpdateReminder );
|
||||
|
||||
//Validation
|
||||
preferences->setProcessPriority(qBound(-2, preferences->getProcessPriority(), 2));
|
||||
preferences->setMaxRunningJobCount(qBound(1U, preferences->getMaxRunningJobCount(), 16U));
|
||||
}
|
||||
|
||||
void PreferencesModel::savePreferences(PreferencesModel *preferences)
|
||||
{
|
||||
const QString appDir = x264_data_path();
|
||||
QSettings settings(QString("%1/preferences.ini").arg(appDir), QSettings::IniFormat);
|
||||
|
||||
settings.beginGroup("preferences");
|
||||
settings.setValue("auto_run_next_job", preferences->m_autoRunNextJob);
|
||||
settings.setValue("shutdown_computer_on_completion", preferences->m_shutdownComputer);
|
||||
settings.setValue("max_running_job_count", preferences->m_maxRunningJobCount);
|
||||
settings.setValue("use_64bit_avisynth", preferences->m_useAvisyth64Bit);
|
||||
settings.setValue("save_log_files", preferences->m_saveLogFiles);
|
||||
settings.setValue("save_to_source_path", preferences->m_saveToSourcePath);
|
||||
settings.setValue("process_priority", preferences->m_processPriority);
|
||||
settings.setValue("enable_sounds", preferences->m_enableSounds);
|
||||
settings.setValue("disable_warnings", preferences->m_disableWarnings);
|
||||
settings.setValue("disable_update_reminder", preferences->m_noUpdateReminder);
|
||||
|
||||
STORE_VALUE(AutoRunNextJob );
|
||||
STORE_VALUE(MaxRunningJobCount);
|
||||
STORE_VALUE(ShutdownComputer );
|
||||
STORE_VALUE(UseAvisyth64Bit );
|
||||
STORE_VALUE(SaveLogFiles );
|
||||
STORE_VALUE(SaveToSourcePath );
|
||||
STORE_VALUE(ProcessPriority );
|
||||
STORE_VALUE(EnableSounds );
|
||||
STORE_VALUE(DisableWarnings );
|
||||
STORE_VALUE(NoUpdateReminder );
|
||||
|
||||
settings.sync();
|
||||
}
|
||||
|
@ -21,49 +21,62 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMutex>
|
||||
#include <QMutexLocker>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define PREFERENCES_MAKE_X(NAME, PREFIX, TYPE) \
|
||||
public: \
|
||||
inline TYPE get##NAME(void) const \
|
||||
{ \
|
||||
QMutexLocker lock(&m_mutex); \
|
||||
return m_##PREFIX##NAME; \
|
||||
} \
|
||||
inline void set##NAME(const TYPE PREFIX##NAME) \
|
||||
{ \
|
||||
QMutexLocker lock(&m_mutex); \
|
||||
m_##PREFIX##NAME = PREFIX##NAME; \
|
||||
} \
|
||||
protected: \
|
||||
TYPE m_##PREFIX##NAME;
|
||||
|
||||
#define PREFERENCES_MAKE_B(NAME) PREFERENCES_MAKE_X(NAME, b, bool)
|
||||
#define PREFERENCES_MAKE_I(NAME) PREFERENCES_MAKE_X(NAME, i, int)
|
||||
#define PREFERENCES_MAKE_U(NAME) PREFERENCES_MAKE_X(NAME, u, unsigned int)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class PreferencesModel
|
||||
{
|
||||
public:
|
||||
PreferencesModel(void);
|
||||
|
||||
//Getter
|
||||
bool autoRunNextJob(void) const { return m_autoRunNextJob; }
|
||||
unsigned int maxRunningJobCount(void) const { return m_maxRunningJobCount; }
|
||||
bool shutdownComputer(void) const { return m_shutdownComputer; }
|
||||
bool useAvisyth64Bit(void) const { return m_useAvisyth64Bit; }
|
||||
bool saveLogFiles(void) const { return m_saveLogFiles; }
|
||||
bool saveToSourcePath(void) const { return m_saveToSourcePath; }
|
||||
int processPriority(void) const { return m_processPriority; }
|
||||
bool enableSounds(void) const { return m_enableSounds; }
|
||||
bool disableWarnings(void) const { return m_disableWarnings; }
|
||||
bool noUpdateReminder(void) const { return m_noUpdateReminder; }
|
||||
PREFERENCES_MAKE_B(AutoRunNextJob)
|
||||
PREFERENCES_MAKE_U(MaxRunningJobCount)
|
||||
PREFERENCES_MAKE_B(ShutdownComputer)
|
||||
PREFERENCES_MAKE_B(UseAvisyth64Bit)
|
||||
PREFERENCES_MAKE_B(SaveLogFiles)
|
||||
PREFERENCES_MAKE_B(SaveToSourcePath)
|
||||
PREFERENCES_MAKE_I(ProcessPriority)
|
||||
PREFERENCES_MAKE_B(EnableSounds)
|
||||
PREFERENCES_MAKE_B(DisableWarnings)
|
||||
PREFERENCES_MAKE_B(NoUpdateReminder)
|
||||
PREFERENCES_MAKE_B(AbortOnTimeout)
|
||||
PREFERENCES_MAKE_B(SkipVersionTest)
|
||||
|
||||
//Setter
|
||||
void setAutoRunNextJob(const bool autoRunNextJob) { m_autoRunNextJob = autoRunNextJob; }
|
||||
void setMaxRunningJobCount(const unsigned int maxRunningJobCount) { m_maxRunningJobCount = maxRunningJobCount; }
|
||||
void setShutdownComputer(const bool shutdownComputer) { m_shutdownComputer = shutdownComputer; }
|
||||
void setUseAvisyth64Bit(const bool useAvisyth64Bit) { m_useAvisyth64Bit = useAvisyth64Bit; }
|
||||
void setSaveLogFiles(const bool saveLogFiles) { m_saveLogFiles = saveLogFiles; }
|
||||
void setSaveToSourcePath(const bool saveToSourcePath) { m_saveToSourcePath = saveToSourcePath; }
|
||||
void setProcessPriority(const int processPriority) { m_processPriority = processPriority; }
|
||||
void setEnableSounds(const bool enableSounds) { m_enableSounds = enableSounds; }
|
||||
void setDisableWarnings(const bool disableWarnings) { m_disableWarnings = disableWarnings; }
|
||||
void setNoUpdateReminder(const bool noUpdateReminder) { m_noUpdateReminder = noUpdateReminder; }
|
||||
|
||||
//Static
|
||||
public:
|
||||
static void initPreferences(PreferencesModel *preferences);
|
||||
static void loadPreferences(PreferencesModel *preferences);
|
||||
static void savePreferences(PreferencesModel *preferences);
|
||||
|
||||
protected:
|
||||
bool m_autoRunNextJob;
|
||||
unsigned int m_maxRunningJobCount;
|
||||
bool m_shutdownComputer;
|
||||
bool m_useAvisyth64Bit;
|
||||
bool m_saveLogFiles;
|
||||
bool m_saveToSourcePath;
|
||||
int m_processPriority;
|
||||
bool m_enableSounds;
|
||||
bool m_disableWarnings;
|
||||
bool m_noUpdateReminder;
|
||||
static QMutex m_mutex;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#undef PREFERENCES_MAKE_X
|
||||
#undef PREFERENCES_MAKE_B
|
||||
#undef PREFERENCES_MAKE_I
|
||||
#undef PREFERENCES_MAKE_U
|
||||
|
@ -20,25 +20,32 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMutex>
|
||||
#include <QMutexLocker>
|
||||
#include <QString>
|
||||
|
||||
#define SYSINFO_MAKE_FLAG(NAME) \
|
||||
inline void set##NAME##Support(const bool &enable) \
|
||||
{ \
|
||||
QMutexLocker lock(&m_mutex); \
|
||||
if(enable) setFlag(FLAG_HAS_##NAME); else clrFlag(FLAG_HAS_##NAME); \
|
||||
} \
|
||||
inline bool has##NAME##Support(void) const \
|
||||
{ \
|
||||
QMutexLocker lock(&m_mutex); \
|
||||
return ((m_flags & (FLAG_HAS_##NAME)) == FLAG_HAS_##NAME); \
|
||||
}
|
||||
|
||||
#define SYSINFO_MAKE_PATH(NAME) \
|
||||
inline void set##NAME##Path(const QString &path) \
|
||||
{ \
|
||||
QMutexLocker lock(&m_mutex); \
|
||||
m_path##NAME = path; \
|
||||
} \
|
||||
inline const QString & get##NAME##Path(void) const \
|
||||
{ \
|
||||
QMutexLocker lock(&m_mutex); \
|
||||
return m_path##NAME; \
|
||||
}
|
||||
|
||||
@ -65,10 +72,12 @@ protected:
|
||||
inline void setFlag(const unsigned int &flag) { m_flags = (m_flags | flag); }
|
||||
inline void clrFlag(const unsigned int &flag) { m_flags = (m_flags & (~flag)); }
|
||||
|
||||
unsigned int m_flags;
|
||||
|
||||
QString m_pathApp;
|
||||
QString m_pathVPS;
|
||||
|
||||
unsigned int m_flags;
|
||||
static QMutex m_mutex;
|
||||
};
|
||||
|
||||
#undef SYSINFO_MAKE_FLAG
|
||||
|
@ -24,7 +24,9 @@
|
||||
#include "global.h"
|
||||
#include "model_options.h"
|
||||
#include "model_preferences.h"
|
||||
#include "model_sysinfo.h"
|
||||
#include "job_object.h"
|
||||
#include "binaries.h"
|
||||
|
||||
#include <QDate>
|
||||
#include <QTime>
|
||||
@ -117,10 +119,6 @@ while(0)
|
||||
} \
|
||||
while(0)
|
||||
|
||||
#define AVS2_BINARY(BIN_DIR, IS_X64) (QString("%1/%2/avs2yuv_%2.exe").arg((BIN_DIR), ((IS_X64) ? "x64" : "x86")))
|
||||
#define X264_BINARY(BIN_DIR, IS_10BIT, IS_X64) (QString("%1/%2/x264_%3_%2.exe").arg((BIN_DIR), ((IS_X64) ? "x64" : "x86"), ((IS_10BIT) ? "10bit" : "8bit")))
|
||||
#define VPSP_BINARY(VPS_DIR) (QString("%1/vspipe.exe").arg((VPS_DIR)))
|
||||
|
||||
/*
|
||||
* Static vars
|
||||
*/
|
||||
@ -131,20 +129,14 @@ static const char *VPS_TEST_FILE = "import vapoursynth as vs\ncore = vs.get_core
|
||||
// Constructor & Destructor
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
EncodeThread::EncodeThread(const QString &sourceFileName, const QString &outputFileName, const OptionsModel *options, const QString &binDir, const QString &vpsDir, const bool &x264_x64, const bool &x264_10bit, const bool &avs2yuv_x64, const bool &skipVersionTest, const int &processPriroity, const bool &abortOnTimeout)
|
||||
EncodeThread::EncodeThread(const QString &sourceFileName, const QString &outputFileName, const OptionsModel *options, const SysinfoModel *const sysinfo, const PreferencesModel *const preferences)
|
||||
:
|
||||
m_jobId(QUuid::createUuid()),
|
||||
m_sourceFileName(sourceFileName),
|
||||
m_outputFileName(outputFileName),
|
||||
m_options(new OptionsModel(*options)),
|
||||
m_binDir(binDir),
|
||||
m_vpsDir(vpsDir),
|
||||
m_x264_x64(x264_x64),
|
||||
m_x264_10bit(x264_10bit),
|
||||
m_avs2yuv_x64(avs2yuv_x64),
|
||||
m_skipVersionTest(skipVersionTest),
|
||||
m_processPriority(qBound(-2, processPriroity, 1)),
|
||||
m_abortOnTimeout(abortOnTimeout),
|
||||
m_sysinfo(sysinfo),
|
||||
m_preferences(preferences),
|
||||
m_jobObject(new JobObject),
|
||||
m_semaphorePaused(0)
|
||||
{
|
||||
@ -238,9 +230,9 @@ void EncodeThread::encode(void)
|
||||
log(tr("Source file: %1").arg(QDir::toNativeSeparators(m_sourceFileName)));
|
||||
log(tr("Output file: %1").arg(QDir::toNativeSeparators(m_outputFileName)));
|
||||
|
||||
if(!m_vpsDir.isEmpty())
|
||||
if(!m_sysinfo->getVPSPath().isEmpty())
|
||||
{
|
||||
log(tr("\nVapourSynth: %1").arg(QDir::toNativeSeparators(m_vpsDir)));
|
||||
log(tr("\nVapourSynth: %1").arg(QDir::toNativeSeparators(m_sysinfo->getVPSPath())));
|
||||
}
|
||||
|
||||
//Print encoder settings
|
||||
@ -251,7 +243,7 @@ void EncodeThread::encode(void)
|
||||
log(tr("Profile: %1").arg(m_options->profile()));
|
||||
log(tr("Custom: %1").arg(m_options->customEncParams().isEmpty() ? tr("(None)") : m_options->customEncParams()));
|
||||
|
||||
log(m_binDir);
|
||||
log(m_sysinfo->getAppPath());
|
||||
|
||||
bool ok = false;
|
||||
unsigned int frames = 0;
|
||||
@ -264,7 +256,7 @@ void EncodeThread::encode(void)
|
||||
log(tr("\n--- CHECK VERSION ---\n"));
|
||||
unsigned int revision_x264 = UINT_MAX;
|
||||
bool x264_modified = false;
|
||||
ok = ((revision_x264 = checkVersionX264(m_x264_x64, m_x264_10bit, x264_modified)) != UINT_MAX);
|
||||
ok = ((revision_x264 = checkVersionX264(x264_modified)) != UINT_MAX);
|
||||
CHECK_STATUS(m_abort, ok);
|
||||
|
||||
//Checking avs2yuv version
|
||||
@ -725,7 +717,7 @@ QStringList EncodeThread::buildCommandLine(bool usePipe, bool use10Bit, unsigned
|
||||
return cmdLine;
|
||||
}
|
||||
|
||||
unsigned int EncodeThread::checkVersionX264(bool use_x64, bool use_10bit, bool &modified)
|
||||
unsigned int EncodeThread::checkVersionX264(bool &modified)
|
||||
{
|
||||
if(m_skipVersionTest)
|
||||
{
|
||||
@ -737,7 +729,7 @@ unsigned int EncodeThread::checkVersionX264(bool use_x64, bool use_10bit, bool &
|
||||
QStringList cmdLine = QStringList() << "--version";
|
||||
|
||||
log("Creating process:");
|
||||
if(!startProcess(process, X264_BINARY(m_binDir, use_10bit, use_x64), cmdLine))
|
||||
if(!startProcess(process, ENC_BINARY(m_sysinfo, m_options), cmdLine))
|
||||
{
|
||||
return false;;
|
||||
}
|
||||
|
@ -29,6 +29,8 @@
|
||||
#include <QStringList>
|
||||
#include <QSemaphore>
|
||||
|
||||
class SysinfoModel;
|
||||
class PreferencesModel;
|
||||
class OptionsModel;
|
||||
class QProcess;
|
||||
class JobObject;
|
||||
@ -38,7 +40,7 @@ class EncodeThread : public QThread
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
EncodeThread(const QString &sourceFileName, const QString &outputFileName, const OptionsModel *options, const QString &binDir, const QString &vpsDir, const bool &x264_x64, const bool &x264_10bit, const bool &avs2yuv_x64, const bool &skipVersionTest, const int &processPriroity, const bool &abortOnTimeout);
|
||||
EncodeThread(const QString &sourceFileName, const QString &outputFileName, const OptionsModel *options, const SysinfoModel *const sysinfo, const PreferencesModel *const m_preferences);
|
||||
~EncodeThread(void);
|
||||
|
||||
QUuid getId(void) { return this->m_jobId; };
|
||||
@ -68,19 +70,15 @@ protected:
|
||||
static const unsigned int m_processTimeoutMaxCounter = 120;
|
||||
static const unsigned int m_processTimeoutWarning = 24;
|
||||
|
||||
//Globals
|
||||
const SysinfoModel *const m_sysinfo;
|
||||
const PreferencesModel *const m_preferences;
|
||||
|
||||
//Constants
|
||||
const QUuid m_jobId;
|
||||
const QString m_sourceFileName;
|
||||
const QString m_outputFileName;
|
||||
const OptionsModel *m_options;
|
||||
const QString m_binDir;
|
||||
const QString m_vpsDir;
|
||||
const bool m_x264_x64;
|
||||
const bool m_x264_10bit;
|
||||
const bool m_avs2yuv_x64;
|
||||
const bool m_skipVersionTest;
|
||||
const int m_processPriority;
|
||||
const bool m_abortOnTimeout;
|
||||
|
||||
//Types
|
||||
enum inputType_t
|
||||
|
@ -26,7 +26,7 @@
|
||||
#define VER_X264_MAJOR 2
|
||||
#define VER_X264_MINOR 3
|
||||
#define VER_X264_PATCH 1
|
||||
#define VER_X264_BUILD 766
|
||||
#define VER_X264_BUILD 767
|
||||
|
||||
#define VER_X264_MINIMUM_REV 2380
|
||||
#define VER_X264_CURRENT_API 142
|
||||
|
@ -338,7 +338,7 @@ void AddJobDialog::showEvent(QShowEvent *event)
|
||||
|
||||
if((!ui->editSource->text().isEmpty()) && ui->editOutput->text().isEmpty())
|
||||
{
|
||||
QString outPath = generateOutputFileName(QDir::fromNativeSeparators(ui->editSource->text()), m_recentlyUsed->outputDirectory(), m_recentlyUsed->filterIndex(), m_preferences->saveToSourcePath());
|
||||
QString outPath = generateOutputFileName(QDir::fromNativeSeparators(ui->editSource->text()), m_recentlyUsed->outputDirectory(), m_recentlyUsed->filterIndex(), m_preferences->getSaveToSourcePath());
|
||||
ui->editOutput->setText(QDir::toNativeSeparators(outPath));
|
||||
ui->buttonAccept->setFocus();
|
||||
}
|
||||
@ -422,7 +422,7 @@ void AddJobDialog::dropEvent(QDropEvent *event)
|
||||
|
||||
if(!droppedFile.isEmpty())
|
||||
{
|
||||
const QString outFileName = generateOutputFileName(droppedFile, currentOutputPath(), currentOutputIndx(), m_preferences->saveToSourcePath());
|
||||
const QString outFileName = generateOutputFileName(droppedFile, currentOutputPath(), currentOutputIndx(), m_preferences->getSaveToSourcePath());
|
||||
ui->editSource->setText(QDir::toNativeSeparators(droppedFile));
|
||||
ui->editOutput->setText(QDir::toNativeSeparators(outFileName));
|
||||
}
|
||||
@ -534,7 +534,7 @@ void AddJobDialog::browseButtonClicked(void)
|
||||
QString filePath = QFileDialog::getOpenFileName(this, tr("Open Source File"), currentSourcePath(true), getInputFilterLst(), NULL, QFileDialog::DontUseNativeDialog);
|
||||
if(!(filePath.isNull() || filePath.isEmpty()))
|
||||
{
|
||||
QString destFile = generateOutputFileName(filePath, currentOutputPath(), currentOutputIndx(), m_preferences->saveToSourcePath());
|
||||
QString destFile = generateOutputFileName(filePath, currentOutputPath(), currentOutputIndx(), m_preferences->getSaveToSourcePath());
|
||||
ui->editSource->setText(QDir::toNativeSeparators(filePath));
|
||||
ui->editOutput->setText(QDir::toNativeSeparators(destFile));
|
||||
}
|
||||
|
@ -83,10 +83,7 @@ MainWindow::MainWindow(const x264_cpu_t *const cpuFeatures, IPC *ipc)
|
||||
m_pendingFiles(new QStringList()),
|
||||
m_preferences(NULL),
|
||||
m_recentlyUsed(NULL),
|
||||
m_skipVersionTest(false),
|
||||
m_abortOnTimeout(true),
|
||||
m_status(STATUS_PRE_INIT),
|
||||
m_firstShow(true),
|
||||
ui(new Ui::MainWindow())
|
||||
{
|
||||
//Init the dialog, from the .ui file
|
||||
@ -247,7 +244,7 @@ void MainWindow::addButtonPressed()
|
||||
m_status = STATUS_BLOCKED;
|
||||
|
||||
qDebug("MainWindow::addButtonPressed");
|
||||
bool runImmediately = (countRunningJobs() < (m_preferences->autoRunNextJob() ? m_preferences->maxRunningJobCount() : 1));
|
||||
bool runImmediately = (countRunningJobs() < (m_preferences->getAutoRunNextJob() ? m_preferences->getMaxRunningJobCount() : 1));
|
||||
QString sourceFileName, outputFileName;
|
||||
|
||||
if(createJob(sourceFileName, outputFileName, m_options, runImmediately))
|
||||
@ -276,7 +273,7 @@ void MainWindow::openActionTriggered()
|
||||
}
|
||||
else
|
||||
{
|
||||
bool runImmediately = (countRunningJobs() < (m_preferences->autoRunNextJob() ? m_preferences->maxRunningJobCount() : 1));
|
||||
bool runImmediately = (countRunningJobs() < (m_preferences->getAutoRunNextJob() ? m_preferences->getMaxRunningJobCount() : 1));
|
||||
QString sourceFileName(fileList.first()), outputFileName;
|
||||
if(createJob(sourceFileName, outputFileName, m_options, runImmediately))
|
||||
{
|
||||
@ -368,7 +365,7 @@ void MainWindow::restartButtonPressed(void)
|
||||
|
||||
if((options) && (!sourceFileName.isEmpty()) && (!outputFileName.isEmpty()))
|
||||
{
|
||||
bool runImmediately = (countRunningJobs() < (m_preferences->autoRunNextJob() ? m_preferences->maxRunningJobCount() : 1)); //bool runImmediately = true;
|
||||
bool runImmediately = (countRunningJobs() < (m_preferences->getAutoRunNextJob() ? m_preferences->getMaxRunningJobCount() : 1));
|
||||
OptionsModel *tempOptions = new OptionsModel(*options);
|
||||
if(createJob(sourceFileName, outputFileName, tempOptions, runImmediately, true))
|
||||
{
|
||||
@ -435,9 +432,9 @@ void MainWindow::jobChangedData(const QModelIndex &topLeft, const QModelIndex &
|
||||
}
|
||||
if((status == JobStatus_Completed) || (status == JobStatus_Failed))
|
||||
{
|
||||
if(m_preferences->autoRunNextJob()) QTimer::singleShot(0, this, SLOT(launchNextJob()));
|
||||
if(m_preferences->shutdownComputer()) QTimer::singleShot(0, this, SLOT(shutdownComputer()));
|
||||
if(m_preferences->saveLogFiles()) saveLogFile(m_jobList->index(i, 1, QModelIndex()));
|
||||
if(m_preferences->getAutoRunNextJob()) QTimer::singleShot(0, this, SLOT(launchNextJob()));
|
||||
if(m_preferences->getShutdownComputer()) QTimer::singleShot(0, this, SLOT(shutdownComputer()));
|
||||
if(m_preferences->getSaveLogFiles()) saveLogFile(m_jobList->index(i, 1, QModelIndex()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -618,7 +615,7 @@ void MainWindow::launchNextJob(void)
|
||||
|
||||
const int rows = m_jobList->rowCount(QModelIndex());
|
||||
|
||||
if(countRunningJobs() >= m_preferences->maxRunningJobCount())
|
||||
if(countRunningJobs() >= m_preferences->getMaxRunningJobCount())
|
||||
{
|
||||
qDebug("Still have too many jobs running, won't launch next one yet!");
|
||||
return;
|
||||
@ -847,14 +844,14 @@ void MainWindow::init(void)
|
||||
if(CLIParser::checkFlag(CLI_PARAM_SKIP_X264_CHECK, arguments))
|
||||
{
|
||||
qWarning("x264 version check disabled, you have been warned!\n");
|
||||
m_skipVersionTest = true;
|
||||
m_preferences->setSkipVersionTest(true);
|
||||
}
|
||||
|
||||
//Don't abort encoding process on timeout (not recommended!)
|
||||
if(CLIParser::checkFlag(CLI_PARAM_NO_DEADLOCK, arguments))
|
||||
{
|
||||
qWarning("Deadlock detection disabled, you have been warned!\n");
|
||||
m_abortOnTimeout = false;
|
||||
m_preferences->setAbortOnTimeout(false);
|
||||
}
|
||||
|
||||
//Check for Avisynth support
|
||||
@ -878,7 +875,7 @@ void MainWindow::init(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!m_preferences->disableWarnings())
|
||||
if(!m_preferences->getDisableWarnings())
|
||||
{
|
||||
QString text = tr("It appears that Avisynth is <b>not</b> currently installed on your computer.<br>Therefore Avisynth (.avs) input will <b>not</b> be working at all!").append("<br><br>");
|
||||
text += tr("Please download and install Avisynth:").append("<br>").append(LINK("http://sourceforge.net/projects/avisynth2/files/AviSynth%202.5/"));
|
||||
@ -911,7 +908,7 @@ void MainWindow::init(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!m_preferences->disableWarnings())
|
||||
if(!m_preferences->getDisableWarnings())
|
||||
{
|
||||
QString text = tr("It appears that VapourSynth is <b>not</b> currently installed on your computer.<br>Therefore VapourSynth (.vpy) input will <b>not</b> be working at all!").append("<br><br>");
|
||||
text += tr("Please download and install VapourSynth for Windows (R19 or later):").append("<br>").append(LINK("http://www.vapoursynth.com/")).append("<br><br>");
|
||||
@ -960,7 +957,7 @@ void MainWindow::init(void)
|
||||
if(!parseCommandLineArgs())
|
||||
{
|
||||
//Update reminder
|
||||
if((!m_preferences->noUpdateReminder()) && (m_recentlyUsed->lastUpdateCheck() + 14 < x264_current_date_safe().toJulianDay()))
|
||||
if((!m_preferences->getNoUpdateReminder()) && (m_recentlyUsed->lastUpdateCheck() + 14 < x264_current_date_safe().toJulianDay()))
|
||||
{
|
||||
if(QMessageBox::warning(this, tr("Update Notification"), QString("<nobr>%1</nobr>").arg(tr("Your last update check was more than 14 days ago. Check for updates now?")), tr("Check for Updates"), tr("Discard")) == 0)
|
||||
{
|
||||
@ -1064,7 +1061,7 @@ void MainWindow::handleCommand(const int &command, const QStringList &args, cons
|
||||
if(QFileInfo(args[0]).exists() && QFileInfo(args[0]).isFile())
|
||||
{
|
||||
OptionsModel options;
|
||||
bool runImmediately = (countRunningJobs() < (m_preferences->autoRunNextJob() ? m_preferences->maxRunningJobCount() : 1));
|
||||
bool runImmediately = (countRunningJobs() < (m_preferences->getAutoRunNextJob() ? m_preferences->getMaxRunningJobCount() : 1));
|
||||
if(!(args[2].isEmpty() || X264_STRCMP(args[2], "-")))
|
||||
{
|
||||
if(!OptionsModel::loadTemplate(&options, args[2].trimmed()))
|
||||
@ -1135,9 +1132,8 @@ void MainWindow::showEvent(QShowEvent *e)
|
||||
{
|
||||
QMainWindow::showEvent(e);
|
||||
|
||||
if(m_firstShow)
|
||||
if(m_status == STATUS_PRE_INIT)
|
||||
{
|
||||
m_firstShow = false;
|
||||
QTimer::singleShot(0, this, SLOT(init()));
|
||||
}
|
||||
}
|
||||
@ -1335,7 +1331,7 @@ bool MainWindow::createJobMultiple(const QStringList &filePathIn)
|
||||
//Add files individually
|
||||
for(iter = filePathIn.constBegin(); (iter != filePathIn.constEnd()) && (!applyToAll); iter++)
|
||||
{
|
||||
runImmediately = (countRunningJobs() < (m_preferences->autoRunNextJob() ? m_preferences->maxRunningJobCount() : 1));
|
||||
runImmediately = (countRunningJobs() < (m_preferences->getAutoRunNextJob() ? m_preferences->getMaxRunningJobCount() : 1));
|
||||
QString sourceFileName(*iter), outputFileName;
|
||||
if(createJob(sourceFileName, outputFileName, m_options, runImmediately, false, counter++, filePathIn.count(), &applyToAll))
|
||||
{
|
||||
@ -1350,9 +1346,9 @@ bool MainWindow::createJobMultiple(const QStringList &filePathIn)
|
||||
//Add remaining files
|
||||
while(applyToAll && (iter != filePathIn.constEnd()))
|
||||
{
|
||||
const bool runImmediatelyTmp = runImmediately && (countRunningJobs() < (m_preferences->autoRunNextJob() ? m_preferences->maxRunningJobCount() : 1));
|
||||
const bool runImmediatelyTmp = runImmediately && (countRunningJobs() < (m_preferences->getAutoRunNextJob() ? m_preferences->getMaxRunningJobCount() : 1));
|
||||
const QString sourceFileName = *iter;
|
||||
const QString outputFileName = AddJobDialog::generateOutputFileName(sourceFileName, m_recentlyUsed->outputDirectory(), m_recentlyUsed->filterIndex(), m_preferences->saveToSourcePath());
|
||||
const QString outputFileName = AddJobDialog::generateOutputFileName(sourceFileName, m_recentlyUsed->outputDirectory(), m_recentlyUsed->filterIndex(), m_preferences->getSaveToSourcePath());
|
||||
if(!appendJob(sourceFileName, outputFileName, m_options, runImmediatelyTmp))
|
||||
{
|
||||
return false;
|
||||
|
@ -71,10 +71,6 @@ protected:
|
||||
private:
|
||||
Ui::MainWindow *const ui;
|
||||
|
||||
bool m_firstShow;
|
||||
bool m_skipVersionTest;
|
||||
bool m_abortOnTimeout;
|
||||
|
||||
x264_status_t m_status;
|
||||
|
||||
QLabel *m_label;
|
||||
|
@ -96,18 +96,18 @@ void PreferencesDialog::showEvent(QShowEvent *event)
|
||||
{
|
||||
if(event) QDialog::showEvent(event);
|
||||
|
||||
UPDATE_CHECKBOX(ui->checkRunNextJob, m_preferences->autoRunNextJob());
|
||||
UPDATE_CHECKBOX(ui->checkShutdownComputer, m_preferences->shutdownComputer());
|
||||
UPDATE_CHECKBOX(ui->checkUse64BitAvs2YUV, m_preferences->useAvisyth64Bit() && m_sysinfo->hasX64Support());
|
||||
UPDATE_CHECKBOX(ui->checkSaveLogFiles, m_preferences->saveLogFiles());
|
||||
UPDATE_CHECKBOX(ui->checkSaveToSourceFolder, m_preferences->saveToSourcePath());
|
||||
UPDATE_CHECKBOX(ui->checkEnableSounds, m_preferences->enableSounds());
|
||||
UPDATE_CHECKBOX(ui->checkNoUpdateReminder, m_preferences->noUpdateReminder());
|
||||
UPDATE_CHECKBOX(ui->checkDisableWarnings, m_preferences->disableWarnings(), true);
|
||||
UPDATE_CHECKBOX(ui->checkRunNextJob, m_preferences->getAutoRunNextJob());
|
||||
UPDATE_CHECKBOX(ui->checkShutdownComputer, m_preferences->getShutdownComputer());
|
||||
UPDATE_CHECKBOX(ui->checkUse64BitAvs2YUV, m_preferences->getUseAvisyth64Bit() && m_sysinfo->hasX64Support());
|
||||
UPDATE_CHECKBOX(ui->checkSaveLogFiles, m_preferences->getSaveLogFiles());
|
||||
UPDATE_CHECKBOX(ui->checkSaveToSourceFolder, m_preferences->getSaveToSourcePath());
|
||||
UPDATE_CHECKBOX(ui->checkEnableSounds, m_preferences->getEnableSounds());
|
||||
UPDATE_CHECKBOX(ui->checkNoUpdateReminder, m_preferences->getNoUpdateReminder());
|
||||
UPDATE_CHECKBOX(ui->checkDisableWarnings, m_preferences->getDisableWarnings(), true);
|
||||
|
||||
ui->spinBoxJobCount->setValue(m_preferences->maxRunningJobCount());
|
||||
ui->spinBoxJobCount->setValue(m_preferences->getMaxRunningJobCount());
|
||||
|
||||
UPDATE_COMBOBOX(ui->comboBoxPriority, qBound(-2, m_preferences->processPriority(), 1), 0);
|
||||
UPDATE_COMBOBOX(ui->comboBoxPriority, qBound(-2, m_preferences->getProcessPriority(), 1), 0);
|
||||
|
||||
ui->checkUse64BitAvs2YUV->setEnabled(m_sysinfo->hasX64Support());
|
||||
ui->labelUse64BitAvs2YUV->setEnabled(m_sysinfo->hasX64Support());
|
||||
|
Loading…
Reference in New Issue
Block a user