From 4f645f1b29f0f858b14eed5eca77bf941b52d150 Mon Sep 17 00:00:00 2001 From: Felix Ernst Date: Wed, 11 Nov 2020 15:40:14 +0100 Subject: [PATCH] Fix navigator alignment for right-to-left localizations --- src/dolphinnavigatorswidgetaction.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/dolphinnavigatorswidgetaction.cpp b/src/dolphinnavigatorswidgetaction.cpp index 984e1f35c..e0ae3132a 100644 --- a/src/dolphinnavigatorswidgetaction.cpp +++ b/src/dolphinnavigatorswidgetaction.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -90,10 +91,20 @@ void DolphinNavigatorsWidgetAction::followViewContainersGeometry( int globalXOfPrimary, int widthOfPrimary, int globalXOfSecondary, int widthOfSecondary) { - m_globalXOfSplitter = m_splitter->mapToGlobal(QPoint(0,0)).x(); - m_globalXOfPrimary = globalXOfPrimary; + if (QApplication::layoutDirection() == Qt::LeftToRight) { + m_globalXOfSplitter = m_splitter->mapToGlobal(QPoint(0,0)).x(); + m_globalXOfPrimary = globalXOfPrimary; + m_globalXOfSecondary = globalXOfSecondary; + } else { + // When the direction is reversed, globalX does not change. + // For the adjustSpacing() code to work we need globalX to measure from right to left + // and to measure up to the rightmost point of a widget instead of the leftmost. + m_globalXOfSplitter = (-1) * (m_splitter->mapToGlobal(QPoint(0,0)).x() + m_splitter->width()); + m_globalXOfPrimary = (-1) * (globalXOfPrimary + widthOfPrimary); + m_globalXOfSecondary = (globalXOfSecondary == INT_MIN) ? INT_MIN : + (-1) * (globalXOfSecondary + widthOfSecondary); + } m_widthOfPrimary = widthOfPrimary; - m_globalXOfSecondary = globalXOfSecondary; m_widthOfSecondary = widthOfSecondary; adjustSpacing(); } -- 2.47.3