2
0
johann 5 жил өмнө
parent
commit
7d4e787aa4

+ 17 - 9
lazpaint/dialog/upreviewdialog.lfm

@@ -7,39 +7,47 @@ object FPreviewDialog: TFPreviewDialog
   Caption = 'Preview'
   ClientHeight = 363
   ClientWidth = 439
+  OnCloseQuery = FormCloseQuery
   OnCreate = FormCreate
   OnDestroy = FormDestroy
-  Position = poMainFormCenter
-  LCLVersion = '1.8.2.0'
+  OnShow = FormShow
+  Position = poWorkAreaCenter
+  LCLVersion = '2.0.2.0'
   object vsPreview: TBGRAVirtualScreen
     Left = 0
-    Height = 339
-    Top = 24
+    Height = 338
+    Top = 25
     Width = 439
     Align = alClient
     Alignment = taLeftJustify
     Color = clGray
     ParentColor = False
+    ParentFont = False
     TabOrder = 0
     TabStop = True
   end
   object Panel1: TPanel
     Left = 0
-    Height = 24
+    Height = 25
     Top = 0
     Width = 439
     Align = alTop
+    AutoSize = True
     BevelOuter = bvNone
-    ClientHeight = 24
+    BorderWidth = 4
+    ClientHeight = 25
     ClientWidth = 439
+    ParentFont = False
     TabOrder = 1
     object LStatus: TLabel
-      Left = 8
+      Left = 4
       Height = 17
-      Top = 6
-      Width = 3
+      Top = 4
+      Width = 431
+      Align = alClient
       Caption = '.'
       ParentColor = False
+      ParentFont = False
     end
   end
 end

+ 41 - 0
lazpaint/dialog/upreviewdialog.pas

@@ -16,8 +16,10 @@ type
     LStatus: TLabel;
     Panel1: TPanel;
     vsPreview: TBGRAVirtualScreen;
+    procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
     procedure FormCreate(Sender: TObject);
     procedure FormDestroy(Sender: TObject);
+    procedure FormShow(Sender: TObject);
   private
     FPreview: TImagePreview;
     function GetDuplicateSourceIndex: integer;
@@ -76,11 +78,50 @@ begin
   FPreview.OnEscape:= @PreviewEscape;
 end;
 
+procedure TFPreviewDialog.FormCloseQuery(Sender: TObject; var CanClose: boolean);
+var r:TRect;
+begin
+  LazPaintInstance.Config.SetDefaultPreviewDialogMaximized(self.WindowState = wsMaximized);
+  if self.WindowState = wsNormal then
+  begin
+    r.left := Left;
+    r.top := Top;
+    r.right := r.left+ClientWidth;
+    r.Bottom := r.top+ClientHeight;
+    LazPaintInstance.Config.SetDefaultPreviewDialogPosition(r);
+  end
+  else
+    LazPaintInstance.Config.SetDefaultPreviewDialogPosition(TRect.Empty);
+end;
+
 procedure TFPreviewDialog.FormDestroy(Sender: TObject);
 begin
   FPreview.Free;
 end;
 
+procedure TFPreviewDialog.FormShow(Sender: TObject);
+var
+  r: TRect;
+begin
+  if Assigned(LazPaintInstance) then
+  begin
+    if LazPaintInstance.Config.DefaultPreviewDialogMaximized then self.WindowState := wsMaximized
+      else
+    begin
+      self.WindowState := wsNormal;
+      r := LazPaintInstance.Config.DefaultPreviewDialogPosition;
+      if (r.right > r.left) and (r.bottom > r.top) then
+      begin
+        self.Position := poDesigned;
+        self.Left := r.Left;
+        self.Top := r.Top;
+        self.ClientWidth := r.right-r.left;
+        self.ClientHeight := r.bottom-r.top
+      end;
+    end;
+  end;
+end;
+
 function TFPreviewDialog.GetFilename: string;
 begin
   result := FPreview.Filename;

+ 24 - 0
lazpaint/uconfig.pas

@@ -150,6 +150,10 @@ type
     procedure SetDefaultBrowseWindowMaximized(value: boolean);
     function DefaultBrowseWindowPosition: TRect;
     procedure SetDefaultBrowseWindowPosition(value: TRect);
+    function DefaultPreviewDialogMaximized: boolean;
+    procedure SetDefaultPreviewDialogMaximized(value: boolean);
+    function DefaultPreviewDialogPosition: TRect;
+    procedure SetDefaultPreviewDialogPosition(value: TRect);
 
     function DefaultPaletteToolbarVisible: boolean;
     procedure SetDefaultPaletteToolbarVisible(value: boolean);
@@ -590,6 +594,26 @@ begin
   iniOptions.WriteString('Window','BrowseWindowPosition',RectToStr(value));
 end;
 
+function TLazPaintConfig.DefaultPreviewDialogMaximized: boolean;
+begin
+  result := iniOptions.ReadBool('Window','PreviewDialogMaximized',false);
+end;
+
+procedure TLazPaintConfig.SetDefaultPreviewDialogMaximized(value: boolean);
+begin
+  iniOptions.WriteBool('Window','PreviewDialogMaximized',value);
+end;
+
+function TLazPaintConfig.DefaultPreviewDialogPosition: TRect;
+begin
+  result := StrToRect(iniOptions.ReadString('Window','PreviewDialogPosition',''));
+end;
+
+procedure TLazPaintConfig.SetDefaultPreviewDialogPosition(value: TRect);
+begin
+  iniOptions.WriteString('Window','PreviewDialogPosition',RectToStr(value));
+end;
+
 function TLazPaintConfig.DefaultPaletteToolbarVisible: boolean;
 begin
   result := iniOptions.ReadBool('Toolbar','PaletteToolbar',true);