mirror of
https://github.com/TagStudioDev/TagStudio.git
synced 2026-01-30 06:40:50 +00:00
Revert QSettings location to IniFormat UserScope defaults
Adds `-c/--config-file <filename/dir>` argument to tag_studio.py
This commit is contained in:
@@ -107,9 +107,6 @@ INFO = f"[INFO]"
|
||||
|
||||
logging.basicConfig(format="%(message)s", level=logging.INFO)
|
||||
|
||||
# Keep settings in ini format in the current working directory.
|
||||
QSettings.setPath(QSettings.IniFormat, QSettings.UserScope, os.getcwd())
|
||||
|
||||
|
||||
class NavigationState:
|
||||
"""Represents a state of the Library grid view."""
|
||||
@@ -189,7 +186,42 @@ class QtDriver(QObject):
|
||||
|
||||
self.SIGTERM.connect(self.handleSIGTERM)
|
||||
|
||||
self.settings = QSettings(QSettings.IniFormat, QSettings.UserScope, "TagStudio")
|
||||
if self.args.config_file:
|
||||
path = Path(self.args.config_file)
|
||||
if path.is_dir():
|
||||
path = path / "TagStudio.ini"
|
||||
self.settings = QSettings(str(path), QSettings.IniFormat)
|
||||
logging.info(
|
||||
f"[QT DRIVER] Directory provided defaulting to TagStudio.ini in directory, using {self.settings.fileName()}"
|
||||
)
|
||||
elif path.is_file():
|
||||
self.settings = QSettings(str(path), QSettings.IniFormat)
|
||||
logging.info(
|
||||
f"[QT DRIVER] Config File exists, using {self.settings.fileName()}"
|
||||
)
|
||||
else:
|
||||
if path.suffix == ".ini" and path.parent.is_dir():
|
||||
self.settings = QSettings(str(path), QSettings.IniFormat)
|
||||
logging.info(
|
||||
f"[QT DRIVER] Config File does not exist, valid path specified using {self.settings.fileName()}"
|
||||
)
|
||||
else:
|
||||
self.settings = QSettings(
|
||||
QSettings.IniFormat,
|
||||
QSettings.UserScope,
|
||||
"TagStudio",
|
||||
"TagStudio",
|
||||
)
|
||||
logging.warning(
|
||||
f"[QT DRIVER] Config File does not exist, defaulting to {self.settings.fileName()}"
|
||||
)
|
||||
else:
|
||||
self.settings = QSettings(
|
||||
QSettings.IniFormat, QSettings.UserScope, "TagStudio", "TagStudio"
|
||||
)
|
||||
logging.info(
|
||||
f"[QT DRIVER] Config File not specified, defaulting to {self.settings.fileName()}"
|
||||
)
|
||||
|
||||
max_threads = os.cpu_count()
|
||||
for i in range(max_threads):
|
||||
|
||||
@@ -29,6 +29,13 @@ def main():
|
||||
type=str,
|
||||
help="Path to a TagStudio Library folder to open on start.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-c", "--config-file",
|
||||
dest="config_file",
|
||||
type=str,
|
||||
help="Path to a TagStudio.ini config file to use"
|
||||
)
|
||||
|
||||
# parser.add_argument('--browse', dest='browse', action='store_true',
|
||||
# help='Jumps to entry browsing on startup.')
|
||||
# parser.add_argument('--external_preview', dest='external_preview', action='store_true',
|
||||
|
||||
Reference in New Issue
Block a user