void BookmarkMenu::refill() { clear(); if (isRoot()) { addAddBookmark(); addAddBookmarksList(); if (parentMenu()->actions().count() > 0) parentMenu()->addSeparator(); WebWindow *w = qobject_cast<WebWindow *>(parentMenu()->parent()); QAction *a; // bk page a = w->actionByName(QL1S("open_bookmarks_page")); parentMenu()->addAction(a); a = w->actionByName(QL1S("show_bookmarks_toolbar")); parentMenu()->addAction(a); addEditBookmarks(); if (parentMenu()->actions().count() > 0) parentMenu()->addSeparator(); } fillBookmarks(); if (!isRoot()) { if (parentMenu()->actions().count() > 0) parentMenu()->addSeparator(); addOpenFolderInTabs(); addAddBookmarksList(); } }
void WebView::contextMenuEvent(QContextMenuEvent *event) { m_contextMenuHitResult = page()->mainFrame()->hitTestContent(event->pos()); if (m_contextMenuHitResult.isContentEditable()) { // Check to see if handled by speller if (popupSpellMenu(event)) return; } WebWindow *webwin = m_parentTab->webWindow(); KMenu menu(this); KAction *sendByMailAction = new KAction(&menu); sendByMailAction->setIcon(KIcon("mail-send")); connect(sendByMailAction, SIGNAL(triggered(bool)), this, SLOT(sendByMail())); // Choose right context int resultHit = 0; if (m_contextMenuHitResult.linkUrl().isEmpty()) resultHit = WebView::EmptySelection; else resultHit = WebView::LinkSelection; if (!m_contextMenuHitResult.pixmap().isNull()) resultHit |= WebView::ImageSelection; if (m_contextMenuHitResult.isContentSelected()) resultHit = WebView::TextSelection; // -------------------------------------------------------------------------------- // Ok, let's start filling up the menu... // is content editable? Add PASTE if (m_contextMenuHitResult.isContentEditable()) { menu.addAction(pageAction(KWebPage::Paste)); menu.addSeparator(); } QAction *a; // EMPTY PAGE ACTIONS ------------------------------------------------------------- if (resultHit == WebView::EmptySelection) { // send by mail: page url sendByMailAction->setData(page()->currentFrame()->url()); sendByMailAction->setText(i18n("Share page URL")); // navigation QWebHistory *history = page()->history(); if (history->canGoBack()) { menu.addAction(pageAction(KWebPage::Back)); } if (history->canGoForward()) { menu.addAction(pageAction(KWebPage::Forward)); } menu.addAction(pageAction(KWebPage::Reload)); menu.addSeparator(); // Frame KActionMenu *frameMenu = new KActionMenu(i18n("Current Frame"), &menu); frameMenu->addAction(pageAction(KWebPage::OpenFrameInNewWindow)); a = new KAction(KIcon("document-print-frame"), i18n("Print Frame"), &menu); connect(a, SIGNAL(triggered()), m_parentTab, SLOT(printFrame())); frameMenu->addAction(a); menu.addAction(frameMenu); menu.addSeparator(); // Page Actions menu.addAction(pageAction(KWebPage::SelectAll)); if (webwin) menu.addAction(webwin->actionByName(KStandardAction::name(KStandardAction::Save))); if (!KStandardDirs::findExe("kget").isNull() && ReKonfig::kgetList()) { a = new KAction(KIcon("kget"), i18n("List All Links"), &menu); connect(a, SIGNAL(triggered(bool)), page(), SLOT(downloadAllContentsWithKGet())); menu.addAction(a); } if (webwin) { menu.addAction(webwin->actionByName("page_source")); menu.addAction(webwin->actionByName("web_inspector")); } } // LINK ACTIONS ------------------------------------------------------------------- if (resultHit & WebView::LinkSelection) { // send by mail: link url sendByMailAction->setData(m_contextMenuHitResult.linkUrl()); sendByMailAction->setText(i18n("Share link")); a = new KAction(KIcon("tab-new"), i18n("Open in New &Tab"), &menu); a->setData(m_contextMenuHitResult.linkUrl()); connect(a, SIGNAL(triggered(bool)), this, SLOT(openLinkInNewTab())); menu.addAction(a); a = new KAction(KIcon("window-new"), i18n("Open in New &Window"), &menu); a->setData(m_contextMenuHitResult.linkUrl()); connect(a, SIGNAL(triggered(bool)), this, SLOT(openLinkInNewWindow())); menu.addAction(a); if (!m_parentTab->isWebApp()) { a = new KAction(KIcon("view-media-artist"), i18n("Open in Private &Window"), &menu); a->setData(m_contextMenuHitResult.linkUrl()); connect(a, SIGNAL(triggered(bool)), this, SLOT(openLinkInPrivateWindow())); menu.addAction(a); }