Change lastPath to a Path object

This commit is contained in:
Veronica Berglyd Olsen
2022-11-09 18:21:40 +01:00
parent 9d3291aba6
commit 47b57172eb
13 changed files with 45 additions and 71 deletions
+2 -7
View File
@@ -23,7 +23,6 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import os
import json
import logging
import novelwriter
@@ -891,13 +890,9 @@ class GuiBuildNovel(QDialog):
cleanName = makeFileNameSafe(self.theProject.data.name)
fileName = "%s.%s" % (cleanName, fileExt)
saveDir = self.mainConf.lastPath
if not os.path.isdir(saveDir):
saveDir = os.path.expanduser("~")
savePath = os.path.join(saveDir, fileName)
savePath = self.mainConf.getLastPath() / fileName
savePath, _ = QFileDialog.getSaveFileName(
self, self.tr("Save Document As"), savePath
self, self.tr("Save Document As"), str(savePath)
)
if not savePath:
return False
+2 -5
View File
@@ -236,12 +236,9 @@ class ProjWizardFolderPage(QWizardPage):
def _doBrowse(self):
"""Select a project folder.
"""
lastPath = self.mainConf.lastPath
if not os.path.isdir(lastPath):
lastPath = ""
lastPath = self.mainConf.getLastPath()
projDir = QFileDialog.getExistingDirectory(
self, self.tr("Select Project Folder"), lastPath, options=QFileDialog.ShowDirsOnly
self, self.tr("Select Project Folder"), str(lastPath), options=QFileDialog.ShowDirsOnly
)
if projDir:
projName = self.field("projName")
+2 -9
View File
@@ -23,7 +23,6 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import os
import json
import logging
import novelwriter
@@ -363,15 +362,9 @@ class GuiWritingStats(QDialog):
return False
# Generate the file name
saveDir = self.mainConf.lastPath
if not os.path.isdir(saveDir):
saveDir = os.path.expanduser("~")
fileName = "sessionStats.%s" % fileExt
savePath = os.path.join(saveDir, fileName)
savePath = self.mainConf.getLastPath() / f"sessionStats.{fileExt}"
savePath, _ = QFileDialog.getSaveFileName(
self, self.tr("Save Data As"), savePath, "%s (*.%s)" % (textFmt, fileExt)
self, self.tr("Save Data As"), str(savePath), "%s (*.%s)" % (textFmt, fileExt)
)
if not savePath:
return False