ソースを参照

Book dialog: update cover preview when image path is edited

- Implement EditFilePathChange to load the image when EditImagePath changes\n- Prevents stale/blank preview when typing or pasting a path manually
Codex CLI 4 ヶ月 前
コミット
30cb5a0eaf
4 ファイル変更180 行追加12 行削除
  1. 155 0
      src/backup/myBookShelf.lps
  2. 14 9
      src/myBookShelf.lps
  3. 2 2
      src/unitbookdialog.lfm
  4. 9 1
      src/unitbookdialog.pas

+ 155 - 0
src/backup/myBookShelf.lps

@@ -0,0 +1,155 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<CONFIG>
+  <ProjectSession>
+    <Version Value="10"/>
+    <BuildModes Active="Default"/>
+    <Units Count="17">
+      <Unit0>
+        <Filename Value="myBookShelf.lpr"/>
+        <IsPartOfProject Value="True"/>
+        <EditorIndex Value="-1"/>
+        <CursorPos X="72" Y="10"/>
+        <UsageCount Value="70"/>
+      </Unit0>
+      <Unit1>
+        <Filename Value="main.pas"/>
+        <IsPartOfProject Value="True"/>
+        <ComponentName Value="Form1"/>
+        <HasResources Value="True"/>
+        <ResourceBaseClass Value="Form"/>
+        <EditorIndex Value="-1"/>
+        <TopLine Value="9"/>
+        <CursorPos X="50" Y="229"/>
+        <UsageCount Value="70"/>
+      </Unit1>
+      <Unit2>
+        <Filename Value="book.pas"/>
+        <IsPartOfProject Value="True"/>
+        <UnitName Value="Book"/>
+        <EditorIndex Value="-1"/>
+        <TopLine Value="82"/>
+        <CursorPos X="36" Y="37"/>
+        <UsageCount Value="70"/>
+      </Unit2>
+      <Unit3>
+        <Filename Value="bookcollection.pas"/>
+        <IsPartOfProject Value="True"/>
+        <UnitName Value="bookCollection"/>
+        <EditorIndex Value="-1"/>
+        <TopLine Value="7"/>
+        <CursorPos X="34" Y="28"/>
+        <UsageCount Value="67"/>
+      </Unit3>
+      <Unit4>
+        <Filename Value="unitbookdialog.pas"/>
+        <IsPartOfProject Value="True"/>
+        <ComponentName Value="BookEditDialog"/>
+        <HasResources Value="True"/>
+        <ResourceBaseClass Value="Form"/>
+        <UnitName Value="UnitBookDialog"/>
+        <EditorIndex Value="-1"/>
+        <TopLine Value="7"/>
+        <CursorPos X="2" Y="67"/>
+        <UsageCount Value="48"/>
+      </Unit4>
+      <Unit5>
+        <Filename Value="unitsettingsdialog.pas"/>
+        <IsPartOfProject Value="True"/>
+        <ComponentName Value="SettingsDialog"/>
+        <ResourceBaseClass Value="Form"/>
+        <UnitName Value="unitSettingsDialog"/>
+        <EditorIndex Value="-1"/>
+        <CursorPos X="55" Y="12"/>
+        <UsageCount Value="25"/>
+      </Unit5>
+      <Unit6>
+        <Filename Value="/usr/lib/lazarus/1.6.4/lcl/include/canvas.inc"/>
+        <EditorIndex Value="-1"/>
+        <TopLine Value="354"/>
+        <CursorPos Y="378"/>
+        <UsageCount Value="8"/>
+      </Unit6>
+      <Unit7>
+        <Filename Value="/usr/lib/lazarus/1.6.4/lcl/include/lclintf.inc"/>
+        <EditorIndex Value="-1"/>
+        <TopLine Value="254"/>
+        <CursorPos Y="275"/>
+        <UsageCount Value="7"/>
+      </Unit7>
+      <Unit8>
+        <Filename Value="/usr/lib/lazarus/1.6.4/lcl/interfaces/gtk2/gtk2winapi.inc"/>
+        <EditorIndex Value="-1"/>
+        <TopLine Value="4718"/>
+        <CursorPos Y="4740"/>
+        <UsageCount Value="7"/>
+      </Unit8>
+      <Unit9>
+        <Filename Value="/usr/lib/lazarus/1.6.4/lcl/interfaces/gtk2/gtk2widgetset.inc"/>
+        <EditorIndex Value="-1"/>
+        <TopLine Value="5406"/>
+        <CursorPos Y="5428"/>
+        <UsageCount Value="7"/>
+      </Unit9>
+      <Unit10>
+        <Filename Value="/usr/lib/lazarus/1.6.4/lcl/dynhasharray.pp"/>
+        <UnitName Value="DynHashArray"/>
+        <EditorIndex Value="-1"/>
+        <TopLine Value="598"/>
+        <CursorPos Y="620"/>
+        <UsageCount Value="7"/>
+      </Unit10>
+      <Unit11>
+        <Filename Value="/usr/lib/lazarus/1.6.4/lcl/include/customform.inc"/>
+        <EditorIndex Value="-1"/>
+        <TopLine Value="133"/>
+        <CursorPos Y="161"/>
+        <UsageCount Value="8"/>
+      </Unit11>
+      <Unit12>
+        <Filename Value="/usr/lib/lazarus/1.6.4/lcl/include/application.inc"/>
+        <EditorIndex Value="-1"/>
+        <TopLine Value="2183"/>
+        <CursorPos Y="2203"/>
+        <UsageCount Value="8"/>
+      </Unit12>
+      <Unit13>
+        <Filename Value="main.lfm"/>
+        <EditorIndex Value="-1"/>
+        <UsageCount Value="26"/>
+        <DefaultSyntaxHighlighter Value="LFM"/>
+      </Unit13>
+      <Unit14>
+        <Filename Value="/usr/lib/lazarus/1.6.4/components/lazutils/lazmethodlist.pas"/>
+        <UnitName Value="LazMethodList"/>
+        <EditorIndex Value="-1"/>
+        <TopLine Value="200"/>
+        <CursorPos Y="238"/>
+        <UsageCount Value="8"/>
+      </Unit14>
+      <Unit15>
+        <Filename Value="../../../Downloads/BigNumbers-master/Source/GenerateBaseConversionTables.dproj"/>
+        <EditorIndex Value="-1"/>
+        <UsageCount Value="10"/>
+        <DefaultSyntaxHighlighter Value="None"/>
+      </Unit15>
+      <Unit16>
+        <Filename Value="../../../Downloads/BigNumbers-master/Source/Velthuis.BigIntegers.pas"/>
+        <IsVisibleTab Value="True"/>
+        <TopLine Value="31"/>
+        <UsageCount Value="10"/>
+        <Loaded Value="True"/>
+      </Unit16>
+    </Units>
+    <JumpHistory HistoryIndex="-1"/>
+  </ProjectSession>
+  <Debugging>
+    <Watches Count="2">
+      <Item1>
+        <Expression Value="mCover"/>
+      </Item1>
+      <Item2>
+        <Expression Value="mFilePath"/>
+      </Item2>
+    </Watches>
+  </Debugging>
+</CONFIG>

