mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-13 21:19:18 +02:00
qt: extend TQtMessageBox implementation
git-svn-id: trunk@28452 -
This commit is contained in:
parent
ea2052e5df
commit
38deafba9a
@ -1509,9 +1509,13 @@ type
|
|||||||
procedure DetachEvents; override;
|
procedure DetachEvents; override;
|
||||||
function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; override;
|
function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; override;
|
||||||
public
|
public
|
||||||
|
procedure AddButton(ABtn: QPushButtonH; AResult: Int64; const ADefaultBtn: Boolean;
|
||||||
|
const AEscapeBtn: Boolean); overload;
|
||||||
procedure AddButton(ABtnType: QMessageBoxStandardButton; ACaption: WideString;
|
procedure AddButton(ABtnType: QMessageBoxStandardButton; ACaption: WideString;
|
||||||
AIsDefaultBtn: Boolean; Const AEscapeBtn: Boolean = False);
|
const ADefaultBtn: Boolean; const AEscapeBtn: Boolean = False); overload;
|
||||||
function exec: QMessageBoxStandardButton;
|
procedure AddButton(AResult: Int64; ACaption: WideString;
|
||||||
|
const ADefaultBtn: Boolean; const AEscapeBtn: Boolean = False);
|
||||||
|
function exec: Int64;
|
||||||
property DetailText: WideString read getDetailText write setDetailText;
|
property DetailText: WideString read getDetailText write setDetailText;
|
||||||
property MessageStr: WideString read getMessageStr write setMessageStr;
|
property MessageStr: WideString read getMessageStr write setMessageStr;
|
||||||
property MsgBoxType:QMessageBoxIcon read getMsgBoxType write setMsgBoxType;
|
property MsgBoxType:QMessageBoxIcon read getMsgBoxType write setMsgBoxType;
|
||||||
@ -4264,7 +4268,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFDEF FPC_HAS_CONSTREF}
|
{$IFDEF FPC_HAS_CONSTREF}
|
||||||
function TQtWidget._Release: longint; stdcall; {$IFDEF WINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
|
function TQtWidget._Release: longint; {$IFDEF WINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
function TQtWidget._Release: longint; stdcall;
|
function TQtWidget._Release: longint; stdcall;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -13485,38 +13489,53 @@ begin
|
|||||||
Result := inherited EventFilter(Sender, Event);
|
Result := inherited EventFilter(Sender, Event);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TQtMessageBox.AddButton(ABtnType: QMessageBoxStandardButton;
|
procedure TQtMessageBox.AddButton(ABtn: QPushButtonH; AResult: Int64; const ADefaultBtn: Boolean; const AEscapeBtn: Boolean);
|
||||||
ACaption: WideString; AIsDefaultBtn: Boolean; const AEscapeBtn: Boolean);
|
|
||||||
var
|
var
|
||||||
ABtn: QPushButtonH;
|
|
||||||
Str: WideString;
|
|
||||||
v: QVariantH;
|
v: QVariantH;
|
||||||
begin
|
begin
|
||||||
ABtn := QMessageBox_addButton(QMessageBoxH(Widget), ABtnType);
|
if ADefaultBtn then
|
||||||
Str := GetUTF8String(ACaption);
|
|
||||||
QAbstractButton_setText(ABtn, @Str);
|
|
||||||
|
|
||||||
if AIsDefaultBtn then
|
|
||||||
QMessageBox_setDefaultButton(QMessageBoxH(Widget), ABtn);
|
QMessageBox_setDefaultButton(QMessageBoxH(Widget), ABtn);
|
||||||
|
|
||||||
if AEscapeBtn then
|
if AEscapeBtn then
|
||||||
QMessageBox_setEscapeButton(QMessageBoxH(Widget), ABtn);
|
QMessageBox_setEscapeButton(QMessageBoxH(Widget), ABtn);
|
||||||
|
|
||||||
v := QVariant_create(Int64(PtrUInt(ABtnType)));
|
v := QVariant_create(AResult);
|
||||||
try
|
try
|
||||||
QObject_setProperty(ABtn, 'lclmsgboxbutton', v);
|
QObject_setProperty(ABtn, 'lclmsgboxbutton', v);
|
||||||
finally
|
finally
|
||||||
QVariant_destroy(v);
|
QVariant_destroy(v);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TQtMessageBox.exec: QMessageBoxStandardButton;
|
procedure TQtMessageBox.AddButton(ABtnType: QMessageBoxStandardButton;
|
||||||
|
ACaption: WideString; const ADefaultBtn: Boolean; const AEscapeBtn: Boolean);
|
||||||
|
var
|
||||||
|
ABtn: QPushButtonH;
|
||||||
|
Str: WideString;
|
||||||
|
begin
|
||||||
|
ABtn := QMessageBox_addButton(QMessageBoxH(Widget), ABtnType);
|
||||||
|
Str := GetUTF8String(ACaption);
|
||||||
|
QAbstractButton_setText(ABtn, @Str);
|
||||||
|
AddButton(ABtn, Int64(ABtnType), ADefaultBtn, AEscapeBtn);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TQtMessageBox.AddButton(AResult: Int64; ACaption: WideString; const ADefaultBtn: Boolean;
|
||||||
|
const AEscapeBtn: Boolean);
|
||||||
|
var
|
||||||
|
ABtn: QPushButtonH;
|
||||||
|
Str: WideString;
|
||||||
|
begin
|
||||||
|
Str := GetUTF8String(ACaption);
|
||||||
|
ABtn := QMessageBox_addButton(QMessageBoxH(Widget), @Str, QMessageBoxActionRole);
|
||||||
|
AddButton(ABtn, AResult, ADefaultBtn, AEscapeBtn);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TQtMessageBox.exec: Int64;
|
||||||
var
|
var
|
||||||
ABtn: QPushButtonH;
|
ABtn: QPushButtonH;
|
||||||
v: QVariantH;
|
v: QVariantH;
|
||||||
ok: Boolean;
|
ok: Boolean;
|
||||||
QResult: QMessageBoxStandardButton;
|
QResult: Int64;
|
||||||
begin
|
begin
|
||||||
Result := QMessageBoxNoButton;
|
Result := QMessageBoxNoButton;
|
||||||
{$IFDEF QTDIALOGS_USES_QT_LOOP}
|
{$IFDEF QTDIALOGS_USES_QT_LOOP}
|
||||||
@ -13537,7 +13556,7 @@ begin
|
|||||||
QObject_property(ABtn, v, 'lclmsgboxbutton');
|
QObject_property(ABtn, v, 'lclmsgboxbutton');
|
||||||
if QVariant_isValid(v) then
|
if QVariant_isValid(v) then
|
||||||
begin
|
begin
|
||||||
QResult := QVariant_toULongLong(v, @Ok);
|
QResult := QVariant_toLongLong(v, @Ok);
|
||||||
if Ok then
|
if Ok then
|
||||||
Result := QResult;
|
Result := QResult;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user