Some more clean-up + moved some more functions to MUtilities library.

This commit is contained in:
LoRd_MuldeR 2015-02-08 21:14:21 +01:00
parent fd689aeb70
commit f64f67606a
13 changed files with 93 additions and 488 deletions

View File

@ -33,6 +33,7 @@
//MUtils //MUtils
#include <MUtils/Global.h> #include <MUtils/Global.h>
#include <MUtils/Exception.h> #include <MUtils/Exception.h>
#include <MUtils/OSSupport.h>
//Qt //Qt
#include <QProcess> #include <QProcess>
@ -130,12 +131,12 @@ bool AbstractEncoder::runEncodingPass(AbstractSource* pipedSource, const QString
log(tr("Job paused by user at %1, %2.").arg(QDate::currentDate().toString(Qt::ISODate), QTime::currentTime().toString( Qt::ISODate))); log(tr("Job paused by user at %1, %2.").arg(QDate::currentDate().toString(Qt::ISODate), QTime::currentTime().toString( Qt::ISODate)));
bool ok[2] = {false, false}; bool ok[2] = {false, false};
QProcess *proc[2] = { &processEncode, &processInput }; QProcess *proc[2] = { &processEncode, &processInput };
ok[0] = x264_suspendProcess(proc[0], true); ok[0] = MUtils::OS::suspend_process(proc[0], true);
ok[1] = x264_suspendProcess(proc[1], true); ok[1] = MUtils::OS::suspend_process(proc[1], true);
while(*m_pause) m_semaphorePause->tryAcquire(1, 5000); while(*m_pause) m_semaphorePause->tryAcquire(1, 5000);
while(m_semaphorePause->tryAcquire(1, 0)); while(m_semaphorePause->tryAcquire(1, 0));
ok[0] = x264_suspendProcess(proc[0], false); ok[0] = MUtils::OS::suspend_process(proc[0], false);
ok[1] = x264_suspendProcess(proc[1], false); ok[1] = MUtils::OS::suspend_process(proc[1], false);
if(!(*m_abort)) setStatus(previousStatus); if(!(*m_abort)) setStatus(previousStatus);
log(tr("Job resumed by user at %1, %2.").arg(QDate::currentDate().toString(Qt::ISODate), QTime::currentTime().toString( Qt::ISODate))); log(tr("Job resumed by user at %1, %2.").arg(QDate::currentDate().toString(Qt::ISODate), QTime::currentTime().toString( Qt::ISODate)));
waitCounter = 0; waitCounter = 0;

View File

@ -95,13 +95,6 @@
typedef HRESULT (WINAPI *SHGetKnownFolderPath_t)(const GUID &rfid, DWORD dwFlags, HANDLE hToken, PWSTR *ppszPath); typedef HRESULT (WINAPI *SHGetKnownFolderPath_t)(const GUID &rfid, DWORD dwFlags, HANDLE hToken, PWSTR *ppszPath);
typedef HRESULT (WINAPI *SHGetFolderPath_t)(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath); typedef HRESULT (WINAPI *SHGetFolderPath_t)(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath);
//Global vars
static bool g_x264_console_attached = false;
static QMutex g_x264_message_mutex;
static const DWORD g_main_thread_id = GetCurrentThreadId();
static FILE *g_x264_log_file = NULL;
static QDate g_x264_version_date;
//Const //Const
static const char *g_x264_months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; static const char *g_x264_months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
static const char *g_x264_imageformats[] = {"png", "jpg", "gif", "ico", "svg", NULL}; static const char *g_x264_imageformats[] = {"png", "jpg", "gif", "ico", "svg", NULL};
@ -113,8 +106,6 @@ static const struct
unsigned int ver_minor; unsigned int ver_minor;
unsigned int ver_patch; unsigned int ver_patch;
unsigned int ver_build; unsigned int ver_build;
const char* ver_date;
const char* ver_time;
} }
g_x264_version = g_x264_version =
{ {
@ -122,21 +113,16 @@ g_x264_version =
(VER_X264_MINOR), (VER_X264_MINOR),
(VER_X264_PATCH), (VER_X264_PATCH),
(VER_X264_BUILD), (VER_X264_BUILD),
__DATE__,
__TIME__,
}; };
//Portable Mode //Portable mode
static struct static QReadWriteLock g_portableModeLock;
{ static bool g_portableModeData = false;
bool bInitialized; static bool g_portableModeInit = false;
bool bPortableModeEnabled;
QReadWriteLock lock;
}
g_x264_portable;
//GURU MEDITATION //Data path
static const char *GURU_MEDITATION = "\n\nGURU MEDITATION !!!\n\n"; static QString g_dataPathData;
static QReadWriteLock g_dataPathLock;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// MACROS // MACROS
@ -177,91 +163,6 @@ static inline bool _CHECK_FLAG(const int argc, char **argv, const char *flag)
#define CHECK_FLAG(FLAG) _CHECK_FLAG(argc, argv, "--" FLAG) #define CHECK_FLAG(FLAG) _CHECK_FLAG(argc, argv, "--" FLAG)
#define X264_ZERO_MEMORY(X) SecureZeroMemory(&X, sizeof(X)) #define X264_ZERO_MEMORY(X) SecureZeroMemory(&X, sizeof(X))
///////////////////////////////////////////////////////////////////////////////
// COMPILER INFO
///////////////////////////////////////////////////////////////////////////////
/*
* Disclaimer: Parts of the following code were borrowed from MPC-HC project: http://mpc-hc.sf.net/
*/
//Compiler detection
#if defined(__INTEL_COMPILER)
#if (__INTEL_COMPILER >= 1300)
static const char *g_x264_version_compiler = "ICL 13." x264_MAKE_STR(__INTEL_COMPILER_BUILD_DATE);
#elif (__INTEL_COMPILER >= 1200)
static const char *g_x264_version_compiler = "ICL 12." x264_MAKE_STR(__INTEL_COMPILER_BUILD_DATE);
#elif (__INTEL_COMPILER >= 1100)
static const char *g_x264_version_compiler = "ICL 11.x";
#elif (__INTEL_COMPILER >= 1000)
static const char *g_x264_version_compiler = "ICL 10.x";
#else
#error Compiler is not supported!
#endif
#elif defined(_MSC_VER)
#if (_MSC_VER == 1800)
#if (_MSC_FULL_VER == 180021005)
static const char *g_x264_version_compiler = "MSVC 2013";
#elif (_MSC_FULL_VER == 180030501)
static const char *g_x264_version_compiler = "MSVC 2013.2";
#elif (_MSC_FULL_VER == 180030723)
static const char *g_x264_version_compiler = "MSVC 2013.3";
#elif (_MSC_FULL_VER == 180031101)
static const char *g_x264_version_compiler = "MSVC 2013.4";
#else
#error Compiler version is not supported yet!
#endif
#elif (_MSC_VER == 1700)
#if (_MSC_FULL_VER == 170050727)
static const char *g_x264_version_compiler = "MSVC 2012";
#elif (_MSC_FULL_VER == 170051106)
static const char *g_x264_version_compiler = "MSVC 2012.1";
#elif (_MSC_FULL_VER == 170060315)
static const char *g_x264_version_compiler = "MSVC 2012.2";
#elif (_MSC_FULL_VER == 170060610)
static const char *g_x264_version_compiler = "MSVC 2012.3";
#elif (_MSC_FULL_VER == 170061030)
static const char *g_x264_version_compiler = "MSVC 2012.4";
#else
#error Compiler version is not supported yet!
#endif
#elif (_MSC_VER == 1600)
#if (_MSC_FULL_VER >= 160040219)
static const char *g_x264_version_compiler = "MSVC 2010-SP1";
#else
static const char *g_x264_version_compiler = "MSVC 2010";
#endif
#elif (_MSC_VER == 1500)
#if (_MSC_FULL_VER >= 150030729)
static const char *g_x264_version_compiler = "MSVC 2008-SP1";
#else
static const char *g_x264_version_compiler = "MSVC 2008";
#endif
#else
#error Compiler is not supported!
#endif
// Note: /arch:SSE and /arch:SSE2 are only available for the x86 platform
#if !defined(_M_X64) && defined(_M_IX86_FP)
#if (_M_IX86_FP == 1)
x264_COMPILER_WARNING("SSE instruction set is enabled!")
#elif (_M_IX86_FP == 2)
x264_COMPILER_WARNING("SSE2 (or higher) instruction set is enabled!")
#endif
#endif
#else
#error Compiler is not supported!
#endif
//Architecture detection
#if defined(_M_X64)
static const char *g_x264_version_arch = "x64";
#elif defined(_M_IX86)
static const char *g_x264_version_arch = "x86";
#else
#error Architecture is not supported!
#endif
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// GLOBAL FUNCTIONS // GLOBAL FUNCTIONS
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -284,49 +185,39 @@ unsigned int x264_version_build(void)
return g_x264_version.ver_build; return g_x264_version.ver_build;
} }
const char *x264_version_compiler(void)
{
return g_x264_version_compiler;
}
const char *x264_version_arch(void)
{
return g_x264_version_arch;
}
/* /*
* Check for portable mode * Check for portable mode
*/ */
bool x264_portable(void) bool x264_is_portable(void)
{ {
QReadLocker readLock(&g_x264_portable.lock); QReadLocker readLock(&g_portableModeLock);
if(g_x264_portable.bInitialized) if(g_portableModeInit)
{ {
return g_x264_portable.bPortableModeEnabled; return g_portableModeData;
} }
readLock.unlock(); readLock.unlock();
QWriteLocker writeLock(&g_x264_portable.lock); QWriteLocker writeLock(&g_portableModeLock);
if(!g_x264_portable.bInitialized) if(!g_portableModeInit)
{ {
if(VER_X264_PORTABLE_EDITION) if(VER_X264_PORTABLE_EDITION)
{ {
qWarning("Simple x264 Launcher portable edition!\n"); qWarning("Simple x264 Launcher portable edition!\n");
g_x264_portable.bPortableModeEnabled = true; g_portableModeData = true;
} }
else else
{ {
QString baseName = QFileInfo(QApplication::applicationFilePath()).completeBaseName(); QString baseName = QFileInfo(QApplication::applicationFilePath()).completeBaseName();
int idx1 = baseName.indexOf("x264", 0, Qt::CaseInsensitive); int idx1 = baseName.indexOf("x264", 0, Qt::CaseInsensitive);
int idx2 = baseName.lastIndexOf("portable", -1, Qt::CaseInsensitive); int idx2 = baseName.lastIndexOf("portable", -1, Qt::CaseInsensitive);
g_x264_portable.bPortableModeEnabled = (idx1 >= 0) && (idx2 >= 0) && (idx1 < idx2); g_portableModeData = (idx1 >= 0) && (idx2 >= 0) && (idx1 < idx2);
} }
g_x264_portable.bInitialized = true; g_portableModeInit = true;
} }
return g_x264_portable.bPortableModeEnabled; return g_portableModeData;
} }
/* /*
@ -334,97 +225,41 @@ bool x264_portable(void)
*/ */
const QString &x264_data_path(void) const QString &x264_data_path(void)
{ {
static QString pathCache; QReadLocker readLock(&g_dataPathLock);
if(pathCache.isNull()) if(!g_dataPathData.isEmpty())
{ {
if(!x264_portable()) return g_dataPathData;
{
pathCache = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
} }
if(pathCache.isEmpty() || x264_portable())
readLock.unlock();
QWriteLocker writeLock(&g_dataPathLock);
if(g_dataPathData.isEmpty())
{ {
pathCache = QApplication::applicationDirPath(); g_dataPathData = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
if(g_dataPathData.isEmpty() || x264_is_portable())
{
g_dataPathData = QApplication::applicationDirPath();
} }
if(!QDir(pathCache).mkpath(".")) if(!QDir(g_dataPathData).mkpath("."))
{ {
qWarning("Data directory could not be created:\n%s\n", pathCache.toUtf8().constData()); qWarning("Data directory could not be created:\n%s\n", g_dataPathData.toUtf8().constData());
pathCache = QDir::currentPath(); g_dataPathData = QDir::currentPath();
} }
} }
return pathCache; return g_dataPathData;
} }
/* /*
* Get build date date * Is pre-release version?
*/ */
const QDate &x264_version_date(void)
{
if(!g_x264_version_date.isValid())
{
int date[3] = {0, 0, 0}; char temp[12] = {'\0'};
strncpy_s(temp, 12, g_x264_version.ver_date, _TRUNCATE);
if(strlen(temp) == 11)
{
temp[3] = temp[6] = '\0';
date[2] = atoi(&temp[4]);
date[0] = atoi(&temp[7]);
for(int j = 0; j < 12; j++)
{
if(!_strcmpi(&temp[0], g_x264_months[j]))
{
date[1] = j+1;
break;
}
}
g_x264_version_date = QDate(date[0], date[1], date[2]);
}
if(!g_x264_version_date.isValid())
{
qFatal("Internal error: Date format could not be recognized!");
}
}
return g_x264_version_date;
}
const char *x264_version_time(void)
{
return g_x264_version.ver_time;
}
bool x264_is_prerelease(void) bool x264_is_prerelease(void)
{ {
return (VER_X264_PRE_RELEASE); return (VER_X264_PRE_RELEASE);
} }
/*
* Suspend or resume process
*/
bool x264_suspendProcess(const QProcess *proc, const bool suspend)
{
if(Q_PID pid = proc->pid())
{
if(suspend)
{
return (SuspendThread(pid->hThread) != ((DWORD) -1));
}
else
{
return (ResumeThread(pid->hThread) != ((DWORD) -1));
}
}
else
{
return false;
}
}
/* /*
* Convert path to short/ANSI path * Convert path to short/ANSI path
*/ */

