Просмотр исходного кода

Autosave on add/delete/reorder and after cover generation

- main: call NotifyBooksChanged after adding, deleting, and drag-reordering books\n- cover worker: NotifyBooksChanged after applying a generated cover
Codex CLI 4 месяцев назад
Родитель
Сommit
2789c08012
2 измененных файлов с 10 добавлено и 2 удалено
  1. 7 1
      src/main.pas
  2. 3 1
      src/unitCoverWorker.pas

+ 7 - 1
src/main.pas

@@ -112,7 +112,7 @@ begin
  PanelBackground.Invalidate;
 end;
 
-procedure TForm1.PanelBackgroundDragDrop({%H-}Sender, Source: TObject; X, Y: Integer);
+  procedure TForm1.PanelBackgroundDragDrop({%H-}Sender, Source: TObject; X, Y: Integer);
 var src,dest:integer;
 begin
  src:=GetCoverIndex(TImage(Source));
@@ -121,6 +121,8 @@ begin
    UnselectAll;
    // After changing book order, recalculate layout so covers move immediately
    RearrangeBooksOnScreen();
+   // Persist order change
+   NotifyBooksChanged;
 end;
 
 procedure TForm1.PanelBackgroundDragOver({%H-}Sender, {%H-}Source: TObject; {%H-}X,
@@ -433,6 +435,8 @@ begin
 
       CoverWorkerStart;
       RearrangeBooksOnScreen();
+      // Persist additions immediately
+      NotifyBooksChanged;
     finally
       files.Free;
     end;
@@ -627,6 +631,8 @@ begin
       end;
     end;
     RearrangeBooksOnScreen();
+    // Persist deletions immediately
+    NotifyBooksChanged;
   end;
 end;
 

+ 3 - 1
src/unitCoverWorker.pas

@@ -7,7 +7,7 @@ interface
 uses
   Classes, SysUtils, Process, LCLIntf, Graphics, Math,
   IntfGraphics, FPImage, FPReadPNG, FPReadJPEG, GraphType, LazCanvas,
-  Book, BookCollection, FileUtil, unitLog;
+  Book, BookCollection, FileUtil, unitLog, unitAppEvents;
 
 { Call this once after loading your data: it scans the list and enqueues
   only the PDFs that still use the generic cover (i.e. ImagePath=''). }
@@ -317,6 +317,8 @@ begin
     begin
       FApplyBook.ImagePath := FApplyImg;  // triggers SetImage + pre-scale
       FApplyBook.EnsureScaledToCoverSize; // in case layout changed
+      // Persist cover change immediately
+      NotifyBooksChanged;
     end;
   except
     // ignore UI exceptions, keep worker going