当前位置: 首页>>代码示例>>C++>>正文


C++ QWebHitTestResult::linkUrl方法代码示例

本文整理汇总了C++中QWebHitTestResult::linkUrl方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebHitTestResult::linkUrl方法的具体用法?C++ QWebHitTestResult::linkUrl怎么用?C++ QWebHitTestResult::linkUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QWebHitTestResult的用法示例。


在下文中一共展示了QWebHitTestResult::linkUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: contextMenuEvent

void WebView::contextMenuEvent(QContextMenuEvent* event)
{
	if (isLoading_) return;
	QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos());
	QMenu *menu;

	if (!r.linkUrl().isEmpty()) {
		if (r.linkUrl().scheme() == "addnick") {
			event->ignore();
			return;
		}
		menu = URLObject::getInstance()->createPopupMenu(r.linkUrl().toEncoded());
		//menu->addAction(pageAction(QWebPage::CopyLinkToClipboard));
	} else {
		menu = new QMenu(this);
		if (!page()->selectedText().isEmpty()) {
			menu->addAction(pageAction(QWebPage::Copy));
		} else {
			if (!menu->isEmpty()) {
				menu->addSeparator();
			}
			menu->addAction(pageAction(QWebPage::SelectAll));
		}
		if (settings()->testAttribute(QWebSettings::DeveloperExtrasEnabled)) {
			menu->addAction(pageAction(QWebPage::InspectElement));
		}
	}
	menu->addAction(pageAction(QWebPage::Reload));
	menu->exec(mapToGlobal(event->pos()));
	event->accept();
	delete menu;
}
开发者ID:akatov,项目名称:psi,代码行数:32,代码来源:webview.cpp

示例2: contextMenuEvent

void WebView::contextMenuEvent(QContextMenuEvent *event)
{
    QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos());
    if (!r.linkUrl().isEmpty()) {
        QMenu menu(this);
        menu.addAction(pageAction(QWebPage::OpenLink));

        // building a custom signal for external browser action
        QSignalMapper* signalMapper = new QSignalMapper (this);
        signalMapper->setProperty("url", QVariant(r.linkUrl()));
        connect(signalMapper, SIGNAL(mapped(int)),
                this, SLOT(triggerContextMenuAction(int)));

        QAction* extAction = menu.addAction(tr("Open in External Browser"));
        connect (extAction, SIGNAL(triggered()), signalMapper, SLOT(map()));
        signalMapper->setMapping(extAction, QWebPage::OpenLink);

        QAction* newAction = menu.addAction(tr("Open in new window"));
        connect (newAction, SIGNAL(triggered()), signalMapper, SLOT(map()));
        signalMapper->setMapping(newAction, QWebPage::OpenLinkInNewWindow);

        menu.addAction(pageAction(QWebPage::DownloadLinkToDisk));
        menu.addAction(pageAction(QWebPage::CopyLinkToClipboard));
        menu.exec(mapToGlobal(event->pos()));
        return;
    }
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:26,代码来源:BrowserView.cpp

示例3: anchorAt

QString ViewWindow::anchorAt(const QPoint & pos)
{
	QWebHitTestResult res = page()->currentFrame()->hitTestContent( pos );

	if ( !res.linkUrl().isValid() )
		return QString::null;

	return  res.linkUrl().path();
}
开发者ID:EmbolismSoil,项目名称:kchmviewer,代码行数:9,代码来源:viewwindow.cpp

示例4: mousePressEvent

void WebView::mousePressEvent(QMouseEvent *event)
{
    if (event->button() == Qt::MidButton) {
        QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos());
        if (!r.linkUrl().isEmpty()) {
            openLinkInNewWindow(r.linkUrl());
            return;
        }
    }
    QWebView::mousePressEvent(event);
}
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:11,代码来源:BrowserView.cpp

示例5: contextMenuEvent

    virtual void contextMenuEvent(QContextMenuEvent* event)
    {
        QMenu* menu = page()->createStandardContextMenu();

        QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos());

        if (!r.linkUrl().isEmpty()) {
            QAction* newTabAction = menu->addAction(tr("Open in Default &Browser"), this, SLOT(openUrlInDefaultBrowser()));
            newTabAction->setData(r.linkUrl());
            menu->insertAction(menu->actions().at(2), newTabAction);
        }

        menu->exec(mapToGlobal(event->pos()));
        delete menu;
    }
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:15,代码来源:main.cpp

