|
107 | 107 |
|
108 | 108 | logging.basicConfig(format="%(message)s", level=logging.INFO) |
109 | 109 |
|
110 | | -# Keep settings in ini format in the current working directory. |
111 | | -QSettings.setPath(QSettings.IniFormat, QSettings.UserScope, os.getcwd()) |
112 | | - |
113 | 110 |
|
114 | 111 | class NavigationState: |
115 | 112 | """Represents a state of the Library grid view.""" |
@@ -189,7 +186,42 @@ def __init__(self, core, args): |
189 | 186 |
|
190 | 187 | self.SIGTERM.connect(self.handleSIGTERM) |
191 | 188 |
|
192 | | - self.settings = QSettings(QSettings.IniFormat, QSettings.UserScope, "TagStudio") |
| 189 | + if self.args.config_file: |
| 190 | + path = Path(self.args.config_file) |
| 191 | + if path.is_dir(): |
| 192 | + path = path / "TagStudio.ini" |
| 193 | + self.settings = QSettings(str(path), QSettings.IniFormat) |
| 194 | + logging.info( |
| 195 | + f"[QT DRIVER] Directory provided defaulting to TagStudio.ini in directory, using {self.settings.fileName()}" |
| 196 | + ) |
| 197 | + elif path.is_file(): |
| 198 | + self.settings = QSettings(str(path), QSettings.IniFormat) |
| 199 | + logging.info( |
| 200 | + f"[QT DRIVER] Config File exists, using {self.settings.fileName()}" |
| 201 | + ) |
| 202 | + else: |
| 203 | + if path.suffix == ".ini" and path.parent.is_dir(): |
| 204 | + self.settings = QSettings(str(path), QSettings.IniFormat) |
| 205 | + logging.info( |
| 206 | + f"[QT DRIVER] Config File does not exist, valid path specified using {self.settings.fileName()}" |
| 207 | + ) |
| 208 | + else: |
| 209 | + self.settings = QSettings( |
| 210 | + QSettings.IniFormat, |
| 211 | + QSettings.UserScope, |
| 212 | + "TagStudio", |
| 213 | + "TagStudio", |
| 214 | + ) |
| 215 | + logging.warning( |
| 216 | + f"[QT DRIVER] Config File does not exist, defaulting to {self.settings.fileName()}" |
| 217 | + ) |
| 218 | + else: |
| 219 | + self.settings = QSettings( |
| 220 | + QSettings.IniFormat, QSettings.UserScope, "TagStudio", "TagStudio" |
| 221 | + ) |
| 222 | + logging.info( |
| 223 | + f"[QT DRIVER] Config File not specified, defaulting to {self.settings.fileName()}" |
| 224 | + ) |
193 | 225 |
|
194 | 226 | max_threads = os.cpu_count() |
195 | 227 | for i in range(max_threads): |
|
0 commit comments