1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 09:32:12 +01:00

Improved mouse press events on page. Closes #33

The original function eventFilter was taken from QTestBrowser and used
the MousePressEvents part.
You can find original function at http://gitorious.org/+qtwebkit-
This commit is contained in:
nowrep 2011-11-05 21:27:01 +01:00
parent b8fbcdbeb5
commit 178baa7dc2
3 changed files with 71 additions and 1 deletions

View File

@ -119,7 +119,8 @@ void WebPage::setSSLCertificate(const QSslCertificate &cert)
QSslCertificate WebPage::sslCertificate() QSslCertificate WebPage::sslCertificate()
{ {
if (mainFrame()->url().scheme() == "https" && m_SslCert.subjectInfo(QSslCertificate::CommonName).remove("*").contains(QRegExp(mainFrame()->url().host()))) if (mainFrame()->url().scheme() == "https" &&
m_SslCert.subjectInfo(QSslCertificate::CommonName).remove("*").contains(QRegExp(mainFrame()->url().host())))
return m_SslCert; return m_SslCert;
else else
return QSslCertificate(); return QSslCertificate();

View File

@ -91,6 +91,8 @@ WebView::WebView(QupZilla* mainClass, WebTab* webTab)
// Set default zoom // Set default zoom
m_currentZoom = mApp->defaultZoom(); m_currentZoom = mApp->defaultZoom();
applyZoom(); applyZoom();
qApp->installEventFilter(this);
} }
void WebView::slotIconChanged() void WebView::slotIconChanged()
@ -841,6 +843,69 @@ bool WebView::isUrlValid(const QUrl &url)
return false; return false;
} }
///
// This function was taken and modified from QTestBrowser to fix bug #33 with flighradar24.com
// You can find original source and copyright here:
// http://gitorious.org/+qtwebkit-developers/webkit/qtwebkit/blobs/qtwebkit-2.2/Tools/QtTestBrowser/launcherwindow.cpp
///
bool WebView::eventFilter(QObject* obj, QEvent* event)
{
if (event->type() == QEvent::MouseButtonPress ||
event->type() == QEvent::MouseButtonRelease ||
event->type() == QEvent::MouseButtonDblClick ||
event->type() == QEvent::MouseMove) {
QMouseEvent* ev = static_cast<QMouseEvent*>(event);
if (ev->type() == QEvent::MouseMove
&& !(ev->buttons() & Qt::LeftButton))
return false;
QTouchEvent::TouchPoint touchPoint;
touchPoint.setState(Qt::TouchPointMoved);
if ((ev->type() == QEvent::MouseButtonPress
|| ev->type() == QEvent::MouseButtonDblClick))
touchPoint.setState(Qt::TouchPointPressed);
else if (ev->type() == QEvent::MouseButtonRelease)
touchPoint.setState(Qt::TouchPointReleased);
touchPoint.setId(0);
touchPoint.setScreenPos(ev->globalPos());
touchPoint.setPos(ev->pos());
touchPoint.setPressure(1);
// If the point already exists, update it. Otherwise create it.
if (m_touchPoints.size() > 0 && !m_touchPoints[0].id())
m_touchPoints[0] = touchPoint;
else if (m_touchPoints.size() > 1 && !m_touchPoints[1].id())
m_touchPoints[1] = touchPoint;
else
m_touchPoints.append(touchPoint);
if (!m_touchPoints.isEmpty()) {
QEvent::Type type = QEvent::TouchUpdate;
if (m_touchPoints.size() == 1) {
if (m_touchPoints[0].state() == Qt::TouchPointReleased)
type = QEvent::TouchEnd;
else if (m_touchPoints[0].state() == Qt::TouchPointPressed)
type = QEvent::TouchBegin;
}
QTouchEvent touchEv(type);
touchEv.setTouchPoints(m_touchPoints);
QCoreApplication::sendEvent(page(), &touchEv);
// After sending the event, remove all touchpoints that were released
if (m_touchPoints[0].state() == Qt::TouchPointReleased)
m_touchPoints.removeAt(0);
if (m_touchPoints.size() > 1 && m_touchPoints[1].state() == Qt::TouchPointReleased)
m_touchPoints.removeAt(1);
}
return false;
}
return QObject::eventFilter(obj, event);
}
WebView::~WebView() WebView::~WebView()
{ {
history()->clear(); history()->clear();

View File

@ -60,6 +60,8 @@ public:
bool hasRss() { return m_hasRss; } bool hasRss() { return m_hasRss; }
void setMouseWheelEnabled(bool state) { m_mouseWheelEnabled = state; } void setMouseWheelEnabled(bool state) { m_mouseWheelEnabled = state; }
bool eventFilter(QObject* obj, QEvent* event);
void setLocationBar(LocationBar* bar) { m_locationBar = bar; } void setLocationBar(LocationBar* bar) { m_locationBar = bar; }
LocationBar* locationBar() { return m_locationBar; } LocationBar* locationBar() { return m_locationBar; }
@ -147,6 +149,8 @@ private:
bool m_hasRss; bool m_hasRss;
bool m_rssChecked; bool m_rssChecked;
QList<QTouchEvent::TouchPoint> m_touchPoints;
//QTimer* m_loadingTimer; //QTimer* m_loadingTimer;
signals: signals: