1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 17:52:10 +02:00

Added JumpList support for Windows 7

This commit is contained in:
nowrep 2011-05-01 22:07:57 +02:00
parent bab9f768c2
commit 26cd0d17dd
6 changed files with 143 additions and 93 deletions

74
src/3rdparty/ecwin7.h vendored
View File

@ -30,78 +30,8 @@
#include <initguid.h> #include <initguid.h>
#define CMIC_MASK_ASYNCOK SEE_MASK_ASYNCOK #define CMIC_MASK_ASYNCOK SEE_MASK_ASYNCOK
// Structs types and enums definitions for Windows 7 taskbar #include <ShlObj.h>
#include <shlwapi.h>
typedef enum THUMBBUTTONMASK
{
THB_BITMAP = 0x1,
THB_ICON = 0x2,
THB_TOOLTIP = 0x4,
THB_FLAGS = 0x8
} THUMBBUTTONMASK;
typedef enum THUMBBUTTONFLAGS
{
THBF_ENABLED = 0,
THBF_DISABLED = 0x1,
THBF_DISMISSONCLICK = 0x2,
THBF_NOBACKGROUND = 0x4,
THBF_HIDDEN = 0x8,
THBF_NONINTERACTIVE = 0x10
} THUMBBUTTONFLAGS;
typedef struct THUMBBUTTON
{
THUMBBUTTONMASK dwMask;
UINT iId;
UINT iBitmap;
HICON hIcon;
WCHAR szTip[260];
THUMBBUTTONFLAGS dwFlags;
} THUMBBUTTON;
typedef struct THUMBBUTTON *LPTHUMBBUTTON;
typedef enum TBPFLAG
{
TBPF_NOPROGRESS = 0,
TBPF_INDETERMINATE = 0x1,
TBPF_NORMAL = 0x2,
TBPF_ERROR = 0x4,
TBPF_PAUSED = 0x8
} TBPFLAG;
typedef IUnknown *HIMAGELIST;
// Taskbar interface
DECLARE_INTERFACE_(ITaskbarList3,IUnknown)
{
// IUnknown
STDMETHOD(QueryInterface) (THIS_ REFIID riid,void **ppv) PURE;
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
STDMETHOD_(ULONG,Release) (THIS) PURE;
// ITaskbarList
STDMETHOD(HrInit) (THIS) PURE;
STDMETHOD(AddTab) (THIS_ HWND hwnd) PURE;
STDMETHOD(DeleteTab) (THIS_ HWND hwnd) PURE;
STDMETHOD(ActivateTab) (THIS_ HWND hwnd) PURE;
STDMETHOD(SetActiveAlt) (THIS_ HWND hwnd) PURE;
STDMETHOD (MarkFullscreenWindow) (THIS_ HWND hwnd, int fFullscreen) PURE;
// ITaskbarList3
STDMETHOD (SetProgressValue) (THIS_ HWND hwnd, ULONGLONG ullCompleted, ULONGLONG ullTotal) PURE;
STDMETHOD (SetProgressState) (THIS_ HWND hwnd, TBPFLAG tbpFlags) PURE;
STDMETHOD (RegisterTab) (THIS_ HWND hwndTab,HWND hwndMDI) PURE;
STDMETHOD (UnregisterTab) (THIS_ HWND hwndTab) PURE;
STDMETHOD (SetTabOrder) (THIS_ HWND hwndTab, HWND hwndInsertBefore) PURE;
STDMETHOD (SetTabActive) (THIS_ HWND hwndTab, HWND hwndMDI, DWORD dwReserved) PURE;
STDMETHOD (ThumbBarAddButtons) (THIS_ HWND hwnd, UINT cButtons, LPTHUMBBUTTON pButton) PURE;
STDMETHOD (ThumbBarUpdateButtons) (THIS_ HWND hwnd, UINT cButtons, LPTHUMBBUTTON pButton) PURE;
STDMETHOD (ThumbBarSetImageList) (THIS_ HWND hwnd, HIMAGELIST himl) PURE;
STDMETHOD (SetOverlayIcon) (THIS_ HWND hwnd, HICON hIcon, LPCWSTR pszDescription) PURE;
STDMETHOD (SetThumbnailTooltip) (THIS_ HWND hwnd, LPCWSTR pszTip) PURE;
STDMETHOD (SetThumbnailClip) (THIS_ HWND hwnd, RECT *prcClip) PURE;
};
typedef ITaskbarList3 *LPITaskbarList3;
// ******************************************************************** // ********************************************************************
// EcWin7 class - Windows 7 taskbar handling for Qt and MinGW // EcWin7 class - Windows 7 taskbar handling for Qt and MinGW

