• R/O
  • SSH
  • HTTPS

denkzettelcompanion: Commit


Commit MetaInfo

Revision47 (tree)
Zeit2018-10-06 20:00:19
Autordummzeuch

Log Message

* Bugfix: If the notes directory did not exist, the configuration dialog should have been shown automatically. But apparently that does not work in the constructor of the main form in a Lazaraus program.
* Bugfix: Tf_DenkzettelCompanion.FormCloseQuery wow checks that FCategoriesFrame is assigned before calling its OnCloseQuery method.
* Bugfix: Tfr_Categories.OnCloseQuery now checks that FNotesFrame is assigned before calling its FormCloseQuery method
* Bugfix: Tfr_Notes.FormCloseQuery now checks that FEditframe is assigned before calling its FormCloseQuery method.

Ändern Zusammenfassung

Diff

--- trunk/src/w_denkzettelcompanion.pas (revision 46)
+++ trunk/src/w_denkzettelcompanion.pas (revision 47)
@@ -11,6 +11,7 @@
1111 Forms,
1212 Controls,
1313 Menus,
14+ StdCtrls,
1415 wf_Categories;
1516
1617 type
@@ -18,11 +19,21 @@
1819 { Tf_DenkzettelCompanion }
1920
2021 Tf_DenkzettelCompanion = class(TForm)
21- procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
22- procedure FormKeyUp(Sender: TObject; var Key: word; Shift: TShiftState);
22+ b_Configure: TButton;
23+ l_NotConfigured: TLabel;
24+ procedure b_ConfigureClick(Sender: TObject);
25+ procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
26+ procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
2327 private
24- FBasePath: string;
28+ const
29+ WM_CONFIG = WM_USER + 4711;
30+
31+ procedure InitCategoryFrame;
32+ private
33+ FBasePath: String;
2534 FCategoriesFrame: Tfr_Categories;
35+ procedure WmConfig(var _msg: TMessage); message WM_CONFIG;
36+ procedure FirstConfig;
2637 public
2738 constructor Create(_Owner: TComponent); override;
2839 destructor Destroy; override;
@@ -58,18 +69,13 @@
5869 end;
5970
6071 if not DirectoryExists(FBasePath) then begin
61- if not Tf_Settings.Execute(Self, FBasePath) then
62- Abort;
63- if not DirectoryExists(FBasePath) then begin
64- if not CreateDir(FBasePath) then
65- raise Exception.Create('Could not create directory.');
66- end;
72+ b_Configure.Visible := True;
73+ l_NotConfigured.Visible := True;
74+ PostMessage(self.Handle, WM_CONFIG, 0, 0);
75+ Exit; //==>
6776 end;
6877
69- FCategoriesFrame := Tfr_Categories.Create(Self);
70- FCategoriesFrame.Parent := Self;
71- FCategoriesFrame.Align := alClient;
72- FCategoriesFrame.Init(FBasePath);
78+ InitCategoryFrame;
7379 end;
7480
7581 destructor Tf_DenkzettelCompanion.Destroy;
@@ -90,13 +96,34 @@
9096 inherited Destroy;
9197 end;
9298
93-procedure Tf_DenkzettelCompanion.FormCloseQuery(Sender: TObject; var CanClose: boolean);
99+procedure Tf_DenkzettelCompanion.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
94100 begin
101+ if not Assigned(FCategoriesFrame) then
102+ Exit; //==>
95103 FCategoriesFrame.OnCloseQuery(Sender, CanClose);
96104 end;
97105
98-procedure Tf_DenkzettelCompanion.FormKeyUp(Sender: TObject; var Key: word; Shift: TShiftState);
106+procedure Tf_DenkzettelCompanion.FirstConfig;
99107 begin
108+ FreeAndNil(FCategoriesFrame);
109+ if not Tf_Settings.Execute(Self, FBasePath) then
110+ Abort;
111+ if not DirectoryExists(FBasePath) then begin
112+ if not CreateDir(FBasePath) then
113+ raise Exception.Create('Could not create directory.');
114+ end;
115+ InitCategoryFrame;
116+ b_Configure.Visible := False;
117+ l_NotConfigured.Visible := False;
118+end;
119+
120+procedure Tf_DenkzettelCompanion.b_ConfigureClick(Sender: TObject);
121+begin
122+ FirstConfig;
123+end;
124+
125+procedure Tf_DenkzettelCompanion.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
126+begin
100127 if not Assigned(FCategoriesFrame) then
101128 Exit; //==>
102129 if Key = VK_F10 then begin
@@ -113,4 +140,17 @@
113140 end;
114141 end;
115142
143+procedure Tf_DenkzettelCompanion.InitCategoryFrame;
144+begin
145+ FCategoriesFrame := Tfr_Categories.Create(Self);
146+ FCategoriesFrame.Parent := Self;
147+ FCategoriesFrame.Align := alClient;
148+ FCategoriesFrame.Init(FBasePath);
149+end;
150+
151+procedure Tf_DenkzettelCompanion.WmConfig(var _msg: TMessage);
152+begin
153+ FirstConfig;
154+end;
155+
116156 end.
--- trunk/src/wf_categories.pas (revision 46)
+++ trunk/src/wf_categories.pas (revision 47)
@@ -96,7 +96,7 @@
9696
9797 procedure Tfr_Categories.OnCloseQuery(_Sender: TObject; var _CanClose: boolean);
9898 begin
99- if not FNotesFrame.Visible then
99+ if not Assigned(FNotesFrame) or not FNotesFrame.Visible then
100100 Exit; //==>
101101 FNotesFrame.FormCloseQuery(_Sender, _CanClose);
102102 end;
--- trunk/src/wf_notes.pas (revision 46)
+++ trunk/src/wf_notes.pas (revision 47)
@@ -155,7 +155,7 @@
155155
156156 procedure Tfr_Notes.FormCloseQuery(_Sender: TObject; var _CanClose: boolean);
157157 begin
158- if not FEditFrame.Visible then
158+ if not Assigned(FEditFrame) or not FEditFrame.Visible then
159159 Exit; //==>
160160 FEditFrame.FormCloseQuery(_Sender, _CanClose);
161161 end;
Show on old repository browser