View File

@ -39,20 +39,18 @@ class QProcess;
// GLOBAL FUNCTIONS // GLOBAL FUNCTIONS
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
//Utility functions
const QString &x264_data_path(void); const QString &x264_data_path(void);
bool x264_is_prerelease(void);
QString x264_path2ansi(const QString &longPath, bool makeLowercase = false); QString x264_path2ansi(const QString &longPath, bool makeLowercase = false);
bool x264_portable(void);
QString x264_query_reg_string(const bool bUser, const QString &path, const QString &name); QString x264_query_reg_string(const bool bUser, const QString &path, const QString &name);
bool x264_set_thread_execution_state(const bool systemRequired); bool x264_set_thread_execution_state(const bool systemRequired);
bool x264_suspendProcess(const QProcess *proc, const bool suspend);
const char *x264_version_arch(void); //Version getters
unsigned int x264_version_build(void);
const char *x264_version_compiler(void);
const QDate &x264_version_date(void);
unsigned int x264_version_major(void); unsigned int x264_version_major(void);
unsigned int x264_version_minor(void); unsigned int x264_version_minor(void);
const char *x264_version_time(void); unsigned int x264_version_build(void);
bool x264_is_prerelease(void);
bool x264_is_portable (void);
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// HELPER MACROS // HELPER MACROS

