From 64889ac5d882b5e8b42dbe38356ea8d5f7db3ca0 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Fri, 2 Feb 2024 20:40:57 +0100 Subject: [PATCH] Add a templates root folder --- novelwriter/constants.py | 2 ++ novelwriter/core/item.py | 20 +++++++++++++++++--- novelwriter/enum.py | 3 ++- novelwriter/gui/projtree.py | 2 ++ sample/content/5aec885635c85.nwd | 13 +++++++++++++ sample/content/5ee8aebcdebc9.nwd | 12 ++++++++++++ sample/nwProject.nwx | 22 +++++++++++++++++----- 7 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 sample/content/5aec885635c85.nwd create mode 100644 sample/content/5ee8aebcdebc9.nwd diff --git a/novelwriter/constants.py b/novelwriter/constants.py index 9d874110..b21d211c 100644 --- a/novelwriter/constants.py +++ b/novelwriter/constants.py @@ -186,6 +186,7 @@ class nwLabels: nwItemClass.ENTITY: QT_TRANSLATE_NOOP("Constant", "Entities"), nwItemClass.CUSTOM: QT_TRANSLATE_NOOP("Constant", "Custom"), nwItemClass.ARCHIVE: QT_TRANSLATE_NOOP("Constant", "Archive"), + nwItemClass.TEMPLATES: QT_TRANSLATE_NOOP("Constant", "Templates"), nwItemClass.TRASH: QT_TRANSLATE_NOOP("Constant", "Trash"), } CLASS_ICON = { @@ -199,6 +200,7 @@ class nwLabels: nwItemClass.ENTITY: "cls_entity", nwItemClass.CUSTOM: "cls_custom", nwItemClass.ARCHIVE: "cls_archive", + nwItemClass.TEMPLATES: "cls_custom", nwItemClass.TRASH: "cls_trash", } LAYOUT_NAME = { diff --git a/novelwriter/core/item.py b/novelwriter/core/item.py index bf13fa46..2c5280ba 100644 --- a/novelwriter/core/item.py +++ b/novelwriter/core/item.py @@ -334,15 +334,29 @@ class NWItem: def isNovelLike(self) -> bool: """Check if the item is of a novel-like class.""" - return self._class in (nwItemClass.NOVEL, nwItemClass.ARCHIVE) + return self._class in ( + nwItemClass.NOVEL, + nwItemClass.ARCHIVE, + nwItemClass.TEMPLATES, + ) def documentAllowed(self) -> bool: """Check if the item is allowed to be of document layout.""" - return self._class in (nwItemClass.NOVEL, nwItemClass.ARCHIVE, nwItemClass.TRASH) + return self._class in ( + nwItemClass.NOVEL, + nwItemClass.ARCHIVE, + nwItemClass.TEMPLATES, + nwItemClass.TRASH, + ) def isInactiveClass(self) -> bool: """Check if the item is in an inactive class.""" - return self._class in (nwItemClass.NO_CLASS, nwItemClass.ARCHIVE, nwItemClass.TRASH) + return self._class in ( + nwItemClass.NO_CLASS, + nwItemClass.ARCHIVE, + nwItemClass.TEMPLATES, + nwItemClass.TRASH, + ) def isRootType(self) -> bool: """Check if item is a root item.""" diff --git a/novelwriter/enum.py b/novelwriter/enum.py index f91e6099..282a1094 100644 --- a/novelwriter/enum.py +++ b/novelwriter/enum.py @@ -47,7 +47,8 @@ class nwItemClass(Enum): ENTITY = 7 CUSTOM = 8 ARCHIVE = 9 - TRASH = 10 + TEMPLATES = 10 + TRASH = 11 # END Enum nwItemClass diff --git a/novelwriter/gui/projtree.py b/novelwriter/gui/projtree.py index d3fcbb34..48b6fb59 100644 --- a/novelwriter/gui/projtree.py +++ b/novelwriter/gui/projtree.py @@ -430,6 +430,8 @@ class GuiProjectToolBar(QWidget): addClass(nwItemClass.OBJECT) addClass(nwItemClass.ENTITY) addClass(nwItemClass.CUSTOM) + self.mAddRoot.addSeparator() + addClass(nwItemClass.TEMPLATES) return diff --git a/sample/content/5aec885635c85.nwd b/sample/content/5aec885635c85.nwd new file mode 100644 index 00000000..7b181bee --- /dev/null +++ b/sample/content/5aec885635c85.nwd @@ -0,0 +1,13 @@ +%%~name: Scene +%%~path: 09f22ae8369f7/5aec885635c85 +%%~kind: TEMPLATES/DOCUMENT +%%~hash: 05c9750b00020f8cf9a7bc7362bf19681022cc03 +%%~date: 2024-02-02 10:58:47/2024-02-02 10:59:32 +### Scene + +@pov: Name + +%Synopsis: A brief note about the scene content. + +Text + diff --git a/sample/content/5ee8aebcdebc9.nwd b/sample/content/5ee8aebcdebc9.nwd new file mode 100644 index 00000000..baf57847 --- /dev/null +++ b/sample/content/5ee8aebcdebc9.nwd @@ -0,0 +1,12 @@ +%%~name: Character Note +%%~path: 09f22ae8369f7/5ee8aebcdebc9 +%%~kind: TEMPLATES/NOTE +%%~hash: 6230bb6f796e708a72f4c29dc79d63dc90a47ba5 +%%~date: 2024-02-02 10:54:52/2024-02-02 10:56:05 +# Character Name + +@tag: Name + +## Motivation + +What motivates the character? diff --git a/sample/nwProject.nwx b/sample/nwProject.nwx index 54c41384..5b821b50 100644 --- a/sample/nwProject.nwx +++ b/sample/nwProject.nwx @@ -1,6 +1,6 @@ - - + + Sample Project Jane Smith @@ -20,7 +20,7 @@ D - New + New Notes Started 1st Draft @@ -35,7 +35,7 @@ Main - + Novel @@ -136,7 +136,19 @@ Old File - + + + Templates + + + + Character Note + + + + Scene + + Trash