Clean up item details panel
This commit is contained in:
@@ -25,25 +25,22 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
from PyQt5.QtCore import pyqtSlot
|
||||||
|
|
||||||
from PyQt5.QtGui import QFont
|
|
||||||
from PyQt5.QtCore import Qt, pyqtSlot
|
|
||||||
from PyQt5.QtWidgets import QWidget, QGridLayout, QLabel
|
from PyQt5.QtWidgets import QWidget, QGridLayout, QLabel
|
||||||
|
|
||||||
from novelwriter import CONFIG, SHARED
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.constants import trConst, nwLabels
|
from novelwriter.constants import trConst, nwLabels
|
||||||
|
from novelwriter.types import (
|
||||||
if TYPE_CHECKING: # pragma: no cover
|
QtAlignLeft, QtAlignLeftBase, QtAlignRight, QtAlignRightBase, QtAlignRightMiddle
|
||||||
from novelwriter.guimain import GuiMain
|
)
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class GuiItemDetails(QWidget):
|
class GuiItemDetails(QWidget):
|
||||||
|
|
||||||
def __init__(self, mainGui: GuiMain) -> None:
|
def __init__(self, parent: QWidget) -> None:
|
||||||
super().__init__(parent=mainGui)
|
super().__init__(parent=parent)
|
||||||
|
|
||||||
logger.debug("Create: GuiItemDetails")
|
logger.debug("Create: GuiItemDetails")
|
||||||
|
|
||||||
@@ -56,89 +53,89 @@ class GuiItemDetails(QWidget):
|
|||||||
mPx = CONFIG.pxInt(6)
|
mPx = CONFIG.pxInt(6)
|
||||||
fPt = SHARED.theme.fontPointSize
|
fPt = SHARED.theme.fontPointSize
|
||||||
|
|
||||||
fntLabel = QFont()
|
fntLabel = self.font()
|
||||||
fntLabel.setBold(True)
|
fntLabel.setBold(True)
|
||||||
fntLabel.setPointSizeF(0.9*fPt)
|
fntLabel.setPointSizeF(0.9*fPt)
|
||||||
|
|
||||||
fntValue = QFont()
|
fntValue = self.font()
|
||||||
fntValue.setPointSizeF(0.9*fPt)
|
fntValue.setPointSizeF(0.9*fPt)
|
||||||
|
|
||||||
# Label
|
# Label
|
||||||
self.labelName = QLabel(self.tr("Label"))
|
self.labelName = QLabel(self.tr("Label"), self)
|
||||||
self.labelName.setFont(fntLabel)
|
self.labelName.setFont(fntLabel)
|
||||||
self.labelName.setAlignment(Qt.AlignLeft | Qt.AlignBaseline)
|
self.labelName.setAlignment(QtAlignLeftBase)
|
||||||
|
|
||||||
self.labelIcon = QLabel("")
|
self.labelIcon = QLabel("", self)
|
||||||
self.labelIcon.setAlignment(Qt.AlignRight | Qt.AlignBaseline)
|
self.labelIcon.setAlignment(QtAlignRightBase)
|
||||||
|
|
||||||
self.labelData = QLabel("")
|
self.labelData = QLabel("", self)
|
||||||
self.labelData.setFont(fntValue)
|
self.labelData.setFont(fntValue)
|
||||||
self.labelData.setAlignment(Qt.AlignLeft | Qt.AlignBaseline)
|
self.labelData.setAlignment(QtAlignLeftBase)
|
||||||
self.labelData.setWordWrap(True)
|
self.labelData.setWordWrap(True)
|
||||||
|
|
||||||
# Status
|
# Status
|
||||||
self.statusName = QLabel(self.tr("Status"))
|
self.statusName = QLabel(self.tr("Status"), self)
|
||||||
self.statusName.setFont(fntLabel)
|
self.statusName.setFont(fntLabel)
|
||||||
self.statusName.setAlignment(Qt.AlignLeft)
|
self.statusName.setAlignment(QtAlignLeft)
|
||||||
|
|
||||||
self.statusIcon = QLabel("")
|
self.statusIcon = QLabel("", self)
|
||||||
self.statusIcon.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
|
self.statusIcon.setAlignment(QtAlignRightMiddle)
|
||||||
|
|
||||||
self.statusData = QLabel("")
|
self.statusData = QLabel("", self)
|
||||||
self.statusData.setFont(fntValue)
|
self.statusData.setFont(fntValue)
|
||||||
self.statusData.setAlignment(Qt.AlignLeft)
|
self.statusData.setAlignment(QtAlignLeft)
|
||||||
|
|
||||||
# Class
|
# Class
|
||||||
self.className = QLabel(self.tr("Class"))
|
self.className = QLabel(self.tr("Class"), self)
|
||||||
self.className.setFont(fntLabel)
|
self.className.setFont(fntLabel)
|
||||||
self.className.setAlignment(Qt.AlignLeft)
|
self.className.setAlignment(QtAlignLeft)
|
||||||
|
|
||||||
self.classIcon = QLabel("")
|
self.classIcon = QLabel("", self)
|
||||||
self.classIcon.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
|
self.classIcon.setAlignment(QtAlignRightMiddle)
|
||||||
|
|
||||||
self.classData = QLabel("")
|
self.classData = QLabel("", self)
|
||||||
self.classData.setFont(fntValue)
|
self.classData.setFont(fntValue)
|
||||||
self.classData.setAlignment(Qt.AlignLeft)
|
self.classData.setAlignment(QtAlignLeft)
|
||||||
|
|
||||||
# Layout
|
# Layout
|
||||||
self.usageName = QLabel(self.tr("Usage"))
|
self.usageName = QLabel(self.tr("Usage"), self)
|
||||||
self.usageName.setFont(fntLabel)
|
self.usageName.setFont(fntLabel)
|
||||||
self.usageName.setAlignment(Qt.AlignLeft)
|
self.usageName.setAlignment(QtAlignLeft)
|
||||||
|
|
||||||
self.usageIcon = QLabel("")
|
self.usageIcon = QLabel("", self)
|
||||||
self.usageIcon.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
|
self.usageIcon.setAlignment(QtAlignRightMiddle)
|
||||||
|
|
||||||
self.usageData = QLabel("")
|
self.usageData = QLabel("", self)
|
||||||
self.usageData.setFont(fntValue)
|
self.usageData.setFont(fntValue)
|
||||||
self.usageData.setAlignment(Qt.AlignLeft)
|
self.usageData.setAlignment(QtAlignLeft)
|
||||||
self.usageData.setWordWrap(True)
|
self.usageData.setWordWrap(True)
|
||||||
|
|
||||||
# Character Count
|
# Character Count
|
||||||
self.cCountName = QLabel(" "+self.tr("Characters"))
|
self.cCountName = QLabel(" "+self.tr("Characters"), self)
|
||||||
self.cCountName.setFont(fntLabel)
|
self.cCountName.setFont(fntLabel)
|
||||||
self.cCountName.setAlignment(Qt.AlignRight)
|
self.cCountName.setAlignment(QtAlignRight)
|
||||||
|
|
||||||
self.cCountData = QLabel("")
|
self.cCountData = QLabel("")
|
||||||
self.cCountData.setFont(fntValue)
|
self.cCountData.setFont(fntValue)
|
||||||
self.cCountData.setAlignment(Qt.AlignRight)
|
self.cCountData.setAlignment(QtAlignRight)
|
||||||
|
|
||||||
# Word Count
|
# Word Count
|
||||||
self.wCountName = QLabel(" "+self.tr("Words"))
|
self.wCountName = QLabel(" "+self.tr("Words"))
|
||||||
self.wCountName.setFont(fntLabel)
|
self.wCountName.setFont(fntLabel)
|
||||||
self.wCountName.setAlignment(Qt.AlignRight)
|
self.wCountName.setAlignment(QtAlignRight)
|
||||||
|
|
||||||
self.wCountData = QLabel("")
|
self.wCountData = QLabel("")
|
||||||
self.wCountData.setFont(fntValue)
|
self.wCountData.setFont(fntValue)
|
||||||
self.wCountData.setAlignment(Qt.AlignRight)
|
self.wCountData.setAlignment(QtAlignRight)
|
||||||
|
|
||||||
# Paragraph Count
|
# Paragraph Count
|
||||||
self.pCountName = QLabel(" "+self.tr("Paragraphs"))
|
self.pCountName = QLabel(" "+self.tr("Paragraphs"))
|
||||||
self.pCountName.setFont(fntLabel)
|
self.pCountName.setFont(fntLabel)
|
||||||
self.pCountName.setAlignment(Qt.AlignRight)
|
self.pCountName.setAlignment(QtAlignRight)
|
||||||
|
|
||||||
self.pCountData = QLabel("")
|
self.pCountData = QLabel("")
|
||||||
self.pCountData.setFont(fntValue)
|
self.pCountData.setFont(fntValue)
|
||||||
self.pCountData.setAlignment(Qt.AlignRight)
|
self.pCountData.setAlignment(QtAlignRight)
|
||||||
|
|
||||||
# Assemble
|
# Assemble
|
||||||
self.mainBox = QGridLayout(self)
|
self.mainBox = QGridLayout(self)
|
||||||
@@ -234,7 +231,7 @@ class GuiItemDetails(QWidget):
|
|||||||
return
|
return
|
||||||
|
|
||||||
self._handle = tHandle
|
self._handle = tHandle
|
||||||
iPx = int(round(0.8*SHARED.theme.baseIconSize))
|
iPx = int(round(0.9*SHARED.theme.baseIconSize))
|
||||||
|
|
||||||
# Label
|
# Label
|
||||||
# =====
|
# =====
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
"""
|
||||||
|
novelWriter – Typings
|
||||||
|
=====================
|
||||||
|
|
||||||
|
File History:
|
||||||
|
Created: 2024-04-01 [2.4rc1]
|
||||||
|
|
||||||
|
This file is a part of novelWriter
|
||||||
|
Copyright 2018–2024, Veronica Berglyd Olsen
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
"""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from PyQt5.QtCore import Qt
|
||||||
|
|
||||||
|
QtAlignLeft = Qt.AlignmentFlag.AlignLeft
|
||||||
|
QtAlignRight = Qt.AlignmentFlag.AlignRight
|
||||||
|
QtAlignLeftBase = Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignBaseline
|
||||||
|
QtAlignRightBase = Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignBaseline
|
||||||
|
QtAlignRightMiddle = Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter
|
||||||
Reference in New Issue
Block a user