summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2019-06-06 02:55:22 +0000
committerJan-Marek Glogowski <glogow@fbihome.de>2019-06-22 16:20:46 +0200
commit1795adce52b614cc6f12ea313f1c377fefbf2351 (patch)
treec21b725cefa6cf2703a3912c77238b8eb62f3adf /vcl
parent24c21375f9983428cabf46407943a2b2daa5a8f0 (diff)
Qt5 fix some broken RTL handling
For RTL decisions we always use Qt's own setting after setting it on startup using QGuiApplication::setLayoutDirection. The only difference between LO and Qt events is the mirrored cursor position, which needs explicit mirroring before reporting mouse based events (mouse and wheel). Tooltips and frame positioning will be handled in separate patches. Additionally the horizontal scroll bar direction hack based on the scroll bar button positions, needs to handle RTL explicitly. Change-Id: I5ce5e69113a6cb6a9cf37a449265c49d92a7c159 Reviewed-on: https://gerrit.libreoffice.org/74545 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qt5/Qt5Graphics_Controls.cxx6
-rw-r--r--vcl/qt5/Qt5Instance.cxx2
-rw-r--r--vcl/qt5/Qt5Widget.cxx8
3 files changed, 12 insertions, 4 deletions
diff --git a/vcl/qt5/Qt5Graphics_Controls.cxx b/vcl/qt5/Qt5Graphics_Controls.cxx
index 73a47e5e5ffa..32a2d132efc5 100644
--- a/vcl/qt5/Qt5Graphics_Controls.cxx
+++ b/vcl/qt5/Qt5Graphics_Controls.cxx
@@ -518,7 +518,11 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part,
option.sliderPosition = sbVal->mnCur;
option.pageStep = sbVal->mnVisibleSize;
if (part == ControlPart::DrawBackgroundHorz)
- option.upsideDown = sbVal->maButton1Rect.Left() > sbVal->maButton2Rect.Left();
+ option.upsideDown
+ = (QGuiApplication::isRightToLeft()
+ && sbVal->maButton1Rect.Left() < sbVal->maButton2Rect.Left())
+ || (QGuiApplication::isLeftToRight()
+ && sbVal->maButton1Rect.Left() > sbVal->maButton2Rect.Left());
//setup the active control... always the slider
if (sbVal->mnThumbState & ControlState::ROLLOVER)
diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
index 6c872b84cb0a..86c94ba792de 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -247,6 +247,8 @@ void Qt5Instance::AfterAppInit()
// as this otherwise overrides the individual desktop icons on X11.
if (QGuiApplication::platformName() == "wayland")
QGuiApplication::setDesktopFileName(QStringLiteral("libreoffice-startcenter.desktop"));
+ QGuiApplication::setLayoutDirection(AllSettings::GetLayoutRTL() ? Qt::RightToLeft
+ : Qt::LeftToRight);
}
void Qt5Instance::deleteObjectLater(QObject* pObject) { pObject->deleteLater(); }
diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index 657c5e8e73f7..dac72b0c764e 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -141,7 +141,9 @@ void Qt5Widget::handleMouseButtonEvent(const Qt5Frame& rFrame, QMouseEvent* pEve
}
aEvent.mnTime = pEvent->timestamp();
- aEvent.mnX = static_cast<long>(pEvent->pos().x());
+ aEvent.mnX = static_cast<long>(QGuiApplication::isLeftToRight()
+ ? pEvent->pos().x()
+ : rFrame.GetQWidget()->width() - pEvent->pos().x());
aEvent.mnY = static_cast<long>(pEvent->pos().y());
aEvent.mnCode = GetKeyModCode(pEvent->modifiers()) | GetMouseModCode(pEvent->buttons());
@@ -166,7 +168,7 @@ void Qt5Widget::mouseMoveEvent(QMouseEvent* pEvent)
SalMouseEvent aEvent;
aEvent.mnTime = pEvent->timestamp();
- aEvent.mnX = point.x();
+ aEvent.mnX = QGuiApplication::isLeftToRight() ? point.x() : width() - point.x();
aEvent.mnY = point.y();
aEvent.mnCode = GetKeyModCode(pEvent->modifiers()) | GetMouseModCode(pEvent->buttons());
aEvent.mnButton = 0;
@@ -191,7 +193,7 @@ void Qt5Widget::wheelEvent(QWheelEvent* pEvent)
aEvent.mbHorz = nDelta == 0;
if (aEvent.mbHorz)
{
- nDelta = pEvent->angleDelta().x();
+ nDelta = (QGuiApplication::isLeftToRight() ? -1 : 1) * pEvent->angleDelta().x();
if (!nDelta)
return;