bool WBWebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type) { // ctrl open in new tab // ctrl-shift open in new tab and select // ctrl-alt open in new window if (type == QWebPage::NavigationTypeLinkClicked && (mKeyboardModifiers & Qt::ControlModifier || mPressedButtons == Qt::MidButton)) { WBWebView *webView; bool selectNewTab = (mKeyboardModifiers & Qt::ShiftModifier); webView = mainWindow()->tabWidget()->newTab(selectNewTab); webView->load(request); mKeyboardModifiers = Qt::NoModifier; mPressedButtons = Qt::NoButton; return false; } if (frame == mainFrame()) { mLoadingUrl = request.url(); emit loadingUrl(mLoadingUrl); } return QWebPage::acceptNavigationRequest(frame, request, type); }
void WBUrlIconLabel::mouseMoveEvent(QMouseEvent *event) { if (event->buttons() == Qt::LeftButton && (event->pos() - m_dragStartPos).manhattanLength() > QApplication::startDragDistance() && m_webView) { QDrag *drag = new QDrag(this); QMimeData *mimeData = new QMimeData; mimeData->setText(QString::fromUtf8(m_webView->url().toEncoded())); QList<QUrl> urls; urls.append(m_webView->url()); mimeData->setUrls(urls); drag->setMimeData(mimeData); drag->exec(); } }
void WBTabWidget::currentChanged(int index) { WBWebView *webView = this->webView(index); if (!webView) return; Q_ASSERT(mLineEdits->count() == count()); WBWebView *oldWebView = this->webView(mLineEdits->currentIndex()); if (oldWebView) { disconnect(oldWebView, SIGNAL(statusBarMessage(const QString&)), this, SIGNAL(showStatusBarMessage(const QString&))); disconnect(oldWebView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), this, SIGNAL(linkHovered(const QString&))); disconnect(oldWebView, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int))); disconnect(oldWebView, SIGNAL(loadFinished(bool)), this, SIGNAL(loadFinished(bool))); } connect(webView, SIGNAL(statusBarMessage(const QString&)), this, SIGNAL(showStatusBarMessage(const QString&))); connect(webView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), this, SIGNAL(linkHovered(const QString&))); connect(webView, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int))); connect(webView, SIGNAL(loadFinished (bool)), this, SIGNAL(loadFinished(bool))); for (int i = 0; i < mWebActions.count(); ++i) { WBWebActionMapper *mapper = mWebActions[i]; mapper->updateCurrent(webView->page()); } emit setCurrentTitle(webView->title()); mLineEdits->setCurrentIndex(index); emit loadProgress(webView->progress()); emit showStatusBarMessage(webView->lastStatusBarText()); if (webView->url().isEmpty()) mLineEdits->currentWidget()->setFocus(); else webView->setFocus(); }