1 ///////////////////////////////////////////////////////////////////////////////
2 // Simple x264 Launcher
3 // Copyright (C) 2004-2015 LoRd_MuldeR <MuldeR2@GMX.de>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
25 #include <MUtils/Exception.h>
35 static UINT s_winMsg = 0;
36 static ITaskbarList3 *s_ptbl = NULL;
38 WinSevenTaskbar::WinSevenTaskbar(void)
40 MUTILS_THROW("Cannot create instance of this class!");
43 WinSevenTaskbar::~WinSevenTaskbar(void)
47 ////////////////////////////////////////////////////////////
49 #ifdef __ITaskbarList3_INTERFACE_DEFINED__
51 void WinSevenTaskbar::init(void)
53 s_winMsg = RegisterWindowMessageW(L"TaskbarButtonCreated");
57 void WinSevenTaskbar::uninit(void)
66 bool WinSevenTaskbar::handleWinEvent(void *message, long *result)
68 bool stopEvent = false;
70 if(((MSG*)message)->message == s_winMsg)
72 if(!s_ptbl) createInterface();
73 *result = (s_ptbl) ? S_OK : S_FALSE;
80 void WinSevenTaskbar::createInterface(void)
84 ITaskbarList3 *ptbl = NULL;
85 HRESULT hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&ptbl));
89 HRESULT hr2 = ptbl->HrInit();
93 /*qDebug("ITaskbarList3::HrInit() succeeded.");*/
98 qWarning("ITaskbarList3::HrInit() has failed.");
103 qWarning("ITaskbarList3 could not be created.");
108 bool WinSevenTaskbar::setTaskbarState(QWidget *window, WinSevenTaskbarState state)
114 HRESULT hr = HRESULT(-1);
118 case WinSevenTaskbarNoState:
119 hr = s_ptbl->SetProgressState(window->winId(), TBPF_NOPROGRESS);
121 case WinSevenTaskbarNormalState:
122 hr = s_ptbl->SetProgressState(window->winId(), TBPF_NORMAL);
124 case WinSevenTaskbarIndeterminateState:
125 hr = s_ptbl->SetProgressState(window->winId(), TBPF_INDETERMINATE);
127 case WinSevenTaskbarErrorState:
128 hr = s_ptbl->SetProgressState(window->winId(), TBPF_ERROR);
130 case WinSevenTaskbarPausedState:
131 hr = s_ptbl->SetProgressState(window->winId(), TBPF_PAUSED);
135 result = SUCCEEDED(hr);
141 void WinSevenTaskbar::setTaskbarProgress(QWidget *window, unsigned __int64 currentValue, unsigned __int64 maximumValue)
145 s_ptbl->SetProgressValue(window->winId(), currentValue, maximumValue);
149 void WinSevenTaskbar::setOverlayIcon(QWidget *window, const QIcon *icon)
153 s_ptbl->SetOverlayIcon(window->winId(), (icon ? icon->pixmap(16,16).toWinHICON() : NULL), L"Simple x264 Launcher");
157 #else //__ITaskbarList3_INTERFACE_DEFINED__
159 X264_COMPILER_WARNING("ITaskbarList3 not defined. Compiling *without* support for Win7 taskbar!")
160 void WinSevenTaskbar::init(void) {}
161 void WinSevenTaskbar::uninit(void) {}
162 bool WinSevenTaskbar::handleWinEvent(MSG *message, long *result) { return false; }
163 void WinSevenTaskbar::createInterface(void) {}
164 bool WinSevenTaskbar::setTaskbarState(QWidget *window, WinSevenTaskbarState state) { return false; }
165 void WinSevenTaskbar::setTaskbarProgress(QWidget *window, unsigned __int64 currentValue, unsigned __int64 maximumValue) {}
166 void WinSevenTaskbar::setOverlayIcon(QWidget *window, QIcon *icon) {}
168 #endif //__ITaskbarList3_INTERFACE_DEFINED__