From 2cc12490d8c8ce9cdcb893b3f532eb1cb755c5ed Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 4 Oct 2020 16:38:53 +0200 Subject: [PATCH] Block cluttering of the user's home folder --- nw/config.py | 6 ++---- nw/core/project.py | 4 ++++ nw/gui/writingstats.py | 9 +++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/nw/config.py b/nw/config.py index c5512783..5f4a1300 100644 --- a/nw/config.py +++ b/nw/config.py @@ -68,7 +68,6 @@ class Config: self.confPath = None # Folder where the config is saved self.confFile = None # The config file name self.dataPath = None # Folder where app data is stored - self.homePath = None # The user's home folder self.lastPath = None # The last user-selected folder (browse dialogs) self.appPath = None # The full path to the novelwriter package folder self.appRoot = None # The full path to the novelwriter root folder @@ -257,8 +256,7 @@ class Config: logger.verbose("Data path: %s" % self.dataPath) self.confFile = self.appHandle+".conf" - self.homePath = os.path.expanduser("~") - self.lastPath = self.homePath + self.lastPath = os.path.expanduser("~") self.appPath = getattr(sys, "_MEIPASS", os.path.abspath(os.path.dirname(__file__))) self.appRoot = os.path.join(self.appPath, os.path.pardir) self.assetPath = os.path.join(self.appPath, "assets") @@ -268,7 +266,7 @@ class Config: self.appIcon = os.path.join(self.iconPath, "novelwriter.svg") logger.verbose("App path: %s" % self.appPath) - logger.verbose("Home path: %s" % self.homePath) + logger.verbose("Last path: %s" % self.lastPath) # If config folder does not exist, make it. # This assumes that the os config folder itself exists. diff --git a/nw/core/project.py b/nw/core/project.py index 953d7879..46e37202 100644 --- a/nw/core/project.py +++ b/nw/core/project.py @@ -757,6 +757,10 @@ class NWProject(): if self.projPath is None or self.projPath == "": return False + if self.projPath == os.path.expanduser("~"): + # Don't make a mess in the user's home folder + return False + self.projMeta = os.path.join(self.projPath, "meta") self.projCache = os.path.join(self.projPath, "cache") self.projContent = os.path.join(self.projPath, "content") diff --git a/nw/gui/writingstats.py b/nw/gui/writingstats.py index d45b3726..165e7fd9 100644 --- a/nw/gui/writingstats.py +++ b/nw/gui/writingstats.py @@ -320,11 +320,12 @@ class GuiWritingStats(QDialog): # Generate the file name if fileExt: - fileName = "sessionStats.%s" % fileExt - saveDir = self.mainConf.lastPath - savePath = os.path.join(saveDir, fileName) + saveDir = self.mainConf.lastPath if not os.path.isdir(saveDir): - saveDir = self.mainConf.homePath + saveDir = os.path.expanduser("~") + + fileName = "sessionStats.%s" % fileExt + savePath = os.path.join(saveDir, fileName) dlgOpt = QFileDialog.Options() dlgOpt |= QFileDialog.DontUseNativeDialog