From 614ac461744227d4d98dfee6d905721ff4bb611c Mon Sep 17 00:00:00 2001 From: David Rosca Date: Tue, 3 Jan 2017 16:21:16 +0100 Subject: [PATCH] WebView: Hide reload/stop actions when not available --- src/lib/webengine/webview.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/lib/webengine/webview.cpp b/src/lib/webengine/webview.cpp index 99c529d7e..ca9c02ea5 100644 --- a/src/lib/webengine/webview.cpp +++ b/src/lib/webengine/webview.cpp @@ -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 @@ -709,8 +709,20 @@ void WebView::createPageContextMenu(QMenu* menu) return; } - menu->addAction(pageAction(QWebEnginePage::Reload)); - menu->addAction(pageAction(QWebEnginePage::Stop)); + QAction *reloadAction = pageAction(QWebEnginePage::Reload); + action = menu->addAction(reloadAction->icon(), reloadAction->text(), reloadAction, &QAction::trigger); + action->setVisible(reloadAction->isEnabled()); + connect(reloadAction, &QAction::changed, action, [=]() { + action->setVisible(reloadAction->isEnabled()); + }); + + QAction *stopAction = pageAction(QWebEnginePage::Stop); + action = menu->addAction(stopAction->icon(), stopAction->text(), stopAction, &QAction::trigger); + action->setVisible(stopAction->isEnabled()); + connect(stopAction, &QAction::changed, action, [=]() { + action->setVisible(stopAction->isEnabled()); + }); + menu->addSeparator(); menu->addAction(QIcon::fromTheme("bookmark-new"), tr("Book&mark page"), this, SLOT(bookmarkLink())); menu->addAction(QIcon::fromTheme("document-save"), tr("&Save page as..."), this, SLOT(savePageAs()));