diff --git a/res/images/movie.png b/res/images/movie.png new file mode 100644 index 0000000..aca92a5 Binary files /dev/null and b/res/images/movie.png differ diff --git a/res/images/update.png b/res/images/update.png new file mode 100644 index 0000000..f2d5494 Binary files /dev/null and b/res/images/update.png differ diff --git a/res/resources.qrc b/res/resources.qrc index 1362a2f..310bd19 100644 --- a/res/resources.qrc +++ b/res/resources.qrc @@ -32,6 +32,8 @@ buttons/trash.png buttons/world_link.png buttons/wrench.png + images/movie.png + images/update.png images/x264.png diff --git a/src/global.cpp b/src/global.cpp index 17ec425..6acad9d 100644 --- a/src/global.cpp +++ b/src/global.cpp @@ -74,13 +74,15 @@ static const struct { unsigned int ver_major; unsigned int ver_minor; + unsigned int ver_patch; const char* ver_date; const char* ver_time; } g_x264_version = { - VER_X264_MAJOR, - VER_X264_MINOR, + (VER_X264_MAJOR), + (VER_X264_MINOR), + (VER_X264_PATCH), __DATE__, __TIME__ }; @@ -264,7 +266,7 @@ void x264_message_handler(QtMsgType type, const char *msg) */ void x264_init_console(int argc, char* argv[]) { - bool enableConsole = x264_is_prerelease() || X264_DEBUG; + bool enableConsole = x264_is_prerelease() || (X264_DEBUG); if(_environ) { @@ -355,6 +357,11 @@ unsigned int x264_version_minor(void) return g_x264_version.ver_minor; } +unsigned int x264_version_patch(void) +{ + return g_x264_version.ver_patch; +} + const char *x264_version_compiler(void) { return g_x264_version_compiler; diff --git a/src/global.h b/src/global.h index 1a09a6d..ef511df 100644 --- a/src/global.h +++ b/src/global.h @@ -97,6 +97,7 @@ void x264_invalid_param_handler(const wchar_t*, const wchar_t*, const wchar_t*, void x264_message_handler(QtMsgType type, const char *msg); unsigned int x264_version_major(void); unsigned int x264_version_minor(void); +unsigned int x264_version_patch(void); const QDate &x264_version_date(void); bool x264_is_prerelease(void); const char *x264_version_time(void); diff --git a/src/main.cpp b/src/main.cpp index 35b324a..7063f66 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,6 +21,7 @@ #include "global.h" #include "win_main.h" +#include "taskbar7.h" //Qt includes #include @@ -37,7 +38,7 @@ static int x264_main(int argc, char* argv[]) x264_init_console(argc, argv); //Print version info - qDebug("Simple x264 Launcher v%u.%02u - use 64-Bit x264 with 32-Bit Avisynth", x264_version_major(), x264_version_minor()); + qDebug("Simple x264 Launcher v%u.%02u.%u - use 64-Bit x264 with 32-Bit Avisynth", x264_version_major(), x264_version_minor(), x264_version_patch()); qDebug("Copyright (c) 2004-%04d LoRd_MuldeR . Some rights reserved.", qMax(x264_version_date().year(),QDate::currentDate().year())); qDebug("Built on %s at %s with %s for Win-%s.\n", x264_version_date().toString(Qt::ISODate).toLatin1().constData(), x264_version_time(), x264_version_compiler(), x264_version_arch()); @@ -67,6 +68,9 @@ static int x264_main(int argc, char* argv[]) { return -1; } + + //Taskbar init + WinSevenTaskbar::init(); //Set style qApp->setStyle(new QPlastiqueStyle()); @@ -77,6 +81,9 @@ static int x264_main(int argc, char* argv[]) //Run application int ret = qApp->exec(); + + //Taskbar uninit + WinSevenTaskbar::init(); X264_DELETE(mainWin); return ret; diff --git a/src/taskbar7.cpp b/src/taskbar7.cpp new file mode 100644 index 0000000..2b377d4 --- /dev/null +++ b/src/taskbar7.cpp @@ -0,0 +1,161 @@ +/////////////////////////////////////////////////////////////////////////////// +// LameXP - Audio Encoder Front-End +// Copyright (C) 2004-2012 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" + +#include +#include +#include + +UINT WinSevenTaskbar::m_winMsg = 0; +ITaskbarList3 *WinSevenTaskbar::m_ptbl = NULL; + +WinSevenTaskbar::WinSevenTaskbar(void) +{ + throw "Cannot create instance of this class!"; +} + +WinSevenTaskbar::~WinSevenTaskbar(void) +{ +} + +//////////////////////////////////////////////////////////// + +#ifdef __ITaskbarList3_INTERFACE_DEFINED__ + +void WinSevenTaskbar::init(void) +{ + m_winMsg = RegisterWindowMessageW(L"TaskbarButtonCreated"); + m_ptbl = NULL; +} + +void WinSevenTaskbar::uninit(void) +{ + if(m_ptbl) + { + m_ptbl->Release(); + m_ptbl = NULL; + } +} + +bool WinSevenTaskbar::handleWinEvent(MSG *message, long *result) +{ + bool stopEvent = false; + + if(message->message == m_winMsg) + { + if(!m_ptbl) createInterface(); + *result = (m_ptbl) ? S_OK : S_FALSE; + stopEvent = true; + } + + return stopEvent; +} + +void WinSevenTaskbar::createInterface(void) +{ + if(!m_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)) + { + m_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(m_ptbl && window) + { + HRESULT hr = HRESULT(-1); + + switch(state) + { + case WinSevenTaskbarNoState: + hr = m_ptbl->SetProgressState(window->winId(), TBPF_NOPROGRESS); + break; + case WinSevenTaskbarNormalState: + hr = m_ptbl->SetProgressState(window->winId(), TBPF_NORMAL); + break; + case WinSevenTaskbarIndeterminateState: + hr = m_ptbl->SetProgressState(window->winId(), TBPF_INDETERMINATE); + break; + case WinSevenTaskbarErrorState: + hr = m_ptbl->SetProgressState(window->winId(), TBPF_ERROR); + break; + case WinSevenTaskbarPausedState: + hr = m_ptbl->SetProgressState(window->winId(), TBPF_PAUSED); + break; + } + + result = SUCCEEDED(hr); + } + + return result; +} + +void WinSevenTaskbar::setTaskbarProgress(QWidget *window, unsigned __int64 currentValue, unsigned __int64 maximumValue) +{ + if(m_ptbl && window) + { + m_ptbl->SetProgressValue(window->winId(), currentValue, maximumValue); + } +} + +void WinSevenTaskbar::setOverlayIcon(QWidget *window, const QIcon *icon) +{ + if(m_ptbl && window) + { + m_ptbl->SetOverlayIcon(window->winId(), (icon ? icon->pixmap(16,16).toWinHICON() : NULL), L"LameXP"); + } +} + +#else //__ITaskbarList3_INTERFACE_DEFINED__ + +LAMEXP_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/thread_encode.cpp b/src/thread_encode.cpp index c6ac2ee..b6e5c9d 100644 --- a/src/thread_encode.cpp +++ b/src/thread_encode.cpp @@ -213,18 +213,18 @@ void EncodeThread::encode(void) if(revision_avs2yuv != UINT_MAX) log(tr("Avs2YUV version: %1.%2.%3").arg(QString::number(revision_avs2yuv / REV_MULT), QString::number((revision_avs2yuv % REV_MULT) / 10),QString::number((revision_avs2yuv % REV_MULT) % 10))); //Is x264 revision supported? - if((revision_x264 % REV_MULT) < VER_X264_MINIMUM_REV) + if((revision_x264 % REV_MULT) < (VER_X264_MINIMUM_REV)) { log(tr("\nERROR: Your revision of x264 is too old! (Minimum required revision is %2)").arg(QString::number(VER_X264_MINIMUM_REV))); setStatus(JobStatus_Failed); return; } - if((revision_x264 / REV_MULT) != VER_X264_CURRENT_API) + if((revision_x264 / REV_MULT) != (VER_X264_CURRENT_API)) { log(tr("\nWARNING: Your revision of x264 uses an unsupported core (API) version, take care!")); log(tr("This application works best with x264 core (API) version %2.").arg(QString::number(VER_X264_CURRENT_API))); } - if((revision_avs2yuv != UINT_MAX) && ((revision_avs2yuv % REV_MULT) != VER_X264_AVS2YUV_VER)) + if((revision_avs2yuv != UINT_MAX) && ((revision_avs2yuv % REV_MULT) != (VER_X264_AVS2YUV_VER))) { log(tr("\nERROR: Your version of avs2yuv is unsupported (Required version: v0.24 BugMaster's mod 2)")); log(tr("You can find the required version at: http://komisar.gin.by/tools/avs2yuv/")); diff --git a/src/version.h b/src/version.h index d5201bd..0f5cbb9 100644 --- a/src/version.h +++ b/src/version.h @@ -19,11 +19,12 @@ // http://www.gnu.org/licenses/gpl-2.0.txt /////////////////////////////////////////////////////////////////////////////// -#define VER_X264_MAJOR (2) -#define VER_X264_MINOR (0) +#define VER_X264_MAJOR 2 +#define VER_X264_MINOR 0 +#define VER_X264_PATCH 52 -#define VER_X264_MINIMUM_REV (2146) -#define VER_X264_CURRENT_API (120) -#define VER_X264_AVS2YUV_VER (242) +#define VER_X264_MINIMUM_REV 2146 +#define VER_X264_CURRENT_API 120 +#define VER_X264_AVS2YUV_VER 242 #define VER_X264_PRE_RELEASE (0) diff --git a/src/win_main.cpp b/src/win_main.cpp index 8b2e04c..21ef065 100644 --- a/src/win_main.cpp +++ b/src/win_main.cpp @@ -25,6 +25,7 @@ #include "model_options.h" #include "win_addJob.h" #include "win_preferences.h" +#include "taskbar7.h" #include "resource.h" #include @@ -41,6 +42,7 @@ #include const char *home_url = "http://mulder.brhack.net/"; +const char *update_url = "http://code.google.com/p/mulder/downloads/list"; #define SET_FONT_BOLD(WIDGET,BOLD) { QFont _font = WIDGET->font(); _font.setBold(BOLD); WIDGET->setFont(_font); } #define SET_TEXT_COLOR(WIDGET,COLOR) { QPalette _palette = WIDGET->palette(); _palette.setColor(QPalette::WindowText, (COLOR)); _palette.setColor(QPalette::Text, (COLOR)); WIDGET->setPalette(_palette); } @@ -259,10 +261,11 @@ void MainWindow::jobSelected(const QModelIndex & current, const QModelIndex & pr connect(logView->model(), SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(jobLogExtended(QModelIndex, int, int))); logView->actions().first()->setEnabled(true); QTimer::singleShot(0, logView, SLOT(scrollToBottom())); - + progressBar->setValue(m_jobList->getJobProgress(current)); editDetails->setText(m_jobList->data(m_jobList->index(current.row(), 3, QModelIndex()), Qt::DisplayRole).toString()); updateButtons(m_jobList->getJobStatus(current)); + updateTaskbar(m_jobList->getJobStatus(current), m_jobList->data(m_jobList->index(current.row(), 0, QModelIndex()), Qt::DecorationRole).value()); } else { @@ -271,6 +274,7 @@ void MainWindow::jobSelected(const QModelIndex & current, const QModelIndex & pr progressBar->setValue(0); editDetails->clear(); updateButtons(EncodeThread::JobStatus_Undefined); + updateTaskbar(EncodeThread::JobStatus_Undefined, QIcon()); } progressBar->repaint(); @@ -289,6 +293,7 @@ void MainWindow::jobChangedData(const QModelIndex &topLeft, const QModelIndex & { qDebug("Current job changed status!"); updateButtons(status); + updateTaskbar(status, m_jobList->data(m_jobList->index(i, 0, QModelIndex()), Qt::DecorationRole).value()); } if((status == EncodeThread::JobStatus_Completed) || (status == EncodeThread::JobStatus_Failed)) { @@ -297,18 +302,19 @@ void MainWindow::jobChangedData(const QModelIndex &topLeft, const QModelIndex & } } } - else if(topLeft.column() <= 2 && bottomRight.column() >= 2) /*PROGRESS*/ + if(topLeft.column() <= 2 && bottomRight.column() >= 2) /*PROGRESS*/ { for(int i = topLeft.row(); i <= bottomRight.row(); i++) { if(i == selected) { progressBar->setValue(m_jobList->getJobProgress(m_jobList->index(i, 0, QModelIndex()))); + WinSevenTaskbar::setTaskbarProgress(this, progressBar->value(), progressBar->maximum()); break; } } } - else if(topLeft.column() <= 3 && bottomRight.column() >= 3) /*DETAILS*/ + if(topLeft.column() <= 3 && bottomRight.column() >= 3) /*DETAILS*/ { for(int i = topLeft.row(); i <= bottomRight.row(); i++) { @@ -330,7 +336,7 @@ void MainWindow::showAbout(void) { QString text; - text += QString().sprintf("Simple x264 Launcher v%u.%02u - use 64-Bit x264 with 32-Bit Avisynth
", x264_version_major(), x264_version_minor()); + text += QString().sprintf("
Simple x264 Launcher v%u.%02u.%u - use 64-Bit x264 with 32-Bit Avisynth
", x264_version_major(), x264_version_minor(), x264_version_patch()); text += QString().sprintf("Copyright (c) 2004-%04d LoRd_MuldeR <mulder2@gmx.de>. Some rights reserved.
", qMax(x264_version_date().year(),QDate::currentDate().year())); text += QString().sprintf("Built on %s at %s with %s for Win-%s.

", x264_version_date().toString(Qt::ISODate).toLatin1().constData(), x264_version_time(), x264_version_compiler(), x264_version_arch()); text += QString().sprintf("This program is free software: you can redistribute it and/or modify
"); @@ -338,11 +344,18 @@ void MainWindow::showAbout(void) text += QString().sprintf("Note that this program is distributed with ABSOLUTELY NO WARRANTY.

"); text += QString().sprintf("Please check the web-site at %s for updates !!!
", home_url, home_url); + QMessageBox aboutBox(this); + aboutBox.setIconPixmap(QIcon(":/images/movie.png").pixmap(64,64)); + aboutBox.setWindowTitle(tr("About...")); + aboutBox.setText(text.replace("-", "−")); + aboutBox.addButton(tr("About x264"), QMessageBox::NoRole); + aboutBox.addButton(tr("About Qt"), QMessageBox::NoRole); + aboutBox.setEscapeButton(aboutBox.addButton(tr("Close"), QMessageBox::NoRole)); + forever { - int ret = QMessageBox::information(this, tr("About..."), text.replace("-", "−"), tr("About x264"), tr("About Qt"), tr("Close"), 0, 2); - - switch(ret) + MessageBeep(MB_ICONINFORMATION); + switch(aboutBox.exec()) { case 0: { @@ -351,7 +364,14 @@ void MainWindow::showAbout(void) text2 += tr("Free software library for encoding video streams into the H.264/MPEG-4 AVC format.
"); text2 += tr("Released under the terms of the GNU General Public License.

"); text2 += tr("Please visit %1 for obtaining a commercial x264 license!
").arg("http://x264licensing.com/"); - QMessageBox::information(this, tr("About x264"), text2.replace("-", "−"), tr("Close")); + + QMessageBox x264Box(this); + x264Box.setIconPixmap(QIcon(":/images/x264.png").pixmap(48,48)); + x264Box.setWindowTitle(tr("About x264")); + x264Box.setText(text2.replace("-", "−")); + x264Box.setEscapeButton(x264Box.addButton(tr("Close"), QMessageBox::NoRole)); + MessageBeep(MB_ICONINFORMATION); + x264Box.exec(); } break; case 1: @@ -557,10 +577,10 @@ void MainWindow::init(void) if(x264_version_date().addMonths(6) < QDate::currentDate()) { QMessageBox msgBox(this); - msgBox.setIcon(QMessageBox::Information); + msgBox.setIconPixmap(QIcon(":/images/update.png").pixmap(56,56)); msgBox.setWindowTitle(tr("Update Notification")); msgBox.setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint); - msgBox.setText(tr("Oups, this version of 'Simple x264 Launcher' is more than 6 months old.

Please check the official web-site at %1 for updates!
").replace("-", "−").arg(home_url)); + msgBox.setText(tr("Your version of 'Simple x264 Launcher' is more than 6 months old!

Please download the most recent version from the official web-site at:
%1
").replace("-", "−").arg(update_url)); QPushButton *btn1 = msgBox.addButton(tr("Discard"), QMessageBox::NoRole); QPushButton *btn2 = msgBox.addButton(tr("Discard"), QMessageBox::AcceptRole); btn1->setEnabled(false); @@ -670,6 +690,9 @@ void MainWindow::resizeEvent(QResizeEvent *e) updateLabelPos(); } +/* + * Event filter + */ bool MainWindow::eventFilter(QObject *o, QEvent *e) { if((o == labelBuildDate) && (e->type() == QEvent::MouseButtonPress)) @@ -680,6 +703,14 @@ bool MainWindow::eventFilter(QObject *o, QEvent *e) return false; } +/* + * Win32 message filter + */ +bool MainWindow::winEvent(MSG *message, long *result) +{ + return WinSevenTaskbar::handleWinEvent(message, result); +} + /* * File dragged over window */ @@ -783,3 +814,46 @@ void MainWindow::updateButtons(EncodeThread::JobStatus status) editDetails->setEnabled(status != EncodeThread::JobStatus_Paused); } + + +void MainWindow::updateTaskbar(EncodeThread::JobStatus status, const QIcon &icon) +{ + qDebug("MainWindow::updateTaskbar(void)"); + + switch(status) + { + case EncodeThread::JobStatus_Undefined: + WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNoState); + break; + case EncodeThread::JobStatus_Aborting: + case EncodeThread::JobStatus_Starting: + case EncodeThread::JobStatus_Pausing: + case EncodeThread::JobStatus_Resuming: + WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarIndeterminateState); + break; + case EncodeThread::JobStatus_Aborted: + case EncodeThread::JobStatus_Failed: + WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarErrorState); + break; + case EncodeThread::JobStatus_Paused: + WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarPausedState); + break; + default: + WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNormalState); + break; + } + + switch(status) + { + case EncodeThread::JobStatus_Aborting: + case EncodeThread::JobStatus_Starting: + case EncodeThread::JobStatus_Pausing: + case EncodeThread::JobStatus_Resuming: + break; + default: + WinSevenTaskbar::setTaskbarProgress(this, progressBar->value(), progressBar->maximum()); + break; + } + + WinSevenTaskbar::setOverlayIcon(this, icon.isNull() ? NULL : &icon); +} diff --git a/src/win_main.h b/src/win_main.h index c001da3..8c33488 100644 --- a/src/win_main.h +++ b/src/win_main.h @@ -45,6 +45,7 @@ protected: virtual bool eventFilter(QObject *o, QEvent *e); virtual void dragEnterEvent(QDragEnterEvent *event); virtual void dropEvent(QDropEvent *event); + virtual bool winEvent(MSG *message, long *result); private: bool m_firstShow; @@ -60,6 +61,7 @@ private: const QString m_appDir; void updateButtons(EncodeThread::JobStatus status); + void updateTaskbar(EncodeThread::JobStatus status, const QIcon &icon); unsigned int countPendingJobs(void); unsigned int countRunningJobs(void); diff --git a/x264_launcher.rc b/x264_launcher.rc index f2a6f9d..7be13b0 100644 Binary files a/x264_launcher.rc and b/x264_launcher.rc differ diff --git a/x264_launcher.vcxproj b/x264_launcher.vcxproj index e44989e..4c55ad9 100644 --- a/x264_launcher.vcxproj +++ b/x264_launcher.vcxproj @@ -71,6 +71,10 @@ copy "$(SolutionDir)res\toolset\*.exe" "$(SolutionDir)bin\$(Configuration)\tools Copy Toolset + + "$(SolutionDir)etc\auto_inc.exe" VER_X264_PATCH "$(SolutionDir)src\version.h" 5 + Update Build Number + @@ -101,12 +105,10 @@ copy "$(SolutionDir)res\toolset\*.exe" "$(SolutionDir)bin\$(Configuration)\tools UseLinkTimeCodeGeneration - - + "$(SolutionDir)etc\auto_inc.exe" VER_X264_PATCH "$(SolutionDir)src\version.h" 5 - - + Update Build Number @@ -227,6 +229,7 @@ copy "$(SolutionDir)res\toolset\*.exe" "$(SolutionDir)bin\$(Configuration)\tools + "$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\moc\moc_%(Filename).cpp" "%(FullPath)" @@ -241,6 +244,7 @@ copy "$(SolutionDir)res\toolset\*.exe" "$(SolutionDir)bin\$(Configuration)\tools + diff --git a/x264_launcher.vcxproj.filters b/x264_launcher.vcxproj.filters index b6a2125..a0724a8 100644 --- a/x264_launcher.vcxproj.filters +++ b/x264_launcher.vcxproj.filters @@ -45,6 +45,9 @@ Header Files + + Header Files + @@ -101,6 +104,9 @@ Generated Files + + Source Files +