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.docsplit import GuiDocSplit
|
||||||
from novelwriter.dialogs.itemeditor import GuiItemEditor
|
from novelwriter.dialogs.itemeditor import GuiItemEditor
|
||||||
from novelwriter.dialogs.preferences import GuiPreferences
|
from novelwriter.dialogs.preferences import GuiPreferences
|
||||||
|
from novelwriter.dialogs.projdetails import GuiProjectDetails
|
||||||
from novelwriter.dialogs.projload import GuiProjectLoad
|
from novelwriter.dialogs.projload import GuiProjectLoad
|
||||||
from novelwriter.dialogs.projsettings import GuiProjectSettings
|
from novelwriter.dialogs.projsettings import GuiProjectSettings
|
||||||
from novelwriter.dialogs.quotes import GuiQuoteSelect
|
from novelwriter.dialogs.quotes import GuiQuoteSelect
|
||||||
@@ -36,6 +37,7 @@ __all__ = [
|
|||||||
"GuiDocSplit",
|
"GuiDocSplit",
|
||||||
"GuiItemEditor",
|
"GuiItemEditor",
|
||||||
"GuiPreferences",
|
"GuiPreferences",
|
||||||
|
"GuiProjectDetails",
|
||||||
"GuiProjectLoad",
|
"GuiProjectLoad",
|
||||||
"GuiProjectSettings",
|
"GuiProjectSettings",
|
||||||
"GuiQuoteSelect",
|
"GuiQuoteSelect",
|
||||||
|
|||||||
@@ -81,6 +81,13 @@ class GuiProjectDetails(PagedDialog):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def updateValues(self):
|
||||||
|
"""Set all the values of the pages.
|
||||||
|
"""
|
||||||
|
self.tabMain.updateValues()
|
||||||
|
self.tabContents.updateValues()
|
||||||
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Slots
|
# Slots
|
||||||
##
|
##
|
||||||
@@ -176,24 +183,20 @@ class GuiProjectDetailsMain(QWidget):
|
|||||||
# Stats
|
# Stats
|
||||||
# =====
|
# =====
|
||||||
|
|
||||||
hCounts = self.theIndex.getNovelTitleCounts()
|
|
||||||
nwCount = self.theIndex.getNovelWordCount()
|
|
||||||
|
|
||||||
self.wordCountLbl = QLabel("<b>%s:</b>" % self.tr("Words"))
|
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.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.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.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.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 = QGridLayout()
|
||||||
self.statsGrid.addWidget(self.wordCountLbl, 0, 0, 1, 1, Qt.AlignRight)
|
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.projPathLbl = QLabel("<b>%s:</b>" % self.tr("Path"))
|
||||||
self.projPathVal = QLineEdit()
|
self.projPathVal = QLineEdit()
|
||||||
self.projPathVal.setText(self.theProject.projPath)
|
|
||||||
self.projPathVal.setReadOnly(True)
|
self.projPathVal.setReadOnly(True)
|
||||||
|
|
||||||
self.projPathBox = QHBoxLayout()
|
self.projPathBox = QHBoxLayout()
|
||||||
@@ -240,6 +242,23 @@ class GuiProjectDetailsMain(QWidget):
|
|||||||
|
|
||||||
return
|
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
|
# END Class GuiProjectDetailsMain
|
||||||
|
|
||||||
|
|
||||||
@@ -376,9 +395,6 @@ class GuiProjectDetailsContents(QWidget):
|
|||||||
|
|
||||||
self.setLayout(self.outerBox)
|
self.setLayout(self.outerBox)
|
||||||
|
|
||||||
self._prepareData()
|
|
||||||
self._populateTree()
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def getColumnSizes(self):
|
def getColumnSizes(self):
|
||||||
@@ -393,6 +409,13 @@ class GuiProjectDetailsContents(QWidget):
|
|||||||
]
|
]
|
||||||
return retVals
|
return retVals
|
||||||
|
|
||||||
|
def updateValues(self):
|
||||||
|
"""Populate the tree.
|
||||||
|
"""
|
||||||
|
self._prepareData()
|
||||||
|
self._populateTree()
|
||||||
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Internal Functions
|
# Internal Functions
|
||||||
##
|
##
|
||||||
@@ -26,7 +26,6 @@ from novelwriter.gui.mainmenu import GuiMainMenu
|
|||||||
from novelwriter.gui.noveltree import GuiNovelTree
|
from novelwriter.gui.noveltree import GuiNovelTree
|
||||||
from novelwriter.gui.outline import GuiOutline
|
from novelwriter.gui.outline import GuiOutline
|
||||||
from novelwriter.gui.outlinedetails import GuiOutlineDetails
|
from novelwriter.gui.outlinedetails import GuiOutlineDetails
|
||||||
from novelwriter.gui.projdetails import GuiProjectDetails
|
|
||||||
from novelwriter.gui.projtree import GuiProjectTree
|
from novelwriter.gui.projtree import GuiProjectTree
|
||||||
from novelwriter.gui.statusbar import GuiMainStatus
|
from novelwriter.gui.statusbar import GuiMainStatus
|
||||||
from novelwriter.gui.theme import GuiTheme
|
from novelwriter.gui.theme import GuiTheme
|
||||||
@@ -41,7 +40,6 @@ __all__ = [
|
|||||||
"GuiNovelTree",
|
"GuiNovelTree",
|
||||||
"GuiOutline",
|
"GuiOutline",
|
||||||
"GuiOutlineDetails",
|
"GuiOutlineDetails",
|
||||||
"GuiProjectDetails",
|
|
||||||
"GuiProjectTree",
|
"GuiProjectTree",
|
||||||
"GuiTheme",
|
"GuiTheme",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -39,12 +39,13 @@ from PyQt5.QtWidgets import (
|
|||||||
|
|
||||||
from novelwriter.gui import (
|
from novelwriter.gui import (
|
||||||
GuiDocEditor, GuiDocViewDetails, GuiDocViewer, GuiItemDetails, GuiMainMenu,
|
GuiDocEditor, GuiDocViewDetails, GuiDocViewer, GuiItemDetails, GuiMainMenu,
|
||||||
GuiMainStatus, GuiNovelTree, GuiOutline, GuiOutlineDetails,
|
GuiMainStatus, GuiNovelTree, GuiOutline, GuiOutlineDetails, GuiProjectTree,
|
||||||
GuiProjectDetails, GuiProjectTree, GuiTheme
|
GuiTheme
|
||||||
)
|
)
|
||||||
from novelwriter.dialogs import (
|
from novelwriter.dialogs import (
|
||||||
GuiAbout, GuiDocMerge, GuiDocSplit, GuiItemEditor, GuiPreferences,
|
GuiAbout, GuiDocMerge, GuiDocSplit, GuiItemEditor, GuiPreferences,
|
||||||
GuiProjectLoad, GuiProjectSettings, GuiUpdates, GuiWordList
|
GuiProjectDetails, GuiProjectLoad, GuiProjectSettings, GuiUpdates,
|
||||||
|
GuiWordList
|
||||||
)
|
)
|
||||||
from novelwriter.tools import GuiBuildNovel, GuiProjectWizard, GuiWritingStats
|
from novelwriter.tools import GuiBuildNovel, GuiProjectWizard, GuiWritingStats
|
||||||
from novelwriter.core import NWProject, NWIndex
|
from novelwriter.core import NWProject, NWIndex
|
||||||
@@ -1017,6 +1018,7 @@ class GuiMain(QMainWindow):
|
|||||||
dlgDetails.setModal(False)
|
dlgDetails.setModal(False)
|
||||||
dlgDetails.show()
|
dlgDetails.show()
|
||||||
dlgDetails.raise_()
|
dlgDetails.raise_()
|
||||||
|
dlgDetails.updateValues()
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ from tools import getGuiItem
|
|||||||
|
|
||||||
from PyQt5.QtWidgets import QAction, QMessageBox
|
from PyQt5.QtWidgets import QAction, QMessageBox
|
||||||
|
|
||||||
from novelwriter.gui import GuiProjectDetails
|
from novelwriter.dialogs import GuiProjectDetails
|
||||||
|
|
||||||
keyDelay = 2
|
keyDelay = 2
|
||||||
typeDelay = 1
|
typeDelay = 1
|
||||||
@@ -33,7 +33,7 @@ stepDelay = 20
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testGuiProjDetails_Dialog(qtbot, monkeypatch, nwGUI, nwLipsum):
|
def testDlgProjDetails_Dialog(qtbot, monkeypatch, nwGUI, nwLipsum):
|
||||||
"""Test the project details dialog.
|
"""Test the project details dialog.
|
||||||
"""
|
"""
|
||||||
# Block message box
|
# Block message box
|
||||||
@@ -111,4 +111,4 @@ def testGuiProjDetails_Dialog(qtbot, monkeypatch, nwGUI, nwLipsum):
|
|||||||
projDet._doClose()
|
projDet._doClose()
|
||||||
nwGUI.closeMain()
|
nwGUI.closeMain()
|
||||||
|
|
||||||
# END Test testGuiProjDetails_Dialog
|
# END Test testDlgProjDetails_Dialog
|
||||||
Reference in New Issue
Block a user