Qt,Qt5: fixed html text escaping - message boxes should be plain text. issue #37805

git-svn-id: trunk@63918 -
This commit is contained in:
zeljko 2020-09-24 08:46:27 +00:00
parent 4c4761c72e
commit 5d132a7330
3 changed files with 35 additions and 0 deletions

View File

@ -1811,9 +1811,11 @@ type
function getDetailText: WideString;
function getMessageStr: WideString;
function getMsgBoxType: QMessageBoxIcon;
function GetTextFormat: QtTextFormat;
procedure setDetailText(const AValue: WideString);
procedure setMessageStr(const AValue: WideString);
procedure setMsgBoxType(const AValue: QMessageBoxIcon);
procedure SetTextFormat(AValue: QtTextFormat);
procedure setTitle(const AValue: WideString);
protected
function CreateWidget(AParent: QWidgetH):QWidgetH; overload;
@ -1834,6 +1836,7 @@ type
property MessageStr: WideString read getMessageStr write setMessageStr;
property MsgBoxType:QMessageBoxIcon read getMsgBoxType write setMsgBoxType;
property Title: WideString read FTitle write setTitle;
property TextFormat: QtTextFormat read GetTextFormat write SetTextFormat;
end;
{ TQtCalendar }
@ -19535,6 +19538,11 @@ begin
Result := QMessageBox_icon(QMessageBoxH(Widget));
end;
function TQtMessageBox.GetTextFormat: QtTextFormat;
begin
Result := QMessageBox_textFormat(QMessageBoxH(Widget));
end;
procedure TQtMessageBox.setDetailText(const AValue: WideString);
var
Str: WideString;
@ -19572,6 +19580,11 @@ begin
QMessageBox_setIcon(QMessageBoxH(Widget), AValue);
end;
procedure TQtMessageBox.SetTextFormat(AValue: QtTextFormat);
begin
QMessageBox_setTextFormat(QMessageBoxH(Widget), AValue);
end;
procedure TQtMessageBox.setTitle(const AValue: WideString);
begin
if AValue <> FTitle then
@ -19604,6 +19617,7 @@ begin
AParent := QApplication_activeWindow;
{$ENDIF}
Widget := CreateWidget(AParent);
TextFormat := QtPlainText;
setProperty(Widget, 'lclwidget', Int64(PtrUInt(Self)));
QtWidgetSet.AddHandle(Self);
end;

View File

@ -1818,9 +1818,11 @@ type
function getDetailText: WideString;
function getMessageStr: WideString;
function getMsgBoxType: QMessageBoxIcon;
function GetTextFormat: QtTextFormat;
procedure setDetailText(const AValue: WideString);
procedure setMessageStr(const AValue: WideString);
procedure setMsgBoxType(const AValue: QMessageBoxIcon);
procedure SetTextFormat(AValue: QtTextFormat);
procedure setTitle(const AValue: WideString);
protected
function CreateWidget(AParent: QWidgetH):QWidgetH; overload;
@ -1841,6 +1843,7 @@ type
property MessageStr: WideString read getMessageStr write setMessageStr;
property MsgBoxType:QMessageBoxIcon read getMsgBoxType write setMsgBoxType;
property Title: WideString read FTitle write setTitle;
property TextFormat: QtTextFormat read GetTextFormat write SetTextFormat;
end;
{ TQtCalendar }
@ -19573,6 +19576,11 @@ begin
Result := QMessageBox_icon(QMessageBoxH(Widget));
end;
function TQtMessageBox.GetTextFormat: QtTextFormat;
begin
Result := QMessageBox_textFormat(QMessageBoxH(Widget));
end;
procedure TQtMessageBox.setDetailText(const AValue: WideString);
var
Str: WideString;
@ -19610,6 +19618,11 @@ begin
QMessageBox_setIcon(QMessageBoxH(Widget), AValue);
end;
procedure TQtMessageBox.SetTextFormat(AValue: QtTextFormat);
begin
QMessageBox_setTextFormat(QMessageBoxH(Widget), AValue);
end;
procedure TQtMessageBox.setTitle(const AValue: WideString);
begin
if AValue <> FTitle then
@ -19642,6 +19655,7 @@ begin
AParent := QApplication_activeWindow;
{$ENDIF}
Widget := CreateWidget(AParent);
TextFormat := QtPlainText;
setProperty(Widget, 'lclwidget', Int64(PtrUInt(Self)));
QtWidgetSet.AddHandle(Self);
end;

View File

@ -5202,6 +5202,7 @@ var
//OkStr: WideString;
AParent: QWidgetH;
DialogType, DefButton, DefIcon : Cardinal;
AQtString: QStringH;
begin
Result := 0;
Str := GetUtf8String(lpText);
@ -5214,6 +5215,12 @@ begin
DefButton:= ((uType and $00000300) shr 8) + 1;
DialogType:= (uType and $0000000F);
DefIcon := (uType and $000000FF) shr 4;
//issue #37805 - we must show plain text.
AQtString := QString_Create(PWideString(@Str));
QString_toHtmlEscaped(AQtString, @Str);
QString_destroy(AQtString);
case IconToMessageType(DefIcon) of
QMessageBoxInformation: Result := QMessageBox_information(AParent, @TitleStr, @Str, ButtonToQtButtons(DialogType), ButtonToQtDefButton(DialogType, DefButton));
QMessageBoxQuestion: Result := QMessageBox_question(AParent, @TitleStr, @Str, ButtonToQtButtons(DialogType), ButtonToQtDefButton(DialogType, DefButton));