View File

@ -24,7 +24,6 @@
#include "win_main.h" #include "win_main.h"
#include "cli.h" #include "cli.h"
#include "ipc.h" #include "ipc.h"
#include "taskbar7.h"
#include "thread_ipc_send.h" #include "thread_ipc_send.h"
//MUtils //MUtils
@ -163,14 +162,11 @@ static int simple_x264_main(int &argc, char **argv)
} }
//Running in portable mode? //Running in portable mode?
if(x264_portable()) if(x264_is_portable())
{ {
qDebug("Application is running in portable mode!\n"); qDebug("Application is running in portable mode!\n");
} }
//Taskbar init
WinSevenTaskbar::init();
//Set style //Set style
if(!arguments.contains(CLI_PARAM_NO_GUI_STYLE)) if(!arguments.contains(CLI_PARAM_NO_GUI_STYLE))
{ {
@ -184,9 +180,6 @@ static int simple_x264_main(int &argc, char **argv)
//Run application //Run application
int ret = qApp->exec(); int ret = qApp->exec();
//Taskbar uninit
WinSevenTaskbar::init();
//Exit program //Exit program
return ret; return ret;
} }

View File

@ -1,168 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
// Simple x264 Launcher
// Copyright (C) 2004-2015 LoRd_MuldeR <MuldeR2@GMX.de>
//
// 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 "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)
{
MUTILS_THROW("Cannot create instance of this class!");
}
WinSevenTaskbar::~WinSevenTaskbar(void)
{
}
////////////////////////////////////////////////////////////
#ifdef __ITaskbarList3_INTERFACE_DEFINED__
void WinSevenTaskbar::init(void)
{
s_winMsg = RegisterWindowMessageW(L"TaskbarButtonCreated");
s_ptbl = NULL;
}
void WinSevenTaskbar::uninit(void)
{
if(s_ptbl)
{
s_ptbl->Release();
s_ptbl = NULL;
}
}
bool WinSevenTaskbar::handleWinEvent(void *message, long *result)
{
bool stopEvent = false;
if(((MSG*)message)->message == s_winMsg)
{
if(!s_ptbl) createInterface();
*result = (s_ptbl) ? S_OK : S_FALSE;
stopEvent = true;
}
return stopEvent;
}
void WinSevenTaskbar::createInterface(void)
{
if(!s_ptbl)
{
ITaskbarList3 *ptbl = NULL;
HRESULT hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&ptbl));
if (SUCCEEDED(hr))
{
HRESULT hr2 = ptbl->HrInit();
if(SUCCEEDED(hr2))
{
s_ptbl = ptbl;
/*qDebug("ITaskbarList3::HrInit() succeeded.");*/
}
else
{
ptbl->Release();
qWarning("ITaskbarList3::HrInit() has failed.");
}
}
else
{
qWarning("ITaskbarList3 could not be created.");
}
}
}
bool WinSevenTaskbar::setTaskbarState(QWidget *window, WinSevenTaskbarState state)
{
bool result = false;
if(s_ptbl && window)
{
HRESULT hr = HRESULT(-1);
switch(state)
{
case WinSevenTaskbarNoState:
hr = s_ptbl->SetProgressState(window->winId(), TBPF_NOPROGRESS);
break;
case WinSevenTaskbarNormalState:
hr = s_ptbl->SetProgressState(window->winId(), TBPF_NORMAL);
break;
case WinSevenTaskbarIndeterminateState:
hr = s_ptbl->SetProgressState(window->winId(), TBPF_INDETERMINATE);
break;
case WinSevenTaskbarErrorState:
hr = s_ptbl->SetProgressState(window->winId(), TBPF_ERROR);
break;
case WinSevenTaskbarPausedState:
hr = s_ptbl->SetProgressState(window->winId(), TBPF_PAUSED);
break;
}
result = SUCCEEDED(hr);
}
return result;
}
void WinSevenTaskbar::setTaskbarProgress(QWidget *window, unsigned __int64 currentValue, unsigned __int64 maximumValue)
{
if(s_ptbl && window)
{
s_ptbl->SetProgressValue(window->winId(), currentValue, maximumValue);
}
}
void WinSevenTaskbar::setOverlayIcon(QWidget *window, const QIcon *icon)
{
if(s_ptbl && window)
{
s_ptbl->SetOverlayIcon(window->winId(), (icon ? icon->pixmap(16,16).toWinHICON() : NULL), L"Simple x264 Launcher");
}
}
#else //__ITaskbarList3_INTERFACE_DEFINED__
X264_COMPILER_WARNING("ITaskbarList3 not defined. Compiling *without* support for Win7 taskbar!")
void WinSevenTaskbar::init(void) {}
void WinSevenTaskbar::uninit(void) {}
bool WinSevenTaskbar::handleWinEvent(MSG *message, long *result) { return false; }
void WinSevenTaskbar::createInterface(void) {}
bool WinSevenTaskbar::setTaskbarState(QWidget *window, WinSevenTaskbarState state) { return false; }
void WinSevenTaskbar::setTaskbarProgress(QWidget *window, unsigned __int64 currentValue, unsigned __int64 maximumValue) {}
void WinSevenTaskbar::setOverlayIcon(QWidget *window, QIcon *icon) {}
#endif //__ITaskbarList3_INTERFACE_DEFINED__

