From cfa314bd0b6f6ed9285c7167948899184f6a8c12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= 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 @@ org.eclipse.cdt.make.core.autoBuildTarget - check=1 QA + org.eclipse.cdt.make.core.buildArguments @@ -29,10 +29,6 @@ python - org.eclipse.cdt.make.core.buildLocation - - - org.eclipse.cdt.make.core.cleanBuildTarget -c @@ -54,7 +50,7 @@ org.eclipse.cdt.make.core.fullBuildTarget - check=1 QA + org.eclipse.cdt.make.core.stopOnError 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 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 +#include namespace Swift { class QtWebView : public QWebView { @@ -24,5 +25,8 @@ namespace Swift { protected: void focusInEvent(QFocusEvent* event); + + private: + std::vector filteredActions; }; } -- cgit v0.10.2-6-g49f6