summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin C Meyer <ben@meyerhome.net>2008-06-24 10:01:23 (GMT)
committerBenjamin C Meyer <ben@meyerhome.net>2008-06-24 10:01:23 (GMT)
commit6b5e2c1d29b73559c6e9e9e3da5600baac7f19de (patch)
treea179ac1d91076b308d8195c0b0d27d9af596b3ea
parentf9e9dddaf3288f3cee7416ceec087ed739f0a445 (diff)
Add webkit trunk DEFINE to test new function "createStandardContextMenu" that will be added to QWebPage in Qt 4.5.0.2.0
-rw-r--r--src/webkittrunk.pri1
-rw-r--r--src/webview.cpp49
2 files changed, 29 insertions, 21 deletions
diff --git a/src/webkittrunk.pri b/src/webkittrunk.pri
index c44b7d0..3a5f417 100644
--- a/src/webkittrunk.pri
+++ b/src/webkittrunk.pri
@@ -7,6 +7,7 @@ webkit_trunk {
message(Using WebKit Trunk)
WEBKITHOME = $$(WEBKITHOME)
QT -= webkit
+ DEFINES += WEBKIT_TRUNK
debug: QMAKE_LIBDIR_FLAGS = -L$$WEBKITHOME/WebKitBuild/Debug/lib
release: QMAKE_LIBDIR_FLAGS = -L$$WEBKITHOME/WebKitBuild/Release/lib
LIBS = -lQtWebKit
diff --git a/src/webview.cpp b/src/webview.cpp
index 676b9ec..8b36119 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -247,42 +247,49 @@ WebView::WebView(QWidget* parent)
void WebView::contextMenuEvent(QContextMenuEvent *event)
{
- QMenu menu(this);
+ QMenu *menu = new QMenu(this);
QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos());
if (!r.linkUrl().isEmpty()) {
- menu.addAction(tr("Open in New &Window"), this, SLOT(openLinkInNewWindow()));
- menu.addAction(tr("Open in New &Tab"), this, SLOT(openLinkInNewTab()));
- menu.addSeparator();
- menu.addAction(tr("Save Lin&k"), this, SLOT(downloadLinkToDisk()));
- menu.addAction(tr("&Bookmark This Link"), this, SLOT(bookmarkLink()))->setData(r.linkUrl().toString());
- menu.addSeparator();
- menu.addAction(tr("&Copy Link Location"), this, SLOT(copyLinkToClipboard()));
+ menu->addAction(tr("Open in New &Window"), this, SLOT(openLinkInNewWindow()));
+ menu->addAction(tr("Open in New &Tab"), this, SLOT(openLinkInNewTab()));
+ menu->addSeparator();
+ menu->addAction(tr("Save Lin&k"), this, SLOT(downloadLinkToDisk()));
+ menu->addAction(tr("&Bookmark This Link"), this, SLOT(bookmarkLink()))->setData(r.linkUrl().toString());
+ menu->addSeparator();
+ menu->addAction(tr("&Copy Link Location"), this, SLOT(copyLinkToClipboard()));
if (page()->settings()->testAttribute(QWebSettings::DeveloperExtrasEnabled))
- menu.addAction(pageAction(QWebPage::InspectElement));
+ menu->addAction(pageAction(QWebPage::InspectElement));
}
if (!r.imageUrl().isEmpty()) {
- if (!menu.isEmpty())
- menu.addSeparator();
- menu.addAction(tr("Open Image in New &Window"), this, SLOT(openImageInNewWindow()));
- menu.addAction(tr("Open Image in New &Tab"), this, SLOT(openImageInNewTab()));
- menu.addSeparator();
- menu.addAction(tr("&Save Image"), this, SLOT(downloadImageToDisk()));
- menu.addAction(tr("&Copy Image"), this, SLOT(copyImageToClipboard()));
- menu.addAction(tr("C&opy Image Location"), this, SLOT(copyImageLocationToClipboard()))->setData(r.imageUrl().toString());
+ if (!menu->isEmpty())
+ menu->addSeparator();
+ menu->addAction(tr("Open Image in New &Window"), this, SLOT(openImageInNewWindow()));
+ menu->addAction(tr("Open Image in New &Tab"), this, SLOT(openImageInNewTab()));
+ menu->addSeparator();
+ menu->addAction(tr("&Save Image"), this, SLOT(downloadImageToDisk()));
+ menu->addAction(tr("&Copy Image"), this, SLOT(copyImageToClipboard()));
+ menu->addAction(tr("C&opy Image Location"), this, SLOT(copyImageLocationToClipboard()))->setData(r.imageUrl().toString());
}
- if (!menu.isEmpty()) {
+#ifdef WEBKIT_TRUNK // i.e. Qt 4.5, but not in Qt 4.5 yet
+ if (menu->isEmpty())
+ menu = page()->createStandardContextMenu();
+#endif
+
+ if (!menu->isEmpty()) {
if (m_page->mainWindow()->menuBar()->isHidden()) {
- menu.addSeparator();
- menu.addAction(m_page->mainWindow()->showMenuBarAction());
+ menu->addSeparator();
+ menu->addAction(m_page->mainWindow()->showMenuBarAction());
}
- menu.exec(mapToGlobal(event->pos()));
+ menu->exec(mapToGlobal(event->pos()));
+ delete menu;
return;
}
+ delete menu;
QWebView::contextMenuEvent(event);
}