本文整理汇总了C++中QWebHitTestResult::imageUrl方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebHitTestResult::imageUrl方法的具体用法?C++ QWebHitTestResult::imageUrl怎么用?C++ QWebHitTestResult::imageUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWebHitTestResult
的用法示例。
在下文中一共展示了QWebHitTestResult::imageUrl方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: 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));
}
示例3: 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());
}
示例4: SendToCGLX
void csWebView::SendToCGLX()
{
//printf("Hello at x: %d y: %d\n", hit_pos.x(), hit_pos.y());
QWebFrame *tframe=page()->currentFrame ();
QWebHitTestResult hitresult = tframe->hitTestContent ( hit_pos );
if(!hitresult.isNull())
{
QPixmap img = hitresult.pixmap();
if(!img.isNull())
{
//printf("Width: %d Height: %d Link: %s\n",img.width(), img.height(),hitresult.imageUrl().toString().toStdString().c_str());
emit send_image(img.width(), img.height() , hitresult.imageUrl());
}
}
}
示例5: 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);
}
示例6: 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()));
}
示例7: contextMenuEvent
void WebView::contextMenuEvent(QContextMenuEvent *event)
{
QMenu *menu = new QMenu(this);
QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos());
if (!r.linkUrl().isEmpty()) {
qDebug() << "Normal Click";
menu->addAction(pageAction(QWebPage::OpenLinkInNewWindow));
menu->addAction(tr("Open in New Tab"), this, SLOT(openLinkInNewTab()));
menu->addSeparator();
menu->addAction(pageAction(QWebPage::DownloadLinkToDisk));
// Add link to bookmarks...
menu->addSeparator();
menu->addAction(pageAction(QWebPage::CopyLinkToClipboard));
menu->addAction(tr("Block Image"), this, SLOT(blockImage()))->setData(r.imageUrl().toString());
if (page()->settings()->testAttribute(QWebSettings::DeveloperExtrasEnabled))
menu->addAction(pageAction(QWebPage::InspectElement));
menu->exec(mapToGlobal(event->pos()));
return;
}
delete menu;
QWebView::contextMenuEvent(event);
}
示例8: contextMenuEvent
void WebView::contextMenuEvent(QContextMenuEvent *event)
{
QMenu menu(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());
}
if (!menu.isEmpty()) {
menu.exec(mapToGlobal(event->pos()));
return;
}
QWebView::contextMenuEvent(event);
}
示例9: contextMenuEvent
void WebView::contextMenuEvent(QContextMenuEvent *event)
{
QMenu *menu = new QMenu(this);
QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos());
if (!r.linkUrl().isEmpty()) {
QAction *newWindowAction = menu->addAction(tr("Open in New &Window"), this, SLOT(openActionUrlInNewWindow()));
newWindowAction->setData(r.linkUrl());
QAction *newTabAction = menu->addAction(tr("Open in New &Tab"), this, SLOT(openActionUrlInNewTab()));
newTabAction->setData(r.linkUrl());
menu->addSeparator();
menu->addAction(tr("Save Lin&k"), this, SLOT(downloadLinkToDisk()));
menu->addAction(tr("&Bookmark This Link"), this, SLOT(bookmarkLink()))->setData(r.linkUrl());
menu->addSeparator();
if (!page()->selectedText().isEmpty())
menu->addAction(pageAction(QWebPage::Copy));
menu->addAction(tr("&Copy Link Location"), this, SLOT(copyLinkToClipboard()));
}
if (!r.imageUrl().isEmpty()) {
if (!menu->isEmpty())
menu->addSeparator();
QAction *newWindowAction = menu->addAction(tr("Open Image in New &Window"), this, SLOT(openActionUrlInNewWindow()));
newWindowAction->setData(r.imageUrl());
QAction *newTabAction = menu->addAction(tr("Open Image in New &Tab"), this, SLOT(openActionUrlInNewTab()));
newTabAction->setData(r.imageUrl());
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());
menu->addSeparator();
menu->addAction(tr("Block Image"), this, SLOT(blockImage()))->setData(r.imageUrl().toString());
}
if (!page()->selectedText().isEmpty()) {
if (menu->isEmpty()) {
menu->addAction(pageAction(QWebPage::Copy));
} else {
menu->addSeparator();
}
QMenu *searchMenu = menu->addMenu(tr("Search with..."));
QList<QString> list = ToolbarSearch::openSearchManager()->allEnginesNames();
for (int i = 0; i < list.count(); ++i) {
QString name = list.at(i);
OpenSearchEngine *engine = ToolbarSearch::openSearchManager()->engine(name);
QAction *action = new OpenSearchEngineAction(engine, searchMenu);
searchMenu->addAction(action);
action->setData(name);
}
connect(searchMenu, SIGNAL(triggered(QAction *)), this, SLOT(searchRequested(QAction *)));
}
QWebElement element = r.element();
if (!element.isNull()
&& element.tagName().toLower() == QLatin1String("input")
&& element.attribute(QLatin1String("type"), QLatin1String("text")) == QLatin1String("text")) {
if (menu->isEmpty()) {
menu->addAction(pageAction(QWebPage::Copy));
} else {
menu->addSeparator();
}
QVariant variant;
variant.setValue(element);
menu->addAction(tr("Add to the toolbar search"), this, SLOT(addSearchEngine()))->setData(variant);
}
if (menu->isEmpty()) {
delete menu;
menu = page()->createStandardContextMenu();
} else {
if (page()->settings()->testAttribute(QWebSettings::DeveloperExtrasEnabled))
menu->addAction(pageAction(QWebPage::InspectElement));
}
if (!menu->isEmpty()) {
if (BrowserMainWindow::parentWindow(tabWidget())->menuBar()->isHidden()) {
menu->addSeparator();
menu->addAction(BrowserMainWindow::parentWindow(tabWidget())->showMenuBarAction());
}
menu->exec(mapToGlobal(event->pos()));
delete menu;
return;
}
delete menu;
QWebView::contextMenuEvent(event);
}
示例10: editorContextMenuRequested
void MainWindow::editorContextMenuRequested ( const QPoint & pos ) {
QString guid = getCurrentNoteGuid();
if (guid == "main")
return;
QWebHitTestResult element = ui->editor->page()->mainFrame()->hitTestContent(pos);
if (element.isNull())
return;
QStringList classes = allClasses(element.element());
if (classes.contains("pdfarea"))
return;
QMenu * menu = new QMenu(ui->editor);
menu->addAction(ui->editor->pageAction(QWebPage::SelectAll));
if (element.isContentSelected()) {
if (!menu->isEmpty())
menu->addSeparator();
menu->addAction(ui->editor->pageAction(QWebPage::Copy));
if (element.isContentEditable()) {
menu->addAction(ui->editor->pageAction(QWebPage::Cut));
menu->addAction(ui->editor->pageAction(QWebPage::Paste));
menu->addSeparator();
menu->addAction(ui->editor->pageAction(QWebPage::ToggleBold));
menu->addAction(ui->editor->pageAction(QWebPage::ToggleItalic));
menu->addAction(ui->editor->pageAction(QWebPage::ToggleUnderline));
}
}
if(!element.imageUrl().isEmpty() && (element.imageUrl().scheme() != "qrc")) {
if (!menu->isEmpty())
menu->addSeparator();
menu->addAction(ui->editor->pageAction(QWebPage::DownloadImageToDisk));
menu->addAction(ui->editor->pageAction(QWebPage::CopyImageToClipboard));
if (element.imageUrl().scheme() == "http" || element.imageUrl().scheme() == "https")
menu->addAction(ui->editor->pageAction(QWebPage::CopyImageUrlToClipboard));
QAction * openImage = new QAction(this);
openImage->setText("Open Image");
openImage->setObjectName("openImage");
menu->addAction(openImage);
if (JS("editMode").toBool()) {
menu->addSeparator();
QAction * deleteImage = new QAction(this);
deleteImage->setText("Delete Image");
deleteImage->setObjectName("deleteImage");
deleteImage->setIcon(QIcon::fromTheme("edit-delete"));
menu->addAction(deleteImage);
if (element.imageUrl().scheme() != "resource") {
QAction * saveLocally = new QAction(this);
saveLocally->setText("Save Locally");
saveLocally->setObjectName("saveLocally");
menu->addAction(saveLocally);
}
}
}
if (!element.linkUrl().isEmpty()) {
if (!menu->isEmpty())
menu->addSeparator();
menu->addAction(ui->editor->pageAction(QWebPage::CopyLinkToClipboard));
if (element.isContentEditable()) {
QAction * deleteURL = new QAction(this);
deleteURL->setText("Remove Link");
deleteURL->setObjectName("deleteURL");
menu->addAction(deleteURL);
}
}
if (element.isContentEditable() && !element.isContentSelected() && element.imageUrl().isEmpty()) {
Speller *speller = Speller::GetInstance();
if (speller->initialized()) {
QHash<QString, QString> languages = speller->availableLanguages();
if (!languages.isEmpty()) {
if (!menu->isEmpty())
menu->addSeparator();
QAction* act = menu->addAction(tr("Check &Spelling"));
act->setCheckable(true);
act->setChecked(speller->isEnabled());
connect(act, SIGNAL(triggered(bool)), speller, SLOT(setEnabled(bool)));
if (speller->isEnabled()) {
//.........这里部分代码省略.........
示例11: contextMenuEvent
void CustomWebView::contextMenuEvent (QGraphicsSceneContextMenuEvent *e)
{
QPointer<QMenu> menu (new QMenu ());
QWebHitTestResult r = page ()->
mainFrame ()->hitTestContent (e->pos ().toPoint ());
IHookProxy_ptr proxy (new Util::DefaultHookProxy ());
emit hookWebViewContextMenu (proxy, this, e, r,
menu, WVSStart);
if (!r.linkUrl ().isEmpty ())
{
QUrl url = r.linkUrl ();
QString text = r.linkText ();
if (XmlSettingsManager::Instance ()->
property ("TryToDetectRSSLinks").toBool ())
{
bool hasAtom = text.contains ("Atom");
bool hasRSS = text.contains ("RSS");
if (hasAtom || hasRSS)
{
LeechCraft::Entity e;
if (hasAtom)
{
e.Additional_ ["UserVisibleName"] = "Atom";
e.Mime_ = "application/atom+xml";
}
else
{
e.Additional_ ["UserVisibleName"] = "RSS";
e.Mime_ = "application/rss+xml";
}
e.Entity_ = url;
e.Parameters_ = LeechCraft::FromUserInitiated |
LeechCraft::OnlyHandle;
bool ch = false;
emit couldHandle (e, &ch);
if (ch)
{
QList<QVariant> datalist;
datalist << url
<< e.Mime_;
menu->addAction (tr ("Subscribe"),
this,
SLOT (subscribeToLink ()))->setData (datalist);
menu->addSeparator ();
}
}
}
menu->addAction (tr ("Open &here"),
this, SLOT (openLinkHere ()))->setData (url);
menu->addAction (tr ("Open in new &tab"),
this, SLOT (openLinkInNewTab ()))->setData (url);
menu->addSeparator ();
menu->addAction (tr ("&Save link..."),
this, SLOT (saveLink ()));
QList<QVariant> datalist;
datalist << url
<< text;
menu->addAction (tr ("&Bookmark link..."),
this, SLOT (bookmarkLink ()))->setData (datalist);
menu->addSeparator ();
if (!page ()->selectedText ().isEmpty ())
menu->addAction (pageAction (QWebPage::Copy));
menu->addAction (tr ("&Copy link"),
this, SLOT (copyLink ()));
if (page ()->settings ()->testAttribute (QWebSettings::DeveloperExtrasEnabled))
menu->addAction (pageAction (QWebPage::InspectElement));
}
else if (page ()->selectedText ().contains (UrlInText))
{
menu->addAction (tr ("Open as link"),
this, SLOT (openLinkInNewTab ()))->
setData (page ()->selectedText ());
}
emit hookWebViewContextMenu (proxy, this, e, r,
menu, WVSAfterLink);
if (!r.imageUrl ().isEmpty ())
{
if (!menu->isEmpty ())
menu->addSeparator ();
menu->addAction (tr ("Open image here"),
this, SLOT (openImageHere ()))->setData (r.imageUrl ());
menu->addAction (tr ("Open image in new tab"),
this, SLOT (openImageInNewTab ()));
menu->addSeparator ();
menu->addAction (tr ("Save image..."),
this, SLOT (saveImage ()));
QAction *spx = menu->addAction (tr ("Save pixmap..."),
//.........这里部分代码省略.........
示例12: contextMenuEvent
void WebView::contextMenuEvent(QContextMenuEvent *event)
{
// do not display the context menu if gesture was previously invoked
if (m_gestureTime.isValid() && !m_gestureTime.isNull())
{
int secs = m_gestureTime.secsTo(QDateTime::currentDateTime());
if (secs >= 0 && secs <=1)
return;
}
QMenu menu(this);
QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos());
m_hitResult = r;
if (!r.linkUrl().isEmpty())
{
MenuCommands cmds;
QAction* newwin = new QAction(pageAction(QWebPage::OpenLinkInNewWindow)->text(), this);
connect(newwin, SIGNAL(triggered()), this, SLOT(openLinkInNewWin()));
menu.addAction(newwin);
QAction* newtab = new QAction(cmds.OpenNewTabTitle(), this);
newtab->setShortcuts(cmds.OpenNewTabShortcuts());
connect(newtab, SIGNAL(triggered()), this, SLOT(openLinkInNewTab()));
menu.addAction(newtab);
menu.addSeparator();
menu.addAction(pageAction(QWebPage::DownloadLinkToDisk));
menu.addSeparator();
menu.addAction(pageAction(QWebPage::CopyLinkToClipboard));
{
QAction* copyadr = new QAction(cmds.CopyAddrTitle(), this);
connect(copyadr, SIGNAL(triggered()), this, SLOT(copyMailtoAddress()));
menu.addAction( copyadr );
}
if (page()->settings()->testAttribute(QWebSettings::DeveloperExtrasEnabled))
{
QAction* inspect = new QAction(cmds.InspectTitle(), this);
//inspect->setShortcuts(cmds.InspectShortcuts());
connect(inspect, SIGNAL(triggered()), this, SLOT(slotInspectElement()));
menu.addAction(inspect);
}
}
if (!r.imageUrl().isEmpty())
{
if (!menu.isEmpty())
menu.addSeparator();
menu.addAction( pageAction(QWebPage::DownloadImageToDisk));
menu.addAction( pageAction(QWebPage::CopyImageToClipboard));
QAction* newwin = new QAction(pageAction(QWebPage::OpenImageInNewWindow)->text(), this);
connect(newwin, SIGNAL(triggered()), this, SLOT(openImageInNewWin()));
menu.addAction(newwin);
MenuCommands cmds;
QAction* newtab = new QAction(cmds.OpenNewTabTitle(), this);
newtab->setShortcuts(cmds.OpenNewTabShortcuts());
connect(newtab, SIGNAL(triggered()), this, SLOT(openImageInNewTab()));
menu.addAction( newtab );
menu.addSeparator();
QAction* adblock = new QAction(cmds.OpenAdBlockTitle(), this);
adblock->setShortcuts(cmds.OpenAdBlockShortcuts());
connect(adblock, SIGNAL(triggered()), this, SLOT(adBlock()));
adblock->setToolTip(r.imageUrl().toString());
menu.addAction( adblock );
}
if (!menu.isEmpty())
{
menu.exec(mapToGlobal(event->pos()));
return;
}
QWebView::contextMenuEvent(event);
}