Merge branch 'dev' into project_options
This commit is contained in:
+57
-7
@@ -2029,10 +2029,43 @@ class OptionState():
|
|||||||
|
|
||||||
self.mainConf = nw.CONFIG
|
self.mainConf = nw.CONFIG
|
||||||
self.theProject = theProject
|
self.theProject = theProject
|
||||||
self.theState = {}
|
|
||||||
self.stringOpt = ()
|
self.theState = {}
|
||||||
self.boolOpt = ()
|
self.validMap = {
|
||||||
self.intOpt = ()
|
"GuiSession": set([
|
||||||
|
"widthCol0",
|
||||||
|
"widthCol1",
|
||||||
|
"widthCol2",
|
||||||
|
"sortCol",
|
||||||
|
"sortOrder",
|
||||||
|
"hideZeros",
|
||||||
|
"hideNegative",
|
||||||
|
]),
|
||||||
|
"GuiDocSplit": set([
|
||||||
|
"spLevel",
|
||||||
|
]),
|
||||||
|
"GuiBuildNovel": set([
|
||||||
|
"winWidth",
|
||||||
|
"winHeight",
|
||||||
|
"addNovel",
|
||||||
|
"addNotes",
|
||||||
|
"ignoreFlag",
|
||||||
|
"justifyText",
|
||||||
|
"excludeBody",
|
||||||
|
"textFont",
|
||||||
|
"textSize",
|
||||||
|
"noStyling",
|
||||||
|
"incSynopsis",
|
||||||
|
"incComments",
|
||||||
|
"incKeywords",
|
||||||
|
"incBodyText",
|
||||||
|
]),
|
||||||
|
"GuiOutline": set([
|
||||||
|
"headerOrder",
|
||||||
|
"columnWidth",
|
||||||
|
"columnHidden",
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -2059,8 +2092,14 @@ class OptionState():
|
|||||||
logger.error("Failed to load GUI options file")
|
logger.error("Failed to load GUI options file")
|
||||||
logger.error(str(e))
|
logger.error(str(e))
|
||||||
return False
|
return False
|
||||||
for anOpt in theState:
|
|
||||||
self.theState[anOpt] = theState[anOpt]
|
# Filter out unused variables
|
||||||
|
for aGroup in theState:
|
||||||
|
if aGroup in self.validMap:
|
||||||
|
self.theState[aGroup] = {}
|
||||||
|
for anOpt in theState[aGroup]:
|
||||||
|
if anOpt in self.validMap[aGroup]:
|
||||||
|
self.theState[aGroup][anOpt] = theState[aGroup][anOpt]
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -2090,9 +2129,19 @@ class OptionState():
|
|||||||
def setValue(self, setGroup, setName, setValue):
|
def setValue(self, setGroup, setName, setValue):
|
||||||
"""Saves a value, with a given group and name.
|
"""Saves a value, with a given group and name.
|
||||||
"""
|
"""
|
||||||
|
if not setGroup in self.validMap:
|
||||||
|
logger.error("Unknown option group '%s'" % setGroup)
|
||||||
|
return False
|
||||||
|
|
||||||
|
if not setName in self.validMap[setGroup]:
|
||||||
|
logger.error("Unknown option name '%s'" % setName)
|
||||||
|
return False
|
||||||
|
|
||||||
if not setGroup in self.theState:
|
if not setGroup in self.theState:
|
||||||
self.theState[setGroup] = {}
|
self.theState[setGroup] = {}
|
||||||
|
|
||||||
self.theState[setGroup][setName] = setValue
|
self.theState[setGroup][setName] = setValue
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
##
|
##
|
||||||
@@ -2120,7 +2169,8 @@ class OptionState():
|
|||||||
if getName in self.theState[getGroup]:
|
if getName in self.theState[getGroup]:
|
||||||
try:
|
try:
|
||||||
return str(self.theState[getGroup][getName])
|
return str(self.theState[getGroup][getName])
|
||||||
except:
|
except Exception as e:
|
||||||
|
logger.warning(str(e))
|
||||||
return defaultValue
|
return defaultValue
|
||||||
return defaultValue
|
return defaultValue
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -233,14 +233,14 @@ class GuiMainMenu(QMenuBar):
|
|||||||
self.projMenu.addSeparator()
|
self.projMenu.addSeparator()
|
||||||
|
|
||||||
# Project > Edit
|
# Project > Edit
|
||||||
self.aEditItem = QAction("&Edit Item", self)
|
self.aEditItem = QAction("&Edit Project Item", self)
|
||||||
self.aEditItem.setStatusTip("Change item settings")
|
self.aEditItem.setStatusTip("Change item settings")
|
||||||
self.aEditItem.setShortcuts(["Ctrl+E", "F2"])
|
self.aEditItem.setShortcuts(["Ctrl+E", "F2"])
|
||||||
self.aEditItem.triggered.connect(self.theParent.editItem)
|
self.aEditItem.triggered.connect(self.theParent.editItem)
|
||||||
self.projMenu.addAction(self.aEditItem)
|
self.projMenu.addAction(self.aEditItem)
|
||||||
|
|
||||||
# Project > Delete
|
# Project > Delete
|
||||||
self.aDeleteItem = QAction("&Delete Item", self)
|
self.aDeleteItem = QAction("&Delete Project Item", self)
|
||||||
self.aDeleteItem.setStatusTip("Delete selected item")
|
self.aDeleteItem.setStatusTip("Delete selected item")
|
||||||
self.aDeleteItem.setShortcut("Ctrl+Del")
|
self.aDeleteItem.setShortcut("Ctrl+Del")
|
||||||
self.aDeleteItem.triggered.connect(lambda : self.theParent.treeView.deleteItem(None))
|
self.aDeleteItem.triggered.connect(lambda : self.theParent.treeView.deleteItem(None))
|
||||||
|
|||||||
+27
-1
@@ -836,7 +836,15 @@ class GuiProjectTreeMenu(QMenu):
|
|||||||
self.theTree = theTree
|
self.theTree = theTree
|
||||||
self.theItem = None
|
self.theItem = None
|
||||||
|
|
||||||
self.editItem = QAction("Edit Item", self)
|
self.openItem = QAction("Open Document", self)
|
||||||
|
self.openItem.triggered.connect(self._doOpenItem)
|
||||||
|
self.addAction(self.openItem)
|
||||||
|
|
||||||
|
self.viewItem = QAction("View Document", self)
|
||||||
|
self.viewItem.triggered.connect(self._doViewItem)
|
||||||
|
self.addAction(self.viewItem)
|
||||||
|
|
||||||
|
self.editItem = QAction("Edit Project Item", self)
|
||||||
self.editItem.triggered.connect(self._doEditItem)
|
self.editItem.triggered.connect(self._doEditItem)
|
||||||
self.addAction(self.editItem)
|
self.addAction(self.editItem)
|
||||||
|
|
||||||
@@ -876,6 +884,8 @@ class GuiProjectTreeMenu(QMenu):
|
|||||||
isFile = theItem.itemType == nwItemType.FILE
|
isFile = theItem.itemType == nwItemType.FILE
|
||||||
isOrph = isFile and theItem.parHandle is None
|
isOrph = isFile and theItem.parHandle is None
|
||||||
|
|
||||||
|
showOpen = isFile
|
||||||
|
showView = isFile
|
||||||
showEdit = not isTrash and not isOrph
|
showEdit = not isTrash and not isOrph
|
||||||
showExport = isFile and not inTrash and not isOrph
|
showExport = isFile and not inTrash and not isOrph
|
||||||
showNewFile = not isTrash and not inTrash and not isOrph
|
showNewFile = not isTrash and not inTrash and not isOrph
|
||||||
@@ -883,6 +893,8 @@ class GuiProjectTreeMenu(QMenu):
|
|||||||
showDelete = not isTrash
|
showDelete = not isTrash
|
||||||
showEmpty = isTrash
|
showEmpty = isTrash
|
||||||
|
|
||||||
|
self.openItem.setVisible(showOpen)
|
||||||
|
self.viewItem.setVisible(showView)
|
||||||
self.editItem.setVisible(showEdit)
|
self.editItem.setVisible(showEdit)
|
||||||
self.toggleExp.setVisible(showExport)
|
self.toggleExp.setVisible(showExport)
|
||||||
self.newFile.setVisible(showNewFile)
|
self.newFile.setVisible(showNewFile)
|
||||||
@@ -896,6 +908,20 @@ class GuiProjectTreeMenu(QMenu):
|
|||||||
# Slots
|
# Slots
|
||||||
##
|
##
|
||||||
|
|
||||||
|
def _doOpenItem(self):
|
||||||
|
"""Forward the open document call to the main GUI window.
|
||||||
|
"""
|
||||||
|
if self.theItem is not None:
|
||||||
|
self.theTree.theParent.openDocument(self.theItem.itemHandle)
|
||||||
|
return
|
||||||
|
|
||||||
|
def _doViewItem(self):
|
||||||
|
"""Forward the view document call to the main GUI window.
|
||||||
|
"""
|
||||||
|
if self.theItem is not None:
|
||||||
|
self.theTree.theParent.viewDocument(self.theItem.itemHandle)
|
||||||
|
return
|
||||||
|
|
||||||
def _doEditItem(self):
|
def _doEditItem(self):
|
||||||
"""Forward the edit item call to the main GUI window.
|
"""Forward the edit item call to the main GUI window.
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user