From 0bfc1668996c3d3d3b51a40c6851bde3c5db1742 Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Thu, 14 Jan 2021 18:31:27 +0100
Subject: [PATCH] Added a few buttons below the project tree now that the tabs
make room for it
---
nw/assets/icons/fallback/settings-dark.svg | 31 ++++++++++++++++++
nw/assets/icons/fallback/settings.svg | 31 ++++++++++++++++++
nw/gui/itemdetails.py | 28 +++++++++-------
nw/gui/theme.py | 19 +++++++----
nw/guimain.py | 37 ++++++++++++++++++++--
5 files changed, 125 insertions(+), 21 deletions(-)
create mode 100644 nw/assets/icons/fallback/settings-dark.svg
create mode 100644 nw/assets/icons/fallback/settings.svg
diff --git a/nw/assets/icons/fallback/settings-dark.svg b/nw/assets/icons/fallback/settings-dark.svg
new file mode 100644
index 00000000..e2014bd8
--- /dev/null
+++ b/nw/assets/icons/fallback/settings-dark.svg
@@ -0,0 +1,31 @@
+
+
diff --git a/nw/assets/icons/fallback/settings.svg b/nw/assets/icons/fallback/settings.svg
new file mode 100644
index 00000000..edc89a8f
--- /dev/null
+++ b/nw/assets/icons/fallback/settings.svg
@@ -0,0 +1,31 @@
+
+
diff --git a/nw/gui/itemdetails.py b/nw/gui/itemdetails.py
index cbb006df..1a48e9cb 100644
--- a/nw/gui/itemdetails.py
+++ b/nw/gui/itemdetails.py
@@ -190,6 +190,22 @@ class GuiItemDetails(QWidget):
# Class Methods
##
+ def clearDetails(self):
+ """Clear all the data values.
+ """
+ self.labelFlag.setPixmap(QPixmap(1, 1))
+ self.labelData.setText("")
+ self.statusFlag.setPixmap(QPixmap(1, 1))
+ self.statusData.setText("")
+ self.classFlag.setText("")
+ self.classData.setText("")
+ self.layoutFlag.setText("")
+ self.layoutData.setText("")
+ self.cCountData.setText("–")
+ self.wCountData.setText("–")
+ self.pCountData.setText("–")
+ return
+
def updateCounts(self, tHandle, cC, wC, pC):
"""Just update the counts if the handle is the same as the one
we're already showing.
@@ -207,17 +223,7 @@ class GuiItemDetails(QWidget):
nwItem = self.theProject.projTree[tHandle]
if nwItem is None:
- self.labelFlag.setText("")
- self.labelData.setText("")
- self.statusFlag.setText("")
- self.statusData.setText("")
- self.classFlag.setText("")
- self.classData.setText("")
- self.layoutFlag.setText("")
- self.layoutData.setText("")
- self.cCountData.setText("–")
- self.wCountData.setText("–")
- self.pCountData.setText("–")
+ self.clearDetails()
else:
theLabel = nwItem.itemName
diff --git a/nw/gui/theme.py b/nw/gui/theme.py
index 8b14e4de..ef97c493 100644
--- a/nw/gui/theme.py
+++ b/nw/gui/theme.py
@@ -473,6 +473,9 @@ class GuiTheme:
return
def _parseLine(self, confParser, cnfSec, cnfName, cnfDefault):
+ """Simple wrapper for the config parser to check that the entry
+ exists before attempting to load it.
+ """
if confParser.has_section(cnfSec):
if confParser.has_option(cnfSec, cnfName):
return confParser.get(cnfSec, cnfName)
@@ -500,12 +503,13 @@ class GuiIcons:
the ICON_MAP data tuple[0]. This will let Qt pull the closest
system icon.
* Third action is to look up the freedesktop icon theme name using
- the fromTheme Qt call. This generally produces the same results
+ the fromTheme Qt call. This generally produces the same result
as the step above, but has more icons available in other cases.
* Fourth, and finally, the icon is looked up in the fallback
folder. Files in this folder must have the same file name as the
- novelWriter internal icon key, with '-dark' appended to it for
- the dark background version of the icon.
+ novelWriter internal icon key, with '-dark' appended to them for
+ the dark background version of the icon. If no dark icon exists,
+ the non-dark version will be returned.
"""
ICON_MAP = {
@@ -563,6 +567,7 @@ class GuiIcons:
"reference" : (None, None),
"backward" : (None, None),
"forward" : (None, None),
+ "settings" : (None, None),
## Switches
"sticky-on" : (None, None),
@@ -611,7 +616,6 @@ class GuiIcons:
the GUI icons cannot really be replaced without writing specific
update functions for the classes where they're used.
"""
-
logger.debug("Loading icon theme files")
self.themeMap = {}
@@ -748,7 +752,7 @@ class GuiIcons:
##
def _loadIcon(self, iconKey):
- """Load an icon from the assets or theme folder, with a
+ """Load an icon from the assets or themes folder, with a
preference for dark/light icons depending on theme type, if such
an icon exists. Prefer svg files over png files. Always returns
a QIcon.
@@ -786,6 +790,7 @@ class GuiIcons:
if os.path.isfile(fbackIcon):
logger.verbose("Loading icon '%s' from fallback theme (dark mode)" % iconKey)
return QIcon(fbackIcon)
+
fbackIcon = os.path.join(self.mainConf.iconPath, self.fbackName, "%s.svg" % iconKey)
if os.path.isfile(fbackIcon):
logger.verbose("Loading icon '%s' from fallback theme (light mode)" % iconKey)
@@ -797,8 +802,8 @@ class GuiIcons:
return QIcon()
def _parseLine(self, confParser, cnfSec, cnfName, cnfDefault):
- """Simple wrapper for the config parser check for entry existing
- before arrempting to load.
+ """Simple wrapper for the config parser to check that the entry
+ exists before attempting to load it.
"""
if confParser.has_section(cnfSec):
if confParser.has_option(cnfSec, cnfName):
diff --git a/nw/guimain.py b/nw/guimain.py
index aa5847b3..a6b1b9d9 100644
--- a/nw/guimain.py
+++ b/nw/guimain.py
@@ -32,11 +32,11 @@ import os
from datetime import datetime
from time import time
-from PyQt5.QtCore import Qt, QTimer, QThreadPool, pyqtSlot
+from PyQt5.QtCore import Qt, QTimer, QSize, QThreadPool, pyqtSlot
from PyQt5.QtGui import QIcon, QPixmap, QColor, QKeySequence, QCursor
from PyQt5.QtWidgets import (
qApp, QMainWindow, QVBoxLayout, QWidget, QSplitter, QFileDialog, QShortcut,
- QMessageBox, QDialog, QTabWidget
+ QMessageBox, QDialog, QTabWidget, QToolBar, QAction
)
from nw.gui import (
@@ -112,7 +112,7 @@ class GuiMain(QMainWindow):
self.statusIcons = []
self.importIcons = []
- # Project Tabs : Project / Novel
+ # Project Tree Tabs
self.projTabs = QTabWidget()
self.projTabs.setTabPosition(QTabWidget.South)
self.projTabs.setStyleSheet("QTabWidget::pane {border: 0;};")
@@ -124,6 +124,30 @@ class GuiMain(QMainWindow):
tabFont.setPointSize(round(0.9*self.theTheme.fontPointSize))
self.projTabs.tabBar().setFont(tabFont)
+ # Project Tree Action Buttons
+ btnSize = round(0.7*self.theTheme.fontPixelSize)
+ self.treeButtons = QToolBar()
+ self.treeButtons.setToolButtonStyle(Qt.ToolButtonIconOnly)
+ self.treeButtons.setIconSize(QSize(btnSize, btnSize))
+ self.treeButtons.setContentsMargins(0, 0, 0, 0)
+ self.treeButtons.setStyleSheet(r"QToolBar {padding: 0;}")
+ self.projTabs.setCornerWidget(self.treeButtons, Qt.BottomRightCorner)
+
+ self.projDetailsBtn = QAction("Project Details")
+ self.projDetailsBtn.setIcon(self.theTheme.getIcon("status_lines"))
+ self.projDetailsBtn.triggered.connect(lambda: self.showProjectDetailsDialog())
+ self.treeButtons.addAction(self.projDetailsBtn)
+
+ self.projStatsBtn = QAction("Project Statistics")
+ self.projStatsBtn.setIcon(self.theTheme.getIcon("status_stats"))
+ self.projStatsBtn.triggered.connect(lambda: self.showWritingStatsDialog())
+ self.treeButtons.addAction(self.projStatsBtn)
+
+ self.projSettingsBtn = QAction("Project Settings")
+ self.projSettingsBtn.setIcon(self.theTheme.getIcon("settings"))
+ self.projSettingsBtn.triggered.connect(lambda: self.showProjectSettingsDialog())
+ self.treeButtons.addAction(self.projSettingsBtn)
+
# Project Tree View
self.treePane = QWidget()
self.treeBox = QVBoxLayout()
@@ -269,11 +293,18 @@ class GuiMain(QMainWindow):
def clearGUI(self):
"""Wrapper function to clear all sub-elements of the main GUI.
"""
+ # Project Area
self.treeView.clearTree()
self.novelView.clearTree()
+ self.treeMeta.clearDetails()
+
+ # Work Area
self.docEditor.clearEditor()
self.closeDocViewer()
+
+ # General
self.statusBar.clearStatus()
+
return True
def initMain(self):