diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-10-24 11:21:18 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-10-24 11:27:49 (GMT) |
commit | cfa314bd0b6f6ed9285c7167948899184f6a8c12 (patch) | |
tree | b3a2f44a7041298cb237a50c12e358c902fa23d3 | |
parent | 7617e03e637cfa153d3fc5cfcb9edc709f4323e3 (diff) | |
download | swift-contrib-cfa314bd0b6f6ed9285c7167948899184f6a8c12.zip swift-contrib-cfa314bd0b6f6ed9285c7167948899184f6a8c12.tar.bz2 |
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.
-rw-r--r-- | .project | 8 | ||||
-rw-r--r-- | Swift/QtUI/QtWebView.cpp | 30 | ||||
-rw-r--r-- | Swift/QtUI/QtWebView.h | 4 |
3 files changed, 30 insertions, 12 deletions
@@ -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; }; } |