From f64f67606adde19ea072069f96d7b0dfcb655601 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Sun, 8 Feb 2015 21:14:21 +0100 Subject: [PATCH] Some more clean-up + moved some more functions to MUtilities library. --- src/encoder_abstract.cpp | 9 +- src/global.cpp | 237 ++++--------------------- src/global.h | 14 +- src/main.cpp | 9 +- src/taskbar7.cpp | 168 ------------------ src/taskbar7.h | 57 ------ src/thread_encode.cpp | 3 +- src/version.h | 2 +- src/win_about.cpp | 15 +- src/win_main.cpp | 44 ++--- src/win_main.h | 9 +- x264_launcher_MSVC2013.vcxproj | 2 - x264_launcher_MSVC2013.vcxproj.filters | 12 +- 13 files changed, 93 insertions(+), 488 deletions(-) delete mode 100644 src/taskbar7.cpp delete mode 100644 src/taskbar7.h diff --git a/src/encoder_abstract.cpp b/src/encoder_abstract.cpp index e2db8ef..935ec3d 100644 --- a/src/encoder_abstract.cpp +++ b/src/encoder_abstract.cpp @@ -33,6 +33,7 @@ //MUtils #include #include +#include //Qt #include @@ -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))); bool ok[2] = {false, false}; QProcess *proc[2] = { &processEncode, &processInput }; - ok[0] = x264_suspendProcess(proc[0], true); - ok[1] = x264_suspendProcess(proc[1], true); + ok[0] = MUtils::OS::suspend_process(proc[0], true); + ok[1] = MUtils::OS::suspend_process(proc[1], true); while(*m_pause) m_semaphorePause->tryAcquire(1, 5000); while(m_semaphorePause->tryAcquire(1, 0)); - ok[0] = x264_suspendProcess(proc[0], false); - ok[1] = x264_suspendProcess(proc[1], false); + ok[0] = MUtils::OS::suspend_process(proc[0], false); + ok[1] = MUtils::OS::suspend_process(proc[1], false); 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))); waitCounter = 0; diff --git a/src/global.cpp b/src/global.cpp index b69bab0..6072ba5 100644 --- a/src/global.cpp +++ b/src/global.cpp @@ -95,13 +95,6 @@ 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); -//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 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}; @@ -113,8 +106,6 @@ static const struct unsigned int ver_minor; unsigned int ver_patch; unsigned int ver_build; - const char* ver_date; - const char* ver_time; } g_x264_version = { @@ -122,21 +113,16 @@ g_x264_version = (VER_X264_MINOR), (VER_X264_PATCH), (VER_X264_BUILD), - __DATE__, - __TIME__, }; -//Portable Mode -static struct -{ - bool bInitialized; - bool bPortableModeEnabled; - QReadWriteLock lock; -} -g_x264_portable; +//Portable mode +static QReadWriteLock g_portableModeLock; +static bool g_portableModeData = false; +static bool g_portableModeInit = false; -//GURU MEDITATION -static const char *GURU_MEDITATION = "\n\nGURU MEDITATION !!!\n\n"; +//Data path +static QString g_dataPathData; +static QReadWriteLock g_dataPathLock; /////////////////////////////////////////////////////////////////////////////// // 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 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 /////////////////////////////////////////////////////////////////////////////// @@ -284,49 +185,39 @@ unsigned int x264_version_build(void) 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 */ -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(); - QWriteLocker writeLock(&g_x264_portable.lock); + QWriteLocker writeLock(&g_portableModeLock); - if(!g_x264_portable.bInitialized) + if(!g_portableModeInit) { if(VER_X264_PORTABLE_EDITION) { qWarning("Simple x264 Launcher portable edition!\n"); - g_x264_portable.bPortableModeEnabled = true; + g_portableModeData = true; } else { QString baseName = QFileInfo(QApplication::applicationFilePath()).completeBaseName(); int idx1 = baseName.indexOf("x264", 0, 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) { - static QString pathCache; - - if(pathCache.isNull()) + QReadLocker readLock(&g_dataPathLock); + + if(!g_dataPathData.isEmpty()) { - if(!x264_portable()) + return g_dataPathData; + } + + readLock.unlock(); + QWriteLocker writeLock(&g_dataPathLock); + + if(g_dataPathData.isEmpty()) + { + g_dataPathData = QDesktopServices::storageLocation(QDesktopServices::DataLocation); + if(g_dataPathData.isEmpty() || x264_is_portable()) { - pathCache = QDesktopServices::storageLocation(QDesktopServices::DataLocation); + g_dataPathData = QApplication::applicationDirPath(); } - if(pathCache.isEmpty() || x264_portable()) + if(!QDir(g_dataPathData).mkpath(".")) { - pathCache = QApplication::applicationDirPath(); - } - if(!QDir(pathCache).mkpath(".")) - { - qWarning("Data directory could not be created:\n%s\n", pathCache.toUtf8().constData()); - pathCache = QDir::currentPath(); + qWarning("Data directory could not be created:\n%s\n", g_dataPathData.toUtf8().constData()); + 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) { 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 */ diff --git a/src/global.h b/src/global.h index fc93e71..1fd0557 100644 --- a/src/global.h +++ b/src/global.h @@ -39,20 +39,18 @@ class QProcess; // GLOBAL FUNCTIONS /////////////////////////////////////////////////////////////////////////////// +//Utility functions const QString &x264_data_path(void); -bool x264_is_prerelease(void); 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); bool x264_set_thread_execution_state(const bool systemRequired); -bool x264_suspendProcess(const QProcess *proc, const bool suspend); -const char *x264_version_arch(void); -unsigned int x264_version_build(void); -const char *x264_version_compiler(void); -const QDate &x264_version_date(void); + +//Version getters unsigned int x264_version_major(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 diff --git a/src/main.cpp b/src/main.cpp index 4ce7a05..b21cd05 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -24,7 +24,6 @@ #include "win_main.h" #include "cli.h" #include "ipc.h" -#include "taskbar7.h" #include "thread_ipc_send.h" //MUtils @@ -163,14 +162,11 @@ static int simple_x264_main(int &argc, char **argv) } //Running in portable mode? - if(x264_portable()) + if(x264_is_portable()) { qDebug("Application is running in portable mode!\n"); } - //Taskbar init - WinSevenTaskbar::init(); - //Set style if(!arguments.contains(CLI_PARAM_NO_GUI_STYLE)) { @@ -183,9 +179,6 @@ static int simple_x264_main(int &argc, char **argv) //Run application int ret = qApp->exec(); - - //Taskbar uninit - WinSevenTaskbar::init(); //Exit program return ret; diff --git a/src/taskbar7.cpp b/src/taskbar7.cpp deleted file mode 100644 index 3a92662..0000000 --- a/src/taskbar7.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Simple x264 Launcher -// Copyright (C) 2004-2015 LoRd_MuldeR -// -// 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 - -//Qt -#include -#include - -//Win32 -#include - - -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__ \ No newline at end of file diff --git a/src/taskbar7.h b/src/taskbar7.h deleted file mode 100644 index 65ac536..0000000 --- a/src/taskbar7.h +++ /dev/null @@ -1,57 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Simple x264 Launcher -// Copyright (C) 2004-2015 LoRd_MuldeR -// -// 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); -}; diff --git a/src/thread_encode.cpp b/src/thread_encode.cpp index f9e408e..2698613 100644 --- a/src/thread_encode.cpp +++ b/src/thread_encode.cpp @@ -39,6 +39,7 @@ //MUtils #include +#include //Qt Framework #include @@ -246,7 +247,7 @@ void EncodeThread::encode(void) // ----------------------------------------------------------------------------------- //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("Source file : %1").arg(QDir::toNativeSeparators(m_sourceFileName))); log(tr("Output file : %1").arg(QDir::toNativeSeparators(m_outputFileName))); diff --git a/src/version.h b/src/version.h index 9d7a103..9f8ef2e 100644 --- a/src/version.h +++ b/src/version.h @@ -26,7 +26,7 @@ #define VER_X264_MAJOR 2 #define VER_X264_MINOR 4 #define VER_X264_PATCH 6 -#define VER_X264_BUILD 915 +#define VER_X264_BUILD 917 #define VER_X264_PORTABLE_EDITION (0) diff --git a/src/win_about.cpp b/src/win_about.cpp index 165652a..705eed3 100644 --- a/src/win_about.cpp +++ b/src/win_about.cpp @@ -22,8 +22,13 @@ #include "win_about.h" #include "UIC_win_about.h" +//Internal #include "global.h" +//MUtils +#include + +//Qt #include #include #include @@ -49,11 +54,11 @@ AboutDialog::AboutDialog(QWidget *parent) QString().sprintf("%u.%02u.%u", x264_version_major(), x264_version_minor(), x264_version_build()), - QString::number(qMax(x264_version_date().year(),QDate::currentDate().year())), - x264_version_date().toString(Qt::ISODate).toLatin1().constData(), - x264_version_time(), - x264_version_compiler(), - x264_version_arch(), + QString::number(qMax(MUtils::Version::app_build_date().year(),QDate::currentDate().year())), + MUtils::Version::app_build_date().toString(Qt::ISODate), + MUtils::Version::app_build_time().toString(Qt::ISODate), + MUtils::Version::compiler_version(), + MUtils::Version::compiler_arch(), QString::fromLatin1(QT_VERSION_STR) ) ); diff --git a/src/win_main.cpp b/src/win_main.cpp index aae7079..b730fe0 100644 --- a/src/win_main.cpp +++ b/src/win_main.cpp @@ -36,7 +36,6 @@ #include "thread_vapoursynth.h" #include "thread_encode.h" #include "thread_ipc_recv.h" -#include "taskbar7.h" #include "input_filter.h" #include "win_addJob.h" #include "win_about.h" @@ -52,6 +51,8 @@ #include #include #include +#include +#include //Qt #include @@ -144,7 +145,7 @@ MainWindow::MainWindow(const MUtils::CPUFetaures::cpu_info_t &cpuFeatures, MUtil ui->splitter->setSizes(QList() << 16 << 196); //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) { @@ -249,6 +250,9 @@ MainWindow::MainWindow(const MUtils::CPUFetaures::cpu_info_t &cpuFeatures, MUtil m_sysTray->setIcon(this->windowIcon()); connect(m_sysTray.data(), SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(sysTrayActived())); + //Init taskbar progress + m_taskbar.reset(new MUtils::Taskbar7(this)); + //Create corner widget QLabel *checkUp = new QLabel(ui->menubar); checkUp->setText(QString(" %1   ").arg(tr("Check for Updates"))); @@ -540,7 +544,10 @@ void MainWindow::jobChangedData(const QModelIndex &topLeft, const QModelIndex & if(i == selected) { 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; } } @@ -821,7 +828,7 @@ void MainWindow::init(void) // Check for portable mode //--------------------------------------- - if(x264_portable()) + if(x264_is_portable()) { bool ok = false; static const char *data = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."; @@ -976,7 +983,7 @@ void MainWindow::init(void) // 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(); QString text; @@ -1326,14 +1333,6 @@ void MainWindow::resizeEvent(QResizeEvent *e) updateLabelPos(); } -/* - * Win32 message filter - */ -bool MainWindow::winEvent(MSG *message, long *result) -{ - return WinSevenTaskbar::handleWinEvent(message, result); -} - /* * File dragged over window */ @@ -1569,26 +1568,31 @@ void MainWindow::updateTaskbar(JobStatus status, const QIcon &icon) { qDebug("MainWindow::updateTaskbar(void)"); + if(m_taskbar.isNull()) + { + return; /*taskbar object not created yet*/ + } + switch(status) { case JobStatus_Undefined: - WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNoState); + m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_NONE); break; case JobStatus_Aborting: case JobStatus_Starting: case JobStatus_Pausing: case JobStatus_Resuming: - WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarIndeterminateState); + m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_INTERMEDIATE); break; case JobStatus_Aborted: case JobStatus_Failed: - WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarErrorState); + m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_ERROR); break; case JobStatus_Paused: - WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarPausedState); + m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_PAUSED); break; default: - WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNormalState); + m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_NORMAL); break; } @@ -1600,11 +1604,11 @@ void MainWindow::updateTaskbar(JobStatus status, const QIcon &icon) case JobStatus_Resuming: break; default: - WinSevenTaskbar::setTaskbarProgress(this, ui->progressBar->value(), ui->progressBar->maximum()); + m_taskbar->setTaskbarProgress(ui->progressBar->value(), ui->progressBar->maximum()); break; } - WinSevenTaskbar::setOverlayIcon(this, icon.isNull() ? NULL : &icon); + m_taskbar->setOverlayIcon(icon.isNull() ? NULL : &icon); } /* diff --git a/src/win_main.h b/src/win_main.h index a5774ec..c9227b3 100644 --- a/src/win_main.h +++ b/src/win_main.h @@ -55,6 +55,7 @@ namespace MUtils } class IPCChannel; + class Taskbar7; } class MainWindow: public QMainWindow @@ -73,18 +74,18 @@ protected: virtual void resizeEvent(QResizeEvent *e); virtual void dragEnterEvent(QDragEnterEvent *event); virtual void dropEvent(QDropEvent *event); - virtual bool winEvent(MSG *message, long *result); private: Ui::MainWindow *const ui; + MUtils::IPCChannel *const m_ipcChannel; bool m_initialized; QScopedPointer m_label; QScopedPointer m_fileTimer; - MUtils::IPCChannel *const m_ipcChannel; - QScopedPointer m_ipcThread; - QScopedPointer m_sysTray; + QScopedPointer m_ipcThread; + QScopedPointer m_taskbar; + QScopedPointer m_sysTray; QScopedPointer m_inputFilter_jobList; QScopedPointer m_inputFilter_version; diff --git a/x264_launcher_MSVC2013.vcxproj b/x264_launcher_MSVC2013.vcxproj index 767846b..aca4fb9 100644 --- a/x264_launcher_MSVC2013.vcxproj +++ b/x264_launcher_MSVC2013.vcxproj @@ -381,7 +381,6 @@ copy /Y "$(QTDIR)\plugins\imageformats\qgif4.dll" "$(TargetDir)\imageformats" - "$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp" "%(FullPath)" "$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp" "%(FullPath)" @@ -433,7 +432,6 @@ copy /Y "$(QTDIR)\plugins\imageformats\qgif4.dll" "$(TargetDir)\imageformats" - diff --git a/x264_launcher_MSVC2013.vcxproj.filters b/x264_launcher_MSVC2013.vcxproj.filters index 0a18593..a22f3fe 100644 --- a/x264_launcher_MSVC2013.vcxproj.filters +++ b/x264_launcher_MSVC2013.vcxproj.filters @@ -48,9 +48,6 @@ Header Files - - Header Files - Header Files @@ -120,9 +117,6 @@ Generated Files - - Header Files - @@ -155,9 +149,6 @@ Source Files - - Source Files - Source Files @@ -346,6 +337,9 @@ Header Files + + Header Files +