Fix Project Details dialog update issue (#883)
* Move project details dialog to correct folder * Add update functions that are run each time the project details dialog is opened
This commit is contained in:
committed by
GitHub
parent
3c8cb34b0a
commit
8313de692e
@@ -24,6 +24,7 @@ from novelwriter.dialogs.docmerge import GuiDocMerge
|
||||
from novelwriter.dialogs.docsplit import GuiDocSplit
|
||||
from novelwriter.dialogs.itemeditor import GuiItemEditor
|
||||
from novelwriter.dialogs.preferences import GuiPreferences
|
||||
from novelwriter.dialogs.projdetails import GuiProjectDetails
|
||||
from novelwriter.dialogs.projload import GuiProjectLoad
|
||||
from novelwriter.dialogs.projsettings import GuiProjectSettings
|
||||
from novelwriter.dialogs.quotes import GuiQuoteSelect
|
||||
@@ -36,6 +37,7 @@ __all__ = [
|
||||
"GuiDocSplit",
|
||||
"GuiItemEditor",
|
||||
"GuiPreferences",
|
||||
"GuiProjectDetails",
|
||||
"GuiProjectLoad",
|
||||
"GuiProjectSettings",
|
||||
"GuiQuoteSelect",
|
||||
|
||||
@@ -81,6 +81,13 @@ class GuiProjectDetails(PagedDialog):
|
||||
|
||||
return
|
||||
|
||||
def updateValues(self):
|
||||
"""Set all the values of the pages.
|
||||
"""
|
||||
self.tabMain.updateValues()
|
||||
self.tabContents.updateValues()
|
||||
return
|
||||
|
||||
##
|
||||
# Slots
|
||||
##
|
||||
@@ -176,24 +183,20 @@ class GuiProjectDetailsMain(QWidget):
|
||||
# Stats
|
||||
# =====
|
||||
|
||||
hCounts = self.theIndex.getNovelTitleCounts()
|
||||
nwCount = self.theIndex.getNovelWordCount()
|
||||
|
||||
self.wordCountLbl = QLabel("<b>%s:</b>" % self.tr("Words"))
|
||||
self.wordCountVal = QLabel(f"{nwCount:n}")
|
||||
self.wordCountVal = QLabel("")
|
||||
|
||||
self.chapCountLbl = QLabel("<b>%s:</b>" % self.tr("Chapters"))
|
||||
self.chapCountVal = QLabel(f"{hCounts[2]:n}")
|
||||
self.chapCountVal = QLabel("")
|
||||
|
||||
self.sceneCountLbl = QLabel("<b>%s:</b>" % self.tr("Scenes"))
|
||||
self.sceneCountVal = QLabel(f"{hCounts[3]:n}")
|
||||
self.sceneCountVal = QLabel("")
|
||||
|
||||
self.revCountLbl = QLabel("<b>%s:</b>" % self.tr("Revisions"))
|
||||
self.revCountVal = QLabel(f"{self.theProject.saveCount:n}")
|
||||
self.revCountVal = QLabel("")
|
||||
|
||||
edTime = self.theProject.getCurrentEditTime()
|
||||
self.editTimeLbl = QLabel("<b>%s:</b>" % self.tr("Editing Time"))
|
||||
self.editTimeVal = QLabel(f"{edTime//3600:02d}:{edTime%3600//60:02d}")
|
||||
self.editTimeVal = QLabel("")
|
||||
|
||||
self.statsGrid = QGridLayout()
|
||||
self.statsGrid.addWidget(self.wordCountLbl, 0, 0, 1, 1, Qt.AlignRight)
|
||||
@@ -214,7 +217,6 @@ class GuiProjectDetailsMain(QWidget):
|
||||
|
||||
self.projPathLbl = QLabel("<b>%s:</b>" % self.tr("Path"))
|
||||
self.projPathVal = QLineEdit()
|
||||
self.projPathVal.setText(self.theProject.projPath)
|
||||
self.projPathVal.setReadOnly(True)
|
||||
|
||||
self.projPathBox = QHBoxLayout()
|
||||
@@ -240,6 +242,23 @@ class GuiProjectDetailsMain(QWidget):
|
||||
|
||||
return
|
||||
|
||||
def updateValues(self):
|
||||
"""Set all the values.
|
||||
"""
|
||||
hCounts = self.theIndex.getNovelTitleCounts()
|
||||
nwCount = self.theIndex.getNovelWordCount()
|
||||
edTime = self.theProject.getCurrentEditTime()
|
||||
|
||||
self.wordCountVal.setText(f"{nwCount:n}")
|
||||
self.chapCountVal.setText(f"{hCounts[2]:n}")
|
||||
self.sceneCountVal.setText(f"{hCounts[3]:n}")
|
||||
self.revCountVal.setText(f"{self.theProject.saveCount:n}")
|
||||
self.editTimeVal.setText(f"{edTime//3600:02d}:{edTime%3600//60:02d}")
|
||||
|
||||
self.projPathVal.setText(self.theProject.projPath)
|
||||
|
||||
return
|
||||
|
||||
# END Class GuiProjectDetailsMain
|
||||
|
||||
|
||||
@@ -376,9 +395,6 @@ class GuiProjectDetailsContents(QWidget):
|
||||
|
||||
self.setLayout(self.outerBox)
|
||||
|
||||
self._prepareData()
|
||||
self._populateTree()
|
||||
|
||||
return
|
||||
|
||||
def getColumnSizes(self):
|
||||
@@ -393,6 +409,13 @@ class GuiProjectDetailsContents(QWidget):
|
||||
]
|
||||
return retVals
|
||||
|
||||
def updateValues(self):
|
||||
"""Populate the tree.
|
||||
"""
|
||||
self._prepareData()
|
||||
self._populateTree()
|
||||
return
|
||||
|
||||
##
|
||||
# Internal Functions
|
||||
##
|
||||
@@ -26,7 +26,6 @@ from novelwriter.gui.mainmenu import GuiMainMenu
|
||||
from novelwriter.gui.noveltree import GuiNovelTree
|
||||
from novelwriter.gui.outline import GuiOutline
|
||||
from novelwriter.gui.outlinedetails import GuiOutlineDetails
|
||||
from novelwriter.gui.projdetails import GuiProjectDetails
|
||||
from novelwriter.gui.projtree import GuiProjectTree
|
||||
from novelwriter.gui.statusbar import GuiMainStatus
|
||||
from novelwriter.gui.theme import GuiTheme
|
||||
@@ -41,7 +40,6 @@ __all__ = [
|
||||
"GuiNovelTree",
|
||||
"GuiOutline",
|
||||
"GuiOutlineDetails",
|
||||
"GuiProjectDetails",
|
||||
"GuiProjectTree",
|
||||
"GuiTheme",
|
||||
]
|
||||
|
||||
@@ -39,12 +39,13 @@ from PyQt5.QtWidgets import (
|
||||
|
||||
from novelwriter.gui import (
|
||||
GuiDocEditor, GuiDocViewDetails, GuiDocViewer, GuiItemDetails, GuiMainMenu,
|
||||
GuiMainStatus, GuiNovelTree, GuiOutline, GuiOutlineDetails,
|
||||
GuiProjectDetails, GuiProjectTree, GuiTheme
|
||||
GuiMainStatus, GuiNovelTree, GuiOutline, GuiOutlineDetails, GuiProjectTree,
|
||||
GuiTheme
|
||||
)
|
||||
from novelwriter.dialogs import (
|
||||
GuiAbout, GuiDocMerge, GuiDocSplit, GuiItemEditor, GuiPreferences,
|
||||
GuiProjectLoad, GuiProjectSettings, GuiUpdates, GuiWordList
|
||||
GuiProjectDetails, GuiProjectLoad, GuiProjectSettings, GuiUpdates,
|
||||
GuiWordList
|
||||
)
|
||||
from novelwriter.tools import GuiBuildNovel, GuiProjectWizard, GuiWritingStats
|
||||
from novelwriter.core import NWProject, NWIndex
|
||||
@@ -1017,6 +1018,7 @@ class GuiMain(QMainWindow):
|
||||
dlgDetails.setModal(False)
|
||||
dlgDetails.show()
|
||||
dlgDetails.raise_()
|
||||
dlgDetails.updateValues()
|
||||
|
||||
return
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ from tools import getGuiItem
|
||||
|
||||
from PyQt5.QtWidgets import QAction, QMessageBox
|
||||
|
||||
from novelwriter.gui import GuiProjectDetails
|
||||
from novelwriter.dialogs import GuiProjectDetails
|
||||
|
||||
keyDelay = 2
|
||||
typeDelay = 1
|
||||
@@ -33,7 +33,7 @@ stepDelay = 20
|
||||
|
||||
|
||||
@pytest.mark.gui
|
||||
def testGuiProjDetails_Dialog(qtbot, monkeypatch, nwGUI, nwLipsum):
|
||||
def testDlgProjDetails_Dialog(qtbot, monkeypatch, nwGUI, nwLipsum):
|
||||
"""Test the project details dialog.
|
||||
"""
|
||||
# Block message box
|
||||
@@ -111,4 +111,4 @@ def testGuiProjDetails_Dialog(qtbot, monkeypatch, nwGUI, nwLipsum):
|
||||
projDet._doClose()
|
||||
nwGUI.closeMain()
|
||||
|
||||
# END Test testGuiProjDetails_Dialog
|
||||
# END Test testDlgProjDetails_Dialog
|
||||
Reference in New Issue
Block a user