Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drag and drop to import file #398

Merged
merged 1 commit into from
Apr 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions buzz/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,8 @@ def __init__(self, tasks_cache=TasksCache()):
self.setWindowIcon(QIcon(BUZZ_ICON_PATH))
self.setMinimumSize(450, 400)

self.setAcceptDrops(True)

self.tasks_cache = tasks_cache

self.tasks = {}
Expand Down Expand Up @@ -979,6 +981,17 @@ def __init__(self, tasks_cache=TasksCache()):

self.load_tasks_from_cache()

def dragEnterEvent(self, event):
# Accept file drag events
if event.mimeData().hasUrls():
event.accept()
else:
event.ignore()

def dropEvent(self, event):
file_paths = [url.toLocalFile() for url in event.mimeData().urls()]
self.open_file_transcriber_widget(file_paths=file_paths)

def on_file_transcriber_triggered(self, options: Tuple[TranscriptionOptions, FileTranscriptionOptions, str]):
transcription_options, file_transcription_options, model_path = options
for file_path in file_transcription_options.file_paths:
Expand Down Expand Up @@ -1028,6 +1041,9 @@ def on_new_transcription_action_triggered(self):
if len(file_paths) == 0:
return

self.open_file_transcriber_widget(file_paths)

def open_file_transcriber_widget(self, file_paths: List[str]):
file_transcriber_window = FileTranscriberWidget(
file_paths, self.openai_access_token, self, flags=Qt.WindowType.Window)
file_transcriber_window.triggered.connect(
Expand Down