Removed a lot of old cruft and use MUtils functions where possible.

This commit is contained in:
LoRd_MuldeR 2015-02-02 22:11:06 +01:00
parent 24e2b93d68
commit e669acfd39
25 changed files with 185 additions and 2146 deletions

View File

@ -61,5 +61,11 @@
<file>images/update_wizard.png</file>
<file>images/x264.png</file>
<file>images/x265.png</file>
<file>sounds/shutdown.wav</file>
<file>sounds/beep.wav</file>
<file>sounds/beep2.wav</file>
<file>sounds/tada.wav</file>
<file>sounds/shattering.wav</file>
<file>sounds/failure.wav</file>
</qresource>
</RCC>

View File

@ -21,11 +21,15 @@
#include "binaries.h"
//Internal
#include "global.h"
#include "model_sysinfo.h"
#include "model_preferences.h"
#include "model_options.h"
//MUtils
#include <MUtils/Exception.h>
/* --- Encooders --- */
QString ENC_BINARY(const SysinfoModel *sysinfo, const OptionsModel::EncType &encType, const OptionsModel::EncArch &encArch, const OptionsModel::EncVariant &encVariant)
@ -68,7 +72,7 @@ QString ENC_BINARY(const SysinfoModel *sysinfo, const OptionsModel::EncType &enc
//Sanity check
if(baseName.isEmpty() || arch.isEmpty() || variant.isEmpty())
{
THROW("Failed to determine the encoder binarty path!");
MUTILS_THROW("Failed to determine the encoder binarty path!");
}
//Return path

View File

@ -21,6 +21,7 @@
#include "encoder_abstract.h"
//Internal
#include "global.h"
#include "model_options.h"
#include "model_preferences.h"
@ -29,6 +30,11 @@
#include "source_abstract.h"
#include "binaries.h"
//MUtils
#include <MUtils/Global.h>
#include <MUtils/Exception.h>
//Qt
#include <QProcess>
#include <QDir>
#include <QTextCodec>
@ -206,7 +212,7 @@ bool AbstractEncoder::runEncodingPass(AbstractSource* pipedSource, const QString
while(!patterns.isEmpty())
{
QRegExp *pattern = patterns.takeFirst();
X264_DELETE(pattern);
MUTILS_DELETE(pattern);
}
if(bTimeout || bAborted || processEncode.exitCode() != EXIT_SUCCESS)
@ -335,5 +341,5 @@ QString AbstractEncoder::sizeToString(qint64 size)
const AbstractEncoderInfo& AbstractEncoder::getEncoderInfo(void)
{
THROW("[getEncoderInfo] This function must be overwritten in sub-classes!");
MUTILS_THROW("[getEncoderInfo] This function must be overwritten in sub-classes!");
}

View File

@ -21,11 +21,15 @@
#include "encoder_factory.h"
//Internal
#include "global.h"
#include "model_options.h"
#include "encoder_x264.h"
#include "encoder_x265.h"
//MUtils
#include <MUtils/Exception.h>
AbstractEncoder *EncoderFactory::createEncoder(JobObject *jobObject, const OptionsModel *options, const SysinfoModel *const sysinfo, const PreferencesModel *const preferences, JobStatus &jobStatus, volatile bool *abort, volatile bool *pause, QSemaphore *semaphorePause, const QString &sourceFile, const QString &outputFile)
{
AbstractEncoder *encoder = NULL;
@ -39,7 +43,7 @@ AbstractEncoder *EncoderFactory::createEncoder(JobObject *jobObject, const Optio
encoder = new X265Encoder(jobObject, options, sysinfo, preferences, jobStatus, abort, pause, semaphorePause, sourceFile, outputFile);
break;
default:
THROW("Unknown encoder type encountered!");
MUTILS_THROW("Unknown encoder type encountered!");
}
return encoder;
@ -54,7 +58,7 @@ const AbstractEncoderInfo& EncoderFactory::getEncoderInfo(const int &encoderType
case OptionsModel::EncType_X265:
return X265Encoder::getEncoderInfo();
default:
THROW("Unknown encoder type encountered!");
MUTILS_THROW("Unknown encoder type encountered!");
}
return *((AbstractEncoderInfo*)NULL);

View File

@ -21,12 +21,17 @@
#include "encoder_x264.h"
//Internal
#include "global.h"
#include "model_options.h"
#include "model_status.h"
#include "binaries.h"
#include "mediainfo.h"
//MUtils
#include <MUtils/Exception.h>
//Qt
#include <QStringList>
#include <QDir>
#include <QRegExp>
@ -185,7 +190,7 @@ X264Encoder::X264Encoder(JobObject *jobObject, const OptionsModel *options, cons
{
if(options->encType() != OptionsModel::EncType_X264)
{
THROW("Invalid encoder type!");
MUTILS_THROW("Invalid encoder type!");
}
}
@ -300,7 +305,7 @@ void X264Encoder::buildCommandLine(QStringList &cmdLine, const bool &usePipe, co
cmdLine << "--bitrate" << QString::number(m_options->bitrate());
break;
default:
THROW("Bad rate-control mode !!!");
MUTILS_THROW("Bad rate-control mode !!!");
}
if((pass == 1) || (pass == 2))
@ -348,7 +353,7 @@ void X264Encoder::buildCommandLine(QStringList &cmdLine, const bool &usePipe, co
if(usePipe)
{
if(frames < 1) THROW("Frames not set!");
if(frames < 1) MUTILS_THROW("Frames not set!");
cmdLine << "--frames" << QString::number(frames);
cmdLine << "--demuxer" << "y4m";
cmdLine << "--stdin" << "y4m" << "-";

View File

@ -21,12 +21,17 @@
#include "encoder_x265.h"
//Internal
#include "global.h"
#include "model_options.h"
#include "model_status.h"
#include "binaries.h"
#include "mediainfo.h"
//MUtils
#include <MUtils/Exception.h>
//Qt
#include <QStringList>
#include <QDir>
#include <QRegExp>
@ -168,7 +173,7 @@ X265Encoder::X265Encoder(JobObject *jobObject, const OptionsModel *options, cons
{
if(options->encType() != OptionsModel::EncType_X265)
{
THROW("Invalid encoder type!");
MUTILS_THROW("Invalid encoder type!");
}
}
@ -278,7 +283,7 @@ void X265Encoder::buildCommandLine(QStringList &cmdLine, const bool &usePipe, co
cmdLine << "--bitrate" << QString::number(m_options->bitrate());
break;
default:
THROW("Bad rate-control mode !!!");
MUTILS_THROW("Bad rate-control mode !!!");
break;
}
@ -327,7 +332,7 @@ void X265Encoder::buildCommandLine(QStringList &cmdLine, const bool &usePipe, co
if(usePipe)
{
if(frames < 1) THROW("Frames not set!");
if(frames < 1) MUTILS_THROW("Frames not set!");
cmdLine << "--frames" << QString::number(frames);
cmdLine << "--y4m" << "-";
}

File diff suppressed because it is too large Load Diff

View File

@ -34,144 +34,18 @@ class QIcon;
class QWidget;
class LockedFile;
class QProcess;
enum QtMsgType;
///////////////////////////////////////////////////////////////////////////////
// TYPE DEFINITIONS
///////////////////////////////////////////////////////////////////////////////
//Types definitions
/*
typedef struct
{
int family;
int model;
int stepping;
int count;
bool x64;
bool mmx;
bool mmx2;
bool sse;
bool sse2;
bool sse3;
bool ssse3;
char vendor[0x40];
char brand[0x40];
bool intel;
}
x264_cpu_t;
*/
//OS version number
typedef struct _x264_os_version_t
{
unsigned int versionMajor;
unsigned int versionMinor;
bool overrideFlag;
//comparision operators
inline bool operator== (const _x264_os_version_t &rhs) const { return (versionMajor == rhs.versionMajor) && (versionMinor == rhs.versionMinor); }
inline bool operator!= (const _x264_os_version_t &rhs) const { return (versionMajor != rhs.versionMajor) || (versionMinor != rhs.versionMinor); }
inline bool operator> (const _x264_os_version_t &rhs) const { return (versionMajor > rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor > rhs.versionMinor)); }
inline bool operator>= (const _x264_os_version_t &rhs) const { return (versionMajor > rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor >= rhs.versionMinor)); }
inline bool operator< (const _x264_os_version_t &rhs) const { return (versionMajor < rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor < rhs.versionMinor)); }
inline bool operator<= (const _x264_os_version_t &rhs) const { return (versionMajor < rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor <= rhs.versionMinor)); }
}
x264_os_version_t;
//Beep types
typedef enum
{
x264_beep_info = 0,
x264_beep_warning = 1,
x264_beep_error = 2
}
x264_beep_t;
//Known folders
typedef enum
{
x264_folder_localappdata = 0,
x264_folder_programfiles = 2,
x264_folder_systemfolder = 3,
x264_folder_systroot_dir = 4
}
x264_known_folder_t;
//Network connection types
typedef enum
{
x264_network_err = 0, /*unknown*/
x264_network_non = 1, /*not connected*/
x264_network_yes = 2 /*connected*/
}
x264_network_t;
//Known Windows versions
extern const x264_os_version_t x264_winver_error; //N/A
extern const x264_os_version_t x264_winver_win2k; //2000
extern const x264_os_version_t x264_winver_winxp; //XP
extern const x264_os_version_t x264_winver_xpx64; //XP_x64
extern const x264_os_version_t x264_winver_vista; //Vista
extern const x264_os_version_t x264_winver_win70; //7
extern const x264_os_version_t x264_winver_win80; //8
extern const x264_os_version_t x264_winver_win81; //8.1
extern const x264_os_version_t x264_winver_wn100; //10
//Exception class
class X264Exception : public std::runtime_error
{
public:
X264Exception(const char *message, ...);
virtual const char* what() const { return m_message; }
private:
static const size_t MAX_MSGLEN = 256;
char m_message[MAX_MSGLEN];
};
///////////////////////////////////////////////////////////////////////////////
// GLOBAL FUNCTIONS
///////////////////////////////////////////////////////////////////////////////
//const QStringList &x264_arguments(void);
bool x264_beep(int beepType);
void x264_blink_window(QWidget *poWindow, unsigned int count, unsigned int delay);
bool x264_bring_process_to_front(const unsigned long pid);
bool x264_bring_to_front(const QWidget *win);
bool x264_change_process_priority(const QProcess *proc, const int priority);
bool x264_change_process_priority(const int priority);
bool x264_change_process_priority(void *hProcess, const int priority);
QDate x264_current_date_safe(void);
const QString &x264_data_path(void);
void x264_dbg_output_string(const char* format, ...);
size_t x264_dbg_private_bytes(void);
//x264_cpu_t x264_detect_cpu_features(const int argc, char **argv);
bool x264_enable_close_button(const QWidget *win, const bool bEnable);
void x264_fatal_exit(const wchar_t* exitMessage, const char* errorBoxMessage = NULL);
void x264_finalization(void);
void x264_init_console(const int argc, char **argv);
void x264_init_process(QProcess &process, const QString &wokringDir, const bool bReplaceTempDir = true);
//bool x264_init_qt(int &argc, char **argv);
bool x264_is_executable(const QString &path);
bool x264_is_prerelease(void);
const QString &x264_known_folder(x264_known_folder_t folder_id);
void x264_message_handler(QtMsgType type, const char *msg);
int x264_network_status(void);
QString x264_path2ansi(const QString &longPath, bool makeLowercase = false);
bool x264_play_sound(const unsigned short uiSoundIdx, const bool bAsync, const wchar_t *alias = NULL);
bool x264_portable(void);
unsigned int x264_process_id(void);
unsigned int x264_process_id(QProcess &process);
QString x264_query_reg_string(const bool bUser, const QString &path, const QString &name);
unsigned int x264_rand(void);
QString x264_rand_str(const bool bLong = false);
void x264_seed_rand(void);
bool x264_set_thread_execution_state(const bool systemRequired);
bool x264_shutdown_computer(const QString &message, const unsigned long timeout, const bool forceShutdown);
void x264_sleep(const unsigned int delay);
bool x264_suspendProcess(const QProcess *proc, const bool suspend);
const QString &x264_temp_directory(void);
bool x264_user_is_admin(void);
const char *x264_version_arch(void);
unsigned int x264_version_build(void);
const char *x264_version_compiler(void);
@ -184,54 +58,9 @@ const char *x264_version_time(void);
// HELPER MACROS
///////////////////////////////////////////////////////////////////////////////
#define QWCHAR(STR) reinterpret_cast<const wchar_t*>(STR.utf16())
#define QUTF8(STR) ((STR).toUtf8().constData())
#define WCHAR2QSTR(STR) (QString::fromUtf16(reinterpret_cast<const unsigned short*>((STR))))
#define X264_BOOL(X) ((X) ? "1" : "0")
#define X264_DELETE(PTR) if(PTR) { delete PTR; PTR = NULL; }
#define X264_DELETE_ARRAY(PTR) if(PTR) { delete [] PTR; PTR = NULL; }
#define _X264_MAKE_STRING_(X) #X
#define X264_MAKE_STRING(X) _X264_MAKE_STRING_(X)
#define X264_COMPILER_WARNING(TXT) __pragma(message(__FILE__ "(" X264_MAKE_STRING(__LINE__) ") : warning: " TXT))
#define X264_STRCMP(X,Y) ((X).compare((Y), Qt::CaseInsensitive) == 0)
//Debug build
#if defined(_DEBUG) && defined(QT_DEBUG) && !defined(NDEBUG) && !defined(QT_NO_DEBUG)
#define X264_DEBUG (1)
#else
#define X264_DEBUG (0)
#endif
//Check for CPU-compatibility options
#if !defined(_M_X64) && defined(_MSC_VER) && defined(_M_IX86_FP)
#if (_M_IX86_FP != 0)
#error We should not enabled SSE or SSE2 in release builds!
#endif
#endif
//Helper macro for throwing exceptions
#define THROW(MESSAGE, ...) do \
{ \
throw X264Exception((MESSAGE), __VA_ARGS__); \
} \
while(0)
//Memory check
#if X264_DEBUG
#define X264_MEMORY_CHECK(FUNC, RETV, ...) do \
{ \
size_t _privateBytesBefore = x264_dbg_private_bytes(); \
RETV = FUNC(__VA_ARGS__); \
size_t _privateBytesLeak = (x264_dbg_private_bytes() - _privateBytesBefore) / 1024; \
if(_privateBytesLeak > 0) { \
x264_dbg_output_string("\nMemory leak: Lost %u KiloBytes of PrivateUsage memory!\n\n", _privateBytesLeak); \
} \
} \
while(0)
#else
#define X264_MEMORY_CHECK(FUNC, RETV, ...) do \
{ \
RETV = __noop(__VA_ARGS__); \
} \
while(0)
#endif

View File

@ -21,8 +21,13 @@
#include "input_filter.h"
//Internal
#include "global.h"
//MUTils
#include <MUtils/Global.h>
//Qt
#include <QWidget>
#include <QKeyEvent>
#include <QMouseEvent>
@ -40,8 +45,8 @@ InputEventFilter::InputEventFilter(QWidget *target)
InputEventFilter::~InputEventFilter(void)
{
m_target->removeEventFilter(this);
X264_DELETE(m_keyMapping);
X264_DELETE(m_mouseMapping);
MUTILS_DELETE(m_keyMapping);
MUTILS_DELETE(m_mouseMapping);
}
void InputEventFilter::addKeyFilter(const int &keyCode, const int &tag)

View File

@ -64,7 +64,7 @@ static void x264_print_logo(void)
qDebug("This application is powerd by MUtils library v%u.%02u (%s, %s).\n", MUtils::Version::lib_version_major(), MUtils::Version::lib_version_minor(), MUTILS_UTF8(MUtils::Version::lib_build_date().toString(Qt::ISODate)), MUTILS_UTF8(MUtils::Version::lib_build_time().toString(Qt::ISODate)));
//Print warning, if this is a "debug" build
if(X264_DEBUG)
if(MUTILS_DEBUG)
{
qWarning("---------------------------------------------------------");
qWarning("DEBUG BUILD: DO NOT RELEASE THIS BINARY TO THE PUBLIC !!!");

View File

@ -19,6 +19,7 @@
// http://www.gnu.org/licenses/gpl-2.0.txt
///////////////////////////////////////////////////////////////////////////////
//Internal
#include "global.h"
#include "model_jobList.h"
#include "thread_encode.h"
@ -26,6 +27,10 @@
#include "model_preferences.h"
#include "resource.h"
//MUtils
#include <MUtils/Sound.h>
//Qt
#include <QIcon>
#include <QFileInfo>
#include <QSettings>
@ -51,8 +56,8 @@ JobListModel::~JobListModel(void)
QUuid id = m_jobs.takeFirst();
EncodeThread *thread = m_threads.value(id, NULL);
LogFileModel *logFile = m_logFile.value(id, NULL);
X264_DELETE(thread);
X264_DELETE(logFile);
MUTILS_DELETE(thread);
MUTILS_DELETE(logFile);
}
}
@ -404,8 +409,8 @@ bool JobListModel::deleteJob(const QModelIndex &index)
m_logFile.remove(id);
m_details.remove(id);
endRemoveRows();
X264_DELETE(thread);
X264_DELETE(logFile);
MUTILS_DELETE(thread);
MUTILS_DELETE(logFile);
return true;
}
}
@ -534,13 +539,13 @@ void JobListModel::updateStatus(const QUuid &jobId, JobStatus newStatus)
switch(newStatus)
{
case JobStatus_Completed:
x264_play_sound(IDR_WAVE4, true);
MUtils::Sound::play_sound("tada", true);
break;
case JobStatus_Aborted:
x264_play_sound(IDR_WAVE5, true);
MUtils::Sound::play_sound("shattering", true);
break;
case JobStatus_Failed:
x264_play_sound(IDR_WAVE6, true);
MUtils::Sound::play_sound("failure", true);
break;
}
}

