From c7187bf06498698efaa42c9caf3effb0b3f07c06 Mon Sep 17 00:00:00 2001 From: nowrep Date: Wed, 21 Mar 2012 13:00:30 +0100 Subject: [PATCH] AKN plugin now correctly shows keys on pages with more frames - it works fine now for example on gmail - status bar overlay now hides after small delay (500ms) --- QupZilla.pro | 2 +- .../bookmarksimport/bookmarksimportdialog.ui | 2 +- src/lib/other/statusbarmessage.cpp | 20 ++++++++++++++++++- src/lib/other/statusbarmessage.h | 9 ++++++++- src/lib/popupwindow/popupstatusbarmessage.cpp | 2 +- src/main/main.pro | 3 +++ src/plugins.pri | 3 ++- .../AccessKeysNavigation/akn_handler.cpp | 11 +++++----- .../AccessKeysNavigation/akn_plugin.cpp | 4 ++-- 9 files changed, 43 insertions(+), 13 deletions(-) diff --git a/QupZilla.pro b/QupZilla.pro index f534e4d0a..fb4b1f07e 100644 --- a/QupZilla.pro +++ b/QupZilla.pro @@ -11,7 +11,7 @@ lessThan(QT_VERSION, 4.7) { } # Create plugins directory first on Mac / Linux -mac|unix: system(mkdir bin/plugins) +mac|unix: system(test -d bin/plugins || mkdir bin/plugins) TEMPLATE = subdirs SUBDIRS = src diff --git a/src/lib/bookmarksimport/bookmarksimportdialog.ui b/src/lib/bookmarksimport/bookmarksimportdialog.ui index d758bd70c..238a0804b 100644 --- a/src/lib/bookmarksimport/bookmarksimportdialog.ui +++ b/src/lib/bookmarksimport/bookmarksimportdialog.ui @@ -7,7 +7,7 @@ 0 0 550 - 350 + 370 diff --git a/src/lib/other/statusbarmessage.cpp b/src/lib/other/statusbarmessage.cpp index e710970fa..448f9bc15 100644 --- a/src/lib/other/statusbarmessage.cpp +++ b/src/lib/other/statusbarmessage.cpp @@ -27,6 +27,7 @@ #include #include #include +#include TipLabel::TipLabel(QWidget* parent) : SqueezeLabelV1(parent) @@ -39,9 +40,26 @@ TipLabel::TipLabel(QWidget* parent) setFrameStyle(QFrame::NoFrame); setMargin(3); + m_timer = new QTimer(this); + m_timer->setSingleShot(true); + m_timer->setInterval(500); + connect(m_timer, SIGNAL(timeout()), this, SLOT(hide())); + qApp->installEventFilter(this); } +void TipLabel::show() +{ + m_timer->stop(); + + SqueezeLabelV1::show(); +} + +void TipLabel::hideDelayed() +{ + m_timer->start(); +} + void TipLabel::paintEvent(QPaintEvent* ev) { QStylePainter p(this); @@ -128,6 +146,6 @@ void StatusBarMessage::clearMessage() p_QupZilla->statusBar()->showMessage(""); } else { - m_statusBarText->hide(); + m_statusBarText->hideDelayed(); } } diff --git a/src/lib/other/statusbarmessage.h b/src/lib/other/statusbarmessage.h index dcc49715e..58a82e7f3 100644 --- a/src/lib/other/statusbarmessage.h +++ b/src/lib/other/statusbarmessage.h @@ -24,17 +24,24 @@ #include "squeezelabelv1.h" #include "animatedwidget.h" +class QTimer; + class QupZilla; class QT_QUPZILLA_EXPORT TipLabel : public SqueezeLabelV1 { public: - TipLabel(QWidget* parent); + explicit TipLabel(QWidget* parent); + + void show(); + void hideDelayed(); bool eventFilter(QObject* o, QEvent* e); private: void paintEvent(QPaintEvent* ev); + + QTimer* m_timer; }; class QT_QUPZILLA_EXPORT StatusBarMessage diff --git a/src/lib/popupwindow/popupstatusbarmessage.cpp b/src/lib/popupwindow/popupstatusbarmessage.cpp index c47be3248..6740d730c 100644 --- a/src/lib/popupwindow/popupstatusbarmessage.cpp +++ b/src/lib/popupwindow/popupstatusbarmessage.cpp @@ -79,6 +79,6 @@ void PopupStatusBarMessage::clearMessage() m_popupWindow->statusBar()->showMessage(""); } else { - m_statusBarText->hide(); + m_statusBarText->hideDelayed(); } } diff --git a/src/main/main.pro b/src/main/main.pro index 5ff227519..8e0b3b85a 100644 --- a/src/main/main.pro +++ b/src/main/main.pro @@ -2,7 +2,10 @@ QT += core gui webkit sql network script unix: QT += dbus TARGET = qupzilla +mac: TARGET = QupZilla + TEMPLATE = app + !unix|mac: LIBS += -L../../bin -lqupzilla !mac:unix: LIBS += ../../bin/libqupzilla.so diff --git a/src/plugins.pri b/src/plugins.pri index c2310a999..f1c07a50b 100644 --- a/src/plugins.pri +++ b/src/plugins.pri @@ -33,7 +33,8 @@ MOC_DIR = build RCC_DIR = build UI_DIR = build -LIBS += -L$$PWD/../bin -lqupzilla +!unix|mac: LIBS += -L$$PWD/../bin -lqupzilla +!mac:unix: LIBS += $$PWD/../bin/libqupzilla.so !mac:unix { target.path = $$library_folder/qupzilla diff --git a/src/plugins/AccessKeysNavigation/akn_handler.cpp b/src/plugins/AccessKeysNavigation/akn_handler.cpp index 04ffd48a8..b1574c817 100644 --- a/src/plugins/AccessKeysNavigation/akn_handler.cpp +++ b/src/plugins/AccessKeysNavigation/akn_handler.cpp @@ -99,6 +99,7 @@ bool AKN_Handler::handleKeyPress(QObject* obj, QKeyEvent* event) } if (event->key() != m_key) { + m_lastKeyPressTime = QTime(); return false; } @@ -187,7 +188,7 @@ void AKN_Handler::handleAccessKey(QKeyEvent* event) p -= frame->scrollPosition(); frame = frame->parentFrame(); } - while (frame && frame != m_view->page()->mainFrame()); + while (frame && frame != m_view->page()->currentFrame()); QMouseEvent pevent(QEvent::MouseButtonPress, p, Qt::LeftButton, 0, 0); qApp->sendEvent(m_view, &pevent); @@ -227,11 +228,11 @@ void AKN_Handler::showAccessKeys() unusedKeys << QLatin1Char(c); } - QRect viewport = QRect(page->mainFrame()->scrollPosition(), page->viewportSize()); + QRect viewport = QRect(page->currentFrame()->scrollPosition(), page->viewportSize()); // Priority first goes to elements with accesskey attributes QList alreadyLabeled; foreach(const QString & elementType, supportedElement) { - QList result = page->mainFrame()->findAllElements(elementType).toList(); + QList result = page->currentFrame()->findAllElements(elementType).toList(); foreach(const QWebElement & element, result) { const QRect geometry = element.geometry(); if (geometry.size().isEmpty() @@ -262,7 +263,7 @@ void AKN_Handler::showAccessKeys() // Pick an access key first from the letters in the text and then from the // list of unused access keys foreach(const QString & elementType, supportedElement) { - QWebElementCollection result = page->mainFrame()->findAllElements(elementType); + QWebElementCollection result = page->currentFrame()->findAllElements(elementType); foreach(const QWebElement & element, result) { const QRect geometry = element.geometry(); if (unusedKeys.isEmpty() @@ -330,7 +331,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()->mainFrame()->scrollPosition(); + point -= m_view->page()->currentFrame()->scrollPosition(); label->move(point); label->show(); point.setX(point.x() - label->width() / 2); diff --git a/src/plugins/AccessKeysNavigation/akn_plugin.cpp b/src/plugins/AccessKeysNavigation/akn_plugin.cpp index d890fc78b..0230fb70b 100644 --- a/src/plugins/AccessKeysNavigation/akn_plugin.cpp +++ b/src/plugins/AccessKeysNavigation/akn_plugin.cpp @@ -18,7 +18,7 @@ #include "akn_plugin.h" #include "akn_handler.h" #include "akn_settings.h" -#include "mainapplication.h" +#include "mainapplication.h #include "pluginproxy.h" #include "qupzilla.h" @@ -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.2.2"; + spec.version = "0.3.1"; spec.author = "David Rosca "; spec.icon = QPixmap(":/accesskeysnavigation/data/icon.png"); spec.hasSettings = true;