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

SiteInfo: Only show on non-internal pages

This commit is contained in:
David Rosca 2015-10-14 12:50:30 +02:00
parent af93ecf81e
commit 387aee12c2
5 changed files with 23 additions and 14 deletions

View File

@ -287,7 +287,7 @@ void MainMenu::webSearch()
void MainMenu::showSiteInfo()
{
if (m_window) {
if (m_window && SiteInfo::canShowSiteInfo(m_window->weView()->url())) {
SiteInfo* info = new SiteInfo(m_window->weView());
info->show();
}
@ -415,7 +415,10 @@ void MainMenu::aboutToHideEditMenu()
void MainMenu::aboutToShowToolsMenu()
{
m_actions[QSL("Tools/SiteInfo")]->setEnabled(true);
if (!m_window)
return;
m_actions[QSL("Tools/SiteInfo")]->setEnabled(SiteInfo::canShowSiteInfo(m_window->weView()->url()));
}
void MainMenu::aboutToHideToolsMenu()

View File

@ -20,6 +20,7 @@
#include "locationbar.h"
#include "tabbedwebview.h"
#include "qztools.h"
#include "siteinfo.h"
#include <QDrag>
#include <QTimer>
@ -159,9 +160,8 @@ bool SiteIcon::showPopup()
QUrl url = m_view->url();
if (url.isEmpty() || url.scheme() == QLatin1String("qupzilla")) {
if (!SiteInfo::canShowSiteInfo(url))
return false;
}
setDown(true);

View File

@ -27,6 +27,7 @@
#include "iconprovider.h"
#include "scripts.h"
#include "networkmanager.h"
#include "locationbar.h"
#include <QMenu>
#include <QMessageBox>
@ -36,14 +37,6 @@
#include <QTimer>
#include <QGraphicsPixmapItem>
QString SiteInfo::showCertInfo(const QString &string)
{
if (string.isEmpty()) {
return tr("<not set in certificate>");
}
return string;
}
SiteInfo::SiteInfo(WebView* view)
: QWidget()
, ui(new Ui::SiteInfo)
@ -141,6 +134,17 @@ SiteInfo::SiteInfo(WebView* view)
QzTools::setWmClass("Site Info", this);
}
bool SiteInfo::canShowSiteInfo(const QUrl &url)
{
if (LocationBar::convertUrlToText(url).isEmpty())
return false;
if (url.scheme() == QL1S("qupzilla") || url.scheme() == QL1S("view-source"))
return false;
return true;
}
void SiteInfo::imagesCustomContextMenuRequested(const QPoint &p)
{
QTreeWidgetItem* item = ui->treeImages->itemAt(p);

View File

@ -42,7 +42,7 @@ public:
explicit SiteInfo(WebView* view);
~SiteInfo();
static QString showCertInfo(const QString &string);
static bool canShowSiteInfo(const QUrl &url);
private slots:
void showImagePreview(QTreeWidgetItem *item);

View File

@ -678,7 +678,9 @@ void WebView::createPageContextMenu(QMenu* menu)
menu->addSeparator();
menu->addAction(QIcon::fromTheme("text-html"), tr("Show so&urce code"), this, SLOT(showSource()));
menu->addAction(QIcon::fromTheme("dialog-information"), tr("Show info ab&out site"), this, SLOT(showSiteInfo()));
if (SiteInfo::canShowSiteInfo(url()))
menu->addAction(QIcon::fromTheme("dialog-information"), tr("Show info ab&out site"), this, SLOT(showSiteInfo()));
}
void WebView::createLinkContextMenu(QMenu* menu, const WebHitTestResult &hitTest)