Skip to content

Commit f619e60

Browse files
liyigang1max-lvs
authored andcommitted
fix: 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
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
1 parent f614642 commit f619e60

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

src/plugins/filemanager/core/dfmplugin-trash/trash.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,20 @@ void Trash::followEvents()
168168
dpfHookSequence->follow("dfmplugin_fileoperations", "hook_Operation_OpenFileInPlugin", TrashFileHelper::instance(), &TrashFileHelper::openFileInPlugin);
169169

170170
dpfHookSequence->follow("dfmplugin_utils", "hook_OpenWith_DisabledOpenWithWidget", TrashFileHelper::instance(), &TrashFileHelper::disableOpenWidgetWidget);
171+
172+
// register to tag
173+
auto searchPlugin { DPF_NAMESPACE::LifeCycle::pluginMetaObj("dfmplugin-tag") };
174+
if (searchPlugin && searchPlugin->pluginState() == DPF_NAMESPACE::PluginMetaObject::kStarted) {
175+
dpfHookSequence->follow("dfmplugin_tag", "hook_CanTaged", TrashFileHelper::instance(), &TrashFileHelper::handleCanTag);
176+
} else {
177+
connect(
178+
DPF_NAMESPACE::Listener::instance(), &DPF_NAMESPACE::Listener::pluginStarted, this, [](const QString &iid, const QString &name) {
179+
Q_UNUSED(iid)
180+
if (name == "dfmplugin-tag")
181+
dpfHookSequence->follow("dfmplugin_tag", "hook_CanTaged", TrashFileHelper::instance(), &TrashFileHelper::handleCanTag);
182+
},
183+
Qt::DirectConnection);
184+
}
171185
}
172186

173187
void Trash::bindWindows()

src/plugins/filemanager/core/dfmplugin-trash/utils/trashfilehelper.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,14 @@ bool TrashFileHelper::disableOpenWidgetWidget(const QUrl &url, bool *result)
141141

142142
return true;
143143
}
144+
145+
bool TrashFileHelper::handleCanTag(const QUrl &url, bool *canTag)
146+
{
147+
if (url.scheme() == scheme() || FileUtils::isTrashFile(url)) {
148+
if (canTag)
149+
*canTag = false;
150+
return true;
151+
}
152+
153+
return false;
154+
}

src/plugins/filemanager/core/dfmplugin-trash/utils/trashfilehelper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class TrashFileHelper : public QObject
3737
bool openFileInPlugin(quint64 windowId, const QList<QUrl> urls);
3838
bool blockPaste(quint64 winId, const QList<QUrl> &fromUrls, const QUrl &to);
3939
bool disableOpenWidgetWidget(const QUrl &url, bool *result);
40+
bool handleCanTag(const QUrl &url, bool *canTag);
4041

4142
private:
4243
explicit TrashFileHelper(QObject *parent = nullptr);

0 commit comments

Comments
 (0)