-
Notifications
You must be signed in to change notification settings - Fork 1
/
webview.cpp
45 lines (36 loc) · 1.16 KB
/
webview.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "webview.h"
WebView::WebView(QWidget *parent)
:QWebView(parent),
m_page(new WebPage(this))
{
setPage(m_page);
}
void WebView::contextMenuEvent(QContextMenuEvent *event)
{
QMenu *menu = new QMenu(this);
QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos());
//if (!page()->selectedText().isNull()) {
// qDebug() << " selected Text is null()";
//}
if (!page()->selectedText().isEmpty()) {
if (!menu->isEmpty())
menu->addSeparator();
menu->addAction(tr("&Add Text Field"), this, SIGNAL(showTextFieldDialog()));
}
//if (!r.imageUrl().isEmpty()) {
if (!menu->isEmpty())
menu->addSeparator();
hitPos = event->pos();
menu->addAction(tr("&Add Image Field"), this, SIGNAL(showImageFieldDialog()));
// }
if (!menu->isEmpty())
menu->addSeparator();
menu->addAction(tr("&Viwie"), this, SIGNAL(showViwieDialog()));
if (menu->isEmpty()) {
delete menu;
menu = page()->createStandardContextMenu();
}
menu->exec(mapToGlobal(event->pos()));
delete menu;
QWebView::contextMenuEvent(event);
}