Settings: add Storage section showing state dir, DB, cover cache, and user data paths
This commit is contained in:
+39
@@ -1280,6 +1280,22 @@ class SettingsPage(QWidget):
|
|||||||
form.addRow(self.clear_covers_btn)
|
form.addRow(self.clear_covers_btn)
|
||||||
col.addWidget(box)
|
col.addWidget(box)
|
||||||
|
|
||||||
|
# -- Storage ---------------------------------------------------------- #
|
||||||
|
box, form = self._group("Storage")
|
||||||
|
self._path_row(form, "State directory", str(config.STATE_DIR))
|
||||||
|
self._path_row(form, "Library database", str(config.DB_PATH))
|
||||||
|
self._path_row(form, "Cover cache", str(config.COVERS_DIR))
|
||||||
|
self._path_row(form, "User data (credentials, NPS cache…)", str(config.USER_DATA_DIR))
|
||||||
|
note = QLabel(
|
||||||
|
"Your library, covers, and credentials live here — outside the app "
|
||||||
|
"bundle, so they survive upgrades. On Linux this is the "
|
||||||
|
"~/.local/state/psp-preserve folder."
|
||||||
|
)
|
||||||
|
note.setWordWrap(True)
|
||||||
|
note.setStyleSheet("color: #9a9ba5;")
|
||||||
|
form.addRow(note)
|
||||||
|
col.addWidget(box)
|
||||||
|
|
||||||
col.addStretch(1)
|
col.addStretch(1)
|
||||||
|
|
||||||
def _group(self, title):
|
def _group(self, title):
|
||||||
@@ -1342,6 +1358,29 @@ class SettingsPage(QWidget):
|
|||||||
form.addRow(label, edit)
|
form.addRow(label, edit)
|
||||||
return edit
|
return edit
|
||||||
|
|
||||||
|
def _path_row(self, form, label, path):
|
||||||
|
edit = QLineEdit(path)
|
||||||
|
edit.setReadOnly(True)
|
||||||
|
open_btn = QPushButton("Open")
|
||||||
|
open_btn.clicked.connect(lambda _=False, p=Path(path): self._open_path(p))
|
||||||
|
row = QWidget()
|
||||||
|
h = QHBoxLayout(row)
|
||||||
|
h.setContentsMargins(0, 0, 0, 0)
|
||||||
|
h.addWidget(edit, 1)
|
||||||
|
h.addWidget(open_btn)
|
||||||
|
form.addRow(label, row)
|
||||||
|
return edit
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _open_path(path):
|
||||||
|
path = Path(path)
|
||||||
|
target = path if path.is_dir() else path.parent
|
||||||
|
if target.is_dir():
|
||||||
|
QDesktopServices.openUrl(QUrl.fromLocalFile(str(target)))
|
||||||
|
else:
|
||||||
|
QMessageBox.information(None, "Not found",
|
||||||
|
f"Folder not created yet:\n{target}\n\nIt is created on first use.")
|
||||||
|
|
||||||
def games_dir(self):
|
def games_dir(self):
|
||||||
return self.games_edit.text().strip()
|
return self.games_edit.text().strip()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user