Improve how tool buttons are generated

This commit is contained in:
Veronica Berglyd Olsen
2024-04-01 20:21:34 +02:00
parent c3467d89c2
commit 24e45fb661
36 changed files with 278 additions and 285 deletions
+11 -6
View File
@@ -28,7 +28,7 @@ import logging
from pathlib import Path
from PyQt5.QtGui import QCloseEvent
from PyQt5.QtCore import QSize, QTimer, Qt, pyqtSlot
from PyQt5.QtCore import QTimer, Qt, pyqtSlot
from PyQt5.QtWidgets import (
QAbstractButton, QAbstractItemView, QDialog, QDialogButtonBox, QFileDialog,
QGridLayout, QHBoxLayout, QLabel, QLineEdit, QListWidget, QListWidgetItem,
@@ -42,6 +42,7 @@ from novelwriter.core.buildsettings import BuildSettings
from novelwriter.core.docbuild import NWBuildDocument
from novelwriter.core.item import NWItem
from novelwriter.enum import nwBuildFmt
from novelwriter.extensions.modified import NIconToolButton
from novelwriter.extensions.simpleprogress import NProgressSimple
from novelwriter.types import QtAlignCenter
@@ -70,7 +71,8 @@ class GuiManuscriptBuild(QDialog):
self.setMinimumWidth(CONFIG.pxInt(500))
self.setMinimumHeight(CONFIG.pxInt(300))
iPx = SHARED.theme.baseIconSize
iSz = SHARED.theme.baseIconSize
bSz = SHARED.theme.buttonIconSize
sp4 = CONFIG.pxInt(4)
sp8 = CONFIG.pxInt(8)
sp16 = CONFIG.pxInt(16)
@@ -88,7 +90,7 @@ class GuiManuscriptBuild(QDialog):
self.lblFormat = QLabel(self.tr("Output Format"))
self.listFormats = QListWidget()
self.listFormats.setIconSize(QSize(iPx, iPx))
self.listFormats.setIconSize(iSz)
current = None
for key in nwBuildFmt:
item = QListWidgetItem()
@@ -115,7 +117,7 @@ class GuiManuscriptBuild(QDialog):
self.lblContent = QLabel(self.tr("Table of Contents"))
self.listContent = QListWidget(self)
self.listContent.setIconSize(QSize(iPx, iPx))
self.listContent.setIconSize(iSz)
self.listContent.setSelectionMode(QAbstractItemView.SelectionMode.NoSelection)
self.contentBox = QVBoxLayout()
@@ -142,7 +144,7 @@ class GuiManuscriptBuild(QDialog):
# Build Path
self.lblPath = QLabel(self.tr("Path"))
self.buildPath = QLineEdit(self)
self.btnBrowse = QPushButton(SHARED.theme.getIcon("browse"), "")
self.btnBrowse = NIconToolButton(self, iSz, "browse")
self.pathBox = QHBoxLayout()
self.pathBox.addWidget(self.buildPath)
@@ -152,7 +154,7 @@ class GuiManuscriptBuild(QDialog):
# Build Name
self.lblName = QLabel(self.tr("File Name"))
self.buildName = QLineEdit(self)
self.btnReset = QPushButton(SHARED.theme.getIcon("revert"), "")
self.btnReset = NIconToolButton(self, iSz, "revert")
self.btnReset.setToolTip(self.tr("Reset file name to default"))
self.nameBox = QHBoxLayout()
@@ -178,7 +180,10 @@ class GuiManuscriptBuild(QDialog):
# Dialog Buttons
self.btnOpen = QPushButton(SHARED.theme.getIcon("browse"), self.tr("Open Folder"))
self.btnOpen.setIconSize(bSz)
self.btnBuild = QPushButton(SHARED.theme.getIcon("export"), self.tr("&Build"))
self.btnBuild.setIconSize(bSz)
self.dlgButtons = QDialogButtonBox(QDialogButtonBox.StandardButton.Close)
self.dlgButtons.addButton(self.btnOpen, QDialogButtonBox.ButtonRole.ActionRole)
self.dlgButtons.addButton(self.btnBuild, QDialogButtonBox.ButtonRole.ActionRole)