View Issue Details

IDProjectCategoryView StatusLast Update
0000269Double CommanderGraphical user interfacepublic2014-01-14 22:53
Reporterdenis230 Assigned ToAlexx2000  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
ProjectionnoneETAnone 
Target Version0.5.5Fixed in Version0.5.5 
Summary0000269: Настройки: Шрифты: при изменении имени шрифта, то он не меняется
Descriptionв форме 'Настройки', закладка 'шрифты' при изменении названия шрифта он не применяется, например так как при изменении размера
TagsNo tags attached.
Attached Files
patch0000269.patch (11,759 bytes)   
Index: foptionsfonts.lfm
===================================================================
--- foptionsfonts.lfm	(revision 4108)
+++ foptionsfonts.lfm	(working copy)
@@ -77,6 +77,7 @@
     Anchors = [akTop, akLeft, akRight]
     BorderSpacing.Top = 6
     BorderSpacing.Right = 4
+    OnExit = edtMainFontExit
     TabOrder = 2
   end
   object btnSelEditFnt: TButton[6]
@@ -107,6 +108,7 @@
     Anchors = [akTop, akLeft, akRight]
     BorderSpacing.Top = 6
     BorderSpacing.Right = 4
+    OnExit = edtEditorFontExit
     TabOrder = 4
   end
   object edtEditorFontSize: TSpinEdit[8]
@@ -153,6 +155,7 @@
     Anchors = [akTop, akLeft, akRight]
     BorderSpacing.Top = 6
     BorderSpacing.Right = 4
+    OnExit = edtViewerFontExit
     TabOrder = 7
   end
   object edtViewerFontSize: TSpinEdit[11]
@@ -195,6 +198,7 @@
     Anchors = [akTop, akLeft, akRight]
     BorderSpacing.Top = 6
     BorderSpacing.Right = 4
+    OnExit = edtLogFontExit
     TabOrder = 9
   end
   object btnSelLogFnt: TButton[14]
@@ -253,6 +257,7 @@
     Anchors = [akTop, akLeft, akRight]
     BorderSpacing.Top = 6
     BorderSpacing.Right = 4
+    OnExit = edtViewerBookFontExit
     TabOrder = 12
   end
   object edtViewerBookFontSize: TSpinEdit[18]
Index: foptionsfonts.pas
===================================================================
--- foptionsfonts.pas	(revision 4108)
+++ foptionsfonts.pas	(working copy)
@@ -28,7 +28,7 @@
 
 uses
   Classes, SysUtils,
-  fOptionsFrame, StdCtrls, Spin, Dialogs;
+  StdCtrls, Spin, Dialogs, Graphics, fOptionsFrame, uGlobs;
 
 type
 
@@ -61,11 +61,26 @@
     procedure btnSelViewFntClick(Sender: TObject);
     procedure btnSelLogFntClick(Sender: TObject);
     procedure btnSelViewerBookFntClick(Sender: TObject);
+    procedure edtEditorFontExit(Sender: TObject);
     procedure edtEditorFontSizeChange(Sender: TObject);
+    procedure edtLogFontExit(Sender: TObject);
+    procedure edtMainFontExit(Sender: TObject);
     procedure edtMainFontSizeChange(Sender: TObject);
+    procedure edtViewerBookFontExit(Sender: TObject);
+    procedure edtViewerFontExit(Sender: TObject);
     procedure edtViewerFontSizeChange(Sender: TObject);
     procedure edtLogFontSizeChange(Sender: TObject);
     procedure edtViewerBookFontSizeChange(Sender: TObject);
+  private
+    procedure LoadFont(aDCFont:TDCFont);
+    procedure SaveFont(aDCFont:TDCFont);
+    //
+    function GetFont(aDCFont:TDCFont):TFont;
+    procedure SetFont(aDCFont:TDCFont;aFont:TFont);
+    procedure SetFontSize(aDCFont:TDCFont;aFontSize:Integer);
+    procedure SetFontName(aDCFont:TDCFont;aFontName:String);
+    //
+    procedure RunDialogFont(aDCFont:TDCFont);
   protected
     procedure Load; override;
     function Save: TOptionsEditorSaveFlags; override;
@@ -79,100 +94,85 @@
 {$R *.lfm}
 
 uses
-  uGlobs, uLng;
+  uLng;
 
 { TfrmOptionsFonts }
 
-procedure TfrmOptionsFonts.btnSelEditFntClick(Sender: TObject);
+procedure TfrmOptionsFonts.btnSelMainFntClick(Sender: TObject);
 begin
-  dlgFnt.Font.Name  := edtEditorFont.Text;
-  dlgFnt.Font.Size  := edtEditorFontSize.Value;
-  dlgFnt.Font.Style := edtEditorFont.Font.Style;
-  if dlgFnt.Execute then
-    begin
-      edtEditorFont.Text       := dlgFnt.Font.Name;
-      edtEditorFontSize.Value  := dlgFnt.Font.Size;
-      edtEditorFont.Font.Style := dlgFnt.Font.Style;
-    end;
+  RunDialogFont(dcfMain);
 end;
 
-procedure TfrmOptionsFonts.btnSelMainFntClick(Sender: TObject);
+procedure TfrmOptionsFonts.btnSelEditFntClick(Sender: TObject);
 begin
-  dlgFnt.Font.Name  := edtMainFont.Text;
-  dlgFnt.Font.Size  := edtMainFontSize.Value;
-  dlgFnt.Font.Style := edtMainFont.Font.Style;
-  if dlgFnt.Execute then
-    begin
-      edtMainFont.Text       := dlgFnt.Font.Name;
-      edtMainFontSize.Value  := dlgFnt.Font.Size;
-      edtMainFont.Font.Style := dlgFnt.Font.Style;
-    end;
+  RunDialogFont(dcfEditor);
 end;
 
 procedure TfrmOptionsFonts.btnSelViewFntClick(Sender: TObject);
 begin
-  dlgFnt.Font.Name  := edtViewerFont.Text;
-  dlgFnt.Font.Size  := edtViewerFontSize.Value;
-  dlgFnt.Font.Style := edtViewerFont.Font.Style;
-  if dlgFnt.Execute then
-    begin
-      edtViewerFont.Text       := dlgFnt.Font.Name;
-      edtViewerFontSize.Value  := dlgFnt.Font.Size;
-      edtViewerFont.Font.Style := dlgFnt.Font.Style;
-    end;
+  RunDialogFont(dcfViewer);
 end;
 
+procedure TfrmOptionsFonts.btnSelViewerBookFntClick(Sender: TObject);
+begin
+  RunDialogFont(dcfViewerBook);
+end;
+
 procedure TfrmOptionsFonts.btnSelLogFntClick(Sender: TObject);
 begin
-  dlgFnt.Font.Name  := edtLogFont.Text;
-  dlgFnt.Font.Size  := edtLogFontSize.Value;
-  dlgFnt.Font.Style := edtLogFont.Font.Style;
-  if dlgFnt.Execute then
-    begin
-      edtLogFont.Text       := dlgFnt.Font.Name;
-      edtLogFontSize.Value  := dlgFnt.Font.Size;
-      edtLogFont.Font.Style := dlgFnt.Font.Style;
-    end;
+  RunDialogFont(dcfLog);
 end;
 
-procedure TfrmOptionsFonts.btnSelViewerBookFntClick(Sender: TObject);
+procedure TfrmOptionsFonts.edtMainFontExit(Sender: TObject);
 begin
-  dlgFnt.Font.Name  := edtViewerBookFont.Text;
-  dlgFnt.Font.Size  := edtViewerBookFontSize.Value;
-  dlgFnt.Font.Style := edtViewerBookFont.Font.Style;
-  if dlgFnt.Execute then
-    begin
-      edtViewerBookFont.Text       := dlgFnt.Font.Name;
-      edtViewerBookFontSize.Value  := dlgFnt.Font.Size;
-      edtViewerBookFont.Font.Style := dlgFnt.Font.Style;
-    end;
+  SetFontName(dcfMain, TEdit(Sender).Text);
 end;
 
-procedure TfrmOptionsFonts.edtEditorFontSizeChange(Sender: TObject);
+procedure TfrmOptionsFonts.edtEditorFontExit(Sender: TObject);
 begin
-  edtEditorFont.Font.Size := edtEditorFontSize.Value;
+  SetFontName(dcfEditor, TEdit(Sender).Text);
 end;
 
+procedure TfrmOptionsFonts.edtViewerFontExit(Sender: TObject);
+begin
+  SetFontName(dcfViewer, TEdit(Sender).Text);
+end;
+
+procedure TfrmOptionsFonts.edtViewerBookFontExit(Sender: TObject);
+begin
+  SetFontName(dcfViewerBook, TEdit(Sender).Text);
+end;
+
+procedure TfrmOptionsFonts.edtLogFontExit(Sender: TObject);
+begin
+  SetFontName(dcfLog, TEdit(Sender).Text);
+end;
+
 procedure TfrmOptionsFonts.edtMainFontSizeChange(Sender: TObject);
 begin
-  edtMainFont.Font.Size := edtMainFontSize.Value;
+  SetFontSize(dcfMain, TSpinEdit(Sender).Value);
 end;
 
-procedure TfrmOptionsFonts.edtViewerFontSizeChange(Sender: TObject);
+procedure TfrmOptionsFonts.edtEditorFontSizeChange(Sender: TObject);
 begin
-  edtViewerFont.Font.Size := edtViewerFontSize.Value;
+  SetFontSize(dcfEditor, TSpinEdit(Sender).Value);
 end;
 
-procedure TfrmOptionsFonts.edtLogFontSizeChange(Sender: TObject);
+procedure TfrmOptionsFonts.edtViewerFontSizeChange(Sender: TObject);
 begin
-  edtLogFont.Font.Size := edtLogFontSize.Value;
+  SetFontSize(dcfViewer, TSpinEdit(Sender).Value);
 end;
 
 procedure TfrmOptionsFonts.edtViewerBookFontSizeChange(Sender: TObject);
 begin
-  edtViewerBookFont.Font.Size := edtViewerBookFontSize.Value;
+  SetFontSize(dcfViewerBook, TSpinEdit(Sender).Value);
 end;
 
+procedure TfrmOptionsFonts.edtLogFontSizeChange(Sender: TObject);
+begin
+  SetFontSize(dcfLog, TSpinEdit(Sender).Value);
+end;
+
 class function TfrmOptionsFonts.GetIconIndex: Integer;
 begin
   Result := 3;
@@ -185,64 +185,100 @@
 
 procedure TfrmOptionsFonts.Load;
 begin
-  edtMainFont.Text   := gFonts[dcfMain].Name;
-  edtEditorFont.Text := gFonts[dcfEditor].Name;
-  edtViewerFont.Text := gFonts[dcfViewer].Name;
-  edtLogFont.Text    := gFonts[dcfLog].Name;
-  edtViewerBookFont.Text := gFonts[dcfViewerBook].Name;
-
-  edtMainFontSize.Value   := gFonts[dcfMain].Size;
-  edtEditorFontSize.Value := gFonts[dcfEditor].Size;
-  edtViewerFontSize.Value := gFonts[dcfViewer].Size;
-  edtLogFontSize.Value    := gFonts[dcfLog].Size;
-  edtViewerBookFontSize.Value := gFonts[dcfViewerBook].Size;
-
-  FontOptionsToFont(gFonts[dcfMain], edtMainFont.Font);
-  FontOptionsToFont(gFonts[dcfEditor], edtEditorFont.Font);
-  FontOptionsToFont(gFonts[dcfViewer], edtViewerFont.Font);
-  FontOptionsToFont(gFonts[dcfLog], edtLogFont.Font);
-  FontOptionsToFont(gFonts[dcfViewerBook], edtViewerBookFont.Font);
+  LoadFont(dcfMain);
+  LoadFont(dcfEditor);
+  LoadFont(dcfViewer);
+  LoadFont(dcfLog);
+  LoadFont(dcfViewerBook);
+  //все загружено
 end;
 
 function TfrmOptionsFonts.Save: TOptionsEditorSaveFlags;
 begin
   Result := [];
+  SaveFont(dcfMain);
+  SaveFont(dcfEditor);
+  SaveFont(dcfViewer);
+  SaveFont(dcfLog);
+  SaveFont(dcfViewerBook);
+end;
 
-  with gFonts[dcfMain] do
-  begin
-    Name  := edtMainFont.Text;
-    Size  := edtMainFontSize.Value;
-    Style := edtMainFont.Font.Style;
+procedure TfrmOptionsFonts.LoadFont(aDCFont: TDCFont);
+ var xFont:TFont;
+begin
+  xFont:=TFont.Create;
+  try
+    FontOptionsToFont(gFonts[aDCFont], xFont);
+    SetFont(aDCFont, xFont);
+  finally
+    FreeAndNil(xFont);
   end;
+end;
 
-  with gFonts[dcfEditor] do
-  begin
-    Name  := edtEditorFont.Text;
-    Size  := edtEditorFontSize.Value;
-    Style := edtEditorFont.Font.Style;
-  end;
+procedure TfrmOptionsFonts.SaveFont(aDCFont: TDCFont);
+begin
+  FontToFontOptions(GetFont(aDCFont), gFonts[aDCFont]);
+end;
 
