diff --git a/CHANGELOG.md b/CHANGELOG.md index 349eb66d..05ebb4f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ * The Session Log dialog, now named Writing Statistics, has been redesigned and now has a few more filter options. This update also fixes the filtered time count properly. The dialog now shows a histogram of words added in a given session, or optionally, on a given date. The filtered log data can also be saved as a JSON or CSV file, the latter suitable for importing to a spread sheet. The new dialog tool required a new session log file format, so the new session log has been given a new file name. The old log file will be left untouched in the project's `meta` folder. For projects created prior to this change, the log will record a word count offset that will be subtracted from the first entry such that the first word diff will always be 1 instead of the total word count of the entire project. Such a large word diff would otherwise saturate the histogram. PRs #339 and #349. * The document editor panel has received a footer bar like the one recently added to the document view panel. The footer bar currently shows the status level of the document, and the document word count. In addition, the word counter shows the change in count for the current session in the same way project word count and change is shown in the status bar. The document word count has been removed from the main window status bar. PR #348. -* The document editor footer can optionally be hidden in Distraction Free (Zen) mode. PR #351. +* The document editor footer can optionally be hidden in Distraction Free mode. PR #351. * The Italic and Bold menu entries have been renamed to Emphasis and Strong Emphasis, which is more in line with what they represent in Markdown and HTML. They are still renderred as Italic and Bold in the document viewer, but the HTML export is using the `` and `` tags. PR #350. * Due to several issues with the formatting of emphasised text using `*`, `**`, and `***` wrappers, especially when using nested emphasis, the syntax for emphasis (italic) and strong (bold) has been reverted to use `_` and `**` wrapping, respectively. This removes the ambiguity, and resolves the corner cases. It was possible to resolve the issues by using a custom written parser that takes care of all valid combinations, but such a parser would be a bit too slow for use in syntax highlighting. I decided therefore to stick with RegEx parsing, and keeping those RegExes as short and fast as possible while enforcing the basic formatting rules. Separating the notation for emphasis and strong is commonly recommended when writing Markdown anyway, so it is a sensible compromise between speed and flexibility. This PR partially reverses PR #310. Issue #353, PR #355. * The syntax highlighter now properly highlights overlapping formattings, including emphasised text inside of highlighted quotes. PR #355. diff --git a/docs/source/interface.rst b/docs/source/interface.rst index 38f05417..2cf0cc15 100644 --- a/docs/source/interface.rst +++ b/docs/source/interface.rst @@ -172,7 +172,7 @@ These are as following: ":kbd:`F5`", "Open the Build Novel Project dialog." ":kbd:`F6`", "Open the Writing Statistics dialog." ":kbd:`F7`", "Re-run spell checker." - ":kbd:`F8`", "Activate Zen Mode, hiding project tree and view panel." + ":kbd:`F8`", "Activate Focus Mode, hiding project tree and view panel." ":kbd:`F9`", "Re-build project index." ":kbd:`F10`", "Re-build project outline." ":kbd:`F11`", "Activate full screen mode." diff --git a/nw/__init__.py b/nw/__init__.py index b96147f5..c8a46a2d 100644 --- a/nw/__init__.py +++ b/nw/__init__.py @@ -217,13 +217,13 @@ def main(sysArgs=None): logger.addHandler(cHandle) logger.setLevel(debugLevel) - logger.info("Starting %s" % __package__) - logger.info("Version: %s (%s)" % (__version__, __hexversion__)) - logger.info("Last Release: %s" % __date__) + logger.info("Starting %s %s (%s) %s" % ( + __package__, __version__, __hexversion__, __date__ + )) # Check Packages and Versions errorData = [] - if sys.hexversion < 0x030403F0: + if sys.hexversion < 0x030403f0: errorData.append( "At least Python 3.4.3 is required, but 3.6 is highly recommended." ) @@ -235,10 +235,12 @@ def main(sysArgs=None): errorData.append( "At least PyQt5 version 5.2 is required, found %s." % CONFIG.verPyQtString ) + try: import PyQt5.QtSvg except: errorData.append("Python module 'PyQt5.QtSvg' is missing.") + try: import lxml except: diff --git a/nw/config.py b/nw/config.py index 33cae9f1..cbd79d17 100644 --- a/nw/config.py +++ b/nw/config.py @@ -111,8 +111,8 @@ class Config: self.textWidth = 600 self.textMargin = 40 self.tabWidth = 40 - self.zenWidth = 800 - self.hideZenFooter = False + self.focusWidth = 800 + self.hideFocusFooter = False self.doJustify = False self.autoSelect = True self.doReplace = True @@ -416,11 +416,11 @@ class Config: self.tabWidth = self._parseLine( cnfParse, cnfSec, "tabwidth", self.CNF_INT, self.tabWidth ) - self.zenWidth = self._parseLine( - cnfParse, cnfSec, "zenwidth", self.CNF_INT, self.zenWidth + self.focusWidth = self._parseLine( + cnfParse, cnfSec, "focuswidth", self.CNF_INT, self.focusWidth ) - self.hideZenFooter = self._parseLine( - cnfParse, cnfSec, "hidezenfooter", self.CNF_BOOL, self.hideZenFooter + self.hideFocusFooter = self._parseLine( + cnfParse, cnfSec, "hidefocusfooter", self.CNF_BOOL, self.hideFocusFooter ) self.doJustify = self._parseLine( cnfParse, cnfSec, "justify", self.CNF_BOOL, self.doJustify @@ -576,8 +576,8 @@ class Config: cnfParse.set(cnfSec,"width", str(self.textWidth)) cnfParse.set(cnfSec,"margin", str(self.textMargin)) cnfParse.set(cnfSec,"tabwidth", str(self.tabWidth)) - cnfParse.set(cnfSec,"zenwidth", str(self.zenWidth)) - cnfParse.set(cnfSec,"hidezenfooter", str(self.hideZenFooter)) + cnfParse.set(cnfSec,"focuswidth", str(self.focusWidth)) + cnfParse.set(cnfSec,"hidefocusfooter", str(self.hideFocusFooter)) cnfParse.set(cnfSec,"justify", str(self.doJustify)) cnfParse.set(cnfSec,"autoselect", str(self.autoSelect)) cnfParse.set(cnfSec,"autoreplace", str(self.doReplace)) @@ -839,8 +839,8 @@ class Config: def getTabWidth(self): return self.pxInt(self.tabWidth) - def getZenWidth(self): - return self.pxInt(self.zenWidth) + def getFocusWidth(self): + return self.pxInt(self.focusWidth) ## # Internal Functions diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index 97189307..cba62c16 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -322,7 +322,7 @@ class GuiDocEditor(QTextEdit): def updateDocMargins(self): """Automatically adjust the margins so the text is centred if - Config.textFixedW is enabled or we're in Zen mode. Otherwise, + Config.textFixedW is enabled or we're in Focus Mode. Otherwise, just ensure the margins are set correctly. """ wW = self.width() @@ -334,9 +334,9 @@ class GuiDocEditor(QTextEdit): else: sW = 0 - if self.mainConf.textFixedW or self.theParent.isZenMode: - if self.theParent.isZenMode: - tW = self.mainConf.getZenWidth() + if self.mainConf.textFixedW or self.theParent.isFocusMode: + if self.theParent.isFocusMode: + tW = self.mainConf.getFocusWidth() else: tW = self.mainConf.getTextWidth() tM = (wW - sW - tW)//2 @@ -1414,6 +1414,7 @@ class GuiDocEditSearch(QFrame): self.showReplace = QToolButton(self) self.showReplace.setArrowType(Qt.RightArrow) self.showReplace.setCheckable(True) + self.showReplace.setToolTip("Show/hide the replace text box") self.showReplace.setStyleSheet(r"QToolButton {border: none; background: transparent;}") self.showReplace.toggled.connect(self._doToggleReplace) @@ -1700,6 +1701,7 @@ class GuiDocEditHeader(QWidget): self.minmaxButton.setStyleSheet(buttonStyle) self.minmaxButton.setToolButtonStyle(Qt.ToolButtonIconOnly) self.minmaxButton.setVisible(False) + self.minmaxButton.setToolTip("Toggle Focus Mode") self.minmaxButton.clicked.connect(self._minmaxDocument) self.closeButton = QToolButton(self) @@ -1710,6 +1712,7 @@ class GuiDocEditHeader(QWidget): self.closeButton.setStyleSheet(buttonStyle) self.closeButton.setToolButtonStyle(Qt.ToolButtonIconOnly) self.closeButton.setVisible(False) + self.closeButton.setToolTip("Close the document") self.closeButton.clicked.connect(self._closeDocument) # Assemble Layout @@ -1772,10 +1775,10 @@ class GuiDocEditHeader(QWidget): return def _minmaxDocument(self): - """Switch on or off zen mode. + """Switch on or off Focus Mode. """ - self.theParent.toggleZenMode() - if self.theParent.isZenMode: + self.theParent.toggleFocusMode() + if self.theParent.isFocusMode: self.minmaxButton.setIcon(self.theTheme.getIcon("minimise")) self.setContentsMargins(self.buttonSize, 0, 0, 0) self.closeButton.setVisible(False) diff --git a/nw/gui/docviewer.py b/nw/gui/docviewer.py index 863d2bf6..f20d9082 100644 --- a/nw/gui/docviewer.py +++ b/nw/gui/docviewer.py @@ -229,7 +229,7 @@ class GuiDocViewer(QTextBrowser): def updateDocMargins(self): """Automatically adjust the margins so the text is centred if - Config.textFixedW is enabled or we're in Zen mode. Otherwise, + Config.textFixedW is enabled or we're in Focus Mode. Otherwise, just ensure the margins are set correctly. """ vBar = self.verticalScrollBar() @@ -449,16 +449,6 @@ class GuiDocViewHeader(QWidget): ).format(*self.theTheme.colText) # Buttons - self.closeButton = QToolButton(self) - self.closeButton.setIcon(self.theTheme.getIcon("close")) - self.closeButton.setContentsMargins(0, 0, 0, 0) - self.closeButton.setIconSize(QSize(fPx, fPx)) - self.closeButton.setFixedSize(fPx, fPx) - self.closeButton.setStyleSheet(buttonStyle) - self.closeButton.setToolButtonStyle(Qt.ToolButtonIconOnly) - self.closeButton.setVisible(False) - self.closeButton.clicked.connect(self._closeDocument) - self.refreshButton = QToolButton(self) self.refreshButton.setIcon(self.theTheme.getIcon("refresh")) self.refreshButton.setContentsMargins(0, 0, 0, 0) @@ -467,8 +457,20 @@ class GuiDocViewHeader(QWidget): self.refreshButton.setStyleSheet(buttonStyle) self.refreshButton.setToolButtonStyle(Qt.ToolButtonIconOnly) self.refreshButton.setVisible(False) + self.refreshButton.setToolTip("Reload the document") self.refreshButton.clicked.connect(self._refreshDocument) + self.closeButton = QToolButton(self) + self.closeButton.setIcon(self.theTheme.getIcon("close")) + self.closeButton.setContentsMargins(0, 0, 0, 0) + self.closeButton.setIconSize(QSize(fPx, fPx)) + self.closeButton.setFixedSize(fPx, fPx) + self.closeButton.setStyleSheet(buttonStyle) + self.closeButton.setToolButtonStyle(Qt.ToolButtonIconOnly) + self.closeButton.setVisible(False) + self.closeButton.setToolTip("Close the document") + self.closeButton.clicked.connect(self._closeDocument) + # Assemble Layout self.outerBox = QHBoxLayout() self.outerBox.setSpacing(hSp) @@ -593,6 +595,7 @@ class GuiDocViewFooter(QWidget): self.showHide.setIconSize(QSize(fPx, fPx)) self.showHide.setFixedSize(QSize(fPx, fPx)) self.showHide.clicked.connect(self._doShowHide) + self.showHide.setToolTip("Show/hide the reference panel") # Sticky Button stickyOn = self.theTheme.getPixmap("sticky-on", (fPx, fPx)) @@ -608,6 +611,9 @@ class GuiDocViewFooter(QWidget): self.stickyRefs.setIconSize(QSize(fPx, fPx)) self.stickyRefs.setFixedSize(QSize(fPx, fPx)) self.stickyRefs.toggled.connect(self._doToggleSticky) + self.stickyRefs.setToolTip( + "Activate to freeze the content of the references panel when changing document" + ) # Labels self.lblRefs = QLabel("References") diff --git a/nw/gui/mainmenu.py b/nw/gui/mainmenu.py index 5cdbf55a..911e4153 100644 --- a/nw/gui/mainmenu.py +++ b/nw/gui/mainmenu.py @@ -50,9 +50,10 @@ class GuiMainMenu(QMenuBar): self._buildProjectMenu() self._buildDocumentMenu() self._buildEditMenu() + self._buildViewMenu() self._buildInsertMenu() self._buildFormatMenu() - self._buildViewMenu() + self._buildSearchMenu() self._buildToolsMenu() self._buildHelpMenu() @@ -200,13 +201,6 @@ class GuiMainMenu(QMenuBar): self.aProjectSettings.triggered.connect(self.theParent.editProjectDialog) self.projMenu.addAction(self.aProjectSettings) - # Project > Export Project - self.aBuildProject = QAction("Build Project", self) - self.aBuildProject.setStatusTip("Build project") - self.aBuildProject.setShortcut("F5") - self.aBuildProject.triggered.connect(self.theParent.buildProjectDialog) - self.projMenu.addAction(self.aBuildProject) - # Project > Separator self.projMenu.addSeparator() @@ -399,53 +393,6 @@ class GuiMainMenu(QMenuBar): # Edit > Separator self.editMenu.addSeparator() - # Edit > Find - self.aEditFind = QAction("Find", self) - self.aEditFind.setStatusTip("Find text in document") - self.aEditFind.setShortcut("Ctrl+F") - self.aEditFind.triggered.connect(lambda: self._docAction(nwDocAction.FIND)) - self.editMenu.addAction(self.aEditFind) - - # Edit > Replace - self.aEditReplace = QAction("Replace", self) - self.aEditReplace.setStatusTip("Replace text in document") - if self.mainConf.osDarwin: - self.aEditReplace.setShortcut("Ctrl+=") - else: - self.aEditReplace.setShortcut("Ctrl+H") - self.aEditReplace.triggered.connect(lambda: self._docAction(nwDocAction.REPLACE)) - self.editMenu.addAction(self.aEditReplace) - - # Edit > Find Next - self.aFindNext = QAction("Find Next", self) - self.aFindNext.setStatusTip("Find next occurrence text in document") - if self.mainConf.osDarwin: - self.aFindNext.setShortcuts(["Ctrl+G","F3"]) - else: - self.aFindNext.setShortcuts(["F3","Ctrl+G"]) - self.aFindNext.triggered.connect(lambda: self._docAction(nwDocAction.GO_NEXT)) - self.editMenu.addAction(self.aFindNext) - - # Edit > Find Prev - self.aFindPrev = QAction("Find Previous", self) - self.aFindPrev.setStatusTip("Find previous occurrence text in document") - if self.mainConf.osDarwin: - self.aFindPrev.setShortcuts(["Ctrl+Shift+G","Shift+F3"]) - else: - self.aFindPrev.setShortcuts(["Shift+F3","Ctrl+Shift+G"]) - self.aFindPrev.triggered.connect(lambda: self._docAction(nwDocAction.GO_PREV)) - self.editMenu.addAction(self.aFindPrev) - - # Edit > Replace Next - self.aReplaceNext = QAction("Replace Next", self) - self.aReplaceNext.setStatusTip("Find and replace next occurrence text in document") - self.aReplaceNext.setShortcut("Ctrl+Shift+1") - self.aReplaceNext.triggered.connect(lambda: self._docAction(nwDocAction.REPL_NEXT)) - self.editMenu.addAction(self.aReplaceNext) - - # Edit > Separator - self.editMenu.addSeparator() - # Edit > Select All self.aSelectAll = QAction("Select All", self) self.aSelectAll.setStatusTip("Select all text in document") @@ -462,6 +409,53 @@ class GuiMainMenu(QMenuBar): return + def _buildViewMenu(self): + + # View + self.viewMenu = self.addMenu("&View") + + # View > TreeView + self.aFocusTree = QAction("Focus Project Tree", self) + self.aFocusTree.setStatusTip("Move focus to project tree") + self.aFocusTree.setShortcut("Alt+1") + self.aFocusTree.triggered.connect(lambda : self.theParent.setFocus(1)) + self.viewMenu.addAction(self.aFocusTree) + + # View > Document Pane 1 + self.aFocusEditor = QAction("Focus Document Editor", self) + self.aFocusEditor.setStatusTip("Move focus to left document pane") + self.aFocusEditor.setShortcut("Alt+2") + self.aFocusEditor.triggered.connect(lambda : self.theParent.setFocus(2)) + self.viewMenu.addAction(self.aFocusEditor) + + # View > Document Pane 2 + self.aFocusView = QAction("Focus Document Viewer", self) + self.aFocusView.setStatusTip("Move focus to right document pane") + self.aFocusView.setShortcut("Alt+3") + self.aFocusView.triggered.connect(lambda : self.theParent.setFocus(3)) + self.viewMenu.addAction(self.aFocusView) + + # View > Separator + self.viewMenu.addSeparator() + + # View > Toggle Distraction Free Mode + self.aFocusMode = QAction("Distraction Free Mode", self) + self.aFocusMode.setStatusTip("Toggles distraction free mode, only showing text editor") + self.aFocusMode.setShortcut("F8") + self.aFocusMode.setCheckable(True) + self.aFocusMode.setChecked(self.theParent.isFocusMode) + self.aFocusMode.toggled.connect(self.theParent.toggleFocusMode) + self.viewMenu.addAction(self.aFocusMode) + + # View > Toggle Full Screen + self.aFullScreen = QAction("Full Screen Mode", self) + self.aFullScreen.setStatusTip("Maximises the main window") + self.aFullScreen.setShortcut("F11") + self.aFullScreen.triggered.connect(self.theParent.toggleFullScreenMode) + self.viewMenu.addAction(self.aFullScreen) + + return + def _buildInsertMenu(self): # Insert @@ -521,6 +515,57 @@ class GuiMainMenu(QMenuBar): return + def _buildSearchMenu(self): + + # Search + self.srcMenu = self.addMenu("&Search") + + # Search > Find + self.aFind = QAction("Find", self) + self.aFind.setStatusTip("Find text in document") + self.aFind.setShortcut("Ctrl+F") + self.aFind.triggered.connect(lambda: self._docAction(nwDocAction.FIND)) + self.srcMenu.addAction(self.aFind) + + # Search > Replace + self.aReplace = QAction("Replace", self) + self.aReplace.setStatusTip("Replace text in document") + if self.mainConf.osDarwin: + self.aReplace.setShortcut("Ctrl+=") + else: + self.aReplace.setShortcut("Ctrl+H") + self.aReplace.triggered.connect(lambda: self._docAction(nwDocAction.REPLACE)) + self.srcMenu.addAction(self.aReplace) + + # Search > Find Next + self.aFindNext = QAction("Find Next", self) + self.aFindNext.setStatusTip("Find next occurrence text in document") + if self.mainConf.osDarwin: + self.aFindNext.setShortcuts(["Ctrl+G","F3"]) + else: + self.aFindNext.setShortcuts(["F3","Ctrl+G"]) + self.aFindNext.triggered.connect(lambda: self._docAction(nwDocAction.GO_NEXT)) + self.srcMenu.addAction(self.aFindNext) + + # Search > Find Prev + self.aFindPrev = QAction("Find Previous", self) + self.aFindPrev.setStatusTip("Find previous occurrence text in document") + if self.mainConf.osDarwin: + self.aFindPrev.setShortcuts(["Ctrl+Shift+G","Shift+F3"]) + else: + self.aFindPrev.setShortcuts(["Shift+F3","Ctrl+Shift+G"]) + self.aFindPrev.triggered.connect(lambda: self._docAction(nwDocAction.GO_PREV)) + self.srcMenu.addAction(self.aFindPrev) + + # Search > Replace Next + self.aReplaceNext = QAction("Replace Next", self) + self.aReplaceNext.setStatusTip("Find and replace next occurrence text in document") + self.aReplaceNext.setShortcut("Ctrl+Shift+1") + self.aReplaceNext.triggered.connect(lambda: self._docAction(nwDocAction.REPL_NEXT)) + self.srcMenu.addAction(self.aReplaceNext) + + return + def _buildFormatMenu(self): # Format @@ -626,53 +671,6 @@ class GuiMainMenu(QMenuBar): return - def _buildViewMenu(self): - - # View - self.viewMenu = self.addMenu("&View") - - # View > TreeView - self.aFocusTree = QAction("Focus Project Tree", self) - self.aFocusTree.setStatusTip("Move focus to project tree") - self.aFocusTree.setShortcut("Alt+1") - self.aFocusTree.triggered.connect(lambda : self.theParent.setFocus(1)) - self.viewMenu.addAction(self.aFocusTree) - - # View > Document Pane 1 - self.aFocusEditor = QAction("Focus Document Editor", self) - self.aFocusEditor.setStatusTip("Move focus to left document pane") - self.aFocusEditor.setShortcut("Alt+2") - self.aFocusEditor.triggered.connect(lambda : self.theParent.setFocus(2)) - self.viewMenu.addAction(self.aFocusEditor) - - # View > Document Pane 2 - self.aFocusView = QAction("Focus Document Viewer", self) - self.aFocusView.setStatusTip("Move focus to right document pane") - self.aFocusView.setShortcut("Alt+3") - self.aFocusView.triggered.connect(lambda : self.theParent.setFocus(3)) - self.viewMenu.addAction(self.aFocusView) - - # View > Separator - self.viewMenu.addSeparator() - - # View > Toggle Distraction Free Mode - self.aZenMode = QAction("Zen Mode", self) - self.aZenMode.setStatusTip("Toggles distraction free mode, only showing text editor") - self.aZenMode.setShortcut("F8") - self.aZenMode.setCheckable(True) - self.aZenMode.setChecked(self.theParent.isZenMode) - self.aZenMode.toggled.connect(self.theParent.toggleZenMode) - self.viewMenu.addAction(self.aZenMode) - - # View > Toggle Full Screen - self.aFullScreen = QAction("Full Screen Mode", self) - self.aFullScreen.setStatusTip("Maximises the main window") - self.aFullScreen.setShortcut("F11") - self.aFullScreen.triggered.connect(self.theParent.toggleFullScreenMode) - self.viewMenu.addAction(self.aFullScreen) - - return - def _buildToolsMenu(self): # Tools @@ -741,13 +739,20 @@ class GuiMainMenu(QMenuBar): self.toolsMenu.addSeparator() # Tools > Backup - self.aBackupProject = QAction("Backup Project", self) + self.aBackupProject = QAction("Backup Project Folder", self) self.aBackupProject.setStatusTip("Backup Project") self.aBackupProject.triggered.connect(self._doBackup) self.toolsMenu.addAction(self.aBackupProject) + # Tools > Export Project + self.aBuildProject = QAction("Build Novel Project", self) + self.aBuildProject.setStatusTip("Launch the Build novel project tool") + self.aBuildProject.setShortcut("F5") + self.aBuildProject.triggered.connect(self.theParent.buildProjectDialog) + self.toolsMenu.addAction(self.aBuildProject) + # Tools > Writing Stats - self.aWritingStats = QAction("Show Writing Statistics", self) + self.aWritingStats = QAction("Writing Statistics", self) self.aWritingStats.setStatusTip("Show the writing statistics dialog") self.aWritingStats.setShortcut("F6") self.aWritingStats.triggered.connect(self.theParent.showWritingStatsDialog) diff --git a/nw/gui/preferences.py b/nw/gui/preferences.py index 7b64138a..0882b089 100644 --- a/nw/gui/preferences.py +++ b/nw/gui/preferences.py @@ -431,15 +431,15 @@ class GuiConfigEditLayoutTab(QWidget): theUnit="px" ) - ## Max Text Width in Zen Mode - self.zenDocWidth = QSpinBox(self) - self.zenDocWidth.setMinimum(300) - self.zenDocWidth.setMaximum(10000) - self.zenDocWidth.setSingleStep(10) - self.zenDocWidth.setValue(self.mainConf.zenWidth) + ## 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 \"Zen Mode\"", - self.zenDocWidth, + "Maximum text width in \"Focus Mode\"", + self.focusDocWidth, theUnit="px" ) @@ -452,12 +452,12 @@ class GuiConfigEditLayoutTab(QWidget): "If disabled, minimum text width is defined by the margin setting." ) - ## Zen Mode Footer - self.hideZenFooter = QSwitch() - self.hideZenFooter.setChecked(self.mainConf.hideZenFooter) + ## Focus Mode Footer + self.hideFocusFooter = QSwitch() + self.hideFocusFooter.setChecked(self.mainConf.hideFocusFooter) self.mainForm.addRow( - "Hide document footer in \"Zen Mode\"", - self.hideZenFooter + "Hide document footer in \"Focus Mode\"", + self.hideFocusFooter ) ## Justify Text @@ -521,29 +521,29 @@ class GuiConfigEditLayoutTab(QWidget): validEntries = True needsRestart = False - textFont = self.textStyleFont.text() - textSize = self.textStyleSize.value() - textWidth = self.textFlowMax.value() - zenWidth = self.zenDocWidth.value() - textFixedW = not self.textFlowFixed.isChecked() - hideZenFooter = self.hideZenFooter.isChecked() - doJustify = self.textJustify.isChecked() - textMargin = self.textMargin.value() - tabWidth = self.tabWidth.value() - viewComments = self.viewComments.isChecked() - viewSynopsis = self.viewSynopsis.isChecked() + textFont = self.textStyleFont.text() + textSize = self.textStyleSize.value() + textWidth = self.textFlowMax.value() + focusWidth = self.focusDocWidth.value() + textFixedW = not self.textFlowFixed.isChecked() + hideFocusFooter = self.hideFocusFooter.isChecked() + doJustify = self.textJustify.isChecked() + textMargin = self.textMargin.value() + tabWidth = self.tabWidth.value() + viewComments = self.viewComments.isChecked() + viewSynopsis = self.viewSynopsis.isChecked() - self.mainConf.textFont = textFont - self.mainConf.textSize = textSize - self.mainConf.textWidth = textWidth - self.mainConf.zenWidth = zenWidth - self.mainConf.textFixedW = textFixedW - self.mainConf.hideZenFooter = hideZenFooter - self.mainConf.doJustify = doJustify - self.mainConf.textMargin = textMargin - self.mainConf.tabWidth = tabWidth - self.mainConf.viewComments = viewComments - self.mainConf.viewSynopsis = viewSynopsis + self.mainConf.textFont = textFont + self.mainConf.textSize = textSize + self.mainConf.textWidth = textWidth + self.mainConf.focusWidth = focusWidth + self.mainConf.textFixedW = textFixedW + self.mainConf.hideFocusFooter = hideFocusFooter + self.mainConf.doJustify = doJustify + self.mainConf.textMargin = textMargin + self.mainConf.tabWidth = tabWidth + self.mainConf.viewComments = viewComments + self.mainConf.viewSynopsis = viewSynopsis self.mainConf.confChanged = True diff --git a/nw/guimain.py b/nw/guimain.py index 7681089c..668ebf9f 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -73,11 +73,11 @@ class GuiMain(QMainWindow): ) # Core Classes and settings - self.theTheme = GuiTheme(self) - self.theProject = NWProject(self) - self.theIndex = NWIndex(self.theProject, self) - self.hasProject = False - self.isZenMode = False + self.theTheme = GuiTheme(self) + self.theProject = NWProject(self) + self.theIndex = NWIndex(self.theProject, self) + self.hasProject = False + self.isFocusMode = False # Prepare main window self.resize(*self.mainConf.getWinSize()) @@ -874,7 +874,7 @@ class GuiMain(QMainWindow): logger.info("Exiting %s" % nw.__package__) - if not self.isZenMode: + if not self.isFocusMode: self.mainConf.setMainPanePos(self.splitMain.sizes()) self.mainConf.setDocPanePos(self.splitDocs.sizes()) self.mainConf.setOutlinePanePos(self.splitOutline.sizes()) @@ -921,28 +921,28 @@ class GuiMain(QMainWindow): self.splitDocs.setSizes(vPos) return not self.splitView.isVisible() - def toggleZenMode(self): - """Main GUI Zen Mode hides tree, view pane and optionally also + def toggleFocusMode(self): + """Main GUI Focus Mode hides tree, view pane and optionally also statusbar and menu. """ if self.docEditor.theHandle is None: - logger.error("No document open, so not activating Zen Mode") + logger.error("No document open, so not activating Focus Mode") return False - self.isZenMode = not self.isZenMode - if self.isZenMode: - logger.debug("Activating Zen mode") + self.isFocusMode = not self.isFocusMode + if self.isFocusMode: + logger.debug("Activating Focus mode") self.tabWidget.setCurrentWidget(self.splitDocs) else: - logger.debug("Deactivating Zen mode") + logger.debug("Deactivating Focus mode") - isVisible = not self.isZenMode + isVisible = not self.isFocusMode self.treePane.setVisible(isVisible) self.statusBar.setVisible(isVisible) self.mainMenu.setVisible(isVisible) self.tabWidget.tabBar().setVisible(isVisible) - hideDocFooter = self.isZenMode and self.mainConf.hideZenFooter + hideDocFooter = self.isFocusMode and self.mainConf.hideFocusFooter self.docEditor.docFooter.setVisible(not hideDocFooter) if self.splitView.isVisible(): @@ -996,6 +996,10 @@ class GuiMain(QMainWindow): self.addAction(self.mainMenu.aSelectAll) self.addAction(self.mainMenu.aSelectPar) + # View + self.addAction(self.mainMenu.aFocusMode) + self.addAction(self.mainMenu.aFullScreen) + # Insert self.addAction(self.mainMenu.aInsENDash) self.addAction(self.mainMenu.aInsEMDash) @@ -1018,10 +1022,6 @@ class GuiMain(QMainWindow): self.addAction(self.mainMenu.aFmtComment) self.addAction(self.mainMenu.aFmtNoFormat) - # View - self.addAction(self.mainMenu.aZenMode) - self.addAction(self.mainMenu.aFullScreen) - # Tools self.addAction(self.mainMenu.aSpellCheck) self.addAction(self.mainMenu.aReRunSpell) @@ -1132,8 +1132,8 @@ class GuiMain(QMainWindow): if self.docEditor.docSearch.isVisible(): self.docEditor.closeSearch() return - elif self.isZenMode: - self.toggleZenMode() + elif self.isFocusMode: + self.toggleFocusMode() return def _mainTabChanged(self, tabIndex): diff --git a/tests/reference/novelwriter.conf b/tests/reference/novelwriter.conf index 849843a0..49054ae7 100644 --- a/tests/reference/novelwriter.conf +++ b/tests/reference/novelwriter.conf @@ -28,8 +28,8 @@ fixedwidth = True width = 600 margin = 40 tabwidth = 40 -zenwidth = 800 -hidezenfooter = False +focuswidth = 800 +hidefocusfooter = False justify = False autoselect = True autoreplace = True