示例6: contextMenuRequest

void tab::contextMenuRequest(QPoint pos)
{
    clickPos = pos;
    QMenu menu;
    QWebHitTestResult r = webView->page()->mainFrame()->hitTestContent(pos);

    if(!r.linkUrl().isEmpty())
    {
        menu.addAction(tr("Open in New Tab"), this, SLOT(openLinkInNewTab()));
        menu.addAction(webView->pageAction(QWebPage::DownloadLinkToDisk));
        menu.addAction(webView->pageAction(QWebPage::CopyLinkToClipboard));
    }
    if(!r.imageUrl().isEmpty())
    {
        menu.addSeparator();
        menu.addAction(webView->pageAction(QWebPage::DownloadImageToDisk));
        menu.addAction(webView->pageAction(QWebPage::CopyImageToClipboard));
        menu.addAction(webView->pageAction(QWebPage::CopyImageUrlToClipboard));
    }

    menu.addSeparator();
    menu.addAction(webView->pageAction(QWebPage::InspectElement));

    menu.exec(webView->mapToGlobal(pos));
}
开发者ID:RafalNiewinski,项目名称:DragonBrowser,代码行数:25,代码来源:tab.cpp

示例7: showBrowserContextMenu

void SearchPage::showBrowserContextMenu(const QPoint &pos) {
    const QWebHitTestResult result = m_browser->page()->mainFrame()->hitTestContent(pos);
    const QString url = result.linkUrl().toString();

    if (url.isEmpty()) {
        return;
    }

    QMenu menu(this);
    QAction *copyAction = menu.addAction(QIcon::fromTheme("edit-copy"), tr("&Copy URL"));
    QAction *addAction = menu.addAction(QIcon::fromTheme("list-add"), tr("&Add URL"));
    QAction *retrieveAction = menu.addAction(QIcon::fromTheme("folder-remote"), tr("&Retrieve URLs"));
    QAction *downloadAction = menu.addAction(QIcon::fromTheme("download"), tr("Retrieve &download requests"));
    QAction *action = menu.exec(m_browser->mapToGlobal(pos));
    
    if (!action) {
        return;
    }
    
    if (action == copyAction) {
        copyUrl(url);
    }
    else if (action == addAction) {
        addUrl(url);
    }
    else if (action == retrieveAction) {
        retrieveUrls(url);
    }
    else if (action == downloadAction) {
        fetchDownloadRequests(url);
    }
}
开发者ID:marxoft,项目名称:qdl2,代码行数:32,代码来源:searchpage.cpp

示例8: populateWebViewMenu

void CopyTitle::populateWebViewMenu(QMenu* menu, WebView* view, const QWebHitTestResult &r)
{
    m_view = view;

    if (!r.linkUrl().isEmpty() || r.isContentEditable()) {
        return;
    }

    QString title;
    if (!r.imageUrl().isEmpty()) {
        QString m_userFileName = r.imageUrl().toString().trimmed();
        int pos = m_userFileName.lastIndexOf(QLatin1Char('/'));
        if (pos != -1) {
            int size = m_userFileName.size();
            title = m_userFileName.right(size - pos - 1);
        }
        else {
            title += "image";
        }
    }

    else {
        title = view->title();
    }

    menu->addAction(QIcon::fromTheme("edit-copy"), !r.imageUrl().isEmpty() ? tr("Copy Image Name") : tr("Copy Page Title"), this, SLOT(copyPageTitle()))->setData(title);
}
开发者ID:beimprovised,项目名称:qupzilla-plugins,代码行数:27,代码来源:copytitle.cpp

示例9: page

QWebView *MyTextBrowser::createWindow(QWebPage::WebWindowType type)
{
  QWebHitTestResult r = page()->mainFrame()->hitTestContent(pressPos);
  if(!r.linkUrl().isEmpty() && type == QWebPage::WebBrowserWindow) 
  {
    QString cmd = opt.newwindow;
    if(cmd.isEmpty()) cmd = "pvbrowser";
    cmd += " \"";
    cmd += r.linkUrl().toString();;
    cmd += "\"";
#ifdef PVUNIX
    //cmd += " &";
    int ret = system(cmd.toUtf8());
#endif
#ifdef PVWIN32
    int ret = mysystem(cmd.toUtf8());
#endif
    if(ret < 0) printf("ERROR system(%s)", (const char *) cmd.toUtf8());
  }
  return NULL;
}
开发者ID:pvbrowser,项目名称:pvb,代码行数:21,代码来源:MyTextBrowser_v4.cpp

