From 3b1c03329acd189c8375b1248f9208b10f13cbfc Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 20 Sep 2020 12:39:35 +0200 Subject: [PATCH] Fix a couple of issues with the project tree context menu where the new file/folder was not showing if the trash folder was None, and isArch was wrong for files in subfolders --- nw/gui/projtree.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/nw/gui/projtree.py b/nw/gui/projtree.py index 0c909a91..0a9c3905 100644 --- a/nw/gui/projtree.py +++ b/nw/gui/projtree.py @@ -985,23 +985,26 @@ class GuiProjectTreeMenu(QMenu): """Update item settings from the nwItem. """ self.theItem = theItem - trashHandle = self.theTree.theProject.projTree.trashRoot() + theRoot = self.theTree.theProject.projTree.getRootItem(theItem.itemHandle) - if theItem is None: + if theItem is None or theRoot is None: + logger.error("Failed to extract information to build tree context menu") return False - inTrash = theItem.parHandle == trashHandle - isTrash = theItem.itemHandle == trashHandle + trashHandle = self.theTree.theProject.projTree.trashRoot() + + inTrash = theItem.parHandle == trashHandle and trashHandle is not None + isTrash = theItem.itemHandle == trashHandle and trashHandle is not None isFile = theItem.itemType == nwItemType.FILE - isArch = theItem.itemClass == nwItemClass.ARCHIVE + isArch = theRoot.itemClass == nwItemClass.ARCHIVE isOrph = isFile and theItem.parHandle is None showOpen = isFile showView = isFile showEdit = not isTrash and not isOrph - showExport = isFile and not inTrash and not isOrph - showNewFile = not isTrash and not inTrash and not isOrph and not isArch - showNewFolder = not isTrash and not inTrash and not isOrph + showExport = isFile + showNewFile = not (isTrash or inTrash or isOrph or isArch) + showNewFolder = not (isTrash or inTrash or isOrph) showDelete = not isTrash showEmpty = isTrash