Add a basic build settings class, and add the paged sidebar to the mbuild dialog

This commit is contained in:
Veronica Berglyd Olsen
2023-02-21 18:15:04 +01:00
parent 981111d380
commit 9d61432641
2 changed files with 166 additions and 6 deletions
+114
View File
@@ -0,0 +1,114 @@
"""
novelWriter Build Settings Class
==================================
A class to hold build settings for the build tool
File History:
Created: 2023-02-14 [2.1b1]
This file is a part of novelWriter
Copyright 20182023, 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/>.
"""
import logging
from PyQt5.QtCore import QT_TRANSLATE_NOOP
logger = logging.getLogger(__name__)
# The Settings Template
# =====================
# Each entry contains a tuple on the form:
# (type, default, [min value, max value])
SETTINGS_TEMPLATE = {
"headings.fmtTitle": (str, "%title%"),
"headings.fmtChapter": (str, "%title%"),
"headings.fmtUnnumbered": (str, "%title%"),
"headings.fmtScene": (str, "%title%"),
"headings.fmtSection": (str, "%title%"),
"headings.hideScene": (bool, False),
"headings.hideSection": (bool, False),
"format.buildLang": (str, "en_GB"),
"format.textFont": (str, ""),
"format.textSize": (str, ""),
"format.lineHeight": (float, 1.15, 0.75, 3.0),
"format.justifyText": (bool, False),
"format.stripUnicode": (bool, False),
"odt.addColours": (bool, True),
"html.addStyles": (bool, False),
}
FILTER_TEMPLATE = {
"filter.includeSynopsis": (bool, False),
"filter.includeComments": (bool, False),
"filter.includeKeywords": (bool, False),
"filter.includeBody": (bool, True),
}
SETTINGS_LABELS = {
"headings": QT_TRANSLATE_NOOP("Builds", "Headings"),
"headings.fmtTitle": QT_TRANSLATE_NOOP("Builds", "Title Heading"),
"headings.fmtChapter": QT_TRANSLATE_NOOP("Builds", "Chapter Heading"),
"headings.fmtUnnumbered": QT_TRANSLATE_NOOP("Builds", "Unnumbered Chapter"),
"headings.fmtScene": QT_TRANSLATE_NOOP("Builds", "Scene Heading"),
"headings.fmtSection": QT_TRANSLATE_NOOP("Builds", "Section Heading"),
"headings.hideScene": QT_TRANSLATE_NOOP("Builds", "Hide Scene"),
"headings.hideSection": QT_TRANSLATE_NOOP("Builds", "Hide Section"),
"format": QT_TRANSLATE_NOOP("Builds", "Text Format"),
"format.buildLang": QT_TRANSLATE_NOOP("Builds", "Build Language"),
"format.textFont": QT_TRANSLATE_NOOP("Builds", "Font Family"),
"format.textSize": QT_TRANSLATE_NOOP("Builds", "Font Size"),
"format.lineHeight": QT_TRANSLATE_NOOP("Builds", "Line Height"),
"format.justifyText": QT_TRANSLATE_NOOP("Builds", "Justify Text Margins"),
"format.stripUnicode": QT_TRANSLATE_NOOP("Builds", "Replace Unicode Characters"),
"odt": QT_TRANSLATE_NOOP("Builds", "Open Document"),
"odt.addColours": QT_TRANSLATE_NOOP("Builds", "Add Highlight Colours"),
"html": QT_TRANSLATE_NOOP("Builds", "HTML"),
"html.addStyles": QT_TRANSLATE_NOOP("Builds", "Add CSS Styles"),
}
FILTER_LABELS = {
"filter.includeSynopsis": QT_TRANSLATE_NOOP("Builds", "Synopsis"),
"filter.includeComments": QT_TRANSLATE_NOOP("Builds", "Comments"),
"filter.includeKeywords": QT_TRANSLATE_NOOP("Builds", "Keywords"),
"filter.includeBody": QT_TRANSLATE_NOOP("Builds", "Body Text"),
}
class BuildSettings:
def __init__(self):
self._data = {}
self._loadTemplate()
return
##
# Internal Functions
##
def _loadTemplate(self):
"""Populate the data dictionary from the template.
"""
return
# END Class BuildSettings
+52 -6
View File
@@ -4,7 +4,7 @@ novelWriter GUI Build Manuscript
GUI classes for the Manuscript build tool
File History:
Created: 2023-02-13 [2.1-a0]
Created: 2023-02-13 [2.1b1]
This file is a part of novelWriter
Copyright 20182023, Veronica Berglyd Olsen
@@ -24,11 +24,16 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
import novelwriter
from PyQt5.QtWidgets import QDialog, QHBoxLayout, QTabWidget, QWidget
from PyQt5.QtWidgets import (
QAbstractItemView, QDialog, QHBoxLayout, QTabWidget, QTreeWidget,
QWidget
)
from novelwriter.custom import VerticalTabBar
from novelwriter.extensions.pageddialog import NVerticalTabBar
from novelwriter.extensions.pagedsidebar import NPagedSideBar
logger = logging.getLogger(__name__)
@@ -40,16 +45,41 @@ class GuiBuildManuscript(QDialog):
self.mainConf = novelwriter.CONFIG
self.mainGui = mainGui
self.mainTheme = mainGui.mainTheme
self.theProject = mainGui.theProject
self.setWindowTitle(self.tr("Build Manuscript"))
self.setMinimumWidth(self.mainConf.pxInt(700))
self.setMinimumHeight(self.mainConf.pxInt(600))
# Optiuons Area
# =============
# Style
mPx = self.mainConf.pxInt(150)
# tPx = int(self.mainTheme.fontPixelSize * 1.5)
self.optTabBar = VerticalTabBar(self)
# Options SideBar
# ===============
self.optSideBar = NPagedSideBar(self)
self.optSideBar.setMinimumWidth(mPx)
self.optSideBar.setMaximumWidth(mPx)
self.optSideBar.setLabelColor(self.mainTheme.helpText)
self.optSideBar.addLabel(self.tr("Options"))
self.optFilters = self.optSideBar.addButton(self.tr("Filters"))
self.optHeadings = self.optSideBar.addButton(self.tr("Headings"))
self.optFormat = self.optSideBar.addButton(self.tr("Format"))
self.optContent = self.optSideBar.addButton(self.tr("Content"))
self.optSideBar.addSeparator()
self.optSideBar.addLabel(self.tr("Build"))
self.bldHtml = self.optSideBar.addButton(self.tr("HTML"))
self.bldMd = self.optSideBar.addButton(self.tr("Markdown"))
self.bldOdt = self.optSideBar.addButton(self.tr("Open Document"))
# Options Area
# ============
self.optTabBar = NVerticalTabBar(self)
self.optTabBar.setExpanding(False)
self.optTabBox = QTabWidget(self)
@@ -66,6 +96,7 @@ class GuiBuildManuscript(QDialog):
# Assemble
self.outerBox = QHBoxLayout()
self.outerBox.addWidget(self.optSideBar)
self.outerBox.addWidget(self.optTabBox)
self.setLayout(self.outerBox)
@@ -80,6 +111,21 @@ class GuiBuildSelectionTab(QWidget):
def __init__(self, buildMain):
super().__init__(parent=buildMain)
self.optTree = QTreeWidget(self)
self.optTree.setSelectionMode(QAbstractItemView.SingleSelection)
self.optTree.setDragDropMode(QAbstractItemView.NoDragDrop)
self.optTree.setColumnCount(2)
self.optTree.setHeaderLabels([
self.tr("Setting"),
self.tr("Value"),
])
self.optTree.setRootIsDecorated(False)
self.outerBox = QHBoxLayout()
self.outerBox.addWidget(self.optTree)
self.setLayout(self.outerBox)
return
# END Class GuiBuildSelectionTab