def __init__(self, theParent): QWidget.__init__(self, theParent) self.mainConf = nw.CONFIG self.theParent = theParent self.theTheme = theParent.theTheme # The Form self.mainForm = QConfigLayout() self.mainForm.setHelpTextStyle(self.theTheme.helpText) self.setLayout(self.mainForm) # Automatic Features # ================== self.mainForm.addGroupLabel("Automatic Features") ## Auto-Select Word Under Cursor self.autoSelect = QSwitch() self.autoSelect.setChecked(self.mainConf.autoSelect) self.mainForm.addRow( "Auto-select word under cursor", self.autoSelect, "Apply formatting to word under cursor if no selection is made.") ## Auto-Replace as You Type Main Switch self.autoReplaceMain = QSwitch() self.autoReplaceMain.setChecked(self.mainConf.doReplace) self.autoReplaceMain.toggled.connect(self._toggleAutoReplaceMain) self.mainForm.addRow( "Auto-replace text as you type", self.autoReplaceMain, "Allow the editor to replace symbols as you type.") # Auto-Replace # ============ self.mainForm.addGroupLabel("Replace as You Type") ## Auto-Replace Single Quotes self.autoReplaceSQ = QSwitch() self.autoReplaceSQ.setChecked(self.mainConf.doReplaceSQuote) self.autoReplaceSQ.setEnabled(self.mainConf.doReplace) self.mainForm.addRow( "Auto-replace single quotes", self.autoReplaceSQ, "Try to guess which is an opening or a closing single quote.") ## Auto-Replace Double Quotes self.autoReplaceDQ = QSwitch() self.autoReplaceDQ.setChecked(self.mainConf.doReplaceDQuote) self.autoReplaceDQ.setEnabled(self.mainConf.doReplace) self.mainForm.addRow( "Auto-replace double quotes", self.autoReplaceDQ, "Try to guess which is an opening or a closing double quote.") ## Auto-Replace Hyphens self.autoReplaceDash = QSwitch() self.autoReplaceDash.setChecked(self.mainConf.doReplaceDash) self.autoReplaceDash.setEnabled(self.mainConf.doReplace) self.mainForm.addRow( "Auto-replace dashes", self.autoReplaceDash, "Double and triple hyphens become short and long dashes.") ## Auto-Replace Dots self.autoReplaceDots = QSwitch() self.autoReplaceDots.setChecked(self.mainConf.doReplaceDots) self.autoReplaceDots.setEnabled(self.mainConf.doReplace) self.mainForm.addRow("Auto-replace dots", self.autoReplaceDots, "Three consecutive dots becomes ellipsis.") # Quotation Style # =============== self.mainForm.addGroupLabel("Quotation Style") qWidth = self.mainConf.pxInt(40) bWidth = int(2.5 * self.theTheme.getTextWidth("...")) self.quoteSym = {} ## Single Quote Style self.quoteSym["SO"] = QLineEdit() self.quoteSym["SO"].setMaxLength(1) self.quoteSym["SO"].setReadOnly(True) self.quoteSym["SO"].setFixedWidth(qWidth) self.quoteSym["SO"].setAlignment(Qt.AlignCenter) self.quoteSym["SO"].setText(self.mainConf.fmtSingleQuotes[0]) self.btnSingleStyleO = QPushButton("...") self.btnSingleStyleO.setMaximumWidth(bWidth) self.btnSingleStyleO.clicked.connect(lambda: self._getQuote("SO")) self.mainForm.addRow("Single quote open style", self.quoteSym["SO"], "The symbol to use for a leading single quote.", theButton=self.btnSingleStyleO) self.quoteSym["SC"] = QLineEdit() self.quoteSym["SC"].setMaxLength(1) self.quoteSym["SC"].setReadOnly(True) self.quoteSym["SC"].setFixedWidth(qWidth) self.quoteSym["SC"].setAlignment(Qt.AlignCenter) self.quoteSym["SC"].setText(self.mainConf.fmtSingleQuotes[1]) self.btnSingleStyleC = QPushButton("...") self.btnSingleStyleC.setMaximumWidth(bWidth) self.btnSingleStyleC.clicked.connect(lambda: self._getQuote("SC")) self.mainForm.addRow("Single quote close style", self.quoteSym["SC"], "The symbol to use for a trailing single quote.", theButton=self.btnSingleStyleC) ## Double Quote Style self.quoteSym["DO"] = QLineEdit() self.quoteSym["DO"].setMaxLength(1) self.quoteSym["DO"].setReadOnly(True) self.quoteSym["DO"].setFixedWidth(qWidth) self.quoteSym["DO"].setAlignment(Qt.AlignCenter) self.quoteSym["DO"].setText(self.mainConf.fmtDoubleQuotes[0]) self.btnDoubleStyleO = QPushButton("...") self.btnDoubleStyleO.setMaximumWidth(bWidth) self.btnDoubleStyleO.clicked.connect(lambda: self._getQuote("DO")) self.mainForm.addRow("Double quote open style", self.quoteSym["DO"], "The symbol to use for a leading double quote.", theButton=self.btnDoubleStyleO) self.quoteSym["DC"] = QLineEdit() self.quoteSym["DC"].setMaxLength(1) self.quoteSym["DC"].setReadOnly(True) self.quoteSym["DC"].setFixedWidth(qWidth) self.quoteSym["DC"].setAlignment(Qt.AlignCenter) self.quoteSym["DC"].setText(self.mainConf.fmtDoubleQuotes[1]) self.btnDoubleStyleC = QPushButton("...") self.btnDoubleStyleC.setMaximumWidth(bWidth) self.btnDoubleStyleC.clicked.connect(lambda: self._getQuote("DC")) self.mainForm.addRow("Double quote close style", self.quoteSym["DC"], "The symbol to use for a trailing double quote.", theButton=self.btnDoubleStyleC) return
def __init__(self, theParent): QWidget.__init__(self, theParent) self.mainConf = nw.CONFIG self.theParent = theParent self.theTheme = theParent.theTheme # The Form self.mainForm = QConfigLayout() self.mainForm.setHelpTextStyle(self.theTheme.helpText) self.setLayout(self.mainForm) # Text Style # ========== self.mainForm.addGroupLabel("Document Text Style") ## Font Family self.textStyleFont = QLineEdit() self.textStyleFont.setReadOnly(True) self.textStyleFont.setFixedWidth(self.mainConf.pxInt(162)) self.textStyleFont.setText(self.mainConf.textFont) self.fontButton = QPushButton("...") self.fontButton.setMaximumWidth( int(2.5 * self.theTheme.getTextWidth("..."))) self.fontButton.clicked.connect(self._selectFont) self.mainForm.addRow("Font family", self.textStyleFont, "Font for the document editor and viewer.", theButton=self.fontButton) ## Font Size self.textStyleSize = QSpinBox(self) self.textStyleSize.setMinimum(8) self.textStyleSize.setMaximum(60) self.textStyleSize.setSingleStep(1) self.textStyleSize.setValue(self.mainConf.textSize) self.mainForm.addRow("Font size", self.textStyleSize, "Font size for the document editor and viewer.", theUnit="pt") # Text Flow # ========= self.mainForm.addGroupLabel("Document Text Flow") ## Max Text Width in Normal Mode self.textFlowMax = QSpinBox(self) self.textFlowMax.setMinimum(300) self.textFlowMax.setMaximum(10000) self.textFlowMax.setSingleStep(10) self.textFlowMax.setValue(self.mainConf.textWidth) self.mainForm.addRow("Maximum text width in \"Normal Mode\"", self.textFlowMax, "Horizontal margins are scaled automatically.", theUnit="px") ## Max Text Width in Focus Mode self.focusDocWidth = QSpinBox(self) self.focusDocWidth.setMinimum(300) self.focusDocWidth.setMaximum(10000) self.focusDocWidth.setSingleStep(10) self.focusDocWidth.setValue(self.mainConf.focusWidth) self.mainForm.addRow("Maximum text width in \"Focus Mode\"", self.focusDocWidth, "Horizontal margins are scaled automatically.", theUnit="px") ## Document Fixed Width self.textFlowFixed = QSwitch() self.textFlowFixed.setChecked(not self.mainConf.textFixedW) self.mainForm.addRow( "Disable maximum text width in \"Normal Mode\"", self.textFlowFixed, "If disabled, minimum text width is defined by the margin.") ## Focus Mode Footer self.hideFocusFooter = QSwitch() self.hideFocusFooter.setChecked(self.mainConf.hideFocusFooter) self.mainForm.addRow( "Hide document footer in \"Focus Mode\"", self.hideFocusFooter, "Hide the information bar at the bottom of the document.") ## Justify Text self.textJustify = QSwitch() self.textJustify.setChecked(self.mainConf.textFixedW) self.mainForm.addRow( "Justify the text margins in editor and viewer", self.textJustify, "Lay out text with straight edges in the editor and viewer.") ## Document Margins self.textMargin = QSpinBox(self) self.textMargin.setMinimum(0) self.textMargin.setMaximum(900) self.textMargin.setSingleStep(1) self.textMargin.setValue(self.mainConf.textMargin) self.mainForm.addRow( "Text margin", self.textMargin, "If maximum width is set, this becomes the minimum margin.", theUnit="px") ## Tab Width self.tabWidth = QSpinBox(self) self.tabWidth.setMinimum(0) self.tabWidth.setMaximum(200) self.tabWidth.setSingleStep(1) self.tabWidth.setValue(self.mainConf.tabWidth) self.mainForm.addRow( "Tab width", self.tabWidth, "The width of a tab key press in the editor and viewer.", theUnit="px") # Scroll Behaviour # ================ self.mainForm.addGroupLabel("Scroll Behaviour") ## Scroll Past End self.scrollPastEnd = QSwitch() self.scrollPastEnd.setChecked(self.mainConf.scrollPastEnd) self.mainForm.addRow( "Scroll past end of the document", self.scrollPastEnd, "Allow scrolling until the last line is centred in the editor.") ## Typewriter Scrolling self.autoScroll = QSwitch() self.autoScroll.setChecked(self.mainConf.autoScroll) self.mainForm.addRow( "Typewriter style scrolling when you type", self.autoScroll, "Try to keep the cursor at a fixed vertical position.") ## Font Size self.autoScrollPos = QSpinBox(self) self.autoScrollPos.setMinimum(10) self.autoScrollPos.setMaximum(90) self.autoScrollPos.setSingleStep(1) self.autoScrollPos.setValue(int(self.mainConf.autoScrollPos)) self.mainForm.addRow("Minimum position for Typewriter scrolling", self.autoScrollPos, "In units of percentage of the editor height.", theUnit="%") return
def __init__(self, theParent): QWidget.__init__(self, theParent) self.mainConf = nw.CONFIG self.theParent = theParent self.theTheme = theParent.theTheme # The Form self.mainForm = QConfigLayout() self.mainForm.setHelpTextStyle(self.theTheme.helpText) self.setLayout(self.mainForm) # Spell Checking # ============== self.mainForm.addGroupLabel("Syntax Highlighting") ## Syntax Highlighting self.selectSyntax = QComboBox() self.selectSyntax.setMinimumWidth(self.mainConf.pxInt(200)) self.theSyntaxes = self.theTheme.listSyntax() for syntaxFile, syntaxName in self.theSyntaxes: self.selectSyntax.addItem(syntaxName, syntaxFile) syntaxIdx = self.selectSyntax.findData(self.mainConf.guiSyntax) if syntaxIdx != -1: self.selectSyntax.setCurrentIndex(syntaxIdx) self.mainForm.addRow( "Highlight theme", self.selectSyntax, "Colour theme to apply to the editor and viewer.") self.highlightQuotes = QSwitch() self.highlightQuotes.setChecked(self.mainConf.highlightQuotes) self.mainForm.addRow("Highlight text wrapped in quotes", self.highlightQuotes, "Applies to single, double and straight quotes.") self.highlightEmph = QSwitch() self.highlightEmph.setChecked(self.mainConf.highlightEmph) self.mainForm.addRow("Add highlight colour to emphasised text", self.highlightEmph, "Applies to emphasis, strong and strikethrough.") # Spell Checking # ============== self.mainForm.addGroupLabel("Spell Checking") ## Spell Check Provider and Language self.spellLangList = QComboBox(self) self.spellToolList = QComboBox(self) self.spellToolList.addItem("Internal (difflib)", nwConst.SP_INTERNAL) self.spellToolList.addItem("Spell Enchant (pyenchant)", nwConst.SP_ENCHANT) theModel = self.spellToolList.model() idEnchant = self.spellToolList.findData(nwConst.SP_ENCHANT) theModel.item(idEnchant).setEnabled(self.mainConf.hasEnchant) self.spellToolList.currentIndexChanged.connect(self._doUpdateSpellTool) toolIdx = self.spellToolList.findData(self.mainConf.spellTool) if toolIdx != -1: self.spellToolList.setCurrentIndex(toolIdx) self._doUpdateSpellTool(0) self.mainForm.addRow( "Spell check provider", self.spellToolList, "Note that the internal spell check tool is quite slow.") self.mainForm.addRow( "Spell check language", self.spellLangList, "Available languages are determined by your system.") ## Big Document Size Limit self.bigDocLimit = QSpinBox(self) self.bigDocLimit.setMinimum(10) self.bigDocLimit.setMaximum(10000) self.bigDocLimit.setSingleStep(10) self.bigDocLimit.setValue(self.mainConf.bigDocLimit) self.mainForm.addRow( "Big document limit", self.bigDocLimit, "Full spell checking is disabled above this limit.", theUnit="kB") # Writing Guides # ============== self.mainForm.addGroupLabel("Writing Guides") ## Show Tabs and Spaces self.showTabsNSpaces = QSwitch() self.showTabsNSpaces.setChecked(self.mainConf.showTabsNSpaces) self.mainForm.addRow( "Show tabs and spaces", self.showTabsNSpaces, "Add symbols to indicate tabs and spaces in the editor.") ## Show Line Endings self.showLineEndings = QSwitch() self.showLineEndings.setChecked(self.mainConf.showLineEndings) self.mainForm.addRow( "Show line endings", self.showLineEndings, "Add a symbol to indicate line endings in the editor.") return
def __init__(self, theParent): QWidget.__init__(self, theParent) self.mainConf = nw.CONFIG self.theParent = theParent self.theTheme = theParent.theTheme # The Form self.mainForm = QConfigLayout() self.mainForm.setHelpTextStyle(self.theTheme.helpText) self.setLayout(self.mainForm) # Look and Feel # ============= self.mainForm.addGroupLabel("Look and Feel") ## Select Theme self.selectTheme = QComboBox() self.selectTheme.setMinimumWidth(self.mainConf.pxInt(200)) self.theThemes = self.theTheme.listThemes() for themeDir, themeName in self.theThemes: self.selectTheme.addItem(themeName, themeDir) themeIdx = self.selectTheme.findData(self.mainConf.guiTheme) if themeIdx != -1: self.selectTheme.setCurrentIndex(themeIdx) self.mainForm.addRow("Main GUI theme", self.selectTheme, "Changing this requires restarting novelWriter.") ## Select Icon Theme self.selectIcons = QComboBox() self.selectIcons.setMinimumWidth(self.mainConf.pxInt(200)) self.theIcons = self.theTheme.theIcons.listThemes() for iconDir, iconName in self.theIcons: self.selectIcons.addItem(iconName, iconDir) iconIdx = self.selectIcons.findData(self.mainConf.guiIcons) if iconIdx != -1: self.selectIcons.setCurrentIndex(iconIdx) self.mainForm.addRow("Main icon theme", self.selectIcons, "Changing this requires restarting novelWriter.") ## Dark Icons self.preferDarkIcons = QSwitch() self.preferDarkIcons.setChecked(self.mainConf.guiDark) self.mainForm.addRow( "Prefer icons for dark backgrounds", self.preferDarkIcons, "This may improve the look of icons on dark themes.") ## Font Family self.guiFont = QLineEdit() self.guiFont.setReadOnly(True) self.guiFont.setFixedWidth(self.mainConf.pxInt(162)) self.guiFont.setText(self.mainConf.guiFont) self.fontButton = QPushButton("...") self.fontButton.setMaximumWidth( int(2.5 * self.theTheme.getTextWidth("..."))) self.fontButton.clicked.connect(self._selectFont) self.mainForm.addRow("Font family", self.guiFont, "Changing this requires restarting novelWriter.", theButton=self.fontButton) ## Font Size self.guiFontSize = QSpinBox(self) self.guiFontSize.setMinimum(8) self.guiFontSize.setMaximum(60) self.guiFontSize.setSingleStep(1) self.guiFontSize.setValue(self.mainConf.guiFontSize) self.mainForm.addRow("Font size", self.guiFontSize, "Changing this requires restarting novelWriter.", theUnit="pt") # GUI Settings # ============ self.mainForm.addGroupLabel("GUI Settings") self.showFullPath = QSwitch() self.showFullPath.setChecked(self.mainConf.showFullPath) self.mainForm.addRow("Show full path in document header", self.showFullPath, "Add the parent folder names to the header.") self.hideVScroll = QSwitch() self.hideVScroll.setChecked(self.mainConf.hideVScroll) self.mainForm.addRow( "Hide vertical scroll bars in main windows", self.hideVScroll, "Scrolling available with mouse wheel and keys only.") self.hideHScroll = QSwitch() self.hideHScroll.setChecked(self.mainConf.hideHScroll) self.mainForm.addRow( "Hide horizontal scroll bars in main windows", self.hideHScroll, "Scrolling available with mouse wheel and keys only.") return
def __init__(self, theParent): QWidget.__init__(self, theParent) self.mainConf = nw.CONFIG self.theParent = theParent self.theTheme = theParent.theTheme # The Form self.mainForm = QConfigLayout() self.mainForm.setHelpTextStyle(self.theTheme.helpText) self.setLayout(self.mainForm) # AutoSave Settings # ================= self.mainForm.addGroupLabel("Automatic Save") ## Document Save Timer self.autoSaveDoc = QSpinBox(self) self.autoSaveDoc.setMinimum(5) self.autoSaveDoc.setMaximum(600) self.autoSaveDoc.setSingleStep(1) self.autoSaveDoc.setValue(self.mainConf.autoSaveDoc) self.backupPathRow = self.mainForm.addRow( "Save document interval", self.autoSaveDoc, "How often the open document is automatically saved.", theUnit="seconds") ## Project Save Timer self.autoSaveProj = QSpinBox(self) self.autoSaveProj.setMinimum(5) self.autoSaveProj.setMaximum(600) self.autoSaveProj.setSingleStep(1) self.autoSaveProj.setValue(self.mainConf.autoSaveProj) self.backupPathRow = self.mainForm.addRow( "Save project interval", self.autoSaveProj, "How often the open project is automatically saved.", theUnit="seconds") # Backup Settings # =============== self.mainForm.addGroupLabel("Project Backup") ## Backup Path self.backupPath = self.mainConf.backupPath self.backupGetPath = QPushButton("Browse") self.backupGetPath.clicked.connect(self._backupFolder) self.backupPathRow = self.mainForm.addRow("Backup storage location", self.backupGetPath, "Path: %s" % self.backupPath) ## Run when closing self.backupOnClose = QSwitch() self.backupOnClose.setChecked(self.mainConf.backupOnClose) self.backupOnClose.toggled.connect(self._toggledBackupOnClose) self.mainForm.addRow( "Run backup when the project is closed", self.backupOnClose, "Can be overridden for individual projects in project settings.") ## Ask before backup ## Only enabled when "Run when closing" is checked self.askBeforeBackup = QSwitch() self.askBeforeBackup.setChecked(self.mainConf.askBeforeBackup) self.askBeforeBackup.setEnabled(self.mainConf.backupOnClose) self.mainForm.addRow( "Ask before running backup", self.askBeforeBackup, "Disabling this will cause backups to run in the background.") return
def __init__(self, theParent): QWidget.__init__(self, theParent) self.mainConf = nw.CONFIG self.theParent = theParent self.theTheme = theParent.theTheme # The Form self.mainForm = QConfigLayout() self.mainForm.setHelpTextStyle(self.theTheme.helpText) self.setLayout(self.mainForm) # Automatic Features # ================== self.mainForm.addGroupLabel(self.tr("Automatic Features")) ## Auto-Select Word Under Cursor self.autoSelect = QSwitch() self.autoSelect.setChecked(self.mainConf.autoSelect) self.mainForm.addRow( self.tr("Auto-select word under cursor"), self.autoSelect, self. tr("Apply formatting to word under cursor if no selection is made." )) ## Auto-Replace as You Type Main Switch self.doReplace = QSwitch() self.doReplace.setChecked(self.mainConf.doReplace) self.doReplace.toggled.connect(self._toggleAutoReplaceMain) self.mainForm.addRow( self.tr("Auto-replace text as you type"), self.doReplace, self.tr("Allow the editor to replace symbols as you type.")) # Replace as You Type # =================== self.mainForm.addGroupLabel(self.tr("Replace as You Type")) ## Auto-Replace Single Quotes self.doReplaceSQuote = QSwitch() self.doReplaceSQuote.setChecked(self.mainConf.doReplaceSQuote) self.doReplaceSQuote.setEnabled(self.mainConf.doReplace) self.mainForm.addRow( self.tr("Auto-replace single quotes"), self.doReplaceSQuote, self.tr( "Try to guess which is an opening or a closing single quote.")) ## Auto-Replace Double Quotes self.doReplaceDQuote = QSwitch() self.doReplaceDQuote.setChecked(self.mainConf.doReplaceDQuote) self.doReplaceDQuote.setEnabled(self.mainConf.doReplace) self.mainForm.addRow( self.tr("Auto-replace double quotes"), self.doReplaceDQuote, self.tr( "Try to guess which is an opening or a closing double quote.")) ## Auto-Replace Hyphens self.doReplaceDash = QSwitch() self.doReplaceDash.setChecked(self.mainConf.doReplaceDash) self.doReplaceDash.setEnabled(self.mainConf.doReplace) self.mainForm.addRow( self.tr("Auto-replace dashes"), self.doReplaceDash, self.tr("Double and triple hyphens become short and long dashes.")) ## Auto-Replace Dots self.doReplaceDots = QSwitch() self.doReplaceDots.setChecked(self.mainConf.doReplaceDots) self.doReplaceDots.setEnabled(self.mainConf.doReplace) self.mainForm.addRow( self.tr("Auto-replace dots"), self.doReplaceDots, self.tr("Three consecutive dots become ellipsis.")) # Automatic Padding # ================= self.mainForm.addGroupLabel(self.tr("Automatic Padding")) ## Pad Before self.fmtPadBefore = QLineEdit() self.fmtPadBefore.setMaxLength(32) self.fmtPadBefore.setText(self.mainConf.fmtPadBefore) self.mainForm.addRow( self.tr("Insert non-breaking space before"), self.fmtPadBefore, self.tr("Automatically add space before any of these symbols."), ) ## Pad After self.fmtPadAfter = QLineEdit() self.fmtPadAfter.setMaxLength(32) self.fmtPadAfter.setText(self.mainConf.fmtPadAfter) self.mainForm.addRow( self.tr("Insert non-breaking space after"), self.fmtPadAfter, self.tr("Automatically add space after any of these symbols."), ) ## Use Thin Space self.fmtPadThin = QSwitch() self.fmtPadThin.setChecked(self.mainConf.fmtPadThin) self.fmtPadThin.setEnabled(self.mainConf.doReplace) self.mainForm.addRow( self.tr("Use thin space instead"), self.fmtPadThin, self.tr("Inserts a thin space instead of a regular space.")) return
def __init__(self, theParent, theProject): QDialog.__init__(self, theParent) logger.debug("Initialising GuiBuildNovel ...") self.setObjectName("GuiBuildNovel") self.mainConf = nw.CONFIG self.theProject = theProject self.theParent = theParent self.theTheme = theParent.theTheme self.optState = self.theProject.optState self.htmlText = [] # List of html documents self.htmlStyle = [] # List of html styles self.nwdText = [] # List of markdown documents self.buildTime = 0 # The timestamp of the last build self.setWindowTitle("Build Novel Project") self.setMinimumWidth(self.mainConf.pxInt(700)) self.setMinimumHeight(self.mainConf.pxInt(600)) self.resize( self.mainConf.pxInt( self.optState.getInt("GuiBuildNovel", "winWidth", 900)), self.mainConf.pxInt( self.optState.getInt("GuiBuildNovel", "winHeight", 800))) self.docView = GuiBuildNovelDocView(self, self.theProject) # Title Formats # ============= self.titleGroup = QGroupBox("Title Formats for Novel Files", self) self.titleForm = QGridLayout(self) self.titleGroup.setLayout(self.titleForm) fmtHelp = (r"<b>Formatting Codes:</b><br>" r"%title% for the title as set in the document<br>" r"%ch% for chapter number (1, 2, 3)<br>" r"%chw% for chapter number as a word (one, two)<br>" r"%chI% for chapter number in upper case Roman<br>" r"%chi% for chapter number in lower case Roman<br>" r"%sc% for scene number within chapter<br>" r"%sca% for scene number within novel") fmtScHelp = ( r"<br><br>" r"Leave blank to skip this heading, or set to a static text, like " r"for instance '* * *', to make a separator. The separator will " r"be centred automatically and only appear between sections of " r"the same type.") xFmt = self.mainConf.pxInt(100) self.fmtTitle = QLineEdit() self.fmtTitle.setMaxLength(200) self.fmtTitle.setMinimumWidth(xFmt) self.fmtTitle.setToolTip(fmtHelp) self.fmtTitle.setText( self._reFmtCodes(self.theProject.titleFormat["title"])) self.fmtChapter = QLineEdit() self.fmtChapter.setMaxLength(200) self.fmtChapter.setMinimumWidth(xFmt) self.fmtChapter.setToolTip(fmtHelp) self.fmtChapter.setText( self._reFmtCodes(self.theProject.titleFormat["chapter"])) self.fmtUnnumbered = QLineEdit() self.fmtUnnumbered.setMaxLength(200) self.fmtUnnumbered.setMinimumWidth(xFmt) self.fmtUnnumbered.setToolTip(fmtHelp) self.fmtUnnumbered.setText( self._reFmtCodes(self.theProject.titleFormat["unnumbered"])) self.fmtScene = QLineEdit() self.fmtScene.setMaxLength(200) self.fmtScene.setMinimumWidth(xFmt) self.fmtScene.setToolTip(fmtHelp + fmtScHelp) self.fmtScene.setText( self._reFmtCodes(self.theProject.titleFormat["scene"])) self.fmtSection = QLineEdit() self.fmtSection.setMaxLength(200) self.fmtSection.setMinimumWidth(xFmt) self.fmtSection.setToolTip(fmtHelp + fmtScHelp) self.fmtSection.setText( self._reFmtCodes(self.theProject.titleFormat["section"])) # Dummy boxes due to QGridView and QLineEdit expand bug self.boxTitle = QHBoxLayout() self.boxTitle.addWidget(self.fmtTitle) self.boxChapter = QHBoxLayout() self.boxChapter.addWidget(self.fmtChapter) self.boxUnnumbered = QHBoxLayout() self.boxUnnumbered.addWidget(self.fmtUnnumbered) self.boxScene = QHBoxLayout() self.boxScene.addWidget(self.fmtScene) self.boxSection = QHBoxLayout() self.boxSection.addWidget(self.fmtSection) self.titleForm.addWidget(QLabel("Title"), 0, 0, 1, 1, Qt.AlignLeft) self.titleForm.addLayout(self.boxTitle, 0, 1, 1, 1, Qt.AlignRight) self.titleForm.addWidget(QLabel("Chapter"), 1, 0, 1, 1, Qt.AlignLeft) self.titleForm.addLayout(self.boxChapter, 1, 1, 1, 1, Qt.AlignRight) self.titleForm.addWidget(QLabel("Unnumbered"), 2, 0, 1, 1, Qt.AlignLeft) self.titleForm.addLayout(self.boxUnnumbered, 2, 1, 1, 1, Qt.AlignRight) self.titleForm.addWidget(QLabel("Scene"), 3, 0, 1, 1, Qt.AlignLeft) self.titleForm.addLayout(self.boxScene, 3, 1, 1, 1, Qt.AlignRight) self.titleForm.addWidget(QLabel("Section"), 4, 0, 1, 1, Qt.AlignLeft) self.titleForm.addLayout(self.boxSection, 4, 1, 1, 1, Qt.AlignRight) self.titleForm.setColumnStretch(0, 0) self.titleForm.setColumnStretch(1, 1) # Text Options # ============= self.formatGroup = QGroupBox("Formatting Options", self) self.formatForm = QGridLayout(self) self.formatGroup.setLayout(self.formatForm) ## Font Family self.textFont = QLineEdit() self.textFont.setReadOnly(True) self.textFont.setMinimumWidth(xFmt) self.textFont.setText( self.optState.getString("GuiBuildNovel", "textFont", self.mainConf.textFont)) self.fontButton = QPushButton("...") self.fontButton.setMaximumWidth( int(2.5 * self.theTheme.getTextWidth("..."))) self.fontButton.clicked.connect(self._selectFont) self.textSize = QSpinBox(self) self.textSize.setFixedWidth(5 * self.theTheme.textNWidth) self.textSize.setMinimum(6) self.textSize.setMaximum(72) self.textSize.setSingleStep(1) self.textSize.setToolTip( "The size is used for PDF and printing. Other formats have no size set." ) self.textSize.setValue( self.optState.getInt("GuiBuildNovel", "textSize", self.mainConf.textSize)) self.justifyText = QSwitch() self.justifyText.setToolTip( "Applies to PDF, printing, HTML, and Open Document exports.") self.justifyText.setChecked( self.optState.getBool("GuiBuildNovel", "justifyText", False)) self.noStyling = QSwitch() self.noStyling.setToolTip("Disable all styling of the text.") self.noStyling.setChecked( self.optState.getBool("GuiBuildNovel", "noStyling", False)) # Dummy box due to QGridView and QLineEdit expand bug self.boxFont = QHBoxLayout() self.boxFont.addWidget(self.textFont) self.formatForm.addWidget(QLabel("Font family"), 0, 0, 1, 1, Qt.AlignLeft) self.formatForm.addLayout(self.boxFont, 0, 1, 1, 1, Qt.AlignRight) self.formatForm.addWidget(self.fontButton, 0, 2, 1, 1, Qt.AlignRight) self.formatForm.addWidget(QLabel("Font size"), 1, 0, 1, 1, Qt.AlignLeft) self.formatForm.addWidget(self.textSize, 1, 1, 1, 2, Qt.AlignRight) self.formatForm.addWidget(QLabel("Justify text"), 2, 0, 1, 1, Qt.AlignLeft) self.formatForm.addWidget(self.justifyText, 2, 1, 1, 2, Qt.AlignRight) self.formatForm.addWidget(QLabel("Disable styling"), 3, 0, 1, 1, Qt.AlignLeft) self.formatForm.addWidget(self.noStyling, 3, 1, 1, 2, Qt.AlignRight) self.formatForm.setColumnStretch(0, 0) self.formatForm.setColumnStretch(1, 1) self.formatForm.setColumnStretch(2, 0) # Include Switches # ================ self.textGroup = QGroupBox("Text Options", self) self.textForm = QGridLayout(self) self.textGroup.setLayout(self.textForm) self.includeSynopsis = QSwitch() self.includeSynopsis.setToolTip( "Include synopsis comments in the output.") self.includeSynopsis.setChecked( self.optState.getBool("GuiBuildNovel", "incSynopsis", False)) self.includeComments = QSwitch() self.includeComments.setToolTip( "Include plain comments in the output.") self.includeComments.setChecked( self.optState.getBool("GuiBuildNovel", "incComments", False)) self.includeKeywords = QSwitch() self.includeKeywords.setToolTip( "Include meta keywords (tags, references) in the output.") self.includeKeywords.setChecked( self.optState.getBool("GuiBuildNovel", "incKeywords", False)) self.includeBody = QSwitch() self.includeBody.setToolTip("Include body text in the output.") self.includeBody.setChecked( self.optState.getBool("GuiBuildNovel", "incBodyText", True)) self.textForm.addWidget(QLabel("Include synopsis"), 0, 0, 1, 1, Qt.AlignLeft) self.textForm.addWidget(self.includeSynopsis, 0, 1, 1, 1, Qt.AlignRight) self.textForm.addWidget(QLabel("Include comments"), 1, 0, 1, 1, Qt.AlignLeft) self.textForm.addWidget(self.includeComments, 1, 1, 1, 1, Qt.AlignRight) self.textForm.addWidget(QLabel("Include keywords"), 2, 0, 1, 1, Qt.AlignLeft) self.textForm.addWidget(self.includeKeywords, 2, 1, 1, 1, Qt.AlignRight) self.textForm.addWidget(QLabel("Include body text"), 3, 0, 1, 1, Qt.AlignLeft) self.textForm.addWidget(self.includeBody, 3, 1, 1, 1, Qt.AlignRight) self.textForm.setColumnStretch(0, 1) self.textForm.setColumnStretch(1, 0) # File Filter Options # =================== self.fileGroup = QGroupBox("File Filter Options", self) self.fileForm = QGridLayout(self) self.fileGroup.setLayout(self.fileForm) self.novelFiles = QSwitch() self.novelFiles.setToolTip( "Include files with layouts 'Book', 'Page', 'Partition', " "'Chapter', 'Unnumbered', and 'Scene'.") self.novelFiles.setChecked( self.optState.getBool("GuiBuildNovel", "addNovel", True)) self.noteFiles = QSwitch() self.noteFiles.setToolTip("Include files with layout 'Note'.") self.noteFiles.setChecked( self.optState.getBool("GuiBuildNovel", "addNotes", False)) self.ignoreFlag = QSwitch() self.ignoreFlag.setToolTip( "Ignore the 'Include when building project' setting and include " "all files in the output.") self.ignoreFlag.setChecked( self.optState.getBool("GuiBuildNovel", "ignoreFlag", False)) self.fileForm.addWidget(QLabel("Include novel files"), 0, 0, 1, 1, Qt.AlignLeft) self.fileForm.addWidget(self.novelFiles, 0, 1, 1, 1, Qt.AlignRight) self.fileForm.addWidget(QLabel("Include note files"), 1, 0, 1, 1, Qt.AlignLeft) self.fileForm.addWidget(self.noteFiles, 1, 1, 1, 1, Qt.AlignRight) self.fileForm.addWidget(QLabel("Ignore export flag"), 2, 0, 1, 1, Qt.AlignLeft) self.fileForm.addWidget(self.ignoreFlag, 2, 1, 1, 1, Qt.AlignRight) self.fileForm.setColumnStretch(0, 1) self.fileForm.setColumnStretch(1, 0) # Export Options # ============== self.exportGroup = QGroupBox("Export Options", self) self.exportForm = QGridLayout(self) self.exportGroup.setLayout(self.exportForm) self.replaceTabs = QSwitch() self.replaceTabs.setToolTip("Replace all tabs with eight spaces.") self.replaceTabs.setChecked( self.optState.getBool("GuiBuildNovel", "replaceTabs", False)) self.exportForm.addWidget(QLabel("Replace tabs with spaces"), 0, 0, 1, 1, Qt.AlignLeft) self.exportForm.addWidget(self.replaceTabs, 0, 1, 1, 1, Qt.AlignRight) self.exportForm.setColumnStretch(0, 1) self.exportForm.setColumnStretch(1, 0) # Build Button # ============ self.buildProgress = QProgressBar() self.buildProgress = QProgressBar() self.buildNovel = QPushButton("Build Project") self.buildNovel.clicked.connect(self._buildPreview) # Action Buttons # ============== self.buttonBox = QHBoxLayout() self.btnPrint = QPushButton("Print") self.btnPrint.clicked.connect(self._printDocument) self.btnSave = QPushButton("Save As") self.saveMenu = QMenu(self) self.btnSave.setMenu(self.saveMenu) self.saveODT = QAction("Open Document (.odt)", self) self.saveODT.triggered.connect( lambda: self._saveDocument(self.FMT_ODT)) self.saveMenu.addAction(self.saveODT) self.savePDF = QAction("Portable Document Format (.pdf)", self) self.savePDF.triggered.connect( lambda: self._saveDocument(self.FMT_PDF)) self.saveMenu.addAction(self.savePDF) self.saveHTM = QAction("novelWriter HTML (.htm)", self) self.saveHTM.triggered.connect( lambda: self._saveDocument(self.FMT_HTM)) self.saveMenu.addAction(self.saveHTM) self.saveNWD = QAction("novelWriter Markdown (.nwd)", self) self.saveNWD.triggered.connect( lambda: self._saveDocument(self.FMT_NWD)) self.saveMenu.addAction(self.saveNWD) if self.mainConf.verQtValue >= 51400: self.saveMD = QAction("Markdown (.md)", self) self.saveMD.triggered.connect( lambda: self._saveDocument(self.FMT_MD)) self.saveMenu.addAction(self.saveMD) self.saveTXT = QAction("Plain Text (.txt)", self) self.saveTXT.triggered.connect( lambda: self._saveDocument(self.FMT_TXT)) self.saveMenu.addAction(self.saveTXT) self.saveJsonH = QAction("JSON + novelWriter HTML (.json)", self) self.saveJsonH.triggered.connect( lambda: self._saveDocument(self.FMT_JSON_H)) self.saveMenu.addAction(self.saveJsonH) self.saveJsonM = QAction("JSON + novelWriters Markdown (.json)", self) self.saveJsonM.triggered.connect( lambda: self._saveDocument(self.FMT_JSON_M)) self.saveMenu.addAction(self.saveJsonM) self.btnClose = QPushButton("Close") self.btnClose.clicked.connect(self._doClose) self.buttonBox.addWidget(self.btnSave) self.buttonBox.addWidget(self.btnPrint) self.buttonBox.addWidget(self.btnClose) self.buttonBox.setSpacing(4) # Assemble GUI # ============ # Splitter Position boxWidth = self.mainConf.pxInt(350) boxWidth = self.optState.getInt("GuiBuildNovel", "boxWidth", boxWidth) docWidth = max(self.width() - boxWidth, 100) docWidth = self.optState.getInt("GuiBuildNovel", "docWidth", docWidth) # The Tool Box self.toolsBox = QVBoxLayout() self.toolsBox.addWidget(self.titleGroup) self.toolsBox.addWidget(self.formatGroup) self.toolsBox.addWidget(self.textGroup) self.toolsBox.addWidget(self.fileGroup) self.toolsBox.addWidget(self.exportGroup) self.toolsBox.addStretch(1) # Tool Box Wrapper Widget self.toolsWidget = QWidget() self.toolsWidget.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Minimum) self.toolsWidget.setLayout(self.toolsBox) # Tool Box Scroll Area self.toolsArea = QScrollArea() self.toolsArea.setMinimumWidth(self.mainConf.pxInt(250)) self.toolsArea.setWidgetResizable(True) self.toolsArea.setWidget(self.toolsWidget) if self.mainConf.hideVScroll: self.toolsArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) else: self.toolsArea.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) if self.mainConf.hideHScroll: self.toolsArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) else: self.toolsArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) # Tools and Buttons Layout self.innerBox = QVBoxLayout() self.innerBox.addWidget(self.toolsArea) self.innerBox.addSpacing(8) self.innerBox.addWidget(self.buildProgress) self.innerBox.addWidget(self.buildNovel) self.innerBox.addSpacing(8) self.innerBox.addLayout(self.buttonBox) # Tools and Buttons Wrapper Widget self.innerWidget = QWidget() self.innerWidget.setLayout(self.innerBox) # Main Dialog Splitter self.mainSplit = QSplitter(Qt.Horizontal) self.mainSplit.addWidget(self.innerWidget) self.mainSplit.addWidget(self.docView) self.mainSplit.setSizes([boxWidth, docWidth]) # Outer Layout self.outerBox = QHBoxLayout() self.outerBox.addWidget(self.mainSplit) self.setLayout(self.outerBox) self.buildNovel.setFocus() logger.debug("GuiBuildNovel initialisation complete") return
def __init__(self, theParent): QWidget.__init__(self, theParent) self.mainConf = nw.CONFIG self.theParent = theParent self.theTheme = theParent.theTheme # The Form self.mainForm = QConfigLayout() self.mainForm.setHelpTextStyle(self.theTheme.helpText) self.setLayout(self.mainForm) # Text Style # ========== self.mainForm.addGroupLabel("Text Style") ## Font Family self.textFont = QLineEdit() self.textFont.setReadOnly(True) self.textFont.setFixedWidth(self.mainConf.pxInt(162)) self.textFont.setText(self.mainConf.textFont) self.fontButton = QPushButton("...") self.fontButton.setMaximumWidth( int(2.5 * self.theTheme.getTextWidth("..."))) self.fontButton.clicked.connect(self._selectFont) self.mainForm.addRow("Font family", self.textFont, "Font for the document editor and viewer.", theButton=self.fontButton) ## Font Size self.textSize = QSpinBox(self) self.textSize.setMinimum(8) self.textSize.setMaximum(60) self.textSize.setSingleStep(1) self.textSize.setValue(self.mainConf.textSize) self.mainForm.addRow("Font size", self.textSize, "Font size for the document editor and viewer.", theUnit="pt") # Text Flow # ========= self.mainForm.addGroupLabel("Text Flow") ## Max Text Width in Normal Mode self.textWidth = QSpinBox(self) self.textWidth.setMinimum(300) self.textWidth.setMaximum(10000) self.textWidth.setSingleStep(10) self.textWidth.setValue(self.mainConf.textWidth) self.mainForm.addRow("Maximum text width in \"Normal Mode\"", self.textWidth, "Horizontal margins are scaled automatically.", theUnit="px") ## Max Text Width in Focus Mode self.focusWidth = QSpinBox(self) self.focusWidth.setMinimum(300) self.focusWidth.setMaximum(10000) self.focusWidth.setSingleStep(10) self.focusWidth.setValue(self.mainConf.focusWidth) self.mainForm.addRow("Maximum text width in \"Focus Mode\"", self.focusWidth, "Horizontal margins are scaled automatically.", theUnit="px") ## Document Fixed Width self.textFixedW = QSwitch() self.textFixedW.setChecked(not self.mainConf.textFixedW) self.mainForm.addRow("Disable maximum text width in \"Normal Mode\"", self.textFixedW, "Text width is defined by the margins only.") ## Focus Mode Footer self.hideFocusFooter = QSwitch() self.hideFocusFooter.setChecked(self.mainConf.hideFocusFooter) self.mainForm.addRow( "Hide document footer in \"Focus Mode\"", self.hideFocusFooter, "Hide the information bar at the bottom of the document.") ## Justify Text self.doJustify = QSwitch() self.doJustify.setChecked(self.mainConf.doJustify) self.mainForm.addRow( "Justify the text margins in editor and viewer", self.doJustify, "Lay out text with straight edges in the editor and viewer.") ## Document Margins self.textMargin = QSpinBox(self) self.textMargin.setMinimum(0) self.textMargin.setMaximum(900) self.textMargin.setSingleStep(1) self.textMargin.setValue(self.mainConf.textMargin) self.mainForm.addRow( "Text margin", self.textMargin, "If maximum width is set, this becomes the minimum margin.", theUnit="px") ## Tab Width self.tabWidth = QSpinBox(self) self.tabWidth.setMinimum(0) self.tabWidth.setMaximum(200) self.tabWidth.setSingleStep(1) self.tabWidth.setValue(self.mainConf.tabWidth) self.mainForm.addRow( "Tab width", self.tabWidth, "The width of a tab key press in the editor and viewer.", theUnit="px") return
def __init__(self, theParent): QWidget.__init__(self, theParent) self.mainConf = nw.CONFIG self.theParent = theParent self.theTheme = theParent.theTheme # The Form self.mainForm = QConfigLayout() self.mainForm.setHelpTextStyle(self.theTheme.helpText) self.setLayout(self.mainForm) # Spell Checking # ============== self.mainForm.addGroupLabel("Spell Checking") ## Spell Check Provider and Language self.spellLangList = QComboBox(self) self.spellToolList = QComboBox(self) self.spellToolList.addItem("Internal (difflib)", nwConst.SP_INTERNAL) self.spellToolList.addItem("Spell Enchant (pyenchant)", nwConst.SP_ENCHANT) theModel = self.spellToolList.model() idEnchant = self.spellToolList.findData(nwConst.SP_ENCHANT) theModel.item(idEnchant).setEnabled(self.mainConf.hasEnchant) self.spellToolList.currentIndexChanged.connect(self._doUpdateSpellTool) toolIdx = self.spellToolList.findData(self.mainConf.spellTool) if toolIdx != -1: self.spellToolList.setCurrentIndex(toolIdx) self._doUpdateSpellTool(0) self.mainForm.addRow( "Spell check provider", self.spellToolList, "Note that the internal spell check tool is quite slow.") self.mainForm.addRow( "Spell check language", self.spellLangList, "Available languages are determined by your system.") ## Big Document Size Limit self.bigDocLimit = QSpinBox(self) self.bigDocLimit.setMinimum(10) self.bigDocLimit.setMaximum(10000) self.bigDocLimit.setSingleStep(10) self.bigDocLimit.setValue(self.mainConf.bigDocLimit) self.mainForm.addRow( "Big document limit", self.bigDocLimit, "Full spell checking is disabled above this limit.", theUnit="kB") # Word Count # ========== self.mainForm.addGroupLabel("Word Count") ## Word Count Timer self.wordCountTimer = QDoubleSpinBox(self) self.wordCountTimer.setDecimals(1) self.wordCountTimer.setMinimum(2.0) self.wordCountTimer.setMaximum(600.0) self.wordCountTimer.setSingleStep(0.1) self.wordCountTimer.setValue(self.mainConf.wordCountTimer) self.mainForm.addRow("Word count interval", self.wordCountTimer, "How often the word count is updated.", theUnit="seconds") # Writing Guides # ============== self.mainForm.addGroupLabel("Writing Guides") ## Show Tabs and Spaces self.showTabsNSpaces = QSwitch() self.showTabsNSpaces.setChecked(self.mainConf.showTabsNSpaces) self.mainForm.addRow( "Show tabs and spaces", self.showTabsNSpaces, "Add symbols to indicate tabs and spaces in the editor.") ## Show Line Endings self.showLineEndings = QSwitch() self.showLineEndings.setChecked(self.mainConf.showLineEndings) self.mainForm.addRow( "Show line endings", self.showLineEndings, "Add a symbol to indicate line endings in the editor.") # Scroll Behaviour # ================ self.mainForm.addGroupLabel("Scroll Behaviour") ## Scroll Past End self.scrollPastEnd = QSwitch() self.scrollPastEnd.setChecked(self.mainConf.scrollPastEnd) self.mainForm.addRow( "Scroll past end of the document", self.scrollPastEnd, "Also improves trypewriter scrolling for short documents.") ## Typewriter Scrolling self.autoScroll = QSwitch() self.autoScroll.setChecked(self.mainConf.autoScroll) self.mainForm.addRow( "Typewriter style scrolling when you type", self.autoScroll, "Try to keep the cursor at a fixed vertical position.") ## Typewriter Position self.autoScrollPos = QSpinBox(self) self.autoScrollPos.setMinimum(10) self.autoScrollPos.setMaximum(90) self.autoScrollPos.setSingleStep(1) self.autoScrollPos.setValue(int(self.mainConf.autoScrollPos)) self.mainForm.addRow("Minimum position for Typewriter scrolling", self.autoScrollPos, "Percentage of the editor height from the top.", theUnit="%") return
def __init__(self, theParent, theProject): QWidget.__init__(self, theParent) self.mainConf = nw.CONFIG self.theParent = theParent self.theProject = theProject # The Form self.mainForm = QConfigLayout() self.mainForm.setHelpTextStyle(self.theParent.theTheme.helpText) self.setLayout(self.mainForm) self.mainForm.addGroupLabel("Project Settings") xW = self.mainConf.pxInt(250) xH = self.mainConf.pxInt(100) self.editName = QLineEdit() self.editName.setMaxLength(200) self.editName.setFixedWidth(xW) self.editName.setText(self.theProject.projName) self.mainForm.addRow( "Working title", self.editName, "Should be set only once." ) self.editTitle = QLineEdit() self.editTitle.setMaxLength(200) self.editTitle.setFixedWidth(xW) self.editTitle.setText(self.theProject.bookTitle) self.mainForm.addRow( "Novel title", self.editTitle, "Change whenever you want!" ) self.editAuthors = QPlainTextEdit() bookAuthors = "" for bookAuthor in self.theProject.bookAuthors: bookAuthors += bookAuthor+"\n" self.editAuthors.setPlainText(bookAuthors) self.editAuthors.setFixedHeight(xH) self.editAuthors.setFixedWidth(xW) self.mainForm.addRow( "Author(s)", self.editAuthors, "One name per line." ) self.spellLang = QComboBox(self) theDict = self.theParent.docEditor.theDict self.spellLang.addItem("Default", "None") if theDict is not None: for spTag, spName in theDict.listDictionaries(): self.spellLang.addItem(spName, spTag) self.mainForm.addRow( "Spell check language", self.spellLang, "Overrides main preferences." ) if self.theProject.projLang is None: spellIdx = 0 else: spellIdx = self.spellLang.findData(self.theProject.projLang) if spellIdx != -1: self.spellLang.setCurrentIndex(spellIdx) self.doBackup = QSwitch(self) self.doBackup.setChecked(not self.theProject.doBackup) self.mainForm.addRow( "No backup on close", self.doBackup, "Overrides main preferences." ) return
def __init__(self, theWizard): QWizardPage.__init__(self) self.mainConf = nw.CONFIG self.theWizard = theWizard self.setTitle("Custom Project Options") self.theText = QLabel( "Select which additional root folders to make, and how to populate " "the Novel folder. If you don't want to add chapters or scenes, set " "the values to 0. You can add scenes without chapters.") self.theText.setWordWrap(True) vS = self.mainConf.pxInt(12) # Root Folders self.rootGroup = QGroupBox("Additional Root Folders") self.rootForm = QGridLayout() self.rootGroup.setLayout(self.rootForm) self.lblPlot = QLabel("%s folder" % nwLabels.CLASS_NAME[nwItemClass.PLOT]) self.lblChar = QLabel("%s folder" % nwLabels.CLASS_NAME[nwItemClass.CHARACTER]) self.lblWorld = QLabel("%s folder" % nwLabels.CLASS_NAME[nwItemClass.WORLD]) self.lblTime = QLabel("%s folder" % nwLabels.CLASS_NAME[nwItemClass.TIMELINE]) self.lblObject = QLabel("%s folder" % nwLabels.CLASS_NAME[nwItemClass.OBJECT]) self.lblEntity = QLabel("%s folder" % nwLabels.CLASS_NAME[nwItemClass.ENTITY]) self.addPlot = QSwitch() self.addChar = QSwitch() self.addWorld = QSwitch() self.addTime = QSwitch() self.addObject = QSwitch() self.addEntity = QSwitch() self.addPlot.setChecked(True) self.addChar.setChecked(True) self.addWorld.setChecked(True) self.rootForm.addWidget(self.lblPlot, 0, 0) self.rootForm.addWidget(self.lblChar, 1, 0) self.rootForm.addWidget(self.lblWorld, 2, 0) self.rootForm.addWidget(self.lblTime, 3, 0) self.rootForm.addWidget(self.lblObject, 4, 0) self.rootForm.addWidget(self.lblEntity, 5, 0) self.rootForm.addWidget(self.addPlot, 0, 1, 1, 1, Qt.AlignRight) self.rootForm.addWidget(self.addChar, 1, 1, 1, 1, Qt.AlignRight) self.rootForm.addWidget(self.addWorld, 2, 1, 1, 1, Qt.AlignRight) self.rootForm.addWidget(self.addTime, 3, 1, 1, 1, Qt.AlignRight) self.rootForm.addWidget(self.addObject, 4, 1, 1, 1, Qt.AlignRight) self.rootForm.addWidget(self.addEntity, 5, 1, 1, 1, Qt.AlignRight) self.rootForm.setRowStretch(6, 1) # Novel Options self.novelGroup = QGroupBox("Populate Novel Folder") self.novelForm = QGridLayout() self.novelGroup.setLayout(self.novelForm) self.numChapters = QSpinBox() self.numChapters.setRange(0, 100) self.numChapters.setValue(5) self.numScenes = QSpinBox() self.numScenes.setRange(0, 200) self.numScenes.setValue(5) self.chFolders = QSwitch() self.chFolders.setChecked(True) self.novelForm.addWidget(QLabel("Add chapters"), 0, 0) self.novelForm.addWidget(QLabel("Scenes (per chapter)"), 1, 0) self.novelForm.addWidget(QLabel("Add chapter folders"), 2, 0) self.novelForm.addWidget(self.numChapters, 0, 1, 1, 1, Qt.AlignRight) self.novelForm.addWidget(self.numScenes, 1, 1, 1, 1, Qt.AlignRight) self.novelForm.addWidget(self.chFolders, 2, 1, 1, 1, Qt.AlignRight) self.novelForm.setRowStretch(3, 1) # Wizard Fields self.registerField("addPlot", self.addPlot) self.registerField("addChar", self.addChar) self.registerField("addWorld", self.addWorld) self.registerField("addTime", self.addTime) self.registerField("addObject", self.addObject) self.registerField("addEntity", self.addEntity) self.registerField("numChapters", self.numChapters) self.registerField("numScenes", self.numScenes) self.registerField("chFolders", self.chFolders) # Assemble self.innerBox = QHBoxLayout() self.innerBox.addWidget(self.rootGroup) self.innerBox.addWidget(self.novelGroup) self.outerBox = QVBoxLayout() self.outerBox.setSpacing(vS) self.outerBox.addWidget(self.theText) self.outerBox.addLayout(self.innerBox) self.outerBox.addStretch(1) self.setLayout(self.outerBox) return
def __init__(self, theParent, theProject): QDialog.__init__(self, theParent) logger.debug("Initialising GuiBuildNovel ...") self.setObjectName("GuiBuildNovel") self.mainConf = nw.CONFIG self.theProject = theProject self.theParent = theParent self.theTheme = theParent.theTheme self.optState = self.theProject.optState self.htmlText = [] # List of html documents self.htmlStyle = [] # List of html styles self.htmlSize = 0 # Size of the html document self.buildTime = 0 # The timestamp of the last build self.setWindowTitle(self.tr("Build Novel Project")) self.setMinimumWidth(self.mainConf.pxInt(700)) self.setMinimumHeight(self.mainConf.pxInt(600)) self.resize( self.mainConf.pxInt( self.optState.getInt("GuiBuildNovel", "winWidth", 900)), self.mainConf.pxInt( self.optState.getInt("GuiBuildNovel", "winHeight", 800))) self.docView = GuiBuildNovelDocView(self, self.theProject) hS = self.theTheme.fontPixelSize wS = 2 * hS # Title Formats # ============= self.titleGroup = QGroupBox(self.tr("Title Formats for Novel Files"), self) self.titleForm = QGridLayout(self) self.titleGroup.setLayout(self.titleForm) fmtHelp = "<br>".join([ "<b>%s</b>" % self.tr("Formatting Codes:"), self.tr("{0} for the title as set in the document").format( r"%title%"), self.tr("{0} for chapter number (1, 2, 3)").format(r"%ch%"), self.tr("{0} for chapter number as a word (one, two)").format( r"%chw%"), self.tr("{0} for chapter number in upper case Roman").format( r"%chI%"), self.tr("{0} for chapter number in lower case Roman").format( r"%chi%"), self.tr("{0} for scene number within chapter").format(r"%sc%"), self.tr("{0} for scene number within novel").format(r"%sca%"), ]) fmtScHelp = "<br><br>%s" % self.tr( "Leave blank to skip this heading, or set to a static text, like " "for instance '{0}', to make a separator. The separator will " "be centred automatically and only appear between sections of " "the same type.").format("* * *") xFmt = self.mainConf.pxInt(100) self.fmtTitle = QLineEdit() self.fmtTitle.setMaxLength(200) self.fmtTitle.setMinimumWidth(xFmt) self.fmtTitle.setToolTip(fmtHelp) self.fmtTitle.setText( self._reFmtCodes(self.theProject.titleFormat["title"])) self.fmtChapter = QLineEdit() self.fmtChapter.setMaxLength(200) self.fmtChapter.setMinimumWidth(xFmt) self.fmtChapter.setToolTip(fmtHelp) self.fmtChapter.setText( self._reFmtCodes(self.theProject.titleFormat["chapter"])) self.fmtUnnumbered = QLineEdit() self.fmtUnnumbered.setMaxLength(200) self.fmtUnnumbered.setMinimumWidth(xFmt) self.fmtUnnumbered.setToolTip(fmtHelp) self.fmtUnnumbered.setText( self._reFmtCodes(self.theProject.titleFormat["unnumbered"])) self.fmtScene = QLineEdit() self.fmtScene.setMaxLength(200) self.fmtScene.setMinimumWidth(xFmt) self.fmtScene.setToolTip(fmtHelp + fmtScHelp) self.fmtScene.setText( self._reFmtCodes(self.theProject.titleFormat["scene"])) self.fmtSection = QLineEdit() self.fmtSection.setMaxLength(200) self.fmtSection.setMinimumWidth(xFmt) self.fmtSection.setToolTip(fmtHelp + fmtScHelp) self.fmtSection.setText( self._reFmtCodes(self.theProject.titleFormat["section"])) self.buildLang = QComboBox() self.buildLang.setMinimumWidth(xFmt) theLangs = self.mainConf.listLanguages(self.mainConf.LANG_PROJ) self.buildLang.addItem("[%s]" % self.tr("Not Set"), "None") for langID, langName in theLangs: self.buildLang.addItem(langName, langID) langIdx = self.buildLang.findData(self.theProject.projLang) if langIdx != -1: self.buildLang.setCurrentIndex(langIdx) # Dummy boxes due to QGridView and QLineEdit expand bug self.boxTitle = QHBoxLayout() self.boxTitle.addWidget(self.fmtTitle) self.boxChapter = QHBoxLayout() self.boxChapter.addWidget(self.fmtChapter) self.boxUnnumb = QHBoxLayout() self.boxUnnumb.addWidget(self.fmtUnnumbered) self.boxScene = QHBoxLayout() self.boxScene.addWidget(self.fmtScene) self.boxSection = QHBoxLayout() self.boxSection.addWidget(self.fmtSection) titleLabel = QLabel(self.tr("Title")) chapterLabel = QLabel(self.tr("Chapter")) unnumbLabel = QLabel(self.tr("Unnumbered")) sceneLabel = QLabel(self.tr("Scene")) sectionLabel = QLabel(self.tr("Section")) langLabel = QLabel(self.tr("Language")) self.titleForm.addWidget(titleLabel, 0, 0, 1, 1, Qt.AlignLeft) self.titleForm.addLayout(self.boxTitle, 0, 1, 1, 1, Qt.AlignRight) self.titleForm.addWidget(chapterLabel, 1, 0, 1, 1, Qt.AlignLeft) self.titleForm.addLayout(self.boxChapter, 1, 1, 1, 1, Qt.AlignRight) self.titleForm.addWidget(unnumbLabel, 2, 0, 1, 1, Qt.AlignLeft) self.titleForm.addLayout(self.boxUnnumb, 2, 1, 1, 1, Qt.AlignRight) self.titleForm.addWidget(sceneLabel, 3, 0, 1, 1, Qt.AlignLeft) self.titleForm.addLayout(self.boxScene, 3, 1, 1, 1, Qt.AlignRight) self.titleForm.addWidget(sectionLabel, 4, 0, 1, 1, Qt.AlignLeft) self.titleForm.addLayout(self.boxSection, 4, 1, 1, 1, Qt.AlignRight) self.titleForm.addWidget(langLabel, 5, 0, 1, 1, Qt.AlignLeft) self.titleForm.addWidget(self.buildLang, 5, 1, 1, 1, Qt.AlignRight) self.titleForm.setColumnStretch(0, 0) self.titleForm.setColumnStretch(1, 1) # Font Options # ============ self.fontGroup = QGroupBox(self.tr("Font Options"), self) self.fontForm = QGridLayout(self) self.fontGroup.setLayout(self.fontForm) ## Font Family self.textFont = QLineEdit() self.textFont.setReadOnly(True) self.textFont.setMinimumWidth(xFmt) self.textFont.setText( self.optState.getString("GuiBuildNovel", "textFont", self.mainConf.textFont)) self.fontButton = QPushButton("...") self.fontButton.setMaximumWidth( int(2.5 * self.theTheme.getTextWidth("..."))) self.fontButton.clicked.connect(self._selectFont) self.textSize = QSpinBox(self) self.textSize.setFixedWidth(6 * self.theTheme.textNWidth) self.textSize.setMinimum(6) self.textSize.setMaximum(72) self.textSize.setSingleStep(1) self.textSize.setValue( self.optState.getInt("GuiBuildNovel", "textSize", self.mainConf.textSize)) self.lineHeight = QDoubleSpinBox(self) self.lineHeight.setFixedWidth(6 * self.theTheme.textNWidth) self.lineHeight.setMinimum(0.8) self.lineHeight.setMaximum(3.0) self.lineHeight.setSingleStep(0.05) self.lineHeight.setDecimals(2) self.lineHeight.setValue( self.optState.getFloat("GuiBuildNovel", "lineHeight", 1.15)) # Dummy box due to QGridView and QLineEdit expand bug self.boxFont = QHBoxLayout() self.boxFont.addWidget(self.textFont) fontFamilyLabel = QLabel(self.tr("Font family")) fontSizeLabel = QLabel(self.tr("Font size")) lineHeightLabel = QLabel(self.tr("Line height")) justifyLabel = QLabel(self.tr("Justify text")) stylingLabel = QLabel(self.tr("Disable styling")) self.fontForm.addWidget(fontFamilyLabel, 0, 0, 1, 1, Qt.AlignLeft) self.fontForm.addLayout(self.boxFont, 0, 1, 1, 1, Qt.AlignRight) self.fontForm.addWidget(self.fontButton, 0, 2, 1, 1, Qt.AlignRight) self.fontForm.addWidget(fontSizeLabel, 1, 0, 1, 1, Qt.AlignLeft) self.fontForm.addWidget(self.textSize, 1, 1, 1, 2, Qt.AlignRight) self.fontForm.addWidget(lineHeightLabel, 2, 0, 1, 1, Qt.AlignLeft) self.fontForm.addWidget(self.lineHeight, 2, 1, 1, 2, Qt.AlignRight) self.fontForm.setColumnStretch(0, 0) self.fontForm.setColumnStretch(1, 1) self.fontForm.setColumnStretch(2, 0) # Styling Options # =============== self.styleGroup = QGroupBox(self.tr("Styling Options"), self) self.styleForm = QGridLayout(self) self.styleGroup.setLayout(self.styleForm) self.justifyText = QSwitch(width=wS, height=hS) self.justifyText.setChecked( self.optState.getBool("GuiBuildNovel", "justifyText", False)) self.noStyling = QSwitch(width=wS, height=hS) self.noStyling.setChecked( self.optState.getBool("GuiBuildNovel", "noStyling", False)) self.styleForm.addWidget(justifyLabel, 1, 0, 1, 1, Qt.AlignLeft) self.styleForm.addWidget(self.justifyText, 1, 1, 1, 2, Qt.AlignRight) self.styleForm.addWidget(stylingLabel, 2, 0, 1, 1, Qt.AlignLeft) self.styleForm.addWidget(self.noStyling, 2, 1, 1, 2, Qt.AlignRight) self.styleForm.setColumnStretch(0, 0) self.styleForm.setColumnStretch(1, 1) # Include Options # =============== self.textGroup = QGroupBox(self.tr("Include Options"), self) self.textForm = QGridLayout(self) self.textGroup.setLayout(self.textForm) self.includeSynopsis = QSwitch(width=wS, height=hS) self.includeSynopsis.setChecked( self.optState.getBool("GuiBuildNovel", "incSynopsis", False)) self.includeComments = QSwitch(width=wS, height=hS) self.includeComments.setChecked( self.optState.getBool("GuiBuildNovel", "incComments", False)) self.includeKeywords = QSwitch(width=wS, height=hS) self.includeKeywords.setChecked( self.optState.getBool("GuiBuildNovel", "incKeywords", False)) self.includeBody = QSwitch(width=wS, height=hS) self.includeBody.setChecked( self.optState.getBool("GuiBuildNovel", "incBodyText", True)) synopsisLabel = QLabel(self.tr("Include synopsis")) commentsLabel = QLabel(self.tr("Include comments")) keywordsLabel = QLabel(self.tr("Include keywords")) bodyLabel = QLabel(self.tr("Include body text")) self.textForm.addWidget(synopsisLabel, 0, 0, 1, 1, Qt.AlignLeft) self.textForm.addWidget(self.includeSynopsis, 0, 1, 1, 1, Qt.AlignRight) self.textForm.addWidget(commentsLabel, 1, 0, 1, 1, Qt.AlignLeft) self.textForm.addWidget(self.includeComments, 1, 1, 1, 1, Qt.AlignRight) self.textForm.addWidget(keywordsLabel, 2, 0, 1, 1, Qt.AlignLeft) self.textForm.addWidget(self.includeKeywords, 2, 1, 1, 1, Qt.AlignRight) self.textForm.addWidget(bodyLabel, 3, 0, 1, 1, Qt.AlignLeft) self.textForm.addWidget(self.includeBody, 3, 1, 1, 1, Qt.AlignRight) self.textForm.setColumnStretch(0, 1) self.textForm.setColumnStretch(1, 0) # File Filter Options # =================== self.fileGroup = QGroupBox(self.tr("File Filter Options"), self) self.fileForm = QGridLayout(self) self.fileGroup.setLayout(self.fileForm) self.novelFiles = QSwitch(width=wS, height=hS) self.novelFiles.setToolTip( self.tr("Include files with layouts other than 'Note'.")) self.novelFiles.setChecked( self.optState.getBool("GuiBuildNovel", "addNovel", True)) self.noteFiles = QSwitch(width=wS, height=hS) self.noteFiles.setToolTip(self.tr("Include files with layout 'Note'.")) self.noteFiles.setChecked( self.optState.getBool("GuiBuildNovel", "addNotes", False)) self.ignoreFlag = QSwitch(width=wS, height=hS) self.ignoreFlag.setToolTip( self. tr("Ignore the 'Include when building project' setting and include " "all files in the output.")) self.ignoreFlag.setChecked( self.optState.getBool("GuiBuildNovel", "ignoreFlag", False)) novelLabel = QLabel(self.tr("Include novel files")) notesLabel = QLabel(self.tr("Include note files")) exportLabel = QLabel(self.tr("Ignore export flag")) self.fileForm.addWidget(novelLabel, 0, 0, 1, 1, Qt.AlignLeft) self.fileForm.addWidget(self.novelFiles, 0, 1, 1, 1, Qt.AlignRight) self.fileForm.addWidget(notesLabel, 1, 0, 1, 1, Qt.AlignLeft) self.fileForm.addWidget(self.noteFiles, 1, 1, 1, 1, Qt.AlignRight) self.fileForm.addWidget(exportLabel, 2, 0, 1, 1, Qt.AlignLeft) self.fileForm.addWidget(self.ignoreFlag, 2, 1, 1, 1, Qt.AlignRight) self.fileForm.setColumnStretch(0, 1) self.fileForm.setColumnStretch(1, 0) # Export Options # ============== self.exportGroup = QGroupBox(self.tr("Export Options"), self) self.exportForm = QGridLayout(self) self.exportGroup.setLayout(self.exportForm) self.replaceTabs = QSwitch(width=wS, height=hS) self.replaceTabs.setChecked( self.optState.getBool("GuiBuildNovel", "replaceTabs", False)) self.replaceUCode = QSwitch(width=wS, height=hS) self.replaceUCode.setChecked( self.optState.getBool("GuiBuildNovel", "replaceUCode", False)) tabsLabel = QLabel(self.tr("Replace tabs with spaces")) uCodeLabel = QLabel(self.tr("Replace Unicode in HTML")) self.exportForm.addWidget(tabsLabel, 0, 0, 1, 1, Qt.AlignLeft) self.exportForm.addWidget(self.replaceTabs, 0, 1, 1, 1, Qt.AlignRight) self.exportForm.addWidget(uCodeLabel, 1, 0, 1, 1, Qt.AlignLeft) self.exportForm.addWidget(self.replaceUCode, 1, 1, 1, 1, Qt.AlignRight) self.exportForm.setColumnStretch(0, 1) self.exportForm.setColumnStretch(1, 0) # Build Button # ============ self.buildProgress = QProgressBar() self.buildNovel = QPushButton(self.tr("Build Preview")) self.buildNovel.clicked.connect(self._buildPreview) # Action Buttons # ============== self.buttonBox = QHBoxLayout() # Printing self.printMenu = QMenu(self) self.btnPrint = QPushButton(self.tr("Print")) self.btnPrint.setMenu(self.printMenu) self.printSend = QAction(self.tr("Print Preview"), self) self.printSend.triggered.connect(self._printDocument) self.printMenu.addAction(self.printSend) self.printFile = QAction(self.tr("Print to PDF"), self) self.printFile.triggered.connect( lambda: self._saveDocument(self.FMT_PDF)) self.printMenu.addAction(self.printFile) # Saving to File self.saveMenu = QMenu(self) self.btnSave = QPushButton(self.tr("Save As")) self.btnSave.setMenu(self.saveMenu) self.saveODT = QAction(self.tr("Open Document (.odt)"), self) self.saveODT.triggered.connect( lambda: self._saveDocument(self.FMT_ODT)) self.saveMenu.addAction(self.saveODT) self.saveFODT = QAction(self.tr("Flat Open Document (.fodt)"), self) self.saveFODT.triggered.connect( lambda: self._saveDocument(self.FMT_FODT)) self.saveMenu.addAction(self.saveFODT) self.saveHTM = QAction(self.tr("novelWriter HTML (.htm)"), self) self.saveHTM.triggered.connect( lambda: self._saveDocument(self.FMT_HTM)) self.saveMenu.addAction(self.saveHTM) self.saveNWD = QAction(self.tr("novelWriter Markdown (.nwd)"), self) self.saveNWD.triggered.connect( lambda: self._saveDocument(self.FMT_NWD)) self.saveMenu.addAction(self.saveNWD) self.saveMD = QAction(self.tr("Standard Markdown (.md)"), self) self.saveMD.triggered.connect(lambda: self._saveDocument(self.FMT_MD)) self.saveMenu.addAction(self.saveMD) self.saveGH = QAction(self.tr("GitHub Markdown (.md)"), self) self.saveGH.triggered.connect(lambda: self._saveDocument(self.FMT_GH)) self.saveMenu.addAction(self.saveGH) self.saveJsonH = QAction(self.tr("JSON + novelWriter HTML (.json)"), self) self.saveJsonH.triggered.connect( lambda: self._saveDocument(self.FMT_JSON_H)) self.saveMenu.addAction(self.saveJsonH) self.saveJsonM = QAction( self.tr("JSON + novelWriter Markdown (.json)"), self) self.saveJsonM.triggered.connect( lambda: self._saveDocument(self.FMT_JSON_M)) self.saveMenu.addAction(self.saveJsonM) self.btnClose = QPushButton(self.tr("Close")) self.btnClose.clicked.connect(self._doClose) self.buttonBox.addWidget(self.btnSave) self.buttonBox.addWidget(self.btnPrint) self.buttonBox.addWidget(self.btnClose) self.buttonBox.setSpacing(self.mainConf.pxInt(4)) # Assemble GUI # ============ # Splitter Position boxWidth = self.mainConf.pxInt(350) boxWidth = self.optState.getInt("GuiBuildNovel", "boxWidth", boxWidth) docWidth = max(self.width() - boxWidth, 100) docWidth = self.optState.getInt("GuiBuildNovel", "docWidth", docWidth) # The Tool Box self.toolsBox = QVBoxLayout() self.toolsBox.addWidget(self.titleGroup) self.toolsBox.addWidget(self.fontGroup) self.toolsBox.addWidget(self.styleGroup) self.toolsBox.addWidget(self.textGroup) self.toolsBox.addWidget(self.fileGroup) self.toolsBox.addWidget(self.exportGroup) self.toolsBox.addStretch(1) # Tool Box Wrapper Widget self.toolsWidget = QWidget() self.toolsWidget.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Minimum) self.toolsWidget.setLayout(self.toolsBox) # Tool Box Scroll Area self.toolsArea = QScrollArea() self.toolsArea.setMinimumWidth(self.mainConf.pxInt(250)) self.toolsArea.setWidgetResizable(True) self.toolsArea.setWidget(self.toolsWidget) if self.mainConf.hideVScroll: self.toolsArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) else: self.toolsArea.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) if self.mainConf.hideHScroll: self.toolsArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) else: self.toolsArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) # Tools and Buttons Layout tSp = self.mainConf.pxInt(8) self.innerBox = QVBoxLayout() self.innerBox.addWidget(self.toolsArea) self.innerBox.addSpacing(tSp) self.innerBox.addWidget(self.buildProgress) self.innerBox.addWidget(self.buildNovel) self.innerBox.addSpacing(tSp) self.innerBox.addLayout(self.buttonBox) # Tools and Buttons Wrapper Widget self.innerWidget = QWidget() self.innerWidget.setLayout(self.innerBox) # Main Dialog Splitter self.mainSplit = QSplitter(Qt.Horizontal) self.mainSplit.addWidget(self.innerWidget) self.mainSplit.addWidget(self.docView) self.mainSplit.setSizes([boxWidth, docWidth]) self.idxSettings = self.mainSplit.indexOf(self.innerWidget) self.idxDocument = self.mainSplit.indexOf(self.docView) self.mainSplit.setCollapsible(self.idxSettings, False) self.mainSplit.setCollapsible(self.idxDocument, False) # Outer Layout self.outerBox = QHBoxLayout() self.outerBox.addWidget(self.mainSplit) self.setLayout(self.outerBox) self.buildNovel.setFocus() logger.debug("GuiBuildNovel initialisation complete") return
def __init__(self, theParent, theProject): QWidget.__init__(self, theParent) self.mainConf = nw.CONFIG self.theParent = theParent self.theProject = theProject # The Form self.mainForm = QConfigLayout() self.mainForm.setHelpTextStyle(self.theParent.theTheme.helpText) self.setLayout(self.mainForm) self.mainForm.addGroupLabel(self.tr("Project Settings")) xW = self.mainConf.pxInt(250) xH = round(4.8*self.theParent.theTheme.fontPixelSize) self.editName = QLineEdit() self.editName.setMaxLength(200) self.editName.setMaximumWidth(xW) self.editName.setText(self.theProject.projName) self.mainForm.addRow( self.tr("Working title"), self.editName, self.tr("Should be set only once.") ) self.editTitle = QLineEdit() self.editTitle.setMaxLength(200) self.editTitle.setMaximumWidth(xW) self.editTitle.setText(self.theProject.bookTitle) self.mainForm.addRow( self.tr("Novel title"), self.editTitle, self.tr("Change whenever you want!") ) self.editAuthors = QPlainTextEdit() self.editAuthors.setMaximumHeight(xH) self.editAuthors.setMaximumWidth(xW) self.editAuthors.setPlainText("\n".join(self.theProject.bookAuthors)) self.mainForm.addRow( self.tr("Author(s)"), self.editAuthors, self.tr("One name per line.") ) self.spellLang = QComboBox(self) self.spellLang.setMaximumWidth(xW) theDict = self.theParent.docEditor.theDict self.spellLang.addItem(self.tr("Default"), "None") if theDict is not None: for spTag, spProv in theDict.listDictionaries(): qLocal = QLocale(spTag) spLang = qLocal.nativeLanguageName().title() self.spellLang.addItem("%s [%s]" % (spLang, spProv), spTag) self.mainForm.addRow( self.tr("Spell check language"), self.spellLang, self.tr("Overrides main preferences.") ) spellIdx = 0 if self.theProject.projSpell is not None: spellIdx = self.spellLang.findData(self.theProject.projSpell) if spellIdx != -1: self.spellLang.setCurrentIndex(spellIdx) self.doBackup = QSwitch(self) self.doBackup.setChecked(not self.theProject.doBackup) self.mainForm.addRow( self.tr("No backup on close"), self.doBackup, self.tr("Overrides main preferences.") ) return
def __init__(self, theParent, theProject): QWidget.__init__(self, theParent) self.mainConf = nw.CONFIG self.theParent = theParent self.theProject = theProject self.theTheme = theParent.theTheme self.theIndex = theParent.theIndex self.optState = theProject.optState # Internal self._theToC = [] iPx = self.theTheme.baseIconSize hPx = self.mainConf.pxInt(12) vPx = self.mainConf.pxInt(4) # Contents Tree # ============= self.tocTree = QTreeWidget() self.tocTree.setIconSize(QSize(iPx, iPx)) self.tocTree.setIndentation(0) self.tocTree.setColumnCount(6) self.tocTree.setSelectionMode(QAbstractItemView.NoSelection) self.tocTree.setHeaderLabels([ self.tr("Title"), self.tr("Words"), self.tr("Pages"), self.tr("Page"), self.tr("Progress"), "" ]) treeHeadItem = self.tocTree.headerItem() treeHeadItem.setTextAlignment(self.C_WORDS, Qt.AlignRight) treeHeadItem.setTextAlignment(self.C_PAGES, Qt.AlignRight) treeHeadItem.setTextAlignment(self.C_PAGE, Qt.AlignRight) treeHeadItem.setTextAlignment(self.C_PROG, Qt.AlignRight) treeHeader = self.tocTree.header() treeHeader.setStretchLastSection(True) treeHeader.setMinimumSectionSize(hPx) wCol0 = self.mainConf.pxInt( self.optState.getInt("GuiProjectDetails", "widthCol0", 200)) wCol1 = self.mainConf.pxInt( self.optState.getInt("GuiProjectDetails", "widthCol1", 60)) wCol2 = self.mainConf.pxInt( self.optState.getInt("GuiProjectDetails", "widthCol2", 60)) wCol3 = self.mainConf.pxInt( self.optState.getInt("GuiProjectDetails", "widthCol3", 60)) wCol4 = self.mainConf.pxInt( self.optState.getInt("GuiProjectDetails", "widthCol4", 90)) self.tocTree.setColumnWidth(0, wCol0) self.tocTree.setColumnWidth(1, wCol1) self.tocTree.setColumnWidth(2, wCol2) self.tocTree.setColumnWidth(3, wCol3) self.tocTree.setColumnWidth(4, wCol4) self.tocTree.setColumnWidth(5, hPx) # Options # ======= wordsPerPage = self.optState.getInt("GuiProjectDetails", "wordsPerPage", 350) countFrom = self.optState.getInt("GuiProjectDetails", "countFrom", 1) clearDouble = self.optState.getInt("GuiProjectDetails", "clearDouble", True) wordsHelp = (self.tr( "Typical word count for a 5 by 8 inch book page with 11 pt font is 350." )) offsetHelp = (self.tr("Start counting page numbers from this page.")) dblHelp = (self.tr( "Assume a new chapter or partition always start on an odd numbered page." )) self.wpLabel = QLabel(self.tr("Words per page")) self.wpLabel.setToolTip(wordsHelp) self.wpValue = QSpinBox() self.wpValue.setMinimum(10) self.wpValue.setMaximum(1000) self.wpValue.setSingleStep(10) self.wpValue.setValue(wordsPerPage) self.wpValue.setToolTip(wordsHelp) self.wpValue.valueChanged.connect(self._populateTree) self.poLabel = QLabel(self.tr("Count pages from")) self.poLabel.setToolTip(offsetHelp) self.poValue = QSpinBox() self.poValue.setMinimum(1) self.poValue.setMaximum(9999) self.poValue.setSingleStep(1) self.poValue.setValue(countFrom) self.poValue.setToolTip(offsetHelp) self.poValue.valueChanged.connect(self._populateTree) self.dblLabel = QLabel(self.tr("Clear double pages")) self.dblLabel.setToolTip(dblHelp) self.dblValue = QSwitch(self, 2 * iPx, iPx) self.dblValue.setChecked(clearDouble) self.dblValue.setToolTip(dblHelp) self.dblValue.clicked.connect(self._populateTree) self.optionsBox = QGridLayout() self.optionsBox.addWidget(self.wpLabel, 0, 0) self.optionsBox.addWidget(self.wpValue, 0, 1) self.optionsBox.addWidget(self.dblLabel, 0, 3) self.optionsBox.addWidget(self.dblValue, 0, 4) self.optionsBox.addWidget(self.poLabel, 1, 0) self.optionsBox.addWidget(self.poValue, 1, 1) self.optionsBox.setHorizontalSpacing(hPx) self.optionsBox.setVerticalSpacing(vPx) self.optionsBox.setColumnStretch(2, 1) # Assemble # ======== self.outerBox = QVBoxLayout() self.outerBox.addWidget( QLabel("<b>%s</b>" % self.tr("Table of Contents"))) self.outerBox.addWidget(self.tocTree) self.outerBox.addLayout(self.optionsBox) self.setLayout(self.outerBox) self._prepareData() self._populateTree() return
def __init__(self, theParent, theProject): QDialog.__init__(self, theParent) logger.debug("Initialising GuiWritingStats ...") self.setObjectName("GuiWritingStats") self.mainConf = nw.CONFIG self.theParent = theParent self.theProject = theProject self.theTheme = theParent.theTheme self.optState = theProject.optState self.logData = [] self.filterData = [] self.timeFilter = 0.0 self.wordOffset = 0 self.setWindowTitle("Writing Statistics") self.setMinimumWidth(self.mainConf.pxInt(420)) self.setMinimumHeight(self.mainConf.pxInt(400)) self.resize( self.mainConf.pxInt(self.optState.getInt("GuiWritingStats", "winWidth", 550)), self.mainConf.pxInt(self.optState.getInt("GuiWritingStats", "winHeight", 500)) ) # List Box wCol0 = self.mainConf.pxInt( self.optState.getInt("GuiWritingStats", "widthCol0", 180) ) wCol1 = self.mainConf.pxInt( self.optState.getInt("GuiWritingStats", "widthCol1", 80) ) wCol2 = self.mainConf.pxInt( self.optState.getInt("GuiWritingStats", "widthCol2", 80) ) self.listBox = QTreeWidget() self.listBox.setHeaderLabels(["Session Start", "Length", "Words", "Histogram"]) self.listBox.setIndentation(0) self.listBox.setColumnWidth(self.C_TIME, wCol0) self.listBox.setColumnWidth(self.C_LENGTH, wCol1) self.listBox.setColumnWidth(self.C_COUNT, wCol2) hHeader = self.listBox.headerItem() hHeader.setTextAlignment(self.C_LENGTH, Qt.AlignRight) hHeader.setTextAlignment(self.C_COUNT, Qt.AlignRight) sortValid = (Qt.AscendingOrder, Qt.DescendingOrder) sortCol = self.optState.validIntRange( self.optState.getInt("GuiWritingStats", "sortCol", 0), 0, 2, 0 ) sortOrder = self.optState.validIntTuple( self.optState.getInt("GuiWritingStats", "sortOrder", Qt.DescendingOrder), sortValid, Qt.DescendingOrder ) self.listBox.sortByColumn(sortCol, sortOrder) self.listBox.setSortingEnabled(True) # Word Bar self.barHeight = int(round(0.5*self.theTheme.fontPixelSize)) self.barWidth = self.mainConf.pxInt(200) self.barImage = QPixmap(self.barHeight, self.barHeight) self.barImage.fill(self.palette().highlight().color()) # Session Info self.infoBox = QGroupBox("Sum Totals", self) self.infoForm = QGridLayout(self) self.infoBox.setLayout(self.infoForm) self.labelTotal = QLabel(formatTime(0)) self.labelTotal.setFont(self.theTheme.guiFontFixed) self.labelTotal.setAlignment(Qt.AlignVCenter | Qt.AlignRight) self.labelFilter = QLabel(formatTime(0)) self.labelFilter.setFont(self.theTheme.guiFontFixed) self.labelFilter.setAlignment(Qt.AlignVCenter | Qt.AlignRight) self.novelWords = QLabel("0") self.novelWords.setFont(self.theTheme.guiFontFixed) self.novelWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight) self.notesWords = QLabel("0") self.notesWords.setFont(self.theTheme.guiFontFixed) self.notesWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight) self.totalWords = QLabel("0") self.totalWords.setFont(self.theTheme.guiFontFixed) self.totalWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight) self.infoForm.addWidget(QLabel("Total Time:"), 0, 0) self.infoForm.addWidget(QLabel("Filtered Time:"), 1, 0) self.infoForm.addWidget(QLabel("Novel Word Count:"), 2, 0) self.infoForm.addWidget(QLabel("Notes Word Count:"), 3, 0) self.infoForm.addWidget(QLabel("Total Word Count:"), 4, 0) self.infoForm.addWidget(self.labelTotal, 0, 1) self.infoForm.addWidget(self.labelFilter, 1, 1) self.infoForm.addWidget(self.novelWords, 2, 1) self.infoForm.addWidget(self.notesWords, 3, 1) self.infoForm.addWidget(self.totalWords, 4, 1) self.infoForm.setRowStretch(5, 1) # Filter Options sPx = self.theTheme.baseIconSize self.filterBox = QGroupBox("Filters", self) self.filterForm = QGridLayout(self) self.filterBox.setLayout(self.filterForm) self.incNovel = QSwitch(width=2*sPx, height=sPx) self.incNovel.setChecked( self.optState.getBool("GuiWritingStats", "incNovel", True) ) self.incNovel.clicked.connect(self._updateListBox) self.incNotes = QSwitch(width=2*sPx, height=sPx) self.incNotes.setChecked( self.optState.getBool("GuiWritingStats", "incNotes", True) ) self.incNotes.clicked.connect(self._updateListBox) self.hideZeros = QSwitch(width=2*sPx, height=sPx) self.hideZeros.setChecked( self.optState.getBool("GuiWritingStats", "hideZeros", True) ) self.hideZeros.clicked.connect(self._updateListBox) self.hideNegative = QSwitch(width=2*sPx, height=sPx) self.hideNegative.setChecked( self.optState.getBool("GuiWritingStats", "hideNegative", False) ) self.hideNegative.clicked.connect(self._updateListBox) self.groupByDay = QSwitch(width=2*sPx, height=sPx) self.groupByDay.setChecked( self.optState.getBool("GuiWritingStats", "groupByDay", False) ) self.groupByDay.clicked.connect(self._updateListBox) self.filterForm.addWidget(QLabel("Count novel files"), 0, 0) self.filterForm.addWidget(QLabel("Count note files"), 1, 0) self.filterForm.addWidget(QLabel("Hide zero word count"), 2, 0) self.filterForm.addWidget(QLabel("Hide negative word count"), 3, 0) self.filterForm.addWidget(QLabel("Group entries by day"), 4, 0) self.filterForm.addWidget(self.incNovel, 0, 1) self.filterForm.addWidget(self.incNotes, 1, 1) self.filterForm.addWidget(self.hideZeros, 2, 1) self.filterForm.addWidget(self.hideNegative, 3, 1) self.filterForm.addWidget(self.groupByDay, 4, 1) self.filterForm.setRowStretch(5, 1) # Settings self.histMax = QSpinBox(self) self.histMax.setMinimum(100) self.histMax.setMaximum(100000) self.histMax.setSingleStep(100) self.histMax.setValue( self.optState.getInt("GuiWritingStats", "histMax", 2000) ) self.histMax.valueChanged.connect(self._updateListBox) self.optsBox = QHBoxLayout() self.optsBox.addStretch(1) self.optsBox.addWidget(QLabel("Word count cap for the histogram"), 0) self.optsBox.addWidget(self.histMax, 0) # Buttons self.buttonBox = QDialogButtonBox() self.buttonBox.rejected.connect(self._doClose) self.btnClose = self.buttonBox.addButton(QDialogButtonBox.Close) self.btnClose.setAutoDefault(False) self.btnSave = self.buttonBox.addButton("Save As", QDialogButtonBox.ActionRole) self.btnSave.setAutoDefault(False) self.saveMenu = QMenu(self) self.btnSave.setMenu(self.saveMenu) self.saveJSON = QAction("JSON Data File (.json)", self) self.saveJSON.triggered.connect(lambda: self._saveData(self.FMT_JSON)) self.saveMenu.addAction(self.saveJSON) self.saveCSV = QAction("CSV Data File (.csv)", self) self.saveCSV.triggered.connect(lambda: self._saveData(self.FMT_CSV)) self.saveMenu.addAction(self.saveCSV) # Assemble self.outerBox = QGridLayout() self.outerBox.addWidget(self.listBox, 0, 0, 1, 2) self.outerBox.addLayout(self.optsBox, 1, 0, 1, 2) self.outerBox.addWidget(self.infoBox, 2, 0) self.outerBox.addWidget(self.filterBox, 2, 1) self.outerBox.addWidget(self.buttonBox, 3, 0, 1, 2) self.outerBox.setRowStretch(0, 1) self.setLayout(self.outerBox) logger.debug("GuiWritingStats initialisation complete") return
def __init__(self, theParent): QWidget.__init__(self, theParent) self.mainConf = nw.CONFIG self.theParent = theParent self.theTheme = theParent.theTheme # The Form self.mainForm = QConfigLayout() self.mainForm.setHelpTextStyle(self.theTheme.helpText) self.setLayout(self.mainForm) # Highlighting Theme # ================== self.mainForm.addGroupLabel("Highlighting Theme") self.guiSyntax = QComboBox() self.guiSyntax.setMinimumWidth(self.mainConf.pxInt(200)) self.theSyntaxes = self.theTheme.listSyntax() for syntaxFile, syntaxName in self.theSyntaxes: self.guiSyntax.addItem(syntaxName, syntaxFile) syntaxIdx = self.guiSyntax.findData(self.mainConf.guiSyntax) if syntaxIdx != -1: self.guiSyntax.setCurrentIndex(syntaxIdx) self.mainForm.addRow( "Highlighting theme", self.guiSyntax, "Colour theme to apply to the editor and viewer.") # Quotes & Dialogue # ================= self.mainForm.addGroupLabel("Quotes & Dialogue") self.highlightQuotes = QSwitch() self.highlightQuotes.setChecked(self.mainConf.highlightQuotes) self.highlightQuotes.toggled.connect(self._toggleHighlightQuotes) self.mainForm.addRow("Highlight text wrapped in quotes", self.highlightQuotes, "Applies to single, double and straight quotes.") self.allowOpenSQuote = QSwitch() self.allowOpenSQuote.setChecked(self.mainConf.allowOpenSQuote) self.mainForm.addRow( "Allow open-ended single quotes", self.allowOpenSQuote, "Highlight single-quoted line with no closing quote.") self.allowOpenDQuote = QSwitch() self.allowOpenDQuote.setChecked(self.mainConf.allowOpenDQuote) self.mainForm.addRow( "Allow open-ended double quotes", self.allowOpenDQuote, "Highlight double-quoted line with no closing quote.") # Text Emphasis # ============= self.mainForm.addGroupLabel("Text Emphasis") self.highlightEmph = QSwitch() self.highlightEmph.setChecked(self.mainConf.highlightEmph) self.mainForm.addRow( "Add highlight colour to emphasised text", self.highlightEmph, "Applies to emphasis (italic) and strong (bold).") return
def __init__(self, theParent, theProject, tHandle): QDialog.__init__(self, theParent) logger.debug("Initialising GuiItemEditor ...") self.setObjectName("GuiItemEditor") self.mainConf = nw.CONFIG self.theProject = theProject self.theParent = theParent ## # Build GUI ## self.theItem = self.theProject.projTree[tHandle] if self.theItem is None: self._doClose() self.setWindowTitle("Item Settings") mVd = self.mainConf.pxInt(220) mSp = self.mainConf.pxInt(16) vSp = self.mainConf.pxInt(4) # Item Label self.editName = QLineEdit() self.editName.setMinimumWidth(mVd) self.editName.setMaxLength(200) # Item Status self.editStatus = QComboBox() self.editStatus.setMinimumWidth(mVd) if self.theItem.itemClass in nwLists.CLS_NOVEL: for sLabel, _, _ in self.theProject.statusItems: self.editStatus.addItem(self.theParent.statusIcons[sLabel], sLabel, sLabel) else: for sLabel, _, _ in self.theProject.importItems: self.editStatus.addItem(self.theParent.importIcons[sLabel], sLabel, sLabel) # Item Layout self.editLayout = QComboBox() self.editLayout.setMinimumWidth(mVd) validLayouts = [] if self.theItem.itemType == nwItemType.FILE: if self.theItem.itemClass in nwLists.CLS_NOVEL: validLayouts.append(nwItemLayout.TITLE) validLayouts.append(nwItemLayout.BOOK) validLayouts.append(nwItemLayout.PAGE) validLayouts.append(nwItemLayout.PARTITION) validLayouts.append(nwItemLayout.UNNUMBERED) validLayouts.append(nwItemLayout.CHAPTER) validLayouts.append(nwItemLayout.SCENE) validLayouts.append(nwItemLayout.NOTE) else: validLayouts.append(nwItemLayout.NO_LAYOUT) self.editLayout.setEnabled(False) for itemLayout in nwItemLayout: if itemLayout in validLayouts: self.editLayout.addItem(nwLabels.LAYOUT_NAME[itemLayout], itemLayout) # Export Switch self.textExport = QLabel("Include when building project") self.editExport = QSwitch() if self.theItem.itemType == nwItemType.FILE: self.editExport.setEnabled(True) self.editExport.setChecked(self.theItem.isExported) else: self.editExport.setEnabled(False) self.editExport.setChecked(False) # Buttons self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.buttonBox.accepted.connect(self._doSave) self.buttonBox.rejected.connect(self._doClose) # Set Current Values self.editName.setText(self.theItem.itemName) self.editName.selectAll() statusIdx = self.editStatus.findData(self.theItem.itemStatus) if statusIdx != -1: self.editStatus.setCurrentIndex(statusIdx) layoutIdx = self.editLayout.findData(self.theItem.itemLayout) if layoutIdx != -1: self.editLayout.setCurrentIndex(layoutIdx) ## # Assemble ## self.mainForm = QGridLayout() self.mainForm.setVerticalSpacing(vSp) self.mainForm.setHorizontalSpacing(mSp) self.mainForm.addWidget(QLabel("Label"), 0, 0, 1, 1) self.mainForm.addWidget(self.editName, 0, 1, 1, 2) self.mainForm.addWidget(QLabel("Status"), 1, 0, 1, 1) self.mainForm.addWidget(self.editStatus, 1, 1, 1, 2) self.mainForm.addWidget(QLabel("Layout"), 2, 0, 1, 1) self.mainForm.addWidget(self.editLayout, 2, 1, 1, 2) self.mainForm.addWidget(self.textExport, 3, 0, 1, 2) self.mainForm.addWidget(self.editExport, 3, 2, 1, 1) self.mainForm.setColumnStretch(0, 0) self.mainForm.setColumnStretch(1, 1) self.mainForm.setColumnStretch(2, 0) self.outerBox = QVBoxLayout() self.outerBox.setSpacing(mSp) self.outerBox.addLayout(self.mainForm) self.outerBox.addStretch(1) self.outerBox.addWidget(self.buttonBox) self.setLayout(self.outerBox) self.rejected.connect(self._doClose) logger.debug("GuiItemEditor initialisation complete") return
def __init__(self, theParent): QWidget.__init__(self, theParent) self.mainConf = nw.CONFIG self.theParent = theParent self.theTheme = theParent.theTheme # The Form self.mainForm = QConfigLayout() self.mainForm.setHelpTextStyle(self.theTheme.helpText) self.setLayout(self.mainForm) # Automatic Save # ============== self.mainForm.addGroupLabel(self.tr("Automatic Save")) ## Document Save Timer self.autoSaveDoc = QSpinBox(self) self.autoSaveDoc.setMinimum(5) self.autoSaveDoc.setMaximum(600) self.autoSaveDoc.setSingleStep(1) self.autoSaveDoc.setValue(self.mainConf.autoSaveDoc) self.mainForm.addRow( self.tr("Save document interval"), self.autoSaveDoc, self.tr("How often the open document is automatically saved."), theUnit=self.tr("seconds")) ## Project Save Timer self.autoSaveProj = QSpinBox(self) self.autoSaveProj.setMinimum(5) self.autoSaveProj.setMaximum(600) self.autoSaveProj.setSingleStep(1) self.autoSaveProj.setValue(self.mainConf.autoSaveProj) self.mainForm.addRow( self.tr("Save project interval"), self.autoSaveProj, self.tr("How often the open project is automatically saved."), theUnit=self.tr("seconds")) # Project Backup # ============== self.mainForm.addGroupLabel(self.tr("Project Backup")) ## Backup Path self.backupPath = self.mainConf.backupPath self.backupGetPath = QPushButton(self.tr("Browse")) self.backupGetPath.clicked.connect(self._backupFolder) self.backupPathRow = self.mainForm.addRow( self.tr("Backup storage location"), self.backupGetPath, self.tr("Path: {0}").format(self.backupPath)) ## Run when closing self.backupOnClose = QSwitch() self.backupOnClose.setChecked(self.mainConf.backupOnClose) self.backupOnClose.toggled.connect(self._toggledBackupOnClose) self.mainForm.addRow( self.tr("Run backup when the project is closed"), self.backupOnClose, self. tr("Can be overridden for individual projects in Project Settings." )) ## Ask before backup ## Only enabled when "Run when closing" is checked self.askBeforeBackup = QSwitch() self.askBeforeBackup.setChecked(self.mainConf.askBeforeBackup) self.askBeforeBackup.setEnabled(self.mainConf.backupOnClose) self.mainForm.addRow( self.tr("Ask before running backup"), self.askBeforeBackup, self.tr("If off, backups will run in the background.")) # Session Timer # ============= self.mainForm.addGroupLabel(self.tr("Session Timer")) ## Pause when idle self.stopWhenIdle = QSwitch() self.stopWhenIdle.setChecked(self.mainConf.stopWhenIdle) self.mainForm.addRow( self.tr("Pause the session timer when not writing"), self.stopWhenIdle, self. tr("Also pauses when the application window does not have focus.")) ## Inactive time for idle self.userIdleTime = QDoubleSpinBox() self.userIdleTime.setMinimum(0.5) self.userIdleTime.setMaximum(600.0) self.userIdleTime.setSingleStep(0.5) self.userIdleTime.setDecimals(1) self.userIdleTime.setValue(self.mainConf.userIdleTime / 60.0) self.mainForm.addRow( self.tr("Editor inactive time before pausing timer"), self.userIdleTime, self.tr("User activity includes typing and changing the content."), theUnit=self.tr("minutes")) return