Compare commits

..

3 Commits

2 changed files with 46 additions and 4 deletions
+19
View File
@@ -12,6 +12,7 @@ from PySide6.QtWidgets import (
QHBoxLayout, QHBoxLayout,
QSpinBox, QSpinBox,
QCheckBox, QCheckBox,
QFileDialog,
) )
import platform import platform
@@ -114,6 +115,15 @@ def settings_dialog(self):
download_path.setText(state.download_path) download_path.setText(state.download_path)
dialog.layout().addWidget(download_path_container) dialog.layout().addWidget(download_path_container)
def browse_download_path():
dir_path = QFileDialog.getExistingDirectory(dialog, "Select Download Directory", state.download_path)
if dir_path:
download_path.setText(dir_path)
browse_button = QPushButton("📁")
download_path_layout.addWidget(browse_button)
browse_button.clicked.connect(browse_download_path)
################## ##################
# SPEED LIMITING # # SPEED LIMITING #
################## ##################
@@ -147,6 +157,15 @@ def settings_dialog(self):
image_path.setText(state.image_path) image_path.setText(state.image_path)
dialog.layout().addWidget(image_path_container) dialog.layout().addWidget(image_path_container)
def browse_image_path():
file_path = QFileDialog.getOpenFileName(dialog, "Select Image File", state.image_path, "Image Files (*.png *.jpg)")[0]
if file_path:
image_path.setText(file_path)
browse_button = QPushButton("📁")
image_path_layout.addWidget(browse_button)
browse_button.clicked.connect(browse_image_path)
############### ###############
# SAVE/CANCEL # # SAVE/CANCEL #
############### ###############
+24 -1
View File
@@ -223,6 +223,23 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
def toggle_pause_resume(self, row): def toggle_pause_resume(self, row):
download = state.downloads[row] download = state.downloads[row]
if download.progress == 100:
if state.download_path is not None and os.path.exists(state.download_path):
if platform.system() == "Windows":
os.startfile(os.path.normpath(state.download_path))
elif platform.system() == "Linux":
subprocess.Popen(["xdg-open", state.download_path])
elif platform.system() == "Darwin":
subprocess.Popen(["open", state.download_path])
else:
if platform.system() == "Windows":
os.startfile(os.path.normpath(os.getcwd()))
elif platform.system() == "Linux":
subprocess.Popen(["xdg-open", os.getcwd()])
elif platform.system() == "Darwin":
subprocess.Popen(["open", os.getcwd()])
return
if download.is_paused: if download.is_paused:
download.resume() download.resume()
consoleLog(f"Resumed download: {download.name}", True) consoleLog(f"Resumed download: {download.name}", True)
@@ -230,7 +247,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
download.pause() download.pause()
consoleLog(f"Paused download: {download.name}", True) consoleLog(f"Paused download: {download.name}", True)
idx = self.index(row, 0) idx = self.index(row, 0)
self.dataChanged.emit(idx, idx, [Qt.DisplayRole, Qt.UserRole]) self.dataChanged.emit(idx, idx, [Qt.ItemDataRole.DisplayRole, Qt.ItemDataRole.UserRole])
class PauseResumeDelegate(QStyledItemDelegate): class PauseResumeDelegate(QStyledItemDelegate):
clicked = Signal(int) clicked = Signal(int)
@@ -241,10 +258,16 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
return return
paused = index.data(Qt.UserRole) paused = index.data(Qt.UserRole)
download = state.downloads[index.row()]
button = QStyleOptionButton() button = QStyleOptionButton()
button.rect = option.rect button.rect = option.rect
if download.progress == 100:
button.text = "📁"
else:
button.text = "▶︎" if paused else "⏸︎" button.text = "▶︎" if paused else "⏸︎"
button.state = QStyle.State_Enabled button.state = QStyle.State_Enabled
QApplication.style().drawControl( QApplication.style().drawControl(