Commit c4e1bbd3 authored by kenneth@webkit.org's avatar kenneth@webkit.org

Rubberstamped by Simon Hausmann.

[Qt] QtLauncher refactoring, separating the webview and
adding a QGraphicsWebView based version.

* QtLauncher/QtLauncher.pro:
* QtLauncher/main.cpp:
(MainWindow::MainWindow):
* QtLauncher/webpage.h:
* QtLauncher/webview.cpp: Added.
(createContextMenu):
(WebViewGraphicsBased::mousePressEvent):
(WebViewTraditional::mousePressEvent):
(WebViewGraphicsBased::contextMenuEvent):
(WebViewTraditional::contextMenuEvent):
* QtLauncher/webview.h: Added.
(WebViewGraphicsBased::WebViewGraphicsBased):
(WebViewTraditional::WebViewTraditional):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53937 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d32172af
2010-01-27 Kenneth Rohde Christiansen <kenneth@webkit.org>
Rubberstamped by Simon Hausmann.
[Qt] QtLauncher refactoring, separating the webview and
adding a QGraphicsWebView based version.
* QtLauncher/QtLauncher.pro:
* QtLauncher/main.cpp:
(MainWindow::MainWindow):
* QtLauncher/webpage.h:
* QtLauncher/webview.cpp: Added.
(createContextMenu):
(WebViewGraphicsBased::mousePressEvent):
(WebViewTraditional::mousePressEvent):
(WebViewGraphicsBased::contextMenuEvent):
(WebViewTraditional::contextMenuEvent):
* QtLauncher/webview.h: Added.
(WebViewGraphicsBased::WebViewGraphicsBased):
(WebViewTraditional::WebViewTraditional):
2010-01-27 Alexander Pavlov <apavlov@chromium.org>
Adding myself as committer. No review necessary.
......
......@@ -2,15 +2,17 @@ TEMPLATE = app
SOURCES += \
main.cpp \
webpage.cpp \
urlloader.cpp \
utils.cpp \
webpage.cpp \
webview.cpp \
HEADERS += \
webinspector.h \
webpage.h \
urlloader.h \
utils.h \
webinspector.h \
webpage.h \
webview.h \
CONFIG -= app_bundle
CONFIG += uitools
......
......@@ -48,48 +48,16 @@
#include <qwebframe.h>
#include <qwebinspector.h>
#include <qwebsettings.h>
#include <qwebview.h>
#include "urlloader.h"
#include "utils.h"
#include "webinspector.h"
#include "webpage.h"
#include "webview.h"
#ifndef NDEBUG
void QWEBKIT_EXPORT qt_drt_garbageCollector_collect();
#endif
class WebView : public QWebView {
Q_OBJECT
public:
WebView(QWidget* parent) : QWebView(parent) {}
protected:
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;
}
virtual void mousePressEvent(QMouseEvent* event)
{
setProperty("mouseButtons", QVariant::fromValue(int(event->buttons())));
setProperty("keyboardModifiers", QVariant::fromValue(int(event->modifiers())));
QWebView::mousePressEvent(event);
}
};
class MainWindow : public QMainWindow {
Q_OBJECT
......@@ -105,7 +73,7 @@ public:
QSplitter* splitter = new QSplitter(Qt::Vertical, this);
setCentralWidget(splitter);
view = new WebView(splitter);
view = new WebViewTraditional(splitter);
WebPage* page = new WebPage(view);
view->setPage(page);
......
......@@ -37,6 +37,8 @@
#include <qwebpage.h>
class WebPage : public QWebPage {
Q_OBJECT
public:
WebPage(QObject* parent = 0);
......
/*
* Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
* Copyright (C) 2009 Girish Ramakrishnan <girish@forwardbias.in>
* Copyright (C) 2006 George Staikos <staikos@kde.org>
* Copyright (C) 2006 Dirk Mueller <mueller@kde.org>
* Copyright (C) 2006 Zack Rusin <zack@kde.org>
* Copyright (C) 2006 Simon Hausmann <hausmann@kde.org>
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "webview.h"
#include <QtGui>
static QMenu* createContextMenu(QWebPage* page, QPoint position)
{
QMenu* menu = page->createStandardContextMenu();
QWebHitTestResult r = page->mainFrame()->hitTestContent(position);
if (!r.linkUrl().isEmpty()) {
WebPage* webPage = qobject_cast<WebPage*>(page);
QAction* newTabAction = menu->addAction("Open in Default &Browser", webPage, SLOT(openUrlInDefaultBrowser()));
newTabAction->setData(r.linkUrl());
menu->insertAction(menu->actions().at(2), newTabAction);
}
return menu;
}
void WebViewGraphicsBased::mousePressEvent(QGraphicsSceneMouseEvent* event)
{
setProperty("mouseButtons", QVariant::fromValue(int(event->buttons())));
setProperty("keyboardModifiers", QVariant::fromValue(int(event->modifiers())));
QGraphicsWebView::mousePressEvent(event);
}
void WebViewTraditional::mousePressEvent(QMouseEvent* event)
{
setProperty("mouseButtons", QVariant::fromValue(int(event->buttons())));
setProperty("keyboardModifiers", QVariant::fromValue(int(event->modifiers())));
QWebView::mousePressEvent(event);
}
void WebViewGraphicsBased::contextMenuEvent(QGraphicsSceneContextMenuEvent* event)
{
QMenu* menu = createContextMenu(page(), event->pos().toPoint());
menu->exec(mapToScene(event->pos()).toPoint());
delete menu;
}
void WebViewTraditional::contextMenuEvent(QContextMenuEvent* event)
{
QMenu* menu = createContextMenu(page(), event->pos());
menu->exec(mapToGlobal(event->pos()));
delete menu;
}
/*
* Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
* Copyright (C) 2009 Girish Ramakrishnan <girish@forwardbias.in>
* Copyright (C) 2006 George Staikos <staikos@kde.org>
* Copyright (C) 2006 Dirk Mueller <mueller@kde.org>
* Copyright (C) 2006 Zack Rusin <zack@kde.org>
* Copyright (C) 2006 Simon Hausmann <hausmann@kde.org>
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef webview_h
#define webview_h
#include "webpage.h"
#include <qwebview.h>
#include <qgraphicswebview.h>
class WebViewGraphicsBased : public QGraphicsWebView {
Q_OBJECT
public:
WebViewGraphicsBased(QGraphicsItem* parent = 0) : QGraphicsWebView(parent) {};
protected:
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent*);
virtual void mousePressEvent(QGraphicsSceneMouseEvent*);
};
class WebViewTraditional : public QWebView {
Q_OBJECT
public:
WebViewTraditional(QWidget* parent) : QWebView(parent) {}
protected:
virtual void contextMenuEvent(QContextMenuEvent*);
virtual void mousePressEvent(QMouseEvent*);
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment