From 4bf82e4df76ace09809cb943a1df8d0f27653c86 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Tue, 20 Feb 2024 23:03:57 +0100 Subject: [PATCH] Hide unused controls on new project form --- novelwriter/tools/welcome.py | 30 ++++++++++++++------------ tests/test_tools/test_tools_welcome.py | 21 +++--------------- 2 files changed, 19 insertions(+), 32 deletions(-) diff --git a/novelwriter/tools/welcome.py b/novelwriter/tools/welcome.py index ba1f9f9b..4d9b3955 100644 --- a/novelwriter/tools/welcome.py +++ b/novelwriter/tools/welcome.py @@ -539,6 +539,7 @@ class _NewProjectForm(QWidget): self._copyPath = None iPx = SHARED.theme.baseIconSize + sPx = CONFIG.pxInt(16) # Project Settings # ================ @@ -668,15 +669,23 @@ class _NewProjectForm(QWidget): # Assemble # ======== + self.extraBox = QVBoxLayout() + self.extraBox.addWidget(QLabel("{0}".format(self.tr("Chapters and Scenes")))) + self.extraBox.addLayout(self.novelForm) + self.extraBox.addSpacing(sPx) + self.extraBox.addWidget(QLabel("{0}".format(self.tr("Project Notes")))) + self.extraBox.addLayout(self.notesForm) + self.extraBox.setContentsMargins(0, 0, 0, 0) + + self.extraWidget = QWidget(self) + self.extraWidget.setLayout(self.extraBox) + self.extraWidget.setContentsMargins(0, 0, 0, 0) + self.formBox = QVBoxLayout() self.formBox.addWidget(QLabel("{0}".format(self.tr("Create New Project")))) self.formBox.addLayout(self.projectForm) - self.formBox.addSpacing(16) - self.formBox.addWidget(QLabel("{0}".format(self.tr("Chapters and Scenes")))) - self.formBox.addLayout(self.novelForm) - self.formBox.addSpacing(16) - self.formBox.addWidget(QLabel("{0}".format(self.tr("Project Notes")))) - self.formBox.addLayout(self.notesForm) + self.formBox.addSpacing(sPx) + self.formBox.addWidget(self.extraWidget) self.formBox.addStretch(1) self.setLayout(self.formBox) @@ -782,14 +791,7 @@ class _NewProjectForm(QWidget): self.projFill.setText(text) self.projFill.setToolTip(text) self.projFill.setCursorPosition(0) - - isBlank = self._fillMode == self.FILL_BLANK - self.numChapters.setEnabled(isBlank) - self.numScenes.setEnabled(isBlank) - self.addPlot.setEnabled(isBlank) - self.addChar.setEnabled(isBlank) - self.addWorld.setEnabled(isBlank) - self.addNotes.setEnabled(isBlank) + self.extraWidget.setVisible(self._fillMode == self.FILL_BLANK) return diff --git a/tests/test_tools/test_tools_welcome.py b/tests/test_tools/test_tools_welcome.py index b3a566d7..85bdabd6 100644 --- a/tests/test_tools/test_tools_welcome.py +++ b/tests/test_tools/test_tools_welcome.py @@ -196,12 +196,7 @@ def testToolWelcome_New(qtbot: QtBot, caplog, monkeypatch, nwGUI, fncPath): newForm.fillSample.trigger() assert newForm._fillMode == newForm.FILL_SAMPLE assert newForm.projFill.text() == "Example Project" - assert newForm.addNotes.isEnabled() is False - assert newForm.addPlot.isEnabled() is False - assert newForm.addChar.isEnabled() is False - assert newForm.addWorld.isEnabled() is False - assert newForm.numChapters.isEnabled() is False - assert newForm.numScenes.isEnabled() is False + assert newForm.extraWidget.isVisible() is False # Change fill info to template with monkeypatch.context() as mp: @@ -209,12 +204,7 @@ def testToolWelcome_New(qtbot: QtBot, caplog, monkeypatch, nwGUI, fncPath): newForm.fillCopy.trigger() assert newForm._fillMode == newForm.FILL_COPY assert newForm.projFill.text() == f"Template: {fncPath}" - assert newForm.addNotes.isEnabled() is False - assert newForm.addPlot.isEnabled() is False - assert newForm.addChar.isEnabled() is False - assert newForm.addWorld.isEnabled() is False - assert newForm.numChapters.isEnabled() is False - assert newForm.numScenes.isEnabled() is False + assert newForm.extraWidget.isVisible() is False # Change back to fill blank using the menu newForm.browseFill.click() @@ -223,12 +213,7 @@ def testToolWelcome_New(qtbot: QtBot, caplog, monkeypatch, nwGUI, fncPath): newForm.fillMenu.close() assert newForm._fillMode == newForm.FILL_BLANK assert newForm.projFill.text() == "Fresh Project" - assert newForm.addNotes.isEnabled() is True - assert newForm.addPlot.isEnabled() is True - assert newForm.addChar.isEnabled() is True - assert newForm.addWorld.isEnabled() is True - assert newForm.numChapters.isEnabled() is True - assert newForm.numScenes.isEnabled() is True + assert newForm.extraWidget.isVisible() is True # Creating a project without a name, pops an error caplog.clear()