Skip to content

Commit

Permalink
Cleaned up progressbar
Browse files Browse the repository at this point in the history
  • Loading branch information
dougollerenshaw committed Oct 8, 2024
1 parent 006a7e0 commit 4afb42b
Showing 1 changed file with 8 additions and 34 deletions.
42 changes: 8 additions & 34 deletions codeaide/ui/chat_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
QTimer,
QThread,
pyqtSignal,
QPropertyAnimation,
QEasingCurve,
)
from PyQt5.QtGui import QColor
from PyQt5.QtWidgets import (
Expand All @@ -19,8 +17,7 @@
QWidget,
QComboBox,
QLabel,
QProgressBar,
QDialog,
QProgressDialog,
)
from codeaide.ui.code_popup import CodePopup
from codeaide.ui.example_selection_dialog import show_example_dialog
Expand Down Expand Up @@ -123,35 +120,6 @@ def run(self):
self.finished.emit(transcribed_text)


class AnimatedProgressDialog(QDialog):
def __init__(self, parent=None):
super().__init__(parent)
self.setWindowTitle("Transcribing Audio")
self.setFixedSize(300, 100)
layout = QVBoxLayout(self)

self.label = QLabel("Transcribing audio...")
layout.addWidget(self.label)

self.progress_bar = QProgressBar(self)
self.progress_bar.setRange(0, 100)
self.progress_bar.setValue(0)
layout.addWidget(self.progress_bar)

self.animation = QPropertyAnimation(self.progress_bar, b"value")
self.animation.setDuration(1000) # 1 second for a full cycle
self.animation.setStartValue(0)
self.animation.setEndValue(100)
self.animation.setEasingCurve(QEasingCurve.Linear)
self.animation.finished.connect(self.restart_animation)

self.animation.start()

def restart_animation(self):
self.progress_bar.setValue(0)
self.animation.start()


class ChatWindow(QMainWindow):
def __init__(self, chat_handler):
super().__init__()
Expand Down Expand Up @@ -666,8 +634,14 @@ def on_recording_finished(self, filename, recording_duration):
)

def transcribe_audio(self, filename):
progress_dialog = AnimatedProgressDialog(self)
progress_dialog = QProgressDialog("Transcribing audio...", None, 0, 0, self)
progress_dialog.setWindowTitle("Please Wait")
progress_dialog.setWindowModality(Qt.WindowModal)
progress_dialog.setAutoClose(True)
progress_dialog.setAutoReset(True)
progress_dialog.setMinimumDuration(0)
progress_dialog.setValue(0)
progress_dialog.setMaximum(0) # This makes it an indeterminate progress dialog
progress_dialog.show()

self.transcription_thread = TranscriptionThread(self.whisper_model, filename)
Expand Down

0 comments on commit 4afb42b

Please sign in to comment.