mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
No longer using global event filters, instead filtering widget events.
- using guarded pointers in plugins now
This commit is contained in:
parent
1bdc7d59a8
commit
4d96a6760c
@ -50,7 +50,7 @@ SourceViewerSearch::SourceViewerSearch(SourceViewer* parent)
|
||||
connect(findPreviousAction, SIGNAL(activated()), this, SLOT(previous()));
|
||||
|
||||
startAnimation();
|
||||
qApp->installEventFilter(this);
|
||||
parent->installEventFilter(this);
|
||||
}
|
||||
|
||||
void SourceViewerSearch::activateLineEdit()
|
||||
|
@ -44,14 +44,13 @@ TipLabel::TipLabel(QWidget* parent)
|
||||
m_timer->setSingleShot(true);
|
||||
m_timer->setInterval(500);
|
||||
connect(m_timer, SIGNAL(timeout()), this, SLOT(hide()));
|
||||
|
||||
qApp->installEventFilter(this);
|
||||
}
|
||||
|
||||
void TipLabel::show()
|
||||
void TipLabel::show(QWidget* widget)
|
||||
{
|
||||
m_timer->stop();
|
||||
|
||||
widget->installEventFilter(this);
|
||||
SqueezeLabelV1::show();
|
||||
}
|
||||
|
||||
@ -77,13 +76,7 @@ bool TipLabel::eventFilter(QObject* o, QEvent* e)
|
||||
|
||||
switch (e->type()) {
|
||||
case QEvent::Leave:
|
||||
case QEvent::WindowActivate:
|
||||
case QEvent::WindowDeactivate:
|
||||
case QEvent::MouseButtonPress:
|
||||
case QEvent::MouseButtonRelease:
|
||||
case QEvent::MouseButtonDblClick:
|
||||
case QEvent::FocusIn:
|
||||
case QEvent::FocusOut:
|
||||
case QEvent::Wheel:
|
||||
hide();
|
||||
break;
|
||||
@ -91,6 +84,7 @@ bool TipLabel::eventFilter(QObject* o, QEvent* e)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -136,7 +130,7 @@ void StatusBarMessage::showMessage(const QString &message)
|
||||
}
|
||||
|
||||
m_statusBarText->move(view->mapToGlobal(position));
|
||||
m_statusBarText->show();
|
||||
m_statusBarText->show(view);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ class QT_QUPZILLA_EXPORT TipLabel : public SqueezeLabelV1
|
||||
public:
|
||||
explicit TipLabel(QWidget* parent);
|
||||
|
||||
void show();
|
||||
void show(QWidget* widget);
|
||||
void hideDelayed();
|
||||
|
||||
bool eventFilter(QObject* o, QEvent* e);
|
||||
|
@ -69,7 +69,7 @@ void PopupStatusBarMessage::showMessage(const QString &message)
|
||||
}
|
||||
|
||||
m_statusBarText->move(view->mapToGlobal(position));
|
||||
m_statusBarText->show();
|
||||
m_statusBarText->show(view);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ SearchToolBar::SearchToolBar(QupZilla* mainClass, QWidget* parent)
|
||||
QShortcut* findPreviousAction = new QShortcut(QKeySequence("Shift+F3"), this);
|
||||
connect(findPreviousAction, SIGNAL(activated()), this, SLOT(findPrevious()));
|
||||
|
||||
qApp->installEventFilter(this);
|
||||
parent->installEventFilter(this);
|
||||
}
|
||||
|
||||
QLineEdit* SearchToolBar::searchLine()
|
||||
|
@ -59,7 +59,7 @@ WebView::WebView(QWidget* parent)
|
||||
// Zoom levels same as in firefox
|
||||
m_zoomLevels << 30 << 50 << 67 << 80 << 90 << 100 << 110 << 120 << 133 << 150 << 170 << 200 << 240 << 300;
|
||||
|
||||
qApp->installEventFilter(this);
|
||||
installEventFilter(this);
|
||||
|
||||
mApp->plugins()->emitWebViewCreated(this);
|
||||
}
|
||||
|
@ -16,11 +16,10 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ============================================================ */
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "mainapplication.h"
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
void sigpipe_handler(int s)
|
||||
{
|
||||
|
@ -64,7 +64,6 @@ Qt::Key keyFromCode(int code)
|
||||
|
||||
AKN_Handler::AKN_Handler(const QString &sPath, QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_view(0)
|
||||
, m_accessKeysVisible(false)
|
||||
, m_settingsPath(sPath)
|
||||
{
|
||||
@ -129,7 +128,7 @@ bool AKN_Handler::handleKeyPress(QObject* obj, QKeyEvent* event)
|
||||
|
||||
bool AKN_Handler::eventFilter(QObject* obj, QEvent* event)
|
||||
{
|
||||
if (obj != m_view) {
|
||||
if (obj != m_view.data()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -188,13 +187,13 @@ void AKN_Handler::handleAccessKey(QKeyEvent* event)
|
||||
p -= frame->scrollPosition();
|
||||
frame = frame->parentFrame();
|
||||
}
|
||||
while (frame && frame != m_view->page()->currentFrame());
|
||||
while (frame && frame != m_view.data()->page()->currentFrame());
|
||||
|
||||
QMouseEvent pevent(QEvent::MouseButtonPress, p, Qt::LeftButton, 0, 0);
|
||||
qApp->sendEvent(m_view, &pevent);
|
||||
qApp->sendEvent(m_view.data(), &pevent);
|
||||
|
||||
QMouseEvent revent(QEvent::MouseButtonRelease, p, Qt::LeftButton, 0, 0);
|
||||
qApp->sendEvent(m_view, &revent);
|
||||
qApp->sendEvent(m_view.data(), &revent);
|
||||
|
||||
hideAccessKeys();
|
||||
}
|
||||
@ -206,7 +205,7 @@ void AKN_Handler::showAccessKeys()
|
||||
return;
|
||||
}
|
||||
|
||||
QWebPage* page = m_view->page();
|
||||
QWebPage* page = m_view.data()->page();
|
||||
|
||||
QStringList supportedElement;
|
||||
supportedElement << QLatin1String("input")
|
||||
@ -292,8 +291,8 @@ void AKN_Handler::showAccessKeys()
|
||||
// Install event filter and connect loadStarted
|
||||
m_accessKeysVisible = !m_accessKeyLabels.isEmpty();
|
||||
if (m_accessKeysVisible) {
|
||||
qApp->installEventFilter(this);
|
||||
connect(m_view, SIGNAL(loadStarted()), this, SLOT(hideAccessKeys()));
|
||||
m_view.data()->installEventFilter(this);
|
||||
connect(m_view.data(), SIGNAL(loadStarted()), this, SLOT(hideAccessKeys()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -307,11 +306,11 @@ void AKN_Handler::hideAccessKeys()
|
||||
}
|
||||
m_accessKeyLabels.clear();
|
||||
m_accessKeyNodes.clear();
|
||||
m_view->update();
|
||||
m_view.data()->update();
|
||||
|
||||
// Uninstall event filter and disconnect loadStarted
|
||||
qApp->removeEventFilter(this);
|
||||
disconnect(m_view, SIGNAL(loadStarted()), this, SLOT(hideAccessKeys()));
|
||||
m_view.data()->removeEventFilter(this);
|
||||
disconnect(m_view.data(), SIGNAL(loadStarted()), this, SLOT(hideAccessKeys()));
|
||||
}
|
||||
|
||||
m_accessKeysVisible = false;
|
||||
@ -319,7 +318,7 @@ void AKN_Handler::hideAccessKeys()
|
||||
|
||||
void AKN_Handler::makeAccessKeyLabel(const QChar &accessKey, const QWebElement &element)
|
||||
{
|
||||
QLabel* label = new QLabel(m_view);
|
||||
QLabel* label = new QLabel(m_view.data());
|
||||
label->setText(QString(QLatin1String("<b>%1</b>")).arg(accessKey));
|
||||
|
||||
QPalette p = QToolTip::palette();
|
||||
@ -331,7 +330,7 @@ void AKN_Handler::makeAccessKeyLabel(const QChar &accessKey, const QWebElement &
|
||||
label->setAutoFillBackground(true);
|
||||
label->setFrameStyle(QFrame::Box | QFrame::Plain);
|
||||
QPoint point = element.geometry().center();
|
||||
point -= m_view->page()->currentFrame()->scrollPosition();
|
||||
point -= m_view.data()->page()->currentFrame()->scrollPosition();
|
||||
label->move(point);
|
||||
label->show();
|
||||
point.setX(point.x() - label->width() / 2);
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <QTime>
|
||||
#include <QHash>
|
||||
#include <QWebElement>
|
||||
#include <QWeakPointer>
|
||||
|
||||
class QKeyEvent;
|
||||
class QWebElement;
|
||||
@ -56,7 +57,7 @@ private:
|
||||
void makeAccessKeyLabel(const QChar &accessKey, const QWebElement &element);
|
||||
void handleAccessKey(QKeyEvent* event);
|
||||
|
||||
WebView* m_view;
|
||||
QWeakPointer<WebView> m_view;
|
||||
|
||||
QList<QLabel*> m_accessKeyLabels;
|
||||
QHash<QChar, QWebElement> m_accessKeyNodes;
|
||||
|
@ -36,7 +36,7 @@ PluginSpec AKN_Plugin::pluginSpec()
|
||||
spec.name = "Access Keys Navigation";
|
||||
spec.info = "Access keys navigation for QupZilla";
|
||||
spec.description = "Provides support for navigating in webpages by keyboard shortcuts";
|
||||
spec.version = "0.3.1";
|
||||
spec.version = "0.3.2";
|
||||
spec.author = "David Rosca <nowrep@gmail.com>";
|
||||
spec.icon = QPixmap(":/accesskeysnavigation/data/icon.png");
|
||||
spec.hasSettings = true;
|
||||
|
@ -51,6 +51,7 @@ public:
|
||||
typedef const T* const_iterator;
|
||||
|
||||
RingBuffer() {
|
||||
array = 0;
|
||||
size = 0;
|
||||
read = 0;
|
||||
write = 0;
|
||||
|
@ -93,37 +93,65 @@ void MouseGestures::showSettings(QWidget* parent)
|
||||
|
||||
void MouseGestures::upGestured()
|
||||
{
|
||||
m_view->stop();
|
||||
if (!m_view) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_view.data()->stop();
|
||||
}
|
||||
|
||||
void MouseGestures::downGestured()
|
||||
{
|
||||
m_view->openUrlInNewTab(QUrl(), Qz::NT_CleanSelectedTabAtTheEnd);
|
||||
if (!m_view) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_view.data()->openUrlInNewTab(QUrl(), Qz::NT_CleanSelectedTabAtTheEnd);
|
||||
}
|
||||
|
||||
void MouseGestures::leftGestured()
|
||||
{
|
||||
m_view->back();
|
||||
if (!m_view) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_view.data()->back();
|
||||
}
|
||||
|
||||
void MouseGestures::rightGestured()
|
||||
{
|
||||
m_view->forward();
|
||||
if (!m_view) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_view.data()->forward();
|
||||
}
|
||||
|
||||
void MouseGestures::downRightGestured()
|
||||
{
|
||||
m_view->closeView();
|
||||
if (!m_view) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_view.data()->closeView();
|
||||
}
|
||||
|
||||
void MouseGestures::downLeftGestured()
|
||||
{
|
||||
m_view->load(mApp->getWindow()->homepageUrl());
|
||||
if (!m_view) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_view.data()->load(mApp->getWindow()->homepageUrl());
|
||||
}
|
||||
|
||||
void MouseGestures::upDownGestured()
|
||||
{
|
||||
m_view->reload();
|
||||
if (!m_view) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_view.data()->reload();
|
||||
}
|
||||
|
||||
MouseGestures::~MouseGestures()
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QMouseEvent>
|
||||
#include <QWeakPointer>
|
||||
|
||||
class WebView;
|
||||
class QjtMouseGestureFilter;
|
||||
@ -51,7 +52,7 @@ private slots:
|
||||
|
||||
private:
|
||||
QjtMouseGestureFilter* m_filter;
|
||||
WebView* m_view;
|
||||
QWeakPointer<WebView> m_view;
|
||||
|
||||
};
|
||||
|
||||
|
@ -35,7 +35,7 @@ PluginSpec MouseGesturesPlugin::pluginSpec()
|
||||
spec.name = "Mouse Gestures";
|
||||
spec.info = "Mouse gestures for QupZilla";
|
||||
spec.description = "Provides support for navigating in webpages by mouse gestures";
|
||||
spec.version = "0.1.0";
|
||||
spec.version = "0.2.1";
|
||||
spec.author = "David Rosca <nowrep@gmail.com>";
|
||||
spec.icon = QPixmap(":/mousegestures/data/icon.png");
|
||||
spec.hasSettings = true;
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
// Header + Footer
|
||||
$site_title = "QupZilla - 輕巧的跨平台瀏覽器";
|
||||
$qupzilla = "QupZilla";
|
||||
|
@ -19,6 +19,7 @@ TRANSLATIONS += $$PWD/cs_CZ.ts\
|
||||
$$PWD/ka_GE.ts\
|
||||
$$PWD/ja_JP.ts\
|
||||
$$PWD/ro_RO.ts\
|
||||
$$PWD/hu_HU.ts\
|
||||
|
||||
updateqm.input = TRANSLATIONS
|
||||
updateqm.output = $$PWD/../bin/locale/${QMAKE_FILE_BASE}.qm
|
||||
|
Loading…
Reference in New Issue
Block a user