2006-01-07 19:56:40 +00:00
|
|
|
{: Contains the configuration dialog.
|
|
|
|
|
|
|
|
Last changed: $Date$
|
|
|
|
Revision: $Rev$
|
|
|
|
Author: $Author$
|
|
|
|
}
|
|
|
|
unit UnSwConfiguration;
|
|
|
|
|
|
|
|
interface
|
|
|
|
uses
|
|
|
|
Classes,
|
|
|
|
ComCtrls,
|
|
|
|
Controls,
|
|
|
|
Dialogs,
|
|
|
|
ExtCtrls,
|
|
|
|
Forms,
|
|
|
|
Graphics,
|
|
|
|
StdCtrls;
|
|
|
|
|
|
|
|
type
|
|
|
|
TfrmUnSwConfiguration = class(TForm)
|
|
|
|
btnCancel: TButton;
|
|
|
|
btnDataModuleColor: TButton;
|
2006-01-15 00:22:09 +00:00
|
|
|
btnDefault: TButton;
|
2006-01-07 19:56:40 +00:00
|
|
|
btnFormColor: TButton;
|
|
|
|
btnOk: TButton;
|
|
|
|
btnProjectColor: TButton;
|
|
|
|
btnUnitColor: TButton;
|
2007-02-16 17:19:22 +00:00
|
|
|
chkAllowEmptyResults: TCheckBox;
|
2006-01-07 19:56:40 +00:00
|
|
|
chkCustomColor: TCheckBox;
|
|
|
|
dlgColor: TColorDialog;
|
|
|
|
imgAbout: TImage;
|
2006-01-09 19:24:56 +00:00
|
|
|
lblBugReport: TLabel;
|
2006-01-07 19:56:40 +00:00
|
|
|
lblDataModuleColor: TLabel;
|
|
|
|
lblFormColor: TLabel;
|
|
|
|
lblProjectColor: TLabel;
|
2006-03-14 20:11:31 +00:00
|
|
|
lblShortcutKeys: TLabel;
|
2006-01-07 19:56:40 +00:00
|
|
|
lblUnitColor: TLabel;
|
|
|
|
lblVersion: TLabel;
|
|
|
|
pcConfiguration: TPageControl;
|
|
|
|
pnlCustomColor: TPanel;
|
|
|
|
tsAbout: TTabSheet;
|
|
|
|
tsGeneral: TTabSheet;
|
2006-01-09 19:24:56 +00:00
|
|
|
|
2006-01-15 00:22:09 +00:00
|
|
|
procedure btnDefaultClick(Sender: TObject);
|
2006-01-07 19:56:40 +00:00
|
|
|
procedure chkCustomColorClick(Sender: TObject);
|
2006-01-09 19:24:56 +00:00
|
|
|
procedure lblBugReportClick(Sender: TObject);
|
2006-03-14 20:11:31 +00:00
|
|
|
procedure lblShortcutKeysClick(Sender: TObject);
|
2006-01-07 19:56:40 +00:00
|
|
|
procedure PickColor(Sender: TObject);
|
|
|
|
private
|
|
|
|
FLabels: array[0..3] of TLabel;
|
|
|
|
|
|
|
|
function InternalExecute(): Boolean;
|
|
|
|
|
|
|
|
procedure LoadSettings();
|
|
|
|
procedure SaveSettings();
|
|
|
|
public
|
|
|
|
class function Execute(): Boolean;
|
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
uses
|
2006-01-09 19:24:56 +00:00
|
|
|
ShellAPI,
|
|
|
|
Windows,
|
|
|
|
|
2006-01-26 19:40:23 +00:00
|
|
|
UnSwSettings,
|
|
|
|
UnSwShortcuts;
|
2006-01-07 19:56:40 +00:00
|
|
|
|
2007-02-16 17:19:22 +00:00
|
|
|
|
2006-01-07 19:56:40 +00:00
|
|
|
{$R *.dfm}
|
|
|
|
|
2007-02-16 17:19:22 +00:00
|
|
|
|
2006-01-07 19:56:40 +00:00
|
|
|
{ TfrmUnSwConfiguration }
|
|
|
|
class function TfrmUnSwConfiguration.Execute(): Boolean;
|
|
|
|
begin
|
|
|
|
with Self.Create(nil) do
|
|
|
|
try
|
2006-03-14 20:11:31 +00:00
|
|
|
pcConfiguration.ActivePage := tsGeneral;
|
2007-02-16 17:19:22 +00:00
|
|
|
|
2006-01-07 19:56:40 +00:00
|
|
|
Result := InternalExecute();
|
|
|
|
finally
|
|
|
|
Free();
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2007-02-16 17:19:22 +00:00
|
|
|
|
2006-01-07 19:56:40 +00:00
|
|
|
function TfrmUnSwConfiguration.InternalExecute(): Boolean;
|
|
|
|
var
|
|
|
|
iLabel: Integer;
|
|
|
|
|
|
|
|
begin
|
|
|
|
for iLabel := 0 to Pred(pnlCustomColor.ControlCount) do
|
|
|
|
with pnlCustomColor do
|
|
|
|
if (Controls[iLabel] is TLabel) and
|
|
|
|
(Controls[iLabel].Tag > 0) then
|
|
|
|
FLabels[Pred(Controls[iLabel].Tag)] := TLabel(Controls[iLabel]);
|
|
|
|
|
|
|
|
LoadSettings();
|
|
|
|
Result := (ShowModal() = mrOk);
|
|
|
|
if Result then
|
|
|
|
SaveSettings();
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2006-01-09 19:24:56 +00:00
|
|
|
procedure TfrmUnSwConfiguration.lblBugReportClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
ShellExecute(0, 'open', 'http://projects.kamadev.net/', nil, nil, SW_SHOWNORMAL);
|
|
|
|
end;
|
|
|
|
|
2007-02-16 17:19:22 +00:00
|
|
|
|
2006-01-26 19:40:23 +00:00
|
|
|
procedure TfrmUnSwConfiguration.lblShortcutKeysClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
TfrmUnSwShortcuts.Execute();
|
|
|
|
end;
|
|
|
|
|
2007-02-16 17:19:22 +00:00
|
|
|
|
2006-01-07 19:56:40 +00:00
|
|
|
procedure TfrmUnSwConfiguration.LoadSettings();
|
|
|
|
begin
|
|
|
|
chkCustomColor.Checked := Settings.Colors.Enabled;
|
|
|
|
lblDataModuleColor.Font.Color := Settings.Colors.DataModules;
|
|
|
|
lblFormColor.Font.Color := Settings.Colors.Forms;
|
|
|
|
lblProjectColor.Font.Color := Settings.Colors.ProjectSource;
|
|
|
|
lblUnitColor.Font.Color := Settings.Colors.Units;
|
2007-02-16 17:19:22 +00:00
|
|
|
chkAllowEmptyResults.Checked := Settings.Filter.AllowEmptyResult;
|
2006-01-07 19:56:40 +00:00
|
|
|
end;
|
|
|
|
|
2007-02-16 17:19:22 +00:00
|
|
|
|
2006-01-07 19:56:40 +00:00
|
|
|
procedure TfrmUnSwConfiguration.SaveSettings();
|
|
|
|
begin
|
2007-02-16 17:19:22 +00:00
|
|
|
Settings.Colors.Enabled := chkCustomColor.Checked;
|
|
|
|
Settings.Colors.DataModules := lblDataModuleColor.Font.Color;
|
|
|
|
Settings.Colors.Forms := lblFormColor.Font.Color;
|
|
|
|
Settings.Colors.ProjectSource := lblProjectColor.Font.Color;
|
|
|
|
Settings.Colors.Units := lblUnitColor.Font.Color;
|
|
|
|
Settings.Filter.AllowEmptyResult := chkAllowEmptyResults.Checked;
|
2006-01-07 19:56:40 +00:00
|
|
|
Settings.Save();
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2006-01-15 00:22:09 +00:00
|
|
|
procedure TfrmUnSwConfiguration.btnDefaultClick(Sender: TObject);
|
|
|
|
begin
|
2007-02-16 17:19:22 +00:00
|
|
|
if MessageBox(Self.Handle, 'Are you sure you want to revert the ' +
|
2006-01-15 00:22:09 +00:00
|
|
|
'settings? This action can not be undone.',
|
|
|
|
'Reset to default', MB_YESNO or MB_ICONQUESTION) = ID_YES then
|
|
|
|
begin
|
2007-02-16 17:19:22 +00:00
|
|
|
Settings.ResetDefaults();
|
2006-01-15 00:22:09 +00:00
|
|
|
Settings.Save();
|
|
|
|
LoadSettings();
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2007-02-16 17:19:22 +00:00
|
|
|
|
2006-01-07 19:56:40 +00:00
|
|
|
procedure TfrmUnSwConfiguration.chkCustomColorClick(Sender: TObject);
|
|
|
|
const
|
|
|
|
Colors: array[Boolean] of TColor = (clBtnFace, clWindow);
|
2007-02-16 17:19:22 +00:00
|
|
|
|
2006-01-07 19:56:40 +00:00
|
|
|
begin
|
|
|
|
pnlCustomColor.Enabled := chkCustomColor.Checked;
|
|
|
|
pnlCustomColor.Color := Colors[pnlCustomColor.Enabled];
|
|
|
|
end;
|
|
|
|
|
2007-02-16 17:19:22 +00:00
|
|
|
|
2006-01-07 19:56:40 +00:00
|
|
|
procedure TfrmUnSwConfiguration.PickColor(Sender: TObject);
|
|
|
|
var
|
|
|
|
typeLabel: TLabel;
|
|
|
|
|
|
|
|
begin
|
|
|
|
typeLabel := FLabels[Pred((Sender as TComponent).Tag)];
|
|
|
|
dlgColor.Color := typeLabel.Font.Color;
|
|
|
|
if dlgColor.Execute() then
|
|
|
|
typeLabel.Font.Color := dlgColor.Color;
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|