-  with gFonts[dcfViewer] do
-  begin
-    Name  := edtViewerFont.Text;
-    Size  := edtViewerFontSize.Value;
-    Style := edtViewerFont.Font.Style;
+procedure TfrmOptionsFonts.SetFont(aDCFont: TDCFont; aFont: TFont);
+begin
+  case aDCFont of
+    dcfMain: begin
+      edtMainFont.Font := aFont;
+      edtMainFont.Text := aFont.Name;
+      edtMainFontSize.Value := aFont.Size;
+    end;
+    dcfEditor: begin
+      edtEditorFont.Font := aFont;
+      edtEditorFont.Text := aFont.Name;
+      edtEditorFontSize.Value := aFont.Size;
+    end;
+    dcfViewer: begin
+      edtViewerFont.Font := aFont;
+      edtViewerFont.Text := aFont.Name;
+      edtViewerFontSize.Value := aFont.Size;
+    end;
+    dcfLog: begin
+      edtLogFont.Font := aFont;
+      edtLogFont.Text := aFont.Name;
+      edtLogFontSize.Value := aFont.Size;
+    end;
+    dcfViewerBook: begin
+      edtViewerBookFont.Font := aFont;
+      edtViewerBookFont.Text := aFont.Name;
+      edtViewerBookFontSize.Value := aFont.Size;
+    end;
   end;
+end;
 
-  with gFonts[dcfLog] do
-  begin
-    Name  := edtLogFont.Text;
-    Size  := edtLogFontSize.Value;
-    Style := edtLogFont.Font.Style;
-  end;
+procedure TfrmOptionsFonts.SetFontSize(aDCFont: TDCFont; aFontSize: Integer);
+begin
+  GetFont(aDCFont).Size:=aFontSize;
+end;
 
-  with gFonts[dcfViewerBook] do
-  begin
-    Name  := edtViewerBookFont.Text;
-    Size  := edtViewerBookFontSize.Value;
-    Style := edtViewerBookFont.Font.Style;
+procedure TfrmOptionsFonts.SetFontName(aDCFont: TDCFont; aFontName: String);
+begin
+  GetFont(aDCFont).Name:=aFontName;
+end;
+
+function TfrmOptionsFonts.GetFont(aDCFont: TDCFont): TFont;
+begin
+  case aDCFont of
+    dcfMain      : result := edtMainFont.Font;
+    dcfEditor    : result := edtEditorFont.Font;
+    dcfViewer    : result := edtViewerFont.Font;
+    dcfLog       : result := edtLogFont.Font;
+    dcfViewerBook: result := edtViewerBookFont.Font;
+    else result:=nil; //DOTO: показать ошибку для программиста
   end;
 end;
 
+procedure TfrmOptionsFonts.RunDialogFont(aDCFont: TDCFont);
+begin
+  dlgFnt.Font := GetFont(aDCFont);
+  if dlgFnt.Execute then SetFont(aDCFont, dlgFnt.Font);
+end;
+
+
 end.
 
patch0000269.patch (11,759 bytes)   
Fixed in Revision4125
Operating systemWindows
WidgetsetWin32
Architecture32-bit, 64-bit

Activities

denis230

2011-11-26 16:13

reporter   ~0000221

Готово, прошу проверить и залить в SVN
правда я почти полностью фреймик переделал, думаю так будет гораздо лучше

Скрипт:
прикрепил файлик к этой заявке

Issue History

Date Modified Username Field Change
2011-11-23 22:25 denis230 New Issue
2011-11-23 22:25 denis230 File Added: DC_Настройки_изменение шрифта.png
2011-11-23 22:25 denis230 Assigned To => denis230
2011-11-23 22:25 denis230 Status new => assigned
2011-11-26 16:12 denis230 File Added: patch0000269.patch
2011-11-26 16:13 denis230 Note Added: 0000221
2011-11-26 16:13 denis230 Assigned To denis230 => Alexx2000
2011-11-26 16:13 denis230 Status assigned => feedback
2011-12-01 12:23 Alexx2000 Fixed in Revision => 4125
2011-12-01 12:23 Alexx2000 Status feedback => resolved
2011-12-01 12:23 Alexx2000 Fixed in Version => 0.5.5
2011-12-01 12:23 Alexx2000 Resolution open => fixed
2012-05-13 00:13 cobines Target Version 0.6.0 (trunk) => 0.5.5
2014-01-14 22:53 Alexx2000 Status resolved => closed