Bläddra i källkod

Right-click opens Book Settings dialog directly

- Remove popup menu approach\n- In TBook.BookMouseDown, handle mbRight to open TBookEditDialog\n- Drop PopupMenu wiring and related code
Codex CLI 4 månader sedan
förälder
incheckning
be76af11e1
3 ändrade filer med 20 tillägg och 41 borttagningar
  1. 18 1
      src/book.pas
  2. 0 8
      src/main.lfm
  3. 2 32
      src/main.pas

+ 18 - 1
src/book.pas

@@ -52,6 +52,8 @@ procedure SetPdfCoverGenerationEnabled(AEnabled: Boolean);
 
 implementation
 
+uses UnitBookDialog;
+
 var
   gPdfCoverEnabled: Boolean = True;
 
@@ -81,12 +83,27 @@ end;
 {------------------------------------------------------------------------------}
 { Mouse handlers (hook up in constructor)                                      }
 {------------------------------------------------------------------------------}
-procedure TBook.BookMouseDown({%H-}Sender: TObject; {%H-}Button: TMouseButton; {%H-}Shift: TShiftState; {%H-}X, {%H-}Y: Integer);
+procedure TBook.BookMouseDown({%H-}Sender: TObject; Button: TMouseButton; Shift: TShiftState; {%H-}X, {%H-}Y: Integer);
 var
   i: Integer;
   ctrl: TControl;
   otherBook: TBook;
+  dlg: TBookEditDialog;
 begin
+  // Right-click: open edit dialog immediately
+  if Button = mbRight then
+  begin
+    dlg := TBookEditDialog.Create(nil);
+    try
+      dlg.LoadBook(Self);
+      if dlg.ShowModal = mrOK then
+        EnsureScaledToCoverSize;
+    finally
+      dlg.Free;
+    end;
+    Exit;
+  end;
+
   // Exclusive select unless Ctrl is held; toggle in Ctrl mode
   if (mCover.Parent <> nil) and not (ssCtrl in Shift) then
   begin

+ 0 - 8
src/main.lfm

@@ -64,14 +64,6 @@ object Form1: TForm1
     Text = 'Search...'
     TextHintFontColor = clBtnText
   end
-  object PopupBook: TPopupMenu
-    left = 312
-    top = 184
-    object MenuEditBook: TMenuItem
-      Caption = 'Edit Book...'
-      OnClick = PopupEditBookClick
-    end
-  end
   object ComboSort: TComboBox
     Left = 400
     Height = 23

+ 2 - 32
src/main.pas

@@ -6,8 +6,8 @@ interface
 
 uses
   Classes, Sysutils, Fileutil, Forms, Controls, Graphics, Dialogs, ExtCtrls, LazFileUtils,
-  Book, BookCollection, LCLIntf, LResources, StdCtrls, Menus, LCLType, IniFiles, unitSettingsDialog,
-  unitCoverWorker, unitStorageXML, unitMetadata, UnitBookDialog, LazUTF8;
+  Book, BookCollection, LCLIntf, LResources, StdCtrls, LCLType, IniFiles, unitSettingsDialog,
+  unitCoverWorker, unitStorageXML, unitMetadata, LazUTF8;
 
 
 type
@@ -16,8 +16,6 @@ type
   TForm1 = class(TForm)
     EditSearch: Tedit;
     ComboSort: TComboBox;
-    PopupBook: TPopupMenu;
-    MenuEditBook: TMenuItem;
     ButtonSettings: Timage;
     ImageToolBar: Timage;
     ButtonAdd: Timage;
@@ -48,7 +46,6 @@ type
     function GetBookIndexAtPoint(X,Y:Integer):Integer;
     procedure UnselectAll;
     function GetCoverIndex(cover:TImage):Integer;
-    procedure PopupEditBookClick({%H-}Sender: TObject);
   private
     mAdd,mAddHover,mGear,mGearHover:TPicture;
     LayoutTimer: TTimer;
@@ -311,31 +308,6 @@ begin
  result:=-1;
 end;
 
-procedure TForm1.PopupEditBookClick({%H-}Sender: TObject);
-var
-  img: TImage;
-  idx: Integer;
-  dlg: TBookEditDialog;
-begin
-  if (PopupBook = nil) or (PopupBook.PopupComponent = nil) then Exit;
-  if not (PopupBook.PopupComponent is TImage) then Exit;
-  img := TImage(PopupBook.PopupComponent);
-  idx := GetCoverIndex(img);
-  if idx < 0 then Exit;
-
-  dlg := TBookEditDialog.Create(Self);
-  try
-    dlg.LoadBook(bookList.Books[idx]);
-    if dlg.ShowModal = mrOK then
-    begin
-      // reflect changes visually
-      bookList.Books[idx].EnsureScaledToCoverSize;
-      ApplyFilterAndLayout;
-    end;
-  finally
-    dlg.Free;
-  end;
-end;
 
 
 procedure TForm1.FormClose({%H-}Sender: TObject; var CloseAction: TCloseAction);
@@ -427,7 +399,6 @@ var
     book.Cover.Width:=coverWidth;
     book.Cover.Height:=coverHeight;
     book.Cover.Parent:=PanelBackground;
-    book.Cover.PopupMenu := PopupBook;
     // Ensure the pre-scaled image matches the final cover size
     book.EnsureScaledToCoverSize;
     CoverWorkerEnqueueBookIfMissing(book);
@@ -591,7 +562,6 @@ begin
     Cover.Width:=coverWidth;
     Cover.Height:=coverHeight;
     Cover.Parent:=PanelBackground;
-    Cover.PopupMenu := PopupBook;
     EnsureScaledToCoverSize;
   end;
 end;