Fix GUI bugs and broken reference links (#1379)
This commit is contained in:
@@ -1201,17 +1201,18 @@ class GuiDocViewDetails(QScrollArea):
|
|||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Internal Functions
|
# Private Slots
|
||||||
##
|
##
|
||||||
|
|
||||||
|
@pyqtSlot(str)
|
||||||
def _linkClicked(self, theLink):
|
def _linkClicked(self, theLink):
|
||||||
"""Capture the link-click and forward it to the document viewer
|
"""Capture the link-click and forward it to the document viewer
|
||||||
class for handling.
|
class for handling.
|
||||||
"""
|
"""
|
||||||
logger.debug("Clicked link: '%s'", theLink)
|
logger.debug("Clicked link: '%s'", theLink)
|
||||||
if len(theLink) == 21:
|
if len(theLink) >= 13:
|
||||||
tHandle = theLink[:13]
|
tHandle = theLink[:13]
|
||||||
tAnchor = theLink[13:]
|
tAnchor = theLink[13:] or None
|
||||||
self.mainGui.viewDocument(tHandle, tAnchor)
|
self.mainGui.viewDocument(tHandle, tAnchor)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ from PyQt5.QtWidgets import (
|
|||||||
QVBoxLayout, QWidget
|
QVBoxLayout, QWidget
|
||||||
)
|
)
|
||||||
|
|
||||||
from novelwriter.enum import nwDocMode, nwItemType, nwItemClass, nwItemLayout, nwAlert
|
from novelwriter.enum import nwDocMode, nwItemType, nwItemClass, nwItemLayout, nwAlert, nwWidget
|
||||||
from novelwriter.constants import nwHeaders, nwUnicode, trConst, nwLabels
|
from novelwriter.constants import nwHeaders, nwUnicode, trConst, nwLabels
|
||||||
from novelwriter.core.coretools import DocMerger, DocSplitter
|
from novelwriter.core.coretools import DocMerger, DocSplitter
|
||||||
from novelwriter.dialogs.docmerge import GuiDocMerge
|
from novelwriter.dialogs.docmerge import GuiDocMerge
|
||||||
@@ -630,6 +630,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
|
|
||||||
# Add the new item to the project tree
|
# Add the new item to the project tree
|
||||||
self.revealNewTreeItem(tHandle, nHandle=nHandle, wordCount=True)
|
self.revealNewTreeItem(tHandle, nHandle=nHandle, wordCount=True)
|
||||||
|
self.mainGui.switchFocus(nwWidget.TREE)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -1087,7 +1088,6 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
if tItem is None:
|
if tItem is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.setFocus()
|
|
||||||
if tHandle in self._treeMap:
|
if tHandle in self._treeMap:
|
||||||
self.setCurrentItem(self._treeMap[tHandle])
|
self.setCurrentItem(self._treeMap[tHandle])
|
||||||
|
|
||||||
|
|||||||
@@ -171,6 +171,19 @@ def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, nwLipsum):
|
|||||||
assert nwGUI.docViewer.loadText("846352075de7d") is False
|
assert nwGUI.docViewer.loadText("846352075de7d") is False
|
||||||
assert nwGUI.docViewer.toPlainText() == "An error occurred while generating the preview."
|
assert nwGUI.docViewer.toPlainText() == "An error occurred while generating the preview."
|
||||||
|
|
||||||
|
# Check reference panel (issue #1378)
|
||||||
|
assert nwGUI.viewDocument("4c4f28287af27") is True
|
||||||
|
assert nwGUI.docViewer.toPlainText().startswith("Nobody Owens")
|
||||||
|
|
||||||
|
nwGUI.viewMeta._linkClicked("fb609cd8319dc")
|
||||||
|
assert nwGUI.docViewer.toPlainText().startswith("Chapter One")
|
||||||
|
|
||||||
|
nwGUI.viewMeta._linkClicked("88243afbe5ed8#T0001")
|
||||||
|
assert nwGUI.docViewer.toPlainText().startswith("Scene One")
|
||||||
|
|
||||||
|
nwGUI.viewMeta._linkClicked("88243afbe5ed8#ABCD")
|
||||||
|
assert nwGUI.docViewer.toPlainText().startswith("Scene One")
|
||||||
|
|
||||||
# qtbot.stop()
|
# qtbot.stop()
|
||||||
|
|
||||||
# END Test testGuiViewer_Main
|
# END Test testGuiViewer_Main
|
||||||
|
|||||||
Reference in New Issue
Block a user