diff --git a/novelwriter/dialogs/projectsettings.py b/novelwriter/dialogs/projectsettings.py index f6ff77303..c76c9f6b9 100644 --- a/novelwriter/dialogs/projectsettings.py +++ b/novelwriter/dialogs/projectsettings.py @@ -79,7 +79,6 @@ def __init__(self, parent: QWidget, gotoPage: int = PAGE_SETTINGS) -> None: self.sidebar.addButton(self.tr("Status"), self.PAGE_STATUS) self.sidebar.addButton(self.tr("Importance"), self.PAGE_IMPORT) self.sidebar.addButton(self.tr("Auto-Replace"), self.PAGE_REPLACE) - self.sidebar.setSelected(gotoPage) self.sidebar.buttonClicked.connect(self._sidebarClicked) # Buttons @@ -122,6 +121,10 @@ def __init__(self, parent: QWidget, gotoPage: int = PAGE_SETTINGS) -> None: self.setLayout(self.outerBox) self.setSizeGripEnabled(True) + # Jump to Specified Page + self.sidebar.setSelected(gotoPage) + self._sidebarClicked(gotoPage) + logger.debug("Ready: GuiProjectSettings") return diff --git a/novelwriter/gui/projtree.py b/novelwriter/gui/projtree.py index 14cb0e762..d3fcbb340 100644 --- a/novelwriter/gui/projtree.py +++ b/novelwriter/gui/projtree.py @@ -1674,9 +1674,13 @@ def buildSingleSelectMenu(self, hasChild: bool) -> None: self._docActions() self.addSeparator() + # Create New Items + self._itemCreation() + self.addSeparator() + # Edit Item Settings - aLabel = self.addAction(self.tr("Rename")) - aLabel.triggered.connect(lambda: self.projTree.renameTreeItem(self._handle)) + action = self.addAction(self.tr("Rename")) + action.triggered.connect(lambda: self.projTree.renameTreeItem(self._handle)) if isFile: self._itemActive(False) self._itemStatusImport(False) @@ -1716,6 +1720,16 @@ def _docActions(self) -> None: ) return + def _itemCreation(self) -> None: + """Add create item actions.""" + menu = self.addMenu(self.tr("Create New ...")) + menu.addAction(self.projView.projBar.aAddEmpty) + menu.addAction(self.projView.projBar.aAddChap) + menu.addAction(self.projView.projBar.aAddScene) + menu.addAction(self.projView.projBar.aAddNote) + menu.addAction(self.projView.projBar.aAddFolder) + return + def _itemActive(self, multi: bool) -> None: """Add Active/Inactive actions.""" if multi: @@ -1769,7 +1783,7 @@ def _itemStatusImport(self, multi: bool) -> None: def _itemTransform(self, isFile: bool, isFolder: bool, hasChild: bool) -> None: """Add actions for the Transform menu.""" - menu = self.addMenu(self.tr("Transform")) + menu = self.addMenu(self.tr("Transform ...")) tree = self.projTree tHandle = self._handle diff --git a/tests/test_gui/test_gui_projtree.py b/tests/test_gui/test_gui_projtree.py index 63e2f7603..628c42be6 100644 --- a/tests/test_gui/test_gui_projtree.py +++ b/tests/test_gui/test_gui_projtree.py @@ -1182,8 +1182,8 @@ def itemPos(tHandle): ctxMenu.buildSingleSelectMenu(True) actions = [x.text() for x in ctxMenu.actions() if x.text()] assert actions == [ - "Rename", "Set Status to ...", "Expand All", "Collapse All", - "Duplicate from Here", "Delete Permanently", + "Create New ...", "Rename", "Set Status to ...", "Expand All", + "Collapse All", "Duplicate from Here", "Delete Permanently", ] # Context Menu on Folder Item @@ -1193,13 +1193,13 @@ def itemPos(tHandle): ctxMenu.buildSingleSelectMenu(True) actions = [x.text() for x in ctxMenu.actions() if x.text()] assert actions == [ - "Rename", "Set Status to ...", "Transform", "Expand All", "Collapse All", - "Duplicate from Here", "Move to Trash", + "Create New ...", "Rename", "Set Status to ...", "Transform ...", "Expand All", + "Collapse All", "Duplicate from Here", "Move to Trash", ] def getTransformSubMenu(menu: QMenu) -> list[str]: for action in menu.actions(): - if action.text() == "Transform": + if action.text() == "Transform ...": return [x.text() for x in action.menu().actions() if x.text()] return [] @@ -1210,8 +1210,9 @@ def getTransformSubMenu(menu: QMenu) -> list[str]: ctxMenu.buildSingleSelectMenu(True) actions = [x.text() for x in ctxMenu.actions() if x.text()] assert actions == [ - "Open Document", "View Document", "Rename", "Toggle Active", "Set Status to ...", - "Transform", "Expand All", "Collapse All", "Duplicate from Here", "Move to Trash", + "Open Document", "View Document", "Create New ...", "Rename", "Toggle Active", + "Set Status to ...", "Transform ...", "Expand All", "Collapse All", + "Duplicate from Here", "Move to Trash", ] assert getTransformSubMenu(ctxMenu) == [ "Convert to Project Note", "Merge Child Items into Self", @@ -1225,8 +1226,8 @@ def getTransformSubMenu(menu: QMenu) -> list[str]: ctxMenu.buildSingleSelectMenu(False) actions = [x.text() for x in ctxMenu.actions() if x.text()] assert actions == [ - "Open Document", "View Document", "Rename", "Toggle Active", "Set Importance to ...", - "Transform", "Duplicate Document", "Move to Trash", + "Open Document", "View Document", "Create New ...", "Rename", "Toggle Active", + "Set Importance to ...", "Transform ...", "Duplicate Document", "Move to Trash", ] assert getTransformSubMenu(ctxMenu) == [ "Split Document by Headers", @@ -1239,8 +1240,8 @@ def getTransformSubMenu(menu: QMenu) -> list[str]: ctxMenu.buildSingleSelectMenu(False) actions = [x.text() for x in ctxMenu.actions() if x.text()] assert actions == [ - "Open Document", "View Document", "Rename", "Toggle Active", "Set Status to ...", - "Transform", "Duplicate Document", "Move to Trash", + "Open Document", "View Document", "Create New ...", "Rename", "Toggle Active", + "Set Status to ...", "Transform ...", "Duplicate Document", "Move to Trash", ] assert getTransformSubMenu(ctxMenu) == [ "Convert to Novel Document", "Split Document by Headers",