Improve the manuscript GUIs a bit

This commit is contained in:
Veronica Berglyd Olsen
2023-06-05 00:25:02 +02:00
parent 2f0ac4fe17
commit ee9da2bdf1
4 changed files with 83 additions and 34 deletions
+31 -15
View File
@@ -53,6 +53,8 @@ class GuiManuscriptBuild(QDialog):
independently of the Manuscript Build Tool.
"""
D_KEY = Qt.ItemDataRole.UserRole
def __init__(self, parent: QWidget, mainGui: GuiMain, build: BuildSettings):
super().__init__(parent=parent)
@@ -71,7 +73,7 @@ class GuiManuscriptBuild(QDialog):
self.setMinimumHeight(CONFIG.pxInt(250))
wWin = CONFIG.pxInt(660)
hWin = CONFIG.pxInt(350)
hWin = CONFIG.pxInt(390)
pOptions = self.theProject.options
self.resize(
@@ -88,7 +90,7 @@ class GuiManuscriptBuild(QDialog):
for key, (_, label) in nwLabels.BUILD_FORMATS.items():
item = QListWidgetItem()
item.setText(label)
item.setData(Qt.UserRole, key)
item.setData(self.D_KEY, key)
self.listFormats.addItem(item)
if key == self._build.lastFormat:
current = item
@@ -130,6 +132,18 @@ class GuiManuscriptBuild(QDialog):
# Dialog Controls
# ===============
font = self.font()
font.setBold(True)
font.setUnderline(True)
font.setPointSizeF(1.5*font.pointSizeF())
self.lblMain = QLabel(self._build.name)
self.lblMain.setWordWrap(True)
self.lblMain.setFont(font)
self.spaceWidget = QWidget()
self.spaceWidget.setFixedHeight(CONFIG.pxInt(8))
# Build Path
self.lblPath = QLabel(self.tr("Build Folder"))
self.buildPath = QLineEdit()
@@ -156,11 +170,9 @@ class GuiManuscriptBuild(QDialog):
self.buildProgress = QProgressBar()
# Dialog Buttons
self.btnBuild = QPushButton(self.mainTheme.getIcon("export"), self.tr("&Build"))
self.dlgButtons = QDialogButtonBox(QDialogButtonBox.Close)
self.dlgButtons.addButton(
QPushButton(self.mainTheme.getIcon("export"), self.tr("&Build")),
QDialogButtonBox.ActionRole
)
self.dlgButtons.addButton(self.btnBuild, QDialogButtonBox.ActionRole)
self.dlgButtons.clicked.connect(self._dialogButtonClicked)
# Assemble GUI
@@ -178,14 +190,16 @@ class GuiManuscriptBuild(QDialog):
])
self.outerBox = QGridLayout()
self.outerBox.addWidget(self.mainSplit, 0, 0, 1, 2)
self.outerBox.addWidget(self.lblPath, 1, 0, 1, 1)
self.outerBox.addLayout(self.pathBox, 1, 1, 1, 1)
self.outerBox.addWidget(self.lblName, 2, 0, 1, 1)
self.outerBox.addLayout(self.nameBox, 2, 1, 1, 1)
self.outerBox.addWidget(self.lblProgress, 3, 0, 1, 1)
self.outerBox.addWidget(self.buildProgress, 3, 1, 1, 1)
self.outerBox.addWidget(self.dlgButtons, 4, 0, 1, 2)
self.outerBox.addWidget(self.lblMain, 0, 0, 1, 2, Qt.AlignCenter)
self.outerBox.addWidget(self.spaceWidget, 1, 0, 1, 2)
self.outerBox.addWidget(self.mainSplit, 2, 0, 1, 2)
self.outerBox.addWidget(self.lblPath, 3, 0, 1, 1)
self.outerBox.addLayout(self.pathBox, 3, 1, 1, 1)
self.outerBox.addWidget(self.lblName, 4, 0, 1, 1)
self.outerBox.addLayout(self.nameBox, 4, 1, 1, 1)
self.outerBox.addWidget(self.lblProgress, 5, 0, 1, 1)
self.outerBox.addWidget(self.buildProgress, 5, 1, 1, 1)
self.outerBox.addWidget(self.dlgButtons, 6, 0, 1, 2)
self.setLayout(self.outerBox)
@@ -194,6 +208,8 @@ class GuiManuscriptBuild(QDialog):
else:
self._doResetBuildName()
self.btnBuild.setFocus()
logger.debug("Ready: GuiManuscriptBuild")
return
@@ -267,7 +283,7 @@ class GuiManuscriptBuild(QDialog):
"""Get the currently selected format."""
items = self.listFormats.selectedItems()
if items and isinstance(items[0], QListWidgetItem):
return str(items[0].data(Qt.UserRole))
return str(items[0].data(self.D_KEY))
return None
def _saveSettings(self):
+50 -17
View File
@@ -31,10 +31,10 @@ from typing import TYPE_CHECKING
from datetime import datetime
from PyQt5.QtGui import QColor, QCursor, QFont, QPalette, QResizeEvent
from PyQt5.QtCore import QTimer, Qt, pyqtSlot
from PyQt5.QtCore import QSize, QTimer, Qt, pyqtSlot
from PyQt5.QtWidgets import (
QDialog, QHBoxLayout, QLabel, QListWidget, QListWidgetItem, QMenu,
QProgressBar, QPushButton, QSplitter, QTextBrowser, QVBoxLayout, QWidget,
QProgressBar, QPushButton, QSplitter, QTextBrowser, QToolButton, QVBoxLayout, QWidget,
qApp
)
@@ -80,6 +80,7 @@ class GuiManuscript(QDialog):
self.setMinimumWidth(CONFIG.pxInt(600))
self.setMinimumHeight(CONFIG.pxInt(500))
iPx = self.mainTheme.baseIconSize
wWin = CONFIG.pxInt(900)
hWin = CONFIG.pxInt(600)
@@ -92,15 +93,52 @@ class GuiManuscript(QDialog):
# Build Controls
# ==============
qPalette = self.palette()
qPalette.setBrush(QPalette.Window, qPalette.base())
self.setPalette(qPalette)
fadeCol = qPalette.text().color()
buttonStyle = (
"QToolButton {{padding: {0}px; border: none; background: transparent;}} "
"QToolButton:hover {{border: none; background: rgba({1},{2},{3},0.2);}}"
).format(CONFIG.pxInt(2), fadeCol.red(), fadeCol.green(), fadeCol.blue())
self.tbAdd = QToolButton(self)
self.tbAdd.setIcon(self.mainTheme.getIcon("add"))
self.tbAdd.setIconSize(QSize(iPx, iPx))
self.tbAdd.setToolTip(self.tr("Add New Build"))
self.tbAdd.setStyleSheet(buttonStyle)
self.tbAdd.clicked.connect(self._createNewBuild)
self.tbDel = QToolButton(self)
self.tbDel.setIcon(self.mainTheme.getIcon("remove"))
self.tbDel.setIconSize(QSize(iPx, iPx))
self.tbDel.setToolTip(self.tr("Remove Selected Build"))
self.tbDel.setStyleSheet(buttonStyle)
self.tbEdit = QToolButton(self)
self.tbEdit.setIcon(self.mainTheme.getIcon("edit"))
self.tbEdit.setIconSize(QSize(iPx, iPx))
self.tbEdit.setToolTip(self.tr("Edit Selected Build"))
self.tbEdit.setStyleSheet(buttonStyle)
self.tbEdit.clicked.connect(self._editSelectedBuild)
self.lblBuilds = QLabel("<b>{0}</b>".format(self.tr("Builds")))
self.buildList = QListWidget()
self.btnNew = QPushButton(self.tr("New"))
self.btnNew.clicked.connect(self._createNewBuild)
self.tbMore = QToolButton(self)
self.tbMore.setIcon(self.mainTheme.getIcon("menu"))
self.tbMore.setIconSize(QSize(iPx, iPx))
self.tbMore.setStyleSheet(buttonStyle)
self.btnEdit = QPushButton(self.tr("Edit"))
self.btnEdit.clicked.connect(self._editSelectedBuild)
self.btnDelete = QPushButton(self.tr("Delete"))
self.listToolBox = QHBoxLayout()
self.listToolBox.addWidget(self.lblBuilds)
self.listToolBox.addStretch(1)
self.listToolBox.addWidget(self.tbAdd)
self.listToolBox.addWidget(self.tbDel)
self.listToolBox.addWidget(self.tbEdit)
self.listToolBox.addWidget(self.tbMore)
self.listToolBox.setSpacing(0)
# Process Controls
# ================
@@ -123,22 +161,17 @@ class GuiManuscript(QDialog):
self.btnClose = QPushButton(self.tr("Close"))
self.btnClose.clicked.connect(self._doClose)
# Assemble GUI
# ============
self.buildBox = QHBoxLayout()
self.buildBox.addWidget(self.btnNew)
self.buildBox.addWidget(self.btnEdit)
self.buildBox.addWidget(self.btnDelete)
self.processBox = QHBoxLayout()
self.processBox.addWidget(self.btnBuild)
self.processBox.addWidget(self.btnPrint)
self.processBox.addWidget(self.btnClose)
# Assemble GUI
# ============
self.controlBox = QVBoxLayout()
self.controlBox.addLayout(self.listToolBox)
self.controlBox.addWidget(self.buildList)
self.controlBox.addLayout(self.buildBox)
self.controlBox.addWidget(self.buildProgress)
self.controlBox.addWidget(self.btnPreview)
self.controlBox.addLayout(self.processBox)