2012-02-08 00:29:47 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2013-11-03 17:08:02 +01:00
|
|
|
// Simple x264 Launcher
|
2014-01-27 19:58:24 +01:00
|
|
|
// Copyright (C) 2004-2014 LoRd_MuldeR <MuldeR2@GMX.de>
|
2012-02-08 00:29:47 +01:00
|
|
|
//
|
|
|
|
// 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 <QWidget>
|
|
|
|
#include <QIcon>
|
|
|
|
#include <ShObjIdl.h>
|
|
|
|
|
2013-11-03 18:34:20 +01:00
|
|
|
static UINT s_winMsg = 0;
|
|
|
|
static ITaskbarList3 *s_ptbl = NULL;
|
2012-02-08 00:29:47 +01:00
|
|
|
|
|
|
|
WinSevenTaskbar::WinSevenTaskbar(void)
|
|
|
|
{
|
2014-04-16 14:57:32 +02:00
|
|
|
THROW("Cannot create instance of this class!");
|
2012-02-08 00:29:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
WinSevenTaskbar::~WinSevenTaskbar(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifdef __ITaskbarList3_INTERFACE_DEFINED__
|
|
|
|
|
|
|
|
void WinSevenTaskbar::init(void)
|
|
|
|
{
|
2013-11-03 18:34:20 +01:00
|
|
|
s_winMsg = RegisterWindowMessageW(L"TaskbarButtonCreated");
|
|
|
|
s_ptbl = NULL;
|
2012-02-08 00:29:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void WinSevenTaskbar::uninit(void)
|
|
|
|
{
|
2013-11-03 18:34:20 +01:00
|
|
|
if(s_ptbl)
|
2012-02-08 00:29:47 +01:00
|
|
|
{
|
2013-11-03 18:34:20 +01:00
|
|
|
s_ptbl->Release();
|
|
|
|
s_ptbl = NULL;
|
2012-02-08 00:29:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-03 18:34:20 +01:00
|
|
|
bool WinSevenTaskbar::handleWinEvent(void *message, long *result)
|
2012-02-08 00:29:47 +01:00
|
|
|
{
|
|
|
|
bool stopEvent = false;
|
|
|
|
|
2013-11-03 18:34:20 +01:00
|
|
|
if(((MSG*)message)->message == s_winMsg)
|
2012-02-08 00:29:47 +01:00
|
|
|
{
|
2013-11-03 18:34:20 +01:00
|
|
|
if(!s_ptbl) createInterface();
|
|
|
|
*result = (s_ptbl) ? S_OK : S_FALSE;
|
2012-02-08 00:29:47 +01:00
|
|
|
stopEvent = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return stopEvent;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WinSevenTaskbar::createInterface(void)
|
|
|
|
{
|
2013-11-03 18:34:20 +01:00
|
|
|
if(!s_ptbl)
|
2012-02-08 00:29:47 +01:00
|
|
|
{
|
|
|
|
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))
|
|
|
|
{
|
2013-11-03 18:34:20 +01:00
|
|
|
s_ptbl = ptbl;
|
2012-02-08 00:29:47 +01:00
|
|
|
/*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;
|
|
|
|
|
2013-11-03 18:34:20 +01:00
|
|
|
if(s_ptbl && window)
|
2012-02-08 00:29:47 +01:00
|
|
|
{
|
|
|
|
HRESULT hr = HRESULT(-1);
|
|
|
|
|
|
|
|
switch(state)
|
|
|
|
{
|
|
|
|
case WinSevenTaskbarNoState:
|
2013-11-03 18:34:20 +01:00
|
|
|
hr = s_ptbl->SetProgressState(window->winId(), TBPF_NOPROGRESS);
|
2012-02-08 00:29:47 +01:00
|
|
|
break;
|
|
|
|
case WinSevenTaskbarNormalState:
|
2013-11-03 18:34:20 +01:00
|
|
|
hr = s_ptbl->SetProgressState(window->winId(), TBPF_NORMAL);
|
2012-02-08 00:29:47 +01:00
|
|
|
break;
|
|
|
|
case WinSevenTaskbarIndeterminateState:
|
2013-11-03 18:34:20 +01:00
|
|
|
hr = s_ptbl->SetProgressState(window->winId(), TBPF_INDETERMINATE);
|
2012-02-08 00:29:47 +01:00
|
|
|
break;
|
|
|
|
case WinSevenTaskbarErrorState:
|
2013-11-03 18:34:20 +01:00
|
|
|
hr = s_ptbl->SetProgressState(window->winId(), TBPF_ERROR);
|
2012-02-08 00:29:47 +01:00
|
|
|
break;
|
|
|
|
case WinSevenTaskbarPausedState:
|
2013-11-03 18:34:20 +01:00
|
|
|
hr = s_ptbl->SetProgressState(window->winId(), TBPF_PAUSED);
|
2012-02-08 00:29:47 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
result = SUCCEEDED(hr);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WinSevenTaskbar::setTaskbarProgress(QWidget *window, unsigned __int64 currentValue, unsigned __int64 maximumValue)
|
|
|
|
{
|
2013-11-03 18:34:20 +01:00
|
|
|
if(s_ptbl && window)
|
2012-02-08 00:29:47 +01:00
|
|
|
{
|
2013-11-03 18:34:20 +01:00
|
|
|
s_ptbl->SetProgressValue(window->winId(), currentValue, maximumValue);
|
2012-02-08 00:29:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WinSevenTaskbar::setOverlayIcon(QWidget *window, const QIcon *icon)
|
|
|
|
{
|
2013-11-03 18:34:20 +01:00
|
|
|
if(s_ptbl && window)
|
2012-02-08 00:29:47 +01:00
|
|
|
{
|
2013-11-03 18:34:20 +01:00
|
|
|
s_ptbl->SetOverlayIcon(window->winId(), (icon ? icon->pixmap(16,16).toWinHICON() : NULL), L"Simple x264 Launcher");
|
2012-02-08 00:29:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#else //__ITaskbarList3_INTERFACE_DEFINED__
|
|
|
|
|
2013-11-03 17:08:02 +01:00
|
|
|
X264_COMPILER_WARNING("ITaskbarList3 not defined. Compiling *without* support for Win7 taskbar!")
|
2012-02-08 00:29:47 +01:00
|
|
|
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__
|