1
0
Эх сурвалжийг харах

Persist sort selection and fix UTF-8 compare dependency

- main: save/read ComboSort selection to config.ini (section 'ui', key 'sort_by')\n- main: add AppConfigPath helper; ensure correct unit structure order\n- bookcollection: add LazUTF8 to implementation uses to fix UTF8LowerCase errors
Codex CLI 4 сар өмнө
parent
commit
971a1b0b46
2 өөрчлөгдсөн 35 нэмэгдсэн , 5 устгасан
  1. 1 1
      src/bookcollection.pas
  2. 34 4
      src/main.pas

+ 1 - 1
src/bookcollection.pas

@@ -35,7 +35,7 @@ end;
 implementation
 
 uses
-  unitCoverWorker;
+  unitCoverWorker, LazUTF8;
 
 { TBookCollection }
 

+ 34 - 4
src/main.pas

@@ -51,6 +51,7 @@ type
     LayoutTimer: TTimer;
     procedure LayoutTimerTick(Sender: TObject);
     procedure ApplyFilterAndLayout;
+    function AppConfigPath: String;
   public
     { public declarations }
   end;
@@ -87,6 +88,11 @@ begin
   RearrangeBooksOnScreen;
 end;
 
+function TForm1.AppConfigPath: String;
+begin
+  Result := IncludeTrailingPathDelimiter(GetAppConfigDirUTF8(False)) + 'config.ini';
+end;
+
 procedure TForm1.PanelBackgroundClick({%H-}Sender: TObject);
 begin
  ActiveControl:=PanelBackground;
@@ -559,6 +565,19 @@ end;
 
  RearrangeBooksOnScreen();
 
+ // Restore sort selection and apply
+ try
+   ini := TIniFile.Create(AppConfigPath);
+   try
+     ComboSort.ItemIndex := ini.ReadInteger('ui','sort_by', 0);
+   finally
+     ini.Free;
+   end;
+   ComboSortChange(nil);
+ except
+   // ignore
+ end;
+
  // Background: generate covers only where still generic
  CoverWorkerEnqueueMissingFromBookList(bookList);
  CoverWorkerStart;
@@ -590,10 +609,6 @@ begin
 end;
 
 
-initialization
-{$i mybookshelf.lrs}
-
-end.
 procedure TForm1.EditSearchChange({%H-}Sender: TObject);
 begin
   ApplyFilterAndLayout;
@@ -606,6 +621,16 @@ begin
     1: bookList.SortByTitle;
     2: bookList.SortByAuthor;
   end;
+  // Persist selection
+  try
+    with TIniFile.Create(AppConfigPath) do
+    try
+      WriteInteger('ui', 'sort_by', ComboSort.ItemIndex);
+    finally
+      Free;
+    end;
+  except
+  end;
   ApplyFilterAndLayout;
 end;
 
@@ -638,3 +663,8 @@ begin
   end;
   RearrangeBooksOnScreen();
 end;
+
+initialization
+{$i mybookshelf.lrs}
+
+end.