From f6de3bd5a01b6f9468b0dcf32744a879e811c255 Mon Sep 17 00:00:00 2001 From: nowrep Date: Wed, 6 Feb 2013 18:17:50 +0100 Subject: [PATCH] [jsoptions] Added "Disable or change context menu" option User can now set whether sites are allowed to change or completely disable context menu. --- CHANGELOG | 1 + src/lib/other/qzsettings.cpp | 3 ++- src/lib/other/qzsettings.h | 3 ++- src/lib/preferences/jsoptions.cpp | 2 ++ src/lib/preferences/jsoptions.ui | 11 +++++++++-- src/lib/webview/webview.cpp | 10 ++++++++++ src/lib/webview/webview.h | 1 + translations/empty.ts | 4 ++++ 8 files changed, 31 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f2e529cde..53f8153c1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,7 @@ Version 1.4.0 * use .qupzilla/tmp instead of /tmp for temporary data * saving passwords should now work for much more sites * don't steal Ctrl+B/U/I shortcuts from page + * fixed scrolling to anchor in background tabs * fixed parsing UTF-8 filenames in Content-Disposition header * fixed crash with context menu in websearchbar and locationbar * fixed loading NYTimes skimmer page diff --git a/src/lib/other/qzsettings.cpp b/src/lib/other/qzsettings.cpp index 1138316c4..1199df113 100644 --- a/src/lib/other/qzsettings.cpp +++ b/src/lib/other/qzsettings.cpp @@ -1,6 +1,6 @@ /* ============================================================ * QupZilla - WebKit based browser -* Copyright (C) 2010-2012 David Rosca +* Copyright (C) 2010-2013 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 @@ -50,6 +50,7 @@ void QzSettings::loadSettings() allowJsHideMenuBar = settings.value("allowJavaScriptHideMenuBar", true).toBool(); allowJsHideStatusBar = settings.value("allowJavaScriptHideStatusBar", true).toBool(); allowJsHideToolBar = settings.value("allowJavaScriptHideToolBar", true).toBool(); + allowJsDisableContextMenu = settings.value("allowJavaScriptDisableContextMenu", true).toBool(); settings.endGroup(); settings.beginGroup("Browser-Tabs-Settings"); diff --git a/src/lib/other/qzsettings.h b/src/lib/other/qzsettings.h index 24f0620bc..8b41bfb2f 100644 --- a/src/lib/other/qzsettings.h +++ b/src/lib/other/qzsettings.h @@ -1,6 +1,6 @@ /* ============================================================ * QupZilla - WebKit based browser -* Copyright (C) 2010-2012 David Rosca +* Copyright (C) 2010-2013 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 @@ -51,6 +51,7 @@ public: bool allowJsHideMenuBar; bool allowJsHideStatusBar; bool allowJsHideToolBar; + bool allowJsDisableContextMenu; QStringList autoOpenProtocols; QStringList blockedProtocols; diff --git a/src/lib/preferences/jsoptions.cpp b/src/lib/preferences/jsoptions.cpp index 5a47205e1..a4ed15496 100644 --- a/src/lib/preferences/jsoptions.cpp +++ b/src/lib/preferences/jsoptions.cpp @@ -39,6 +39,7 @@ JsOptions::JsOptions(QWidget* parent) ui->jscanHideMenu->setChecked(settings.value("allowJavaScriptHideMenuBar", true).toBool()); ui->jscanHideStatus->setChecked(settings.value("allowJavaScriptHideStatusBar", true).toBool()); ui->jscanHideTool->setChecked(settings.value("allowJavaScriptHideToolBar", true).toBool()); + ui->jscanDisableContextMenu->setChecked(settings.value("allowJavaScriptDisableContextMenu", true).toBool()); ui->jscanAccessClipboard->setChecked(settings.value("allowJavaScriptAccessClipboard", false).toBool()); settings.endGroup(); @@ -59,6 +60,7 @@ void JsOptions::accept() settings.setValue("allowJavaScriptHideMenuBar", ui->jscanHideMenu->isChecked()); settings.setValue("allowJavaScriptHideStatusBar", ui->jscanHideStatus->isChecked()); settings.setValue("allowJavaScriptHideToolBar", ui->jscanHideTool->isChecked()); + settings.setValue("allowJavaScriptDisableContextMenu", ui->jscanDisableContextMenu->isChecked()); settings.setValue("allowJavaScriptAccessClipboard", ui->jscanAccessClipboard->isChecked()); settings.endGroup(); diff --git a/src/lib/preferences/jsoptions.ui b/src/lib/preferences/jsoptions.ui index 1c826c302..64d829a92 100644 --- a/src/lib/preferences/jsoptions.ui +++ b/src/lib/preferences/jsoptions.ui @@ -6,8 +6,8 @@ 0 0 - 214 - 261 + 240 + 286 @@ -78,6 +78,13 @@ + + + + Disable or change context menu + + + diff --git a/src/lib/webview/webview.cpp b/src/lib/webview/webview.cpp index ed3e55178..c0508485a 100644 --- a/src/lib/webview/webview.cpp +++ b/src/lib/webview/webview.cpp @@ -679,6 +679,16 @@ void WebView::showClickedFrameSource() showSource(m_clickedFrame); } +bool WebView::event(QEvent* event) +{ + if (event->type() == QEvent::ContextMenu && !qzSettings->allowJsDisableContextMenu) { + contextMenuEvent(static_cast(event)); + return true; + } + + return QWebView::event(event); +} + void WebView::printPage(QWebFrame* frame) { QPrintPreviewDialog* dialog = new QPrintPreviewDialog(this); diff --git a/src/lib/webview/webview.h b/src/lib/webview/webview.h index cdaa7a373..23e206a20 100644 --- a/src/lib/webview/webview.h +++ b/src/lib/webview/webview.h @@ -121,6 +121,7 @@ protected slots: void showClickedFrameSource(); protected: + bool event(QEvent* event); void wheelEvent(QWheelEvent* event); void mousePressEvent(QMouseEvent* event); void mouseReleaseEvent(QMouseEvent* event); diff --git a/translations/empty.ts b/translations/empty.ts index 69aad66aa..75188a258 100644 --- a/translations/empty.ts +++ b/translations/empty.ts @@ -1699,6 +1699,10 @@ Access clipboard + + Disable or change context menu + + LicenseViewer