View File

@ -21,9 +21,14 @@
#include "model_options.h"
//Internal
#include "global.h"
#include "model_sysinfo.h"
//Mutils
#include <MUtils/Global.h>
//Qt
#include <QDesktopServices>
#include <QSettings>
#include <QStringList>
@ -181,7 +186,7 @@ QMap<QString, OptionsModel*> OptionsModel::loadAllTemplates(const SysinfoModel *
list.insert(name, options);
continue;
}
X264_DELETE(options);
MUTILS_DELETE(options);
}
}

View File

@ -21,11 +21,16 @@
#include "source_abstract.h"
//Internal
#include "global.h"
#include "model_sysinfo.h"
#include "model_options.h"
#include "model_preferences.h"
//MUtils
#include <MUtils/Global.h>
//Qt
#include <QProcess>
#include <QTextCodec>
#include <QDir>
@ -131,7 +136,7 @@ bool AbstractSource::checkSourceProperties(unsigned int &frames)
while(!patterns.isEmpty())
{
QRegExp *pattern = patterns.takeFirst();
X264_DELETE(pattern);
MUTILS_DELETE(pattern);
}
if(bTimeout || bAborted || process.exitCode() != EXIT_SUCCESS)

View File

@ -21,16 +21,23 @@
#include "taskbar7.h"
//Mutils
#include <MUtils/Exception.h>
//Qt
#include <QWidget>
#include <QIcon>
//Win32
#include <ShObjIdl.h>
static UINT s_winMsg = 0;
static ITaskbarList3 *s_ptbl = NULL;
WinSevenTaskbar::WinSevenTaskbar(void)
{
THROW("Cannot create instance of this class!");
MUTILS_THROW("Cannot create instance of this class!");
}
WinSevenTaskbar::~WinSevenTaskbar(void)

