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>
(cherry picked from commit 1795adce52b614cc6f12ea313f1c377fefbf2351)
Reviewed-on: https://gerrit.libreoffice.org/74564
diff --git a/vcl/qt5/Qt5Graphics_Controls.cxx b/vcl/qt5/Qt5Graphics_Controls.cxx
index 4cc108f..c8f7069 100644
--- a/vcl/qt5/Qt5Graphics_Controls.cxx
+++ b/vcl/qt5/Qt5Graphics_Controls.cxx
@@ -494,7 +494,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 556e8a6..0494720 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -246,6 +246,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 b46b48b..4513ab9 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -140,7 +140,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());
@@ -165,7 +167,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;
@@ -190,7 +192,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;