Skip to content

Commit 8313de6

Browse files
authored
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
1 parent 3c8cb34 commit 8313de6

File tree

5 files changed

+46
-21
lines changed

5 files changed

+46
-21
lines changed

novelwriter/dialogs/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from novelwriter.dialogs.docsplit import GuiDocSplit
2525
from novelwriter.dialogs.itemeditor import GuiItemEditor
2626
from novelwriter.dialogs.preferences import GuiPreferences
27+
from novelwriter.dialogs.projdetails import GuiProjectDetails
2728
from novelwriter.dialogs.projload import GuiProjectLoad
2829
from novelwriter.dialogs.projsettings import GuiProjectSettings
2930
from novelwriter.dialogs.quotes import GuiQuoteSelect
@@ -36,6 +37,7 @@
3637
"GuiDocSplit",
3738
"GuiItemEditor",
3839
"GuiPreferences",
40+
"GuiProjectDetails",
3941
"GuiProjectLoad",
4042
"GuiProjectSettings",
4143
"GuiQuoteSelect",

novelwriter/gui/projdetails.py renamed to novelwriter/dialogs/projdetails.py

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ def __init__(self, theParent):
8181

8282
return
8383

84+
def updateValues(self):
85+
"""Set all the values of the pages.
86+
"""
87+
self.tabMain.updateValues()
88+
self.tabContents.updateValues()
89+
return
90+
8491
##
8592
# Slots
8693
##
@@ -176,24 +183,20 @@ def __init__(self, theParent, theProject):
176183
# Stats
177184
# =====
178185

179-
hCounts = self.theIndex.getNovelTitleCounts()
180-
nwCount = self.theIndex.getNovelWordCount()
181-
182186
self.wordCountLbl = QLabel("<b>%s:</b>" % self.tr("Words"))
183-
self.wordCountVal = QLabel(f"{nwCount:n}")
187+
self.wordCountVal = QLabel("")
184188

185189
self.chapCountLbl = QLabel("<b>%s:</b>" % self.tr("Chapters"))
186-
self.chapCountVal = QLabel(f"{hCounts[2]:n}")
190+
self.chapCountVal = QLabel("")
187191

188192
self.sceneCountLbl = QLabel("<b>%s:</b>" % self.tr("Scenes"))
189-
self.sceneCountVal = QLabel(f"{hCounts[3]:n}")
193+
self.sceneCountVal = QLabel("")
190194

191195
self.revCountLbl = QLabel("<b>%s:</b>" % self.tr("Revisions"))
192-
self.revCountVal = QLabel(f"{self.theProject.saveCount:n}")
196+
self.revCountVal = QLabel("")
193197

194-
edTime = self.theProject.getCurrentEditTime()
195198
self.editTimeLbl = QLabel("<b>%s:</b>" % self.tr("Editing Time"))
196-
self.editTimeVal = QLabel(f"{edTime//3600:02d}:{edTime%3600//60:02d}")
199+
self.editTimeVal = QLabel("")
197200

198201
self.statsGrid = QGridLayout()
199202
self.statsGrid.addWidget(self.wordCountLbl, 0, 0, 1, 1, Qt.AlignRight)
@@ -214,7 +217,6 @@ def __init__(self, theParent, theProject):
214217

215218
self.projPathLbl = QLabel("<b>%s:</b>" % self.tr("Path"))
216219
self.projPathVal = QLineEdit()
217-
self.projPathVal.setText(self.theProject.projPath)
218220
self.projPathVal.setReadOnly(True)
219221

220222
self.projPathBox = QHBoxLayout()
@@ -240,6 +242,23 @@ def __init__(self, theParent, theProject):
240242

241243
return
242244

245+
def updateValues(self):
246+
"""Set all the values.
247+
"""
248+
hCounts = self.theIndex.getNovelTitleCounts()
249+
nwCount = self.theIndex.getNovelWordCount()
250+
edTime = self.theProject.getCurrentEditTime()
251+
252+
self.wordCountVal.setText(f"{nwCount:n}")
253+
self.chapCountVal.setText(f"{hCounts[2]:n}")
254+
self.sceneCountVal.setText(f"{hCounts[3]:n}")
255+
self.revCountVal.setText(f"{self.theProject.saveCount:n}")
256+
self.editTimeVal.setText(f"{edTime//3600:02d}:{edTime%3600//60:02d}")
257+
258+
self.projPathVal.setText(self.theProject.projPath)
259+
260+
return
261+
243262
# END Class GuiProjectDetailsMain
244263

