1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

Port StatusBarIcons plugin to QtWebEngine

Network icon is disabled.
This commit is contained in:
David Rosca 2015-05-22 18:21:28 +02:00
parent 05fcc35658
commit 4bd92d1403
8 changed files with 23 additions and 18 deletions

View File

@ -27,19 +27,19 @@ SBI_Icon::SBI_Icon(BrowserWindow* window, const QString &settingsPath)
{
}
bool SBI_Icon::testCurrentPageWebAttribute(QWebSettings::WebAttribute attr) const
bool SBI_Icon::testCurrentPageWebAttribute(QWebEngineSettings::WebAttribute attr) const
{
return currentPageSettings() && currentPageSettings()->testAttribute(attr);
}
void SBI_Icon::setCurrentPageWebAttribute(QWebSettings::WebAttribute attr, bool value)
void SBI_Icon::setCurrentPageWebAttribute(QWebEngineSettings::WebAttribute attr, bool value)
{
if (currentPageSettings()) {
currentPageSettings()->setAttribute(attr, value);
}
}
QWebSettings* SBI_Icon::currentPageSettings() const
QWebEngineSettings* SBI_Icon::currentPageSettings() const
{
if (!m_window->weView()) {
return 0;

View File

@ -18,7 +18,7 @@
#ifndef SBI_ICON_H
#define SBI_ICON_H
#include <QWebSettings>
#include <QWebEngineSettings>
#include "clickablelabel.h"
@ -33,10 +33,10 @@ public:
explicit SBI_Icon(BrowserWindow* window, const QString &settingsPath = QString());
protected:
bool testCurrentPageWebAttribute(QWebSettings::WebAttribute attr) const;
void setCurrentPageWebAttribute(QWebSettings::WebAttribute attr, bool value);
bool testCurrentPageWebAttribute(QWebEngineSettings::WebAttribute attr) const;
void setCurrentPageWebAttribute(QWebEngineSettings::WebAttribute attr, bool value);
QWebSettings* currentPageSettings() const;
QWebEngineSettings* currentPageSettings() const;
WebPage* currentPage() const;
BrowserWindow* m_window;

View File

@ -136,6 +136,7 @@ void SBI_IconsManager::mainWindowCreated(BrowserWindow* window)
m_windows[window].append(w);
}
#if QTWEBENGINE_DISABLED
if (m_showNetworkIcon) {
if (!m_networkManager) {
m_networkManager = new SBI_NetworkManager(m_settingsPath, this);
@ -145,6 +146,7 @@ void SBI_IconsManager::mainWindowCreated(BrowserWindow* window)
window->statusBar()->addPermanentWidget(w);
m_windows[window].append(w);
}
#endif
if (m_showZoomWidget) {
SBI_ZoomWidget* w = new SBI_ZoomWidget(window);

View File

@ -39,7 +39,7 @@ SBI_ImagesIcon::SBI_ImagesIcon(BrowserWindow* window, const QString &settingsPat
m_loadingImages = settings.value("LoadImages", true).toBool();
settings.endGroup();
QWebSettings::globalSettings()->setAttribute(QWebSettings::AutoLoadImages, m_loadingImages);
QWebEngineSettings::globalSettings()->setAttribute(QWebEngineSettings::AutoLoadImages, m_loadingImages);
updateIcon();
@ -55,7 +55,7 @@ void SBI_ImagesIcon::showMenu(const QPoint &point)
QMenu menu;
menu.addAction(m_icon, tr("Current Page Settings"))->setFont(boldFont);
if (testCurrentPageWebAttribute(QWebSettings::AutoLoadImages)) {
if (testCurrentPageWebAttribute(QWebEngineSettings::AutoLoadImages)) {
menu.addAction(tr("Disable loading images (temporarily)"), this, SLOT(toggleLoadingImages()));
}
else {
@ -75,8 +75,8 @@ void SBI_ImagesIcon::showMenu(const QPoint &point)
void SBI_ImagesIcon::toggleLoadingImages()
{
bool current = testCurrentPageWebAttribute(QWebSettings::AutoLoadImages);
setCurrentPageWebAttribute(QWebSettings::AutoLoadImages, !current);
bool current = testCurrentPageWebAttribute(QWebEngineSettings::AutoLoadImages);
setCurrentPageWebAttribute(QWebEngineSettings::AutoLoadImages, !current);
// We should reload page on disabling images
if (current) {
@ -96,7 +96,7 @@ void SBI_ImagesIcon::setGlobalLoadingImages(bool enable)
// Switch it in websettings
m_loadingImages = enable;
QWebSettings::globalSettings()->setAttribute(QWebSettings::AutoLoadImages, m_loadingImages);
QWebEngineSettings::globalSettings()->setAttribute(QWebEngineSettings::AutoLoadImages, m_loadingImages);
updateIcon();
// We should reload page on disabling images
@ -107,7 +107,7 @@ void SBI_ImagesIcon::setGlobalLoadingImages(bool enable)
void SBI_ImagesIcon::updateIcon()
{
if (testCurrentPageWebAttribute(QWebSettings::AutoLoadImages)) {
if (testCurrentPageWebAttribute(QWebEngineSettings::AutoLoadImages)) {
setGraphicsEffect(0);
}
else {

View File

@ -23,7 +23,7 @@
#include "jsoptions.h"
#include <QGraphicsColorizeEffect>
#include <QWebSettings>
#include <QWebEngineSettings>
#include <QMenu>
SBI_JavaScriptIcon::SBI_JavaScriptIcon(BrowserWindow* window)
@ -49,7 +49,7 @@ void SBI_JavaScriptIcon::showMenu(const QPoint &point)
QMenu menu;
menu.addAction(m_icon, tr("Current Page Settings"))->setFont(boldFont);
if (testCurrentPageWebAttribute(QWebSettings::JavascriptEnabled)) {
if (testCurrentPageWebAttribute(QWebEngineSettings::JavascriptEnabled)) {
menu.addAction(tr("Disable JavaScript (temporarily)"), this, SLOT(toggleJavaScript()));
}
else {
@ -69,7 +69,7 @@ void SBI_JavaScriptIcon::showMenu(const QPoint &point)
void SBI_JavaScriptIcon::updateIcon()
{
if (testCurrentPageWebAttribute(QWebSettings::JavascriptEnabled)) {
if (testCurrentPageWebAttribute(QWebEngineSettings::JavascriptEnabled)) {
setGraphicsEffect(0);
}
else {
@ -86,7 +86,7 @@ void SBI_JavaScriptIcon::toggleJavaScript()
}
bool current = testCurrentPageWebAttribute(QWebSettings::JavascriptEnabled);
bool current = testCurrentPageWebAttribute(QWebEngineSettings::JavascriptEnabled);
currentPage()->setJavaScriptEnabled(!current);
m_window->weView()->reload();

View File

@ -105,6 +105,7 @@ void SBI_NetworkIcon::updateToolTip()
tooltip = tooltip.arg(tr("Offline"));
}
#if QTWEBENGINE_DISABLED
switch (mApp->networkManager()->proxyFactory()->proxyPreference()) {
case NetworkProxyFactory::SystemProxy:
tooltip = tooltip.arg(tr("System proxy"));
@ -126,6 +127,7 @@ void SBI_NetworkIcon::updateToolTip()
qWarning() << "Unknown NetworkProxyFactory::ProxyPreference!";
break;
}
#endif
if (SBINetManager->currentProxy()) {
tooltip.append(QString(" (%1)").arg(SBINetManager->currentProxyName()));

View File

@ -129,7 +129,9 @@ void SBI_NetworkManager::applyCurrentProxy()
settings.endGroup();
settings.sync();
#if QTWEBENGINE_DISABLED
mApp->networkManager()->proxyFactory()->loadSettings();
#endif
}
void SBI_NetworkManager::deleteProxies()

View File

@ -48,7 +48,6 @@ disablePlugin(GreaseMonkey)
disablePlugin(MailHandle)
disablePlugin(MouseGestures)
disablePlugin(PIM)
disablePlugin(StatusBarIcons)
disablePlugin(TabManager)
disablePlugin(TestPlugin)
disablePlugin(Videoner)