View File

@ -27,9 +27,13 @@
#include <QMutexLocker>
#include <QApplication>
//Internal
#include "global.h"
#include "3rd_party/avisynth_c.h"
//MUtils
#include <MUtils/Global.h>
QMutex AvisynthCheckThread::m_avsLock;
QLibrary *AvisynthCheckThread::m_avsLib = NULL;
@ -96,7 +100,7 @@ void AvisynthCheckThread::unload(void)
}
}
X264_DELETE(m_avsLib);
MUTILS_DELETE(m_avsLib);
}
//-------------------------------------

View File

@ -37,6 +37,9 @@
#include "source_avisynth.h"
#include "source_vapoursynth.h"
//MUtils
#include <MUtils/OSSupport.h>
//Qt Framework
#include <QDate>
#include <QTime>
@ -153,10 +156,10 @@ EncodeThread::EncodeThread(const QString &sourceFileName, const QString &outputF
EncodeThread::~EncodeThread(void)
{
X264_DELETE(m_encoder);
X264_DELETE(m_jobObject);
X264_DELETE(m_options);
X264_DELETE(m_pipedSource);
MUTILS_DELETE(m_encoder);
MUTILS_DELETE(m_jobObject);
MUTILS_DELETE(m_options);
MUTILS_DELETE(m_pipedSource);
}
///////////////////////////////////////////////////////////////////////////////
@ -181,7 +184,7 @@ void EncodeThread::run(void)
if(m_jobObject)
{
m_jobObject->terminateJob(42);
X264_DELETE(m_jobObject);
MUTILS_DELETE(m_jobObject);
}
}
@ -215,7 +218,7 @@ void EncodeThread::checkedRun(void)
}
catch(...)
{
x264_fatal_exit(L"Unhandeled exception error in encode thread!");
MUtils::OS::fatal_exit(L"Unhandeled exception error in encode thread!");
}
}

