2010-12-05 23:11:03 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// LameXP - Audio Encoder Front-End
|
2012-01-02 00:52:27 +01:00
|
|
|
// Copyright (C) 2004-2012 LoRd_MuldeR <MuldeR2@GMX.de>
|
2010-12-05 23:11:03 +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 "WinSevenTaskbar.h"
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QIcon>
|
2011-11-07 17:13:41 +01:00
|
|
|
#include <ShObjIdl.h>
|
2010-12-05 23:11:03 +01:00
|
|
|
|
2011-11-07 17:13:41 +01:00
|
|
|
UINT WinSevenTaskbar::m_winMsg = 0;
|
2010-12-05 23:11:03 +01:00
|
|
|
ITaskbarList3 *WinSevenTaskbar::m_ptbl = NULL;
|
|
|
|
|
|
|
|
WinSevenTaskbar::WinSevenTaskbar(void)
|
|
|
|
{
|
2011-11-07 17:13:41 +01:00
|
|
|
throw "Cannot create instance of this class!";
|
2010-12-05 23:11:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
WinSevenTaskbar::~WinSevenTaskbar(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-11-07 17:13:41 +01:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifdef __ITaskbarList3_INTERFACE_DEFINED__
|
|
|
|
|
|
|
|
void WinSevenTaskbar::init(void)
|
2010-12-05 23:11:03 +01:00
|
|
|
{
|
2011-11-07 17:13:41 +01:00
|
|
|
m_winMsg = RegisterWindowMessageW(L"TaskbarButtonCreated");
|
|
|
|
m_ptbl = NULL;
|
|
|
|
}
|
2010-12-05 23:11:03 +01:00
|
|
|
|
2011-11-07 17:13:41 +01:00
|
|
|
void WinSevenTaskbar::uninit(void)
|
|
|
|
{
|
|
|
|
if(m_ptbl)
|
2010-12-05 23:11:03 +01:00
|
|
|
{
|
2011-11-07 17:13:41 +01:00
|
|
|
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;
|
|
|
|
}
|
2010-12-05 23:11:03 +01:00
|
|
|
|
2011-11-07 17:13:41 +01:00
|
|
|
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))
|
2010-12-05 23:11:03 +01:00
|
|
|
{
|
2011-11-07 17:13:41 +01:00
|
|
|
m_ptbl = ptbl;
|
|
|
|
/*qDebug("ITaskbarList3::HrInit() succeeded.");*/
|
2010-12-05 23:11:03 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-07 17:13:41 +01:00
|
|
|
ptbl->Release();
|
|
|
|
qWarning("ITaskbarList3::HrInit() has failed.");
|
2010-12-05 23:11:03 +01:00
|
|
|
}
|
|
|
|
}
|
2011-11-07 17:13:41 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
qWarning("ITaskbarList3 could not be created.");
|
|
|
|
}
|
2010-12-05 23:11:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-07 17:13:41 +01:00
|
|
|
bool WinSevenTaskbar::setTaskbarState(QWidget *window, WinSevenTaskbarState state)
|
2010-12-05 23:11:03 +01:00
|
|
|
{
|
2011-11-07 17:13:41 +01:00
|
|
|
bool result = false;
|
|
|
|
|
2010-12-05 23:11:03 +01:00
|
|
|
if(m_ptbl && window)
|
|
|
|
{
|
2011-11-07 17:13:41 +01:00
|
|
|
HRESULT hr = HRESULT(-1);
|
|
|
|
|
2010-12-05 23:11:03 +01:00
|
|
|
switch(state)
|
|
|
|
{
|
|
|
|
case WinSevenTaskbarNoState:
|
2012-04-11 00:44:40 +02:00
|
|
|
hr = m_ptbl->SetProgressState(reinterpret_cast<HWND>(window->winId()), TBPF_NOPROGRESS);
|
2010-12-05 23:11:03 +01:00
|
|
|
break;
|
|
|
|
case WinSevenTaskbarNormalState:
|
2012-04-11 00:44:40 +02:00
|
|
|
hr = m_ptbl->SetProgressState(reinterpret_cast<HWND>(window->winId()), TBPF_NORMAL);
|
2010-12-05 23:11:03 +01:00
|
|
|
break;
|
|
|
|
case WinSevenTaskbarIndeterminateState:
|
2012-04-11 00:44:40 +02:00
|
|
|
hr = m_ptbl->SetProgressState(reinterpret_cast<HWND>(window->winId()), TBPF_INDETERMINATE);
|
2010-12-05 23:11:03 +01:00
|
|
|
break;
|
|
|
|
case WinSevenTaskbarErrorState:
|
2012-04-11 00:44:40 +02:00
|
|
|
hr = m_ptbl->SetProgressState(reinterpret_cast<HWND>(window->winId()), TBPF_ERROR);
|
2010-12-05 23:11:03 +01:00
|
|
|
break;
|
|
|
|
case WinSevenTaskbarPausedState:
|
2012-04-11 00:44:40 +02:00
|
|
|
hr = m_ptbl->SetProgressState(reinterpret_cast<HWND>(window->winId()), TBPF_PAUSED);
|
2010-12-05 23:11:03 +01:00
|
|
|
break;
|
|
|
|
}
|
2011-11-07 17:13:41 +01:00
|
|
|
|
|
|
|
result = SUCCEEDED(hr);
|
2010-12-05 23:11:03 +01:00
|
|
|
}
|
2011-11-07 17:13:41 +01:00
|
|
|
|
|
|
|
return result;
|
2010-12-05 23:11:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void WinSevenTaskbar::setTaskbarProgress(QWidget *window, unsigned __int64 currentValue, unsigned __int64 maximumValue)
|
|
|
|
{
|
|
|
|
if(m_ptbl && window)
|
|
|
|
{
|
2012-04-11 00:44:40 +02:00
|
|
|
m_ptbl->SetProgressValue(reinterpret_cast<HWND>(window->winId()), currentValue, maximumValue);
|
2010-12-05 23:11:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WinSevenTaskbar::setOverlayIcon(QWidget *window, QIcon *icon)
|
|
|
|
{
|
2012-04-11 00:44:40 +02:00
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
|
2010-12-05 23:11:03 +01:00
|
|
|
if(m_ptbl && window)
|
|
|
|
{
|
|
|
|
m_ptbl->SetOverlayIcon(window->winId(), (icon ? icon->pixmap(16,16).toWinHICON() : NULL), L"LameXP");
|
|
|
|
}
|
2012-04-11 00:44:40 +02:00
|
|
|
#endif
|
2010-12-05 23:11:03 +01:00
|
|
|
}
|
|
|
|
|
2011-11-07 17:13:41 +01:00
|
|
|
#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) {}
|
2011-11-07 17:29:07 +01:00
|
|
|
bool WinSevenTaskbar::setTaskbarState(QWidget *window, WinSevenTaskbarState state) { return false; }
|
2011-11-07 17:13:41 +01:00
|
|
|
void WinSevenTaskbar::setTaskbarProgress(QWidget *window, unsigned __int64 currentValue, unsigned __int64 maximumValue) {}
|
|
|
|
void WinSevenTaskbar::setOverlayIcon(QWidget *window, QIcon *icon) {}
|
|
|
|
|
|
|
|
#endif //__ITaskbarList3_INTERFACE_DEFINED__
|