]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinviewcontainer.cpp
port to KIO::createDefaultJobUiDelegate
[dolphin.git] / src / dolphinviewcontainer.cpp
index c801d095d95e04a819b85389d026f11958a4c065..1930226d8f2442ba29e39ec519bd0b4f147ab53a 100644 (file)
 #endif
 #include <KFileItemActions>
 #include <KFilePlacesModel>
-#include <KIO/PreviewJob>
-#include <KIO/OpenUrlJob>
+#include <kio_version.h>
+#if KIO_VERSION >= QT_VERSION_CHECK(5, 98, 0)
+#include <KIO/JobUiDelegateFactory>
+#else
 #include <KIO/JobUiDelegate>
+#endif
+#include <KIO/OpenUrlJob>
 #include <KLocalizedString>
 #include <KMessageWidget>
 #include <KProtocolManager>
 #include <KShell>
-#include <KUrlComboBox>
 
+#include <QDesktopServices>
 #include <QDropEvent>
 #include <QGridLayout>
 #include <QGuiApplication>
-#include <QLoggingCategory>
-#include <QMimeData>
 #include <QTimer>
 #include <QUrl>
-#include <QDesktopServices>
+#include <QRegularExpression>
 
 // An overview of the widgets contained by this ViewContainer
 struct LayoutStructure {
@@ -376,16 +378,17 @@ void DolphinViewContainer::disconnectUrlNavigator()
 void DolphinViewContainer::setSelectionModeEnabled(bool enabled, KActionCollection *actionCollection, SelectionMode::BottomBar::Contents bottomBarContents)
 {
     const bool wasEnabled = m_view->selectionMode();
-    m_view->setSelectionMode(enabled);
+    m_view->setSelectionModeEnabled(enabled);
 
     if (!enabled) {
+        if (!wasEnabled) {
+            return; // nothing to do here
+        }
         Q_CHECK_PTR(m_selectionModeTopBar); // there is no point in disabling selectionMode when it wasn't even enabled once.
         Q_CHECK_PTR(m_selectionModeBottomBar);
         m_selectionModeTopBar->setVisible(false, WithAnimation);
         m_selectionModeBottomBar->setVisible(false, WithAnimation);
-        if (wasEnabled) {
-            Q_EMIT selectionModeChanged(false);
-        }
+        Q_EMIT selectionModeChanged(false);
         return;
     }
 
@@ -396,7 +399,7 @@ void DolphinViewContainer::setSelectionModeEnabled(bool enabled, KActionCollecti
         });
 
         m_selectionModeTopBar = new SelectionMode::TopBar(this); // will be created hidden
-        connect(m_selectionModeTopBar, &SelectionMode::TopBar::leaveSelectionModeRequested, this, [this]() {
+        connect(m_selectionModeTopBar, &SelectionMode::TopBar::selectionModeLeavingRequested, this, [this]() {
             setSelectionModeEnabled(false);
         });
         m_topLayout->addWidget(m_selectionModeTopBar, positionFor.selectionModeTopBar, 0);
@@ -410,7 +413,7 @@ void DolphinViewContainer::setSelectionModeEnabled(bool enabled, KActionCollecti
         connect(m_selectionModeBottomBar, &SelectionMode::BottomBar::error, this, [this](const QString &errorMessage) {
             showErrorMessage(errorMessage);
         });
-        connect(m_selectionModeBottomBar, &SelectionMode::BottomBar::leaveSelectionModeRequested, this, [this]() {
+        connect(m_selectionModeBottomBar, &SelectionMode::BottomBar::selectionModeLeavingRequested, this, [this]() {
             setSelectionModeEnabled(false);
         });
         m_topLayout->addWidget(m_selectionModeBottomBar, positionFor.selectionModeBottomBar, 0);
@@ -760,7 +763,11 @@ void DolphinViewContainer::slotItemActivated(const KFileItem &item)
     }
 
     KIO::OpenUrlJob *job = new KIO::OpenUrlJob(item.targetUrl(), item.mimetype());
-    job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoWarningHandlingEnabled, this));
+#if KIO_VERSION >= QT_VERSION_CHECK(5, 98, 0)
+    job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this));
+#else
+    job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this));
+#endif
     job->setShowOpenOrExecuteDialog(true);
     connect(job, &KIO::OpenUrlJob::finished, this, &DolphinViewContainer::slotOpenUrlFinished);
     job->start();