24
24
QProgressDialog , QPushButton , QVBoxLayout , QHBoxLayout , QMenu ,
25
25
QWidget , QGroupBox , QToolBar , QTableWidget , QMenuBar , QFormLayout , QTableWidgetItem ,
26
26
QHeaderView , QAbstractItemView , QListWidget , QListWidgetItem , QToolButton , QSizePolicy )
27
- from requests import get
28
27
from whisper import tokenizer
29
28
30
29
from buzz .cache import TasksCache
@@ -615,7 +614,8 @@ def on_transcriber_finished(self):
615
614
def on_transcriber_error (self , error : str ):
616
615
self .reset_record_button ()
617
616
self .set_recording_status_stopped ()
618
- QMessageBox .critical (self , '' , f'An error occurred while starting a new recording: { error } . Please check your audio devices or check the application logs for more information.' )
617
+ QMessageBox .critical (self , '' ,
618
+ f'An error occurred while starting a new recording: { error } . Please check your audio devices or check the application logs for more information.' )
619
619
620
620
def on_cancel_model_progress_dialog (self ):
621
621
if self .model_loader is not None :
@@ -669,7 +669,8 @@ class AboutDialog(QDialog):
669
669
GITHUB_API_LATEST_RELEASE_URL = 'https://api.github.com/repos/chidiwilliams/buzz/releases/latest'
670
670
GITHUB_LATEST_RELEASE_URL = 'https://github.com/chidiwilliams/buzz/releases/latest'
671
671
672
- def __init__ (self , network_access_manager : Optional [QNetworkAccessManager ]= None , parent : Optional [QWidget ] = None ) -> None :
672
+ def __init__ (self , network_access_manager : Optional [QNetworkAccessManager ] = None ,
673
+ parent : Optional [QWidget ] = None ) -> None :
673
674
super ().__init__ (parent )
674
675
675
676
self .setFixedSize (200 , 250 )
@@ -862,7 +863,8 @@ def __init__(self, parent: Optional[QWidget]):
862
863
863
864
def load_icon (self , file_path : str ):
864
865
is_dark_theme = self .palette ().window ().color ().black () > 127
865
- return self .load_icon_with_color (file_path , self .ICON_DARK_THEME_BACKGROUND if is_dark_theme else self .ICON_LIGHT_THEME_BACKGROUND )
866
+ return self .load_icon_with_color (file_path ,
867
+ self .ICON_DARK_THEME_BACKGROUND if is_dark_theme else self .ICON_LIGHT_THEME_BACKGROUND )
866
868
867
869
@staticmethod
868
870
def load_icon_with_color (file_path : str , color : str ):
@@ -878,8 +880,8 @@ def on_record_action_triggered(self):
878
880
recording_transcriber_window = RecordingTranscriberWidget (self )
879
881
recording_transcriber_window .exec ()
880
882
881
- def set_open_transcript_action_disabled (self , disabled : bool ):
882
- self .open_transcript_action .setDisabled ( disabled )
883
+ def set_open_transcript_action_enabled (self , enabled : bool ):
884
+ self .open_transcript_action .setEnabled ( enabled )
883
885
884
886
def set_clear_history_action_enabled (self , enabled : bool ):
885
887
self .clear_history_action .setEnabled (enabled )
@@ -987,8 +989,16 @@ def on_open_transcript_action_triggered(self):
987
989
self .open_transcription_viewer (task_id )
988
990
989
991
def on_table_selection_changed (self ):
992
+ enable_open_transcript_action = self .should_enable_open_transcript_action ()
993
+ self .toolbar .set_open_transcript_action_enabled (enable_open_transcript_action )
994
+
995
+ def should_enable_open_transcript_action (self ):
990
996
selected_rows = self .table_widget .selectionModel ().selectedRows ()
991
- self .toolbar .set_open_transcript_action_disabled (len (selected_rows ) == 0 )
997
+ if len (selected_rows ) == 1 :
998
+ task_id = TranscriptionTasksTableWidget .find_task_id (selected_rows [0 ])
999
+ if self .tasks [task_id ].status == FileTranscriptionTask .Status .COMPLETED :
1000
+ return True
1001
+ return False
992
1002
993
1003
def on_table_double_clicked (self , index : QModelIndex ):
994
1004
task_id = TranscriptionTasksTableWidget .find_task_id (index )
@@ -1020,6 +1030,9 @@ def on_tasks_changed(self):
1020
1030
self .toolbar .set_clear_history_action_enabled (
1021
1031
any ([self .task_completed_or_errored (task ) for task in self .tasks .values ()]))
1022
1032
1033
+ enable_open_transcript_action = self .should_enable_open_transcript_action ()
1034
+ self .toolbar .set_open_transcript_action_enabled (enable_open_transcript_action )
1035
+
1023
1036
def closeEvent (self , event : QtGui .QCloseEvent ) -> None :
1024
1037
self .transcriber_worker .stop ()
1025
1038
self .transcriber_thread .quit ()
@@ -1040,7 +1053,8 @@ class HuggingFaceSearchLineEdit(LineEdit):
1040
1053
model_selected = pyqtSignal (str )
1041
1054
popup : QListWidget
1042
1055
1043
- def __init__ (self , network_access_manager : Optional [QNetworkAccessManager ] = None , parent : Optional [QWidget ] = None ):
1056
+ def __init__ (self , network_access_manager : Optional [QNetworkAccessManager ] = None ,
1057
+ parent : Optional [QWidget ] = None ):
1044
1058
super ().__init__ ('' , parent )
1045
1059
1046
1060
self .setMinimumWidth (150 )
0 commit comments