Added first page to wizard
This commit is contained in:
+76
-1
@@ -28,7 +28,11 @@
|
|||||||
import logging
|
import logging
|
||||||
import nw
|
import nw
|
||||||
|
|
||||||
from PyQt5.QtWidgets import QWizard
|
from PyQt5.QtGui import QPixmap, QColor
|
||||||
|
from PyQt5.QtWidgets import (
|
||||||
|
QWizard, QWizardPage, QLabel, QVBoxLayout, QLineEdit, QPlainTextEdit,
|
||||||
|
QFormLayout
|
||||||
|
)
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -41,9 +45,80 @@ class GuiProjectWizard(QWizard):
|
|||||||
|
|
||||||
self.mainConf = nw.CONFIG
|
self.mainConf = nw.CONFIG
|
||||||
self.theParent = theParent
|
self.theParent = theParent
|
||||||
|
self.theTheme = theParent.theTheme
|
||||||
|
|
||||||
|
nPx = self.mainConf.pxInt(96)
|
||||||
|
wmW = self.mainConf.pxInt(100)
|
||||||
|
wmH = self.mainConf.pxInt(340)
|
||||||
|
|
||||||
|
self.sideImage = QPixmap(wmW, wmH)
|
||||||
|
self.sideImage.fill(self.palette().dark().color())
|
||||||
|
|
||||||
|
# self.setWizardStyle(QWizard.ModernStyle)
|
||||||
|
self.setPixmap(QWizard.WatermarkPixmap, self.sideImage)
|
||||||
|
|
||||||
|
self.introPage = ProjWizardIntroPage()
|
||||||
|
self.addPage(self.introPage)
|
||||||
|
|
||||||
|
self.setOption(QWizard.NoBackButtonOnStartPage, True)
|
||||||
|
# self.setOption(QWizard.ExtendedWatermarkPixmap, True)
|
||||||
|
|
||||||
logger.debug("GuiProjectWizard initialisation complete")
|
logger.debug("GuiProjectWizard initialisation complete")
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# END Class GuiProjectWizard
|
# END Class GuiProjectWizard
|
||||||
|
|
||||||
|
class ProjWizardIntroPage(QWizardPage):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
QWizardPage.__init__(self)
|
||||||
|
|
||||||
|
self.mainConf = nw.CONFIG
|
||||||
|
|
||||||
|
self.setTitle("Create New Project")
|
||||||
|
self.theText = QLabel(
|
||||||
|
"Provide at least a working title. The working title should not "
|
||||||
|
"be change beyond this point as it is used by the application for "
|
||||||
|
"generating file names for for instance backups. The other fields "
|
||||||
|
"are optional and can be changed at any time in Project Settings."
|
||||||
|
)
|
||||||
|
self.theText.setWordWrap(True)
|
||||||
|
|
||||||
|
xW = self.mainConf.pxInt(250)
|
||||||
|
xH = self.mainConf.pxInt(100)
|
||||||
|
vS = self.mainConf.pxInt(12)
|
||||||
|
fS = self.mainConf.pxInt(4)
|
||||||
|
|
||||||
|
self.projName = QLineEdit()
|
||||||
|
self.projName.setMaxLength(200)
|
||||||
|
self.projName.setFixedWidth(xW)
|
||||||
|
self.projName.setPlaceholderText("Required")
|
||||||
|
|
||||||
|
self.projTitle = QLineEdit()
|
||||||
|
self.projTitle.setMaxLength(200)
|
||||||
|
self.projTitle.setFixedWidth(xW)
|
||||||
|
self.projTitle.setPlaceholderText("Optional")
|
||||||
|
|
||||||
|
self.projAuthors = QPlainTextEdit()
|
||||||
|
self.projAuthors.setFixedHeight(xH)
|
||||||
|
self.projAuthors.setFixedWidth(xW)
|
||||||
|
self.projAuthors.setPlaceholderText("Optional. One name per line.")
|
||||||
|
|
||||||
|
self.mainForm = QFormLayout()
|
||||||
|
self.mainForm.addRow("Working title", self.projName)
|
||||||
|
self.mainForm.addRow("Novel title", self.projTitle)
|
||||||
|
self.mainForm.addRow("Author(s)", self.projAuthors)
|
||||||
|
self.mainForm.setVerticalSpacing(fS)
|
||||||
|
|
||||||
|
# Assemble
|
||||||
|
self.outerBox = QVBoxLayout()
|
||||||
|
self.outerBox.setSpacing(vS)
|
||||||
|
self.outerBox.addWidget(self.theText)
|
||||||
|
self.outerBox.addLayout(self.mainForm)
|
||||||
|
self.outerBox.addStretch(1)
|
||||||
|
self.setLayout(self.outerBox)
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
# END Class ProjWizardIntroPage
|
||||||
|
|||||||
+11
-9
@@ -43,7 +43,7 @@ from nw.gui import (
|
|||||||
GuiBuildNovel, GuiDocEditor, GuiDocMerge, GuiDocSplit, GuiDocViewDetails,
|
GuiBuildNovel, GuiDocEditor, GuiDocMerge, GuiDocSplit, GuiDocViewDetails,
|
||||||
GuiDocViewer, GuiItemDetails, GuiItemEditor, GuiMainMenu, GuiMainStatus,
|
GuiDocViewer, GuiItemDetails, GuiItemEditor, GuiMainMenu, GuiMainStatus,
|
||||||
GuiOutline, GuiOutlineDetails, GuiPreferences, GuiProjectLoad, GuiTheme,
|
GuiOutline, GuiOutlineDetails, GuiPreferences, GuiProjectLoad, GuiTheme,
|
||||||
GuiProjectSettings, GuiProjectTree, GuiWritingStats
|
GuiProjectSettings, GuiProjectTree, GuiWritingStats, GuiProjectWizard
|
||||||
)
|
)
|
||||||
from nw.core import NWProject, NWDoc, NWIndex
|
from nw.core import NWProject, NWDoc, NWIndex
|
||||||
from nw.constants import nwFiles, nwItemType, nwAlert
|
from nw.constants import nwFiles, nwItemType, nwAlert
|
||||||
@@ -766,14 +766,16 @@ class GuiMain(QMainWindow):
|
|||||||
def newProjectDialog(self):
|
def newProjectDialog(self):
|
||||||
"""Select where to save new project.
|
"""Select where to save new project.
|
||||||
"""
|
"""
|
||||||
dlgOpt = QFileDialog.Options()
|
newProj = GuiProjectWizard(self)
|
||||||
dlgOpt |= QFileDialog.ShowDirsOnly
|
newProj.exec_()
|
||||||
dlgOpt |= QFileDialog.DontUseNativeDialog
|
# dlgOpt = QFileDialog.Options()
|
||||||
projPath = QFileDialog.getExistingDirectory(
|
# dlgOpt |= QFileDialog.ShowDirsOnly
|
||||||
self, "Select Location for New novelWriter Project", "", options=dlgOpt
|
# dlgOpt |= QFileDialog.DontUseNativeDialog
|
||||||
)
|
# projPath = QFileDialog.getExistingDirectory(
|
||||||
if projPath:
|
# self, "Select Location for New novelWriter Project", "", options=dlgOpt
|
||||||
return projPath
|
# )
|
||||||
|
# if projPath:
|
||||||
|
# return projPath
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def editConfigDialog(self):
|
def editConfigDialog(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user