Use platformdirs for finding the desktop path

This commit is contained in:
Deniz Şafak
2025-04-30 16:29:47 +03:00
parent 68dbdf123d
commit 04e16722e2
4 changed files with 7 additions and 3 deletions
+1
View File
@@ -1 +1,2 @@
- Added voice mixing functionality that enables combining multiple voices into a single "Mixed voice", as suggested by @PulsarFTW in #1. (Special thanks to @jborza for making this feature possible with his contributions in #5) - Added voice mixing functionality that enables combining multiple voices into a single "Mixed voice", as suggested by @PulsarFTW in #1. (Special thanks to @jborza for making this feature possible with his contributions in #5)
- Switched to platformdirs for determining the correct desktop path, instead of using old methods.
+2 -1
View File
@@ -4,6 +4,7 @@ import tempfile
import time import time
import chardet import chardet
import charset_normalizer import charset_normalizer
from platformdirs import user_desktop_dir
from PyQt5.QtCore import QThread, pyqtSignal, Qt from PyQt5.QtCore import QThread, pyqtSignal, Qt
from PyQt5.QtWidgets import QCheckBox, QVBoxLayout, QDialog, QLabel, QDialogButtonBox from PyQt5.QtWidgets import QCheckBox, QVBoxLayout, QDialog, QLabel, QDialogButtonBox
import soundfile as sf import soundfile as sf
@@ -280,7 +281,7 @@ class ConversionThread(QThread):
base_path = self.display_path if self.display_path else self.file_name base_path = self.display_path if self.display_path else self.file_name
base_name = os.path.splitext(os.path.basename(base_path))[0] base_name = os.path.splitext(os.path.basename(base_path))[0]
if self.save_option == "Save to Desktop": if self.save_option == "Save to Desktop":
parent_dir = os.path.join(os.path.expanduser("~"), "Desktop") parent_dir = user_desktop_dir()
elif self.save_option == "Save next to input file": elif self.save_option == "Save next to input file":
parent_dir = os.path.dirname(base_path) parent_dir = os.path.dirname(base_path)
else: else:
+2 -1
View File
@@ -72,6 +72,7 @@ from constants import (
) )
from threading import Thread from threading import Thread
from voice_formula_gui import VoiceFormulaDialog from voice_formula_gui import VoiceFormulaDialog
from platformdirs import user_desktop_dir
# Import ctypes for Windows-specific taskbar icon # Import ctypes for Windows-specific taskbar icon
if platform.system() == "Windows": if platform.system() == "Windows":
@@ -1628,7 +1629,7 @@ class abogen(QWidget):
try: try:
# where to put the .lnk # where to put the .lnk
desktop = os.path.join(os.environ.get("USERPROFILE", ""), "Desktop") desktop = user_desktop_dir()
shortcut_path = os.path.join(desktop, "abogen.lnk") shortcut_path = os.path.join(desktop, "abogen.lnk")
# target exe # target exe
+1
View File
@@ -18,6 +18,7 @@ dependencies = [
"ebooklib>=0.18", "ebooklib>=0.18",
"beautifulsoup4>=4.13.4", "beautifulsoup4>=4.13.4",
"PyMuPDF>=1.25.5", "PyMuPDF>=1.25.5",
"platformdirs>=4.3.7",
"soundfile>=0.13.1", "soundfile>=0.13.1",
"pygame>=2.6.1", "pygame>=2.6.1",
"charset_normalizer>=3.4.1", "charset_normalizer>=3.4.1",