예제 #1
0
WizWebEngineView::WizWebEngineView(QWidget* parent)
    : QWebEngineView(parent)
    , m_server(NULL)
    , m_clientWrapper(NULL)
    , m_channel(NULL)
{
    WizWebEnginePage* p = new WizWebEnginePage(this);
    setPage(p);
    //
    connect(p, SIGNAL(openLinkInNewWindow(QUrl)), this, SLOT(openLinkInDefaultBrowser(QUrl)));
    //
    connect(this, SIGNAL(loadFinished(bool)), this, SLOT(innerLoadFinished(bool)));
    //
    // setup the QWebSocketServer
    m_server = new QWebSocketServer(QStringLiteral("WizNote QWebChannel Server"), QWebSocketServer::NonSecureMode);
    //
    if (!m_server->listen(QHostAddress::LocalHost)) {
        qFatal("Failed to open web socket server.");
        return;
    }

    // wrap WebSocket clients in QWebChannelAbstractTransport objects
    m_clientWrapper = new WebSocketClientWrapper(m_server);
    //
    // setup the channel
    m_channel = new QWebChannel();
    QObject::connect(m_clientWrapper, &WebSocketClientWrapper::clientConnected, m_channel, &QWebChannel::connectTo);
}
예제 #2
0
WizWebEngineView::WizWebEngineView(const WizWebEngineViewInjectObjects& objects, QWidget* parent)
    : QWebEngineView(parent)
{
    WizWebEnginePage* p = new WizWebEnginePage(objects, this);
    setPage(p);
    //
    connect(p, SIGNAL(openLinkInNewWindow(QUrl)), this, SLOT(openLinkInDefaultBrowser(QUrl)));
    connect(this, SIGNAL(loadFinished(bool)), this, SLOT(innerLoadFinished(bool)));
}
예제 #3
0
파일: webview.cpp 프로젝트: ariya/arora
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);
}
예제 #4
0
파일: helpwindow.cpp 프로젝트: Fale/qtmoko
void HelpWindow::contextMenuEvent(QContextMenuEvent *e)
{
    QMenu menu(QLatin1String(""), 0);

    QUrl link;
    QAction *copyAnchorAction = 0;
    if (hasAnchorAt(e->pos())) {
        link = anchorAt(e->pos());
        if (link.isRelative())            
            link = source().resolved(link);
        copyAnchorAction = menu.addAction(tr("Copy &Link Location"));
        copyAnchorAction->setEnabled(!link.isEmpty() && link.isValid());

        menu.addAction(tr("Open Link in New Tab"),
                       this, SLOT(openLinkInNewPage()));
        menu.addAction(tr("Open Link in New Window\tShift+LMB"),
                       this, SLOT(openLinkInNewWindow()));
    }
    mw->setupPopupMenu(&menu);
    QAction *action = menu.exec(e->globalPos());
    if (action == copyAnchorAction)
        QApplication::clipboard()->setText(link.toString());
}
예제 #5
0
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);
}
예제 #6
0
파일: helpwindow.cpp 프로젝트: Fale/qtmoko
void HelpWindow::openLinkInNewWindow(const QString &link)
{
    lastAnchor = link;
    openLinkInNewWindow();
}