parent
c540f4f768
commit
29bccf9984
14 changed files with 21 additions and 1021 deletions
@ -1,95 +0,0 @@ |
||||
/* EcWin7 - Support library for integrating Windows 7 taskbar features
|
||||
* into any Qt application |
||||
* Copyright (C) 2010 Emanuele Colombo |
||||
* |
||||
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
*/ |
||||
|
||||
#include "ecwin7.h" |
||||
|
||||
// Windows only definitions
|
||||
#ifdef W7TASKBAR |
||||
DEFINE_GUID(CLSID_TaskbarList, 0x56fdf344, 0xfd6d, 0x11d0, 0x95, 0x8a, 0x0, 0x60, 0x97, 0xc9, 0xa0, 0x90); |
||||
DEFINE_GUID(IID_ITaskbarList3, 0xea1afb91, 0x9e28, 0x4b86, 0x90, 0xE9, 0x9e, 0x9f, 0x8a, 0x5e, 0xef, 0xaf); |
||||
|
||||
// Constructor: variabiles initialization
|
||||
EcWin7::EcWin7() |
||||
{ |
||||
mTaskbar = NULL; |
||||
mOverlayIcon = NULL; |
||||
} |
||||
|
||||
// Init taskbar communication
|
||||
void EcWin7::init(HWND wid) |
||||
{ |
||||
mWindowId = wid; |
||||
mTaskbarMessageId = RegisterWindowMessage(L"TaskbarButtonCreated"); |
||||
} |
||||
|
||||
// Windows event handler callback function
|
||||
// (handles taskbar communication initial message)
|
||||
bool EcWin7::winEvent(MSG* message, long* result) |
||||
{ |
||||
if (message->message == mTaskbarMessageId) { |
||||
HRESULT hr = CoCreateInstance(CLSID_TaskbarList, |
||||
0, |
||||
CLSCTX_INPROC_SERVER, |
||||
IID_ITaskbarList3, |
||||
reinterpret_cast<void**>(&(mTaskbar))); |
||||
*result = hr; |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
// Set progress bar current value
|
||||
void EcWin7::setProgressValue(int value, int max) |
||||
{ |
||||
mTaskbar->SetProgressValue(mWindowId, value, max); |
||||
|
||||
} |
||||
|
||||
// Set progress bar current state (active, error, pause, ecc...)
|
||||
void EcWin7::setProgressState(ToolBarProgressState state) |
||||
{ |
||||
mTaskbar->SetProgressState(mWindowId, (TBPFLAG)state); |
||||
} |
||||
|
||||
// Set new overlay icon and corresponding description (for accessibility)
|
||||
// (call with iconName == "" and description == "" to remove any previous overlay icon)
|
||||
void EcWin7::setOverlayIcon(QString iconName, QString description) |
||||
{ |
||||
HICON oldIcon = NULL; |
||||
if (mOverlayIcon != NULL) { |
||||
oldIcon = mOverlayIcon; |
||||
} |
||||
if (iconName.isEmpty()) { |
||||
mTaskbar->SetOverlayIcon(mWindowId, NULL, NULL); |
||||
mOverlayIcon = NULL; |
||||
} |
||||
else { |
||||
mOverlayIcon = (HICON) LoadImage(GetModuleHandle(NULL), |
||||
iconName.toStdWString().c_str(), |
||||
IMAGE_ICON, |
||||
0, |
||||
0, |
||||
NULL); |
||||
mTaskbar->SetOverlayIcon(mWindowId, mOverlayIcon, description.toStdWString().c_str()); |
||||
} |
||||
if ((oldIcon != NULL) && (oldIcon != mOverlayIcon)) { |
||||
DestroyIcon(oldIcon); |
||||
} |
||||
} |
||||
#endif |
||||
@ -1,76 +0,0 @@ |
||||
/* EcWin7 - Support library for integrating Windows 7 taskbar features
|
||||
* into any Qt application |
||||
* Copyright (C) 2010 Emanuele Colombo |
||||
* |
||||
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||||
*/ |
||||
|
||||
#ifndef ECWIN7_H |
||||
#define ECWIN7_H |
||||
|
||||
#include "qzcommon.h" |
||||
|
||||
#include <QtGlobal> |
||||
#include <QWidget> |
||||
|
||||
// Windows only data definitions
|
||||
#ifdef W7TASKBAR |
||||
#ifndef __MINGW32__ |
||||
#define NOMINMAX |
||||
#endif |
||||
#include <windows.h> |
||||
#include <initguid.h> |
||||
#define CMIC_MASK_ASYNCOK SEE_MASK_ASYNCOK |
||||
|
||||
#include <ShlObj.h> |
||||
#include <shlwapi.h> |
||||
#include "msvc2008.h" |
||||
|
||||
// ********************************************************************
|
||||
// EcWin7 class - Windows 7 taskbar handling for Qt and MinGW
|
||||
|
||||
class EcWin7 |
||||
{ |
||||
public: |
||||
|
||||
// Initialization methods
|
||||
EcWin7(); |
||||
void init(HWND wid); |
||||
bool winEvent(MSG* message, long* result); |
||||
|
||||
// Overlay icon handling
|
||||
void setOverlayIcon(QString iconName, QString description); |
||||
|
||||
// Progress indicator handling
|
||||
enum ToolBarProgressState { |
||||
NoProgress = 0, |
||||
Indeterminate = 1, |
||||
Normal = 2, |
||||
Error = 4, |
||||
Paused = 8 |
||||
}; |
||||
void setProgressValue(int value, int max); |
||||
void setProgressState(ToolBarProgressState state); |
||||
|
||||
private: |
||||
HWND mWindowId; |
||||
UINT mTaskbarMessageId; |
||||
ITaskbarList3* mTaskbar; |
||||
HICON mOverlayIcon; |
||||
}; |
||||
// Windows only data definitions - END
|
||||
#endif // W7TASKBAR
|
||||
|
||||
#endif // ECWIN7_H
|
||||
@ -1,318 +0,0 @@ |
||||
#ifndef MSVC2008_H |
||||
#define MSVC2008_H |
||||
|
||||
//Neccessary declarations to use new Windows 7 API with Microsoft Visual C++ 2008 compiler
|
||||
//However, it is still needed to link against newer libraries from Visual C++ 2010
|
||||
|
||||
#if (_MSC_VER >= 1500 && _MSC_VER < 1600) //Microsoft Visual C++ 2008
|
||||
|
||||
#include "rpc.h" |
||||
#include "rpcndr.h" |
||||
|
||||
#ifndef COM_NO_WINDOWS_H |
||||
#include "windows.h" |
||||
#include "ole2.h" |
||||
#endif /*COM_NO_WINDOWS_H*/ |
||||
|
||||
#ifndef __objectarray_h__ |
||||
#define __objectarray_h__ |
||||
|
||||
#pragma once |
||||
|
||||
/* Forward Declarations */ |
||||
#ifndef __IObjectArray_FWD_DEFINED__ |
||||
#define __IObjectArray_FWD_DEFINED__ |
||||
typedef interface IObjectArray IObjectArray; |
||||
#endif /* __IObjectArray_FWD_DEFINED__ */ |
||||
|
||||
|
||||
#ifndef __IObjectCollection_FWD_DEFINED__ |
||||
#define __IObjectCollection_FWD_DEFINED__ |
||||
typedef interface IObjectCollection IObjectCollection; |
||||
#endif /* __IObjectCollection_FWD_DEFINED__ */ |
||||
|
||||
/* header files for imported files */ |
||||
#include "oaidl.h" |
||||
#include "ocidl.h" |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
/*
|
||||
**************************************************************************************************** |
||||
IObjectArray |
||||
|
||||
<from ObjectArray.h> |
||||
**************************************************************************************************** |
||||
*/ |
||||
#ifndef __IObjectArray_INTERFACE_DEFINED__ |
||||
#define __IObjectArray_INTERFACE_DEFINED__ |
||||
|
||||
/* interface IObjectArray */ |
||||
/* [unique][object][uuid][helpstring] */ |
||||
|
||||
|
||||
EXTERN_C const IID IID_IObjectArray; |
||||
|
||||
MIDL_INTERFACE("92CA9DCD-5622-4bba-A805-5E9F541BD8C9") |
||||
IObjectArray : public IUnknown { |
||||
public: |
||||
virtual HRESULT STDMETHODCALLTYPE GetCount( |
||||
/* [out] */ __RPC__out UINT * pcObjects) = 0; |
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE GetAt( |
||||
/* [in] */ UINT uiIndex, |
||||
/* [in] */ __RPC__in REFIID riid, |
||||
/* [iid_is][out] */ __RPC__deref_out_opt void** ppv) = 0; |
||||
|
||||
}; |
||||
#endif /* __IObjectArray_INTERFACE_DEFINED__ */ |
||||
|
||||
|
||||
#ifndef __IObjectCollection_INTERFACE_DEFINED__ |
||||
#define __IObjectCollection_INTERFACE_DEFINED__ |
||||
|
||||
/* interface IObjectCollection */ |
||||
/* [unique][object][uuid] */ |
||||
|
||||
|
||||
EXTERN_C const IID IID_IObjectCollection; |
||||
|
||||
MIDL_INTERFACE("5632b1a4-e38a-400a-928a-d4cd63230295") |
||||
IObjectCollection : public IObjectArray { |
||||
public: |
||||
virtual HRESULT STDMETHODCALLTYPE AddObject( |
||||
/* [in] */ __RPC__in_opt IUnknown * punk) = 0; |
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE AddFromArray( |
||||
/* [in] */ __RPC__in_opt IObjectArray * poaSource) = 0; |
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE RemoveObjectAt( |
||||
/* [in] */ UINT uiIndex) = 0; |
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE Clear(void) = 0; |
||||
|
||||
}; |
||||
#endif /* __IObjectCollection_INTERFACE_DEFINED__ */ |
||||
|
||||
|
||||
/* Additional Prototypes for ALL interfaces */ |
||||
/* end of Additional Prototypes */ |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#endif |
||||
/*
|
||||
**************************************************************************************************** |
||||
ICustomDestinationList |
||||
|
||||
<from ShObjIdl.h> |
||||
**************************************************************************************************** |
||||
*/ |
||||
typedef interface ICustomDestinationList ICustomDestinationList; |
||||
|
||||
/* interface ICustomDestinationList */ |
||||
/* [unique][object][uuid] */ |
||||
|
||||
typedef /* [v1_enum] */ |
||||
enum KNOWNDESTCATEGORY { |
||||
KDC_FREQUENT = 1, |
||||
KDC_RECENT = (KDC_FREQUENT + 1) |
||||
} KNOWNDESTCATEGORY; |
||||
|
||||
|
||||
EXTERN_C const IID IID_ICustomDestinationList; |
||||
|
||||
MIDL_INTERFACE("6332debf-87b5-4670-90c0-5e57b408a49e") |
||||
ICustomDestinationList : public IUnknown { |
||||
public: |
||||
virtual HRESULT STDMETHODCALLTYPE SetAppID( |
||||
/* [string][in] */ __RPC__in_string LPCWSTR pszAppID) = 0; |
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE BeginList( |
||||
/* [out] */ __RPC__out UINT * pcMinSlots, |
||||
/* [in] */ __RPC__in REFIID riid, |
||||
/* [iid_is][out] */ __RPC__deref_out_opt void** ppv) = 0; |
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE AppendCategory( |
||||
/* [string][in] */ __RPC__in_string LPCWSTR pszCategory, |
||||
/* [in] */ __RPC__in_opt IObjectArray * poa) = 0; |
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE AppendKnownCategory( |
||||
/* [in] */ KNOWNDESTCATEGORY category) = 0; |
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE AddUserTasks( |
||||
/* [in] */ __RPC__in_opt IObjectArray * poa) = 0; |
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE CommitList(void) = 0; |
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE GetRemovedDestinations( |
||||
/* [in] */ __RPC__in REFIID riid, |
||||
/* [iid_is][out] */ __RPC__deref_out_opt void** ppv) = 0; |
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE DeleteList( |
||||
/* [string][unique][in] */ __RPC__in_opt_string LPCWSTR pszAppID) = 0; |
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE AbortList(void) = 0; |
||||
|
||||
}; |
||||
/*
|
||||
**************************************************************************************************** |
||||
CLSID_EnumerableObjectCollection + CLSID_DestinationList |
||||
|
||||
<from ShObjIdl.h> |
||||
**************************************************************************************************** |
||||
*/ |
||||
EXTERN_C const CLSID CLSID_EnumerableObjectCollection; |
||||
|
||||
#ifdef __cplusplus |
||||
|
||||
class DECLSPEC_UUID("2d3468c1-36a7-43b6-ac24-d3f02fd9607a") |
||||
EnumerableObjectCollection; |
||||
#endif |
||||
|
||||
EXTERN_C const CLSID CLSID_DestinationList; |
||||
|
||||
#ifdef __cplusplus |
||||
|
||||
class DECLSPEC_UUID("77f10cf0-3db5-4966-b520-b7c54fd35ed6") |
||||
DestinationList; |
||||
#endif |
||||
/*
|
||||
**************************************************************************************************** |
||||
ITaskbarList3 |
||||
|
||||
<from ShObjIdl.h> |
||||
**************************************************************************************************** |
||||
*/ |
||||
#define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) \ |
||||
extern "C++" { \
|
||||
inline ENUMTYPE operator | (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a) | ((int)b)); } \
|
||||
inline ENUMTYPE &operator |= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) |= ((int)b)); } \
|
||||
inline ENUMTYPE operator & (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a) & ((int)b)); } \
|
||||
inline ENUMTYPE &operator &= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) &= ((int)b)); } \
|
||||
inline ENUMTYPE operator ~ (ENUMTYPE a) { return ENUMTYPE(~((int)a)); } \
|
||||
inline ENUMTYPE operator ^ (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a) ^ ((int)b)); } \
|
||||
inline ENUMTYPE &operator ^= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) ^= ((int)b)); } \
|
||||
} |
||||
|
||||
#ifdef MIDL_PASS |
||||
typedef IUnknown* HIMAGELIST; |
||||
|
||||
#endif |
||||
typedef /* [v1_enum] */ |
||||
enum THUMBBUTTONFLAGS { |
||||
THBF_ENABLED = 0, |
||||
THBF_DISABLED = 0x1, |
||||
THBF_DISMISSONCLICK = 0x2, |
||||
THBF_NOBACKGROUND = 0x4, |
||||
THBF_HIDDEN = 0x8, |
||||
THBF_NONINTERACTIVE = 0x10 |
||||
} THUMBBUTTONFLAGS; |
||||
|
||||
DEFINE_ENUM_FLAG_OPERATORS(THUMBBUTTONFLAGS) |
||||
typedef /* [v1_enum] */ |
||||
enum THUMBBUTTONMASK { |
||||
THB_BITMAP = 0x1, |
||||
THB_ICON = 0x2, |
||||
THB_TOOLTIP = 0x4, |
||||
THB_FLAGS = 0x8 |
||||
} THUMBBUTTONMASK; |
||||
|
||||
DEFINE_ENUM_FLAG_OPERATORS(THUMBBUTTONMASK) |
||||
#include <pshpack8.h> |
||||
typedef struct THUMBBUTTON { |
||||
THUMBBUTTONMASK dwMask; |
||||
UINT iId; |
||||
UINT iBitmap; |
||||
HICON hIcon; |
||||
WCHAR szTip[ 260 ]; |
||||
THUMBBUTTONFLAGS dwFlags; |
||||
} THUMBBUTTON; |
||||
|
||||
typedef struct THUMBBUTTON* LPTHUMBBUTTON; |
||||
|
||||
#include <poppack.h> |
||||
#define THBN_CLICKED 0x1800 |
||||
|
||||
|
||||
extern RPC_IF_HANDLE __MIDL_itf_shobjidl_0000_0093_v0_0_c_ifspec; |
||||
extern RPC_IF_HANDLE __MIDL_itf_shobjidl_0000_0093_v0_0_s_ifspec; |
||||
|
||||
/* interface ITaskbarList3 */ |
||||
/* [object][uuid] */ |
||||
|
||||
typedef /* [v1_enum] */ |
||||
enum TBPFLAG { |
||||
TBPF_NOPROGRESS = 0, |
||||
TBPF_INDETERMINATE = 0x1, |
||||
TBPF_NORMAL = 0x2, |
||||
TBPF_ERROR = 0x4, |
||||
TBPF_PAUSED = 0x8 |
||||
} TBPFLAG; |
||||
|
||||
DEFINE_ENUM_FLAG_OPERATORS(TBPFLAG) |
||||
|
||||
EXTERN_C const IID IID_ITaskbarList3; |
||||
|
||||
|
||||
MIDL_INTERFACE("ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf") |
||||
ITaskbarList3 : public ITaskbarList2 { |
||||
public: |
||||
virtual HRESULT STDMETHODCALLTYPE SetProgressValue( |
||||
/* [in] */ __RPC__in HWND hwnd, |
||||
/* [in] */ ULONGLONG ullCompleted, |
||||
/* [in] */ ULONGLONG ullTotal) = 0; |
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE SetProgressState( |
||||
/* [in] */ __RPC__in HWND hwnd, |
||||
/* [in] */ TBPFLAG tbpFlags) = 0; |
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE RegisterTab( |
||||
/* [in] */ __RPC__in HWND hwndTab, |
||||
/* [in] */ __RPC__in HWND hwndMDI) = 0; |
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE UnregisterTab( |
||||
/* [in] */ __RPC__in HWND hwndTab) = 0; |
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE SetTabOrder( |
||||
/* [in] */ __RPC__in HWND hwndTab, |
||||
/* [in] */ __RPC__in HWND hwndInsertBefore) = 0; |
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE SetTabActive( |
||||
/* [in] */ __RPC__in HWND hwndTab, |
||||
/* [in] */ __RPC__in HWND hwndMDI, |
||||
/* [in] */ DWORD dwReserved) = 0; |
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE ThumbBarAddButtons( |
||||
/* [in] */ __RPC__in HWND hwnd, |
||||
/* [in] */ UINT cButtons, |
||||
/* [size_is][in] */ __RPC__in_ecount_full(cButtons) LPTHUMBBUTTON pButton) = 0; |
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE ThumbBarUpdateButtons( |
||||
/* [in] */ __RPC__in HWND hwnd, |
||||
/* [in] */ UINT cButtons, |
||||
/* [size_is][in] */ __RPC__in_ecount_full(cButtons) LPTHUMBBUTTON pButton) = 0; |
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE ThumbBarSetImageList( |
||||
/* [in] */ __RPC__in HWND hwnd, |
||||
/* [in] */ __RPC__in_opt HIMAGELIST himl) = 0; |
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE SetOverlayIcon( |
||||
/* [in] */ __RPC__in HWND hwnd, |
||||
/* [in] */ __RPC__in HICON hIcon, |
||||
/* [string][unique][in] */ __RPC__in_opt_string LPCWSTR pszDescription) = 0; |
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE SetThumbnailTooltip( |
||||
/* [in] */ __RPC__in HWND hwnd, |
||||
/* [string][unique][in] */ __RPC__in_opt_string LPCWSTR pszTip) = 0; |
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE SetThumbnailClip( |
||||
/* [in] */ __RPC__in HWND hwnd, |
||||
/* [in] */ __RPC__in RECT * prcClip) = 0; |
||||
}; |
||||
|
||||
#endif //_MSC_VER >= 1500 && _MSC_VER < 1600
|
||||
#endif // MSVC2008_H
|
||||
@ -1,423 +0,0 @@ |
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser |
||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com> |
||||
* |
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
* ============================================================ */ |
||||
/****************************************************************************
|
||||
** |
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
||||
** |
||||
** Use, modification and distribution is allowed without limitation, |
||||
** warranty, liability or support of any kind. |
||||
** |
||||
****************************************************************************/ |
||||
|
||||
#include "qtwin.h" |
||||
#include <QLibrary> |
||||
#include <QApplication> |
||||
#include <QWidget> |
||||
#include <QList> |
||||
#include "history.h" |
||||
#include "mainapplication.h" |
||||
|
||||
#ifdef Q_OS_WIN |
||||
#include <qt_windows.h> |
||||
|
||||
// Blur behind data structures
|
||||
#define DWM_BB_ENABLE 0x00000001 // fEnable has been specified
|
||||
#define DWM_BB_BLURREGION 0x00000002 // hRgnBlur has been specified
|
||||
#define DWM_BB_TRANSITIONONMAXIMIZED 0x00000004 // fTransitionOnMaximized has been specified
|
||||
#define WM_DWMCOMPOSITIONCHANGED 0x031E // Composition changed window message
|
||||
|
||||
typedef struct _DWM_BLURBEHIND { |
||||
DWORD dwFlags; |
||||
BOOL fEnable; |
||||
HRGN hRgnBlur; |
||||
BOOL fTransitionOnMaximized; |
||||
} DWM_BLURBEHIND, *PDWM_BLURBEHIND; |
||||
|
||||
typedef struct _MARGINS { |
||||
int cxLeftWidth; |
||||
int cxRightWidth; |
||||
int cyTopHeight; |
||||
int cyBottomHeight; |
||||
} MARGINS, *PMARGINS; |
||||
|
||||
typedef HRESULT(WINAPI* PtrDwmIsCompositionEnabled)(BOOL* pfEnabled); |
||||
typedef HRESULT(WINAPI* PtrDwmExtendFrameIntoClientArea)(HWND hWnd, const MARGINS* pMarInset); |
||||
typedef HRESULT(WINAPI* PtrDwmEnableBlurBehindWindow)(HWND hWnd, const DWM_BLURBEHIND* pBlurBehind); |
||||
typedef HRESULT(WINAPI* PtrDwmGetColorizationColor)(DWORD* pcrColorization, BOOL* pfOpaqueBlend); |
||||
|
||||
static PtrDwmIsCompositionEnabled pDwmIsCompositionEnabled = 0; |
||||
static PtrDwmEnableBlurBehindWindow pDwmEnableBlurBehindWindow = 0; |
||||
static PtrDwmExtendFrameIntoClientArea pDwmExtendFrameIntoClientArea = 0; |
||||
static PtrDwmGetColorizationColor pDwmGetColorizationColor = 0; |
||||
|
||||
QHash<QWidget*, bool> widgetsBlurState = QHash<QWidget*, bool>(); |
||||
|
||||
/*
|
||||
* Internal helper class that notifies windows if the |
||||
* DWM compositing state changes and updates the widget |
||||
* flags correspondingly. |
||||
*/ |
||||
class QUPZILLA_EXPORT WindowNotifier : public QWidget |
||||
{ |
||||
public: |
||||
WindowNotifier() { |
||||
winId(); |
||||
} |
||||
void addWidget(QWidget* widget) { |
||||
widgets.append(widget); |
||||
} |
||||
void removeWidget(QWidget* widget) { |
||||
widgets.removeAll(widget); |
||||
} |
||||
bool nativeEvent(const QByteArray &eventType, void* _message, long* result); |
||||
|
||||
private: |
||||
QWidgetList widgets; |
||||
}; |
||||
|
||||
static bool resolveLibs() |
||||
{ |
||||
if (!pDwmIsCompositionEnabled) { |
||||
QLibrary dwmLib(QString::fromLatin1("dwmapi")); |
||||
pDwmIsCompositionEnabled = (PtrDwmIsCompositionEnabled)dwmLib.resolve("DwmIsCompositionEnabled"); |
||||
pDwmExtendFrameIntoClientArea = (PtrDwmExtendFrameIntoClientArea)dwmLib.resolve("DwmExtendFrameIntoClientArea"); |
||||
pDwmEnableBlurBehindWindow = (PtrDwmEnableBlurBehindWindow)dwmLib.resolve("DwmEnableBlurBehindWindow"); |
||||
pDwmGetColorizationColor = (PtrDwmGetColorizationColor)dwmLib.resolve("DwmGetColorizationColor"); |
||||
} |
||||
return pDwmIsCompositionEnabled != 0; |
||||
} |
||||
|
||||
#endif |
||||
|
||||
/*!
|
||||
* Chekcs and returns true if Windows version |
||||
* currently running is Windows 7 |
||||
* |
||||
* This function is useful when you are using |
||||
* Windows7 new TaskBar API |
||||
* |
||||
*/ |
||||
bool QtWin::isRunningWindows7() |
||||
{ |
||||
#ifdef Q_OS_WIN |
||||
return QSysInfo::windowsVersion() == QSysInfo::WV_WINDOWS7; |
||||
#else |
||||
return false; |
||||
#endif |
||||
} |
||||
|
||||
/*!
|
||||
* Checks and returns true if Windows DWM composition |
||||
* is currently enabled on the system. |
||||
* |
||||
* To get live notification on the availability of |
||||
* this feature, you will currently have to |
||||
* reimplement winEvent() on your widget and listen |
||||
* for the WM_DWMCOMPOSITIONCHANGED event to occur. |
||||
* |
||||
*/ |
||||
bool QtWin::isCompositionEnabled() |
||||
{ |
||||
#ifdef Q_OS_WIN |
||||
if (resolveLibs()) { |
||||
HRESULT hr; |
||||
BOOL isEnabled = false; |
||||
hr = pDwmIsCompositionEnabled(&isEnabled); |
||||
if (SUCCEEDED(hr)) { |
||||
return isEnabled; |
||||
} |
||||
} |
||||
#endif |
||||
return false; |
||||
} |
||||
|
||||
/*!
|
||||
* Enables Blur behind on a Widget. |
||||
* |
||||
* \a enable tells if the blur should be enabled or not |
||||
*/ |
||||
bool QtWin::enableBlurBehindWindow(QWidget* widget, bool enable) |
||||
{ |
||||
Q_UNUSED(enable); |
||||
Q_UNUSED(widget); |
||||
Q_ASSERT(widget); |
||||
bool result = false; |
||||
#ifdef Q_OS_WIN |
||||
if (resolveLibs()) { |
||||
DWM_BLURBEHIND bb = {0}; |
||||
bb.fEnable = enable; |
||||
bb.dwFlags = DWM_BB_ENABLE; |
||||
bb.hRgnBlur = NULL; |
||||
|
||||
widget->setAttribute(Qt::WA_TranslucentBackground, enable); |
||||
widget->setAttribute(Qt::WA_NoSystemBackground, enable); |
||||
// Qt5: setting WA_TranslucentBackground without the following line hides the widget!!
|
||||
widget->setWindowOpacity(1); |
||||
|
||||
HRESULT hr = pDwmEnableBlurBehindWindow(hwndOfWidget(widget) , &bb); |
||||
if (SUCCEEDED(hr)) { |
||||
result = true; |
||||
windowNotifier()->addWidget(widget); |
||||
widgetsBlurState.insert(widget, true); |
||||
} |
||||
} |
||||
#endif |
||||
return result; |
||||
} |
||||
|
||||
/*!
|
||||
* ExtendFrameIntoClientArea. |
||||
* |
||||
* This controls the rendering of the frame inside the window. |
||||
* Note that passing margins of -1 (the default value) will completely |
||||
* remove the frame from the window. |
||||
* |
||||
* \note you should not call enableBlurBehindWindow before calling |
||||
* this functions |
||||
* |
||||
* \a enable tells if the blur should be enabled or not |
||||
*/ |
||||
bool QtWin::extendFrameIntoClientArea(QWidget* widget, int left, int top, int right, int bottom) |
||||
{ |
||||
|
||||
Q_ASSERT(widget); |
||||
Q_UNUSED(left); |
||||
Q_UNUSED(top); |
||||
Q_UNUSED(right); |
||||
Q_UNUSED(bottom); |
||||
Q_UNUSED(widget); |
||||
|
||||
bool result = false; |
||||
#ifdef Q_OS_WIN |
||||
if (resolveLibs()) { |
||||
QLibrary dwmLib(QString::fromLatin1("dwmapi")); |
||||
HRESULT hr; |
||||
MARGINS m = {left, right, top, bottom}; |
||||
hr = pDwmExtendFrameIntoClientArea(hwndOfWidget(widget), &m); |
||||
if (SUCCEEDED(hr)) { |
||||
result = true; |
||||
windowNotifier()->addWidget(widget); |
||||
widgetsBlurState.insert(widget, true); |
||||
} |
||||
widget->setAttribute(Qt::WA_TranslucentBackground, result); |
||||
// Qt5: setting WA_TranslucentBackground without the following line hides the widget!!
|
||||
widget->setWindowOpacity(1); |
||||
} |
||||
#endif |
||||
return result; |
||||
} |
||||
|
||||
/*!
|
||||
* Returns the current colorizationColor for the window. |
||||
* |
||||
* \a enable tells if the blur should be enabled or not |
||||
*/ |
||||
QColor QtWin::colorizationColor() |
||||
{ |
||||
QColor resultColor = QApplication::palette().window().color(); |
||||
|
||||
#ifdef Q_OS_WIN |
||||
if (resolveLibs()) { |
||||
DWORD color = 0; |
||||
BOOL opaque = FALSE; |
||||
QLibrary dwmLib(QString::fromLatin1("dwmapi")); |
||||
HRESULT hr; |
||||
hr = pDwmGetColorizationColor(&color, &opaque); |
||||
if (SUCCEEDED(hr)) { |
||||
resultColor = QColor(color); |
||||
} |
||||
} |
||||
#endif |
||||
return resultColor; |
||||
} |
||||
|
||||
#ifdef Q_OS_WIN |
||||
HWND QtWin::hwndOfWidget(const QWidget* widget) |
||||
{ |
||||
if (widget) { |
||||
return reinterpret_cast<HWND>(widget->winId()); |
||||
} |
||||
else { |
||||
return 0; |
||||
} |
||||
} |
||||
|
||||
WindowNotifier* QtWin::windowNotifier() |
||||
{ |
||||
static WindowNotifier* windowNotifierInstance = 0; |
||||
if (!windowNotifierInstance) { |
||||
windowNotifierInstance = new WindowNotifier; |
||||
} |
||||
return windowNotifierInstance; |
||||
} |
||||
|
||||
|
||||
/* Notify all enabled windows that the DWM state changed */ |
||||
bool WindowNotifier::nativeEvent(const QByteArray &eventType, void* _message, long* result) |
||||
{ |
||||
Q_UNUSED(eventType) |
||||
MSG* message = static_cast<MSG*>(_message); |
||||
if (message && message->message == WM_DWMCOMPOSITIONCHANGED) { |
||||
bool compositionEnabled = QtWin::isCompositionEnabled(); |
||||
foreach (QWidget* widget, widgets) { |
||||
if (widget) { |
||||
widget->setAttribute(Qt::WA_NoSystemBackground, compositionEnabled); |
||||
bool isBlur = widgetsBlurState.value(widget, false); |
||||
if (compositionEnabled && isBlur) { |
||||
// hack for fixing black background when enabling composition
|
||||
QtWin::enableBlurBehindWindow(widget, false); |
||||
QtWin::extendFrameIntoClientArea(widget); |
||||
} |
||||
widget->update(); |
||||
} |
||||
} |
||||
} |
||||
return QWidget::nativeEvent(eventType, _message, result); |
||||
} |
||||
|
||||
#ifdef W7API |
||||
IShellLink* QtWin::CreateShellLink(const QString &title, const QString &description, |
||||
const QString &app_path, const QString &app_args, |
||||
const QString &icon_path, int app_index) |
||||
{ |
||||
|
||||
const wchar_t* _title = reinterpret_cast<const wchar_t*>(title.utf16()); |
||||
const wchar_t* _description = reinterpret_cast<const wchar_t*>(description.utf16()); |
||||
const wchar_t* _app_path = reinterpret_cast<const wchar_t*>(app_path.utf16()); |
||||
const wchar_t* _icon_path = reinterpret_cast<const wchar_t*>(icon_path.utf16()); |
||||
const wchar_t* _app_args = reinterpret_cast<const wchar_t*>(app_args.utf16()); |
||||
|
||||
IShellLink* shell_link = NULL; |
||||
IPropertyStore* prop_store = NULL; |
||||
bool is_not_separator = (app_path.length() > 0); |
||||
|
||||
HRESULT hr = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, |
||||
reinterpret_cast<void**>(&(shell_link))); |
||||
if (SUCCEEDED(hr)) { |
||||
if (is_not_separator) { |
||||
shell_link->SetPath(_app_path); |
||||
shell_link->SetArguments(_app_args); |
||||
shell_link->SetIconLocation(_icon_path, app_index); |
||||
shell_link->SetDescription(_description); |
||||
} |
||||
|
||||
hr = shell_link->QueryInterface(IID_IPropertyStore, reinterpret_cast<void**>(&(prop_store))); |
||||
|
||||
if (SUCCEEDED(hr)) { |
||||
PROPVARIANT pv; |
||||
|
||||
if (is_not_separator) { |
||||
hr = InitPropVariantFromString(_title, &pv); |
||||
if (SUCCEEDED(hr)) { |
||||
hr = prop_store->SetValue(PKEY_Title, pv); |
||||
} |
||||
} |
||||
else { |
||||
hr = InitPropVariantFromBoolean(TRUE, &pv); |
||||
|
||||
if (SUCCEEDED(hr)) { |
||||
hr = prop_store->SetValue(PKEY_AppUserModel_IsDestListSeparator, pv); |
||||
} |
||||
} |
||||
|
||||
//Save the changes we made to the property store
|
||||
prop_store->Commit(); |
||||
prop_store->Release(); |
||||
|
||||
PropVariantClear(&pv); |
||||
} |
||||
} |
||||
return shell_link; |
||||
} |
||||
|
||||
void QtWin::populateFrequentSites(IObjectCollection* collection, const QString &appPath) |
||||
{ |
||||
History* history = mApp->history(); |
||||
QVector<HistoryEntry> mostList = history->mostVisited(6); |
||||
|
||||
foreach (const HistoryEntry &entry, mostList) { |
||||
collection->AddObject(CreateShellLink(entry.title, entry.url.toString(), appPath, QString(" " + entry.url.toEncoded()), appPath, 1)); |
||||
} |
||||
|
||||
collection->AddObject(CreateShellLink("", "", "", "", "", 0)); //Spacer
|
||||
} |
||||
|
||||
void QtWin::AddTasksToList(ICustomDestinationList* destinationList) |
||||
{ |
||||
IObjectArray* object_array; |
||||
IObjectCollection* obj_collection; |
||||
|
||||
CoCreateInstance(CLSID_EnumerableObjectCollection, NULL, |
||||
CLSCTX_INPROC, IID_IObjectCollection, reinterpret_cast<void**>(&(obj_collection))); |
||||
|
||||
obj_collection->QueryInterface(IID_IObjectArray, reinterpret_cast<void**>(&(object_array))); |
||||
|
||||
QString icons_source = qApp->applicationFilePath(); |
||||
QString app_path = qApp->applicationFilePath(); |
||||
|
||||
populateFrequentSites(obj_collection, icons_source); |
||||
|
||||
obj_collection->AddObject(CreateShellLink(tr("Open new tab"), tr("Opens a new tab if browser is running"), |
||||
app_path, "--new-tab", |
||||
icons_source, 0)); |
||||
|
||||
obj_collection->AddObject(CreateShellLink(tr("Open new window"), tr("Opens a new window if browser is running"), |
||||
app_path, "--new-window", |
||||
icons_source, 0)); |
||||
|
||||
obj_collection->AddObject(CreateShellLink(tr("Open new private window"), tr("Opens a new private window"), |
||||
app_path, "--private-browsing", |
||||
icons_source, 0)); |
||||
|
||||
obj_collection->AddObject(CreateShellLink(tr("Open download manager"), tr("Opens a download manager if browser is running"), |
||||
app_path, "--download-manager", |
||||
icons_source, 0)); |
||||
|
||||
destinationList->AddUserTasks(object_array); |
||||
|
||||
object_array->Release(); |
||||
obj_collection->Release(); |
||||
} |
||||
#endif //W7API
|
||||
#endif //Q_OS_WIN
|
||||
|
||||
void QtWin::createJumpList() |
||||
{ |
||||
#ifdef W7API |
||||
if (!isRunningWindows7()) { |
||||
return; |
||||
} |
||||
|
||||
UINT max_count = 0; |
||||
IObjectArray* objectArray; |
||||
ICustomDestinationList* destinationList; |
||||
|
||||
//create the custom jump list object
|
||||
CoCreateInstance(CLSID_DestinationList, NULL, CLSCTX_INPROC_SERVER, IID_ICustomDestinationList, |
||||
reinterpret_cast<void**>(&(destinationList))); |
||||
|
||||
//initialize list
|
||||
destinationList->BeginList(&max_count, IID_IObjectArray, reinterpret_cast<void**>(&(objectArray))); |
||||
AddTasksToList(destinationList); |
||||
|
||||
//commit list
|
||||
destinationList->CommitList(); |
||||
objectArray->Release(); |
||||
destinationList->Release(); |
||||
#endif |
||||
} |
||||
@ -1,82 +0,0 @@ |
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser |
||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com> |
||||
* |
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
* ============================================================ */ |
||||
/****************************************************************************
|
||||
** |
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
||||
** |
||||
** Use, modification and distribution is allowed without limitation, |
||||
** warranty, liability or support of any kind. |
||||
** |
||||
****************************************************************************/ |
||||
|
||||
#ifndef QTWIN_H |
||||
#define QTWIN_H |
||||
|
||||
#include "qzcommon.h" |
||||
|
||||
#include <QColor> |
||||
#include <QWidget> |
||||
#include <QSysInfo> |
||||
/**
|
||||
* This is a helper class for using the Desktop Window Manager |
||||
* functionality on Windows 7 and Windows Vista. On other platforms |
||||
* these functions will simply not do anything. |
||||
*/ |
||||
#ifdef Q_OS_WIN |
||||
// Qt5 compile issue: http://comments.gmane.org/gmane.comp.lib.qt.user/4711
|
||||
#ifndef __MINGW32__ |
||||
#define NOMINMAX |
||||
#endif |
||||
#ifdef W7API |
||||
#include <ShlObj.h> |
||||
#include <shlwapi.h> |
||||
#include <Propvarutil.h> |
||||
#include "msvc2008.h" |
||||
|
||||
DEFINE_PROPERTYKEY(PKEY_Title, 0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9, 2); |
||||
DEFINE_PROPERTYKEY(PKEY_AppUserModel_IsDestListSeparator, 0x9F4C2855, 0x9F79, 0x4B39, 0xA8, 0xD0, 0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3, 6); |
||||
#endif |
||||
#endif |
||||
class WindowNotifier; |
||||
class QUPZILLA_EXPORT QtWin : public QObject |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
static bool isRunningWindows7(); |
||||
static bool enableBlurBehindWindow(QWidget* widget, bool enable = true); |
||||
static bool extendFrameIntoClientArea(QWidget* widget, |
||||
int left = -1, int top = -1, |
||||
int right = -1, int bottom = -1); |
||||
static bool isCompositionEnabled(); |
||||
static QColor colorizationColor(); |
||||
|
||||
static void createJumpList(); |
||||
#ifdef Q_OS_WIN |
||||
static HWND hwndOfWidget(const QWidget* widget); |
||||
#endif |
||||
|
||||
private: |
||||
static WindowNotifier* windowNotifier(); |
||||
#ifdef W7API |
||||
static void populateFrequentSites(IObjectCollection* collection, const QString &appPath); |
||||
static void AddTasksToList(ICustomDestinationList* destinationList); |
||||
static IShellLink* CreateShellLink(const QString &title, const QString &description, const QString &app_path, const QString &app_args, const QString &icon_path, int app_index); |
||||
#endif |
||||
}; |
||||
|
||||
#endif // QTWIN_H
|
||||
Loading…
Reference in new issue