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