Added recent project menu option
This commit is contained in:
@@ -33,6 +33,8 @@ class GuiProjectEditor(QDialog):
|
|||||||
self.outerBox = QHBoxLayout()
|
self.outerBox = QHBoxLayout()
|
||||||
self.innerBox = QVBoxLayout()
|
self.innerBox = QVBoxLayout()
|
||||||
|
|
||||||
|
self.setWindowTitle("Project Settings")
|
||||||
|
|
||||||
self.gradPath = path.abspath(path.join(self.mainConf.appPath,"graphics","block.svg"))
|
self.gradPath = path.abspath(path.join(self.mainConf.appPath,"graphics","block.svg"))
|
||||||
self.svgGradient = QSvgWidget(self.gradPath)
|
self.svgGradient = QSvgWidget(self.gradPath)
|
||||||
self.svgGradient.setFixedWidth(80)
|
self.svgGradient.setFixedWidth(80)
|
||||||
|
|||||||
+24
-20
@@ -35,7 +35,7 @@ class GuiMain(QMainWindow):
|
|||||||
self.theProject = NWProject()
|
self.theProject = NWProject()
|
||||||
|
|
||||||
self.resize(1100,650)
|
self.resize(1100,650)
|
||||||
self.setTitle()
|
self._setWindowTitle()
|
||||||
self.setWindowIcon(QIcon(path.join(self.mainConf.appPath,"..","novelWriter.svg")))
|
self.setWindowIcon(QIcon(path.join(self.mainConf.appPath,"..","novelWriter.svg")))
|
||||||
|
|
||||||
self.docEditor = GuiDocEditor()
|
self.docEditor = GuiDocEditor()
|
||||||
@@ -70,26 +70,13 @@ class GuiMain(QMainWindow):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
#
|
|
||||||
# Set and Get Methods
|
|
||||||
#
|
|
||||||
|
|
||||||
def setTitle(self, projName=None):
|
|
||||||
winTitle = "%s [%s]" % (nw.__package__, nw.__version__)
|
|
||||||
if projName is not None:
|
|
||||||
winTitle += " - %s" % projName
|
|
||||||
self.setWindowTitle(winTitle)
|
|
||||||
return True
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Project Actions
|
# Project Actions
|
||||||
#
|
#
|
||||||
|
|
||||||
def newProject(self):
|
def newProject(self):
|
||||||
|
|
||||||
logger.info("Creating new project")
|
logger.info("Creating new project")
|
||||||
self.docTabs.createTab(tabType=nw.DOCTYPE_PROJECT)
|
self.docTabs.createTab(tabType=nw.DOCTYPE_PROJECT)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def openProject(self):
|
def openProject(self):
|
||||||
@@ -99,6 +86,7 @@ class GuiMain(QMainWindow):
|
|||||||
self,"Open novelWriter Project","","novelWriter Project File (nwProject.nwx);;All Files (*)", options=dlgOpt)
|
self,"Open novelWriter Project","","novelWriter Project File (nwProject.nwx);;All Files (*)", options=dlgOpt)
|
||||||
if projPath:
|
if projPath:
|
||||||
self.theProject.openProject(projPath)
|
self.theProject.openProject(projPath)
|
||||||
|
self._setWindowTitle(self.theProject.projName)
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
@@ -121,14 +109,18 @@ class GuiMain(QMainWindow):
|
|||||||
dlgProj.exec_()
|
dlgProj.exec_()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def openRecentProject(self, recentItem):
|
||||||
|
logger.vverbose("User requested opening recent project #%d" % recentItem)
|
||||||
|
self.theProject.openProject(self.mainConf.recentList[recentItem])
|
||||||
|
self._setWindowTitle(self.theProject.projName)
|
||||||
|
return True
|
||||||
|
|
||||||
#
|
#
|
||||||
# Document Actions
|
# Document Actions
|
||||||
#
|
#
|
||||||
|
|
||||||
def saveDocument(self):
|
def saveDocument(self):
|
||||||
|
|
||||||
self.docEditor.getText()
|
self.docEditor.getText()
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -136,7 +128,7 @@ class GuiMain(QMainWindow):
|
|||||||
#
|
#
|
||||||
|
|
||||||
def _buildMenu(self):
|
def _buildMenu(self):
|
||||||
menuBar = self.menuBar()
|
menuBar = self.menuBar()
|
||||||
|
|
||||||
# File
|
# File
|
||||||
fileMenu = menuBar.addMenu("&File")
|
fileMenu = menuBar.addMenu("&File")
|
||||||
@@ -160,9 +152,14 @@ class GuiMain(QMainWindow):
|
|||||||
fileMenu.addAction(menuSaveProject)
|
fileMenu.addAction(menuSaveProject)
|
||||||
|
|
||||||
# File > Recent Project
|
# File > Recent Project
|
||||||
menuRecentProject = QAction(QIcon.fromTheme("document-open-recent"), "Open Recent Project", menuBar)
|
recentMenu = fileMenu.addMenu(QIcon.fromTheme("document-open-recent"),"Recent Projects")
|
||||||
menuRecentProject.setStatusTip("Open Recent Project")
|
itemCount = 0
|
||||||
fileMenu.addAction(menuRecentProject)
|
for recentProject in self.mainConf.recentList:
|
||||||
|
if recentProject == "": continue
|
||||||
|
menuRecentProject = QAction(QIcon.fromTheme("folder-open"), "%d: %s" % (itemCount,recentProject), fileMenu)
|
||||||
|
menuRecentProject.triggered.connect(self.openRecentProject, itemCount)
|
||||||
|
recentMenu.addAction(menuRecentProject)
|
||||||
|
itemCount += 1
|
||||||
|
|
||||||
# ---------------------
|
# ---------------------
|
||||||
fileMenu.addSeparator()
|
fileMenu.addSeparator()
|
||||||
@@ -240,6 +237,13 @@ class GuiMain(QMainWindow):
|
|||||||
self.mainConf.saveConfig()
|
self.mainConf.saveConfig()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def _setWindowTitle(self, projName=None):
|
||||||
|
winTitle = "%s [%s]" % (nw.__package__, nw.__version__)
|
||||||
|
if projName is not None:
|
||||||
|
winTitle += " - %s" % projName
|
||||||
|
self.setWindowTitle(winTitle)
|
||||||
|
return True
|
||||||
|
|
||||||
#
|
#
|
||||||
# Menu Action
|
# Menu Action
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -42,8 +42,10 @@ class NWProject():
|
|||||||
def openProject(self, fileName):
|
def openProject(self, fileName):
|
||||||
|
|
||||||
if not path.isfile(fileName):
|
if not path.isfile(fileName):
|
||||||
logger.error("File not found: %s" % fileName)
|
fileName = path.join(fileName, "nwProject.nwx")
|
||||||
return False
|
if not path.isfile(fileName):
|
||||||
|
logger.error("File not found: %s" % fileName)
|
||||||
|
return False
|
||||||
|
|
||||||
self.projPath = path.dirname(fileName)
|
self.projPath = path.dirname(fileName)
|
||||||
|
|
||||||
@@ -66,7 +68,10 @@ class NWProject():
|
|||||||
logger.debug("Found book data")
|
logger.debug("Found book data")
|
||||||
for xItem in xChild:
|
for xItem in xChild:
|
||||||
if xItem.text is None: continue
|
if xItem.text is None: continue
|
||||||
if xItem.tag == "title":
|
if xItem.tag == "name":
|
||||||
|
logger.verbose("Working Title: '%s'" % xItem.text)
|
||||||
|
self.projName = xItem.text
|
||||||
|
elif xItem.tag == "title":
|
||||||
logger.verbose("Title is '%s'" % xItem.text)
|
logger.verbose("Title is '%s'" % xItem.text)
|
||||||
self.bookTitle = xItem.text
|
self.bookTitle = xItem.text
|
||||||
elif xItem.tag == "author":
|
elif xItem.tag == "author":
|
||||||
|
|||||||
@@ -4,6 +4,6 @@
|
|||||||
<name>Sample Project</name>
|
<name>Sample Project</name>
|
||||||
<title>Sample Project</title>
|
<title>Sample Project</title>
|
||||||
<author>Jane Smith</author>
|
<author>Jane Smith</author>
|
||||||
<author>Jane Doh</author>
|
<author>Jay Doh</author>
|
||||||
</project>
|
</project>
|
||||||
</novelWriterXML>
|
</novelWriterXML>
|
||||||
|
|||||||
Reference in New Issue
Block a user