Răsfoiți Sursa

FIX: Bug [0001933] Viewer store current scroll position for next/previous files

Alexander Koblov 8 ani în urmă
părinte
comite
97f3e7d099
2 a modificat fișierele cu 33 adăugiri și 23 ștergeri
  1. 1 1
      components/viewer/viewercontrol.pas
  2. 32 22
      src/fviewer.pas

+ 1 - 1
components/viewer/viewercontrol.pas

@@ -1680,7 +1680,7 @@ begin
     Invalidate;
     Invalidate;
 
 
     // Set new scroll position.
     // Set new scroll position.
-    if LastLineReached then
+    if LastLineReached and (Value > 0) then
       FScrollBarPosition := 100
       FScrollBarPosition := 100
     else
     else
       FScrollBarPosition := Percent;
       FScrollBarPosition := Percent;

+ 32 - 22
src/fviewer.pas

@@ -554,12 +554,21 @@ begin
 end;
 end;
 
 
 procedure TfrmViewer.LoadFile(iIndex: Integer);
 procedure TfrmViewer.LoadFile(iIndex: Integer);
+var
+  ANewFile: Boolean;
 begin
 begin
+  ANewFile:= iActiveFile <> iIndex;
+
   iActiveFile := iIndex;
   iActiveFile := iIndex;
   LoadFile(FileList.Strings[iIndex]);
   LoadFile(FileList.Strings[iIndex]);
-  gboxPaint.Visible:=false;
-  gboxHightlight.Visible:=false;
-  Status.Panels[sbpFileNr].Text:=Format('%d/%d',[iIndex+1,FileList.Count]);
+
+  gboxPaint.Visible:= False;
+  gboxHightlight.Visible:= False;
+  Status.Panels[sbpFileNr].Text:= Format('%d/%d', [iIndex + 1, FileList.Count]);
+
+  if ANewFile then begin
+    if ViewerControl.IsFileOpen then ViewerControl.GoHome;
+  end;
 end;
 end;
 
 
 procedure TfrmViewer.FormResize(Sender: TObject);
 procedure TfrmViewer.FormResize(Sender: TObject);
@@ -1466,19 +1475,19 @@ begin
   gImagePaintMode := ComboBoxPaint.text;
   gImagePaintMode := ComboBoxPaint.text;
   gImagePaintWidth := StrToInt(ComboBoxWidth.Text) ;
   gImagePaintWidth := StrToInt(ComboBoxWidth.Text) ;
   gImagePaintColor := ColorBoxPaint.Selected;
   gImagePaintColor := ColorBoxPaint.Selected;
-  gTextPosition := ViewerControl.Position;
   case ViewerControl.Mode of
   case ViewerControl.Mode of
     vcmText: gViewerMode := 1;
     vcmText: gViewerMode := 1;
     vcmBin : gViewerMode := 2;
     vcmBin : gViewerMode := 2;
     vcmHex : gViewerMode := 3;
     vcmHex : gViewerMode := 3;
     vcmWrap: gViewerMode := 4;
     vcmWrap: gViewerMode := 4;
-    vcmBook: gViewerMode := 4;
+    vcmBook:
+      begin
+        gViewerMode := 4;
+        gTextPosition := ViewerControl.Position;
+      end;
   end;
   end;
 
 
-  if Assigned(WlxPlugins) then
-     begin
-       ExitPluginMode;
-     end;
+  if Assigned(WlxPlugins) then ExitPluginMode;
 
 
 {$IF NOT DEFINED(LCLWIN32)}
 {$IF NOT DEFINED(LCLWIN32)}
   if WindowState = wsFullScreen then WindowState:= wsNormal;
   if WindowState = wsFullScreen then WindowState:= wsNormal;
@@ -2649,25 +2658,26 @@ end;
 procedure TfrmViewer.cm_ShowGraphics(const Params: array of string);
 procedure TfrmViewer.cm_ShowGraphics(const Params: array of string);
 begin
 begin
   if CheckGraphics(FileList.Strings[iActiveFile]) then
   if CheckGraphics(FileList.Strings[iActiveFile]) then
-    begin
-      ViewerControl.FileName := ''; // unload current file if any is loaded
-      if LoadGraphics(FileList.Strings[iActiveFile]) then
-        ActivatePanel(pnlImage)
-      else
-        begin
-          ViewerControl.FileName := FileList.Strings[iActiveFile];
-          ActivatePanel(pnlText);
-        end;
-    end;
+  begin
+    ViewerControl.FileName := ''; // unload current file if any is loaded
+    if LoadGraphics(FileList.Strings[iActiveFile]) then
+      ActivatePanel(pnlImage)
+    else
+      begin
+        ViewerControl.FileName := FileList.Strings[iActiveFile];
+        ActivatePanel(pnlText);
+      end;
+  end;
 end;
 end;
 
 
 procedure TfrmViewer.cm_ShowPlugins(const Params: array of string);
 procedure TfrmViewer.cm_ShowPlugins(const Params: array of string);
 begin
 begin
   bPlugin:= CheckPlugins(FileList.Strings[iActiveFile], True);
   bPlugin:= CheckPlugins(FileList.Strings[iActiveFile], True);
   if bPlugin then
   if bPlugin then
-    ActivatePanel(nil)
-  else
-    ViewerControl.FileName := FileList.Strings[iActiveFile];
+  begin
+    ViewerControl.FileName := ''; // unload current file if any is loaded
+    ActivatePanel(nil);
+  end;
 end;
 end;
 
 
 procedure TfrmViewer.cm_ExitViewer(const Params: array of string);
 procedure TfrmViewer.cm_ExitViewer(const Params: array of string);