Added project settings GUI
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
id="svg1014"
|
||||
version="1.1"
|
||||
viewBox="0 0 40 40"
|
||||
height="40mm"
|
||||
width="40mm">
|
||||
<defs
|
||||
id="defs1008" />
|
||||
<metadata
|
||||
id="metadata1011">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
transform="translate(0,-257)"
|
||||
id="layer1">
|
||||
<rect
|
||||
y="257"
|
||||
x="-1.7763568e-15"
|
||||
height="40"
|
||||
width="40"
|
||||
id="rect1580"
|
||||
style="fill:#646464;fill-opacity:0.39351851;stroke:none;stroke-width:0.18425357;stroke-linecap:square;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
id="svg1014"
|
||||
version="1.1"
|
||||
viewBox="0 0 40 40"
|
||||
height="40mm"
|
||||
width="40mm">
|
||||
<defs
|
||||
id="defs1008">
|
||||
<linearGradient
|
||||
id="linearGradient1586">
|
||||
<stop
|
||||
id="stop1582"
|
||||
offset="0"
|
||||
style="stop-color:#646464;stop-opacity:0" />
|
||||
<stop
|
||||
id="stop1584"
|
||||
offset="1"
|
||||
style="stop-color:#646464;stop-opacity:1" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
gradientTransform="matrix(0.90450234,0,0,0.53447864,-9.5726494,251.5932)"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
y2="47.535713"
|
||||
x2="54.938839"
|
||||
y1="47.535713"
|
||||
x1="10.451041"
|
||||
id="linearGradient1588"
|
||||
xlink:href="#linearGradient1586" />
|
||||
</defs>
|
||||
<metadata
|
||||
id="metadata1011">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
transform="translate(0,-257)"
|
||||
id="layer1">
|
||||
<rect
|
||||
y="257"
|
||||
x="-1.7763568e-15"
|
||||
height="40"
|
||||
width="40"
|
||||
id="rect1580"
|
||||
style="fill:url(#linearGradient1588);fill-opacity:1;stroke:none;stroke-width:0.18425357;stroke-linecap:square;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.7 KiB |
+50
-17
@@ -13,20 +13,32 @@
|
||||
import logging
|
||||
import nw
|
||||
|
||||
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QVBoxLayout, QGroupBox, QFormLayout, QLabel, QLineEdit, QPlainTextEdit, QPushButton, QFileDialog
|
||||
from os import path
|
||||
|
||||
from PyQt5.QtWidgets import QDialog, QHBoxLayout, QVBoxLayout, QGroupBox, QFormLayout, QLabel, QLineEdit, QPlainTextEdit, QPushButton
|
||||
from PyQt5.QtSvg import QSvgWidget
|
||||
from PyQt5.QtGui import QIcon
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class GuiProjectEditor(QWidget):
|
||||
class GuiProjectEditor(QDialog):
|
||||
|
||||
def __init__(self):
|
||||
QWidget.__init__(self)
|
||||
def __init__(self, guiParent, theProject):
|
||||
QDialog.__init__(self, guiParent)
|
||||
|
||||
logger.debug("Initialising ProjectEditor ...")
|
||||
|
||||
self.outerBox = QVBoxLayout()
|
||||
self.mainConf = nw.CONFIG
|
||||
self.theProject = theProject
|
||||
self.outerBox = QHBoxLayout()
|
||||
self.innerBox = QVBoxLayout()
|
||||
|
||||
self.gradPath = path.abspath(path.join(self.mainConf.appPath,"graphics","block.svg"))
|
||||
self.svgGradient = QSvgWidget(self.gradPath)
|
||||
self.svgGradient.setFixedWidth(80)
|
||||
self.setLayout(self.outerBox)
|
||||
self.outerBox.addWidget(self.svgGradient)
|
||||
self.outerBox.addLayout(self.innerBox)
|
||||
|
||||
self.mainGroup = QGroupBox("Project Settings")
|
||||
self.mainForm = QFormLayout()
|
||||
@@ -34,29 +46,50 @@ class GuiProjectEditor(QWidget):
|
||||
self.editName = QLineEdit()
|
||||
self.editTitle = QLineEdit()
|
||||
self.editAuthors = QPlainTextEdit()
|
||||
self.saveBox = QHBoxLayout()
|
||||
self.savePath = QLineEdit()
|
||||
self.saveButton = QPushButton(QIcon.fromTheme("folder"),"Browse")
|
||||
self.saveButton.setToolTip("Browse for Save Path")
|
||||
self.saveButton.clicked.connect(self._browseProjectPath)
|
||||
self.saveBox.addWidget(self.savePath)
|
||||
self.saveBox.addWidget(self.saveButton)
|
||||
|
||||
self.mainForm.addRow("Working Title", self.editName)
|
||||
self.mainForm.addRow("Book Title", self.editTitle)
|
||||
self.mainForm.addRow("Book Authors", self.editAuthors)
|
||||
self.mainForm.addRow("Save Path", self.saveBox)
|
||||
|
||||
self.editName.setText(self.theProject.projName)
|
||||
self.editTitle.setText(self.theProject.bookTitle)
|
||||
bookAuthors = ""
|
||||
for bookAuthor in self.theProject.bookAuthors:
|
||||
bookAuthors += bookAuthor+"\n"
|
||||
self.editAuthors.setPlainText(bookAuthors)
|
||||
|
||||
self.buttonBox = QHBoxLayout()
|
||||
self.closeButton = QPushButton("Close")
|
||||
self.closeButton.clicked.connect(self._doClose)
|
||||
self.saveButton = QPushButton("Save")
|
||||
self.saveButton.clicked.connect(self._doSave)
|
||||
self.buttonBox.addStretch(1)
|
||||
self.buttonBox.addWidget(self.closeButton)
|
||||
self.buttonBox.addWidget(self.saveButton)
|
||||
|
||||
self.mainGroup.setLayout(self.mainForm)
|
||||
self.outerBox.addWidget(self.mainGroup)
|
||||
self.innerBox.addWidget(self.mainGroup)
|
||||
self.innerBox.addLayout(self.buttonBox)
|
||||
|
||||
self.show()
|
||||
|
||||
logger.debug("ProjectEditor initialisation complete")
|
||||
|
||||
return
|
||||
|
||||
def _browseProjectPath(self):
|
||||
fileName, _ = QFileDialog.getSaveFileName(self,"Project File Name","","novelWriter File (*.nwf);;All Files (*)")
|
||||
self.savePath.setText(fileName)
|
||||
def _doSave(self):
|
||||
logger.vverbose("ProjectEditor save button clicked")
|
||||
projName = self.editName.text()
|
||||
bookTitle = self.editTitle.text()
|
||||
bookAuthors = self.editAuthors.toPlainText()
|
||||
self.theProject.setProjectName(projName)
|
||||
self.theProject.setBookTitle(bookTitle)
|
||||
self.theProject.setBookAuthors(bookAuthors)
|
||||
return
|
||||
|
||||
def _doClose(self):
|
||||
logger.vverbose("ProjectEditor close button clicked")
|
||||
self.close()
|
||||
return
|
||||
|
||||
# END Class GuiProjectEditor
|
||||
|
||||
+14
-7
@@ -13,14 +13,15 @@
|
||||
import logging
|
||||
import nw
|
||||
|
||||
from os import path
|
||||
from PyQt5.QtWidgets import qApp, QWidget, QMainWindow, QHBoxLayout, QVBoxLayout, QFrame, QSplitter, QAction, QToolBar, QFileDialog
|
||||
from PyQt5.QtCore import Qt, QSize
|
||||
from PyQt5.QtGui import QIcon, QStandardItemModel
|
||||
from os import path
|
||||
from PyQt5.QtWidgets import qApp, QWidget, QMainWindow, QHBoxLayout, QVBoxLayout, QFrame, QSplitter, QAction, QToolBar, QFileDialog
|
||||
from PyQt5.QtCore import Qt, QSize
|
||||
from PyQt5.QtGui import QIcon, QStandardItemModel
|
||||
|
||||
from nw.gui.doctree import GuiDocTree
|
||||
from nw.gui.doceditor import GuiDocEditor
|
||||
from nw.project.project import NWProject
|
||||
from nw.gui.doctree import GuiDocTree
|
||||
from nw.gui.doceditor import GuiDocEditor
|
||||
from nw.gui.projecteditor import GuiProjectEditor
|
||||
from nw.project.project import NWProject
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -115,6 +116,11 @@ class GuiMain(QMainWindow):
|
||||
self.theProject.saveProject()
|
||||
return True
|
||||
|
||||
def editProject(self):
|
||||
dlgProj = GuiProjectEditor(self, self.theProject)
|
||||
dlgProj.exec_()
|
||||
return True
|
||||
|
||||
#
|
||||
# Document Actions
|
||||
#
|
||||
@@ -164,6 +170,7 @@ class GuiMain(QMainWindow):
|
||||
# File > Project Settings
|
||||
menuProjectSettings = QAction(QIcon.fromTheme("document-properties"), "Project Settings", menuBar)
|
||||
menuProjectSettings.setStatusTip("Project Settings")
|
||||
menuProjectSettings.triggered.connect(self.editProject)
|
||||
fileMenu.addAction(menuProjectSettings)
|
||||
|
||||
# ---------------------
|
||||
|
||||
+22
-16
@@ -29,6 +29,7 @@ class NWProject():
|
||||
# Project Settings
|
||||
self.projPath = None
|
||||
self.projFile = "nwProject.nwx"
|
||||
self.projName = ""
|
||||
self.bookTitle = ""
|
||||
self.bookAuthors = []
|
||||
|
||||
@@ -60,17 +61,17 @@ class NWProject():
|
||||
logger.error("Project file does not appear to be a novelWriterXML file version 1.0")
|
||||
return False
|
||||
|
||||
# for xChild in xRoot:
|
||||
# if xChild.tag == "book":
|
||||
# logger.debug("BookOpen: Found book data")
|
||||
# for xItem in xChild:
|
||||
# if xItem.text is None: continue
|
||||
# if xItem.tag == "title":
|
||||
# logger.verbose("BookOpen: Title is '%s'" % xItem.text)
|
||||
# self.bookTitle = xItem.text
|
||||
# elif xItem.tag == "author":
|
||||
# logger.verbose("BookOpen: Author: '%s'" % xItem.text)
|
||||
# self.bookAuthors.append(xItem.text)
|
||||
for xChild in xRoot:
|
||||
if xChild.tag == "project":
|
||||
logger.debug("Found book data")
|
||||
for xItem in xChild:
|
||||
if xItem.text is None: continue
|
||||
if xItem.tag == "title":
|
||||
logger.verbose("Title is '%s'" % xItem.text)
|
||||
self.bookTitle = xItem.text
|
||||
elif xItem.tag == "author":
|
||||
logger.verbose("Author: '%s'" % xItem.text)
|
||||
self.bookAuthors.append(xItem.text)
|
||||
|
||||
self.mainConf.setRecent(self.projPath)
|
||||
|
||||
@@ -92,12 +93,14 @@ class NWProject():
|
||||
"appVersion" : str(nw.__version__),
|
||||
"timeStamp" : datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
||||
})
|
||||
xBook = etree.SubElement(nwXML,"book")
|
||||
xBookTitle = etree.SubElement(xBook,"title")
|
||||
xProject = etree.SubElement(nwXML,"project")
|
||||
xProjName = etree.SubElement(xProject,"name")
|
||||
xProjName.text = self.projName
|
||||
xBookTitle = etree.SubElement(xProject,"title")
|
||||
xBookTitle.text = self.bookTitle
|
||||
for bookAuthor in self.bookAuthors:
|
||||
if bookAuthor == "": continue
|
||||
xBookAuthor = etree.SubElement(xBook,"author")
|
||||
xBookAuthor = etree.SubElement(xProject,"author")
|
||||
xBookAuthor.text = bookAuthor
|
||||
|
||||
# Write the xml tree to file
|
||||
@@ -131,8 +134,11 @@ class NWProject():
|
||||
|
||||
def setBookAuthors(self, bookAuthors):
|
||||
self.bookAuthors = []
|
||||
for bookAuthor in bookAuthors.split(","):
|
||||
self.bookAuthors.append(bookAuthor.strip())
|
||||
for bookAuthor in bookAuthors.split("\n"):
|
||||
bookAuthor = bookAuthor.strip()
|
||||
if bookAuthor == "":
|
||||
continue
|
||||
self.bookAuthors.append(bookAuthor)
|
||||
return True
|
||||
|
||||
# END Class NWProject
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<novelWriterXML appVersion="0.1.0" fileVersion="1.0" timeStamp="2018-10-23T21:36:09">
|
||||
<book>
|
||||
<title></title>
|
||||
</book>
|
||||
<novelWriterXML appVersion="0.1.0" fileVersion="1.0" timeStamp="2018-10-25 22:17:01">
|
||||
<project>
|
||||
<name>Sample Project</name>
|
||||
<title>Sample Project</title>
|
||||
<author>Jane Smith</author>
|
||||
<author>Jane Doh</author>
|
||||
</project>
|
||||
</novelWriterXML>
|
||||
|
||||
Reference in New Issue
Block a user