Bläddra i källkod

Fix cover updates: preserve manual cover when changing file; save FilePath before ImagePath; refresh cover after save

- TBook.SetFile: if mImagePath already set, do not auto-override with sibling images\n- BookEditDialog.Save: set FilePath first, then ImagePath and refresh scaled cover
Codex CLI 4 månader sedan
förälder
incheckning
8183b294c8
2 ändrade filer med 10 tillägg och 2 borttagningar
  1. 4 1
      src/book.pas
  2. 6 1
      src/unitbookdialog.pas

+ 4 - 1
src/book.pas

@@ -227,7 +227,10 @@ begin
   if mFilePath = AValue then Exit;
   mFilePath := AValue;
 
-  // first try sibling images
+  // If a cover image was already chosen (manually or previously set), don't override it
+  if Trim(mImagePath) <> '' then Exit;
+
+  // Otherwise, try sibling images next to the book file
   SetImage(ChangeFileExt(AValue, '.png'));
   if mImagePath = '' then
     SetImage(ChangeFileExt(AValue, '.jpg'));

+ 6 - 1
src/unitbookdialog.pas

@@ -257,8 +257,13 @@ begin
   mbook.Title:=EditTitle.Text;
   mBook.Authors:=EditAuthors.Text;
   mBook.ISBN:=editisbn.Text;
-  mBook.ImagePath:=editimagepath.Text;
+  // Set file path first (auto-cover logic may look for sibling images)
   mBook.FilePath:=EditFilePath.Text;
+  // Then set explicit image path to ensure it takes precedence
+  mBook.ImagePath:=editimagepath.Text;
+
+  // Ensure UI reflects any new cover choice
+  mBook.EnsureScaledToCoverSize;
 
   Close;
 End;