Moved the code for browsing for projects to the open projects dialog
This commit is contained in:
+13
-22
@@ -264,8 +264,6 @@ class GuiMain(QMainWindow):
|
||||
if dlgProj.result() == QDialog.Accepted:
|
||||
if dlgProj.openState == GuiProjectLoad.OPEN_STATE:
|
||||
self.openProject(dlgProj.openPath)
|
||||
elif dlgProj.openState == GuiProjectLoad.BROWSE_STATE:
|
||||
self.openProject(dlgProj.openPath)
|
||||
elif dlgProj.openState == GuiProjectLoad.NEW_STATE:
|
||||
self.newProject()
|
||||
|
||||
@@ -354,13 +352,11 @@ class GuiMain(QMainWindow):
|
||||
|
||||
return saveOK
|
||||
|
||||
def openProject(self, projFile=None):
|
||||
def openProject(self, projFile):
|
||||
"""Open a project. The parameter projFile is passed from the
|
||||
open recent projects menu, so it can be set. If not, we pop the
|
||||
dialog.
|
||||
open recent projects menu, and must be set to be forwarded to
|
||||
the project class. Otherwise, we just return.
|
||||
"""
|
||||
if projFile is None:
|
||||
projFile = self.openProjectDialog()
|
||||
if projFile is None:
|
||||
return False
|
||||
|
||||
@@ -484,6 +480,8 @@ class GuiMain(QMainWindow):
|
||||
return True
|
||||
|
||||
def saveDocument(self):
|
||||
"""Save the current documents.
|
||||
"""
|
||||
if self.hasProject:
|
||||
self.docEditor.saveText()
|
||||
return True
|
||||
@@ -491,7 +489,6 @@ class GuiMain(QMainWindow):
|
||||
def viewDocument(self, tHandle=None):
|
||||
"""Load a document for viewing in the view panel.
|
||||
"""
|
||||
|
||||
if tHandle is None:
|
||||
tHandle = self.treeView.getSelectedHandle()
|
||||
if tHandle is None:
|
||||
@@ -521,7 +518,6 @@ class GuiMain(QMainWindow):
|
||||
"""Import the text contained in an out-of-project text file, and
|
||||
insert the text into the currently open document.
|
||||
"""
|
||||
|
||||
lastPath = self.mainConf.lastPath
|
||||
|
||||
extFilter = [
|
||||
@@ -610,6 +606,8 @@ class GuiMain(QMainWindow):
|
||||
##
|
||||
|
||||
def openSelectedItem(self):
|
||||
"""Open the selected documents.
|
||||
"""
|
||||
tHandle = self.treeView.getSelectedHandle()
|
||||
if tHandle is None:
|
||||
logger.warning("No item selected")
|
||||
@@ -626,6 +624,8 @@ class GuiMain(QMainWindow):
|
||||
return True
|
||||
|
||||
def editItem(self):
|
||||
"""Open the edit item dialog.
|
||||
"""
|
||||
tHandle = self.treeView.getSelectedHandle()
|
||||
if tHandle is None:
|
||||
logger.warning("No item selected")
|
||||
@@ -654,7 +654,6 @@ class GuiMain(QMainWindow):
|
||||
def rebuildIndex(self):
|
||||
"""Rebuild the entire index.
|
||||
"""
|
||||
|
||||
if not self.hasProject:
|
||||
return False
|
||||
|
||||
@@ -708,19 +707,9 @@ class GuiMain(QMainWindow):
|
||||
# Main Dialogs
|
||||
##
|
||||
|
||||
def openProjectDialog(self):
|
||||
dlgOpt = QFileDialog.Options()
|
||||
dlgOpt |= QFileDialog.DontUseNativeDialog
|
||||
projFile, _ = QFileDialog.getOpenFileName(
|
||||
self, "Open novelWriter Project", "",
|
||||
"novelWriter Project File (%s);;All Files (*)" % nwFiles.PROJ_FILE,
|
||||
options=dlgOpt
|
||||
)
|
||||
if projFile:
|
||||
return projFile
|
||||
return None
|
||||
|
||||
def saveProjectDialog(self):
|
||||
"""Select where to save project.
|
||||
"""
|
||||
dlgOpt = QFileDialog.Options()
|
||||
dlgOpt |= QFileDialog.ShowDirsOnly
|
||||
dlgOpt |= QFileDialog.DontUseNativeDialog
|
||||
@@ -732,6 +721,8 @@ class GuiMain(QMainWindow):
|
||||
return None
|
||||
|
||||
def newProjectDialog(self):
|
||||
"""Select where to save new project.
|
||||
"""
|
||||
dlgOpt = QFileDialog.Options()
|
||||
dlgOpt |= QFileDialog.ShowDirsOnly
|
||||
dlgOpt |= QFileDialog.DontUseNativeDialog
|
||||
|
||||
Reference in New Issue
Block a user