]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinnavigatorswidgetaction.cpp
D-Bus activation systemd service
[dolphin.git] / src / dolphinnavigatorswidgetaction.cpp
index 84f52279a56471afc1bc109f56efd5e1b7ec3820..e0ae3132acb6a073dcc45bc13685d290b99547b4 100644 (file)
@@ -13,6 +13,7 @@
 #include <KXMLGUIFactory>
 #include <KXmlGuiWindow>
 
+#include <QApplication>
 #include <QDomDocument>
 #include <QHBoxLayout>
 #include <QPushButton>
@@ -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();
 }
@@ -201,7 +212,7 @@ QWidget *DolphinNavigatorsWidgetAction::createNavigatorWidget(Side side) const
     auto emptyTrashButton = newEmptyTrashButton(urlNavigator, navigatorWidget);
     layout->addWidget(emptyTrashButton);
 
-    connect(urlNavigator, &KUrlNavigator::urlChanged, [this]() {
+    connect(urlNavigator, &KUrlNavigator::urlChanged, this, [this]() {
         // We have to wait for DolphinUrlNavigator::sizeHint() to update which
         // happens a little bit later than when urlChanged is emitted.
         this->m_adjustSpacingTimer->start();
@@ -231,7 +242,7 @@ QPushButton *DolphinNavigatorsWidgetAction::newEmptyTrashButton(const DolphinUrl
     connect(&Trash::instance(), &Trash::emptinessChanged,
             emptyTrashButton, &QPushButton::setDisabled);
     emptyTrashButton->hide();
-    connect(urlNavigator, &KUrlNavigator::urlChanged, [emptyTrashButton, urlNavigator]() {
+    connect(urlNavigator, &KUrlNavigator::urlChanged, this, [emptyTrashButton, urlNavigator]() {
         emptyTrashButton->setVisible(urlNavigator->locationUrl().scheme() == QLatin1String("trash"));
     });
     emptyTrashButton->setDisabled(Trash::isEmpty());