Skip to content

Commit

Permalink
Add Refresh Button To Video Tab #41
Browse files Browse the repository at this point in the history
  • Loading branch information
yaser01 committed Jun 3, 2023
1 parent 3d635c3 commit ba72648
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion packages/Tabs/VideoTab/VideoSelection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from packages.Tabs.GlobalSetting import sort_names_like_windows, get_readable_filesize, get_files_names_absolute_list, \
get_file_name_absolute_path
from packages.Tabs.VideoTab.Widgets.LoadingVideosInfoDialog import LoadingVideosInfoDialog
from packages.Tabs.VideoTab.Widgets.RefreshFilesButton import RefreshFilesButton
from packages.Tabs.VideoTab.Widgets.VideoClearButton import VideoClearButton
from packages.Tabs.VideoTab.Widgets.VideoDefaultDurationFPSComboBox import VideoDefaultDurationFPSComboBox
from packages.Tabs.VideoTab.Widgets.VideoExtensionsCheckableComboBox import VideoExtensionsCheckableComboBox
Expand Down Expand Up @@ -58,6 +59,7 @@ def __init__(self):
self.video_extensions_comboBox = VideoExtensionsCheckableComboBox()
self.video_modify_old_tracks_button = ModifyOldTracksButton()
self.video_info_button = VideoInfoButton()
self.video_refresh_files_button = RefreshFilesButton()
self.table = VideoTable()
self.side_buttons_layout = QHBoxLayout()
self.main_layout = QGridLayout()
Expand Down Expand Up @@ -95,6 +97,8 @@ def update_folder_path(self, new_path: str):
self.video_source_lineEdit.set_text_safe_change(new_path)
self.update_files_lists(new_path)
self.show_files_list()
self.video_refresh_files_button.update_current_path(new_path=new_path)
self.video_refresh_files_button.setEnabled(True)
else:
if self.is_drag_and_drop:
self.video_source_lineEdit.set_text_safe_change(self.drag_and_dropped_text)
Expand All @@ -103,6 +107,7 @@ def update_files_lists(self, folder_path):
if folder_path == "" or folder_path.isspace():
self.folder_path = ""
if self.is_drag_and_drop:
self.disable_video_refresh_button_cause_drag_and_drop()
new_files_absolute_path_list = []
self.files_names_list = []
self.folders_paths = []
Expand Down Expand Up @@ -195,6 +200,10 @@ def update_files_lists(self, folder_path):
invalid_path_dialog = InvalidPathDialog()
invalid_path_dialog.execute()

def disable_video_refresh_button_cause_drag_and_drop(self):
self.video_refresh_files_button.setEnabled(False)
self.video_refresh_files_button.setToolTip("Disabled due to Drag/Drop mode")

def get_files_list(self, folder_path):
temp_files_names = sort_names_like_windows(names_list=os.listdir(folder_path))
temp_files_names_absolute = get_files_names_absolute_list(temp_files_names, folder_path)
Expand Down Expand Up @@ -245,6 +254,8 @@ def check_extension_changes(self, new_extensions):

def clear_files(self):
self.folder_path = ""
self.video_refresh_files_button.update_current_path(new_path="")
self.video_refresh_files_button.setEnabled(True)
self.files_names_list = []
self.folders_paths = []
self.files_names_absolute_list = []
Expand All @@ -268,7 +279,8 @@ def setup_main_layout(self):
self.main_layout.addWidget(self.video_source_label, 0, 0)
self.main_layout.addWidget(self.video_source_lineEdit, 0, 1, 1, 80)
self.main_layout.addWidget(self.video_clear_button, 0, 81)
self.main_layout.addWidget(self.video_source_button, 0, 82)
self.main_layout.addWidget(self.video_refresh_files_button, 0, 82)
self.main_layout.addWidget(self.video_source_button, 0, 83)
self.main_layout.addWidget(self.video_extensions_label, 1, 0)
self.main_layout.addWidget(self.video_extensions_comboBox, 1, 1)
self.main_layout.addWidget(self.video_default_duration_fps_label, 1, 2)
Expand Down Expand Up @@ -328,6 +340,7 @@ def connect_signals(self):
self.video_source_button.clicked_signal.connect(self.update_folder_path)
self.video_source_lineEdit.edit_finished_signal.connect(self.update_folder_path)
self.video_source_lineEdit.set_is_drag_and_drop_signal.connect(self.update_is_drag_and_drop)
self.video_refresh_files_button.clicked_signal.connect(self.update_folder_path)
self.video_clear_button.clear_files_signal.connect(self.clear_files)
self.video_extensions_comboBox.close_list.connect(self.check_extension_changes)
self.table.drop_folder_and_files_signal.connect(self.update_files_with_drag_and_drop)
Expand All @@ -342,6 +355,7 @@ def tab_clicked(self):
self.enable_editable_widgets()

def update_files_with_drag_and_drop(self, paths_list):
self.disable_video_refresh_button_cause_drag_and_drop()
duplicate_flag = False
not_duplicate_files_absolute_path_list = []
not_duplicate_files_list = []
Expand Down Expand Up @@ -426,6 +440,7 @@ def disable_editable_widgets(self):
self.video_extensions_comboBox.setEnabled(False)
self.video_source_lineEdit.setEnabled(False)
self.video_source_button.setEnabled(False)
self.video_refresh_files_button.setEnabled(False)
self.video_clear_button.setEnabled(False)
self.video_default_duration_fps_comboBox.setEnabled(False)
self.table.setAcceptDrops(False)
Expand All @@ -435,6 +450,7 @@ def enable_editable_widgets(self):
self.video_extensions_comboBox.setEnabled(True)
self.video_source_lineEdit.setEnabled(True)
self.video_source_button.setEnabled(True)
self.video_refresh_files_button.setEnabled(True)
self.video_clear_button.setEnabled(True)
self.video_default_duration_fps_comboBox.setEnabled(True)
self.table.setAcceptDrops(True)
Expand Down
2 changes: 1 addition & 1 deletion packages/Tabs/VideoTab/Widgets/RefreshFilesButton.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class RefreshFilesButton(QPushButton):
def __init__(self):
super().__init__()
self.setIcon(GlobalIcons.RefreshIcon)
self.hint_when_enabled = ""
self.hint_when_enabled = "Refresh Files"
self.current_path = ""
self.clicked.connect(self.refresh_files)

Expand Down

0 comments on commit ba72648

Please sign in to comment.