Added "Clear cache" button
This commit is contained in:
parent
5128b90e95
commit
8b8f2ed43b
1 changed files with 21 additions and 0 deletions
21
syng/gui.py
21
syng/gui.py
|
@ -607,6 +607,27 @@ class SyngGui(QMainWindow):
|
||||||
"You need to start the client before you can import a queue.",
|
"You need to start the client before you can import a queue.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def clear_cache(self) -> None:
|
||||||
|
"""
|
||||||
|
Clear the cache directory of the client.
|
||||||
|
"""
|
||||||
|
|
||||||
|
cache_dir = platformdirs.user_cache_dir("syng")
|
||||||
|
if os.path.exists(cache_dir):
|
||||||
|
answer = QMessageBox.question(
|
||||||
|
self,
|
||||||
|
"Clear Cache",
|
||||||
|
f"Are you sure you want to clear the cache directory at {cache_dir}?",
|
||||||
|
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
|
||||||
|
)
|
||||||
|
if answer == QMessageBox.StandardButton.Yes:
|
||||||
|
for root, dirs, files in os.walk(cache_dir, topdown=False):
|
||||||
|
for name in files:
|
||||||
|
os.remove(os.path.join(root, name))
|
||||||
|
for name in dirs:
|
||||||
|
os.rmdir(os.path.join(root, name))
|
||||||
|
QMessageBox.information(self, "Cache Cleared", "The cache has been cleared.")
|
||||||
|
|
||||||
def remove_room(self) -> None:
|
def remove_room(self) -> None:
|
||||||
if self.client is not None:
|
if self.client is not None:
|
||||||
answer = QMessageBox.question(
|
answer = QMessageBox.question(
|
||||||
|
|
Loading…
Add table
Reference in a new issue