]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinpart.cpp
Update kconf update script version to 6
[dolphin.git] / src / dolphinpart.cpp
index c3447ad6e45185c2c422a8bec7e1e938b85ed485..a7f0d85cd2e939c7d266699370b1ee7cc0514d17 100644 (file)
@@ -28,7 +28,6 @@
 #include <KLocalizedString>
 #include <KMessageBox>
 #include <KMimeTypeEditor>
-#include <KMoreToolsMenuFactory>
 #include <KPluginFactory>
 #include <KPluginMetaData>
 #include <KSharedConfig>
@@ -46,6 +45,7 @@
 #include <QTextDocument>
 
 #include <KPluginFactory>
+#include <QAction>
 
 K_PLUGIN_CLASS_WITH_JSON(DolphinPart, "dolphinpart.json")
 
@@ -140,23 +140,23 @@ DolphinPart::~DolphinPart()
 void DolphinPart::createActions()
 {
     // Edit menu
-
-    m_newFileMenu = new DolphinNewFileMenu(actionCollection(), this);
+    QAction *newDirAction = actionCollection()->action(QStringLiteral("create_dir"));
+    QAction *newFileAction = actionCollection()->action(QStringLiteral("create_file"));
+    m_newFileMenu = new DolphinNewFileMenu(newDirAction, newFileAction, this);
     m_newFileMenu->setParentWidget(widget());
-    m_newFileMenu->setNewFolderShortcutAction(actionCollection()->action("create_dir"));
     connect(m_newFileMenu->menu(), &QMenu::aboutToShow, this, &DolphinPart::updateNewMenu);
 
     QAction *editMimeTypeAction = actionCollection()->addAction(QStringLiteral("editMimeType"));
-    editMimeTypeAction->setText(i18nc("@action:inmenu Edit", "&Edit File Type..."));
+    editMimeTypeAction->setText(i18nc("@action:inmenu Edit", "&Edit File Type"));
     connect(editMimeTypeAction, &QAction::triggered, this, &DolphinPart::slotEditMimeType);
 
     QAction *selectItemsMatching = actionCollection()->addAction(QStringLiteral("select_items_matching"));
-    selectItemsMatching->setText(i18nc("@action:inmenu Edit", "Select Items Matching..."));
+    selectItemsMatching->setText(i18nc("@action:inmenu Edit", "Select Items Matching"));
     actionCollection()->setDefaultShortcut(selectItemsMatching, Qt::CTRL | Qt::Key_S);
     connect(selectItemsMatching, &QAction::triggered, this, &DolphinPart::slotSelectItemsMatchingPattern);
 
     QAction *unselectItemsMatching = actionCollection()->addAction(QStringLiteral("unselect_items_matching"));
-    unselectItemsMatching->setText(i18nc("@action:inmenu Edit", "Unselect Items Matching..."));
+    unselectItemsMatching->setText(i18nc("@action:inmenu Edit", "Unselect Items Matching"));
     connect(unselectItemsMatching, &QAction::triggered, this, &DolphinPart::slotUnselectItemsMatchingPattern);
 
     KStandardAction::selectAll(m_view, &DolphinView::selectAll, actionCollection());
@@ -188,7 +188,7 @@ void DolphinPart::createActions()
 
     // Tools menu
     m_findFileAction = KStandardAction::find(this, &DolphinPart::slotFindFile, actionCollection());
-    m_findFileAction->setText(i18nc("@action:inmenu Tools", "Find File..."));
+    m_findFileAction->setText(i18nc("@action:inmenu Tools", "Find File"));
 
 #ifndef Q_OS_WIN
     if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
@@ -340,11 +340,7 @@ void DolphinPart::slotItemActivated(const KFileItem &item)
         args.setMimeType(item.mimetype());
     }
 
-    // Ideally, konqueror should be changed to not require trustedSource for directory views,
-    // since the idea was not to need BrowserArguments for non-browser stuff...
-    KParts::BrowserArguments browserArgs;
-    browserArgs.trustedSource = true;
-    Q_EMIT m_extension->openUrlRequest(item.targetUrl(), args, browserArgs);
+    Q_EMIT m_extension->openUrlRequest(item.targetUrl(), args);
 }
 
 void DolphinPart::slotItemsActivated(const KFileItemList &items)
@@ -393,7 +389,8 @@ void DolphinPart::slotOpenContextMenu(const QPoint &pos, const KFileItem &_item,
         const bool supportsMoving = capabilities.supportsMoving();
 
         if (capabilities.supportsDeleting()) {
-            const bool showDeleteAction = (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) || !item.isLocalFile());
+            const bool showDeleteAction =
+                (KSharedConfig::openConfig()->group(QStringLiteral("KDE")).readEntry("ShowDeleteCommand", false) || !item.isLocalFile());
             const bool showMoveToTrashAction = capabilities.isLocal() && supportsMoving;
 
             if (showDeleteAction && showMoveToTrashAction) {
@@ -426,7 +423,7 @@ void DolphinPart::slotOpenContextMenu(const QPoint &pos, const KFileItem &_item,
 
     actionGroups.insert(QStringLiteral("editactions"), editActions);
 
-    Q_EMIT m_extension->popupMenu(pos, items, KParts::OpenUrlArguments(), KParts::BrowserArguments(), popupFlags, actionGroups);
+    Q_EMIT m_extension->popupMenu(pos, items, KParts::OpenUrlArguments(), popupFlags, actionGroups);
 }
 
 void DolphinPart::slotDirectoryRedirection(const QUrl &oldUrl, const QUrl &newUrl)
@@ -465,13 +462,13 @@ void DolphinPart::openSelectionDialog(const QString &title, const QString &text,
     dialog->setWindowTitle(title);
     dialog->setLabelText(text);
 
-    const KConfigGroup group = KSharedConfig::openConfig("dolphinpartrc")->group("Select Dialog");
+    const KConfigGroup group = KSharedConfig::openConfig("dolphinpartrc")->group(QStringLiteral("Select Dialog"));
     dialog->setComboBoxEditable(true);
     dialog->setComboBoxItems(group.readEntry("History", QStringList()));
 
     dialog->setTextValue(QStringLiteral("*"));
 
-    connect(dialog, &QDialog::accepted, this, [=]() {
+    connect(dialog, &QDialog::accepted, this, [=, this]() {
         const QString pattern = dialog->textValue();
         if (!pattern.isEmpty()) {
             QStringList items = dialog->comboBoxItems();
@@ -480,7 +477,7 @@ void DolphinPart::openSelectionDialog(const QString &title, const QString &text,
 
             // Need to evaluate this again here, because the captured value is const
             // (even if the const were removed from 'const KConfigGroup group =' above).
-            KConfigGroup group = KSharedConfig::openConfig("dolphinpartrc")->group("Select Dialog");
+            KConfigGroup group = KSharedConfig::openConfig("dolphinpartrc")->group(QStringLiteral("Select Dialog"));
             // Limit the size of the saved history.
             group.writeEntry("History", items.mid(0, 10));
             group.sync();
@@ -531,17 +528,10 @@ void DolphinPart::slotOpenTerminal()
 
 void DolphinPart::slotFindFile()
 {
-    QMenu searchTools;
-    KMoreToolsMenuFactory("dolphin/search-tools").fillMenuFromGroupingNames(&searchTools, {"files-find"}, QUrl::fromLocalFile(localFilePathOrHome()));
-    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();
-    }
+    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()
@@ -597,3 +587,4 @@ bool DolphinPart::eventFilter(QObject *obj, QEvent *event)
 }
 
 #include "dolphinpart.moc"
+#include "moc_dolphinpart.cpp"