View File

@ -1,57 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
// Simple x264 Launcher
// Copyright (C) 2004-2015 LoRd_MuldeR <MuldeR2@GMX.de>
//
// 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
///////////////////////////////////////////////////////////////////////////////
#pragma once
#include "global.h"
class QWidget;
class QIcon;
struct ITaskbarList3;
class WinSevenTaskbar
{
public:
WinSevenTaskbar(void);
~WinSevenTaskbar(void);
//Taskbar states
enum WinSevenTaskbarState
{
WinSevenTaskbarNoState = 0,
WinSevenTaskbarNormalState = 1,
WinSevenTaskbarIndeterminateState = 2,
WinSevenTaskbarPausedState = 3,
WinSevenTaskbarErrorState = 4
};
//Public interface
static bool handleWinEvent(void *message, long *result);
static bool setTaskbarState(QWidget *window, WinSevenTaskbarState state);
static void setTaskbarProgress(QWidget *window, unsigned __int64 currentValue, unsigned __int64 maximumValue);
static void setOverlayIcon(QWidget *window, const QIcon *icon);
static void init(void);
static void uninit(void);
private:
static void createInterface(void);
};

View File

@ -39,6 +39,7 @@
//MUtils //MUtils
#include <MUtils/OSSupport.h> #include <MUtils/OSSupport.h>
#include <MUtils/Version.h>
//Qt Framework //Qt Framework
#include <QDate> #include <QDate>
@ -246,7 +247,7 @@ void EncodeThread::encode(void)
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
//Print some basic info //Print some basic info
log(tr("Simple x264 Launcher (Build #%1), built %2\n").arg(QString::number(x264_version_build()), x264_version_date().toString(Qt::ISODate))); log(tr("Simple x264 Launcher (Build #%1), built %2\n").arg(QString::number(x264_version_build()), MUtils::Version::app_build_date().toString(Qt::ISODate)));
log(tr("Job started at %1, %2.\n").arg(QDate::currentDate().toString(Qt::ISODate), QTime::currentTime().toString( Qt::ISODate))); log(tr("Job started at %1, %2.\n").arg(QDate::currentDate().toString(Qt::ISODate), QTime::currentTime().toString( Qt::ISODate)));
log(tr("Source file : %1").arg(QDir::toNativeSeparators(m_sourceFileName))); log(tr("Source file : %1").arg(QDir::toNativeSeparators(m_sourceFileName)));
log(tr("Output file : %1").arg(QDir::toNativeSeparators(m_outputFileName))); log(tr("Output file : %1").arg(QDir::toNativeSeparators(m_outputFileName)));

