From 1e5d980b859d2687f201f96d73f02d3c3103e4fc Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Thu, 11 Feb 2021 18:42:28 +0100
Subject: [PATCH 1/7] Fix the label of the idle time switch on Writing
Statistics
---
nw/gui/writingstats.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/nw/gui/writingstats.py b/nw/gui/writingstats.py
index c225762a..dec1fef4 100644
--- a/nw/gui/writingstats.py
+++ b/nw/gui/writingstats.py
@@ -215,7 +215,7 @@ class GuiWritingStats(QDialog):
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(QLabel("Show idle time column"), 5, 0)
+ self.filterForm.addWidget(QLabel("Show idle time"), 5, 0)
self.filterForm.addWidget(self.incNovel, 0, 1)
self.filterForm.addWidget(self.incNotes, 1, 1)
self.filterForm.addWidget(self.hideZeros, 2, 1)
From 3a60abaeeed5cd7ca61dc6a019682e379da63ada Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Thu, 11 Feb 2021 18:57:44 +0100
Subject: [PATCH 2/7] F2 should only edit item if project tree has focus, and
edit current document meta if editor has focus
---
nw/guimain.py | 6 +++++-
tests/test_gui/test_gui_itemeditor.py | 3 ++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/nw/guimain.py b/nw/guimain.py
index c72c6d46..cb2756cc 100644
--- a/nw/guimain.py
+++ b/nw/guimain.py
@@ -800,7 +800,11 @@ class GuiMain(QMainWindow):
return False
if tHandle is None:
- tHandle = self.treeView.getSelectedHandle()
+ if self.treeView.hasFocus():
+ tHandle = self.treeView.getSelectedHandle()
+ elif self.docEditor.hasFocus():
+ tHandle = self.docEditor.theHandle
+
if tHandle is None:
logger.warning("No item selected")
return
diff --git a/tests/test_gui/test_gui_itemeditor.py b/tests/test_gui/test_gui_itemeditor.py
index 453aac68..aacdd4b7 100644
--- a/tests/test_gui/test_gui_itemeditor.py
+++ b/tests/test_gui/test_gui_itemeditor.py
@@ -28,7 +28,7 @@ from tools import cmpFiles, getGuiItem
from PyQt5.QtWidgets import QAction, QMessageBox
-from nw.gui import GuiItemEditor
+from nw.gui import GuiItemEditor, GuiProjectTree
from nw.constants import nwItemLayout
keyDelay = 2
@@ -45,6 +45,7 @@ def testGuiItemEditor_Dialog(qtbot, monkeypatch, nwGUI, fncDir, fncProj, refDir,
# Block message box
monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes)
+ monkeypatch.setattr(GuiProjectTree, "hasFocus", lambda *args: True)
# Create new, save, open project
nwGUI.theProject.projTree.setSeed(42)
From 08651685d4f44607ea48c6a293079af5dc06c1aa Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Thu, 11 Feb 2021 19:11:41 +0100
Subject: [PATCH 3/7] Allow Ctrl+Del to be propagated to the document editor
---
nw/constants/enum.py | 1 +
nw/gui/doceditor.py | 7 +++++--
nw/gui/mainmenu.py | 12 +++++++++++-
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/nw/constants/enum.py b/nw/constants/enum.py
index 539c0ae0..74d0e9f4 100644
--- a/nw/constants/enum.py
+++ b/nw/constants/enum.py
@@ -94,6 +94,7 @@ class nwDocAction(Enum):
BLOCK_TXT = 23
REPL_SNG = 24
REPL_DBL = 25
+ DEL_WORD = 26
# END Enum nwDocAction
diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py
index abafc6fb..b70e113f 100644
--- a/nw/gui/doceditor.py
+++ b/nw/gui/doceditor.py
@@ -37,11 +37,11 @@ from time import time
from PyQt5.QtCore import (
Qt, QSize, QTimer, pyqtSlot, pyqtSignal, QRegExp, QRegularExpression,
- QPointF, QObject, QRunnable, QPropertyAnimation
+ QPointF, QObject, QRunnable, QPropertyAnimation, QEvent
)
from PyQt5.QtGui import (
QTextCursor, QTextOption, QKeySequence, QFont, QColor, QPalette,
- QTextDocument, QCursor, QPixmap
+ QTextDocument, QCursor, QPixmap, QKeyEvent
)
from PyQt5.QtWidgets import (
qApp, QTextEdit, QAction, QMenu, QShortcut, QMessageBox, QWidget, QLabel,
@@ -719,6 +719,8 @@ class GuiDocEditor(QTextEdit):
self._replaceQuotes("'", self.typSQOpen, self.typSQClose)
elif theAction == nwDocAction.REPL_DBL:
self._replaceQuotes("\"", self.typDQOpen, self.typDQClose)
+ elif theAction == nwDocAction.DEL_WORD:
+ self.keyPressEvent(QKeyEvent(QEvent.KeyPress, Qt.Key_Delete, Qt.ControlModifier))
else:
logger.debug("Unknown or unsupported document action %s" % str(theAction))
self._allowAutoReplace(True)
@@ -843,6 +845,7 @@ class GuiDocEditor(QTextEdit):
* The undo/redo/select all sequences bypasses the docAction
pathway from the menu, so we redirect them back from here.
"""
+ print(keyEvent.type())
self.lastActive = time()
isReturn = keyEvent.key() == Qt.Key_Return
isReturn |= keyEvent.key() == Qt.Key_Enter
diff --git a/nw/gui/mainmenu.py b/nw/gui/mainmenu.py
index e91679ef..c44b2214 100644
--- a/nw/gui/mainmenu.py
+++ b/nw/gui/mainmenu.py
@@ -172,6 +172,16 @@ class GuiMainMenu(QMenuBar):
QDesktopServices.openUrl(QUrl(theUrl))
return True
+ def _handleCtrlDel(self):
+ """Direct the Ctrl+Del key press to the correct widget.
+ """
+ if self.theParent.treeView.hasFocus():
+ self.theParent.treeView.deleteItem(None)
+ elif self.theParent.docEditor.hasFocus():
+ self.theParent.docEditor.docAction(nwDocAction.DEL_WORD)
+
+ return
+
##
# Menu Builders
##
@@ -270,7 +280,7 @@ class GuiMainMenu(QMenuBar):
self.aDeleteItem = QAction("Delete Item", self)
self.aDeleteItem.setStatusTip("Delete selected project item")
self.aDeleteItem.setShortcut("Ctrl+Del")
- self.aDeleteItem.triggered.connect(lambda: self.theParent.treeView.deleteItem(None))
+ self.aDeleteItem.triggered.connect(self._handleCtrlDel)
self.projMenu.addAction(self.aDeleteItem)
# Project > Move Up
From 525c9c8fd835989f95d4f7e277b21341795bd622 Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Thu, 11 Feb 2021 19:27:35 +0100
Subject: [PATCH 4/7] Revert last commit and instead change delete item
shortcut
---
docs/source/usage_interface.rst | 4 +++-
nw/constants/enum.py | 1 -
nw/gui/doceditor.py | 7 ++-----
nw/gui/mainmenu.py | 14 ++------------
nw/gui/projtree.py | 2 +-
5 files changed, 8 insertions(+), 20 deletions(-)
diff --git a/docs/source/usage_interface.rst b/docs/source/usage_interface.rst
index f8c419a1..e9d9c4ae 100644
--- a/docs/source/usage_interface.rst
+++ b/docs/source/usage_interface.rst
@@ -377,9 +377,10 @@ Most features are available as keyboard shortcuts. These are as follows:
":kbd:`Ctrl`:kbd:`Z`", "Undo latest changes."
":kbd:`Ctrl`:kbd:`F7`", "Toggle spell checking."
":kbd:`Ctrl`:kbd:`F10`", "Toggle automatic updating of project outline."
- ":kbd:`Ctrl`:kbd:`Del`", "If in the project tree, move a document to trash, or delete a folder."
":kbd:`Ctrl`:kbd:`Up`", "Move item one step up in the project tree."
":kbd:`Ctrl`:kbd:`Down`", "Move item one step down in the project tree."
+ ":kbd:`Ctrl`:kbd:`Del`", "Delete next word in editor."
+ ":kbd:`Ctrl`:kbd:`Backspace`", "Delete previous word in editor."
":kbd:`Ctrl`:kbd:`'`", "Wrap selected text, or word under cursor, in single quotes."
":kbd:`Ctrl`:kbd:`""`", "Wrap selected text, or word under cursor, in double quotes."
":kbd:`Ctrl`:kbd:`Enter`", "Open the tag or reference under the cursor in the Viewer."
@@ -395,6 +396,7 @@ Most features are available as keyboard shortcuts. These are as follows:
":kbd:`Ctrl`:kbd:`Shift`:kbd:`S`", "Save the current project."
":kbd:`Ctrl`:kbd:`Shift`:kbd:`W`", "Close the current project."
":kbd:`Ctrl`:kbd:`Shift`:kbd:`Z`", "Undo move of project tree item."
+ ":kbd:`Ctrl`:kbd:`Shift`:kbd:`Del`", "If in the project tree, move a document to trash, or delete a folder."
":kbd:`F1`", "Open the documentation. This will either open the Qt Assistant, if available, or send you to the documentation website."
":kbd:`F2`", "If in the project tree, edit a document or folder settings. (Same as :kbd:`Ctrl`:kbd:`E`)"
":kbd:`F3`", "Find next occurrence of search word in current document. (Same as :kbd:`Ctrl`:kbd:`G`)"
diff --git a/nw/constants/enum.py b/nw/constants/enum.py
index 74d0e9f4..539c0ae0 100644
--- a/nw/constants/enum.py
+++ b/nw/constants/enum.py
@@ -94,7 +94,6 @@ class nwDocAction(Enum):
BLOCK_TXT = 23
REPL_SNG = 24
REPL_DBL = 25
- DEL_WORD = 26
# END Enum nwDocAction
diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py
index b70e113f..abafc6fb 100644
--- a/nw/gui/doceditor.py
+++ b/nw/gui/doceditor.py
@@ -37,11 +37,11 @@ from time import time
from PyQt5.QtCore import (
Qt, QSize, QTimer, pyqtSlot, pyqtSignal, QRegExp, QRegularExpression,
- QPointF, QObject, QRunnable, QPropertyAnimation, QEvent
+ QPointF, QObject, QRunnable, QPropertyAnimation
)
from PyQt5.QtGui import (
QTextCursor, QTextOption, QKeySequence, QFont, QColor, QPalette,
- QTextDocument, QCursor, QPixmap, QKeyEvent
+ QTextDocument, QCursor, QPixmap
)
from PyQt5.QtWidgets import (
qApp, QTextEdit, QAction, QMenu, QShortcut, QMessageBox, QWidget, QLabel,
@@ -719,8 +719,6 @@ class GuiDocEditor(QTextEdit):
self._replaceQuotes("'", self.typSQOpen, self.typSQClose)
elif theAction == nwDocAction.REPL_DBL:
self._replaceQuotes("\"", self.typDQOpen, self.typDQClose)
- elif theAction == nwDocAction.DEL_WORD:
- self.keyPressEvent(QKeyEvent(QEvent.KeyPress, Qt.Key_Delete, Qt.ControlModifier))
else:
logger.debug("Unknown or unsupported document action %s" % str(theAction))
self._allowAutoReplace(True)
@@ -845,7 +843,6 @@ class GuiDocEditor(QTextEdit):
* The undo/redo/select all sequences bypasses the docAction
pathway from the menu, so we redirect them back from here.
"""
- print(keyEvent.type())
self.lastActive = time()
isReturn = keyEvent.key() == Qt.Key_Return
isReturn |= keyEvent.key() == Qt.Key_Enter
diff --git a/nw/gui/mainmenu.py b/nw/gui/mainmenu.py
index c44b2214..4cf4960a 100644
--- a/nw/gui/mainmenu.py
+++ b/nw/gui/mainmenu.py
@@ -172,16 +172,6 @@ class GuiMainMenu(QMenuBar):
QDesktopServices.openUrl(QUrl(theUrl))
return True
- def _handleCtrlDel(self):
- """Direct the Ctrl+Del key press to the correct widget.
- """
- if self.theParent.treeView.hasFocus():
- self.theParent.treeView.deleteItem(None)
- elif self.theParent.docEditor.hasFocus():
- self.theParent.docEditor.docAction(nwDocAction.DEL_WORD)
-
- return
-
##
# Menu Builders
##
@@ -279,8 +269,8 @@ class GuiMainMenu(QMenuBar):
# Project > Delete
self.aDeleteItem = QAction("Delete Item", self)
self.aDeleteItem.setStatusTip("Delete selected project item")
- self.aDeleteItem.setShortcut("Ctrl+Del")
- self.aDeleteItem.triggered.connect(self._handleCtrlDel)
+ self.aDeleteItem.setShortcut("Ctrl+Shift+Del")
+ self.aDeleteItem.triggered.connect(lambda: self.theParent.treeView.deleteItem(None))
self.projMenu.addAction(self.aDeleteItem)
# Project > Move Up
diff --git a/nw/gui/projtree.py b/nw/gui/projtree.py
index a2e7c7b0..eff1ae7c 100644
--- a/nw/gui/projtree.py
+++ b/nw/gui/projtree.py
@@ -451,7 +451,7 @@ class GuiProjectTree(QTreeWidget):
for tHandle in self.getTreeFromHandle(trashHandle):
if tHandle == trashHandle:
continue
- self.deleteItem(tHandle, True)
+ self.deleteItem(tHandle, alreadyAsked=True)
if nTrash > 0:
self._setTreeChanged(True)
From bf6a3adc06fd01779f0b2ca4e44382a0cfd24275 Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Thu, 11 Feb 2021 22:53:14 +0100
Subject: [PATCH 5/7] Change the delete item shortcut
---
nw/gui/mainmenu.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/nw/gui/mainmenu.py b/nw/gui/mainmenu.py
index 82de494a..df99559d 100644
--- a/nw/gui/mainmenu.py
+++ b/nw/gui/mainmenu.py
@@ -272,7 +272,7 @@ class GuiMainMenu(QMenuBar):
# Project > Delete
self.aDeleteItem = QAction("Delete Project Item", self)
self.aDeleteItem.setStatusTip("Delete selected item")
- self.aDeleteItem.setShortcut("Ctrl+Del")
+ self.aDeleteItem.setShortcut("Ctrl+Shift+Del")
self.aDeleteItem.triggered.connect(lambda: self.theParent.treeView.deleteItem(None))
self.projMenu.addAction(self.aDeleteItem)
From 23c200f3335ce6957f64282d00941403b60abe7e Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Thu, 11 Feb 2021 22:53:58 +0100
Subject: [PATCH 6/7] Update docs
---
docs/source/usage_interface.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/source/usage_interface.rst b/docs/source/usage_interface.rst
index cf6bc065..3c40c3cf 100644
--- a/docs/source/usage_interface.rst
+++ b/docs/source/usage_interface.rst
@@ -377,7 +377,6 @@ Most features are available as keyboard shortcuts. These are as follows:
":kbd:`Ctrl`:kbd:`Z`", "Undo latest changes."
":kbd:`Ctrl`:kbd:`F7`", "Toggle spell checking."
":kbd:`Ctrl`:kbd:`F10`", "Toggle automatic updating of project outline."
- ":kbd:`Ctrl`:kbd:`Del`", "If in the project tree, move a document to trash, or delete a folder."
":kbd:`Ctrl`:kbd:`'`", "Wrap selected text, or word under cursor, in single quotes."
":kbd:`Ctrl`:kbd:`""`", "Wrap selected text, or word under cursor, in double quotes."
":kbd:`Ctrl`:kbd:`Enter`", "Open the tag or reference under the cursor in the Viewer."
@@ -395,6 +394,7 @@ Most features are available as keyboard shortcuts. These are as follows:
":kbd:`Ctrl`:kbd:`Shift`:kbd:`Z`", "Alternative sequence for redo last undo."
":kbd:`Ctrl`:kbd:`Shift`:kbd:`Up`", "Move item one step up in the project tree."
":kbd:`Ctrl`:kbd:`Shift`:kbd:`Down`", "Move item one step down in the project tree."
+ ":kbd:`Ctrl`:kbd:`Shift`:kbd:`Del`", "If in the project tree, move a document to trash, or delete a folder."
":kbd:`F1`", "Open the documentation. This will either open the Qt Assistant, if available, or send you to the documentation website."
":kbd:`F2`", "If in the project tree, edit a document or folder settings. (Same as :kbd:`Ctrl`:kbd:`E`)"
":kbd:`F3`", "Find next occurrence of search word in current document. (Same as :kbd:`Ctrl`:kbd:`G`)"
From a57ce557e86eff343817e064ccf46196a32c7cf8 Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Thu, 11 Feb 2021 22:59:19 +0100
Subject: [PATCH 7/7] Clean up lisence header of main init file
---
nw/__init__.py | 37 ++++++++++++++++++-------------------
1 file changed, 18 insertions(+), 19 deletions(-)
diff --git a/nw/__init__.py b/nw/__init__.py
index 6745d10e..37954bc6 100644
--- a/nw/__init__.py
+++ b/nw/__init__.py
@@ -1,28 +1,27 @@
# -*- coding: utf-8 -*-
-"""novelWriter Init
+"""
+novelWriter – Init File
+=======================
+Application initialisation
- novelWriter – Init File
-=========================
- Application initialisation
+File History:
+Created: 2018-09-22 [0.0.1]
- File History:
- Created: 2018-09-22 [0.0.1]
+This file is a part of novelWriter
+Copyright 2018–2021, Veronica Berglyd Olsen
- This file is a part of novelWriter
- Copyright 2018–2021, Veronica Berglyd Olsen
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
+You should have received a copy of the GNU General Public License
+along with this program. If not, see .
"""
import sys