diff options
author | adjam <adjam@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-05-14 10:28:37 +0000 |
---|---|---|
committer | adjam <adjam@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-05-14 10:28:37 +0000 |
commit | ad61438a123423ce83aeecf42607244c4c1ca1a3 (patch) | |
tree | 88084ae3d4ab5e7d12d689c92a9adf9f151cec4b /src/webview.cpp | |
parent | strings fix (diff) | |
parent | updated TODO (diff) | |
download | rekonq-ad61438a123423ce83aeecf42607244c4c1ca1a3.tar.xz |
Merge branch 'master' into local-svn
git-svn-id: svn+ssh://svn.kde.org/home/kde/trunk/playground/network/rekonq@967887 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/webview.cpp')
-rw-r--r-- | src/webview.cpp | 152 |
1 files changed, 63 insertions, 89 deletions
diff --git a/src/webview.cpp b/src/webview.cpp index 055f2f7d..01fd0d00 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -290,9 +290,6 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) // ----------------------------------------------------------------------------------------------------------------- -KActionCollection* WebView::s_webActionCollection; - - WebView::WebView(QWidget* parent) : QWebView(parent) , m_page(new WebPage(this)) @@ -308,63 +305,6 @@ WebView::WebView(QWidget* parent) } -KActionCollection* WebView::webActions() -{ - if (!s_webActionCollection) - { - s_webActionCollection = new KActionCollection(this); - - QAction *a; - - a = new KAction(KIcon("tab-new"), i18n("Open Link in New &Tab"), this); - connect(a, SIGNAL(triggered()), this, SLOT(openLinkInNewTab())); - s_webActionCollection->addAction(QLatin1String("open_link_in_new_tab"), a); - - a = pageAction(QWebPage::Cut); - a->setIcon(KIcon("edit-cut")); - a->setText(i18n("Cu&t")); - s_webActionCollection->addAction(QLatin1String("edit_cut"), a); - - a = pageAction(QWebPage::Copy); - a->setIcon(KIcon("edit-copy")); - a->setText(i18n("&Copy")); - s_webActionCollection->addAction(QLatin1String("edit_copy"), a); - - a = pageAction(QWebPage::Paste); - a->setIcon(KIcon("edit-paste")); - a->setText(i18n("&Paste")); - s_webActionCollection->addAction(QLatin1String("edit_paste"), a); - - a = pageAction(QWebPage::DownloadImageToDisk); - a->setIcon(KIcon("folder-image")); - a->setText(i18n("&Save Image As...")); - s_webActionCollection->addAction(QLatin1String("save_image_as"), a); - - a = pageAction(QWebPage::CopyImageToClipboard); - a->setIcon(KIcon("insert-image")); - a->setText(i18n("&Copy This Image")); - s_webActionCollection->addAction(QLatin1String("copy_this_image"), a); - - a = pageAction(QWebPage::DownloadLinkToDisk); - a->setIcon(KIcon("folder-downloads")); - a->setText(i18n("&Save Link As...")); - s_webActionCollection->addAction(QLatin1String("save_link_as"), a); - - a = pageAction(QWebPage::CopyLinkToClipboard); - a->setIcon(KIcon("insert-link")); - a->setText(i18n("&Copy Link Location")); - s_webActionCollection->addAction(QLatin1String("copy_link_location"), a); - - a = pageAction(QWebPage::InspectElement); - a->setIcon(KIcon("tools-report-bug")); - a->setText(i18n("&Inspect Element")); - s_webActionCollection->addAction(QLatin1String("inspect_element"), a); - } - - return s_webActionCollection; -} - - void WebView::contextMenuEvent(QContextMenuEvent *event) { QWebHitTestResult result = page()->mainFrame()->hitTestContent(event->pos()); @@ -373,28 +313,62 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) QAction *addBookmarkAction = Application::bookmarkProvider()->actionByName("add_bookmark_payload"); addBookmarkAction->setText(i18n("Bookmark This Page")); addBookmarkAction->setData(QVariant()); + KMenu menu(this); + QAction *a; + // link actions + bool linkIsEmpty = result.linkUrl().isEmpty(); + if (!linkIsEmpty) + { + a = new KAction(KIcon("tab-new"), i18n("Open Link in New &Tab"), this); + connect(a, SIGNAL(triggered()), this, SLOT(openLinkInNewTab())); + menu.addAction(a); + } + else + { + menu.addAction(mainwindow->actionByName("new_tab")); + } + menu.addAction(mainwindow->actionByName("view_redisplay")); + menu.addSeparator(); + + // Developer Extras actions + if (page()->settings()->testAttribute(QWebSettings::DeveloperExtrasEnabled)) + { + a = pageAction(QWebPage::InspectElement); + a->setIcon(KIcon("tools-report-bug")); + a->setText(i18n("&Inspect Element")); + menu.addAction(a); + menu.addSeparator(); + } // cut - copy - paste Actions. - // If someone selects text perhaps wanna work with it.. bool b = false; if (result.isContentSelected() && result.isContentEditable()) { - menu.addAction(webActions()->action("edit_cut")); + a = pageAction(QWebPage::Cut); + a->setIcon(KIcon("edit-cut")); + a->setText(i18n("Cu&t")); + menu.addAction(a); b = true; } if (result.isContentSelected()) { - menu.addAction(webActions()->action("edit_copy")); + a = pageAction(QWebPage::Copy); + a->setIcon(KIcon("edit-copy")); + a->setText(i18n("&Copy")); + menu.addAction(a); b = true; } if (result.isContentEditable()) { - menu.addAction(webActions()->action("edit_paste")); + a = pageAction(QWebPage::Paste); + a->setIcon(KIcon("edit-paste")); + a->setText(i18n("&Paste")); + menu.addAction(a); b = true; } @@ -403,38 +377,34 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) menu.addSeparator(); } - // link actions - bool linkIsEmpty = result.linkUrl().isEmpty(); + // save/copy link actions if (!linkIsEmpty) { - menu.addAction(webActions()->action("open_link_in_new_tab")); - } - else - { - menu.addAction(mainwindow->actionByName("new_tab")); - } - menu.addAction(mainwindow->actionByName("view_redisplay")); - menu.addSeparator(); + a = pageAction(QWebPage::DownloadLinkToDisk); + a->setIcon(KIcon("folder-downloads")); + a->setText(i18n("&Save Link As...")); + menu.addAction(a); - // Developer Extras actions - if (page()->settings()->testAttribute(QWebSettings::DeveloperExtrasEnabled)) - { - menu.addAction(webActions()->action("inspect_element")); - menu.addSeparator(); - } + a = pageAction(QWebPage::CopyLinkToClipboard); + a->setIcon(KIcon("insert-link")); + a->setText(i18n("&Copy Link Location")); + menu.addAction(a); - // save/copy link actions - if (!linkIsEmpty) - { - menu.addAction(webActions()->action("save_link_as")); - menu.addAction(webActions()->action("copy_link_location")); menu.addSeparator(); if (!result.pixmap().isNull()) { - // TODO Add "View Image" - menu.addAction(webActions()->action("save_image_as")); - menu.addAction(webActions()->action("copy_this_image")); + // TODO Add "View Image" && remove copy_this_image action + a = pageAction(QWebPage::DownloadImageToDisk); + a->setIcon(KIcon("folder-image")); + a->setText(i18n("&Save Image As...")); + menu.addAction(a); + + a = pageAction(QWebPage::CopyImageToClipboard); + a->setIcon(KIcon("insert-image")); + a->setText(i18n("&Copy This Image")); + menu.addAction(a); + menu.addSeparator(); } } @@ -452,6 +422,11 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) menu.addAction(addBookmarkAction); } + if(mainwindow->isFullScreen()) + { + menu.addAction(mainwindow->actionByName("fullscreen")); + } + menu.exec(mapToGlobal(event->pos())); } @@ -534,4 +509,3 @@ void WebView::keyPressEvent(QKeyEvent *event) QWebView::keyPressEvent(event); } - |