From 9315be222a3142d20897400a08bc8ecf8e13cd91 Mon Sep 17 00:00:00 2001 From: kateleet Date: Mon, 27 Dec 2021 11:01:59 +0800 Subject: [PATCH] fix: new text file visible --- model/foldermodel.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/model/foldermodel.cpp b/model/foldermodel.cpp index 8b084fa..7eee901 100644 --- a/model/foldermodel.cpp +++ b/model/foldermodel.cpp @@ -1249,6 +1249,7 @@ void FolderModel::openContextMenu(QQuickItem *visualParent, Qt::KeyboardModifier updateActions(); const QModelIndexList indexes = m_selectionModel->selectedIndexes(); + const bool isTrash = (resolvedUrl().scheme() == QLatin1String("trash")); QMenu *menu = new QMenu; // Open folder menu. @@ -1256,11 +1257,14 @@ void FolderModel::openContextMenu(QQuickItem *visualParent, Qt::KeyboardModifier QAction *selectAll = new QAction(tr("Select All"), this); connect(selectAll, &QAction::triggered, this, &FolderModel::selectAll); - QMenu *newMenu = new QMenu(tr("New Documents")); - newMenu->addAction(m_actionCollection.action("newTextFile")); - menu->addAction(m_actionCollection.action("newFolder")); - menu->addMenu(newMenu); + + if (!isTrash) { + QMenu *newMenu = new QMenu(tr("New Documents")); + newMenu->addAction(m_actionCollection.action("newTextFile")); + menu->addMenu(newMenu); + } + menu->addSeparator(); menu->addAction(m_actionCollection.action("paste")); menu->addAction(selectAll);