Fixed and imrpoved margin calculations on GUI elements
This commit is contained in:
@@ -390,7 +390,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
theFormat.setBackground(QBrush(fmtCol, Qt.SolidPattern))
|
||||
|
||||
if fmtSize is not None:
|
||||
theFormat.setFontPointSize(round(fmtSize*self.mainConf.textSize))
|
||||
theFormat.setFontPointSize(int(round(fmtSize*self.mainConf.textSize)))
|
||||
|
||||
return theFormat
|
||||
|
||||
|
||||
+36
-24
@@ -49,24 +49,22 @@ class GuiItemDetails(QWidget):
|
||||
self.theTheme = theParent.theTheme
|
||||
self.theHandle = None
|
||||
|
||||
self.mainBox = QGridLayout(self)
|
||||
self.mainBox.setVerticalSpacing(1)
|
||||
self.mainBox.setHorizontalSpacing(6)
|
||||
self.setLayout(self.mainBox)
|
||||
# Sizes
|
||||
hSp = self.mainConf.pxInt(6)
|
||||
vSp = self.mainConf.pxInt(1)
|
||||
mPx = self.mainConf.pxInt(6)
|
||||
iPx = self.theTheme.baseIconSize
|
||||
fPt = self.theTheme.fontPointSize
|
||||
|
||||
self.pS = 0.9*self.theTheme.fontPointSize
|
||||
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))
|
||||
self.expCheck = self.theTheme.getPixmap("check", (iPx, iPx))
|
||||
self.expCross = self.theTheme.getPixmap("cross", (iPx, iPx))
|
||||
|
||||
self.fntLabel = QFont()
|
||||
self.fntLabel.setBold(True)
|
||||
self.fntLabel.setPointSizeF(self.pS)
|
||||
self.fntLabel.setPointSizeF(0.9*fPt)
|
||||
|
||||
self.fntValue = QFont()
|
||||
self.fntValue.setPointSizeF(self.pS)
|
||||
self.fntValue.setPointSizeF(0.9*fPt)
|
||||
|
||||
# Label
|
||||
self.labelName = QLabel("Label")
|
||||
@@ -147,6 +145,7 @@ class GuiItemDetails(QWidget):
|
||||
self.pCountData.setAlignment(Qt.AlignRight)
|
||||
|
||||
# Assemble
|
||||
self.mainBox = QGridLayout(self)
|
||||
self.mainBox.addWidget(self.labelName, 0, 0, 1, 1)
|
||||
self.mainBox.addWidget(self.labelFlag, 0, 1, 1, 1)
|
||||
self.mainBox.addWidget(self.labelData, 0, 2, 1, 3)
|
||||
@@ -175,6 +174,12 @@ class GuiItemDetails(QWidget):
|
||||
self.mainBox.setColumnStretch(3, 0)
|
||||
self.mainBox.setColumnStretch(4, 0)
|
||||
|
||||
self.mainBox.setHorizontalSpacing(hSp)
|
||||
self.mainBox.setVerticalSpacing(vSp)
|
||||
self.mainBox.setContentsMargins(mPx, mPx, mPx, mPx)
|
||||
|
||||
self.setLayout(self.mainBox)
|
||||
|
||||
# Make sure the columns for flags and counts don't resize too often
|
||||
flagWidth = self.theTheme.getTextWidth("Mm", self.fntValue)
|
||||
countWidth = self.theTheme.getTextWidth("99,999", self.fntValue)
|
||||
@@ -193,26 +198,30 @@ class GuiItemDetails(QWidget):
|
||||
"""Clear all the data values.
|
||||
"""
|
||||
self.labelFlag.setPixmap(QPixmap(1, 1))
|
||||
self.labelData.setText("")
|
||||
self.statusFlag.setPixmap(QPixmap(1, 1))
|
||||
self.statusData.setText("")
|
||||
self.classFlag.setText("")
|
||||
self.classData.setText("")
|
||||
self.layoutFlag.setText("")
|
||||
self.layoutData.setText("")
|
||||
|
||||
self.labelData.setText("–")
|
||||
self.statusData.setText("–")
|
||||
self.classData.setText("–")
|
||||
self.layoutData.setText("–")
|
||||
|
||||
self.cCountData.setText("–")
|
||||
self.wCountData.setText("–")
|
||||
self.pCountData.setText("–")
|
||||
|
||||
return
|
||||
|
||||
def updateCounts(self, tHandle, cC, wC, pC):
|
||||
"""Just update the counts if the handle is the same as the one
|
||||
we're already showing.
|
||||
"""Update the counts if the handle is the same as the one we're
|
||||
already showing. Otherwise, do nothing.
|
||||
"""
|
||||
if tHandle == self.theHandle:
|
||||
self.cCountData.setText(f"{cC:n}")
|
||||
self.wCountData.setText(f"{wC:n}")
|
||||
self.pCountData.setText(f"{pC:n}")
|
||||
|
||||
return
|
||||
|
||||
def updateViewBox(self, tHandle):
|
||||
@@ -229,13 +238,13 @@ class GuiItemDetails(QWidget):
|
||||
if len(theLabel) > 100:
|
||||
theLabel = theLabel[:96].rstrip()+" ..."
|
||||
|
||||
iStatus = nwItem.itemStatus
|
||||
itStatus = nwItem.itemStatus
|
||||
if nwItem.itemClass == nwItemClass.NOVEL:
|
||||
iStatus = self.theProject.statusItems.checkEntry(iStatus) # Make sure it's valid
|
||||
flagIcon = self.theParent.statusIcons[iStatus]
|
||||
itStatus = self.theProject.statusItems.checkEntry(itStatus) # Make sure it's valid
|
||||
flagIcon = self.theParent.statusIcons[itStatus]
|
||||
else:
|
||||
iStatus = self.theProject.importItems.checkEntry(iStatus) # Make sure it's valid
|
||||
flagIcon = self.theParent.importIcons[iStatus]
|
||||
itStatus = self.theProject.importItems.checkEntry(itStatus) # Make sure it's valid
|
||||
flagIcon = self.theParent.importIcons[itStatus]
|
||||
|
||||
if nwItem.itemType == nwItemType.FILE:
|
||||
if nwItem.isExported:
|
||||
@@ -244,8 +253,11 @@ class GuiItemDetails(QWidget):
|
||||
self.labelFlag.setPixmap(self.expCross)
|
||||
else:
|
||||
self.labelFlag.setPixmap(QPixmap(1, 1))
|
||||
self.statusFlag.setPixmap(flagIcon.pixmap(self.sPx, self.sPx))
|
||||
|
||||
iPx = int(round(0.8*self.theTheme.baseIconSize))
|
||||
self.statusFlag.setPixmap(flagIcon.pixmap(iPx, iPx))
|
||||
self.classFlag.setText(nwLabels.CLASS_FLAG[nwItem.itemClass])
|
||||
|
||||
if nwItem.itemLayout == nwItemLayout.NO_LAYOUT:
|
||||
self.layoutFlag.setText("-")
|
||||
else:
|
||||
|
||||
@@ -57,7 +57,7 @@ class GuiProjectDetails(PagedDialog):
|
||||
self.setWindowTitle("Project Details")
|
||||
|
||||
wW = self.mainConf.pxInt(600)
|
||||
wH = self.mainConf.pxInt(425)
|
||||
wH = self.mainConf.pxInt(400)
|
||||
|
||||
self.setMinimumWidth(wW)
|
||||
self.setMinimumHeight(wH)
|
||||
@@ -137,6 +137,7 @@ class GuiProjectDetailsMain(QWidget):
|
||||
self.theIndex = theParent.theIndex
|
||||
|
||||
fPx = self.theTheme.fontPixelSize
|
||||
fPt = self.theTheme.fontPointSize
|
||||
vPx = self.mainConf.pxInt(4)
|
||||
hPx = self.mainConf.pxInt(12)
|
||||
|
||||
@@ -145,7 +146,7 @@ class GuiProjectDetailsMain(QWidget):
|
||||
|
||||
self.bookTitle = QLabel(self.theProject.bookTitle)
|
||||
bookFont = self.bookTitle.font()
|
||||
bookFont.setPixelSize(round(2.2*fPx))
|
||||
bookFont.setPointSizeF(2.2*fPt)
|
||||
bookFont.setWeight(QFont.Bold)
|
||||
self.bookTitle.setFont(bookFont)
|
||||
self.bookTitle.setAlignment(Qt.AlignHCenter)
|
||||
@@ -153,7 +154,7 @@ class GuiProjectDetailsMain(QWidget):
|
||||
|
||||
self.projName = QLabel("Working Title: %s" % self.theProject.projName)
|
||||
workFont = self.projName.font()
|
||||
workFont.setPixelSize(round(0.8*fPx))
|
||||
workFont.setPointSizeF(0.8*fPt)
|
||||
workFont.setItalic(True)
|
||||
self.projName.setFont(workFont)
|
||||
self.projName.setAlignment(Qt.AlignHCenter)
|
||||
@@ -161,7 +162,7 @@ class GuiProjectDetailsMain(QWidget):
|
||||
|
||||
self.bookAuthors = QLabel("By %s" % self.theProject.getAuthors())
|
||||
authFont = self.bookAuthors.font()
|
||||
authFont.setPixelSize(round(1.2*fPx))
|
||||
authFont.setPointSizeF(1.2*fPt)
|
||||
self.bookAuthors.setFont(authFont)
|
||||
self.bookAuthors.setAlignment(Qt.AlignHCenter)
|
||||
self.bookAuthors.setWordWrap(True)
|
||||
@@ -219,12 +220,13 @@ class GuiProjectDetailsMain(QWidget):
|
||||
# ========
|
||||
|
||||
self.outerBox = QVBoxLayout()
|
||||
self.outerBox.addSpacing(fPx)
|
||||
self.outerBox.addWidget(self.bookTitle)
|
||||
self.outerBox.addWidget(self.projName)
|
||||
self.outerBox.addWidget(self.bookAuthors)
|
||||
self.outerBox.addSpacing(round(2.5*fPx))
|
||||
self.outerBox.addSpacing(2*fPx)
|
||||
self.outerBox.addLayout(self.statsGrid)
|
||||
self.outerBox.addSpacing(round(0.8*fPx))
|
||||
self.outerBox.addSpacing(fPx)
|
||||
self.outerBox.addStretch(1)
|
||||
self.outerBox.addLayout(self.projPathBox)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user