mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-06 07:58:07 +02:00
Qt5: Use QColorDialog_getColor() instead of QColorDialog_getRgba() so we can set title and options. issue #22717
This commit is contained in:
parent
7c3e5aa112
commit
563018b0c5
@ -873,11 +873,11 @@ end;
|
||||
class procedure TQtWSColorDialog.ShowModal(const ACommonDialog: TCommonDialog);
|
||||
var
|
||||
AColor: TColorRef;
|
||||
AQColor: TQColor;
|
||||
AQtColor: QColorH;
|
||||
ARgb: QRgb;
|
||||
AQColor, AQColorRet: TQColor;
|
||||
ReturnBool: Boolean;
|
||||
ATitle: WideString;
|
||||
ColorDialog: TColorDialog absolute ACommonDialog;
|
||||
AOptions: QColorDialogColorDialogOptions;
|
||||
{$IFDEF HASX11}
|
||||
AWND: HWND;
|
||||
{$ENDIF}
|
||||
@ -894,8 +894,8 @@ var
|
||||
if ExtractColorIndexAndColor(ColorDialog.CustomColors, i, AIndex, AColor) then
|
||||
if AIndex < CustomColorCount then
|
||||
begin
|
||||
ColorRefToTQColor(AColor, AQColor);
|
||||
QColorDialog_setCustomColor(AIndex, @AQColor{QRgb(AColor)});
|
||||
ColorRefToTQColor(AColor, AQColor{%H-});
|
||||
QColorDialog_setCustomColor(AIndex, @AQColor);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -905,30 +905,27 @@ begin
|
||||
AQColor.ColorSpec := 1;
|
||||
AQColor.Pad := 0;
|
||||
ColorRefToTQColor(AColor, AQColor);
|
||||
AQtColor := QColor_create(PQColor(@AQColor));
|
||||
ARgb := QColor_rgba(AQtColor);
|
||||
|
||||
FillCustomColors;
|
||||
|
||||
{$IFDEF HASX11}
|
||||
Clipboard.BeginX11SelectionLock;
|
||||
{$ENDIF}
|
||||
|
||||
ARgb := QColorDialog_getRgba(ARgb, @ReturnBool,
|
||||
TQtWSCommonDialog.GetDialogParent(ACommonDialog));
|
||||
ATitle := UTF8ToUTF16(ACommonDialog.Title);
|
||||
AQColorRet := Default(TQColor);
|
||||
AOptions := 0; // here we add possible options from ColorDialog.Options, see QColorDialogColorDialogOptions for possible options.
|
||||
QColorDialog_getColor(PQColor(@AQColorRet), PQColor(@AQColor), TQtWSCommonDialog.GetDialogParent(ACommonDialog), @ATitle, AOptions);
|
||||
|
||||
QColor_fromRgba(PQColor(AQtColor), ARgb);
|
||||
try
|
||||
QColor_toRgb(AQtColor, @AQColor);
|
||||
TQColorToColorRef(AQColor, AColor);
|
||||
ColorDialog.Color := TColor(AColor);
|
||||
finally
|
||||
QColor_destroy(AQtColor);
|
||||
end;
|
||||
ReturnBool := AQColorRet.ColorSpec <> 0;
|
||||
|
||||
if ReturnBool then
|
||||
ACommonDialog.UserChoice := mrOk
|
||||
else
|
||||
ACommonDialog.UserChoice := mrCancel;
|
||||
begin
|
||||
TQColorToColorRef(AQColorRet, AColor);
|
||||
ColorDialog.Color := AColor;
|
||||
ColorDialog.UserChoice := mrOk
|
||||
end else
|
||||
ColorDialog.UserChoice := mrCancel;
|
||||
{$IFDEF HASX11}
|
||||
Clipboard.EndX11SelectionLock;
|
||||
if (QtWidgetSet.WindowManagerName = 'xfwm4') and (QApplication_activeModalWidget() <> nil) then
|
||||
|
Loading…
Reference in New Issue
Block a user