A few improvements here and there

This commit is contained in:
Veronica K. B. Olsen
2020-06-04 22:49:27 +02:00
parent 10ef9d3453
commit 0a3751046b
3 changed files with 20 additions and 14 deletions
+8 -3
View File
@@ -88,7 +88,7 @@ class Config:
self.guiLang = "en" # Hardcoded for now
self.guiFont = ""
self.guiFontSize = 11
self.guiScale = 1.0
self.guiScale = 1.0 # Set automatically by Theme class
## Sizes
self.winGeometry = [1100, 650]
@@ -126,8 +126,8 @@ class Config:
self.highlightQuotes = True
self.fmtApostrophe = nwUnicode.U_RSQUO
self.fmtSingleQuotes = [nwUnicode.U_LSQUO,nwUnicode.U_RSQUO]
self.fmtDoubleQuotes = [nwUnicode.U_LDQUO,nwUnicode.U_RDQUO]
self.fmtSingleQuotes = [nwUnicode.U_LSQUO, nwUnicode.U_RSQUO]
self.fmtDoubleQuotes = [nwUnicode.U_LDQUO, nwUnicode.U_RDQUO]
self.spellTool = None
self.spellLanguage = None
@@ -202,9 +202,14 @@ class Config:
##
def pxInt(self, theSize):
"""Used to scale fixed gui sizes by the screen scale factor.
This function returns an int, which is always rounded down.
"""
return int(self.guiScale*theSize)
def pxFloat(self, theSize):
"""Used to scale fixed gui sizes by the screen scale factor.
"""
return self.guiScale*theSize
##
+2
View File
@@ -329,6 +329,8 @@ class GuiConfigEditGeneralTab(QWidget):
##
def _backupFolder(self):
"""Open a dialog to select the backup folder.
"""
currDir = self.backupPath
if not path.isdir(currDir):
+10 -11
View File
@@ -61,20 +61,20 @@ class GuiProjectLoad(QDialog):
self.openState = self.NONE_STATE
self.openPath = None
xSp = self.mainConf.pxInt(16)
xIc = self.mainConf.pxInt(96)
sPx = self.mainConf.pxInt(16)
iPx = self.mainConf.pxInt(96)
self.outerBox = QVBoxLayout()
self.innerBox = QHBoxLayout()
self.outerBox.setSpacing(xSp)
self.innerBox.setSpacing(xSp)
self.outerBox.setSpacing(sPx)
self.innerBox.setSpacing(sPx)
self.setWindowTitle("Open Project")
self.setMinimumWidth(self.mainConf.pxInt(650))
self.setMinimumHeight(self.mainConf.pxInt(400))
self.setModal(True)
self.guiDeco = self.theTheme.loadDecoration("nwicon", (xIc, xIc))
self.guiDeco = self.theTheme.loadDecoration("nwicon", (iPx, iPx))
self.innerBox.addWidget(self.guiDeco, 0, Qt.AlignTop)
self.projectForm = QGridLayout()
@@ -84,10 +84,9 @@ class GuiProjectLoad(QDialog):
self.listBox = QTreeWidget()
self.listBox.setSelectionMode(QAbstractItemView.SingleSelection)
self.listBox.setDragDropMode(QAbstractItemView.NoDragDrop)
self.listBox.setColumnCount(4)
self.listBox.setHeaderLabels(["Working Title","Words","Last Opened","Path"])
self.listBox.setColumnCount(3)
self.listBox.setHeaderLabels(["Working Title", "Words", "Last Opened"])
self.listBox.setRootIsDecorated(False)
self.listBox.setColumnHidden(3, True)
self.listBox.itemSelectionChanged.connect(self._doSelectRecent)
self.listBox.itemDoubleClicked.connect(self._doOpenRecent)
self.listBox.setIconSize(QSize(iPx, iPx))
@@ -154,7 +153,7 @@ class GuiProjectLoad(QDialog):
self._saveDialogState()
selItems = self.listBox.selectedItems()
if selItems:
self.openPath = selItems[0].text(3)
self.openPath = selItems[0].data(0, Qt.UserRole)
self.openState = self.OPEN_STATE
self.accept()
else:
@@ -167,7 +166,7 @@ class GuiProjectLoad(QDialog):
"""
selList = self.listBox.selectedItems()
if selList:
self.selPath.setText(selList[0].text(3))
self.selPath.setText(selList[0].data(0, Qt.UserRole))
return
def _doBrowse(self):
@@ -257,9 +256,9 @@ class GuiProjectLoad(QDialog):
newItem = QTreeWidgetItem([""]*4)
newItem.setIcon(0, self.theParent.theTheme.getIcon("proj_nwx"))
newItem.setText(0, listData[timeStamp][0])
newItem.setData(0, Qt.UserRole, listData[timeStamp][2])
newItem.setText(1, formatInt(listData[timeStamp][1]))
newItem.setText(2, datetime.fromtimestamp(timeStamp).strftime("%x %X"))
newItem.setText(3, listData[timeStamp][2])
newItem.setTextAlignment(0, Qt.AlignLeft | Qt.AlignVCenter)
newItem.setTextAlignment(1, Qt.AlignRight | Qt.AlignVCenter)
newItem.setTextAlignment(2, Qt.AlignRight | Qt.AlignVCenter)