diff --git a/nw/assets/icons/typicons_grey_light/bookmark.svg b/nw/assets/icons/typicons_grey_light/bookmark.svg new file mode 100644 index 00000000..0d97d10d --- /dev/null +++ b/nw/assets/icons/typicons_grey_light/bookmark.svg @@ -0,0 +1,55 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/nw/assets/icons/typicons_grey_light/icons.conf b/nw/assets/icons/typicons_grey_light/icons.conf index 9d99741c..2c019496 100644 --- a/nw/assets/icons/typicons_grey_light/icons.conf +++ b/nw/assets/icons/typicons_grey_light/icons.conf @@ -49,3 +49,6 @@ edit = pencil.svg check = tick.svg cross = times.svg hash = hash.svg +reference = bookmark.svg +sticky-on = pin.svg +sticky-off = pin-outline.svg diff --git a/nw/assets/icons/typicons_grey_light/pin-outline.svg b/nw/assets/icons/typicons_grey_light/pin-outline.svg new file mode 100644 index 00000000..481e8d02 --- /dev/null +++ b/nw/assets/icons/typicons_grey_light/pin-outline.svg @@ -0,0 +1,55 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/nw/assets/icons/typicons_grey_light/pin.svg b/nw/assets/icons/typicons_grey_light/pin.svg new file mode 100644 index 00000000..9fd617a4 --- /dev/null +++ b/nw/assets/icons/typicons_grey_light/pin.svg @@ -0,0 +1,55 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/nw/gui/docbars.py b/nw/gui/docbars.py index 4c521860..e79ac3f8 100644 --- a/nw/gui/docbars.py +++ b/nw/gui/docbars.py @@ -33,7 +33,7 @@ from PyQt5.QtCore import Qt, QSize from PyQt5.QtGui import QPalette, QColor from PyQt5.QtWidgets import ( qApp, QWidget, QFrame, QGridLayout, QLabel, QLineEdit, QPushButton, - QHBoxLayout + QHBoxLayout, QToolButton ) from nw.constants import nwDocAction, nwUnicode @@ -370,9 +370,22 @@ class GuiDocViewFooter(QWidget): self.setAutoFillBackground(True) self.setPalette(self.thePalette) + # Show/Hide Details + self.showHide = QToolButton() + self.showHide.setStyleSheet("QToolButton { border: none; background: transparent; }") + self.showHide.setToolButtonStyle(Qt.ToolButtonIconOnly) + self.showHide.setIcon(self.theTheme.getIcon("reference")) + self.showHide.setFixedSize(QSize(fPx, fPx)) + self.showHide.setIconSize(QSize(fPx, fPx)) + self.showHide.clicked.connect(self._doShowHide) + # Title Label - self.theTitle = QLabel() - self.theTitle.setText("References") + self.theTitle = QLabel("References") + self.theTitle.setIndent(0) + self.theTitle.setMargin(0) + self.theTitle.setContentsMargins(0, 0, 0, 0) + self.theTitle.setAlignment(Qt.AlignLeft | Qt.AlignTop) + self.theTitle.setFixedHeight(fPx) lblFont = self.theTitle.font() lblFont.setPointSizeF(0.9*self.theTheme.fontPointSize) @@ -381,6 +394,7 @@ class GuiDocViewFooter(QWidget): # Assemble Layout self.outerBox = QHBoxLayout() self.outerBox.setSpacing(hSp) + self.outerBox.addWidget(self.showHide, 0) self.outerBox.addWidget(self.theTitle, 1) self.setLayout(self.outerBox) @@ -388,4 +402,15 @@ class GuiDocViewFooter(QWidget): return + ## + # Slots + ## + + def _doShowHide(self): + """Toggle the expand/collapse of the panel. + """ + isVisible = self.theParent.theParent.viewMeta.isVisible() + self.theParent.theParent.viewMeta.setVisible(not isVisible) + return + # END Class GuiDocViewFooter diff --git a/nw/gui/docdetails.py b/nw/gui/docdetails.py index 7c4ec8f7..170ce1dd 100644 --- a/nw/gui/docdetails.py +++ b/nw/gui/docdetails.py @@ -30,15 +30,15 @@ import nw from PyQt5.QtCore import Qt, QSize from PyQt5.QtWidgets import ( - QWidget, QLabel, QScrollArea, QFrame, QToolButton, QCheckBox, QGridLayout + QWidget, QLabel, QScrollArea, QFrame, QToolButton, QCheckBox, QGridLayout, QHBoxLayout ) logger = logging.getLogger(__name__) -class GuiDocViewDetails(QWidget): +class GuiDocViewDetails(QScrollArea): def __init__(self, theParent): - QWidget.__init__(self, theParent) + QScrollArea.__init__(self, theParent) logger.debug("Initialising DocViewDetails ...") self.mainConf = nw.CONFIG @@ -47,28 +47,28 @@ class GuiDocViewDetails(QWidget): self.theTheme = theParent.theTheme self.currHandle = None - x4 = self.mainConf.pxInt(4) - x80 = self.mainConf.pxInt(80) - iPx = self.theTheme.textIconSize + # x4 = self.mainConf.pxInt(4) + # x80 = self.mainConf.pxInt(80) + # iPx = self.theTheme.textIconSize - self.outerBox = QGridLayout(self) - self.outerBox.setContentsMargins(0, 0, 0, 0) - self.outerBox.setHorizontalSpacing(0) - self.outerBox.setVerticalSpacing(x4) + # self.outerBox = QGridLayout(self) + # self.outerBox.setContentsMargins(0, 0, 0, 0) + # self.outerBox.setHorizontalSpacing(0) + # self.outerBox.setVerticalSpacing(x4) - self.refLabel = QLabel("Referenced By", self) + # self.refLabel = QLabel("Referenced By", self) - self.showHide = QToolButton() - self.showHide.setStyleSheet("QToolButton { border: none; }") - self.showHide.setToolButtonStyle(Qt.ToolButtonIconOnly) - self.showHide.setArrowType(Qt.DownArrow) - self.showHide.setCheckable(True) - self.showHide.setIconSize(QSize(iPx, iPx)) - self.showHide.toggled.connect(self._doShowHide) + # self.showHide = QToolButton() + # self.showHide.setStyleSheet("QToolButton { border: none; }") + # self.showHide.setToolButtonStyle(Qt.ToolButtonIconOnly) + # self.showHide.setArrowType(Qt.DownArrow) + # self.showHide.setCheckable(True) + # self.showHide.setIconSize(QSize(iPx, iPx)) + # self.showHide.toggled.connect(self._doShowHide) - self.isSticky = QCheckBox("Sticky") - self.isSticky.setChecked(False) - self.isSticky.toggled.connect(self._doSticky) + # self.isSticky = QCheckBox("Sticky") + # self.isSticky.setChecked(False) + # self.isSticky.toggled.connect(self._doSticky) self.refList = QLabel("None") self.refList.setWordWrap(True) @@ -76,23 +76,31 @@ class GuiDocViewDetails(QWidget): self.refList.setScaledContents(True) self.refList.linkActivated.connect(self._linkClicked) - self.scrollBox = QScrollArea() - self.scrollBox.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) - self.scrollBox.setFrameStyle(QFrame.NoFrame) - self.scrollBox.setWidgetResizable(True) - self.scrollBox.setFixedHeight(x80) - self.scrollBox.setWidget(self.refList) + # self.scrollBox = QScrollArea() + # self.scrollBox.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + # self.scrollBox.setFrameStyle(QFrame.NoFrame) + # self.scrollBox.setWidgetResizable(True) + # self.scrollBox.setFixedHeight(x80) + # self.scrollBox.setWidget(self.refList) - self.outerBox.addWidget(self.showHide, 0, 0) - self.outerBox.addWidget(self.refLabel, 0, 1) - self.outerBox.addWidget(self.isSticky, 0, 2) - self.outerBox.addWidget(self.scrollBox, 1, 1, 1, 2) - self.outerBox.setColumnStretch(1, 1) + # self.outerBox.addWidget(self.showHide, 0, 0) + # self.outerBox.addWidget(self.refLabel, 0, 1) + # self.outerBox.addWidget(self.isSticky, 0, 2) + # self.outerBox.addWidget(self.scrollBox, 1, 1, 1, 2) + # self.outerBox.setColumnStretch(1, 1) - self.setLayout(self.outerBox) - self.setContentsMargins(0, 0, 0, 0) + # Assemble + self.outerWidget = QWidget() + self.outerBox = QHBoxLayout() + self.outerBox.addWidget(self.refList, 1) - self._doShowHide(self.mainConf.showRefPanel) + self.outerWidget.setLayout(self.outerBox) + self.setWidget(self.outerWidget) + + self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) + self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) + self.setWidgetResizable(True) + self.setMinimumHeight(self.mainConf.pxInt(50)) logger.debug("DocViewDetails initialisation complete") @@ -103,8 +111,7 @@ class GuiDocViewDetails(QWidget): project index. """ self.currHandle = tHandle - - if self.isSticky.isChecked(): + if self.theParent.docViewer.stickyRef: return theRefs = self.theParent.theIndex.getBackReferenceList(tHandle) @@ -112,9 +119,10 @@ class GuiDocViewDetails(QWidget): for tHandle in theRefs: tItem = self.theProject.projTree[tHandle] if tItem is not None: - theList.append("%s" % ( - tHandle, theRefs[tHandle], tItem.itemName - )) + for n in range(10): + theList.append("%s" % ( + tHandle, theRefs[tHandle], tItem.itemName + )) self.refList.setText(", ".join(theList)) self.refList.adjustSize() @@ -135,22 +143,22 @@ class GuiDocViewDetails(QWidget): self.theParent.viewDocument(tHandle, theLink) return - def _doShowHide(self, chState): - """Toggle the expand/collapse of the panel. - """ - self.scrollBox.setVisible(chState) - self.mainConf.setShowRefPanel(chState) - if chState: - self.showHide.setArrowType(Qt.DownArrow) - else: - self.showHide.setArrowType(Qt.RightArrow) - return + # def _doShowHide(self, chState): + # """Toggle the expand/collapse of the panel. + # """ + # self.scrollBox.setVisible(chState) + # self.mainConf.setShowRefPanel(chState) + # if chState: + # self.showHide.setArrowType(Qt.DownArrow) + # else: + # self.showHide.setArrowType(Qt.RightArrow) + # return - def _doSticky(self, chState): - """Toggle the sticky feature of the references. - """ - if not chState and self.currHandle is not None: - self.refreshReferences(self.currHandle) - return + # def _doSticky(self, chState): + # """Toggle the sticky feature of the references. + # """ + # if not chState and self.currHandle is not None: + # self.refreshReferences(self.currHandle) + # return # END Class GuiDocViewDetails diff --git a/nw/gui/docviewer.py b/nw/gui/docviewer.py index e4c37bf9..f6e02d57 100644 --- a/nw/gui/docviewer.py +++ b/nw/gui/docviewer.py @@ -60,6 +60,7 @@ class GuiDocViewer(QTextBrowser): # Document Title and Footer self.docTitle = GuiDocTitleBar(self, self.theProject, isEditor=False) self.docFooter = GuiDocViewFooter(self, self.theProject) + self.stickyRef = False theOpt = QTextOption() if self.mainConf.doJustify: diff --git a/nw/gui/outlinedetails.py b/nw/gui/outlinedetails.py index 739b1c37..9a010559 100644 --- a/nw/gui/outlinedetails.py +++ b/nw/gui/outlinedetails.py @@ -216,11 +216,9 @@ class GuiOutlineDetails(QScrollArea): self.outerBox = QHBoxLayout() self.outerBox.addWidget(self.mainGroup, 0) self.outerBox.addWidget(self.tagsGroup, 1) - # self.outerBox.addStretch(1) self.outerWidget.setLayout(self.outerBox) self.setWidget(self.outerWidget) - self.show() self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) diff --git a/nw/gui/theme.py b/nw/gui/theme.py index 08b18691..78b2b44d 100644 --- a/nw/gui/theme.py +++ b/nw/gui/theme.py @@ -537,6 +537,9 @@ class GuiIcons: "maximise" : (None, None), "minimise" : (None, None), "refresh" : (None, None), + "reference" : (None, None), + "sticky-on" : (None, None), + "sticky-off" : (None, None), ## Other Icons "warning" : (QStyle.SP_MessageBoxWarning, "dialog-warning"), diff --git a/nw/guimain.py b/nw/guimain.py index 773e0592..24deedf7 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -120,17 +120,8 @@ class GuiMain(QMainWindow): self.docEdit.addWidget(self.docEditor) self.editPane.setLayout(self.docEdit) - self.viewPane = QWidget() - self.docView = QVBoxLayout() - self.docView.setContentsMargins(0, 0, 0, 0) - self.docView.setSpacing(self.mainConf.pxInt(2)) - self.docView.addWidget(self.docViewer) - # self.docView.addWidget(self.viewMeta) - self.docView.setStretch(0, 1) - self.viewPane.setLayout(self.docView) - self.splitView = QSplitter(Qt.Vertical) - self.splitView.addWidget(self.viewPane) + self.splitView.addWidget(self.docViewer) self.splitView.addWidget(self.viewMeta) self.splitView.setSizes(self.mainConf.getViewPanePos()) @@ -161,20 +152,23 @@ class GuiMain(QMainWindow): self.setCentralWidget(self.splitMain) - self.idxTree = self.splitMain.indexOf(self.treePane) - self.idxMain = self.splitMain.indexOf(self.tabWidget) - self.idxEditor = self.splitDocs.indexOf(self.editPane) - self.idxViewer = self.splitDocs.indexOf(self.viewPane) - - self.idxTabEdit = self.tabWidget.indexOf(self.splitDocs) - self.idxTabProj = self.tabWidget.indexOf(self.splitOutline) + self.idxTree = self.splitMain.indexOf(self.treePane) + self.idxMain = self.splitMain.indexOf(self.tabWidget) + self.idxEditor = self.splitDocs.indexOf(self.editPane) + self.idxViewer = self.splitDocs.indexOf(self.splitView) + self.idxViewDoc = self.splitView.indexOf(self.docViewer) + self.idxViewMeta = self.splitView.indexOf(self.viewMeta) + self.idxTabEdit = self.tabWidget.indexOf(self.splitDocs) + self.idxTabProj = self.tabWidget.indexOf(self.splitOutline) self.splitMain.setCollapsible(self.idxTree, False) self.splitMain.setCollapsible(self.idxMain, False) self.splitDocs.setCollapsible(self.idxEditor, False) self.splitDocs.setCollapsible(self.idxViewer, True) + self.splitView.setCollapsible(self.idxViewDoc, False) + self.splitView.setCollapsible(self.idxViewMeta, False) - self.viewPane.setVisible(False) + self.splitView.setVisible(False) self.searchBar.setVisible(False) # Build the Tree View @@ -516,9 +510,9 @@ class GuiMain(QMainWindow): self.tabWidget.setCurrentWidget(self.splitDocs) if self.docViewer.loadText(tHandle): - if not self.viewPane.isVisible(): + if not self.splitView.isVisible(): bPos = self.splitMain.sizes() - self.viewPane.setVisible(True) + self.splitView.setVisible(True) vPos = [0, 0] vPos[0] = int(bPos[1]/2) vPos[1] = bPos[1] - vPos[0] @@ -882,13 +876,15 @@ class GuiMain(QMainWindow): return def closeDocViewer(self): + """Close the document view panel. + """ self.docViewer.clearViewer() self.theProject.setLastViewed(None) bPos = self.splitMain.sizes() - self.viewPane.setVisible(False) + self.splitView.setVisible(False) vPos = [bPos[1], 0] self.splitDocs.setSizes(vPos) - return not self.viewPane.isVisible() + return not self.splitView.isVisible() def toggleZenMode(self): """Main GUI Zen Mode hides tree, view pane and optionally also @@ -911,10 +907,10 @@ class GuiMain(QMainWindow): self.mainMenu.setVisible(isVisible) self.tabWidget.tabBar().setVisible(isVisible) - if self.viewPane.isVisible(): - self.viewPane.setVisible(False) + if self.splitView.isVisible(): + self.splitView.setVisible(False) elif self.docViewer.theHandle is not None: - self.viewPane.setVisible(True) + self.splitView.setVisible(True) return True