From 67452c1bf41a870f24c6ecb6366ba3cc02932e3e Mon Sep 17 00:00:00 2001 From: David Rosca Date: Fri, 20 Jan 2017 11:14:50 +0100 Subject: [PATCH] Reimplement Windows jumplist with Qt Windows Extras --- src/lib/app/mainapplication.cpp | 31 ++++++++++++++++++++++++++++++- src/lib/app/mainapplication.h | 6 ++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp index b4ba2a034..b254de4c9 100644 --- a/src/lib/app/mainapplication.cpp +++ b/src/lib/app/mainapplication.cpp @@ -64,6 +64,12 @@ #include #include +#ifdef Q_OS_WIN +#include +#include +#include +#endif + #include #if defined(Q_OS_WIN) && !defined(Q_OS_OS2) @@ -675,7 +681,7 @@ void MainApplication::postLaunch() connect(this, SIGNAL(messageReceived(QString)), this, SLOT(messageReceived(QString))); connect(this, SIGNAL(aboutToQuit()), this, SLOT(saveSettings())); -// QtWin::createJumpList(); + createJumpList(); QTimer::singleShot(5000, this, &MainApplication::runDeferredPostLaunchActions); } @@ -1122,6 +1128,29 @@ void MainApplication::setUserStyleSheet(const QString &filePath) m_webProfile->scripts()->insert(script); } +void MainApplication::createJumpList() +{ +#ifdef Q_OS_WIN + QWinJumpList *jumpList = new QWinJumpList(this); + jumpList->clear(); + + // Frequent + QWinJumpListCategory *frequent = jumpList->frequent(); + frequent->setVisible(true); + const QVector mostList = m_history->mostVisited(7); + for (const HistoryEntry &entry : mostList) { + frequent->addLink(IconProvider::iconForUrl(entry.url), entry.title, applicationFilePath(), QStringList{entry.url.toEncoded()}); + } + + // Tasks + QWinJumpListCategory *tasks = jumpList->tasks(); + tasks->setVisible(true); + tasks->addLink(IconProvider::newTabIcon(), tr("Open new tab"), applicationFilePath(), {QSL("--new-tab")}); + tasks->addLink(IconProvider::newWindowIcon(), tr("Open new window"), applicationFilePath(), {QSL("--new-window")}); + tasks->addLink(IconProvider::privateBrowsingIcon(), tr("Open new private window"), applicationFilePath(), {QSL("--private-browsing")}); +#endif +} + #if defined(Q_OS_WIN) && !defined(Q_OS_OS2) RegisterQAppAssociation* MainApplication::associationManager() { diff --git a/src/lib/app/mainapplication.h b/src/lib/app/mainapplication.h index 120d62a88..549ed72a1 100644 --- a/src/lib/app/mainapplication.h +++ b/src/lib/app/mainapplication.h @@ -1,6 +1,6 @@ /* ============================================================ -* QupZilla - WebKit based browser -* Copyright (C) 2010-2016 David Rosca +* QupZilla - Qt web browser +* Copyright (C) 2010-2017 David Rosca * * 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 @@ -183,6 +183,8 @@ private: QString m_languageFile; + void createJumpList(); + #if defined(Q_OS_WIN) && !defined(Q_OS_OS2) public: RegisterQAppAssociation* associationManager();