Add handling of build settings and build name
This commit is contained in:
@@ -75,7 +75,7 @@ SETTINGS_LABELS = {
|
|||||||
"headings": QT_TRANSLATE_NOOP("Builds", "Headings"),
|
"headings": QT_TRANSLATE_NOOP("Builds", "Headings"),
|
||||||
"headings.fmtTitle": QT_TRANSLATE_NOOP("Builds", "Title Heading"),
|
"headings.fmtTitle": QT_TRANSLATE_NOOP("Builds", "Title Heading"),
|
||||||
"headings.fmtChapter": QT_TRANSLATE_NOOP("Builds", "Chapter Heading"),
|
"headings.fmtChapter": QT_TRANSLATE_NOOP("Builds", "Chapter Heading"),
|
||||||
"headings.fmtUnnumbered": QT_TRANSLATE_NOOP("Builds", "Alt. Chapter Heading"),
|
"headings.fmtUnnumbered": QT_TRANSLATE_NOOP("Builds", "Unnumbered Heading"),
|
||||||
"headings.fmtScene": QT_TRANSLATE_NOOP("Builds", "Scene Heading"),
|
"headings.fmtScene": QT_TRANSLATE_NOOP("Builds", "Scene Heading"),
|
||||||
"headings.fmtSection": QT_TRANSLATE_NOOP("Builds", "Section Heading"),
|
"headings.fmtSection": QT_TRANSLATE_NOOP("Builds", "Section Heading"),
|
||||||
"headings.hideScene": QT_TRANSLATE_NOOP("Builds", "Hide Scene"),
|
"headings.hideScene": QT_TRANSLATE_NOOP("Builds", "Hide Scene"),
|
||||||
@@ -296,6 +296,7 @@ class BuildSettings:
|
|||||||
def pack(self):
|
def pack(self):
|
||||||
"""Pack all content into a JSON compatible dictionary.
|
"""Pack all content into a JSON compatible dictionary.
|
||||||
"""
|
"""
|
||||||
|
logger.debug("Collecting build setting for '%s'", self._name)
|
||||||
return {
|
return {
|
||||||
"name": self._name,
|
"name": self._name,
|
||||||
"uuid": self._uuid,
|
"uuid": self._uuid,
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ General Public License for more details.
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|||||||
@@ -22,9 +22,13 @@ General Public License for more details.
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
from PyQt5.QtCore import pyqtSlot
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QDialog, QGridLayout, QPushButton, QSplitter, QTextBrowser, QVBoxLayout,
|
QDialog, QGridLayout, QPushButton, QSplitter, QTextBrowser, QVBoxLayout,
|
||||||
QWidget, qApp
|
QWidget, qApp
|
||||||
@@ -33,12 +37,15 @@ from PyQt5.QtWidgets import (
|
|||||||
from novelwriter import CONFIG
|
from novelwriter import CONFIG
|
||||||
from novelwriter.tools.manussettings import GuiBuildSettings
|
from novelwriter.tools.manussettings import GuiBuildSettings
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from novelwriter.guimain import GuiMain
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class GuiBuildManuscript(QDialog):
|
class GuiBuildManuscript(QDialog):
|
||||||
|
|
||||||
def __init__(self, mainGui):
|
def __init__(self, mainGui: GuiMain):
|
||||||
super().__init__(parent=mainGui)
|
super().__init__(parent=mainGui)
|
||||||
|
|
||||||
self.mainGui = mainGui
|
self.mainGui = mainGui
|
||||||
@@ -110,6 +117,7 @@ class GuiBuildManuscript(QDialog):
|
|||||||
# Private Slots
|
# Private Slots
|
||||||
##
|
##
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
def _createNewBuild(self):
|
def _createNewBuild(self):
|
||||||
"""Open the build settings dialog for a new build.
|
"""Open the build settings dialog for a new build.
|
||||||
"""
|
"""
|
||||||
@@ -121,9 +129,17 @@ class GuiBuildManuscript(QDialog):
|
|||||||
dlgSettings.raise_()
|
dlgSettings.raise_()
|
||||||
qApp.processEvents()
|
qApp.processEvents()
|
||||||
dlgSettings.loadContent()
|
dlgSettings.loadContent()
|
||||||
|
dlgSettings.newSettingsReady.connect(self._processNewSettings)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@pyqtSlot(dict)
|
||||||
|
def _processNewSettings(self, data: dict):
|
||||||
|
"""
|
||||||
|
"""
|
||||||
|
print(data)
|
||||||
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Internal Functions
|
# Internal Functions
|
||||||
##
|
##
|
||||||
|
|||||||
@@ -29,11 +29,12 @@ import logging
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from PyQt5.QtGui import QIcon
|
from PyQt5.QtGui import QIcon
|
||||||
from PyQt5.QtCore import QEvent, QSize, Qt, pyqtSlot
|
from PyQt5.QtCore import QEvent, QSize, Qt, pyqtSignal, pyqtSlot
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QAbstractItemView, QDialog, QGridLayout, QHBoxLayout, QHeaderView, QLabel,
|
QAbstractButton, QAbstractItemView, QDialog, QDialogButtonBox, QGridLayout,
|
||||||
QLineEdit, QPushButton, QSplitter, QStackedWidget, QToolButton,
|
QHBoxLayout, QHeaderView, QLabel, QLineEdit, QPushButton, QSplitter,
|
||||||
QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget
|
QStackedWidget, QToolButton, QTreeWidget, QTreeWidgetItem, QVBoxLayout,
|
||||||
|
QWidget
|
||||||
)
|
)
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
from novelwriter import CONFIG
|
||||||
@@ -58,6 +59,8 @@ class GuiBuildSettings(QDialog):
|
|||||||
BLD_MARKDOWN = 6
|
BLD_MARKDOWN = 6
|
||||||
BLD_ODT = 7
|
BLD_ODT = 7
|
||||||
|
|
||||||
|
newSettingsReady = pyqtSignal(dict)
|
||||||
|
|
||||||
def __init__(self, mainGui: GuiMain, buildData: dict):
|
def __init__(self, mainGui: GuiMain, buildData: dict):
|
||||||
super().__init__(parent=mainGui)
|
super().__init__(parent=mainGui)
|
||||||
|
|
||||||
@@ -129,10 +132,20 @@ class GuiBuildSettings(QDialog):
|
|||||||
self.toolStack.addWidget(self.buildTabMarkdown)
|
self.toolStack.addWidget(self.buildTabMarkdown)
|
||||||
self.toolStack.addWidget(self.buildTabODT)
|
self.toolStack.addWidget(self.buildTabODT)
|
||||||
|
|
||||||
# Main Settings
|
# Main Settings + Buttons
|
||||||
# =============
|
# =======================
|
||||||
|
|
||||||
self.lblTitle = QLabel()
|
self.lblBuildName = QLabel(self.tr("Name"))
|
||||||
|
self.editBuildName = QLineEdit()
|
||||||
|
self.dlgButtons = QDialogButtonBox(
|
||||||
|
QDialogButtonBox.Apply | QDialogButtonBox.Save | QDialogButtonBox.Close
|
||||||
|
)
|
||||||
|
self.dlgButtons.clicked.connect(self._dialogButtonClicked)
|
||||||
|
|
||||||
|
self.buttonBox = QHBoxLayout()
|
||||||
|
self.buttonBox.addWidget(self.lblBuildName)
|
||||||
|
self.buttonBox.addWidget(self.editBuildName)
|
||||||
|
self.buttonBox.addWidget(self.dlgButtons)
|
||||||
|
|
||||||
# Assemble GUI
|
# Assemble GUI
|
||||||
# ============
|
# ============
|
||||||
@@ -140,9 +153,12 @@ class GuiBuildSettings(QDialog):
|
|||||||
self.mainBox = QHBoxLayout()
|
self.mainBox = QHBoxLayout()
|
||||||
self.mainBox.addWidget(self.optSideBar)
|
self.mainBox.addWidget(self.optSideBar)
|
||||||
self.mainBox.addWidget(self.toolStack)
|
self.mainBox.addWidget(self.toolStack)
|
||||||
|
self.mainBox.setContentsMargins(0, 0, 0, 0)
|
||||||
|
|
||||||
self.outerBox = QVBoxLayout()
|
self.outerBox = QVBoxLayout()
|
||||||
self.outerBox.addLayout(self.mainBox)
|
self.outerBox.addLayout(self.mainBox)
|
||||||
|
self.outerBox.addLayout(self.buttonBox)
|
||||||
|
self.outerBox.setSpacing(CONFIG.pxInt(12))
|
||||||
|
|
||||||
self.setLayout(self.outerBox)
|
self.setLayout(self.outerBox)
|
||||||
|
|
||||||
@@ -156,6 +172,7 @@ class GuiBuildSettings(QDialog):
|
|||||||
def loadContent(self):
|
def loadContent(self):
|
||||||
"""Populate the child widgets.
|
"""Populate the child widgets.
|
||||||
"""
|
"""
|
||||||
|
self.editBuildName.setText(self._build.name)
|
||||||
self.optTabSelect.loadContent(self._build)
|
self.optTabSelect.loadContent(self._build)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -183,6 +200,22 @@ class GuiBuildSettings(QDialog):
|
|||||||
self.toolStack.setCurrentWidget(self.buildTabODT)
|
self.toolStack.setCurrentWidget(self.buildTabODT)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@pyqtSlot("QAbstractButton*")
|
||||||
|
def _dialogButtonClicked(self, button: QAbstractButton):
|
||||||
|
"""Handle button clicks from the dialog button box.
|
||||||
|
"""
|
||||||
|
role = self.dlgButtons.buttonRole(button)
|
||||||
|
if role in (QDialogButtonBox.ApplyRole, QDialogButtonBox.AcceptRole):
|
||||||
|
self._build.setName(self.editBuildName.text())
|
||||||
|
self.newSettingsReady.emit(self._build.pack())
|
||||||
|
|
||||||
|
if role == QDialogButtonBox.AcceptRole:
|
||||||
|
self.accept()
|
||||||
|
elif role == QDialogButtonBox.RejectRole:
|
||||||
|
self.reject()
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Events
|
# Events
|
||||||
##
|
##
|
||||||
@@ -329,6 +362,7 @@ class GuiBuildFilterTab(QWidget):
|
|||||||
|
|
||||||
self.outerBox = QHBoxLayout()
|
self.outerBox = QHBoxLayout()
|
||||||
self.outerBox.addWidget(self.mainSplit)
|
self.outerBox.addWidget(self.mainSplit)
|
||||||
|
self.outerBox.setContentsMargins(0, 0, 0, 0)
|
||||||
|
|
||||||
self.setLayout(self.outerBox)
|
self.setLayout(self.outerBox)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user