Merge branch 'dev' into chars_in_build_alt2

This commit is contained in:
Veronica Berglyd Olsen
2024-01-31 20:25:55 +01:00
committed by GitHub
3 changed files with 33 additions and 15 deletions
+4 -1
View File
@@ -79,7 +79,6 @@ class GuiProjectSettings(QDialog):
self.sidebar.addButton(self.tr("Status"), self.PAGE_STATUS) self.sidebar.addButton(self.tr("Status"), self.PAGE_STATUS)
self.sidebar.addButton(self.tr("Importance"), self.PAGE_IMPORT) self.sidebar.addButton(self.tr("Importance"), self.PAGE_IMPORT)
self.sidebar.addButton(self.tr("Auto-Replace"), self.PAGE_REPLACE) self.sidebar.addButton(self.tr("Auto-Replace"), self.PAGE_REPLACE)
self.sidebar.setSelected(gotoPage)
self.sidebar.buttonClicked.connect(self._sidebarClicked) self.sidebar.buttonClicked.connect(self._sidebarClicked)
# Buttons # Buttons
@@ -122,6 +121,10 @@ class GuiProjectSettings(QDialog):
self.setLayout(self.outerBox) self.setLayout(self.outerBox)
self.setSizeGripEnabled(True) self.setSizeGripEnabled(True)
# Jump to Specified Page
self.sidebar.setSelected(gotoPage)
self._sidebarClicked(gotoPage)
logger.debug("Ready: GuiProjectSettings") logger.debug("Ready: GuiProjectSettings")
return return
+17 -3
View File
@@ -1674,9 +1674,13 @@ class _TreeContextMenu(QMenu):
self._docActions() self._docActions()
self.addSeparator() self.addSeparator()
# Create New Items
self._itemCreation()
self.addSeparator()
# Edit Item Settings # Edit Item Settings
aLabel = self.addAction(self.tr("Rename")) action = self.addAction(self.tr("Rename"))
aLabel.triggered.connect(lambda: self.projTree.renameTreeItem(self._handle)) action.triggered.connect(lambda: self.projTree.renameTreeItem(self._handle))
if isFile: if isFile:
self._itemActive(False) self._itemActive(False)
self._itemStatusImport(False) self._itemStatusImport(False)
@@ -1716,6 +1720,16 @@ class _TreeContextMenu(QMenu):
) )
return 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: def _itemActive(self, multi: bool) -> None:
"""Add Active/Inactive actions.""" """Add Active/Inactive actions."""
if multi: if multi:
@@ -1769,7 +1783,7 @@ class _TreeContextMenu(QMenu):
def _itemTransform(self, isFile: bool, isFolder: bool, hasChild: bool) -> None: def _itemTransform(self, isFile: bool, isFolder: bool, hasChild: bool) -> None:
"""Add actions for the Transform menu.""" """Add actions for the Transform menu."""
menu = self.addMenu(self.tr("Transform")) menu = self.addMenu(self.tr("Transform ..."))
tree = self.projTree tree = self.projTree
tHandle = self._handle tHandle = self._handle
+12 -11
View File
@@ -1182,8 +1182,8 @@ def testGuiProjTree_ContextMenu(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
ctxMenu.buildSingleSelectMenu(True) ctxMenu.buildSingleSelectMenu(True)
actions = [x.text() for x in ctxMenu.actions() if x.text()] actions = [x.text() for x in ctxMenu.actions() if x.text()]
assert actions == [ assert actions == [
"Rename", "Set Status to ...", "Expand All", "Collapse All", "Create New ...", "Rename", "Set Status to ...", "Expand All",
"Duplicate from Here", "Delete Permanently", "Collapse All", "Duplicate from Here", "Delete Permanently",
] ]
# Context Menu on Folder Item # Context Menu on Folder Item
@@ -1193,13 +1193,13 @@ def testGuiProjTree_ContextMenu(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
ctxMenu.buildSingleSelectMenu(True) ctxMenu.buildSingleSelectMenu(True)
actions = [x.text() for x in ctxMenu.actions() if x.text()] actions = [x.text() for x in ctxMenu.actions() if x.text()]
assert actions == [ assert actions == [
"Rename", "Set Status to ...", "Transform", "Expand All", "Collapse All", "Create New ...", "Rename", "Set Status to ...", "Transform ...", "Expand All",
"Duplicate from Here", "Move to Trash", "Collapse All", "Duplicate from Here", "Move to Trash",
] ]
def getTransformSubMenu(menu: QMenu) -> list[str]: def getTransformSubMenu(menu: QMenu) -> list[str]:
for action in menu.actions(): 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 [x.text() for x in action.menu().actions() if x.text()]
return [] return []
@@ -1210,8 +1210,9 @@ def testGuiProjTree_ContextMenu(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
ctxMenu.buildSingleSelectMenu(True) ctxMenu.buildSingleSelectMenu(True)
actions = [x.text() for x in ctxMenu.actions() if x.text()] actions = [x.text() for x in ctxMenu.actions() if x.text()]
assert actions == [ assert actions == [
"Open Document", "View Document", "Rename", "Toggle Active", "Set Status to ...", "Open Document", "View Document", "Create New ...", "Rename", "Toggle Active",
"Transform", "Expand All", "Collapse All", "Duplicate from Here", "Move to Trash", "Set Status to ...", "Transform ...", "Expand All", "Collapse All",
"Duplicate from Here", "Move to Trash",
] ]
assert getTransformSubMenu(ctxMenu) == [ assert getTransformSubMenu(ctxMenu) == [
"Convert to Project Note", "Merge Child Items into Self", "Convert to Project Note", "Merge Child Items into Self",
@@ -1225,8 +1226,8 @@ def testGuiProjTree_ContextMenu(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
ctxMenu.buildSingleSelectMenu(False) ctxMenu.buildSingleSelectMenu(False)
actions = [x.text() for x in ctxMenu.actions() if x.text()] actions = [x.text() for x in ctxMenu.actions() if x.text()]
assert actions == [ assert actions == [
"Open Document", "View Document", "Rename", "Toggle Active", "Set Importance to ...", "Open Document", "View Document", "Create New ...", "Rename", "Toggle Active",
"Transform", "Duplicate Document", "Move to Trash", "Set Importance to ...", "Transform ...", "Duplicate Document", "Move to Trash",
] ]
assert getTransformSubMenu(ctxMenu) == [ assert getTransformSubMenu(ctxMenu) == [
"Split Document by Headers", "Split Document by Headers",
@@ -1239,8 +1240,8 @@ def testGuiProjTree_ContextMenu(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
ctxMenu.buildSingleSelectMenu(False) ctxMenu.buildSingleSelectMenu(False)
actions = [x.text() for x in ctxMenu.actions() if x.text()] actions = [x.text() for x in ctxMenu.actions() if x.text()]
assert actions == [ assert actions == [
"Open Document", "View Document", "Rename", "Toggle Active", "Set Status to ...", "Open Document", "View Document", "Create New ...", "Rename", "Toggle Active",
"Transform", "Duplicate Document", "Move to Trash", "Set Status to ...", "Transform ...", "Duplicate Document", "Move to Trash",
] ]
assert getTransformSubMenu(ctxMenu) == [ assert getTransformSubMenu(ctxMenu) == [
"Convert to Novel Document", "Split Document by Headers", "Convert to Novel Document", "Split Document by Headers",