diff --git a/src/lib/other/sourceviewersearch.cpp b/src/lib/other/sourceviewersearch.cpp index d4f364711..ca97f87ac 100644 --- a/src/lib/other/sourceviewersearch.cpp +++ b/src/lib/other/sourceviewersearch.cpp @@ -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() diff --git a/src/lib/other/statusbarmessage.cpp b/src/lib/other/statusbarmessage.cpp index 448f9bc15..307fdc230 100644 --- a/src/lib/other/statusbarmessage.cpp +++ b/src/lib/other/statusbarmessage.cpp @@ -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); } } diff --git a/src/lib/other/statusbarmessage.h b/src/lib/other/statusbarmessage.h index 58a82e7f3..6ba5613d3 100644 --- a/src/lib/other/statusbarmessage.h +++ b/src/lib/other/statusbarmessage.h @@ -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); diff --git a/src/lib/popupwindow/popupstatusbarmessage.cpp b/src/lib/popupwindow/popupstatusbarmessage.cpp index 6740d730c..346d49aeb 100644 --- a/src/lib/popupwindow/popupstatusbarmessage.cpp +++ b/src/lib/popupwindow/popupstatusbarmessage.cpp @@ -69,7 +69,7 @@ void PopupStatusBarMessage::showMessage(const QString &message) } m_statusBarText->move(view->mapToGlobal(position)); - m_statusBarText->show(); + m_statusBarText->show(view); } } diff --git a/src/lib/webview/searchtoolbar.cpp b/src/lib/webview/searchtoolbar.cpp index fae843d34..f8eae0d6c 100644 --- a/src/lib/webview/searchtoolbar.cpp +++ b/src/lib/webview/searchtoolbar.cpp @@ -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() diff --git a/src/lib/webview/webview.cpp b/src/lib/webview/webview.cpp index 40bb82703..63a3491aa 100644 --- a/src/lib/webview/webview.cpp +++ b/src/lib/webview/webview.cpp @@ -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); } diff --git a/src/main/main.cpp b/src/main/main.cpp index 0d7031c3d..03010e675 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -16,11 +16,10 @@ * along with this program. If not, see . * ============================================================ */ -#include - #include "mainapplication.h" #ifdef Q_WS_X11 +#include #include void sigpipe_handler(int s) { diff --git a/src/plugins/AccessKeysNavigation/akn_handler.cpp b/src/plugins/AccessKeysNavigation/akn_handler.cpp index b1574c817..92c05f363 100644 --- a/src/plugins/AccessKeysNavigation/akn_handler.cpp +++ b/src/plugins/AccessKeysNavigation/akn_handler.cpp @@ -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("%1")).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); diff --git a/src/plugins/AccessKeysNavigation/akn_handler.h b/src/plugins/AccessKeysNavigation/akn_handler.h index 395378591..1871f2414 100644 --- a/src/plugins/AccessKeysNavigation/akn_handler.h +++ b/src/plugins/AccessKeysNavigation/akn_handler.h @@ -22,6 +22,7 @@ #include #include #include +#include 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 m_view; QList m_accessKeyLabels; QHash m_accessKeyNodes; diff --git a/src/plugins/AccessKeysNavigation/akn_plugin.cpp b/src/plugins/AccessKeysNavigation/akn_plugin.cpp index 51ef304d5..81604e2bb 100644 --- a/src/plugins/AccessKeysNavigation/akn_plugin.cpp +++ b/src/plugins/AccessKeysNavigation/akn_plugin.cpp @@ -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 "; spec.icon = QPixmap(":/accesskeysnavigation/data/icon.png"); spec.hasSettings = true; diff --git a/src/plugins/MouseGestures/3rdparty/ring_buffer.h b/src/plugins/MouseGestures/3rdparty/ring_buffer.h index 5fcac9d56..eac30ec55 100644 --- a/src/plugins/MouseGestures/3rdparty/ring_buffer.h +++ b/src/plugins/MouseGestures/3rdparty/ring_buffer.h @@ -51,6 +51,7 @@ public: typedef const T* const_iterator; RingBuffer() { + array = 0; size = 0; read = 0; write = 0; diff --git a/src/plugins/MouseGestures/mousegestures.cpp b/src/plugins/MouseGestures/mousegestures.cpp index af839ff73..5dd1b63a8 100644 --- a/src/plugins/MouseGestures/mousegestures.cpp +++ b/src/plugins/MouseGestures/mousegestures.cpp @@ -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() diff --git a/src/plugins/MouseGestures/mousegestures.h b/src/plugins/MouseGestures/mousegestures.h index 55ae7386b..7ab24fc29 100644 --- a/src/plugins/MouseGestures/mousegestures.h +++ b/src/plugins/MouseGestures/mousegestures.h @@ -20,6 +20,7 @@ #include #include +#include class WebView; class QjtMouseGestureFilter; @@ -51,7 +52,7 @@ private slots: private: QjtMouseGestureFilter* m_filter; - WebView* m_view; + QWeakPointer m_view; }; diff --git a/src/plugins/MouseGestures/mousegesturesplugin.cpp b/src/plugins/MouseGestures/mousegesturesplugin.cpp index 6b84fbfee..ab6072c86 100644 --- a/src/plugins/MouseGestures/mousegesturesplugin.cpp +++ b/src/plugins/MouseGestures/mousegesturesplugin.cpp @@ -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 "; spec.icon = QPixmap(":/mousegestures/data/icon.png"); spec.hasSettings = true; diff --git a/translations/homepage/zh_TW.php b/translations/homepage/zh_TW.php index ce31abf7c..88da0ff5d 100644 --- a/translations/homepage/zh_TW.php +++ b/translations/homepage/zh_TW.php @@ -1,4 +1,4 @@ -