The opren recent project dialog now remembers column width and projects can be opened with double click

This commit is contained in:
Veronica K. B. Olsen
2020-04-14 22:49:25 +02:00
parent 5e90b1ff77
commit 4abec49b0a
2 changed files with 28 additions and 5 deletions
+10
View File
@@ -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
+18 -5
View File
@@ -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