|
|
@@ -7,7 +7,7 @@ interface
|
|
|
uses
|
|
|
Classes, Sysutils, Fileutil, Forms, Controls, Graphics, Dialogs, ExtCtrls, LazFileUtils,
|
|
|
Book, BookCollection, LCLIntf, LResources, StdCtrls, LCLType, IniFiles, unitSettingsDialog,
|
|
|
- unitCoverWorker, unitStorageXML, unitMetadata, LazUTF8;
|
|
|
+ unitCoverWorker, unitStorageXML, unitMetadata, unitAppEvents, LazUTF8;
|
|
|
|
|
|
|
|
|
type
|
|
|
@@ -52,6 +52,7 @@ type
|
|
|
procedure LayoutTimerTick(Sender: TObject);
|
|
|
procedure ApplyFilterAndLayout;
|
|
|
function AppConfigPath: String;
|
|
|
+ procedure SaveBooksNow;
|
|
|
public
|
|
|
{ public declarations }
|
|
|
end;
|
|
|
@@ -93,6 +94,16 @@ begin
|
|
|
Result := IncludeTrailingPathDelimiter(GetAppConfigDirUTF8(False)) + 'config.ini';
|
|
|
end;
|
|
|
|
|
|
+procedure TForm1.SaveBooksNow;
|
|
|
+begin
|
|
|
+ try
|
|
|
+ if Assigned(bookList) then
|
|
|
+ SaveBooksXML(dataXmlPath, bookList);
|
|
|
+ except
|
|
|
+ // ignore save errors during runtime autosave
|
|
|
+ end;
|
|
|
+end;
|
|
|
+
|
|
|
procedure TForm1.PanelBackgroundClick({%H-}Sender: TObject);
|
|
|
begin
|
|
|
ActiveControl:=PanelBackground;
|
|
|
@@ -549,6 +560,9 @@ begin
|
|
|
|
|
|
bookList:=TBookCollection.Create;
|
|
|
|
|
|
+ // Register autosave callback for book edits
|
|
|
+ OnBooksChanged := @SaveBooksNow;
|
|
|
+
|
|
|
// speed up startup: we skipped synchronous PDF generation during load
|
|
|
SetPdfCoverGenerationEnabled(False);
|
|
|
try
|