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

Fixed, sent correct event for right/left key on RTL layouts.

-see #839
This commit is contained in:
S. Razi Alavizadeh 2013-04-09 18:27:44 +04:30
parent fe6e450a44
commit 7c9b30c443

View File

@ -1229,7 +1229,20 @@ void WebView::keyPressEvent(QKeyEvent* event)
return;
}
switch (event->key()) {
int eventKey = event->key();
bool rightOrLeft = eventKey == Qt::Key_Left || eventKey == Qt::Key_Right;
if (rightOrLeft) {
const QWebElement &elementHasCursor = activeElement();
if (!elementHasCursor.isNull()) {
bool isRTL = elementHasCursor.styleProperty("direction", QWebElement::ComputedStyle) == QLatin1String("rtl");
if (isRTL) {
eventKey = eventKey == Qt::Key_Left ? Qt::Key_Right : Qt::Key_Left;
}
}
}
switch (eventKey) {
case Qt::Key_C:
if (event->modifiers() == Qt::ControlModifier) {
triggerPageAction(QWebPage::Copy);
@ -1318,6 +1331,8 @@ void WebView::keyPressEvent(QKeyEvent* event)
break;
}
event = new QKeyEvent(event->type(), eventKey, event->modifiers(),
event->text(), event->isAutoRepeat());
QWebView::keyPressEvent(event);
}