From 2ed0b17c52a90a14f01c8f0eafcad35eeef38cd8 Mon Sep 17 00:00:00 2001
From: elukjanovica <elukjanovica.e@rkg.lv>
Date: Fri, 7 Jun 2024 08:44:38 +0300
Subject: [PATCH]

---
 main.py | 52 ++++++++++++++++++++++++----------------------------
 1 file changed, 24 insertions(+), 28 deletions(-)

diff --git a/main.py b/main.py
index c8135bb..5136bcb 100644
--- a/main.py
+++ b/main.py
@@ -468,42 +468,40 @@ def handle_album_interaction(album_hover, album):
     return None
 
 
+albums_to_delete = []
+
 def delete_albums_mode(album, y, album_rect, current_hovered_index, hover_index):
-    global checkbox_clicked
-    albums_to_delete = []
+    global albums_to_delete
     checkbox_rect = pygame.Rect(cons[2], y + cons[3], checkbox[1], checkbox[1])
     checkbox_hover = checkbox_rect.collidepoint(pygame.mouse.get_pos())
+    
+    for event in event_list:
+        if checkbox_hover and event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
+            pygame.time.wait(100)
+            cursor_pos = pygame.mouse.get_pos()
+            adjusted_pos = (cursor_pos[0] + 20, cursor_pos[1])
+            album_hover = album_rect.collidepoint(adjusted_pos)
+            index = update_hover_index(current_hovered_index, album_hover, hover_index)
+            album = list(storage["albums"].keys())[index]
 
-    if checkbox_hover and checkbox_clicked:
-        pygame.time.wait(100)
-        cursor_pos = pygame.mouse.get_pos()
-        adjusted_pos = (cursor_pos[0] + 20, cursor_pos[1])
-        album_hover = album_rect.collidepoint(adjusted_pos)
-        index = update_hover_index(current_hovered_index, album_hover, hover_index)
-        album = list(storage["albums"].keys())[index]
-        print("Adjusted Pos:", adjusted_pos, current_hovered_index)
-        print("salakhsahhgfsdjf", album)
+            if album_rect.collidepoint(adjusted_pos):
 
-        if album_rect.collidepoint(adjusted_pos):
-            #print(album)
-            album = list(storage["albums"].keys())[current_hovered_index]
-            #print("Checkbox Clicked for Album:", album)
+                if album not in albums_to_delete:
+                    albums_to_delete.append(album)
+                    checkbox_image = Image((checkbox[0] + checkbox[1] + 3, 0), (cons[2], y + cons[3]), (checkbox[1], checkbox[1]))
+                    print(albums_to_delete)
 
-            if album not in albums_to_delete:
-                albums_to_delete.append(album)
-                #print(albums_to_delete, album)
-        else:
-            if album in albums_to_delete:
-                albums_to_delete.remove(album)
-                #print("Album removed from delete:", album)
-        
-        #print(albums_to_delete, adjusted_pos)
-        return albums_to_delete
+                elif album in albums_to_delete:
+                    albums_to_delete.remove(album)
+                    print(albums_to_delete)
+            
+            return albums_to_delete
 
     checkbox_image = Image((checkbox[0], 0), (cons[2], y + cons[3]), (checkbox[1], checkbox[1]))
     if album in albums_to_delete:
         checkbox_image = Image((checkbox[0] + checkbox[1] + 3, 0), (cons[2], y + cons[3]), (checkbox[1], checkbox[1]))
     checkbox_image.draw(screen)
+    return albums_to_delete
 
 
 def delete_albums(albums_to_delete):
@@ -1233,9 +1231,7 @@ while run:
         elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
             if not non_movable_area.collidepoint(pygame.mouse.get_pos()):
                 can_move = True
-            if current_mode == "menu" and delete_mode:
-                checkbox_clicked = True
-            elif current_mode == "select":
+            if current_mode == "select":
                 clicked_image_rect = ImageRender.image_save(selected_album, current_img)
                 clicked_image = clicked_image_rect.collidepoint(event.pos)
                 if clicked_image: