Skip to content

Commit 8e11e28

Browse files
authored
Merge pull request #159 from Loran425/main
Change QSettings behavior to work with executables
2 parents 5d85417 + eba7c3e commit 8e11e28

2 files changed

Lines changed: 23 additions & 6 deletions

File tree

tagstudio/src/qt/ts_qt.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,6 @@
107107

108108
logging.basicConfig(format="%(message)s", level=logging.INFO)
109109

110-
# Keep settings in ini format in the current working directory.
111-
QSettings.setPath(QSettings.IniFormat, QSettings.UserScope, os.getcwd())
112-
113110

114111
class NavigationState:
115112
"""Represents a state of the Library grid view."""
@@ -189,9 +186,21 @@ def __init__(self, core, args):
189186

190187
self.SIGTERM.connect(self.handleSIGTERM)
191188

192-
self.settings = QSettings(
193-
QSettings.IniFormat, QSettings.UserScope, "tagstudio", "TagStudio"
194-
)
189+
if self.args.config_file:
190+
path = Path(self.args.config_file)
191+
if not path.exists():
192+
logging.warning(
193+
f"[QT DRIVER] Config File does not exist creating {str(path)}"
194+
)
195+
logging.info(f"[QT DRIVER] Using Config File {str(path)}")
196+
self.settings = QSettings(str(path), QSettings.IniFormat)
197+
else:
198+
self.settings = QSettings(
199+
QSettings.IniFormat, QSettings.UserScope, "TagStudio", "TagStudio"
200+
)
201+
logging.info(
202+
f"[QT DRIVER] Config File not specified, defaulting to {self.settings.fileName()}"
203+
)
195204

196205
max_threads = os.cpu_count()
197206
if args.ci:

tagstudio/tag_studio.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ def main():
2929
type=str,
3030
help="Path to a TagStudio Library folder to open on start.",
3131
)
32+
parser.add_argument(
33+
"-c",
34+
"--config-file",
35+
dest="config_file",
36+
type=str,
37+
help="Path to a TagStudio.ini config file to use",
38+
)
39+
3240
# parser.add_argument('--browse', dest='browse', action='store_true',
3341
# help='Jumps to entry browsing on startup.')
3442
# parser.add_argument('--external_preview', dest='external_preview', action='store_true',

0 commit comments

Comments
 (0)