示例10: contextMenuEvent

void webview::contextMenuEvent(QContextMenuEvent * event)
{
    QMenu * menu = new QMenu();
    menu->setVisible(true);
    QWebHitTestResult element = this->page()->mainFrame()->hitTestContent(event->pos());
    if(!element.linkUrl().isEmpty())
    {
        QAction * newtab = this->pageAction(QWebPage::OpenLinkInNewWindow);
        newtab->setText(tr("open link in new tab"));
        menu->addAction(newtab);
        menu->addAction(this->pageAction(QWebPage::DownloadLinkToDisk));
        menu->addAction(this->pageAction(QWebPage::CopyLinkToClipboard));
    }
    if(!element.imageUrl().isEmpty())
    {
        menu->addAction(this->pageAction(QWebPage::DownloadImageToDisk));
        menu->addAction(this->pageAction(QWebPage::CopyImageToClipboard));
        menu->addAction(this->pageAction(QWebPage::CopyImageUrlToClipboard));
        QAction * newimage = this->pageAction(QWebPage::OpenImageInNewWindow);
        newimage->setText(tr("open image in new tab"));
        menu->addAction(newimage);
    }
    if(!page()->selectedText().isEmpty())
    {
        menu->addAction(this->pageAction(QWebPage::Copy));
        menu->addAction(this->pageAction(QWebPage::Cut));
        menu->addAction(this->pageAction(QWebPage::Paste));
        menu->addAction(this->pageAction(QWebPage::Undo));
        menu->addAction(this->pageAction(QWebPage::Redo));
        menu->addAction(this->pageAction(QWebPage::SelectAll));
    }
    if(element.element().tagName().toLower() == "input" && element.element().attribute(QLatin1String("type")).toLower() == "text")
    {
        menu->addAction(this->pageAction(QWebPage::SelectAll));
        menu->addAction(this->pageAction(QWebPage::Paste));
        menu->addAction(this->pageAction(QWebPage::SetTextDirectionLeftToRight));
        menu->addAction(this->pageAction(QWebPage::SetTextDirectionRightToLeft));
        menu->addAction(this->pageAction(QWebPage::SetTextDirectionDefault));
        menu->addAction(this->pageAction(QWebPage::MoveToNextWord));
    }
    if(!element.isNull())
    {
        menu->addAction(this->pageAction(QWebPage::Back));
        menu->addAction(this->pageAction(QWebPage::Forward));
        menu->addAction(this->pageAction(QWebPage::Reload));
        menu->addAction(this->pageAction(QWebPage::Stop));
        menu->addAction(this->pageAction(QWebPage::InspectElement));
    }
    menu->exec(event->globalPos());
}
开发者ID:ubuntuphp,项目名称:letssee,代码行数:50,代码来源:webview.cpp

示例11: contextMenuEvent

void WebView::contextMenuEvent(QContextMenuEvent* event)
{
    QSettings settings;
    return;
    if(settings.value("disableDebug").toBool()) {
        return;
    }

    QMenu* menu = m_page->createStandardContextMenu();

    QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos());

    if (!r.linkUrl().isEmpty()) {
        QAction* newTabAction = menu->addAction(tr("Test Menu"));
        newTabAction->setData(r.linkUrl());
        menu->insertAction(menu->actions().at(2), newTabAction);
    }
    for(int i=0; i< menu->actions().size(); i++) {
        QAction *qa = menu->actions().at(i);
    }

    menu->exec(mapToGlobal(event->pos()));
    delete menu;
}
开发者ID:lotux,项目名称:MediaPort,代码行数:24,代码来源:webview.cpp

示例12: contextMenu

