Added a menu option to show storage details about the currently open file
This commit is contained in:
@@ -16,9 +16,9 @@ import nw
|
||||
from time import time
|
||||
|
||||
from PyQt5.QtCore import Qt, QTimer, QSizeF
|
||||
from PyQt5.QtWidgets import qApp, QTextEdit, QAction, QMenu, QShortcut
|
||||
from PyQt5.QtWidgets import qApp, QTextEdit, QAction, QMenu, QShortcut, QMessageBox
|
||||
from PyQt5.QtGui import (
|
||||
QTextCursor, QTextOption, QIcon, QKeySequence, QFont, QColor, QPalette, QTextDocument
|
||||
QTextCursor, QTextOption, QIcon, QKeySequence, QFont, QColor, QPalette, QTextDocument,
|
||||
)
|
||||
|
||||
from nw.project.document import NWDoc
|
||||
@@ -332,6 +332,19 @@ class GuiDocEditor(QTextEdit):
|
||||
def isEmpty(self):
|
||||
return self.qDocument.isEmpty()
|
||||
|
||||
def revealLocation(self):
|
||||
if self.theHandle is not None:
|
||||
msgBox = QMessageBox()
|
||||
msgBox.information(self, "File Location", (
|
||||
"File details for the currently open file<br>"
|
||||
"Handle: {handle:s}<br>"
|
||||
"Location: {fileLoc:s}"
|
||||
).format(
|
||||
handle = self.theHandle,
|
||||
fileLoc = str(self.nwDocument.fileLoc)
|
||||
))
|
||||
return
|
||||
|
||||
##
|
||||
# Document Events and Maintenance
|
||||
##
|
||||
|
||||
@@ -117,7 +117,7 @@ class GuiDocViewer(QTextBrowser):
|
||||
self.theHandle = tHandle
|
||||
self.theProject.setLastViewed(tHandle)
|
||||
|
||||
self.theParent.docMeta.refreshReferences(tHandle)
|
||||
self.theParent.viewMeta.refreshReferences(tHandle)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
Class holding the document view details panel
|
||||
|
||||
File History:
|
||||
Created: 2019-09-31 [0.3.2]
|
||||
Created: 2019-10-31 [0.3.2]
|
||||
|
||||
"""
|
||||
|
||||
@@ -20,7 +20,7 @@ from PyQt5.QtWidgets import (
|
||||
QSizePolicy, QCheckBox, QGridLayout
|
||||
)
|
||||
|
||||
from nw.constants import nwLabels
|
||||
from nw.constants import nwLabels
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -168,6 +168,10 @@ class GuiMainMenu(QMenuBar):
|
||||
self.updateRecentProjects()
|
||||
return True
|
||||
|
||||
def _showDocumentLocation(self):
|
||||
self.theParent.docEditor.revealLocation()
|
||||
return True
|
||||
|
||||
##
|
||||
# Menu Builders
|
||||
##
|
||||
@@ -347,6 +351,12 @@ class GuiMainMenu(QMenuBar):
|
||||
# Document > Separator
|
||||
self.docuMenu.addSeparator()
|
||||
|
||||
# Document > Show File Details
|
||||
menuItem = QAction("Show File Details", self)
|
||||
menuItem.setStatusTip("Shows a message box with the document location in the project folder")
|
||||
menuItem.triggered.connect(self._showDocumentLocation)
|
||||
self.docuMenu.addAction(menuItem)
|
||||
|
||||
# Document > Import From File
|
||||
menuItem = QAction("Import from File", self)
|
||||
menuItem.setStatusTip("Import document from a text or markdown file")
|
||||
|
||||
+2
-2
@@ -77,7 +77,7 @@ class GuiMain(QMainWindow):
|
||||
self.noticeBar = GuiNoticeBar(self)
|
||||
self.docEditor = GuiDocEditor(self, self.theProject)
|
||||
self.docViewer = GuiDocViewer(self, self.theProject)
|
||||
self.docMeta = GuiDocViewDetails(self, self.theProject)
|
||||
self.viewMeta = GuiDocViewDetails(self, self.theProject)
|
||||
self.searchBar = GuiSearchBar(self)
|
||||
self.treeMeta = GuiDocDetails(self, self.theProject)
|
||||
self.treeView = GuiDocTree(self, self.theProject)
|
||||
@@ -107,7 +107,7 @@ class GuiMain(QMainWindow):
|
||||
self.docView = QVBoxLayout()
|
||||
self.docView.setContentsMargins(0,0,0,0)
|
||||
self.docView.addWidget(self.docViewer)
|
||||
self.docView.addWidget(self.docMeta)
|
||||
self.docView.addWidget(self.viewMeta)
|
||||
self.docView.setStretch(0, 1)
|
||||
self.viewPane.setLayout(self.docView)
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ class NWDoc():
|
||||
self.theItem = None
|
||||
self.docHandle = None
|
||||
self.docEditable = False
|
||||
self.fileLoc = None
|
||||
|
||||
# Internal Mapping
|
||||
self.makeAlert = self.theParent.makeAlert
|
||||
@@ -58,7 +59,8 @@ class NWDoc():
|
||||
self.docEditable = False
|
||||
|
||||
docDir, docFile = self._assemblePath(self.FILE_MN)
|
||||
logger.debug("Opening document %s" % path.join(docDir,docFile))
|
||||
self.fileLoc = path.join(docDir,docFile)
|
||||
logger.debug("Opening document %s" % self.fileLoc)
|
||||
dataDir = path.join(self.theProject.projPath, docDir)
|
||||
docPath = path.join(dataDir, docFile)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user