117
src/3rdparty/qtwin.cpp vendored
View File

@ -32,7 +32,6 @@
#include <QPointer> #include <QPointer>
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
#include <qt_windows.h> #include <qt_windows.h>
// Blur behind data structures // Blur behind data structures
@ -110,14 +109,7 @@ static bool resolveLibs()
bool QtWin::isRunningWindows7() bool QtWin::isRunningWindows7()
{ {
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
OSVERSIONINFO osvi; return QSysInfo::windowsVersion() == QSysInfo::WV_WINDOWS7;
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osvi);
return ( (osvi.dwMajorVersion > 6) || ( (osvi.dwMajorVersion == 6) && (osvi.dwMinorVersion >= 1) ));
#endif #endif
return false; return false;
} }
@ -262,4 +254,111 @@ bool WindowNotifier::winEvent(MSG *message, long *result)
} }
return QWidget::winEvent(message, result); return QWidget::winEvent(message, result);
} }
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::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();
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 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 #endif
void QtWin::setupJumpList() {
#ifdef Q_WS_WIN
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
}

19
src/3rdparty/qtwin.h vendored
View File

@ -29,16 +29,25 @@
#include <QColor> #include <QColor>
#include <QWidget> #include <QWidget>
#include <QSysInfo>
/** /**
* This is a helper class for using the Desktop Window Manager * This is a helper class for using the Desktop Window Manager
* functionality on Windows 7 and Windows Vista. On other platforms * functionality on Windows 7 and Windows Vista. On other platforms
* these functions will simply not do anything. * these functions will simply not do anything.
*/ */
#ifdef Q_WS_WIN
#include <ShlObj.h>
#include <shlwapi.h>
#include <Propvarutil.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
class WindowNotifier; class WindowNotifier;
class QtWin : public QObject
class QtWin
{ {
Q_OBJECT
public: public:
static bool isRunningWindows7(); static bool isRunningWindows7();
static bool enableBlurBehindWindow(QWidget *widget, bool enable = true); static bool enableBlurBehindWindow(QWidget *widget, bool enable = true);
@ -48,8 +57,14 @@ public:
static bool isCompositionEnabled(); static bool isCompositionEnabled();
static QColor colorizatinColor(); static QColor colorizatinColor();
static void setupJumpList();
private: private:
static WindowNotifier *windowNotifier(); static WindowNotifier *windowNotifier();
#ifdef Q_WS_WIN
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 #endif // QTWIN_H

View File

@ -36,6 +36,7 @@
#include "adblockmanager.h" #include "adblockmanager.h"
#include "desktopnotificationsfactory.h" #include "desktopnotificationsfactory.h"
#include "iconprovider.h" #include "iconprovider.h"
#include "qtwin.h"
MainApplication::MainApplication(int &argc, char **argv) MainApplication::MainApplication(int &argc, char **argv)
: QtSingleApplication("QupZillaWebBrowser", argc, argv) : QtSingleApplication("QupZillaWebBrowser", argc, argv)
@ -156,6 +157,8 @@ MainApplication::MainApplication(int &argc, char **argv)
loadSettings(); loadSettings();
QTimer::singleShot(2000, this, SLOT(restoreCursor())); QTimer::singleShot(2000, this, SLOT(restoreCursor()));
QtWin::setupJumpList();
} }
void MainApplication::loadSettings() void MainApplication::loadSettings()
@ -204,7 +207,7 @@ void MainApplication::loadSettings()
#ifdef Q_WS_X11 #ifdef Q_WS_X11
m_websettings->setWebGraphic(QWebSettings::DefaultFrameIconGraphic, QIcon::fromTheme("text-plain").pixmap(16,16)); m_websettings->setWebGraphic(QWebSettings::DefaultFrameIconGraphic, QIcon::fromTheme("text-plain").pixmap(16,16));
#else #else
m_websettings->setWebGraphic(QWebSettings::DefaultFrameIconGraphic, QPixmap(":icons/locationbar/unknownpage.png"); m_websettings->setWebGraphic(QWebSettings::DefaultFrameIconGraphic, QPixmap(":icons/locationbar/unknownpage.png"));
#endif #endif
if (allowPersistentStorage) m_websettings->enablePersistentStorage(m_activeProfil); if (allowPersistentStorage) m_websettings->enablePersistentStorage(m_activeProfil);

View File

@ -53,7 +53,8 @@ DownloadManager::DownloadManager(QWidget* parent) :
connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clearList())); connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clearList()));
#ifdef W7API #ifdef W7API
win7.init(this->winId()); if (QtWin::isRunningWindows7())
win7.init(this->winId());
#endif #endif
} }
@ -107,8 +108,10 @@ void DownloadManager::timerEvent(QTimerEvent* event)
DownloadItem::remaingTimeToString(remaining))); DownloadItem::remaingTimeToString(remaining)));
setWindowTitle(QString::number(progress) + tr("% - Download Manager")); setWindowTitle(QString::number(progress) + tr("% - Download Manager"));
#ifdef W7API #ifdef W7API
win7.setProgressValue(progress, 100); if (QtWin::isRunningWindows7()) {
win7.setProgressState(win7.Normal); win7.setProgressValue(progress, 100);
win7.setProgressState(win7.Normal);
}
#endif #endif
} else } else
QWidget::timerEvent(event); QWidget::timerEvent(event);
@ -219,8 +222,10 @@ void DownloadManager::downloadFinished(bool success)
ui->speedLabel->clear(); ui->speedLabel->clear();
setWindowTitle(tr("Download Manager")); setWindowTitle(tr("Download Manager"));
#ifdef W7API #ifdef W7API
win7.setProgressValue(0, 0); if (QtWin::isRunningWindows7()) {
win7.setProgressState(win7.Normal); win7.setProgressValue(0, 0);
win7.setProgressState(win7.Normal);
}
#endif #endif
} }
} }

View File

@ -114,8 +114,7 @@ void HistorySideBar::historyEntryAdded(const HistoryModel::HistoryEntry &entry)
item->setText(0, entry.title); item->setText(0, entry.title);
item->setText(1, entry.url.toEncoded()); item->setText(1, entry.url.toEncoded());
item->setToolTip(0, entry.title); item->setToolTip(0, entry.url.toEncoded());
item->setToolTip(1, entry.url.toEncoded());
item->setWhatsThis(1, QString::number(entry.id)); item->setWhatsThis(1, QString::number(entry.id));
item->setIcon(0, _iconForUrl(entry.url)); item->setIcon(0, _iconForUrl(entry.url));
@ -201,8 +200,7 @@ void HistorySideBar::refreshTable()
item->setText(0, title); item->setText(0, title);
item->setText(1, url.toEncoded()); item->setText(1, url.toEncoded());
item->setToolTip(0, title); item->setToolTip(0, url.toEncoded());
item->setToolTip(1, url.toEncoded());
item->setWhatsThis(1, QString::number(id)); item->setWhatsThis(1, QString::number(id));
item->setIcon(0, _iconForUrl(url)); item->setIcon(0, _iconForUrl(url));