/* This file is part of the KDE project
- Copyright (c) 2007 David Faure <faure@kde.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
+ SPDX-FileCopyrightText: 2007 David Faure <faure@kde.org>
+
+ SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "dolphinpart.h"
#include <KActionCollection>
#include <KAuthorized>
#include <KConfigGroup>
+#include <KDialogJobUiDelegate>
#include <KFileItemListProperties>
#include <KIconLoader>
#include <KJobWidgets>
#include <KLocalizedString>
#include <KMessageBox>
#include <KMimeTypeEditor>
+#include <KNS3/KMoreToolsMenuFactory>
#include <KPluginFactory>
-#include <KRun>
+#include <KIO/CommandLauncherJob>
#include <KSharedConfig>
#include <KToolInvocation>
#include <QInputDialog>
#include <QKeyEvent>
#include <QMenu>
+#include <QRegularExpression>
#include <QStandardPaths>
#include <QTextDocument>
const QString pattern = QInputDialog::getText(m_view, title, text, QLineEdit::Normal, QStringLiteral("*"), &okClicked);
if (okClicked && !pattern.isEmpty()) {
- QRegExp patternRegExp(pattern, Qt::CaseSensitive, QRegExp::Wildcard);
+ const QRegularExpression patternRegExp(QRegularExpression::wildcardToRegularExpression(pattern));
m_view->selectItems(patternRegExp, selectItems);
}
}
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 {
+ KIO::CommandLauncherJob *job = new KIO::CommandLauncherJob(QStringLiteral("kfind"), {url().toString()}, this);
+ job->setDesktopName(QStringLiteral("org.kde.kfind"));
+ job->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, widget()));
+ job->start();
+ }
}
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()
void DolphinPart::createDirectory()
{
m_newFileMenu->setViewShowsHiddenFiles(m_view->hiddenFilesShown());
- m_newFileMenu->setPopupFiles(url());
+ m_newFileMenu->setPopupFiles(QList<QUrl>() << url());
m_newFileMenu->createDirectory();
}