void MainWindow::openPrevious(Qt::MouseButtons mouseButtons, Qt::KeyboardModifiers keyboardModifiers) { QWebHistory *history = currentTab()->view()->history(); QWebHistoryItem *item = 0; if (currentTab()->page()->isOnRekonqPage()) { item = new QWebHistoryItem(history->currentItem()); } else { if (history->canGoBack()) { item = new QWebHistoryItem(history->backItem()); } } if(!item) return; if (mouseButtons == Qt::MidButton || keyboardModifiers == Qt::ControlModifier) { Application::instance()->loadUrl(item->url(), Rekonq::NewTab); } else { history->goToItem(*item); } updateActions(); }
void NavigationBar::goBackInNewTab() { QWebHistory* history = m_window->weView()->page()->history(); if (!history->canGoBack()) { return; } loadHistoryItemInNewTab(history->backItem()); }
void NavigationBar::refreshHistory() { if (mApp->isClosing() || !m_window->weView()) { return; } QWebHistory* history = m_window->weView()->page()->history(); m_buttonBack->setEnabled(history->canGoBack()); m_buttonForward->setEnabled(history->canGoForward()); }
void NavigationBar::refreshHistory() { if (mApp->isClosing() || p_QupZilla->isClosing()) { return; } QWebHistory* history = p_QupZilla->weView()->page()->history(); m_buttonBack->setEnabled(history->canGoBack()); m_buttonNext->setEnabled(history->canGoForward()); }
void WebView::back() { QWebHistory* history = page()->history(); if (history->canGoBack()) { history->back(); emit urlChanged(url()); emit iconChanged(); } }
void NavigationBar::goBackInNewTab() { QWebHistory* history = p_QupZilla->weView()->page()->history(); if (!history->canGoBack()) { return; } int itemIndex = WebHistoryWrapper::indexOfItem(history->items(), history->backItem()); if (itemIndex == -1) { return; } goAtHistoryIndexInNewTab(itemIndex); }
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); }
void MyTextBrowser::moveContent(int pos) { if(pos >= '\t' || pos < 0) { activateWindow(); char text[16]; text[0] = pos & 0x0ff; text[1] = '\0'; int modifiers = pos & 0x07fffff00; int key = pos & 0x0ff; if ((pos & 0x0ff) == '\t') key = Qt::Key_Tab; else if((pos & 0x0ff) == 0x0d) key = Qt::Key_Return; QKeyEvent pressEvent( QEvent::KeyPress, (Qt::Key) key, (Qt::KeyboardModifiers) modifiers, text); QKeyEvent releaseEvent(QEvent::KeyRelease, (Qt::Key) key, (Qt::KeyboardModifiers) modifiers, text); if((pos & 0x0ff) == '\t') QWidget::setFocus(Qt::TabFocusReason); keyPressEvent(&pressEvent); keyReleaseEvent(&releaseEvent); return; } #ifdef NO_WEBKIT char buf[MAX_PRINTF_LENGTH]; QString myurl; if(opt.arg_debug) printf("moveContent(%d)\n", pos); if (pos == 0 && homeIsSet) { myurl = home; setSource(QUrl(home)); } else if(pos == 1) { forward(); myurl = source().path(); } else if(pos == 2) { backward(); myurl = source().path(); } else if(pos == 3) { reload(); myurl = source().path(); } #else char buf[MAX_PRINTF_LENGTH]; QString myurl; QWebHistory *hist; if(opt.arg_debug) printf("moveContent(%d)\n", pos); if (pos == 0 && homeIsSet) { myurl = home; load(home); } else if(pos == 1) { hist = history(); if(hist != NULL && hist->canGoForward()) myurl = hist->forwardItem().url().toString(); forward(); } else if(pos == 2) { hist = history(); if(hist != NULL && hist->canGoBack()) myurl = hist->backItem().url().toString(); back(); } else if(pos == 3) { hist = history(); if(hist != NULL) myurl = hist->currentItem().url().toString(); reload(); } #endif if(myurl.isEmpty()) return; if(opt.arg_debug) printf("moveContent(%s)\n", (const char *) myurl.toUtf8()); if(myurl.length()+40 > MAX_PRINTF_LENGTH) return; sprintf(buf,"text(%d,\"%s\")\n", id,decode(myurl)); tcp_send(s,buf,strlen(buf)); }