void ChannelsView::contextMenu(QMenu *menu, const QWebHitTestResult &result)
{
  menu->addSeparator();

  const QUrl url = result.linkUrl();
  if (url.scheme() == LS("chat") && url.host() == LS("channel"))
    ChannelMenu::bind(menu, ChatUrls::channel(url), IChannelMenu::ChatViewScope);

  menu->addSeparator();

  if (!result.isContentEditable()) {
    menu->removeAction(pageAction(QWebPage::SelectAll));
    menu->addAction(pageAction(QWebPage::SelectAll));
  }
}
开发者ID:Artanomell,项目名称:schat,代码行数:15,代码来源:ChannelsView.cpp

示例13: contextMenuEvent

void WebView::contextMenuEvent(QContextMenuEvent *event)
{
    QMenu *menu = new QMenu(this);

    QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos());

    if (!r.linkUrl().isEmpty()) {
        menu->addAction(tr("Open in New &Window"), this, SLOT(openLinkInNewWindow()));
        menu->addAction(tr("Open in New &Tab"), this, SLOT(openLinkInNewTab()));
        menu->addSeparator();
        menu->addAction(tr("Save Lin&k"), this, SLOT(downloadLinkToDisk()));
        menu->addAction(tr("&Bookmark This Link"), this, SLOT(bookmarkLink()))->setData(r.linkUrl().toString());
        menu->addSeparator();
        menu->addAction(tr("&Copy Link Location"), this, SLOT(copyLinkToClipboard()));
        if (page()->settings()->testAttribute(QWebSettings::DeveloperExtrasEnabled))
            menu->addAction(pageAction(QWebPage::InspectElement));
    }

    if (!r.imageUrl().isEmpty()) {
        if (!menu->isEmpty())
            menu->addSeparator();
        menu->addAction(tr("Open Image in New &Window"), this, SLOT(openImageInNewWindow()));
        menu->addAction(tr("Open Image in New &Tab"), this, SLOT(openImageInNewTab()));
        menu->addSeparator();
        menu->addAction(tr("&Save Image"), this, SLOT(downloadImageToDisk()));
        menu->addAction(tr("&Copy Image"), this, SLOT(copyImageToClipboard()));
        menu->addAction(tr("C&opy Image Location"), this, SLOT(copyImageLocationToClipboard()))->setData(r.imageUrl().toString());
    }

#ifdef WEBKIT_TRUNK // i.e. Qt 4.5, but not in Qt 4.5 yet
    if (menu->isEmpty())
        menu = page()->createStandardContextMenu();
#endif

    if (!menu->isEmpty()) {
        if (m_page->mainWindow()->menuBar()->isHidden()) {
            menu->addSeparator();
            menu->addAction(m_page->mainWindow()->showMenuBarAction());
        }

        menu->exec(mapToGlobal(event->pos()));
        delete menu;
        return;
    }
    delete menu;

    QWebView::contextMenuEvent(event);
}
开发者ID:ariya,项目名称:arora,代码行数:48,代码来源:webview.cpp

示例14: contextMenuEvent

void AdiumThemeView::contextMenuEvent(QContextMenuEvent *event)
{
    QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos());
    QUrl url = r.linkUrl();
    if (!url.isEmpty()) {
        // save current link url in openLinkAction
        m_openLinkAction->setData(url);

        QMenu menu(this);
        menu.addAction(m_openLinkAction);
        menu.addAction(pageAction(QWebPage::CopyLinkToClipboard));
        menu.exec(mapToGlobal(event->pos()));
    } else {
        QWebView::contextMenuEvent(event);
    }
}
开发者ID:R4md4c,项目名称:ktp-text-ui,代码行数:16,代码来源:adium-theme-view.cpp

示例15: populateWebViewMenu

void TestPlugin::populateWebViewMenu(QMenu* menu, WebView* view, const QWebHitTestResult &r)
{
    // Called from WebView when creating context menu

    m_view = view;

    QString title;
    if (!r.imageUrl().isEmpty()) {
        title += " on image";
    }

    if (!r.linkUrl().isEmpty()) {
        title += " on link";
    }

    if (r.isContentEditable()) {
        title += " on input";
    }

    menu->addAction(tr("My first plugin action") + title, this, SLOT(actionSlot()));
}
开发者ID:framp,项目名称:qupzilla,代码行数:21,代码来源:testplugin.cpp


注:本文中的QWebHitTestResult::linkUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。