View File

@ -21,6 +21,10 @@
#include "thread_vapoursynth.h"
//Mutils
#include <MUtils/OSSupport.h>
//Qt
#include <QLibrary>
#include <QEventLoop>
#include <QTimer>
@ -130,9 +134,9 @@ void VapourSynthCheckThread::unload(void)
}
}
X264_DELETE(m_vpsExePath);
X264_DELETE(m_vpsDllPath);
X264_DELETE(m_vpsLib);
MUTILS_DELETE(m_vpsExePath);
MUTILS_DELETE(m_vpsDllPath);
MUTILS_DELETE(m_vpsLib);
}
//-------------------------------------
@ -187,8 +191,8 @@ bool VapourSynthCheckThread::detectVapourSynthPath2(QString &path, volatile bool
bool VapourSynthCheckThread::detectVapourSynthPath3(QString &path)
{
bool success = false;
X264_DELETE(m_vpsExePath);
X264_DELETE(m_vpsDllPath);
MUTILS_DELETE(m_vpsExePath);
MUTILS_DELETE(m_vpsDllPath);
path.clear();
static const char *VPS_REG_KEYS[] =
@ -242,14 +246,14 @@ bool VapourSynthCheckThread::detectVapourSynthPath3(QString &path)
m_vpsDllPath = new QFile(vpsDllInfo.canonicalFilePath());
if(m_vpsExePath->open(QIODevice::ReadOnly) && m_vpsDllPath->open(QIODevice::ReadOnly))
{
if(vapoursynthComplete = x264_is_executable(m_vpsExePath->fileName()))
if(vapoursynthComplete = MUtils::OS::is_executable_file(m_vpsExePath->fileName()))
{
vapoursynthPath.append("/").append(CORE_PATH[i]);
}
break;
}
X264_DELETE(m_vpsExePath);
X264_DELETE(m_vpsDllPath);
MUTILS_DELETE(m_vpsExePath);
MUTILS_DELETE(m_vpsDllPath);
}
}
if(!vapoursynthComplete)

