Merge pull request #309 from vkbo/load_updates
Project Load Updates (++)
This commit is contained in:
@@ -56,8 +56,8 @@ class GuiItemDetails(QWidget):
|
||||
self.setLayout(self.mainBox)
|
||||
|
||||
self.pS = 0.9*self.theTheme.fontPointSize
|
||||
self.iPx = self.theTheme.textIconSize
|
||||
self.sPx = int(round(0.8*self.theTheme.textIconSize))
|
||||
self.iPx = self.theTheme.baseIconSize
|
||||
self.sPx = int(round(0.8*self.theTheme.baseIconSize))
|
||||
|
||||
self.expCheck = self.theTheme.getPixmap("check", (self.iPx, self.iPx))
|
||||
self.expCross = self.theTheme.getPixmap("cross", (self.iPx, self.iPx))
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ class GuiOutline(QTreeWidget):
|
||||
self.itemDoubleClicked.connect(self._treeDoubleClick)
|
||||
self.itemSelectionChanged.connect(self._itemSelected)
|
||||
|
||||
iPx = self.theTheme.textIconSize
|
||||
iPx = self.theTheme.baseIconSize
|
||||
self.setIconSize(QSize(iPx, iPx))
|
||||
self.setIndentation(iPx)
|
||||
|
||||
|
||||
+45
-23
@@ -36,7 +36,7 @@ from PyQt5.QtGui import QKeySequence
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialog, QHBoxLayout, QVBoxLayout, QGridLayout, QPushButton, QTreeWidget,
|
||||
QAbstractItemView, QTreeWidgetItem, QDialogButtonBox, QLabel, QShortcut,
|
||||
QFileDialog, QLineEdit
|
||||
QFileDialog, QLineEdit, QMessageBox
|
||||
)
|
||||
|
||||
from nw.common import formatInt
|
||||
@@ -50,6 +50,10 @@ class GuiProjectLoad(QDialog):
|
||||
NEW_STATE = 1
|
||||
OPEN_STATE = 2
|
||||
|
||||
C_NAME = 0
|
||||
C_COUNT = 1
|
||||
C_TIME = 2
|
||||
|
||||
def __init__(self, theParent):
|
||||
QDialog.__init__(self, theParent)
|
||||
|
||||
@@ -62,7 +66,8 @@ class GuiProjectLoad(QDialog):
|
||||
self.openPath = None
|
||||
|
||||
sPx = self.mainConf.pxInt(16)
|
||||
iPx = self.mainConf.pxInt(96)
|
||||
nPx = self.mainConf.pxInt(96)
|
||||
iPx = self.theTheme.baseIconSize
|
||||
|
||||
self.outerBox = QVBoxLayout()
|
||||
self.innerBox = QHBoxLayout()
|
||||
@@ -74,13 +79,12 @@ class GuiProjectLoad(QDialog):
|
||||
self.setMinimumHeight(self.mainConf.pxInt(400))
|
||||
self.setModal(True)
|
||||
|
||||
self.guiDeco = self.theTheme.loadDecoration("nwicon", (iPx, iPx))
|
||||
self.guiDeco = self.theTheme.loadDecoration("nwicon", (nPx, nPx))
|
||||
self.innerBox.addWidget(self.guiDeco, 0, Qt.AlignTop)
|
||||
|
||||
self.projectForm = QGridLayout()
|
||||
self.projectForm.setContentsMargins(0, 0, 0, 0)
|
||||
|
||||
iPx = self.theTheme.textIconSize
|
||||
self.listBox = QTreeWidget()
|
||||
self.listBox.setSelectionMode(QAbstractItemView.SingleSelection)
|
||||
self.listBox.setDragDropMode(QAbstractItemView.NoDragDrop)
|
||||
@@ -92,8 +96,8 @@ class GuiProjectLoad(QDialog):
|
||||
self.listBox.setIconSize(QSize(iPx, iPx))
|
||||
|
||||
treeHead = self.listBox.headerItem()
|
||||
treeHead.setTextAlignment(1, Qt.AlignRight)
|
||||
treeHead.setTextAlignment(2, Qt.AlignRight)
|
||||
treeHead.setTextAlignment(self.C_COUNT, Qt.AlignRight)
|
||||
treeHead.setTextAlignment(self.C_TIME, Qt.AlignRight)
|
||||
|
||||
self.lblRecent = QLabel("<b>Recently Opened Projects</b>")
|
||||
self.lblPath = QLabel("<b>Path</b>")
|
||||
@@ -150,7 +154,7 @@ class GuiProjectLoad(QDialog):
|
||||
self._saveDialogState()
|
||||
selItems = self.listBox.selectedItems()
|
||||
if selItems:
|
||||
self.openPath = selItems[0].data(0, Qt.UserRole)
|
||||
self.openPath = selItems[0].data(self.C_NAME, Qt.UserRole)
|
||||
self.openState = self.OPEN_STATE
|
||||
self.accept()
|
||||
else:
|
||||
@@ -163,7 +167,7 @@ class GuiProjectLoad(QDialog):
|
||||
"""
|
||||
selList = self.listBox.selectedItems()
|
||||
if selList:
|
||||
self.selPath.setText(selList[0].data(0, Qt.UserRole))
|
||||
self.selPath.setText(selList[0].data(self.C_NAME, Qt.UserRole))
|
||||
return
|
||||
|
||||
def _doBrowse(self):
|
||||
@@ -210,8 +214,23 @@ class GuiProjectLoad(QDialog):
|
||||
"""
|
||||
selList = self.listBox.selectedItems()
|
||||
if selList:
|
||||
self.mainConf.removeFromRecentCache(selList[0].text(3))
|
||||
self._populateList()
|
||||
doRemove = False
|
||||
if self.mainConf.showGUI:
|
||||
msgBox = QMessageBox()
|
||||
msgRes = msgBox.question(
|
||||
self, "Remove Entry",
|
||||
"Remove the selected entry from the recent projects list?"
|
||||
)
|
||||
doRemove = (msgRes == QMessageBox.Yes)
|
||||
else:
|
||||
doRemove = True
|
||||
|
||||
if doRemove:
|
||||
self.mainConf.removeFromRecentCache(
|
||||
selList[0].data(self.C_NAME, Qt.UserRole)
|
||||
)
|
||||
self._populateList()
|
||||
|
||||
return
|
||||
|
||||
##
|
||||
@@ -221,9 +240,10 @@ class GuiProjectLoad(QDialog):
|
||||
def _saveDialogState(self):
|
||||
"""Save the changes made to the dialog.
|
||||
"""
|
||||
colWidths = [50]*3
|
||||
for i in range(3):
|
||||
colWidths[i] = self.listBox.columnWidth(i)
|
||||
colWidths = [0, 0, 0]
|
||||
colWidths[self.C_NAME] = self.listBox.columnWidth(self.C_NAME)
|
||||
colWidths[self.C_COUNT] = self.listBox.columnWidth(self.C_COUNT)
|
||||
colWidths[self.C_TIME] = self.listBox.columnWidth(self.C_TIME)
|
||||
self.mainConf.setProjColWidths(colWidths)
|
||||
return
|
||||
|
||||
@@ -251,22 +271,24 @@ class GuiProjectLoad(QDialog):
|
||||
hasSelection = False
|
||||
for timeStamp in sorted(listOrder, reverse=True):
|
||||
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.setTextAlignment(0, Qt.AlignLeft | Qt.AlignVCenter)
|
||||
newItem.setTextAlignment(1, Qt.AlignRight | Qt.AlignVCenter)
|
||||
newItem.setTextAlignment(2, Qt.AlignRight | Qt.AlignVCenter)
|
||||
newItem.setIcon(self.C_NAME, self.theParent.theTheme.getIcon("proj_nwx"))
|
||||
newItem.setText(self.C_NAME, listData[timeStamp][0])
|
||||
newItem.setData(self.C_NAME, Qt.UserRole, listData[timeStamp][2])
|
||||
newItem.setText(self.C_COUNT, formatInt(listData[timeStamp][1]))
|
||||
newItem.setText(self.C_TIME, datetime.fromtimestamp(timeStamp).strftime("%x %X"))
|
||||
newItem.setTextAlignment(self.C_NAME, Qt.AlignLeft | Qt.AlignVCenter)
|
||||
newItem.setTextAlignment(self.C_COUNT, Qt.AlignRight | Qt.AlignVCenter)
|
||||
newItem.setTextAlignment(self.C_TIME, Qt.AlignRight | Qt.AlignVCenter)
|
||||
self.listBox.addTopLevelItem(newItem)
|
||||
if not hasSelection:
|
||||
newItem.setSelected(True)
|
||||
hasSelection = True
|
||||
|
||||
projColWidth = self.mainConf.getProjColWidths()
|
||||
for i in range(3):
|
||||
self.listBox.setColumnWidth(i, projColWidth[i])
|
||||
if len(projColWidth) == 3:
|
||||
self.listBox.setColumnWidth(self.C_NAME, projColWidth[self.C_NAME])
|
||||
self.listBox.setColumnWidth(self.C_COUNT, projColWidth[self.C_COUNT])
|
||||
self.listBox.setColumnWidth(self.C_TIME, projColWidth[self.C_TIME])
|
||||
|
||||
return
|
||||
|
||||
|
||||
@@ -282,7 +282,7 @@ class GuiProjectEditStatus(QWidget):
|
||||
self.colChanged = False
|
||||
self.selColour = None
|
||||
|
||||
self.iPx = self.theTheme.textIconSize
|
||||
self.iPx = self.theTheme.baseIconSize
|
||||
|
||||
self.outerBox = QVBoxLayout()
|
||||
self.mainBox = QHBoxLayout()
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ class GuiMainStatus(QStatusBar):
|
||||
colTrue = QColor(*self.theTheme.statUnsaved)
|
||||
colFalse = QColor(*self.theTheme.statSaved)
|
||||
|
||||
iPx = self.theTheme.textIconSize
|
||||
iPx = self.theTheme.baseIconSize
|
||||
|
||||
# Permanent Widgets
|
||||
# =================
|
||||
|
||||
@@ -143,7 +143,6 @@ class GuiTheme:
|
||||
self.fontPointSize = self.guiFont.pointSizeF()
|
||||
self.fontPixelSize = int(round(qMetric.height()))
|
||||
self.baseIconSize = int(round(qMetric.ascent()))
|
||||
self.textIconSize = int(round(qMetric.ascent() + qMetric.leading()))
|
||||
self.textNHeight = qMetric.boundingRect("N").height()
|
||||
self.textNWidth = qMetric.boundingRect("N").width()
|
||||
|
||||
@@ -151,7 +150,6 @@ class GuiTheme:
|
||||
logger.verbose("GUI Font Point Size: %.2f" % self.fontPointSize)
|
||||
logger.verbose("GUI Font Pixel Size: %d" % self.fontPixelSize)
|
||||
logger.verbose("GUI Base Icon Size: %d" % self.baseIconSize)
|
||||
logger.verbose("GUI Text Icon Size: %d" % self.textIconSize)
|
||||
logger.verbose("Text 'N' Height: %d" % self.textNHeight)
|
||||
logger.verbose("Text 'N' Width: %d" % self.textNWidth)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user