mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
parent
a8fad834ce
commit
16a7156d69
@ -470,8 +470,10 @@ win32 {
|
||||
}
|
||||
|
||||
mac {
|
||||
HEADERS += other/macmenureceiver.h
|
||||
SOURCES += other/macmenureceiver.cpp
|
||||
HEADERS += other/macmenureceiver.h \
|
||||
webview/macwebviewscroller.h
|
||||
SOURCES += other/macmenureceiver.cpp \
|
||||
webview/macwebviewscroller.cpp
|
||||
RESOURCES -= data/certs.qrc
|
||||
|
||||
LIBS += -framework CoreServices
|
||||
|
68
src/lib/webview/macwebviewscroller.cpp
Normal file
68
src/lib/webview/macwebviewscroller.cpp
Normal file
@ -0,0 +1,68 @@
|
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2013 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ============================================================ */
|
||||
#include "macwebviewscroller.h"
|
||||
#include "webview.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QWheelEvent>
|
||||
#include <QTimer>
|
||||
|
||||
// Workaround for QTBUG-22269 (Extremely slow scrolling on Apple trackpads)
|
||||
// https://bugreports.qt-project.org/browse/QTBUG-22269
|
||||
|
||||
MacWebViewScroller::MacWebViewScroller(WebView* view)
|
||||
: QObject(view)
|
||||
, m_view(view)
|
||||
, m_timerRunning(false)
|
||||
, m_delta(0)
|
||||
{
|
||||
view->installEventFilter(this);
|
||||
}
|
||||
|
||||
bool MacWebViewScroller::eventFilter(QObject* obj, QEvent* event)
|
||||
{
|
||||
if (obj != m_view || event->type() != QEvent::Wheel) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QWheelEvent* ev = static_cast<QWheelEvent*>(event);
|
||||
if (ev->buttons() != Qt::NoButton || ev->modifiers() != Qt::NoModifier) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_timerRunning) {
|
||||
m_delta = ev->delta();
|
||||
m_pos = ev->pos();
|
||||
m_globalPos = ev->globalPos();
|
||||
|
||||
QTimer::singleShot(25, this, SLOT(sendWheelEvent()));
|
||||
m_timerRunning = true;
|
||||
}
|
||||
else {
|
||||
m_delta += ev->delta();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MacWebViewScroller::sendWheelEvent()
|
||||
{
|
||||
QWheelEvent ev(m_pos, m_delta, Qt::NoButton, Qt::NoModifier);
|
||||
m_view->event(&ev);
|
||||
m_timerRunning = false;
|
||||
}
|
49
src/lib/webview/macwebviewscroller.h
Normal file
49
src/lib/webview/macwebviewscroller.h
Normal file
@ -0,0 +1,49 @@
|
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2013 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ============================================================ */
|
||||
#ifndef MACWEBVIEWSCROLLER_H
|
||||
#define MACWEBVIEWSCROLLER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QPoint>
|
||||
|
||||
class QWheelEvent;
|
||||
|
||||
class WebView;
|
||||
|
||||
class MacWebViewScroller : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MacWebViewScroller(WebView* view);
|
||||
|
||||
bool eventFilter(QObject* obj, QEvent* event);
|
||||
|
||||
private slots:
|
||||
void sendWheelEvent();
|
||||
|
||||
private:
|
||||
WebView* m_view;
|
||||
|
||||
bool m_timerRunning;
|
||||
int m_delta;
|
||||
QPoint m_pos;
|
||||
QPoint m_globalPos;
|
||||
|
||||
};
|
||||
|
||||
#endif // MACWEBVIEWSCROLLER_H
|
@ -37,6 +37,10 @@
|
||||
#include "qtwebkit/spellcheck/speller.h"
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
#include "macwebviewscroller.h"
|
||||
#endif
|
||||
|
||||
#include <QDir>
|
||||
#include <QTimer>
|
||||
#include <QDesktopServices>
|
||||
@ -74,6 +78,10 @@ WebView::WebView(QWidget* parent)
|
||||
#if QTWEBKIT_TO_2_3
|
||||
installEventFilter(this);
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
new MacWebViewScroller(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
QIcon WebView::icon() const
|
||||
|
Loading…
Reference in New Issue
Block a user