View File

@ -21,6 +21,7 @@
#include "tool_abstract.h"
//Internal
#include "global.h"
#include "model_options.h"
#include "model_preferences.h"
@ -28,6 +29,10 @@
#include "binaries.h"
#include "job_object.h"
//MUtils
#include <MUtils/OSSupport.h>
//Qt
#include <QProcess>
#include <QMutexLocker>
#include <QDir>
@ -122,7 +127,7 @@ unsigned int AbstractTool::checkVersion(bool &modified)
while(!patterns.isEmpty())
{
QRegExp *pattern = patterns.takeFirst();
X264_DELETE(pattern);
MUTILS_DELETE(pattern);
}
if(bTimeout || bAborted || (!checkVersion_succeeded(process.exitCode())))
@ -175,7 +180,7 @@ bool AbstractTool::startProcess(QProcess &process, const QString &program, const
if(process.waitForStarted())
{
m_jobObject->addProcessToJob(&process);
x264_change_process_priority(&process, m_preferences->getProcessPriority());
MUtils::OS::change_process_priority(&process, m_preferences->getProcessPriority());
lock.unlock();
return true;
}

View File

@ -26,7 +26,7 @@
#define VER_X264_MAJOR 2
#define VER_X264_MINOR 4
#define VER_X264_PATCH 6
#define VER_X264_BUILD 911
#define VER_X264_BUILD 914
#define VER_X264_PORTABLE_EDITION (0)

View File

@ -22,6 +22,7 @@
#include "win_addJob.h"
#include "UIC_win_addJob.h"
//Internal
#include "global.h"
#include "model_options.h"
#include "model_preferences.h"
@ -32,6 +33,10 @@
#include "win_help.h"
#include "win_editor.h"
//MUtils
#include <MUtils/Global.h>
//Qt
#include <QDate>
#include <QTimer>
#include <QCloseEvent>
@ -320,22 +325,22 @@ AddJobDialog::~AddJobDialog(void)
}
const OptionsModel *item = reinterpret_cast<const OptionsModel*>(ui->cbxTemplate->itemData(i).value<const void*>());
ui->cbxTemplate->setItemData(i, QVariant::fromValue<const void*>(NULL));
X264_DELETE(item);
MUTILS_DELETE(item);
}
//Free validators
if(const QValidator *tmp = ui->editCustomX264Params->validator())
{
ui->editCustomX264Params->setValidator(NULL);
X264_DELETE(tmp);
MUTILS_DELETE(tmp);
}
if(const QValidator *tmp = ui->editCustomAvs2YUVParams->validator())
{
ui->editCustomAvs2YUVParams->setValidator(NULL);
X264_DELETE(tmp);
MUTILS_DELETE(tmp);
}
X264_DELETE(m_defaults);
MUTILS_DELETE(m_defaults);
delete ui;
}
@ -834,7 +839,7 @@ void AddJobDialog::deleteTemplateButtonClicked(void)
OptionsModel::deleteTemplate(name);
const OptionsModel *item = reinterpret_cast<const OptionsModel*>(ui->cbxTemplate->itemData(index).value<const void*>());
ui->cbxTemplate->removeItem(index);
X264_DELETE(item);
MUTILS_DELETE(item);
}
void AddJobDialog::editorActionTriggered(void)
@ -852,7 +857,7 @@ void AddJobDialog::editorActionTriggered(void)
lineEdit->setText(editor->getEditText());
}
X264_DELETE(editor);
MUTILS_DELETE(editor);
}
}

View File

@ -22,10 +22,15 @@
#include "win_help.h"
#include "UIC_win_help.h"
//Internal
#include "global.h"
#include "model_options.h"
#include "binaries.h"
//MUtils
#include <MUtils/Sound.h>
//Qt
#include <QProcess>
#include <QScrollBar>
#include <QTimer>
@ -99,7 +104,7 @@ void HelpDialog::closeEvent(QCloseEvent *e)
if(m_process->state() != QProcess::NotRunning)
{
e->ignore();
x264_beep(x264_beep_warning);
MUtils::Sound::beep(MUtils::Sound::BEEP_WRN);
return;
}

View File

@ -49,6 +49,9 @@
#include <MUtils/OSSupport.h>
#include <MUtils/CPUFeatures.h>
#include <MUtils/IPCChannel.h>
#include <MUtils/GUI.h>
#include <MUtils/Sound.h>
#include <MUtils/Exception.h>
//Qt
#include <QDate>
@ -86,7 +89,8 @@ static const int vsynth_rev = 24;
#define NEXT(X) ((*reinterpret_cast<int*>(&(X)))++)
#define SETUP_WEBLINK(OBJ, URL) do { (OBJ)->setData(QVariant(QUrl(URL))); connect((OBJ), SIGNAL(triggered()), this, SLOT(showWebLink())); } while(0)
#define APP_IS_READY (m_initialized && (!m_fileTimer->isActive()) && (QApplication::activeModalWidget() == NULL))
#define ENSURE_APP_IS_READY() do { if(!APP_IS_READY) { x264_beep(x264_beep_warning); qWarning("Cannot perfrom this action at this time!"); return; } } while(0)
#define ENSURE_APP_IS_READY() do { if(!APP_IS_READY) { MUtils::Sound::beep(MUtils::Sound::BEEP_WRN); qWarning("Cannot perfrom this action at this time!"); return; } } while(0)
#define X264_STRCMP(X,Y) ((X).compare((Y), Qt::CaseInsensitive) == 0)
///////////////////////////////////////////////////////////////////////////////
// Constructor & Destructor
@ -142,7 +146,7 @@ MainWindow::MainWindow(const MUtils::CPUFetaures::cpu_info_t &cpuFeatures, MUtil
//Update title
ui->labelBuildDate->setText(tr("Built on %1 at %2").arg(x264_version_date().toString(Qt::ISODate), QString::fromLatin1(x264_version_time())));
if(X264_DEBUG)
if(MUTILS_DEBUG)
{
setWindowTitle(QString("%1 | !!! DEBUG VERSION !!!").arg(windowTitle()));
setStyleSheet("QMenuBar, QMainWindow { background-color: yellow }");
@ -272,7 +276,7 @@ MainWindow::~MainWindow(void)
while(!m_toolsList->isEmpty())
{
QFile *temp = m_toolsList->takeFirst();
X264_DELETE(temp);
MUTILS_DELETE(temp);
}
if(!m_ipcThread.isNull())
@ -402,7 +406,7 @@ void MainWindow::moveButtonPressed(void)
qDebug("Move job %d (direction: UP)", ui->jobsView->currentIndex().row());
if(!m_jobList->moveJob(ui->jobsView->currentIndex(), JobListModel::MOVE_UP))
{
x264_beep(x264_beep_error);
MUtils::Sound::beep(MUtils::Sound::BEEP_ERR);
}
ui->jobsView->scrollTo(ui->jobsView->currentIndex(), QAbstractItemView::PositionAtCenter);
}
@ -411,7 +415,7 @@ void MainWindow::moveButtonPressed(void)
qDebug("Move job %d (direction: DOWN)", ui->jobsView->currentIndex().row());
if(!m_jobList->moveJob(ui->jobsView->currentIndex(), JobListModel::MOVE_DOWN))
{
x264_beep(x264_beep_error);
MUtils::Sound::beep(MUtils::Sound::BEEP_ERR);
}
ui->jobsView->scrollTo(ui->jobsView->currentIndex(), QAbstractItemView::PositionAtCenter);
}
@ -428,7 +432,7 @@ void MainWindow::pauseButtonPressed(bool checked)
{
if(!APP_IS_READY)
{
x264_beep(x264_beep_warning);
MUtils::Sound::beep(MUtils::Sound::BEEP_WRN);
qWarning("Cannot perfrom this action at this time!");
ui->buttonPauseJob->setChecked(!checked);
}
@ -463,7 +467,7 @@ void MainWindow::restartButtonPressed(void)
{
appendJob(sourceFileName, outputFileName, tempOptions, runImmediately);
}
X264_DELETE(tempOptions);
MUTILS_DELETE(tempOptions);
}
}
@ -572,7 +576,7 @@ void MainWindow::showAbout(void)
if(AboutDialog *aboutDialog = new AboutDialog(this))
{
aboutDialog->exec();
X264_DELETE(aboutDialog);
MUTILS_DELETE(aboutDialog);
}
}
@ -605,7 +609,7 @@ void MainWindow::showPreferences(void)
PreferencesDialog *preferences = new PreferencesDialog(this, m_preferences.data(), m_sysinfo.data());
preferences->exec();
X264_DELETE(preferences);
MUTILS_DELETE(preferences);
}
/*
@ -709,7 +713,7 @@ void MainWindow::shutdownComputer(void)
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
QApplication::setOverrideCursor(Qt::WaitCursor);
x264_play_sound(IDR_WAVE1, false);
MUtils::Sound::play_sound("shutdown", false);
QApplication::restoreOverrideCursor();
QTimer timer;
@ -732,12 +736,12 @@ void MainWindow::shutdownComputer(void)
progressDialog.setLabelText(text.arg(iTimeout-i));
if(iTimeout-i == 3) progressDialog.setCancelButton(NULL);
QApplication::processEvents();
x264_play_sound(((i < iTimeout) ? IDR_WAVE2 : IDR_WAVE3), false);
MUtils::Sound::play_sound(((i < iTimeout) ? "beep" : "beep2"), false);
}
qWarning("Shutting down !!!");
if(x264_shutdown_computer("Simple x264 Launcher: All jobs completed, shutting down!", 10, true))
if(MUtils::OS::shutdown_computer("Simple x264 Launcher: All jobs completed, shutting down!", 10, true, false))
{
qApp->closeAllWindows();
}
@ -790,11 +794,11 @@ void MainWindow::init(void)
qDebug("%s", file->fileName().toLatin1().constData());
if(file->open(QIODevice::ReadOnly))
{
if(!x264_is_executable(file->fileName()))
if(!MUtils::OS::is_executable_file(file->fileName()))
{
QMessageBox::critical(this, tr("Invalid File!"), tr("<nobr>At least on required tool is not a valid Win32 or Win64 binary:<br><tt style=\"whitespace:nowrap\">%1</tt><br><br>Please re-install the program in order to fix the problem!</nobr>").arg(QDir::toNativeSeparators(file->fileName())).replace("-", "&minus;"));
qFatal(QString("Binary is invalid: %1").arg(file->fileName()).toLatin1().constData());
X264_DELETE(file);
MUTILS_DELETE(file);
INIT_ERROR_EXIT();
}
if(m_toolsList.isNull())
@ -807,7 +811,7 @@ void MainWindow::init(void)
{
QMessageBox::critical(this, tr("File Not Found!"), tr("<nobr>At least on required tool could not be found:<br><tt style=\"whitespace:nowrap\">%1</tt><br><br>Please re-install the program in order to fix the problem!</nobr>").arg(QDir::toNativeSeparators(file->fileName())).replace("-", "&minus;"));
qFatal(QString("Binary not found: %1/toolset/%2").arg(m_sysinfo->getAppPath(), file->fileName()).toLatin1().constData());
X264_DELETE(file);
MUTILS_DELETE(file);
INIT_ERROR_EXIT();
}
}
@ -972,7 +976,7 @@ void MainWindow::init(void)
// Check for Expiration
//---------------------------------------
if(x264_version_date().addMonths(6) < x264_current_date_safe())
if(x264_version_date().addMonths(6) < MUtils::OS::current_date())
{
if(QWidget *cornerWidget = ui->menubar->cornerWidget()) cornerWidget->show();
QString text;
@ -1006,7 +1010,7 @@ void MainWindow::init(void)
m_recentlyUsed->setLastUpdateCheck(0);
RecentlyUsed::saveRecentlyUsed(m_recentlyUsed.data());
}
else if(m_recentlyUsed->lastUpdateCheck() + 14 < x264_current_date_safe().toJulianDay())
else if(m_recentlyUsed->lastUpdateCheck() + 14 < MUtils::OS::current_date().toJulianDay())
{
if(QWidget *cornerWidget = ui->menubar->cornerWidget()) cornerWidget->show();
if(!m_preferences->getNoUpdateReminder())
@ -1058,7 +1062,7 @@ void MainWindow::copyLogToClipboard(bool checked)
if(LogFileModel *log = dynamic_cast<LogFileModel*>(ui->logView->model()))
{
log->copyToClipboard();
x264_beep(x264_beep_info);
MUtils::Sound::beep(MUtils::Sound::BEEP_NFO);
}
}
@ -1095,7 +1099,7 @@ void MainWindow::handleCommand(const int &command, const QStringList &args, cons
sysTrayActived();
}
x264_bring_to_front(this);
MUtils::GUI::bring_to_front(this);
#ifdef IPC_LOGGING
qDebug("\n---------- IPC ----------");
@ -1112,7 +1116,7 @@ void MainWindow::handleCommand(const int &command, const QStringList &args, cons
{
case IPC_OPCODE_PING:
qDebug("Received a PING request from another instance!");
x264_blink_window(this, 5, 125);
MUtils::GUI::blink_window(this, 5, 125);
break;
case IPC_OPCODE_ADD_FILE:
if(!args.isEmpty())
@ -1157,7 +1161,7 @@ void MainWindow::handleCommand(const int &command, const QStringList &args, cons
}
break;
default:
THROW("Unknown command received!");
MUTILS_THROW("Unknown command received!");
}
}
@ -1179,7 +1183,7 @@ void MainWindow::checkUpdates(void)
if(updater->getSuccess())
{
m_recentlyUsed->setLastUpdateCheck(x264_current_date_safe().toJulianDay());
m_recentlyUsed->setLastUpdateCheck(MUtils::OS::current_date().toJulianDay());
RecentlyUsed::saveRecentlyUsed(m_recentlyUsed.data());
if(QWidget *cornerWidget = ui->menubar->cornerWidget()) cornerWidget->hide();
}
@ -1191,7 +1195,7 @@ void MainWindow::checkUpdates(void)
QApplication::quit();
}
X264_DELETE(updater);
MUTILS_DELETE(updater);
}
/*
@ -1228,7 +1232,7 @@ void MainWindow::sysTrayActived(void)
{
m_sysTray->hide();
showNormal();
x264_bring_to_front(this);
MUtils::GUI::bring_to_front(this);
}
///////////////////////////////////////////////////////////////////////////////
@ -1423,7 +1427,7 @@ bool MainWindow::createJob(QString &sourceFileName, QString &outputFileName, Opt
okay = true;
}
X264_DELETE(addDialog);
MUTILS_DELETE(addDialog);
return okay;
}

View File

@ -22,10 +22,15 @@
#include "win_preferences.h"
#include "UIC_win_preferences.h"
//Internal
#include "global.h"
#include "model_preferences.h"
#include "model_sysinfo.h"
//MUtils
#include <MUtils/GUI.h>
//Qt
#include <QSettings>
#include <QDesktopServices>
#include <QMouseEvent>
@ -62,7 +67,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, PreferencesModel *preferen
ui->setupUi(this);
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
setFixedSize(minimumSize());
x264_enable_close_button(this, false);
MUtils::GUI::enable_close_button(this, false);
ui->comboBoxPriority->setItemData(0, QVariant::fromValue( 1)); //Above Normal
ui->comboBoxPriority->setItemData(1, QVariant::fromValue( 0)); //Normal

View File

@ -29,7 +29,11 @@
//MUtils
#include <MUtils/UpdateChecker.h>
#include <MUtils/Hash_Blake2.h>
#include <MUtils/GUI.h>
#include <MUtils/OSSupport.h>
#include <MUtils/Exception.h>
//Qt
#include <QMovie>
#include <QCloseEvent>
#include <QTimer>
@ -139,7 +143,7 @@ bool UpdaterDialog::event(QEvent *e)
{
if((e->type() == QEvent::ActivationChange) && (m_updaterProcess != NULL))
{
x264_bring_process_to_front(m_updaterProcess);
MUtils::GUI::bring_to_front(m_updaterProcess);
}
return QDialog::event(e);
}
@ -165,7 +169,7 @@ void UpdaterDialog::keyPressEvent(QKeyEvent *event)
{
if(event->key() == Qt::Key_F11)
{
QFile logFile(QString("%1/%2.log").arg(x264_temp_directory(), x264_rand_str()));
QFile logFile(QString("%1/%2.log").arg(MUtils::temp_folder(), MUtils::rand_str()));
if(logFile.open(QIODevice::WriteOnly | QIODevice::Truncate))
{
logFile.write("\xEF\xBB\xBF");
@ -206,7 +210,7 @@ void UpdaterDialog::initUpdate(void)
}
//Make sure user does have admin access
if(!x264_user_is_admin())
if(!MUtils::OS::user_is_admin())
{
qWarning("User is not in the \"admin\" group, cannot update!");
QString message;
@ -312,7 +316,7 @@ void UpdaterDialog::threadStatusChanged(int status)
UPDATE_ICON(3, "play");
break;
default:
THROW("Unknown status code!");
MUTILS_THROW("Unknown status code!");
}
}
@ -405,7 +409,7 @@ void UpdaterDialog::installUpdate(void)
QStringList args;
QEventLoop loop;
x264_init_process(process, x264_temp_directory(), false);
MUtils::init_process(process, MUtils::temp_folder(), false);
connect(&process, SIGNAL(error(QProcess::ProcessError)), &loop, SLOT(quit()));
connect(&process, SIGNAL(finished(int,QProcess::ExitStatus)), &loop, SLOT(quit()));
@ -428,7 +432,7 @@ void UpdaterDialog::installUpdate(void)
return;
}
m_updaterProcess = x264_process_id(process);
m_updaterProcess = MUtils::OS::process_id(&process);
loop.exec(QEventLoop::ExcludeUserInputEvents);
if(!process.waitForFinished())

View File

@ -49,7 +49,6 @@ static size_t x264_entry_check(void)
/*
* Function declarations
*/
void x264_initialization(void);
extern "C" int mainCRTStartup(void);
/*
@ -65,9 +64,6 @@ extern "C" int x264_entry_point(void)
//Make sure we will pass the check
g_x264_entry_check_flag = ~g_x264_entry_check_flag;
//Call global initialization function
x264_initialization();
//Now initialize the C Runtime library!
return mainCRTStartup();
}