245264

@@ -376,9 +395,6 @@ def __init__(self, theParent, theProject):
376395

377396
self.setLayout(self.outerBox)
378397

379-
self._prepareData()
380-
self._populateTree()
381-
382398
return
383399

384400
def getColumnSizes(self):
@@ -393,6 +409,13 @@ def getColumnSizes(self):
393409
]
394410
return retVals
395411

412+
def updateValues(self):
413+
"""Populate the tree.
414+
"""
415+
self._prepareData()
416+
self._populateTree()
417+
return
418+
396419
##
397420
# Internal Functions
398421
##

novelwriter/gui/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
from novelwriter.gui.noveltree import GuiNovelTree
2727
from novelwriter.gui.outline import GuiOutline
2828
from novelwriter.gui.outlinedetails import GuiOutlineDetails
29-
from novelwriter.gui.projdetails import GuiProjectDetails
3029
from novelwriter.gui.projtree import GuiProjectTree
3130
from novelwriter.gui.statusbar import GuiMainStatus
3231
from novelwriter.gui.theme import GuiTheme
@@ -41,7 +40,6 @@
4140
"GuiNovelTree",
4241
"GuiOutline",
4342
"GuiOutlineDetails",
44-
"GuiProjectDetails",
4543
"GuiProjectTree",
4644
"GuiTheme",
4745
]

novelwriter/guimain.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,13 @@
3939

4040
from novelwriter.gui import (
4141
GuiDocEditor, GuiDocViewDetails, GuiDocViewer, GuiItemDetails, GuiMainMenu,
42-
GuiMainStatus, GuiNovelTree, GuiOutline, GuiOutlineDetails,
43-
GuiProjectDetails, GuiProjectTree, GuiTheme
42+
GuiMainStatus, GuiNovelTree, GuiOutline, GuiOutlineDetails, GuiProjectTree,
43+
GuiTheme
4444
)
4545
from novelwriter.dialogs import (
4646
GuiAbout, GuiDocMerge, GuiDocSplit, GuiItemEditor, GuiPreferences,
47-
GuiProjectLoad, GuiProjectSettings, GuiUpdates, GuiWordList
47+
GuiProjectDetails, GuiProjectLoad, GuiProjectSettings, GuiUpdates,
48+
GuiWordList
4849
)
4950
from novelwriter.tools import GuiBuildNovel, GuiProjectWizard, GuiWritingStats
5051
from novelwriter.core import NWProject, NWIndex
@@ -1017,6 +1018,7 @@ def showProjectDetailsDialog(self):
10171018
dlgDetails.setModal(False)
10181019
dlgDetails.show()
10191020
dlgDetails.raise_()
1021+
dlgDetails.updateValues()
10201022

10211023
return
10221024

tests/test_gui/test_gui_projdetails.py renamed to tests/test_dialogs/test_dlg_projdetails.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525

2626
from PyQt5.QtWidgets import QAction, QMessageBox
2727

28-
from novelwriter.gui import GuiProjectDetails
28+
from novelwriter.dialogs import GuiProjectDetails
2929

3030
keyDelay = 2
3131
typeDelay = 1
3232
stepDelay = 20
3333

3434

3535
@pytest.mark.gui
36-
def testGuiProjDetails_Dialog(qtbot, monkeypatch, nwGUI, nwLipsum):
36+
def testDlgProjDetails_Dialog(qtbot, monkeypatch, nwGUI, nwLipsum):
3737
"""Test the project details dialog.
3838
"""
3939
# Block message box
@@ -111,4 +111,4 @@ def testGuiProjDetails_Dialog(qtbot, monkeypatch, nwGUI, nwLipsum):
111111
projDet._doClose()
112112
nwGUI.closeMain()
113113

114-
# END Test testGuiProjDetails_Dialog
114+
# END Test testDlgProjDetails_Dialog

0 commit comments

Comments
 (0)