Updated avs2wav tool.
[LameXP.git] / src / WinSevenTaskbar.cpp
blob82a8d485c89759149390ceed09a833b3ba701a07
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2011 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
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.
9 //
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 ///////////////////////////////////////////////////////////////////////////////
22 #include "WinSevenTaskbar.h"
24 #include <QWidget>
25 #include <QIcon>
27 #ifdef __ITaskbarList3_INTERFACE_DEFINED__
29 ITaskbarList3 *WinSevenTaskbar::m_ptbl = NULL;
31 WinSevenTaskbar::WinSevenTaskbar(void)
35 WinSevenTaskbar::~WinSevenTaskbar(void)
39 void WinSevenTaskbar::initTaskbar(void)
41 OSVERSIONINFOW version;
42 memset(&version, 0, sizeof(OSVERSIONINFOW));
43 version.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
44 GetVersionEx(&version);
46 if(version.dwMajorVersion >= 6 && version.dwMinorVersion >= 1)
48 if(!m_ptbl)
50 ITaskbarList3 *ptbl;
51 HRESULT hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&ptbl));
53 if (SUCCEEDED(hr))
55 HRESULT hr2 = ptbl->HrInit();
56 if(SUCCEEDED(hr2))
58 m_ptbl = ptbl;
60 else
62 ptbl->Release();
63 qWarning("ITaskbarList3::HrInit() has failed.");
66 else
68 qWarning("ITaskbarList3 could not be created.");
72 else
74 qWarning("This OS doesn't support the ITaskbarList3 interface (needs NT 6.1 or later)");
78 void WinSevenTaskbar::setTaskbarState(QWidget *window, WinSevenTaskbarState state)
80 if(m_ptbl && window)
82 switch(state)
84 case WinSevenTaskbarNoState:
85 m_ptbl->SetProgressState(window->winId(), TBPF_NOPROGRESS);
86 break;
87 case WinSevenTaskbarNormalState:
88 m_ptbl->SetProgressState(window->winId(), TBPF_NORMAL);
89 break;
90 case WinSevenTaskbarIndeterminateState:
91 m_ptbl->SetProgressState(window->winId(), TBPF_INDETERMINATE);
92 break;
93 case WinSevenTaskbarErrorState:
94 m_ptbl->SetProgressState(window->winId(), TBPF_ERROR);
95 break;
96 case WinSevenTaskbarPausedState:
97 m_ptbl->SetProgressState(window->winId(), TBPF_PAUSED);
98 break;
103 void WinSevenTaskbar::setTaskbarProgress(QWidget *window, unsigned __int64 currentValue, unsigned __int64 maximumValue)
105 if(m_ptbl && window)
107 m_ptbl->SetProgressValue(window->winId(), currentValue, maximumValue);
111 void WinSevenTaskbar::setOverlayIcon(QWidget *window, QIcon *icon)
113 if(m_ptbl && window)
115 m_ptbl->SetOverlayIcon(window->winId(), (icon ? icon->pixmap(16,16).toWinHICON() : NULL), L"LameXP");
119 #endif //__ITaskbarList3_INTERFACE_DEFINED__