+ 14 - 9
src/myBookShelf.lps

@@ -1,15 +1,16 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <CONFIG>
   <ProjectSession>
-    <Version Value="10"/>
+    <Version Value="12"/>
     <BuildModes Active="Default"/>
     <Units Count="17">
       <Unit0>
         <Filename Value="myBookShelf.lpr"/>
         <IsPartOfProject Value="True"/>
-        <EditorIndex Value="-1"/>
+        <IsVisibleTab Value="True"/>
         <CursorPos X="72" Y="10"/>
         <UsageCount Value="70"/>
+        <Loaded Value="True"/>
       </Unit0>
       <Unit1>
         <Filename Value="main.pas"/>
@@ -134,22 +135,26 @@
       </Unit15>
       <Unit16>
         <Filename Value="../../../Downloads/BigNumbers-master/Source/Velthuis.BigIntegers.pas"/>
-        <IsVisibleTab Value="True"/>
+        <EditorIndex Value="-1"/>
+        <WindowIndex Value="-1"/>
         <TopLine Value="31"/>
         <UsageCount Value="10"/>
-        <Loaded Value="True"/>
       </Unit16>
     </Units>
     <JumpHistory HistoryIndex="-1"/>
+    <RunParams>
+      <FormatVersion Value="2"/>
+      <Modes ActiveMode="default"/>
+    </RunParams>
   </ProjectSession>
   <Debugging>
-    <Watches Count="2">
-      <Item1>
+    <Watches>
+      <Item>
         <Expression Value="mCover"/>
-      </Item1>
-      <Item2>
+      </Item>
+      <Item>
         <Expression Value="mFilePath"/>
-      </Item2>
+      </Item>
     </Watches>
   </Debugging>
 </CONFIG>

+ 2 - 2
src/unitbookdialog.lfm

@@ -76,9 +76,9 @@ object BookEditDialog: TBookEditDialog
   end
   object Panel1: TPanel
     Left = 24
-    Height = 250
+    Height = 260
     Top = 33
-    Width = 130
+    Width = 140
     BorderWidth = 2
     BorderStyle = bsSingle
     ClientHeight = 250

+ 9 - 1
src/unitbookdialog.pas

@@ -239,7 +239,15 @@ End;
 
 procedure Tbookeditdialog.EditFilePathChange(Sender: Tobject);
 begin
-
+  // If user edits the image path manually, refresh the preview
+  if (Sender = EditImagePath) and FileExists(EditImagePath.Text) then
+  begin
+    try
+      ImageBookCover.Picture.LoadFromFile(EditImagePath.Text);
+    except
+      // ignore preview errors
+    end;
+  end;
 End;
 
 procedure Tbookeditdialog.Buttonsaveclick(Sender: Tobject);