]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinpart.cpp
Fix file preview for desktop files with absolute icon paths
[dolphin.git] / src / dolphinpart.cpp
index f5d4f95b64e95ed21713147ac8a3346c422bb5cc..7e7425121ca81105c7016630a2b6d9289550d5d6 100644 (file)
@@ -40,6 +40,7 @@
 #include <KLocalizedString>
 #include <KMessageBox>
 #include <KMimeTypeEditor>
+#include <KNS3/KMoreToolsMenuFactory>
 #include <KPluginFactory>
 #include <KRun>
 #include <KSharedConfig>
@@ -76,7 +77,7 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL
     connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage,
             this, &DolphinPart::slotErrorMessage);
 
-    connect(m_view, &DolphinView::directoryLoadingCompleted, this, static_cast<void(DolphinPart::*)()>(&DolphinPart::completed));
+    connect(m_view, &DolphinView::directoryLoadingCompleted, this, QOverload<>::of(&KParts::ReadOnlyPart::completed));
     connect(m_view, &DolphinView::directoryLoadingCompleted, this, &DolphinPart::updatePasteAction);
     connect(m_view, &DolphinView::directoryLoadingProgress, this, &DolphinPart::updateProgress);
     connect(m_view, &DolphinView::errorMessage, this, &DolphinPart::slotErrorMessage);
@@ -98,7 +99,7 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL
     connect(m_view, &DolphinView::requestContextMenu,
             this, &DolphinPart::slotOpenContextMenu);
     connect(m_view, &DolphinView::selectionChanged,
-            m_extension, static_cast<void(DolphinPartBrowserExtension::*)(const KFileItemList&)>(&DolphinPartBrowserExtension::selectionInfo));
+            m_extension, QOverload<const KFileItemList&>::of(&KParts::BrowserExtension::selectionInfo));
     connect(m_view, &DolphinView::selectionChanged,
             this, &DolphinPart::slotSelectionChanged);
     connect(m_view, &DolphinView::requestItemInfo,
@@ -222,7 +223,7 @@ void DolphinPart::createActions()
 #ifndef Q_OS_WIN
     if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
         m_openTerminalAction = actionCollection()->addAction(QStringLiteral("open_terminal"));
-        m_openTerminalAction->setIcon(QIcon::fromTheme(QStringLiteral("utilities-terminal")));
+        m_openTerminalAction->setIcon(QIcon::fromTheme(QStringLiteral("dialog-scripts")));
         m_openTerminalAction->setText(i18nc("@action:inmenu Tools", "Open &Terminal"));
         connect(m_openTerminalAction, &QAction::triggered, this, &DolphinPart::slotOpenTerminal);
         actionCollection()->setDefaultShortcut(m_openTerminalAction, Qt::Key_F4);
@@ -532,28 +533,21 @@ void DolphinPart::setNameFilter(const QString& nameFilter)
 
 void DolphinPart::slotOpenTerminal()
 {
-    QString dir(QDir::homePath());
-
-    QUrl u(url());
-
-    // If the given directory is not local, it can still be the URL of an
-    // ioslave using UDS_LOCAL_PATH which to be converted first.
-    KIO::StatJob* statJob = KIO::mostLocalUrl(u);
-    KJobWidgets::setWindow(statJob, widget());
-    statJob->exec();
-    u = statJob->mostLocalUrl();
-
-    //If the URL is local after the above conversion, set the directory.
-    if (u.isLocalFile()) {
-        dir = u.toLocalFile();
-    }
-
-    KToolInvocation::invokeTerminal(QString(), dir);
+    KToolInvocation::invokeTerminal(QString(), KParts::ReadOnlyPart::localFilePath());
 }
 
 void DolphinPart::slotFindFile()
 {
-    KRun::run(QStringLiteral("kfind"), {url()}, widget());
+    QMenu searchTools;
+    KMoreToolsMenuFactory("dolphin/search-tools").fillMenuFromGroupingNames(
+        &searchTools, { "files-find" }, QUrl::fromLocalFile(KParts::ReadOnlyPart::localFilePath())
+    );
+    QList<QAction*> actions = searchTools.actions();
+    if (!(actions.isEmpty())) {
+        actions.first()->trigger();
+    } else {
+        KRun::run(QStringLiteral("kfind"), {url()}, widget());
+    }
 }
 
 void DolphinPart::updateNewMenu()
@@ -562,7 +556,7 @@ void DolphinPart::updateNewMenu()
     m_newFileMenu->checkUpToDate();
     m_newFileMenu->setViewShowsHiddenFiles(m_view->hiddenFilesShown());
     // And set the files that the menu apply on :
-    m_newFileMenu->setPopupFiles(url());
+    m_newFileMenu->setPopupFiles(QList<QUrl>() << url());
 }
 
 void DolphinPart::updateStatusBar()
@@ -579,7 +573,7 @@ void DolphinPart::updateProgress(int percent)
 void DolphinPart::createDirectory()
 {
     m_newFileMenu->setViewShowsHiddenFiles(m_view->hiddenFilesShown());
-    m_newFileMenu->setPopupFiles(url());
+    m_newFileMenu->setPopupFiles(QList<QUrl>() << url());
     m_newFileMenu->createDirectory();
 }