Skip to content

Commit

Permalink
fix: After enabling the long file name function, delete files to the …
Browse files Browse the repository at this point in the history
…trash. Right click on the attribute window and there is marked information that can be edited

All trash files cannot be marked. Register the hook_cantag function and return a tag that is not allowed

Log:  After enabling the long file name function, delete files to the trash. Right click on the attribute window and there is marked information that can be edited
Bug: https://pms.uniontech.com/bug-view-260621.html
  • Loading branch information
liyigang1 authored and max-lvs committed Jun 19, 2024
1 parent f614642 commit f619e60
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/plugins/filemanager/core/dfmplugin-trash/trash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,20 @@ void Trash::followEvents()
dpfHookSequence->follow("dfmplugin_fileoperations", "hook_Operation_OpenFileInPlugin", TrashFileHelper::instance(), &TrashFileHelper::openFileInPlugin);

dpfHookSequence->follow("dfmplugin_utils", "hook_OpenWith_DisabledOpenWithWidget", TrashFileHelper::instance(), &TrashFileHelper::disableOpenWidgetWidget);

// register to tag
auto searchPlugin { DPF_NAMESPACE::LifeCycle::pluginMetaObj("dfmplugin-tag") };
if (searchPlugin && searchPlugin->pluginState() == DPF_NAMESPACE::PluginMetaObject::kStarted) {
dpfHookSequence->follow("dfmplugin_tag", "hook_CanTaged", TrashFileHelper::instance(), &TrashFileHelper::handleCanTag);
} else {
connect(
DPF_NAMESPACE::Listener::instance(), &DPF_NAMESPACE::Listener::pluginStarted, this, [](const QString &iid, const QString &name) {
Q_UNUSED(iid)
if (name == "dfmplugin-tag")
dpfHookSequence->follow("dfmplugin_tag", "hook_CanTaged", TrashFileHelper::instance(), &TrashFileHelper::handleCanTag);
},
Qt::DirectConnection);
}
}

void Trash::bindWindows()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,14 @@ bool TrashFileHelper::disableOpenWidgetWidget(const QUrl &url, bool *result)

return true;
}

bool TrashFileHelper::handleCanTag(const QUrl &url, bool *canTag)
{
if (url.scheme() == scheme() || FileUtils::isTrashFile(url)) {
if (canTag)
*canTag = false;
return true;
}

return false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class TrashFileHelper : public QObject
bool openFileInPlugin(quint64 windowId, const QList<QUrl> urls);
bool blockPaste(quint64 winId, const QList<QUrl> &fromUrls, const QUrl &to);
bool disableOpenWidgetWidget(const QUrl &url, bool *result);
bool handleCanTag(const QUrl &url, bool *canTag);

private:
explicit TrashFileHelper(QObject *parent = nullptr);
Expand Down

0 comments on commit f619e60

Please sign in to comment.