Skip to content

Commit

Permalink
Added open and view document to the project tree context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
vkbo committed Jun 5, 2020
1 parent 9258d49 commit 213889e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
4 changes: 2 additions & 2 deletions nw/gui/mainmenu.py
Expand Up @@ -233,14 +233,14 @@ def _buildProjectMenu(self):
self.projMenu.addSeparator()

# Project > Edit
self.aEditItem = QAction("&Edit Item", self)
self.aEditItem = QAction("&Edit Project Item", self)
self.aEditItem.setStatusTip("Change item settings")
self.aEditItem.setShortcuts(["Ctrl+E", "F2"])
self.aEditItem.triggered.connect(self.theParent.editItem)
self.projMenu.addAction(self.aEditItem)

# Project > Delete
self.aDeleteItem = QAction("&Delete Item", self)
self.aDeleteItem = QAction("&Delete Project Item", self)
self.aDeleteItem.setStatusTip("Delete selected item")
self.aDeleteItem.setShortcut("Ctrl+Del")
self.aDeleteItem.triggered.connect(lambda : self.theParent.treeView.deleteItem(None))
Expand Down
28 changes: 27 additions & 1 deletion nw/gui/projtree.py
Expand Up @@ -836,7 +836,15 @@ def __init__(self, theTree):
self.theTree = theTree
self.theItem = None

self.editItem = QAction("Edit Item", self)
self.openItem = QAction("Open Document", self)
self.openItem.triggered.connect(self._doOpenItem)
self.addAction(self.openItem)

self.viewItem = QAction("View Document", self)
self.viewItem.triggered.connect(self._doViewItem)
self.addAction(self.viewItem)

self.editItem = QAction("Edit Project Item", self)
self.editItem.triggered.connect(self._doEditItem)
self.addAction(self.editItem)

Expand Down Expand Up @@ -876,13 +884,17 @@ def filterActions(self, theItem):
isFile = theItem.itemType == nwItemType.FILE
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
showNewFolder = not isTrash and not inTrash and not isOrph
showDelete = not isTrash
showEmpty = isTrash

self.openItem.setVisible(showOpen)
self.viewItem.setVisible(showView)
self.editItem.setVisible(showEdit)
self.toggleExp.setVisible(showExport)
self.newFile.setVisible(showNewFile)
Expand All @@ -896,6 +908,20 @@ def filterActions(self, theItem):
# Slots
##

def _doOpenItem(self):
"""Forward the open document call to the main GUI window.
"""
if self.theItem is not None:
self.theTree.theParent.openDocument(self.theItem.itemHandle)
return

def _doViewItem(self):
"""Forward the view document call to the main GUI window.
"""
if self.theItem is not None:
self.theTree.theParent.viewDocument(self.theItem.itemHandle)
return

def _doEditItem(self):
"""Forward the edit item call to the main GUI window.
"""
Expand Down

0 comments on commit 213889e

Please sign in to comment.