@@ -1,7 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from nw.constants.iso import isoLanguage, isoCountry
|
from nw.constants.iso import isoLanguage, isoCountry
|
||||||
from nw.constants.constants import (
|
from nw.constants.constants import (
|
||||||
nwConst, nwRegEx, nwFiles, nwKeyWords, nwLabels, nwQuotes, nwUnicode
|
nwConst, nwLists, nwRegEx, nwFiles, nwKeyWords, nwLabels, nwQuotes, nwUnicode
|
||||||
)
|
)
|
||||||
from nw.constants.enum import (
|
from nw.constants.enum import (
|
||||||
nwAlert, nwDocAction, nwItemClass, nwItemLayout, nwItemType, nwOutline,
|
nwAlert, nwDocAction, nwItemClass, nwItemLayout, nwItemType, nwOutline,
|
||||||
@@ -11,18 +11,19 @@ from nw.constants.enum import (
|
|||||||
__all__ = [
|
__all__ = [
|
||||||
"isoCountry",
|
"isoCountry",
|
||||||
"isoLanguage",
|
"isoLanguage",
|
||||||
"nwAlert",
|
|
||||||
"nwConst",
|
"nwConst",
|
||||||
"nwDocAction",
|
"nwLists",
|
||||||
"nwDocInsert",
|
"nwRegEx",
|
||||||
"nwFiles",
|
"nwFiles",
|
||||||
|
"nwKeyWords",
|
||||||
|
"nwLabels",
|
||||||
|
"nwQuotes",
|
||||||
|
"nwUnicode",
|
||||||
|
"nwAlert",
|
||||||
|
"nwDocAction",
|
||||||
"nwItemClass",
|
"nwItemClass",
|
||||||
"nwItemLayout",
|
"nwItemLayout",
|
||||||
"nwItemType",
|
"nwItemType",
|
||||||
"nwKeyWords",
|
|
||||||
"nwLabels",
|
|
||||||
"nwOutline",
|
"nwOutline",
|
||||||
"nwQuotes",
|
"nwDocInsert",
|
||||||
"nwRegEx",
|
|
||||||
"nwUnicode",
|
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -45,10 +45,19 @@ class nwConst():
|
|||||||
SP_INTERNAL = "internal"
|
SP_INTERNAL = "internal"
|
||||||
SP_ENCHANT = "enchant"
|
SP_ENCHANT = "enchant"
|
||||||
|
|
||||||
# Check Lists
|
# END Class nwConst
|
||||||
|
|
||||||
|
class nwLists():
|
||||||
|
"""Lists used for grouping various other constants.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Regular user-accessible item types
|
||||||
REG_TYPES = {nwItemType.ROOT, nwItemType.FOLDER, nwItemType.FILE}
|
REG_TYPES = {nwItemType.ROOT, nwItemType.FOLDER, nwItemType.FILE}
|
||||||
|
|
||||||
# END Class nwConst
|
# Item classes where the full list of novel layouts are allowed
|
||||||
|
CLS_NOVEL = {nwItemClass.NOVEL, nwItemClass.ARCHIVE}
|
||||||
|
|
||||||
|
# END Class nwLists
|
||||||
|
|
||||||
class nwRegEx():
|
class nwRegEx():
|
||||||
|
|
||||||
|
|||||||
+57
-34
@@ -28,13 +28,14 @@
|
|||||||
import nw
|
import nw
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from PyQt5.QtCore import pyqtSlot
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QDialog, QVBoxLayout, QGridLayout, QLineEdit, QComboBox, QLabel,
|
QDialog, QVBoxLayout, QGridLayout, QLineEdit, QComboBox, QLabel,
|
||||||
QDialogButtonBox
|
QDialogButtonBox
|
||||||
)
|
)
|
||||||
|
|
||||||
from nw.gui.custom import QSwitch
|
from nw.gui.custom import QSwitch
|
||||||
from nw.constants import nwLabels, nwItemLayout, nwItemClass, nwItemType
|
from nw.constants import nwLabels, nwItemLayout, nwItemType, nwLists
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -50,23 +51,29 @@ class GuiItemEditor(QDialog):
|
|||||||
self.theProject = theProject
|
self.theProject = theProject
|
||||||
self.theParent = theParent
|
self.theParent = theParent
|
||||||
|
|
||||||
self.outerBox = QVBoxLayout()
|
##
|
||||||
|
# Build GUI
|
||||||
|
##
|
||||||
|
|
||||||
self.theItem = self.theProject.projTree[tHandle]
|
self.theItem = self.theProject.projTree[tHandle]
|
||||||
if self.theItem is None:
|
if self.theItem is None:
|
||||||
self._doClose()
|
self._doClose()
|
||||||
|
|
||||||
self.setWindowTitle("Item Settings")
|
self.setWindowTitle("Item Settings")
|
||||||
self.setLayout(self.outerBox)
|
|
||||||
|
mVd = self.mainConf.pxInt(220)
|
||||||
|
mSp = self.mainConf.pxInt(16)
|
||||||
|
vSp = self.mainConf.pxInt(4)
|
||||||
|
|
||||||
# Item Label
|
# Item Label
|
||||||
self.editName = QLineEdit()
|
self.editName = QLineEdit()
|
||||||
self.editName.setMinimumWidth(self.mainConf.pxInt(220))
|
self.editName.setMinimumWidth(mVd)
|
||||||
self.editName.setMaxLength(self.mainConf.pxInt(200))
|
self.editName.setMaxLength(200)
|
||||||
|
|
||||||
# Item Status
|
# Item Status
|
||||||
self.editStatus = QComboBox()
|
self.editStatus = QComboBox()
|
||||||
if self.theItem.itemClass == nwItemClass.NOVEL:
|
self.editStatus.setMinimumWidth(mVd)
|
||||||
|
if self.theItem.itemClass in nwLists.CLS_NOVEL:
|
||||||
for sLabel, _, _ in self.theProject.statusItems:
|
for sLabel, _, _ in self.theProject.statusItems:
|
||||||
self.editStatus.addItem(
|
self.editStatus.addItem(
|
||||||
self.theParent.statusIcons[sLabel], sLabel, sLabel
|
self.theParent.statusIcons[sLabel], sLabel, sLabel
|
||||||
@@ -79,24 +86,24 @@ class GuiItemEditor(QDialog):
|
|||||||
|
|
||||||
# Item Layout
|
# Item Layout
|
||||||
self.editLayout = QComboBox()
|
self.editLayout = QComboBox()
|
||||||
self.validLayouts = []
|
self.editLayout.setMinimumWidth(mVd)
|
||||||
|
validLayouts = []
|
||||||
if self.theItem.itemType == nwItemType.FILE:
|
if self.theItem.itemType == nwItemType.FILE:
|
||||||
if self.theItem.itemClass == nwItemClass.NOVEL:
|
if self.theItem.itemClass in nwLists.CLS_NOVEL:
|
||||||
self.validLayouts.append(nwItemLayout.TITLE)
|
validLayouts.append(nwItemLayout.TITLE)
|
||||||
self.validLayouts.append(nwItemLayout.BOOK)
|
validLayouts.append(nwItemLayout.BOOK)
|
||||||
self.validLayouts.append(nwItemLayout.PAGE)
|
validLayouts.append(nwItemLayout.PAGE)
|
||||||
self.validLayouts.append(nwItemLayout.PARTITION)
|
validLayouts.append(nwItemLayout.PARTITION)
|
||||||
self.validLayouts.append(nwItemLayout.UNNUMBERED)
|
validLayouts.append(nwItemLayout.UNNUMBERED)
|
||||||
self.validLayouts.append(nwItemLayout.CHAPTER)
|
validLayouts.append(nwItemLayout.CHAPTER)
|
||||||
self.validLayouts.append(nwItemLayout.SCENE)
|
validLayouts.append(nwItemLayout.SCENE)
|
||||||
self.validLayouts.append(nwItemLayout.NOTE)
|
validLayouts.append(nwItemLayout.NOTE)
|
||||||
else:
|
|
||||||
self.validLayouts.append(nwItemLayout.NOTE)
|
|
||||||
else:
|
else:
|
||||||
self.validLayouts.append(nwItemLayout.NO_LAYOUT)
|
validLayouts.append(nwItemLayout.NO_LAYOUT)
|
||||||
|
self.editLayout.setEnabled(False)
|
||||||
|
|
||||||
for itemLayout in nwItemLayout:
|
for itemLayout in nwItemLayout:
|
||||||
if itemLayout in self.validLayouts:
|
if itemLayout in validLayouts:
|
||||||
self.editLayout.addItem(nwLabels.LAYOUT_NAME[itemLayout], itemLayout)
|
self.editLayout.addItem(nwLabels.LAYOUT_NAME[itemLayout], itemLayout)
|
||||||
|
|
||||||
# Export Switch
|
# Export Switch
|
||||||
@@ -109,23 +116,30 @@ class GuiItemEditor(QDialog):
|
|||||||
self.editExport.setEnabled(False)
|
self.editExport.setEnabled(False)
|
||||||
self.editExport.setChecked(False)
|
self.editExport.setChecked(False)
|
||||||
|
|
||||||
self.editName.setText(self.theItem.itemName)
|
|
||||||
statusIdx = self.editStatus.findData(self.theItem.itemStatus)
|
|
||||||
if statusIdx != -1:
|
|
||||||
self.editStatus.setCurrentIndex(statusIdx)
|
|
||||||
layoutIdx = self.editLayout.findData(self.theItem.itemLayout)
|
|
||||||
if layoutIdx != -1:
|
|
||||||
self.editLayout.setCurrentIndex(layoutIdx)
|
|
||||||
|
|
||||||
# Buttons
|
# Buttons
|
||||||
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
||||||
self.buttonBox.accepted.connect(self._doSave)
|
self.buttonBox.accepted.connect(self._doSave)
|
||||||
self.buttonBox.rejected.connect(self._doClose)
|
self.buttonBox.rejected.connect(self._doClose)
|
||||||
|
|
||||||
# Assemble
|
# Set Current Values
|
||||||
|
self.editName.setText(self.theItem.itemName)
|
||||||
|
self.editName.selectAll()
|
||||||
|
|
||||||
|
statusIdx = self.editStatus.findData(self.theItem.itemStatus)
|
||||||
|
if statusIdx != -1:
|
||||||
|
self.editStatus.setCurrentIndex(statusIdx)
|
||||||
|
|
||||||
|
layoutIdx = self.editLayout.findData(self.theItem.itemLayout)
|
||||||
|
if layoutIdx != -1:
|
||||||
|
self.editLayout.setCurrentIndex(layoutIdx)
|
||||||
|
|
||||||
|
##
|
||||||
|
# Assemble
|
||||||
|
##
|
||||||
|
|
||||||
self.mainForm = QGridLayout()
|
self.mainForm = QGridLayout()
|
||||||
self.mainForm.setVerticalSpacing(self.mainConf.pxInt(4))
|
self.mainForm.setVerticalSpacing(vSp)
|
||||||
self.mainForm.setHorizontalSpacing(self.mainConf.pxInt(16))
|
self.mainForm.setHorizontalSpacing(mSp)
|
||||||
self.mainForm.addWidget(QLabel("Label"), 0, 0, 1, 1)
|
self.mainForm.addWidget(QLabel("Label"), 0, 0, 1, 1)
|
||||||
self.mainForm.addWidget(self.editName, 0, 1, 1, 2)
|
self.mainForm.addWidget(self.editName, 0, 1, 1, 2)
|
||||||
self.mainForm.addWidget(QLabel("Status"), 1, 0, 1, 1)
|
self.mainForm.addWidget(QLabel("Status"), 1, 0, 1, 1)
|
||||||
@@ -134,20 +148,28 @@ class GuiItemEditor(QDialog):
|
|||||||
self.mainForm.addWidget(self.editLayout, 2, 1, 1, 2)
|
self.mainForm.addWidget(self.editLayout, 2, 1, 1, 2)
|
||||||
self.mainForm.addWidget(self.textExport, 3, 0, 1, 2)
|
self.mainForm.addWidget(self.textExport, 3, 0, 1, 2)
|
||||||
self.mainForm.addWidget(self.editExport, 3, 2, 1, 1)
|
self.mainForm.addWidget(self.editExport, 3, 2, 1, 1)
|
||||||
|
self.mainForm.setColumnStretch(0, 0)
|
||||||
|
self.mainForm.setColumnStretch(1, 1)
|
||||||
|
self.mainForm.setColumnStretch(2, 0)
|
||||||
|
|
||||||
self.outerBox.setSpacing(self.mainConf.pxInt(16))
|
self.outerBox = QVBoxLayout()
|
||||||
|
self.outerBox.setSpacing(mSp)
|
||||||
self.outerBox.addLayout(self.mainForm)
|
self.outerBox.addLayout(self.mainForm)
|
||||||
self.outerBox.addStretch(1)
|
self.outerBox.addStretch(1)
|
||||||
self.outerBox.addWidget(self.buttonBox)
|
self.outerBox.addWidget(self.buttonBox)
|
||||||
self.setLayout(self.outerBox)
|
self.setLayout(self.outerBox)
|
||||||
|
|
||||||
self.rejected.connect(self._doClose)
|
self.rejected.connect(self._doClose)
|
||||||
self.editName.selectAll()
|
|
||||||
|
|
||||||
logger.debug("GuiItemEditor initialisation complete")
|
logger.debug("GuiItemEditor initialisation complete")
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
##
|
||||||
|
# Slots
|
||||||
|
##
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
def _doSave(self):
|
def _doSave(self):
|
||||||
"""Save the setting to the item.
|
"""Save the setting to the item.
|
||||||
"""
|
"""
|
||||||
@@ -170,10 +192,11 @@ class GuiItemEditor(QDialog):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
def _doClose(self):
|
def _doClose(self):
|
||||||
"""Close the dialog without saving the settings.
|
"""Close the dialog without saving the settings.
|
||||||
"""
|
"""
|
||||||
logger.verbose("ItemEditor close button clicked")
|
logger.verbose("ItemEditor cancel button clicked")
|
||||||
self.close()
|
self.close()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
+7
-13
@@ -535,36 +535,30 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
def setTreeItemValues(self, tHandle):
|
def setTreeItemValues(self, tHandle):
|
||||||
"""Set the name and flag values for a tree item.
|
"""Set the name and flag values for a tree item.
|
||||||
"""
|
"""
|
||||||
trItem = self._getTreeItem(tHandle)
|
trItem = self._getTreeItem(tHandle)
|
||||||
nwItem = self.theProject.projTree[tHandle]
|
nwItem = self.theProject.projTree[tHandle]
|
||||||
tName = nwItem.itemName
|
|
||||||
tClass = nwItem.itemClass
|
|
||||||
tHandle = nwItem.itemHandle
|
|
||||||
|
|
||||||
expIcon = QIcon()
|
expIcon = QIcon()
|
||||||
|
stFlags = nwLabels.CLASS_FLAG[nwItem.itemClass]
|
||||||
stClass = nwLabels.CLASS_FLAG[nwItem.itemClass]
|
|
||||||
stLayout = ""
|
|
||||||
if nwItem.itemType == nwItemType.FILE:
|
if nwItem.itemType == nwItemType.FILE:
|
||||||
stLayout = "."+nwLabels.LAYOUT_FLAG[nwItem.itemLayout]
|
stFlags += "."+nwLabels.LAYOUT_FLAG[nwItem.itemLayout]
|
||||||
if nwItem.isExported:
|
if nwItem.isExported:
|
||||||
expIcon = self.theTheme.getIcon("check")
|
expIcon = self.theTheme.getIcon("check")
|
||||||
else:
|
else:
|
||||||
expIcon = self.theTheme.getIcon("cross")
|
expIcon = self.theTheme.getIcon("cross")
|
||||||
tStatus = stClass+stLayout
|
|
||||||
|
|
||||||
iStatus = nwItem.itemStatus
|
iStatus = nwItem.itemStatus
|
||||||
if tClass == nwItemClass.NOVEL:
|
if nwItem.itemClass == nwItemClass.NOVEL:
|
||||||
iStatus = self.theProject.statusItems.checkEntry(iStatus) # Make sure it's valid
|
iStatus = self.theProject.statusItems.checkEntry(iStatus) # Make sure it's valid
|
||||||
flagIcon = self.theParent.statusIcons[iStatus]
|
flagIcon = self.theParent.statusIcons[iStatus]
|
||||||
else:
|
else:
|
||||||
iStatus = self.theProject.importItems.checkEntry(iStatus) # Make sure it's valid
|
iStatus = self.theProject.importItems.checkEntry(iStatus) # Make sure it's valid
|
||||||
flagIcon = self.theParent.importIcons[iStatus]
|
flagIcon = self.theParent.importIcons[iStatus]
|
||||||
|
|
||||||
trItem.setText(self.C_NAME, tName)
|
trItem.setText(self.C_NAME, nwItem.itemName)
|
||||||
trItem.setIcon(self.C_EXPORT, expIcon)
|
trItem.setIcon(self.C_EXPORT, expIcon)
|
||||||
trItem.setText(self.C_FLAGS, tStatus)
|
|
||||||
trItem.setIcon(self.C_FLAGS, flagIcon)
|
trItem.setIcon(self.C_FLAGS, flagIcon)
|
||||||
|
trItem.setText(self.C_FLAGS, stFlags)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -47,7 +47,7 @@ from nw.gui import (
|
|||||||
GuiTheme, GuiWritingStats
|
GuiTheme, GuiWritingStats
|
||||||
)
|
)
|
||||||
from nw.core import NWProject, NWDoc, NWIndex
|
from nw.core import NWProject, NWDoc, NWIndex
|
||||||
from nw.constants import nwItemType, nwItemClass, nwAlert, nwConst
|
from nw.constants import nwItemType, nwItemClass, nwAlert, nwLists
|
||||||
from nw.common import getGuiItem
|
from nw.common import getGuiItem
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -725,7 +725,7 @@ class GuiMain(QMainWindow):
|
|||||||
tItem = self.theProject.projTree[tHandle]
|
tItem = self.theProject.projTree[tHandle]
|
||||||
if tItem is None:
|
if tItem is None:
|
||||||
return
|
return
|
||||||
if tItem.itemType not in nwConst.REG_TYPES:
|
if tItem.itemType not in nwLists.REG_TYPES:
|
||||||
return
|
return
|
||||||
|
|
||||||
logger.verbose("Requesting change to item %s" % tHandle)
|
logger.verbose("Requesting change to item %s" % tHandle)
|
||||||
|
|||||||
Reference in New Issue
Block a user