From cfa314bd0b6f6ed9285c7167948899184f6a8c12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be> Date: Sun, 24 Oct 2010 13:21:18 +0200 Subject: Don't show 'copy link' in chat context menu if there is no link. Resolves: #554 Release-Notes: We no longer show 'copy link' in the context menu in the chat dialog if no link is selected. diff --git a/.project b/.project index 17363c7..fcdfcdc 100644 --- a/.project +++ b/.project @@ -18,7 +18,7 @@ </dictionary> <dictionary> <key>org.eclipse.cdt.make.core.autoBuildTarget</key> - <value>check=1 QA</value> + <value></value> </dictionary> <dictionary> <key>org.eclipse.cdt.make.core.buildArguments</key> @@ -29,10 +29,6 @@ <value>python</value> </dictionary> <dictionary> - <key>org.eclipse.cdt.make.core.buildLocation</key> - <value></value> - </dictionary> - <dictionary> <key>org.eclipse.cdt.make.core.cleanBuildTarget</key> <value>-c</value> </dictionary> @@ -54,7 +50,7 @@ </dictionary> <dictionary> <key>org.eclipse.cdt.make.core.fullBuildTarget</key> - <value>check=1 QA</value> + <value></value> </dictionary> <dictionary> <key>org.eclipse.cdt.make.core.stopOnError</key> diff --git a/Swift/QtUI/QtWebView.cpp b/Swift/QtUI/QtWebView.cpp index 553ac56..3aab88b 100644 --- a/Swift/QtUI/QtWebView.cpp +++ b/Swift/QtUI/QtWebView.cpp @@ -14,6 +14,9 @@ namespace Swift { QtWebView::QtWebView(QWidget* parent) : QWebView(parent) { setRenderHint(QPainter::SmoothPixmapTransform); + filteredActions.push_back(QWebPage::CopyLinkToClipboard); + filteredActions.push_back(QWebPage::CopyImageToClipboard); + filteredActions.push_back(QWebPage::Copy); } void QtWebView::keyPressEvent(QKeyEvent* event) { @@ -37,13 +40,28 @@ void QtWebView::dragEnterEvent(QDragEnterEvent*) { } void QtWebView::contextMenuEvent(QContextMenuEvent* ev) { - QMenu menu(this); - QAction* copyLinkAction = pageAction(QWebPage::CopyLinkToClipboard); - if (copyLinkAction) { - menu.addAction(copyLinkAction); + // Filter out the relevant actions from the standard actions + QMenu* menu = page()->createStandardContextMenu(); + QList<QAction*> actions(menu->actions()); + for (int i = 0; i < actions.size(); ++i) { + QAction* action = actions.at(i); + bool removeAction = true; + for(size_t j = 0; j < filteredActions.size(); ++j) { + if (action == pageAction(filteredActions[j])) { + removeAction = false; + break; + } + } + if (removeAction) { + menu->removeAction(action); + } } - menu.addAction("Clear", this, SIGNAL(clearRequested())); - menu.exec(ev->globalPos()); + + // Add our own custom actions + menu->addAction("Clear", this, SIGNAL(clearRequested())); + + menu->exec(ev->globalPos()); + delete menu; } void QtWebView::focusInEvent(QFocusEvent* event) { diff --git a/Swift/QtUI/QtWebView.h b/Swift/QtUI/QtWebView.h index f60e5ef..fbd31e3 100644 --- a/Swift/QtUI/QtWebView.h +++ b/Swift/QtUI/QtWebView.h @@ -8,6 +8,7 @@ #pragma once #include <QWebView> +#include <vector> namespace Swift { class QtWebView : public QWebView { @@ -24,5 +25,8 @@ namespace Swift { protected: void focusInEvent(QFocusEvent* event); + + private: + std::vector<QWebPage::WebAction> filteredActions; }; } -- cgit v0.10.2-6-g49f6