1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 09:32:12 +01:00

Reimplement Windows jumplist with Qt Windows Extras

This commit is contained in:
David Rosca 2017-01-20 11:14:50 +01:00
parent 3a612c07bd
commit 67452c1bf4
2 changed files with 34 additions and 3 deletions

View File

@ -64,6 +64,12 @@
#include <QWebEngineDownloadItem>
#include <QWebEngineScriptCollection>
#ifdef Q_OS_WIN
#include <QtWin>
#include <QWinJumpList>
#include <QWinJumpListCategory>
#endif
#include <iostream>
#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<HistoryEntry> 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()
{

View File

@ -1,6 +1,6 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2016 David Rosca <nowrep@gmail.com>
* QupZilla - Qt web browser
* Copyright (C) 2010-2017 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
@ -183,6 +183,8 @@ private:
QString m_languageFile;
void createJumpList();
#if defined(Q_OS_WIN) && !defined(Q_OS_OS2)
public:
RegisterQAppAssociation* associationManager();