Merge pull request #183 from vkbo/tweaks
Tweaks (Open Project and Outline)
This commit is contained in:
@@ -73,6 +73,7 @@ class Config:
|
|||||||
## Sizes
|
## Sizes
|
||||||
self.winGeometry = [1100, 650]
|
self.winGeometry = [1100, 650]
|
||||||
self.treeColWidth = [120, 30, 50]
|
self.treeColWidth = [120, 30, 50]
|
||||||
|
self.projColWidth = [140, 55, 140]
|
||||||
self.mainPanePos = [300, 800]
|
self.mainPanePos = [300, 800]
|
||||||
self.docPanePos = [400, 400]
|
self.docPanePos = [400, 400]
|
||||||
self.isFullScreen = False
|
self.isFullScreen = False
|
||||||
@@ -295,6 +296,9 @@ class Config:
|
|||||||
self.treeColWidth = self._parseLine(
|
self.treeColWidth = self._parseLine(
|
||||||
cnfParse, cnfSec, "treecols", self.CNF_LIST, self.treeColWidth
|
cnfParse, cnfSec, "treecols", self.CNF_LIST, self.treeColWidth
|
||||||
)
|
)
|
||||||
|
self.projColWidth = self._parseLine(
|
||||||
|
cnfParse, cnfSec, "projcols", self.CNF_LIST, self.projColWidth
|
||||||
|
)
|
||||||
self.mainPanePos = self._parseLine(
|
self.mainPanePos = self._parseLine(
|
||||||
cnfParse, cnfSec, "mainpane", self.CNF_LIST, self.mainPanePos
|
cnfParse, cnfSec, "mainpane", self.CNF_LIST, self.mainPanePos
|
||||||
)
|
)
|
||||||
@@ -432,6 +436,7 @@ class Config:
|
|||||||
cnfParse.add_section(cnfSec)
|
cnfParse.add_section(cnfSec)
|
||||||
cnfParse.set(cnfSec,"geometry", self._packList(self.winGeometry))
|
cnfParse.set(cnfSec,"geometry", self._packList(self.winGeometry))
|
||||||
cnfParse.set(cnfSec,"treecols", self._packList(self.treeColWidth))
|
cnfParse.set(cnfSec,"treecols", self._packList(self.treeColWidth))
|
||||||
|
cnfParse.set(cnfSec,"projcols", self._packList(self.projColWidth))
|
||||||
cnfParse.set(cnfSec,"mainpane", self._packList(self.mainPanePos))
|
cnfParse.set(cnfSec,"mainpane", self._packList(self.mainPanePos))
|
||||||
cnfParse.set(cnfSec,"docpane", self._packList(self.docPanePos))
|
cnfParse.set(cnfSec,"docpane", self._packList(self.docPanePos))
|
||||||
cnfParse.set(cnfSec,"fullscreen", str(self.isFullScreen))
|
cnfParse.set(cnfSec,"fullscreen", str(self.isFullScreen))
|
||||||
@@ -619,6 +624,11 @@ class Config:
|
|||||||
self.confChanged = True
|
self.confChanged = True
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def setProjColWidths(self, colWidths):
|
||||||
|
self.projColWidth = colWidths
|
||||||
|
self.confChanged = True
|
||||||
|
return True
|
||||||
|
|
||||||
def setMainPanePos(self, panePos):
|
def setMainPanePos(self, panePos):
|
||||||
self.mainPanePos = panePos
|
self.mainPanePos = panePos
|
||||||
self.confChanged = True
|
self.confChanged = True
|
||||||
|
|||||||
@@ -54,11 +54,13 @@ class GuiProjectLoad(QDialog):
|
|||||||
self.listBox.setSelectionMode(QAbstractItemView.SingleSelection)
|
self.listBox.setSelectionMode(QAbstractItemView.SingleSelection)
|
||||||
self.listBox.setDragDropMode(QAbstractItemView.NoDragDrop)
|
self.listBox.setDragDropMode(QAbstractItemView.NoDragDrop)
|
||||||
self.listBox.setColumnCount(4)
|
self.listBox.setColumnCount(4)
|
||||||
self.listBox.setHeaderLabels(["Working Title","Words","Accessed","Path"])
|
self.listBox.setHeaderLabels(["Working Title","Words","Last Opened","Path"])
|
||||||
self.listBox.setRootIsDecorated(False)
|
self.listBox.setRootIsDecorated(False)
|
||||||
|
self.listBox.itemDoubleClicked.connect(self._doOpenRecent)
|
||||||
|
|
||||||
treeHead = self.listBox.headerItem()
|
treeHead = self.listBox.headerItem()
|
||||||
treeHead.setTextAlignment(1, Qt.AlignRight)
|
treeHead.setTextAlignment(1, Qt.AlignRight)
|
||||||
|
treeHead.setTextAlignment(2, Qt.AlignRight)
|
||||||
|
|
||||||
self.recentButton = QPushButton("Open")
|
self.recentButton = QPushButton("Open")
|
||||||
self.recentButton.clicked.connect(self._doOpenRecent)
|
self.recentButton.clicked.connect(self._doOpenRecent)
|
||||||
@@ -95,7 +97,7 @@ class GuiProjectLoad(QDialog):
|
|||||||
"""Close the dialog window with a recent project selected.
|
"""Close the dialog window with a recent project selected.
|
||||||
"""
|
"""
|
||||||
logger.verbose("GuiProjectLoad open button clicked")
|
logger.verbose("GuiProjectLoad open button clicked")
|
||||||
|
self._saveDialogState()
|
||||||
selItems = self.listBox.selectedItems()
|
selItems = self.listBox.selectedItems()
|
||||||
if selItems:
|
if selItems:
|
||||||
self.openPath = selItems[0].text(3)
|
self.openPath = selItems[0].text(3)
|
||||||
@@ -110,6 +112,7 @@ class GuiProjectLoad(QDialog):
|
|||||||
project browser dialog.
|
project browser dialog.
|
||||||
"""
|
"""
|
||||||
logger.verbose("GuiProjectLoad browse button clicked")
|
logger.verbose("GuiProjectLoad browse button clicked")
|
||||||
|
self._saveDialogState()
|
||||||
self.openPath = None
|
self.openPath = None
|
||||||
self.accept()
|
self.accept()
|
||||||
return
|
return
|
||||||
@@ -118,6 +121,7 @@ class GuiProjectLoad(QDialog):
|
|||||||
"""Close the dialog window without doing anything.
|
"""Close the dialog window without doing anything.
|
||||||
"""
|
"""
|
||||||
logger.verbose("GuiProjectLoad close button clicked")
|
logger.verbose("GuiProjectLoad close button clicked")
|
||||||
|
self._saveDialogState()
|
||||||
self.close()
|
self.close()
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -125,6 +129,15 @@ class GuiProjectLoad(QDialog):
|
|||||||
# Internal Functions
|
# Internal Functions
|
||||||
##
|
##
|
||||||
|
|
||||||
|
def _saveDialogState(self):
|
||||||
|
"""Save the changes made to the dialog.
|
||||||
|
"""
|
||||||
|
colWidths = [50]*3
|
||||||
|
for i in range(3):
|
||||||
|
colWidths[i] = self.listBox.columnWidth(i)
|
||||||
|
self.mainConf.setProjColWidths(colWidths)
|
||||||
|
return
|
||||||
|
|
||||||
def _populateList(self):
|
def _populateList(self):
|
||||||
"""Populate the list box with recent project data.
|
"""Populate the list box with recent project data.
|
||||||
"""
|
"""
|
||||||
@@ -155,14 +168,14 @@ class GuiProjectLoad(QDialog):
|
|||||||
newItem.setText(2, datetime.fromtimestamp(timeStamp).strftime("%x %X"))
|
newItem.setText(2, datetime.fromtimestamp(timeStamp).strftime("%x %X"))
|
||||||
newItem.setText(3, listData[timeStamp][2])
|
newItem.setText(3, listData[timeStamp][2])
|
||||||
newItem.setTextAlignment(1, Qt.AlignRight)
|
newItem.setTextAlignment(1, Qt.AlignRight)
|
||||||
|
newItem.setTextAlignment(2, Qt.AlignRight)
|
||||||
self.listBox.addTopLevelItem(newItem)
|
self.listBox.addTopLevelItem(newItem)
|
||||||
if not hasSelection:
|
if not hasSelection:
|
||||||
newItem.setSelected(True)
|
newItem.setSelected(True)
|
||||||
hasSelection = True
|
hasSelection = True
|
||||||
|
|
||||||
self.listBox.resizeColumnToContents(0)
|
for i in range(3):
|
||||||
self.listBox.resizeColumnToContents(1)
|
self.listBox.setColumnWidth(i, self.mainConf.projColWidth[i])
|
||||||
self.listBox.resizeColumnToContents(2)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -97,24 +97,29 @@ class GuiProjectOutline(QTreeWidget):
|
|||||||
self.colIndex = {}
|
self.colIndex = {}
|
||||||
self.treeNCols = 0
|
self.treeNCols = 0
|
||||||
|
|
||||||
self.initOutline()
|
self.clearOutline()
|
||||||
self.headerMenu.setHiddenState(self.colHidden)
|
self.headerMenu.setHiddenState(self.colHidden)
|
||||||
|
|
||||||
logger.debug("ProjectOutline initialisation complete")
|
logger.debug("ProjectOutline initialisation complete")
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def initOutline(self):
|
def clearOutline(self):
|
||||||
"""Set the default values for the Outline tree.
|
"""Clear the tree and header and set the default values for the
|
||||||
|
columns arrays.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
self.clear()
|
||||||
|
self.setColumnCount(1)
|
||||||
|
self.setHeaderLabel(nwLabels.OUTLINE_COLS[nwOutline.TITLE])
|
||||||
|
|
||||||
self.treeOrder = []
|
self.treeOrder = []
|
||||||
self.colWidth = {}
|
self.colWidth = {}
|
||||||
self.colHidden = {}
|
self.colHidden = {}
|
||||||
self.colIndex = {}
|
self.colIndex = {}
|
||||||
self.treeNCols = 0
|
self.treeNCols = 0
|
||||||
|
|
||||||
for hItem in nwOutline:
|
for i, hItem in enumerate(nwOutline):
|
||||||
self.treeOrder.append(hItem)
|
self.treeOrder.append(hItem)
|
||||||
self.colWidth[hItem] = self.DEF_WIDTH[hItem]
|
self.colWidth[hItem] = self.DEF_WIDTH[hItem]
|
||||||
self.colHidden[hItem] = self.DEF_HIDDEN[hItem]
|
self.colHidden[hItem] = self.DEF_HIDDEN[hItem]
|
||||||
@@ -153,7 +158,7 @@ class GuiProjectOutline(QTreeWidget):
|
|||||||
"""Called before a project is closed.
|
"""Called before a project is closed.
|
||||||
"""
|
"""
|
||||||
self._saveHeaderState()
|
self._saveHeaderState()
|
||||||
self.clear()
|
self.clearOutline()
|
||||||
self.firstView = True
|
self.firstView = True
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -315,6 +315,7 @@ class GuiMain(QMainWindow):
|
|||||||
self.theIndex.clearIndex()
|
self.theIndex.clearIndex()
|
||||||
self.clearGUI()
|
self.clearGUI()
|
||||||
self.hasProject = False
|
self.hasProject = False
|
||||||
|
self.tabWidget.setCurrentWidget(self.splitView)
|
||||||
|
|
||||||
return saveOK
|
return saveOK
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ class OptionState():
|
|||||||
"""Load the options dictionary from the project settings file.
|
"""Load the options dictionary from the project settings file.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if self.theProject.projMeta is None:
|
||||||
|
return False
|
||||||
|
|
||||||
stateFile = path.join(self.theProject.projMeta, nwFiles.OPTS_FILE)
|
stateFile = path.join(self.theProject.projMeta, nwFiles.OPTS_FILE)
|
||||||
theState = {}
|
theState = {}
|
||||||
|
|
||||||
@@ -60,6 +63,9 @@ class OptionState():
|
|||||||
"""Save the options dictionary to the project settings file.
|
"""Save the options dictionary to the project settings file.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if self.theProject.projMeta is None:
|
||||||
|
return False
|
||||||
|
|
||||||
stateFile = path.join(self.theProject.projMeta, nwFiles.OPTS_FILE)
|
stateFile = path.join(self.theProject.projMeta, nwFiles.OPTS_FILE)
|
||||||
logger.debug("Saving GUI options file")
|
logger.debug("Saving GUI options file")
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[Main]
|
[Main]
|
||||||
timestamp = 2020-02-26 18:10:35
|
timestamp = 2020-04-14 22:47:16
|
||||||
theme = default
|
theme = default
|
||||||
syntax = default_light
|
syntax = default_light
|
||||||
guidark = False
|
guidark = False
|
||||||
@@ -7,6 +7,7 @@ guidark = False
|
|||||||
[Sizes]
|
[Sizes]
|
||||||
geometry = 1100, 650
|
geometry = 1100, 650
|
||||||
treecols = 120, 30, 50
|
treecols = 120, 30, 50
|
||||||
|
projcols = 140, 55, 140
|
||||||
mainpane = 300, 800
|
mainpane = 300, 800
|
||||||
docpane = 400, 400
|
docpane = 400, 400
|
||||||
fullscreen = False
|
fullscreen = False
|
||||||
|
|||||||
Reference in New Issue
Block a user