2011-03-15 23:14:39 +01:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
2013-02-26 12:56:11 +01:00
|
|
|
* Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
|
2011-03-15 23:14:39 +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 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/>.
|
|
|
|
* ============================================================ */
|
2011-03-02 16:57:41 +01:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
|
|
|
** 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"
|
2013-02-18 21:44:14 +01:00
|
|
|
#include <QLibrary>
|
2011-03-02 16:57:41 +01:00
|
|
|
#include <QApplication>
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QList>
|
2012-04-30 16:33:14 +02:00
|
|
|
#include "history.h"
|
2011-05-06 20:05:49 +02:00
|
|
|
#include "mainapplication.h"
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-09-03 22:48:52 +02:00
|
|
|
#ifdef Q_OS_WIN
|
2011-03-02 16:57:41 +01:00
|
|
|
#include <qt_windows.h>
|
2011-05-08 13:46:50 +02:00
|
|
|
|
2013-02-18 21:44:14 +01:00
|
|
|
// 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
|
2011-05-08 13:46:50 +02:00
|
|
|
#define WM_DWMCOMPOSITIONCHANGED 0x031E // Composition changed window message
|
|
|
|
|
2013-02-18 21:44:14 +01:00
|
|
|
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;
|
|
|
|
|
2012-08-21 20:28:38 +02:00
|
|
|
QHash<QWidget*, bool> widgetsBlurState = QHash<QWidget*, bool>();
|
2011-05-08 13:46:50 +02:00
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
/*
|
|
|
|
* Internal helper class that notifies windows if the
|
|
|
|
* DWM compositing state changes and updates the widget
|
|
|
|
* flags correspondingly.
|
|
|
|
*/
|
2012-02-29 18:33:50 +01:00
|
|
|
class QT_QUPZILLA_EXPORT WindowNotifier : public QWidget
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
|
|
|
public:
|
2011-11-06 17:01:23 +01:00
|
|
|
WindowNotifier() {
|
|
|
|
winId();
|
|
|
|
}
|
|
|
|
void addWidget(QWidget* widget) {
|
|
|
|
widgets.append(widget);
|
|
|
|
}
|
|
|
|
void removeWidget(QWidget* widget) {
|
|
|
|
widgets.removeAll(widget);
|
|
|
|
}
|
2013-01-19 23:22:30 +01:00
|
|
|
#if (QT_VERSION < 0x050000)
|
2011-11-06 17:01:23 +01:00
|
|
|
bool winEvent(MSG* message, long* result);
|
2013-01-19 23:22:30 +01:00
|
|
|
#else
|
|
|
|
bool nativeEvent(const QByteArray &eventType, void* _message, long* result);
|
|
|
|
#endif
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
QWidgetList widgets;
|
|
|
|
};
|
2013-02-18 21:44:14 +01:00
|
|
|
|
|
|
|
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
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
/*!
|
2011-05-08 13:46:50 +02:00
|
|
|
* Chekcs and returns true if Windows version
|
2011-03-15 23:14:39 +01:00
|
|
|
* currently running is Windows 7
|
|
|
|
*
|
|
|
|
* This function is useful when you are using
|
|
|
|
* Windows7 new TaskBar API
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
bool QtWin::isRunningWindows7()
|
|
|
|
{
|
2012-09-03 22:48:52 +02:00
|
|
|
#ifdef Q_OS_WIN
|
2011-05-01 22:07:57 +02:00
|
|
|
return QSysInfo::windowsVersion() == QSysInfo::WV_WINDOWS7;
|
2012-01-02 17:23:31 +01:00
|
|
|
#else
|
2011-03-17 17:03:04 +01:00
|
|
|
return false;
|
2012-01-02 17:23:31 +01:00
|
|
|
#endif
|
2011-03-15 23:14:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Checks and returns true if Windows DWM composition
|
2011-03-02 16:57:41 +01:00
|
|
|
* 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()
|
|
|
|
{
|
2012-09-03 22:48:52 +02:00
|
|
|
#ifdef Q_OS_WIN
|
2013-02-18 21:44:14 +01:00
|
|
|
if (resolveLibs()) {
|
2011-05-08 13:46:50 +02:00
|
|
|
HRESULT hr = S_OK;
|
|
|
|
BOOL isEnabled = false;
|
2013-02-18 21:44:14 +01:00
|
|
|
hr = pDwmIsCompositionEnabled(&isEnabled);
|
2011-11-06 17:01:23 +01:00
|
|
|
if (SUCCEEDED(hr)) {
|
2011-05-08 13:46:50 +02:00
|
|
|
return isEnabled;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-05-08 13:46:50 +02:00
|
|
|
}
|
2011-03-02 16:57:41 +01:00
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Enables Blur behind on a Widget.
|
|
|
|
*
|
|
|
|
* \a enable tells if the blur should be enabled or not
|
|
|
|
*/
|
2011-11-06 17:01:23 +01:00
|
|
|
bool QtWin::enableBlurBehindWindow(QWidget* widget, bool enable)
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
|
|
|
Q_UNUSED(enable);
|
|
|
|
Q_UNUSED(widget);
|
|
|
|
Q_ASSERT(widget);
|
|
|
|
bool result = false;
|
2012-09-03 22:48:52 +02:00
|
|
|
#ifdef Q_OS_WIN
|
2013-02-18 21:44:14 +01:00
|
|
|
if (resolveLibs()) {
|
2011-05-08 13:46:50 +02:00
|
|
|
DWM_BLURBEHIND bb = {0};
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
bb.fEnable = enable;
|
|
|
|
bb.dwFlags = DWM_BB_ENABLE;
|
|
|
|
bb.hRgnBlur = NULL;
|
2013-01-19 23:22:30 +01:00
|
|
|
|
2011-05-08 13:46:50 +02:00
|
|
|
widget->setAttribute(Qt::WA_TranslucentBackground, enable);
|
|
|
|
widget->setAttribute(Qt::WA_NoSystemBackground, enable);
|
2013-01-19 23:22:30 +01:00
|
|
|
// Qt5: setting WA_TranslucentBackground without the following line hides the widget!!
|
|
|
|
widget->setWindowOpacity(1);
|
|
|
|
|
2013-02-18 21:44:14 +01:00
|
|
|
hr = pDwmEnableBlurBehindWindow(hwndOfWidget(widget) , &bb);
|
2011-05-08 13:46:50 +02:00
|
|
|
if (SUCCEEDED(hr)) {
|
|
|
|
result = true;
|
|
|
|
windowNotifier()->addWidget(widget);
|
2012-08-20 21:47:43 +02:00
|
|
|
widgetsBlurState.insert(widget, true);
|
2011-05-08 13:46:50 +02:00
|
|
|
}
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
#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
|
|
|
|
*/
|
2011-11-06 17:01:23 +01:00
|
|
|
bool QtWin::extendFrameIntoClientArea(QWidget* widget, int left, int top, int right, int bottom)
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
2011-05-08 13:46:50 +02:00
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
Q_ASSERT(widget);
|
|
|
|
Q_UNUSED(left);
|
|
|
|
Q_UNUSED(top);
|
|
|
|
Q_UNUSED(right);
|
|
|
|
Q_UNUSED(bottom);
|
|
|
|
Q_UNUSED(widget);
|
|
|
|
|
|
|
|
bool result = false;
|
2012-09-03 22:48:52 +02:00
|
|
|
#ifdef Q_OS_WIN
|
2013-02-18 21:44:14 +01:00
|
|
|
if (resolveLibs()) {
|
|
|
|
QLibrary dwmLib(QString::fromLatin1("dwmapi"));
|
2011-05-08 13:46:50 +02:00
|
|
|
HRESULT hr = S_OK;
|
2012-08-30 10:46:58 +02:00
|
|
|
MARGINS m = {left, right, top, bottom};
|
2013-02-18 21:44:14 +01:00
|
|
|
hr = pDwmExtendFrameIntoClientArea(hwndOfWidget(widget), &m);
|
2011-05-08 13:46:50 +02:00
|
|
|
if (SUCCEEDED(hr)) {
|
|
|
|
result = true;
|
|
|
|
windowNotifier()->addWidget(widget);
|
2012-08-20 21:47:43 +02:00
|
|
|
widgetsBlurState.insert(widget, true);
|
2011-05-08 13:46:50 +02:00
|
|
|
}
|
|
|
|
widget->setAttribute(Qt::WA_TranslucentBackground, result);
|
2013-01-19 23:22:30 +01:00
|
|
|
// Qt5: setting WA_TranslucentBackground without the following line hides the widget!!
|
|
|
|
widget->setWindowOpacity(1);
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Returns the current colorizationColor for the window.
|
|
|
|
*
|
|
|
|
* \a enable tells if the blur should be enabled or not
|
|
|
|
*/
|
2011-05-06 20:05:49 +02:00
|
|
|
QColor QtWin::colorizationColor()
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
|
|
|
QColor resultColor = QApplication::palette().window().color();
|
2011-05-08 13:46:50 +02:00
|
|
|
|
2012-09-03 22:48:52 +02:00
|
|
|
#ifdef Q_OS_WIN
|
2013-02-18 21:44:14 +01:00
|
|
|
if (resolveLibs()) {
|
2011-05-08 13:46:50 +02:00
|
|
|
DWORD color = 0;
|
|
|
|
BOOL opaque = FALSE;
|
2013-02-18 21:44:14 +01:00
|
|
|
QLibrary dwmLib(QString::fromLatin1("dwmapi"));
|
2011-05-08 13:46:50 +02:00
|
|
|
HRESULT hr = S_OK;
|
2013-02-18 21:44:14 +01:00
|
|
|
hr = pDwmGetColorizationColor(&color, &opaque);
|
2011-11-06 17:01:23 +01:00
|
|
|
if (SUCCEEDED(hr)) {
|
2011-05-08 13:46:50 +02:00
|
|
|
resultColor = QColor(color);
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-05-08 13:46:50 +02:00
|
|
|
}
|
2011-03-02 16:57:41 +01:00
|
|
|
#endif
|
|
|
|
return resultColor;
|
|
|
|
}
|
|
|
|
|
2012-09-03 22:48:52 +02:00
|
|
|
#ifdef Q_OS_WIN
|
2013-01-19 23:22:30 +01:00
|
|
|
HWND QtWin::hwndOfWidget(const QWidget* widget)
|
|
|
|
{
|
|
|
|
if (widget) {
|
|
|
|
return reinterpret_cast<HWND>(widget->winId());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-06 17:01:23 +01:00
|
|
|
WindowNotifier* QtWin::windowNotifier()
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
2011-11-06 17:01:23 +01:00
|
|
|
static WindowNotifier* windowNotifierInstance = 0;
|
|
|
|
if (!windowNotifierInstance) {
|
2011-03-02 16:57:41 +01:00
|
|
|
windowNotifierInstance = new WindowNotifier;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-03-02 16:57:41 +01:00
|
|
|
return windowNotifierInstance;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Notify all enabled windows that the DWM state changed */
|
2013-01-19 23:22:30 +01:00
|
|
|
#if (QT_VERSION < 0x050000)
|
2011-11-06 17:01:23 +01:00
|
|
|
bool WindowNotifier::winEvent(MSG* message, long* result)
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
2013-01-19 23:22:30 +01:00
|
|
|
#else
|
|
|
|
bool WindowNotifier::nativeEvent(const QByteArray &eventType, void* _message, long* result)
|
|
|
|
{
|
|
|
|
Q_UNUSED(eventType)
|
|
|
|
MSG* message = static_cast<MSG*>(_message);
|
|
|
|
#endif
|
2011-03-02 16:57:41 +01:00
|
|
|
if (message && message->message == WM_DWMCOMPOSITIONCHANGED) {
|
|
|
|
bool compositionEnabled = QtWin::isCompositionEnabled();
|
|
|
|
foreach(QWidget * widget, widgets) {
|
|
|
|
if (widget) {
|
|
|
|
widget->setAttribute(Qt::WA_NoSystemBackground, compositionEnabled);
|
2012-08-20 21:47:43 +02:00
|
|
|
bool isBlur = widgetsBlurState.value(widget, false);
|
2012-08-21 20:28:38 +02:00
|
|
|
if (compositionEnabled && isBlur) {
|
2012-08-20 21:47:43 +02:00
|
|
|
// hack for fixing black background when enabling composition
|
|
|
|
QtWin::enableBlurBehindWindow(widget, false);
|
|
|
|
QtWin::extendFrameIntoClientArea(widget);
|
|
|
|
}
|
2011-10-09 14:51:25 +02:00
|
|
|
widget->update();
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-01-19 23:22:30 +01:00
|
|
|
#if (QT_VERSION < 0x050000)
|
2011-03-02 16:57:41 +01:00
|
|
|
return QWidget::winEvent(message, result);
|
2013-01-19 23:22:30 +01:00
|
|
|
#else
|
|
|
|
return QWidget::nativeEvent(eventType, _message, result);
|
|
|
|
#endif
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
2011-05-01 22:07:57 +02:00
|
|
|
|
2011-10-12 22:28:41 +02:00
|
|
|
#ifdef W7API
|
2011-05-01 22:07:57 +02:00
|
|
|
IShellLink* QtWin::CreateShellLink(const QString &title, const QString &description,
|
2011-11-06 17:01:23 +01:00
|
|
|
const QString &app_path, const QString &app_args,
|
|
|
|
const QString &icon_path, int app_index)
|
|
|
|
{
|
2011-05-01 22:07:57 +02:00
|
|
|
|
|
|
|
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,
|
2011-11-06 17:01:23 +01:00
|
|
|
reinterpret_cast<void**>(&(shell_link)));
|
|
|
|
if (SUCCEEDED(hr)) {
|
2011-05-01 22:07:57 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2011-11-06 17:01:23 +01:00
|
|
|
hr = shell_link->QueryInterface(IID_IPropertyStore, reinterpret_cast<void**>(&(prop_store)));
|
2011-05-01 22:07:57 +02:00
|
|
|
|
|
|
|
if (SUCCEEDED(hr)) {
|
|
|
|
PROPVARIANT pv;
|
|
|
|
|
|
|
|
if (is_not_separator) {
|
|
|
|
hr = InitPropVariantFromString(_title, &pv);
|
|
|
|
if (SUCCEEDED(hr)) {
|
|
|
|
hr = prop_store->SetValue(PKEY_Title, pv);
|
|
|
|
}
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
else {
|
2011-05-01 22:07:57 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2011-05-06 20:05:49 +02:00
|
|
|
void QtWin::populateFrequentSites(IObjectCollection* collection, const QString &appPath)
|
|
|
|
{
|
2012-07-04 11:16:38 +02:00
|
|
|
History* history = mApp->history();
|
2013-02-26 12:56:11 +01:00
|
|
|
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));
|
|
|
|
}
|
2011-05-06 20:05:49 +02:00
|
|
|
|
|
|
|
collection->AddObject(CreateShellLink("", "", "", "", "", 0)); //Spacer
|
|
|
|
}
|
2011-05-01 22:07:57 +02:00
|
|
|
|
2011-11-06 17:01:23 +01:00
|
|
|
void QtWin::AddTasksToList(ICustomDestinationList* destinationList)
|
|
|
|
{
|
2011-05-01 22:07:57 +02:00
|
|
|
IObjectArray* object_array;
|
|
|
|
IObjectCollection* obj_collection;
|
|
|
|
|
|
|
|
CoCreateInstance(CLSID_EnumerableObjectCollection, NULL,
|
2011-11-06 17:01:23 +01:00
|
|
|
CLSCTX_INPROC, IID_IObjectCollection, reinterpret_cast<void**>(&(obj_collection)));
|
2011-05-01 22:07:57 +02:00
|
|
|
|
2011-11-06 17:01:23 +01:00
|
|
|
obj_collection->QueryInterface(IID_IObjectArray, reinterpret_cast<void**>(&(object_array)));
|
2011-05-01 22:07:57 +02:00
|
|
|
|
|
|
|
QString icons_source = qApp->applicationFilePath();
|
|
|
|
QString app_path = qApp->applicationFilePath();
|
|
|
|
|
2011-05-06 20:05:49 +02:00
|
|
|
populateFrequentSites(obj_collection, icons_source);
|
|
|
|
|
2011-05-01 22:07:57 +02:00
|
|
|
obj_collection->AddObject(CreateShellLink(tr("Open new tab"), tr("Opens a new tab if browser is running"),
|
2011-11-06 17:01:23 +01:00
|
|
|
app_path, "--new-tab",
|
|
|
|
icons_source, 0));
|
2011-05-01 22:07:57 +02:00
|
|
|
|
|
|
|
obj_collection->AddObject(CreateShellLink(tr("Open new window"), tr("Opens a new window if browser is running"),
|
2011-11-06 17:01:23 +01:00
|
|
|
app_path, "--new-window",
|
|
|
|
icons_source, 0));
|
2011-05-01 22:07:57 +02:00
|
|
|
|
|
|
|
obj_collection->AddObject(CreateShellLink(tr("Open download manager"), tr("Opens a download manager if browser is running"),
|
2011-11-06 17:01:23 +01:00
|
|
|
app_path, "--download-manager",
|
|
|
|
icons_source, 0));
|
2011-05-01 22:07:57 +02:00
|
|
|
|
|
|
|
destinationList->AddUserTasks(object_array);
|
|
|
|
|
|
|
|
object_array->Release();
|
|
|
|
obj_collection->Release();
|
|
|
|
}
|
2011-10-10 20:54:11 +02:00
|
|
|
#endif //W7API
|
2012-09-03 22:48:52 +02:00
|
|
|
#endif //Q_OS_WIN
|
2011-05-01 22:07:57 +02:00
|
|
|
|
2011-11-06 17:01:23 +01:00
|
|
|
void QtWin::setupJumpList()
|
|
|
|
{
|
2011-05-06 20:05:49 +02:00
|
|
|
#ifdef W7API
|
2011-11-06 17:01:23 +01:00
|
|
|
if (!isRunningWindows7()) {
|
2011-05-01 22:07:57 +02:00
|
|
|
return;
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-05-01 22:07:57 +02:00
|
|
|
|
|
|
|
UINT max_count = 0;
|
|
|
|
IObjectArray* objectArray;
|
|
|
|
ICustomDestinationList* destinationList;
|
|
|
|
|
|
|
|
//create the custom jump list object
|
|
|
|
CoCreateInstance(CLSID_DestinationList, NULL, CLSCTX_INPROC_SERVER, IID_ICustomDestinationList,
|
2011-11-06 17:01:23 +01:00
|
|
|
reinterpret_cast<void**>(&(destinationList)));
|
2011-05-01 22:07:57 +02:00
|
|
|
|
|
|
|
//initialize list
|
2011-11-06 17:01:23 +01:00
|
|
|
destinationList->BeginList(&max_count, IID_IObjectArray, reinterpret_cast<void**>(&(objectArray)));
|
2011-05-01 22:07:57 +02:00
|
|
|
AddTasksToList(destinationList);
|
|
|
|
|
|
|
|
//commit list
|
|
|
|
destinationList->CommitList();
|
|
|
|
objectArray->Release();
|
|
|
|
destinationList->Release();
|
|
|
|
#endif
|
|
|
|
}
|