From dec7e51a77ceb2bcf1d7319c89d7a9267e5204bf Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 17 May 2020 18:23:27 +0200 Subject: [PATCH] Cleaned up item editor, and removed some redundant imports here and there --- nw/assets/graphics/gear.svg | 48 ----------------------- nw/assets/graphics/license.txt | 8 ---- nw/gui/dialogs/docmerge.py | 5 +-- nw/gui/dialogs/docsplit.py | 4 +- nw/gui/dialogs/itemeditor.py | 71 +++++++++++++++++++--------------- nw/gui/icons.py | 1 - 6 files changed, 44 insertions(+), 93 deletions(-) delete mode 100644 nw/assets/graphics/gear.svg delete mode 100644 nw/assets/graphics/license.txt diff --git a/nw/assets/graphics/gear.svg b/nw/assets/graphics/gear.svg deleted file mode 100644 index b5da5b7a..00000000 --- a/nw/assets/graphics/gear.svg +++ /dev/null @@ -1,48 +0,0 @@ - -image/svg+xml - - \ No newline at end of file diff --git a/nw/assets/graphics/license.txt b/nw/assets/graphics/license.txt deleted file mode 100644 index 00a23f87..00000000 --- a/nw/assets/graphics/license.txt +++ /dev/null @@ -1,8 +0,0 @@ -FROM ICON SET: Typicons -LICENSE: Creative Commons (Attribution-Share Alike 3.0 Unported) -https://creativecommons.org/licenses/by-sa/3.0/ - -Applies to: - * graphics/export.svg - * graphics/merge.svg - * graphics/split.svg diff --git a/nw/gui/dialogs/docmerge.py b/nw/gui/dialogs/docmerge.py index 47391a72..39c7d0bf 100644 --- a/nw/gui/dialogs/docmerge.py +++ b/nw/gui/dialogs/docmerge.py @@ -29,10 +29,9 @@ import logging import nw from PyQt5.QtCore import Qt -from PyQt5.QtGui import QColor, QPalette from PyQt5.QtWidgets import ( - QDialog, QHBoxLayout, QVBoxLayout, QGridLayout, QPushButton, QLabel, - QListWidget, QAbstractItemView, QListWidgetItem, QDialogButtonBox + QDialog, QVBoxLayout, QLabel, QListWidget, QAbstractItemView, + QListWidgetItem, QDialogButtonBox ) from nw.constants import nwAlert, nwItemType diff --git a/nw/gui/dialogs/docsplit.py b/nw/gui/dialogs/docsplit.py index 7e2e80cd..137138c3 100644 --- a/nw/gui/dialogs/docsplit.py +++ b/nw/gui/dialogs/docsplit.py @@ -30,8 +30,8 @@ import nw from PyQt5.QtCore import Qt from PyQt5.QtWidgets import ( - QDialog, QHBoxLayout, QVBoxLayout, QGridLayout, QPushButton, QComboBox, - QListWidget, QAbstractItemView, QListWidgetItem, QDialogButtonBox, QLabel + QDialog, QVBoxLayout, QComboBox, QListWidget, QAbstractItemView, + QListWidgetItem, QDialogButtonBox, QLabel ) from nw.constants import nwAlert, nwItemType, nwItemClass, nwItemLayout from nw.gui.additions import QHelpLabel diff --git a/nw/gui/dialogs/itemeditor.py b/nw/gui/dialogs/itemeditor.py index d2446579..51583195 100644 --- a/nw/gui/dialogs/itemeditor.py +++ b/nw/gui/dialogs/itemeditor.py @@ -30,11 +30,11 @@ import nw from PyQt5.QtCore import Qt from PyQt5.QtWidgets import ( - QDialog, QHBoxLayout, QVBoxLayout, QGroupBox, QGridLayout, QLineEdit, - QComboBox, QLabel, QSpacerItem, QSizePolicy, QDialogButtonBox + QDialog, QVBoxLayout, QGridLayout, QLineEdit, QComboBox, QLabel, + QDialogButtonBox ) -from nw.gui.additions import QSwitch +from nw.gui.additions import QSwitch, QHelpLabel from nw.constants import nwLabels, nwItemLayout, nwItemClass, nwItemType logger = logging.getLogger(__name__) @@ -49,31 +49,30 @@ class GuiItemEditor(QDialog): self.mainConf = nw.CONFIG self.theProject = theProject self.theParent = theParent - self.outerBox = QHBoxLayout() - self.innerBox = QVBoxLayout() - self.theItem = self.theProject.projTree[tHandle] + self.outerBox = QVBoxLayout() + + self.theItem = self.theProject.projTree[tHandle] if self.theItem is None: self._doClose() self.setWindowTitle("Item Settings") - self.guiDeco = self.theParent.theTheme.loadDecoration("settings", (64,64)) - self.outerBox.setSpacing(16) - - self.outerBox.addWidget(self.guiDeco, 0, Qt.AlignTop) - self.outerBox.addLayout(self.innerBox) self.setLayout(self.outerBox) - self.mainGroup = QGroupBox("Item Settings") - self.mainForm = QGridLayout() + # Labels + self.headLabel = QLabel("Edit Item Settings") + self.helpLabel = QHelpLabel( + "Item layout and status options depend on the root folder.", + self.theParent.theTheme.helpText + ) + # Item Label self.editName = QLineEdit() self.editName.setMinimumWidth(220) self.editName.setMaxLength(200) + # Item Status self.editStatus = QComboBox() - self.editLayout = QComboBox() - if self.theItem.itemClass == nwItemClass.NOVEL: for sLabel, _, _ in self.theProject.statusItems: self.editStatus.addItem( @@ -85,6 +84,8 @@ class GuiItemEditor(QDialog): self.theParent.importIcons[sLabel], sLabel, sLabel ) + # Item Layout + self.editLayout = QComboBox() self.validLayouts = [] if self.theItem.itemType == nwItemType.FILE: if self.theItem.itemClass == nwItemClass.NOVEL: @@ -105,6 +106,7 @@ class GuiItemEditor(QDialog): if itemLayout in self.validLayouts: self.editLayout.addItem(nwLabels.LAYOUT_NAME[itemLayout],itemLayout) + # Export Switch self.textExport = QLabel("Include when building project") self.editExport = QSwitch() if self.theItem.itemType == nwItemType.FILE: @@ -114,18 +116,6 @@ class GuiItemEditor(QDialog): self.editExport.setEnabled(False) self.editExport.setChecked(False) - self.mainForm.addWidget(QLabel("Label"), 0, 0) - self.mainForm.addWidget(self.editName, 0, 1, 1, 2) - self.mainForm.addWidget(QLabel("Status"), 1, 0) - self.mainForm.addWidget(self.editStatus, 1, 1, 1, 2) - self.mainForm.addWidget(QLabel("Layout"), 2, 0) - self.mainForm.addWidget(self.editLayout, 2, 1, 1, 2) - self.mainForm.addWidget(self.textExport, 4, 0, 1, 2) - self.mainForm.addWidget(self.editExport, 4, 2) - - self.spacerItem = QSpacerItem(12, 12, QSizePolicy.Fixed, QSizePolicy.Fixed) - self.mainForm.addItem(self.spacerItem, 3, 0) - self.editName.setText(self.theItem.itemName) statusIdx = self.editStatus.findData(self.theItem.itemStatus) if statusIdx != -1: @@ -134,14 +124,34 @@ class GuiItemEditor(QDialog): if layoutIdx != -1: self.editLayout.setCurrentIndex(layoutIdx) + # Buttons self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.buttonBox.accepted.connect(self._doSave) self.buttonBox.rejected.connect(self._doClose) - self.mainGroup.setLayout(self.mainForm) - self.innerBox.addWidget(self.mainGroup) - self.innerBox.addWidget(self.buttonBox) + # Assemble + self.mainForm = QGridLayout() + self.mainForm.setVerticalSpacing(4) + self.mainForm.addWidget(QLabel("Label"), 0, 0, 1, 1) + self.mainForm.addWidget(self.editName, 0, 1, 1, 2) + self.mainForm.addWidget(QLabel("Status"), 1, 0, 1, 1) + self.mainForm.addWidget(self.editStatus, 1, 1, 1, 2) + self.mainForm.addWidget(QLabel("Layout"), 2, 0, 1, 1) + self.mainForm.addWidget(self.editLayout, 2, 1, 1, 2) + self.mainForm.addWidget(self.textExport, 3, 0, 1, 2) + self.mainForm.addWidget(self.editExport, 3, 2, 1, 1) + self.outerBox.setSpacing(0) + self.outerBox.addWidget(self.headLabel) + self.outerBox.addWidget(self.helpLabel) + self.outerBox.addSpacing(8) + self.outerBox.addLayout(self.mainForm) + self.outerBox.addSpacing(12) + self.outerBox.addStretch(1) + self.outerBox.addWidget(self.buttonBox) + self.setLayout(self.outerBox) + + self.rejected.connect(self._doClose) self.show() self.editName.selectAll() @@ -175,7 +185,6 @@ class GuiItemEditor(QDialog): def _doClose(self): logger.verbose("ItemEditor close button clicked") - self.reject() self.close() return diff --git a/nw/gui/icons.py b/nw/gui/icons.py index 9340d900..bc0bd493 100644 --- a/nw/gui/icons.py +++ b/nw/gui/icons.py @@ -99,7 +99,6 @@ class GuiIcons: DECO_MAP = { "nwicon" : ["icons", "novelWriter.svg"], - "settings" : ["graphics", "gear.svg"], } def __init__(self, theParent):