コード例 #1
0
bool WebPage::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
        && (m_keyboardModifiers & Qt::ControlModifier
            || m_pressedButtons == Qt::MidButton)) {
        bool newWindow = (m_keyboardModifiers & Qt::AltModifier);
        WebView *webView;
        if (newWindow) {
            BrowserApplication::instance()->newMainWindow();
            BrowserMainWindow *newMainWindow = BrowserApplication::instance()->mainWindow();
            webView = newMainWindow->currentTab();
            newMainWindow->raise();
            newMainWindow->activateWindow();
            webView->setFocus();
        } else {
            bool selectNewTab = (m_keyboardModifiers & Qt::ShiftModifier);
            webView = mainWindow()->tabWidget()->newTab(selectNewTab);
        }
        webView->load(request);
        m_keyboardModifiers = Qt::NoModifier;
        m_pressedButtons = Qt::NoButton;
        return false;
    }
    if (frame == mainFrame()) {
        m_loadingUrl = request.url();
        emit loadingUrl(m_loadingUrl);
    }
    return QWebPage::acceptNavigationRequest(frame, request, type);
}
コード例 #2
0
ファイル: webpage.cpp プロジェクト: AwkwardDev/qupzilla
void WebPage::doWebSearch(const QString &text)
{
    WebView* webView = qobject_cast<WebView*>(view());

    if (webView) {
        const LoadRequest searchRequest = mApp->searchEnginesManager()->searchResult(text);
        webView->load(searchRequest);
    }
}
コード例 #3
0
ファイル: main.cpp プロジェクト: kekekeks/webmerge
int main(int argc, char *argv[])
{
	QApplication a(argc, argv);
	if(argc>3)
		a.setApplicationName(QApplication::arguments().at(3));

	WebView w;
	w.show();
	w.load(QUrl(QString::fromLocal8Bit(argv[1])));

	return a.exec();
}