1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

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)
This commit is contained in:
nowrep 2012-03-21 13:00:30 +01:00
parent 6833fb9202
commit c7187bf064
9 changed files with 43 additions and 13 deletions

View File

@ -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

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>550</width>
<height>350</height>
<height>370</height>
</rect>
</property>
<property name="minimumSize">

View File

@ -27,6 +27,7 @@
#include <QToolTip>
#include <QStylePainter>
#include <QWebFrame>
#include <QTimer>
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();
}
}

View File

@ -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

View File

@ -79,6 +79,6 @@ void PopupStatusBarMessage::clearMessage()
m_popupWindow->statusBar()->showMessage("");
}
else {
m_statusBarText->hide();
m_statusBarText->hideDelayed();
}
}

View File

@ -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

View File

@ -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

View File

@ -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<QWebElement> alreadyLabeled;
foreach(const QString & elementType, supportedElement) {
QList<QWebElement> result = page->mainFrame()->findAllElements(elementType).toList();
QList<QWebElement> 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);

View File

@ -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 <nowrep@gmail.com>";
spec.icon = QPixmap(":/accesskeysnavigation/data/icon.png");
spec.hasSettings = true;