Fix minor GUI issues (#1253)
This commit is contained in:
+74
-71
@@ -2063,38 +2063,38 @@
|
||||
<context>
|
||||
<name>GuiMainStatus</name>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/statusbar.py" line="221" />
|
||||
<location filename="../novelwriter/gui/statusbar.py" line="67" />
|
||||
<location filename="../novelwriter/gui/statusbar.py" line="222" />
|
||||
<location filename="../novelwriter/gui/statusbar.py" line="68" />
|
||||
<source>None</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/statusbar.py" line="75" />
|
||||
<location filename="../novelwriter/gui/statusbar.py" line="76" />
|
||||
<source>Editor</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/statusbar.py" line="83" />
|
||||
<location filename="../novelwriter/gui/statusbar.py" line="84" />
|
||||
<source>Project</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/statusbar.py" line="101" />
|
||||
<location filename="../novelwriter/gui/statusbar.py" line="102" />
|
||||
<source>Session Time</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/statusbar.py" line="192" />
|
||||
<location filename="../novelwriter/gui/statusbar.py" line="193" />
|
||||
<source>Words: {0} ({1})</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/statusbar.py" line="194" />
|
||||
<location filename="../novelwriter/gui/statusbar.py" line="195" />
|
||||
<source>Project word count (session change)</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/statusbar.py" line="196" />
|
||||
<location filename="../novelwriter/gui/statusbar.py" line="197" />
|
||||
<source>Novel word count (session change)</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
@@ -2102,47 +2102,47 @@
|
||||
<context>
|
||||
<name>GuiNovelToolBar</name>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/noveltree.py" line="203" />
|
||||
<source>Novel Outline</source>
|
||||
<location filename="../novelwriter/gui/noveltree.py" line="207" />
|
||||
<source>Outline of {0}</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/noveltree.py" line="209" />
|
||||
<source>Refresh</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/noveltree.py" line="219" />
|
||||
<location filename="../novelwriter/gui/noveltree.py" line="215" />
|
||||
<source>Novel Root</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/noveltree.py" line="227" />
|
||||
<location filename="../novelwriter/gui/noveltree.py" line="221" />
|
||||
<source>Refresh</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/noveltree.py" line="228" />
|
||||
<source>Last Column</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/noveltree.py" line="230" />
|
||||
<location filename="../novelwriter/gui/noveltree.py" line="231" />
|
||||
<source>Hidden</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/noveltree.py" line="231" />
|
||||
<location filename="../novelwriter/gui/noveltree.py" line="232" />
|
||||
<source>Point of View Character</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/noveltree.py" line="232" />
|
||||
<location filename="../novelwriter/gui/noveltree.py" line="233" />
|
||||
<source>Focus Character</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/noveltree.py" line="233" />
|
||||
<location filename="../novelwriter/gui/noveltree.py" line="234" />
|
||||
<source>Novel Plot</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/noveltree.py" line="236" />
|
||||
<location filename="../novelwriter/gui/noveltree.py" line="237" />
|
||||
<source>More Options</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
@@ -2150,7 +2150,7 @@
|
||||
<context>
|
||||
<name>GuiNovelTree</name>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/noveltree.py" line="771" />
|
||||
<location filename="../novelwriter/gui/noveltree.py" line="778" />
|
||||
<source>No meta data</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
@@ -2158,65 +2158,65 @@
|
||||
<context>
|
||||
<name>GuiOutlineDetails</name>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/outline.py" line="1061" />
|
||||
<location filename="../novelwriter/gui/outline.py" line="1022" />
|
||||
<location filename="../novelwriter/gui/outline.py" line="826" />
|
||||
<location filename="../novelwriter/gui/outline.py" line="799" />
|
||||
<location filename="../novelwriter/gui/outline.py" line="1053" />
|
||||
<location filename="../novelwriter/gui/outline.py" line="1014" />
|
||||
<location filename="../novelwriter/gui/outline.py" line="818" />
|
||||
<location filename="../novelwriter/gui/outline.py" line="791" />
|
||||
<source>Title</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/outline.py" line="800" />
|
||||
<location filename="../novelwriter/gui/outline.py" line="792" />
|
||||
<source>Chapter</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/outline.py" line="801" />
|
||||
<location filename="../novelwriter/gui/outline.py" line="793" />
|
||||
<source>Scene</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/outline.py" line="802" />
|
||||
<location filename="../novelwriter/gui/outline.py" line="794" />
|
||||
<source>Section</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/outline.py" line="827" />
|
||||
<location filename="../novelwriter/gui/outline.py" line="819" />
|
||||
<source>Document</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/outline.py" line="828" />
|
||||
<location filename="../novelwriter/gui/outline.py" line="820" />
|
||||
<source>Status</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/outline.py" line="841" />
|
||||
<location filename="../novelwriter/gui/outline.py" line="833" />
|
||||
<source>Characters</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/outline.py" line="842" />
|
||||
<location filename="../novelwriter/gui/outline.py" line="834" />
|
||||
<source>Words</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/outline.py" line="843" />
|
||||
<location filename="../novelwriter/gui/outline.py" line="835" />
|
||||
<source>Paragraphs</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/outline.py" line="856" />
|
||||
<location filename="../novelwriter/gui/outline.py" line="848" />
|
||||
<source>Synopsis</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/outline.py" line="928" />
|
||||
<location filename="../novelwriter/gui/outline.py" line="920" />
|
||||
<source>Title Details</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/outline.py" line="953" />
|
||||
<location filename="../novelwriter/gui/outline.py" line="945" />
|
||||
<source>Reference Tags</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
@@ -2224,7 +2224,7 @@
|
||||
<context>
|
||||
<name>GuiOutlineHeaderMenu</name>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/outline.py" line="761" />
|
||||
<location filename="../novelwriter/gui/outline.py" line="753" />
|
||||
<source>Select Columns</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
@@ -2232,20 +2232,15 @@
|
||||
<context>
|
||||
<name>GuiOutlineToolBar</name>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/outline.py" line="233" />
|
||||
<location filename="../novelwriter/gui/outline.py" line="234" />
|
||||
<source>Outline of</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/outline.py" line="241" />
|
||||
<location filename="../novelwriter/gui/outline.py" line="242" />
|
||||
<source>Refresh</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/outline.py" line="290" />
|
||||
<source>All Novel Folders</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>GuiPreferences</name>
|
||||
@@ -2923,17 +2918,17 @@
|
||||
<context>
|
||||
<name>GuiProjectDetails</name>
|
||||
<message>
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="58" />
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="57" />
|
||||
<source>Project Details</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="74" />
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="73" />
|
||||
<source>Overview</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="75" />
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="74" />
|
||||
<source>Contents</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
@@ -2941,72 +2936,72 @@
|
||||
<context>
|
||||
<name>GuiProjectDetailsContents</name>
|
||||
<message>
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="298" />
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="297" />
|
||||
<source>Table of Contents</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="317" />
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="316" />
|
||||
<source>Title</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="318" />
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="317" />
|
||||
<source>Words</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="319" />
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="318" />
|
||||
<source>Pages</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="320" />
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="319" />
|
||||
<source>Page</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="321" />
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="320" />
|
||||
<source>Progress</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="356" />
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="355" />
|
||||
<source>Typical word count for a 5 by 8 inch book page with 11 pt font is 350.</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="359" />
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="358" />
|
||||
<source>Start counting page numbers from this page.</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="362" />
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="361" />
|
||||
<source>Assume a new chapter or partition always start on an odd numbered page.</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="365" />
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="364" />
|
||||
<source>Words per page</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="376" />
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="375" />
|
||||
<source>Count pages from</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="387" />
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="386" />
|
||||
<source>Clear double pages</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="462" />
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="449" />
|
||||
<source>END</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="517" />
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="503" />
|
||||
<source>Untitled</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
@@ -3014,42 +3009,42 @@
|
||||
<context>
|
||||
<name>GuiProjectDetailsMain</name>
|
||||
<message>
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="169" />
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="168" />
|
||||
<source>Working Title: {0}</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="178" />
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="177" />
|
||||
<source>By {0}</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="190" />
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="189" />
|
||||
<source>Words</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="193" />
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="192" />
|
||||
<source>Chapters</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="196" />
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="195" />
|
||||
<source>Scenes</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="199" />
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="198" />
|
||||
<source>Revisions</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="202" />
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="201" />
|
||||
<source>Editing Time</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="222" />
|
||||
<location filename="../novelwriter/dialogs/projdetails.py" line="221" />
|
||||
<source>Path</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
@@ -4004,6 +3999,14 @@
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>NovelSelector</name>
|
||||
<message>
|
||||
<location filename="../novelwriter/gui/components.py" line="106" />
|
||||
<source>All Novel Folders</source>
|
||||
<translation type="unfinished" />
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ProjWizardCustomPage</name>
|
||||
<message>
|
||||
|
||||
@@ -30,15 +30,14 @@ import novelwriter
|
||||
from PyQt5.QtCore import Qt, QSize, pyqtSlot
|
||||
from PyQt5.QtGui import QFont
|
||||
from PyQt5.QtWidgets import (
|
||||
QAbstractItemView, QComboBox, QDialogButtonBox, QGridLayout, QHBoxLayout,
|
||||
QLabel, QLineEdit, QSpinBox, QTreeWidget, QTreeWidgetItem, QVBoxLayout,
|
||||
QWidget
|
||||
QAbstractItemView, QDialogButtonBox, QGridLayout, QHBoxLayout, QLabel,
|
||||
QLineEdit, QSpinBox, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget
|
||||
)
|
||||
|
||||
from novelwriter.enum import nwItemClass
|
||||
from novelwriter.common import numberToRoman
|
||||
from novelwriter.custom import PagedDialog, QSwitch
|
||||
from novelwriter.constants import nwLabels, nwUnicode
|
||||
from novelwriter.constants import nwUnicode
|
||||
from novelwriter.gui.components import NovelSelector
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -297,9 +296,9 @@ class GuiProjectDetailsContents(QWidget):
|
||||
|
||||
self.tocLabel = QLabel("<b>%s</b>" % self.tr("Table of Contents"))
|
||||
|
||||
self.novelValue = QComboBox(self)
|
||||
self.novelValue = NovelSelector(self, self.theProject, self.mainGui)
|
||||
self.novelValue.setMinimumWidth(self.mainConf.pxInt(200))
|
||||
self.novelValue.currentIndexChanged.connect(self._novelValueChanged)
|
||||
self.novelValue.novelSelectionChanged.connect(self._novelValueChanged)
|
||||
|
||||
self.headBox = QHBoxLayout()
|
||||
self.headBox.addWidget(self.tocLabel)
|
||||
@@ -431,10 +430,9 @@ class GuiProjectDetailsContents(QWidget):
|
||||
"""Populate the tree.
|
||||
"""
|
||||
self._currentRoot = None
|
||||
self._populateNovelList()
|
||||
|
||||
rootHandle = self.novelValue.currentData()
|
||||
self._prepareData(rootHandle)
|
||||
self.novelValue.updateList()
|
||||
self.novelValue.setHandle(self.novelValue.firstHandle)
|
||||
self._prepareData(self.novelValue.firstHandle)
|
||||
self._populateTree()
|
||||
|
||||
return
|
||||
@@ -443,17 +441,6 @@ class GuiProjectDetailsContents(QWidget):
|
||||
# Internal Functions
|
||||
##
|
||||
|
||||
def _populateNovelList(self):
|
||||
"""Fill the novel combo box with a list of all novel folders.
|
||||
"""
|
||||
self.novelValue.clear()
|
||||
|
||||
tIcon = self.mainTheme.getIcon(nwLabels.CLASS_ICON[nwItemClass.NOVEL])
|
||||
for tHandle, nwItem in self.theProject.tree.iterRoots(nwItemClass.NOVEL):
|
||||
self.novelValue.addItem(tIcon, nwItem.itemName, tHandle)
|
||||
|
||||
return
|
||||
|
||||
def _prepareData(self, rootHandle):
|
||||
"""Extract the information from the project index.
|
||||
"""
|
||||
@@ -466,15 +453,14 @@ class GuiProjectDetailsContents(QWidget):
|
||||
# Slots
|
||||
##
|
||||
|
||||
@pyqtSlot()
|
||||
def _novelValueChanged(self):
|
||||
@pyqtSlot(str)
|
||||
def _novelValueChanged(self, tHandle):
|
||||
"""Refresh the tree with another root item.
|
||||
"""
|
||||
rootHandle = self.novelValue.currentData()
|
||||
if rootHandle != self._currentRoot:
|
||||
self._prepareData(rootHandle)
|
||||
if tHandle != self._currentRoot:
|
||||
self._prepareData(tHandle)
|
||||
self._populateTree()
|
||||
self._currentRoot = rootHandle
|
||||
self._currentRoot = self.novelValue.handle
|
||||
return
|
||||
|
||||
@pyqtSlot()
|
||||
|
||||
@@ -40,20 +40,35 @@ class NovelSelector(QComboBox):
|
||||
|
||||
novelSelectionChanged = pyqtSignal(str)
|
||||
|
||||
def __init__(self, parent, project, theme):
|
||||
def __init__(self, parent, project, mainGui):
|
||||
super().__init__(parent=parent)
|
||||
|
||||
self._mainGui = mainGui
|
||||
self._project = project
|
||||
self._theme = theme
|
||||
self._theme = mainGui.mainTheme
|
||||
self._blockSignal = False
|
||||
self._firstHandle = None
|
||||
|
||||
self.currentIndexChanged.connect(self._indexChanged)
|
||||
|
||||
return
|
||||
|
||||
##
|
||||
# Properties
|
||||
##
|
||||
|
||||
@property
|
||||
def handle(self):
|
||||
return self.currentData()
|
||||
|
||||
@property
|
||||
def firstHandle(self):
|
||||
return self._firstHandle
|
||||
|
||||
##
|
||||
# Methods
|
||||
##
|
||||
|
||||
def setHandle(self, tHandle, blockSignal=True):
|
||||
"""Set the currently selected handle.
|
||||
"""
|
||||
@@ -71,6 +86,7 @@ class NovelSelector(QComboBox):
|
||||
"""Rebuild the list of novel items.
|
||||
"""
|
||||
self._blockSignal = True
|
||||
self._firstHandle = None
|
||||
self.clear()
|
||||
|
||||
icon = self._theme.getIcon(nwLabels.CLASS_ICON[nwItemClass.NOVEL])
|
||||
@@ -82,13 +98,12 @@ class NovelSelector(QComboBox):
|
||||
else:
|
||||
name = nwItem.itemName
|
||||
self.addItem(icon, nwItem.itemName, tHandle)
|
||||
if self._firstHandle is None:
|
||||
self._firstHandle = tHandle
|
||||
|
||||
if includeAll:
|
||||
self.insertSeparator(self.count())
|
||||
if prefix:
|
||||
self.addItem(prefix.format(self.tr("All Novel Folders")), "")
|
||||
else:
|
||||
self.addItem(icon, self.tr("All Novel Folders"), "")
|
||||
self.addItem(icon, self.tr("All Novel Folders"), "")
|
||||
|
||||
self.setHandle(handle)
|
||||
self.setEnabled(self.count() > 1)
|
||||
@@ -102,6 +117,8 @@ class NovelSelector(QComboBox):
|
||||
|
||||
@pyqtSlot(int)
|
||||
def _indexChanged(self, index):
|
||||
"""Re-emit the change of selected novel signal, unless blocked.
|
||||
"""
|
||||
if not self._blockSignal:
|
||||
self.novelSelectionChanged.emit(self.currentData())
|
||||
return
|
||||
|
||||
@@ -191,6 +191,7 @@ class GuiNovelToolBar(QWidget):
|
||||
|
||||
self.mainConf = novelwriter.CONFIG
|
||||
self.novelView = novelView
|
||||
self.mainGui = novelView.mainGui
|
||||
self.theProject = novelView.mainGui.theProject
|
||||
self.mainTheme = novelView.mainGui.mainTheme
|
||||
|
||||
@@ -204,12 +205,17 @@ class GuiNovelToolBar(QWidget):
|
||||
selFont = self.font()
|
||||
selFont.setWeight(QFont.Bold)
|
||||
self.novelPrefix = self.tr("Outline of {0}")
|
||||
self.novelValue = NovelSelector(self, self.theProject, self.mainTheme)
|
||||
self.novelValue = NovelSelector(self, self.theProject, self.mainGui)
|
||||
self.novelValue.setFont(selFont)
|
||||
self.novelValue.setMinimumWidth(self.mainConf.pxInt(150))
|
||||
self.novelValue.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
||||
self.novelValue.novelSelectionChanged.connect(self.setCurrentRoot)
|
||||
|
||||
self.tbNovel = QToolButton(self)
|
||||
self.tbNovel.setToolTip(self.tr("Novel Root"))
|
||||
self.tbNovel.setIconSize(QSize(iPx, iPx))
|
||||
self.tbNovel.clicked.connect(self._openNovelSelector)
|
||||
|
||||
# Refresh Button
|
||||
self.tbRefresh = QToolButton(self)
|
||||
self.tbRefresh.setToolTip(self.tr("Refresh"))
|
||||
@@ -236,6 +242,7 @@ class GuiNovelToolBar(QWidget):
|
||||
# Assemble
|
||||
self.outerBox = QHBoxLayout()
|
||||
self.outerBox.addWidget(self.novelValue)
|
||||
self.outerBox.addWidget(self.tbNovel)
|
||||
self.outerBox.addWidget(self.tbRefresh)
|
||||
self.outerBox.addWidget(self.tbMore)
|
||||
self.outerBox.setContentsMargins(mPx, mPx, 0, mPx)
|
||||
@@ -257,6 +264,7 @@ class GuiNovelToolBar(QWidget):
|
||||
"""Update theme elements.
|
||||
"""
|
||||
# Icons
|
||||
self.tbNovel.setIcon(self.mainTheme.getIcon("cls_novel"))
|
||||
self.tbRefresh.setIcon(self.mainTheme.getIcon("refresh"))
|
||||
self.tbMore.setIcon(self.mainTheme.getIcon("menu"))
|
||||
|
||||
@@ -271,6 +279,7 @@ class GuiNovelToolBar(QWidget):
|
||||
"QToolButton:hover {{border: none; background: rgba({1},{2},{3},0.2);}}"
|
||||
).format(self.mainConf.pxInt(2), fadeCol.red(), fadeCol.green(), fadeCol.blue())
|
||||
|
||||
self.tbNovel.setStyleSheet(buttonStyle)
|
||||
self.tbRefresh.setStyleSheet(buttonStyle)
|
||||
self.tbMore.setStyleSheet(buttonStyle)
|
||||
|
||||
@@ -279,10 +288,7 @@ class GuiNovelToolBar(QWidget):
|
||||
"QComboBox::drop-down {border-style: none}"
|
||||
)
|
||||
self.novelValue.updateList(prefix=self.novelPrefix)
|
||||
if self.novelValue.count() > 1:
|
||||
self.novelValue.setToolTip(self.tr("Click to change root folder"))
|
||||
else:
|
||||
self.novelValue.setToolTip("")
|
||||
self.tbNovel.setVisible(self.novelValue.count() > 1)
|
||||
|
||||
return
|
||||
|
||||
@@ -297,10 +303,7 @@ class GuiNovelToolBar(QWidget):
|
||||
"""Build the novel root menu.
|
||||
"""
|
||||
self.novelValue.updateList(prefix=self.novelPrefix)
|
||||
if self.novelValue.count() > 1:
|
||||
self.novelValue.setToolTip(self.tr("Click to change root folder"))
|
||||
else:
|
||||
self.novelValue.setToolTip("")
|
||||
self.tbNovel.setVisible(self.novelValue.count() > 1)
|
||||
return
|
||||
|
||||
def setCurrentRoot(self, rootHandle):
|
||||
@@ -321,6 +324,13 @@ class GuiNovelToolBar(QWidget):
|
||||
# Private Slots
|
||||
##
|
||||
|
||||
@pyqtSlot()
|
||||
def _openNovelSelector(self):
|
||||
"""Trigger the dropdown list of the novel selector.
|
||||
"""
|
||||
self.novelValue.showPopup()
|
||||
return
|
||||
|
||||
@pyqtSlot()
|
||||
def _refreshNovelTree(self):
|
||||
"""Rebuild the current tree.
|
||||
@@ -519,13 +529,14 @@ class GuiNovelTree(QTreeWidget):
|
||||
return
|
||||
|
||||
def getSelectedHandle(self):
|
||||
"""Get the currently selected handle. If multiple items are
|
||||
selected, return the first.
|
||||
"""Get the currently selected or active handle. If multiple
|
||||
items are selected, return the first.
|
||||
"""
|
||||
selItem = self.selectedItems()
|
||||
if selItem:
|
||||
tHandle = selItem[0].data(self.C_TITLE, self.D_HANDLE)
|
||||
sTitle = selItem[0].data(self.C_TITLE, self.D_TITLE)
|
||||
selList = self.selectedItems()
|
||||
trItem = selList[0] if selList else self.currentItem()
|
||||
if isinstance(trItem, QTreeWidgetItem):
|
||||
tHandle = trItem.data(self.C_TITLE, self.D_HANDLE)
|
||||
sTitle = trItem.data(self.C_TITLE, self.D_TITLE)
|
||||
return tHandle, sTitle
|
||||
return None, None
|
||||
|
||||
|
||||
@@ -234,7 +234,7 @@ class GuiOutlineToolBar(QToolBar):
|
||||
self.novelLabel = QLabel(self.tr("Outline of"))
|
||||
self.novelLabel.setContentsMargins(0, 0, mPx, 0)
|
||||
|
||||
self.novelValue = NovelSelector(self, self.theProject, self.mainTheme)
|
||||
self.novelValue = NovelSelector(self, self.theProject, self.mainGui)
|
||||
self.novelValue.setMinimumWidth(self.mainConf.pxInt(200))
|
||||
self.novelValue.novelSelectionChanged.connect(self._novelValueChanged)
|
||||
|
||||
|
||||
@@ -93,6 +93,11 @@ def testDlgProjDetails_Dialog(qtbot, nwGUI, nwLipsum):
|
||||
assert tocTree.topLevelItem(i).text(tocTab.C_PAGES) == thePages[i]
|
||||
assert tocTree.topLevelItem(i).text(tocTab.C_PAGE) == thePage[i]
|
||||
|
||||
# Re-populate
|
||||
assert tocTab._currentRoot is None
|
||||
tocTab._novelValueChanged("7a992350f3eb6") # Not a root
|
||||
assert tocTab._currentRoot == "b3643d0f92e32" # The actual novel root
|
||||
|
||||
# qtbot.stop()
|
||||
|
||||
# Clean Up
|
||||
|
||||
Reference in New Issue
Block a user