From 48ab9d2cbb310a4c5c455e742a8a42e1263f6c7d Mon Sep 17 00:00:00 2001 From: mattias Date: Tue, 8 Nov 2016 14:59:32 +0000 Subject: [PATCH] =?UTF-8?q?IDEIntf:=20TPasswordStringPropertyEditor:=20dra?= =?UTF-8?q?w=20empty=20field=20on=20empty=20password=20and=20allow=20to=20?= =?UTF-8?q?override=20value,=20patch=20#30842,=20from=20Silvio=20Cl=C3=A9c?= =?UTF-8?q?io?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: trunk@53313 - --- components/ideintf/propedits.pp | 30 ++++++++++++++++++++++++------ components/sqldb/registersqldb.pas | 2 +- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/components/ideintf/propedits.pp b/components/ideintf/propedits.pp index 7e48b456fb..a0a61d3a37 100644 --- a/components/ideintf/propedits.pp +++ b/components/ideintf/propedits.pp @@ -23,7 +23,7 @@ interface uses // RTL / FCL - Classes, TypInfo, SysUtils, StrUtils, types, RtlConsts, variants, + Classes, TypInfo, SysUtils, types, RtlConsts, variants, // LCL LCLType, LCLIntf, LCLProc, Forms, Controls, GraphType, ButtonPanel, Graphics, StdCtrls, Buttons, Menus, ExtCtrls, ComCtrls, Dialogs, EditBtn, Grids, ValEdit, @@ -300,14 +300,14 @@ type FOwnerComponent: TComponent; FPropCount: Integer; FPropList: PInstPropList; - function GetPrivateDirectory: ansistring; - procedure DrawValue(const AValue: string; ACanvas:TCanvas; const ARect:TRect; - AState:TPropEditDrawState); protected // Draw Checkbox for Boolean and Set element editors. function DrawCheckbox(ACanvas: TCanvas; const ARect: TRect; IsTrue: Boolean): TRect; function DrawCheckValue(ACanvas: TCanvas; const ARect: TRect; {%H-}AState: TPropEditDrawState; {%H-}IsTrue: Boolean): TRect; + procedure DrawValue(const AValue: string; ACanvas:TCanvas; const ARect:TRect; + {%H-}AState:TPropEditDrawState); + function GetPrivateDirectory: ansistring; public constructor Create(Hook:TPropertyEditorHook; APropCount:Integer); virtual; destructor Destroy; override; @@ -529,6 +529,7 @@ type TPasswordStringPropertyEditor = class(TStringPropertyEditor) public + function GetPassword: string; virtual; procedure PropDrawValue(ACanvas: TCanvas; const ARect: TRect; AState: TPropEditDrawState); override; end; @@ -548,6 +549,7 @@ type TPasswordWideStringPropertyEditor = class(TWideStringPropertyEditor) public + function GetPassword: WideString; virtual; procedure PropDrawValue(ACanvas: TCanvas; const ARect: TRect; AState: TPropEditDrawState); override; end; @@ -3809,10 +3811,18 @@ end; { TPasswordStringPropertyEditor } +function TPasswordStringPropertyEditor.GetPassword: string; +begin + if GetVisualValue<>'' then + Result:='*****' + else + Result:=''; +end; + procedure TPasswordStringPropertyEditor.PropDrawValue(ACanvas: TCanvas; const ARect: TRect; AState: TPropEditDrawState); begin - DrawValue('*****',ACanvas,ARect,AState); + DrawValue(GetPassword,ACanvas,ARect,AState); end; { TWideStringPropertyEditor } @@ -3843,10 +3853,18 @@ end; { TPasswordWideStringPropertyEditor } +function TPasswordWideStringPropertyEditor.GetPassword: WideString; +begin + if GetVisualValue<>'' then + Result:='*****' + else + Result:=''; +end; + procedure TPasswordWideStringPropertyEditor.PropDrawValue(ACanvas: TCanvas; const ARect: TRect; AState: TPropEditDrawState); begin - DrawValue('*****',ACanvas,ARect,AState); + DrawValue(UTF8Encode(GetPassword),ACanvas,ARect,AState); end; { TNestedPropertyEditor } diff --git a/components/sqldb/registersqldb.pas b/components/sqldb/registersqldb.pas index 88a69f869a..158a3243ed 100644 --- a/components/sqldb/registersqldb.pas +++ b/components/sqldb/registersqldb.pas @@ -566,7 +566,7 @@ begin RegisterPropertyEditor(TypeInfo(AnsiString), TSQLDBLibraryLoader, 'ConnectionType', TSQLDBConnectorTypePropertyEditor); {$endif} - RegisterPropertyEditor(TypeInfo(string), TSQLConnection, 'Password', TPasswordWideStringPropertyEditor); + RegisterPropertyEditor(TypeInfo(AnsiString), TSQLConnection, 'Password', TPasswordStringPropertyEditor); RegisterPropertyEditor(TStrings.ClassInfo, TSQLQuery, 'SQL' , TSQLStringsPropertyEditor); RegisterPropertyEditor(TStrings.ClassInfo, TSQLQuery, 'InsertSQL', TSQLStringsPropertyEditor); RegisterPropertyEditor(TStrings.ClassInfo, TSQLQuery, 'UpdateSQL', TSQLStringsPropertyEditor);