View File

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

View File

@ -22,8 +22,13 @@
#include "win_about.h" #include "win_about.h"
#include "UIC_win_about.h" #include "UIC_win_about.h"
//Internal
#include "global.h" #include "global.h"
//MUtils
#include <MUtils/Version.h>
//Qt
#include <QProcess> #include <QProcess>
#include <QScrollBar> #include <QScrollBar>
#include <QDate> #include <QDate>
@ -49,11 +54,11 @@ AboutDialog::AboutDialog(QWidget *parent)
QString().sprintf("%u.%02u.%u", x264_version_major(), QString().sprintf("%u.%02u.%u", x264_version_major(),
x264_version_minor(), x264_version_minor(),
x264_version_build()), x264_version_build()),
QString::number(qMax(x264_version_date().year(),QDate::currentDate().year())), QString::number(qMax(MUtils::Version::app_build_date().year(),QDate::currentDate().year())),
x264_version_date().toString(Qt::ISODate).toLatin1().constData(), MUtils::Version::app_build_date().toString(Qt::ISODate),
x264_version_time(), MUtils::Version::app_build_time().toString(Qt::ISODate),
x264_version_compiler(), MUtils::Version::compiler_version(),
x264_version_arch(), MUtils::Version::compiler_arch(),
QString::fromLatin1(QT_VERSION_STR) QString::fromLatin1(QT_VERSION_STR)
) )
); );

