]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinmainwindow.cpp
Fix item highlighting through DBus
[dolphin.git] / src / dolphinmainwindow.cpp
index d383d04d6d4bc8b48d7cd329fb623b981ea922bc..305c7f2821b8366182aca1665adcd9ef1532c2cf 100644 (file)
 #include <KDualAction>
 #include <KFileItemListProperties>
 #include <KIO/CommandLauncherJob>
+#include <kio_version.h>
+#if KIO_VERSION >= QT_VERSION_CHECK(5, 98, 0)
+#include <KIO/JobUiDelegateFactory>
+#else
 #include <KIO/JobUiDelegate>
+#endif
 #include <KIO/OpenFileManagerWindowJob>
 #include <KIO/OpenUrlJob>
 #include <KJobWidgets>
@@ -810,7 +815,6 @@ void DolphinMainWindow::slotAboutToShowBackPopupMenu()
     m_backAction->menu()->clear();
     for (int i = urlNavigator->historyIndex() + 1; i < urlNavigator->historySize() && entries < MaxNumberOfNavigationentries; ++i, ++entries) {
         QAction *action = urlNavigatorHistoryAction(urlNavigator, i, m_backAction->menu());
-        action->setData(i);
         m_backAction->menu()->addAction(action);
     }
 }
@@ -839,7 +843,6 @@ void DolphinMainWindow::slotAboutToShowForwardPopupMenu()
     m_forwardAction->menu()->clear();
     for (int i = urlNavigator->historyIndex() - 1; i >= 0 && entries < MaxNumberOfNavigationentries; --i, ++entries) {
         QAction *action = urlNavigatorHistoryAction(urlNavigator, i, m_forwardAction->menu());
-        action->setData(i);
         m_forwardAction->menu()->addAction(action);
     }
 }
@@ -1243,7 +1246,11 @@ void DolphinMainWindow::handleUrl(const QUrl& url)
         activeViewContainer()->setUrl(url);
     } else {
         m_lastHandleUrlOpenJob = new KIO::OpenUrlJob(url);
+#if KIO_VERSION >= QT_VERSION_CHECK(5, 98, 0)
+        m_lastHandleUrlOpenJob->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this));
+#else
         m_lastHandleUrlOpenJob->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this));
+#endif
         m_lastHandleUrlOpenJob->setShowOpenOrExecuteDialog(true);
 
         connect(m_lastHandleUrlOpenJob, &KIO::OpenUrlJob::mimeTypeFound, this,
@@ -1433,6 +1440,10 @@ void DolphinMainWindow::activeViewChanged(DolphinViewContainer* viewContainer)
         // except the requestItemInfo so that on hover the information panel can still be updated
         connect(oldViewContainer->view(), &DolphinView::requestItemInfo,
                 this, &DolphinMainWindow::requestItemInfo);
+
+        // Disconnect other slots.
+        disconnect(nullptr, &DolphinViewContainer::selectionModeChanged,
+                   actionCollection()->action(QStringLiteral("toggle_selection_mode")), &QAction::setChecked);
     }
 
     connectViewSignals(viewContainer);
@@ -2286,13 +2297,6 @@ void DolphinMainWindow::updateViewActions()
 {
     m_actionHandler->updateViewActions();
 
-    QAction *toggleSelectionModeAction = actionCollection()->action(QStringLiteral("toggle_selection_mode"));
-    disconnect(nullptr, &DolphinViewContainer::selectionModeChanged,
-               toggleSelectionModeAction, &QAction::setChecked);
-    toggleSelectionModeAction->setChecked(m_activeViewContainer->isSelectionModeEnabled());
-    connect(m_activeViewContainer, &DolphinViewContainer::selectionModeChanged,
-            toggleSelectionModeAction, &QAction::setChecked);
-
     QAction* toggleFilterBarAction = actionCollection()->action(QStringLiteral("toggle_filter"));
     toggleFilterBarAction->setChecked(m_activeViewContainer->isFilterBarVisible());
 
@@ -2350,6 +2354,12 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container)
     const QAction* toggleSearchAction = actionCollection()->action(QStringLiteral("toggle_search"));
     connect(toggleSearchAction, &QAction::triggered, container, &DolphinViewContainer::setSearchModeEnabled);
 
+    // Make the toggled state of the selection mode actions visually follow the selection mode state of the view.
+    auto toggleSelectionModeAction = actionCollection()->action(QStringLiteral("toggle_selection_mode"));
+    toggleSelectionModeAction->setChecked(m_activeViewContainer->isSelectionModeEnabled());
+    connect(m_activeViewContainer, &DolphinViewContainer::selectionModeChanged,
+            toggleSelectionModeAction, &QAction::setChecked);
+
     const DolphinView* view = container->view();
     connect(view, &DolphinView::selectionChanged,
             this, &DolphinMainWindow::slotSelectionChanged);
@@ -2670,7 +2680,7 @@ bool DolphinMainWindow::isUrlOpen(const QString &url)
     return m_tabWidget->isUrlOpen(QUrl::fromUserInput(url));
 }
 
-bool DolphinMainWindow::isUrlOrParentOpen(const QString &url)
+bool DolphinMainWindow::isItemVisibleInAnyView(const QString &urlOfItem)
 {
-    return m_tabWidget->isUrlOrParentOpen(QUrl::fromUserInput(url));
+    return m_tabWidget->isItemVisibleInAnyView(QUrl::fromUserInput(urlOfItem));
 }