[Libreoffice-commits] core.git: vcl/qt5

Jan-Marek Glogowski (via logerrit) logerrit at kemper.freedesktop.org
Sat Jun 22 14:21:35 UTC 2019


 vcl/qt5/Qt5Graphics_Controls.cxx |    6 +++++-
 vcl/qt5/Qt5Instance.cxx          |    2 ++
 vcl/qt5/Qt5Widget.cxx            |    8 +++++---
 3 files changed, 12 insertions(+), 4 deletions(-)

New commits:
commit 1795adce52b614cc6f12ea313f1c377fefbf2351
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Thu Jun 6 02:55:22 2019 +0000
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Sat Jun 22 16:20:46 2019 +0200

    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 at fbihome.de>

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;
 


More information about the Libreoffice-commits mailing list