View File

@ -36,7 +36,6 @@
#include "thread_vapoursynth.h" #include "thread_vapoursynth.h"
#include "thread_encode.h" #include "thread_encode.h"
#include "thread_ipc_recv.h" #include "thread_ipc_recv.h"
#include "taskbar7.h"
#include "input_filter.h" #include "input_filter.h"
#include "win_addJob.h" #include "win_addJob.h"
#include "win_about.h" #include "win_about.h"
@ -52,6 +51,8 @@
#include <MUtils/GUI.h> #include <MUtils/GUI.h>
#include <MUtils/Sound.h> #include <MUtils/Sound.h>
#include <MUtils/Exception.h> #include <MUtils/Exception.h>
#include <MUtils/Taskbar7.h>
#include <MUtils/Version.h>
//Qt //Qt
#include <QDate> #include <QDate>
@ -144,7 +145,7 @@ MainWindow::MainWindow(const MUtils::CPUFetaures::cpu_info_t &cpuFeatures, MUtil
ui->splitter->setSizes(QList<int>() << 16 << 196); ui->splitter->setSizes(QList<int>() << 16 << 196);
//Update title //Update title
ui->labelBuildDate->setText(tr("Built on %1 at %2").arg(x264_version_date().toString(Qt::ISODate), QString::fromLatin1(x264_version_time()))); ui->labelBuildDate->setText(tr("Built on %1 at %2").arg(MUtils::Version::app_build_date().toString(Qt::ISODate), MUtils::Version::app_build_time().toString(Qt::ISODate)));
if(MUTILS_DEBUG) if(MUTILS_DEBUG)
{ {
@ -249,6 +250,9 @@ MainWindow::MainWindow(const MUtils::CPUFetaures::cpu_info_t &cpuFeatures, MUtil
m_sysTray->setIcon(this->windowIcon()); m_sysTray->setIcon(this->windowIcon());
connect(m_sysTray.data(), SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(sysTrayActived())); connect(m_sysTray.data(), SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(sysTrayActived()));
//Init taskbar progress
m_taskbar.reset(new MUtils::Taskbar7(this));
//Create corner widget //Create corner widget
QLabel *checkUp = new QLabel(ui->menubar); QLabel *checkUp = new QLabel(ui->menubar);
checkUp->setText(QString("<nobr><img src=\":/buttons/exclamation_small.png\">&nbsp;<b style=\"color:darkred\">%1</b>&nbsp;&nbsp;&nbsp;</nobr>").arg(tr("Check for Updates"))); checkUp->setText(QString("<nobr><img src=\":/buttons/exclamation_small.png\">&nbsp;<b style=\"color:darkred\">%1</b>&nbsp;&nbsp;&nbsp;</nobr>").arg(tr("Check for Updates")));
@ -540,7 +544,10 @@ void MainWindow::jobChangedData(const QModelIndex &topLeft, const QModelIndex &
if(i == selected) if(i == selected)
{ {
ui->progressBar->setValue(m_jobList->getJobProgress(m_jobList->index(i, 0, QModelIndex()))); ui->progressBar->setValue(m_jobList->getJobProgress(m_jobList->index(i, 0, QModelIndex())));
WinSevenTaskbar::setTaskbarProgress(this, ui->progressBar->value(), ui->progressBar->maximum()); if(!m_taskbar.isNull())
{
m_taskbar->setTaskbarProgress(ui->progressBar->value(), ui->progressBar->maximum());
}
break; break;
} }
} }
@ -821,7 +828,7 @@ void MainWindow::init(void)
// Check for portable mode // Check for portable mode
//--------------------------------------- //---------------------------------------
if(x264_portable()) if(x264_is_portable())
{ {
bool ok = false; bool ok = false;
static const char *data = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."; static const char *data = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
@ -976,7 +983,7 @@ void MainWindow::init(void)
// Check for Expiration // Check for Expiration
//--------------------------------------- //---------------------------------------
if(x264_version_date().addMonths(6) < MUtils::OS::current_date()) if(MUtils::Version::app_build_date().addMonths(6) < MUtils::OS::current_date())
{ {
if(QWidget *cornerWidget = ui->menubar->cornerWidget()) cornerWidget->show(); if(QWidget *cornerWidget = ui->menubar->cornerWidget()) cornerWidget->show();
QString text; QString text;
@ -1326,14 +1333,6 @@ void MainWindow::resizeEvent(QResizeEvent *e)
updateLabelPos(); updateLabelPos();
} }
/*
* Win32 message filter
*/
bool MainWindow::winEvent(MSG *message, long *result)
{
return WinSevenTaskbar::handleWinEvent(message, result);
}
/* /*
* File dragged over window * File dragged over window
*/ */
@ -1569,26 +1568,31 @@ void MainWindow::updateTaskbar(JobStatus status, const QIcon &icon)
{ {
qDebug("MainWindow::updateTaskbar(void)"); qDebug("MainWindow::updateTaskbar(void)");
if(m_taskbar.isNull())
{
return; /*taskbar object not created yet*/
}
switch(status) switch(status)
{ {
case JobStatus_Undefined: case JobStatus_Undefined:
WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNoState); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_NONE);
break; break;
case JobStatus_Aborting: case JobStatus_Aborting:
case JobStatus_Starting: case JobStatus_Starting:
case JobStatus_Pausing: case JobStatus_Pausing:
case JobStatus_Resuming: case JobStatus_Resuming:
WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarIndeterminateState); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_INTERMEDIATE);
break; break;
case JobStatus_Aborted: case JobStatus_Aborted:
case JobStatus_Failed: case JobStatus_Failed:
WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarErrorState); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_ERROR);
break; break;
case JobStatus_Paused: case JobStatus_Paused:
WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarPausedState); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_PAUSED);
break; break;
default: default:
WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNormalState); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_NORMAL);
break; break;
} }
@ -1600,11 +1604,11 @@ void MainWindow::updateTaskbar(JobStatus status, const QIcon &icon)
case JobStatus_Resuming: case JobStatus_Resuming:
break; break;
default: default:
WinSevenTaskbar::setTaskbarProgress(this, ui->progressBar->value(), ui->progressBar->maximum()); m_taskbar->setTaskbarProgress(ui->progressBar->value(), ui->progressBar->maximum());
break; break;
} }
WinSevenTaskbar::setOverlayIcon(this, icon.isNull() ? NULL : &icon); m_taskbar->setOverlayIcon(icon.isNull() ? NULL : &icon);
} }
/* /*

View File

@ -55,6 +55,7 @@ namespace MUtils
} }
class IPCChannel; class IPCChannel;
class Taskbar7;
} }
class MainWindow: public QMainWindow class MainWindow: public QMainWindow
@ -73,17 +74,17 @@ protected:
virtual void resizeEvent(QResizeEvent *e); virtual void resizeEvent(QResizeEvent *e);
virtual void dragEnterEvent(QDragEnterEvent *event); virtual void dragEnterEvent(QDragEnterEvent *event);
virtual void dropEvent(QDropEvent *event); virtual void dropEvent(QDropEvent *event);
virtual bool winEvent(MSG *message, long *result);
private: private:
Ui::MainWindow *const ui; Ui::MainWindow *const ui;
MUtils::IPCChannel *const m_ipcChannel;
bool m_initialized; bool m_initialized;
QScopedPointer<QLabel> m_label; QScopedPointer<QLabel> m_label;
QScopedPointer<QTimer> m_fileTimer; QScopedPointer<QTimer> m_fileTimer;
MUtils::IPCChannel *const m_ipcChannel;
QScopedPointer<IPCThread_Recv> m_ipcThread; QScopedPointer<IPCThread_Recv> m_ipcThread;
QScopedPointer<MUtils::Taskbar7> m_taskbar;
QScopedPointer<QSystemTrayIcon> m_sysTray; QScopedPointer<QSystemTrayIcon> m_sysTray;
QScopedPointer<InputEventFilter> m_inputFilter_jobList; QScopedPointer<InputEventFilter> m_inputFilter_jobList;

View File

@ -381,7 +381,6 @@ copy /Y "$(QTDIR)\plugins\imageformats\qgif4.dll" "$(TargetDir)\imageformats"
<ClInclude Include="src\source_avisynth.h" /> <ClInclude Include="src\source_avisynth.h" />
<ClInclude Include="src\source_vapoursynth.h" /> <ClInclude Include="src\source_vapoursynth.h" />
<ClInclude Include="src\targetver.h" /> <ClInclude Include="src\targetver.h" />
<ClInclude Include="src\taskbar7.h" />
<CustomBuild Include="src\thread_avisynth.h"> <CustomBuild Include="src\thread_avisynth.h">
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp" "%(FullPath)"</Command> <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp" "%(FullPath)"</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp" "%(FullPath)"</Command> <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp" "%(FullPath)"</Command>
@ -433,7 +432,6 @@ copy /Y "$(QTDIR)\plugins\imageformats\qgif4.dll" "$(TargetDir)\imageformats"
<ClCompile Include="src\source_abstract.cpp" /> <ClCompile Include="src\source_abstract.cpp" />
<ClCompile Include="src\source_avisynth.cpp" /> <ClCompile Include="src\source_avisynth.cpp" />
<ClCompile Include="src\source_vapoursynth.cpp" /> <ClCompile Include="src\source_vapoursynth.cpp" />
<ClCompile Include="src\taskbar7.cpp" />
<ClCompile Include="src\thread_avisynth.cpp" /> <ClCompile Include="src\thread_avisynth.cpp" />
<ClCompile Include="src\thread_encode.cpp" /> <ClCompile Include="src\thread_encode.cpp" />
<ClCompile Include="src\global.cpp" /> <ClCompile Include="src\global.cpp" />

View File

@ -48,9 +48,6 @@
<ClInclude Include="src\model_options.h"> <ClInclude Include="src\model_options.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src\taskbar7.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\model_preferences.h"> <ClInclude Include="src\model_preferences.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
@ -120,9 +117,6 @@
<ClInclude Include="tmp\x264_launcher\UIC_win_updater.h"> <ClInclude Include="tmp\x264_launcher\UIC_win_updater.h">
<Filter>Generated Files</Filter> <Filter>Generated Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src\thread_ipc_recv.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="src\main.cpp"> <ClCompile Include="src\main.cpp">
@ -155,9 +149,6 @@
<ClCompile Include="src\win_preferences.cpp"> <ClCompile Include="src\win_preferences.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="src\taskbar7.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\win_editor.cpp"> <ClCompile Include="src\win_editor.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@ -346,6 +337,9 @@
<CustomBuild Include="src\thread_ipc_send.h"> <CustomBuild Include="src\thread_ipc_send.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</CustomBuild> </CustomBuild>
<CustomBuild Include="src\thread_ipc_recv.h">
<Filter>Header Files</Filter>
</CustomBuild>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="x264_launcher.rc"> <ResourceCompile Include="x264_launcher.rc">