LCL-QT: Use UnicodeString instead of WideString. Reduce explicit string conversion calls.

git-svn-id: trunk@56639 -
This commit is contained in:
juha 2017-12-05 21:30:51 +00:00
parent 778f207e50
commit 057f42d604
19 changed files with 541 additions and 589 deletions

View File

@ -13989,14 +13989,14 @@ begin
Dispose(S);
end;
// WideString Access from c-code
procedure CopyUnicodeToPWideString(Unicode: PWideChar; var S: WideString; Len: Integer); cdecl; export;
// UnicodeString Access from c-code
procedure CopyUnicodeToPWideString(Unicode: PWideChar; var S: UnicodeString; Len: Integer); cdecl; export;
begin
SetString(S, Unicode, Len);
end;
function UnicodeOfPWideString(var S: WideString): PWideChar; cdecl; export;
function UnicodeOfPWideString(var S: UnicodeString): PWideChar; cdecl; export;
const
cEmptyStr = '';
begin
@ -14006,7 +14006,7 @@ begin
Result := PWideChar(Pointer(S));
end;
function LengthOfPWideString(var S: WideString): Integer; cdecl; export;
function LengthOfPWideString(var S: UnicodeString): Integer; cdecl; export;
begin
if @S <> nil then
Result := Length(S)

View File

@ -81,7 +81,7 @@ type
FAppSaveSessionRequest: QApplication_hookH;
// default application font name (FamilyName for "default" font)
FDefaultAppFontName: WideString;
FDefaultAppFontName: UnicodeString;
FDockImage: QRubberBandH;
FDragImageList: QWidgetH;
@ -186,7 +186,7 @@ type
// application global actions (mainform mainmenu mnemonics Alt+XX)
procedure ClearGlobalActions;
procedure AddGlobalAction(AnAction: QActionH);
function ShortcutInGlobalActions(const AMnemonicText: WideString;
function ShortcutInGlobalActions(const AMnemonicText: UnicodeString;
out AGlobalActionIndex: Integer): Boolean;
procedure TriggerGlobalAction(const ActionIndex: Integer);
@ -211,7 +211,7 @@ type
function GetWinKeyState(AKeyState: LongInt): SHORT;
{$ENDIF}
function CreateDefaultFont: HFONT; virtual;
function GetDefaultAppFontName: WideString;
function GetDefaultAppFontName: UnicodeString;
function GetQtDefaultDC: HDC; virtual;
procedure DeleteDefaultDC; virtual;
procedure SetQtDefaultDC(Handle: HDC); virtual;

View File

@ -176,23 +176,23 @@ begin
if (BtnID >= Low(IdButtonToQtStandardButton)) and
(BtnID <= High(IdButtonToQtStandardButton)) and
(IdButtonToQtStandardButton[BtnID] <> QMessageBoxNoButton) then
QtMessageBox.AddButton(Caption, IdButtonToQtStandardButton[BtnID], ModalResult, Default, Cancel)
QtMessageBox.AddButton(Caption{%H-}, IdButtonToQtStandardButton[BtnID], ModalResult, Default, Cancel)
else
QtMessageBox.AddButton(Caption, ModalResult, Default, Cancel);
QtMessageBox.AddButton(Caption{%H-}, ModalResult, Default, Cancel);
end;
end;
if DialogCaption <> '' then
QtMessageBox.Title := DialogCaption
else
{%H-}else
case DialogType of
idDialogWarning: QtMessageBox.Title := rsMtWarning;
idDialogError: QtMessageBox.Title := rsMtError;
idDialogInfo : QtMessageBox.Title := rsMtInformation;
idDialogConfirm : QtMessageBox.Title := rsMtConfirmation;
idDialogWarning: QtMessageBox.Title := rsMtWarning{%H-};
idDialogError: QtMessageBox.Title := rsMtError{%H-};
idDialogInfo : QtMessageBox.Title := rsMtInformation{%H-};
idDialogConfirm : QtMessageBox.Title := rsMtConfirmation{%H-};
end;
QtMessageBox.MessageStr := DialogMessage;
QtMessageBox.MessageStr := DialogMessage{%H-};
case DialogType of
idDialogWarning: QtMessageBox.MsgBoxType := QMessageBoxWarning;
@ -396,24 +396,24 @@ begin
if (BtnID >= Low(IdButtonToQtStandardButton)) and
(BtnID <= High(IdButtonToQtStandardButton)) and
(IdButtonToQtStandardButton[BtnID] <> QMessageBoxNoButton) then
QtMessageBox.AddButton(GetButtonCaption(BtnID), IdButtonToQtStandardButton[BtnID], BtnID,
QtMessageBox.AddButton(GetButtonCaption(BtnID){%H-}, IdButtonToQtStandardButton[BtnID], BtnID,
BtnIdx = DefaultIndex, (EscapeResult = mrCancel) and (BtnId = EscapeResult))
else
QtMessageBox.AddButton(GetButtonCaption(BtnID), BtnID, BtnIdx = DefaultIndex,
QtMessageBox.AddButton(GetButtonCaption(BtnID){%H-}, BtnID, BtnIdx = DefaultIndex,
(EscapeResult = mrCancel) and (BtnId = EscapeResult));
end;
if DialogCaption <> '' then
QtMessageBox.Title := DialogCaption
else
{%H-}else
case DialogType of
idDialogWarning: QtMessageBox.Title := rsMtWarning;
idDialogError: QtMessageBox.Title := rsMtError;
idDialogInfo : QtMessageBox.Title := rsMtInformation;
idDialogConfirm : QtMessageBox.Title := rsMtConfirmation;
idDialogWarning: QtMessageBox.Title := rsMtWarning{%H-};
idDialogError: QtMessageBox.Title := rsMtError{%H-};
idDialogInfo : QtMessageBox.Title := rsMtInformation{%H-};
idDialogConfirm : QtMessageBox.Title := rsMtConfirmation{%H-};
end;
QtMessageBox.MessageStr := DialogMessage;
QtMessageBox.MessageStr := DialogMessage{%H-};
case DialogType of
idDialogWarning: QtMessageBox.MsgBoxType := QMessageBoxWarning;

View File

@ -497,9 +497,9 @@ end;
procedure TQtWidgetSet.AppSetTitle(const ATitle: string);
var
W: WideString;
W: UnicodeString;
begin
W := GetUtf8String(ATitle);
W := {%H-}ATitle;
QCoreApplication_setApplicationName(@W);
end;
@ -625,7 +625,7 @@ var
W: TQtMainWindow;
LCLEvent: QLCLMessageEventH;
ASequence: QKeySequenceH;
AKey: WideString;
AKey: UnicodeString;
AParent: QWidgetH;
R: TRect;
AQtPoint: TQtPoint;
@ -639,7 +639,7 @@ var
function IsSystemTrayWidget: boolean;
var
AName: WideString;
AName: UnicodeString;
AWidget: QWidgetH;
RGeom: TRect;
AFlags: QtWindowFlags;
@ -650,7 +650,7 @@ var
begin
AWidget := QWidgetH(Sender);
QObject_objectName(Sender, @AName);
if UTF8Copy(AName, 1, 16) = 'qtlclsystrayicon' then
if Copy(AName, 1, 16) = 'qtlclsystrayicon' then
begin
for i := 0 to SysTrayIconsList.Count - 1 do
begin
@ -696,7 +696,7 @@ var
RGeom := TQtSystemTrayIcon(SysTrayIconsList.Items[i]).GetGeometry;
if (QApplication_widgetAt(RGeom.Left, RGeom.Top) = AWidget) then
begin
AName := 'qtlclsystrayicon_' + dbgHex(PtrUInt(AWidget));
AName := 'qtlclsystrayicon_' {%H-}+ dbgHex(PtrUInt(AWidget));
QObject_setObjectName(Sender, @AName);
TQtSystemTrayIcon(SysTrayIconsList.Items[i]).AttachSysTrayWidget(AWidget);
{$IFDEF DEBUGSYSTRAYICON}
@ -769,8 +769,7 @@ begin
QEventShortcutOverride: // issue #22827
begin
QKeyEvent_text(QKeyEventH(Event), @AKey);
if (QKeyEvent_modifiers(QKeyEventH(Event)) = QtAltModifier) and
(AKey <> '') then
if (QKeyEvent_modifiers(QKeyEventH(Event)) = QtAltModifier) and (AKey <> '') then
begin
ASequence := QKeySequence_create(QKeyEvent_modifiers(QKeyEventH(Event))
or QKeyEvent_Key(QKeyEventH(Event)));
@ -1566,13 +1565,13 @@ begin
FGlobalActions.Add(AnAction);
end;
function TQtWidgetSet.ShortcutInGlobalActions(const AMnemonicText: WideString;
function TQtWidgetSet.ShortcutInGlobalActions(const AMnemonicText: UnicodeString;
out AGlobalActionIndex: Integer): Boolean;
var
NewKey: QKeySequenceH;
NewStr: WideString;
NewStr: UnicodeString;
CurrentKey: QKeySequenceH;
CurrentStr: WideString;
CurrentStr: UnicodeString;
Action: QActionH;
i: Integer;
begin
@ -1763,7 +1762,7 @@ begin
Result := HFONT(QtFont);
end;
function TQtWidgetSet.GetDefaultAppFontName: WideString;
function TQtWidgetSet.GetDefaultAppFontName: UnicodeString;
begin
Result := FDefaultAppFontName;
end;
@ -1896,7 +1895,7 @@ function TQtWidgetSet.GetMenuHeight: Integer;
var
AMenuBar: QMenuBarH;
DummyWindow: QMainWindowH;
DummyStr: WideString;
DummyStr: UnicodeString;
Size: TSize;
begin
{$IFDEF DARWIN}
@ -2086,10 +2085,10 @@ end;
function TQtWidgetSet.GetStyleName: String;
var
WStr: WideString;
WStr: UnicodeString;
begin
QObject_objectName(QApplication_style, @WStr);
Result := UTF16ToUTF8(WStr);
Result := {%H-}WStr;
end;
//------------------------------------------------------------------------

View File

@ -95,8 +95,8 @@ type
constructor Create(const AParent: QObjectH = nil);
destructor Destroy; override;
function addAction(action: QActionH): QActionH; overload;
function addAction(text: WideString): QActionH; overload;
function addAction(icon: QIconH; text: WideString): QActionH; overload;
function addAction(text: UnicodeString): QActionH; overload;
function addAction(icon: QIconH; text: UnicodeString): QActionH; overload;
procedure removeAction(action: QActionH);
function actions: TQActions;
function checkedAction: QActionH;
@ -186,7 +186,7 @@ type
function getBold: Boolean;
function getUnderline: Boolean;
function getStrikeOut: Boolean;
function getFamily: WideString;
function getFamily: UnicodeString;
function getStyleStategy: QFontStyleStrategy;
procedure setPointSize(p1: Integer);
@ -224,11 +224,11 @@ type
function leading: Integer;
function maxWidth: Integer;
procedure boundingRect(retval: PRect; r: PRect; flags: Integer; text: PWideString; tabstops: Integer = 0; tabarray: PInteger = nil);
function charWidth(str: WideString; pos: Integer): Integer;
function charWidth(str: UnicodeString; pos: Integer): Integer;
function averageCharWidth: Integer;
function elidedText(const AText: WideString;
function elidedText(const AText: UnicodeString;
const AMode: QtTextElideMode; const AWidth: Integer;
const AFlags: Integer = 0): WideString;
const AFlags: Integer = 0): UnicodeString;
end;
{ TQtFontInfo }
@ -237,7 +237,7 @@ type
private
function GetBold: Boolean;
function GetExactMatch: Boolean;
function GetFamily: WideString;
function GetFamily: UnicodeString;
function GetFixedPitch: Boolean;
function GetFontStyle: QFontStyle;
function GetFontStyleHint: QFontStyleHint;
@ -258,7 +258,7 @@ type
property Bold: Boolean read GetBold;
property Italic: Boolean read GetItalic;
property ExactMatch: Boolean read GetExactMatch;
property Family: WideString read GetFamily;
property Family: UnicodeString read GetFamily;
property FixedPitch: Boolean read GetFixedPitch;
property Overline: Boolean read GetOverLine;
property PointSize: Integer read GetPointSize;
@ -606,37 +606,37 @@ type
function getPrinterContext: TQtDeviceContext;
function getCollateCopies: Boolean;
function getColorMode: QPrinterColorMode;
function getCreator: WideString;
function getCreator: UnicodeString;
function getDevType: Integer;
function getDocName: WideString;
function getDocName: UnicodeString;
function getDoubleSidedPrinting: Boolean;
function getFontEmbedding: Boolean;
function getFullPage: Boolean;
function getOutputFormat: QPrinterOutputFormat;
function getPaperSource: QPrinterPaperSource;
function getPrintProgram: WideString;
function getPrintProgram: UnicodeString;
function getPrintRange: QPrinterPrintRange;
procedure setCollateCopies(const AValue: Boolean);
procedure setColorMode(const AValue: QPrinterColorMode);
procedure setCreator(const AValue: WideString);
procedure setDocName(const AValue: WideString);
procedure setCreator(const AValue: UnicodeString);
procedure setDocName(const AValue: UnicodeString);
procedure setDoubleSidedPrinting(const AValue: Boolean);
procedure SetDuplexMode(AValue: QPrinterDuplexMode);
procedure setFontEmbedding(const AValue: Boolean);
procedure setFullPage(const AValue: Boolean);
procedure setOutputFormat(const AValue: QPrinterOutputFormat);
procedure setPaperSource(const AValue: QPrinterPaperSource);
procedure setPrinterName(const AValue: WideString);
function getPrinterName: WideString;
procedure setOutputFileName(const AValue: WideString);
function getOutputFileName: WideString;
procedure setPrinterName(const AValue: UnicodeString);
function getPrinterName: UnicodeString;
procedure setOutputFileName(const AValue: UnicodeString);
function getOutputFileName: UnicodeString;
procedure setOrientation(const AValue: QPrinterOrientation);
function getOrientation: QPrinterOrientation;
procedure setPageSize(const AValue: QPrinterPageSize);
function getPageSize: QPrinterPageSize;
procedure setPageOrder(const AValue: QPrinterPageOrder);
function getPageOrder: QPrinterPageOrder;
procedure setPrintProgram(const AValue: WideString);
procedure setPrintProgram(const AValue: UnicodeString);
procedure setPrintRange(const AValue: QPrinterPrintRange);
procedure setResolution(const AValue: Integer);
function getResolution: Integer;
@ -648,7 +648,7 @@ type
constructor Create(AMode: QPrinterPrinterMode); virtual; overload;
destructor Destroy; override;
function DefaultPrinter: WideString;
function DefaultPrinter: UnicodeString;
function GetAvailablePrinters(Lst: TStrings): Boolean;
procedure beginDoc;
@ -671,9 +671,9 @@ type
property Collate: Boolean read getCollateCopies write setCollateCopies;
property ColorMode: QPrinterColorMode read getColorMode write setColorMode;
property Creator: WideString read getCreator write setCreator;
property Creator: UnicodeString read getCreator write setCreator;
property DeviceType: Integer read getDevType;
property DocName: WideString read getDocName write setDocName;
property DocName: UnicodeString read getDocName write setDocName;
property DoubleSidedPrinting: Boolean read getDoubleSidedPrinting write setDoubleSidedPrinting;
property Duplex: QPrinterDuplexMode read GetDuplexMode write SetDuplexMode;
property FontEmbedding: Boolean read getFontEmbedding write setFontEmbedding;
@ -682,16 +682,16 @@ type
property NumCopies: Integer read getNumCopies write setNumCopies;
property Orientation: QPrinterOrientation read getOrientation write setOrientation;
property OutputFormat: QPrinterOutputFormat read getOutputFormat write setOutputFormat;
property OutputFileName: WideString read getOutputFileName write setOutputFileName;
property OutputFileName: UnicodeString read getOutputFileName write setOutputFileName;
property PageOrder: QPrinterPageOrder read getPageOrder write setPageOrder;
property PageSize: QPrinterPageSize read getPageSize write setPageSize;
property PaperSource: QPrinterPaperSource read getPaperSource write setPaperSource;
property PrinterContext: TQtDeviceContext read getPrinterContext;
property PrinterName: WideString read getPrinterName write setPrinterName;
property PrinterName: UnicodeString read getPrinterName write setPrinterName;
property PrinterActive: Boolean read FPrinterActive;
property PrintRange: QPrinterPrintRange read getPrintRange write setPrintRange;
property PrinterState: QPrinterPrinterState read getPrinterState;
property PrintProgram: WideString read getPrintProgram write setPrintProgram;
property PrintProgram: UnicodeString read getPrintProgram write setPrintProgram;
property Resolution: Integer read getResolution write setResolution;
end;
@ -789,10 +789,10 @@ type
constructor Create(AnObject: QObjectH);
destructor Destroy; override;
procedure DumpObject;
function findWidgetByName(const AName: WideString): QWidgetH;
function findWidgetByName(const AName: UnicodeString): QWidgetH;
function IsWidget(AnObject: QObjectH): Boolean;
function GetObjectName(AnObject: QObjectH): WideString;
function InheritsQtClass(AnObject: QObjectH; AQtClass: WideString): Boolean;
function GetObjectName(AnObject: QObjectH): UnicodeString;
function InheritsQtClass(AnObject: QObjectH; AQtClass: UnicodeString): Boolean;
property List: TStrings read FList;
property ObjList: TFPList read FObjList;
end;
@ -932,7 +932,7 @@ end;
procedure AssignQtFont(FromFont: QFontH; ToFont: QFontH);
var
FntFam: WideString;
FntFam: UnicodeString;
begin
QFont_family(FromFont, @FntFam);
QFont_setFamily(ToFont, @FntFam);
@ -983,12 +983,12 @@ begin
Result := QFontInfo_exactMatch(FHandle);
end;
function TQtFontInfo.GetFamily: WideString;
function TQtFontInfo.GetFamily: UnicodeString;
var
WStr: WideString;
WStr: UnicodeString;
begin
QFontInfo_family(FHandle, @WStr);
Result := UTF8ToUTF16(WStr);
Result := WStr;
end;
function TQtFontInfo.GetFixedPitch: Boolean;
@ -1632,7 +1632,7 @@ begin
Result := QFont_strikeOut(FHandle);
end;
function TQtFont.getFamily: WideString;
function TQtFont.getFamily: UnicodeString;
begin
if FHandle = nil then
QFont_family(getDefaultFont, @Result)
@ -1675,19 +1675,17 @@ end;
procedure TQtFont.setRawName(p1: string);
var
Str: WideString;
Str: UnicodeString;
begin
Str := GetUtf8String(p1);
Str := {%H-}p1;
QFont_setRawName(FHandle, @Str);
end;
procedure TQtFont.setFamily(p1: string);
var
Str: WideString;
Str: UnicodeString;
begin
Str := GetUtf8String(p1);
Str := {%H-}p1;
QFont_setFamily(FHandle, @Str);
end;
@ -1767,7 +1765,7 @@ begin
QFontMetrics_boundingRect(FHandle, retval, r, flags, text, tabstops, tabarray);
end;
function TQtFontMetrics.charWidth(str: WideString; pos: Integer): Integer;
function TQtFontMetrics.charWidth(str: UnicodeString; pos: Integer): Integer;
begin
Result := QFontMetrics_charWidth(FHandle, @str, pos);
end;
@ -1777,9 +1775,9 @@ begin
Result := QFontMetrics_averageCharWidth(FHandle);
end;
function TQtFontMetrics.elidedText(const AText: WideString;
function TQtFontMetrics.elidedText(const AText: UnicodeString;
const AMode: QtTextElideMode; const AWidth: Integer;
const AFlags: Integer = 0): WideString;
const AFlags: Integer = 0): UnicodeString;
begin
QFontMetrics_elidedText(FHandle, @Result, @AText, AMode, AWidth, AFlags);
end;
@ -1823,7 +1821,7 @@ begin
lG := ALogBrush.radStops[i].radColorG / $FFFF;
lB := ALogBrush.radStops[i].radColorB / $FFFF;
lA := ALogBrush.radStops[i].radColorA / $FFFF;
QColor_fromRgbF(lColor, lR, lG, lB, lA);
QColor_fromRgbF(lColor, lR, lG, lB, lA); // By Juha: Uninitialized pointer passed.
QGradient_setColorAt(FRadialGradient, ALogBrush.radStops[i].radPosition, lColor);
end;
@ -3847,7 +3845,7 @@ end;
procedure TQtClipboard.signalSelectionChanged; cdecl;
var
TempMimeData: QMimeDataH;
WStr: WideString;
WStr: UnicodeString;
Clip: TClipBoard;
begin
{$IFDEF VERBOSE_QT_CLIPBOARD}
@ -3873,7 +3871,7 @@ begin
Clip := Clipbrd.Clipboard(ctPrimarySelection);
Clip.OnRequest := nil;
FOnClipBoardRequest[ctPrimarySelection] := nil;
Clip.AsText := UTF8Decode(WStr);
Clip.AsText := WStr{%H-};
EndUpdate;
end;
end;
@ -3901,8 +3899,7 @@ end;
function TQtClipboard.IsClipboardChanged: Boolean;
var
TempMimeData: QMimeDataH;
Str: WideString;
Str2: WideString;
Str, Str2: UnicodeString;
begin
Result := not FLockClip;
if FLockClip then
@ -3916,13 +3913,10 @@ begin
QMimeData_hasURLS(TempMimeData)) then
begin
QMimeData_text(TempMimeData, @Str);
Str := UTF16ToUTF8(Str);
Str2 := Clipbrd.Clipboard.AsText;
Str2 := Clipbrd.Clipboard{%H-}.AsText;
Result := Str <> Str2;
if Result then
Clipbrd.Clipboard.AsText := Str;
Clipbrd.Clipboard.AsText := Str{%H-};
end;
finally
FLockClip := False;
@ -3938,7 +3932,7 @@ var
procedure PutSelectionOnClipBoard;
var
MimeType: WideString;
MimeType: UnicodeString;
MimeData: QMimeDataH;
Data: QByteArrayH;
DataStream: TMemoryStream;
@ -3966,7 +3960,7 @@ var
begin
DataStream.Size := 0;
DataStream.Position := 0;
MimeType := FormatToMimeType(Clip.Formats[I]);
MimeType := {%H-}FormatToMimeType(Clip.Formats[I]);
FOnClipBoardRequest[ClipboardType](Clip.Formats[I], DataStream);
Data := QByteArray_create(PAnsiChar(DataStream.Memory), DataStream.Size);
if (QByteArray_length(Data) > 1) and QByteArray_endsWith(Data, #0) then
@ -4056,14 +4050,14 @@ function TQtClipboard.GetData(ClipboardType: TClipboardType;
FormatID: TClipboardFormat; Stream: TStream): boolean;
var
QtMimeData: QMimeDataH;
MimeType: WideString;
MimeType: UnicodeString;
Data: QByteArrayH;
p: PAnsiChar;
s: Integer;
begin
Result := False;
QtMimeData := getMimeData(ClipbBoardTypeToQtClipboard[ClipBoardType]);
MimeType := FormatToMimeType(FormatID);
MimeType := {%H-}FormatToMimeType(FormatID);
Data := QByteArray_create();
QMimeData_data(QtMimeData, Data, @MimeType);
s := QByteArray_size(Data);
@ -4080,7 +4074,7 @@ var
QtMimeData: QMimeDataH;
QtList: QStringListH;
i: Integer;
Str: WideString;
Str: UnicodeString;
begin
Result := False;
Count := 0;
@ -4098,8 +4092,7 @@ begin
for i := 0 to Count - 1 do
begin
QStringList_at(QtList, @Str, i);
Str := UTF16ToUTF8(Str);
List[i] := RegisterFormat(Str);
List[i] := RegisterFormat(Str{%H-});
end;
Result := True;
@ -4115,7 +4108,7 @@ function TQtClipboard.GetOwnerShip(ClipboardType: TClipboardType;
procedure PutOnClipBoard;
var
MimeType: WideString;
MimeType: UnicodeString;
MimeData: QMimeDataH;
Data: QByteArrayH;
DataStream: TMemoryStream;
@ -4142,7 +4135,7 @@ function TQtClipboard.GetOwnerShip(ClipboardType: TClipboardType;
begin
DataStream.Size := 0;
DataStream.Position := 0;
MimeType := FormatToMimeType(Formats[I]);
MimeType := {%H-}FormatToMimeType(Formats[I]);
FOnClipBoardRequest[ClipboardType](Formats[I], DataStream);
Data := QByteArray_create(PAnsiChar(DataStream.Memory), DataStream.Size);
{do not remove #0 from Application/X-Laz-SynEdit-Tagged issue #25692}
@ -4215,18 +4208,16 @@ begin
end;
{returns default system printer}
function TQtPrinter.DefaultPrinter: WideString;
function TQtPrinter.DefaultPrinter: UnicodeString;
var
prnName: WideString;
PrnInfo: QPrinterInfoH;
begin
PrnInfo := QPrinterInfo_create();
QPrinterInfo_defaultPrinter(PrnInfo);
QPrinterInfo_printerName(PrnInfo, @PrnName);
QPrinterInfo_printerName(PrnInfo, @Result);
QPrinterInfo_destroy(PrnInfo);
if PrnName = '' then
PrnName := 'unknown';
Result := UTF8ToUTF16(PrnName);
if Result = '' then
Result := 'unknown';
end;
{returns available list of printers.
@ -4234,8 +4225,7 @@ end;
Default sys printer is always 1st in the list.}
function TQtPrinter.GetAvailablePrinters(Lst: TStrings): Boolean;
var
Str: WideString;
PrnName: WideString;
Str, PrnName: UnicodeString;
i: Integer;
PrnInfo: QPrinterInfoH;
Prntr: QPrinterInfoH;
@ -4255,16 +4245,16 @@ begin
begin
QPrinterInfo_printerName(Prntr, @PrnName);
if QPrinterInfo_isDefault(Prntr) then
Lst.Insert(0, UTF8ToUTF16(PrnName))
Lst.Insert(0, PrnName{%H-})
else
Lst.Add(UTF8ToUTF16(PrnName));
Lst.Add(PrnName{%H-});
end;
end;
finally
QPrinterInfo_destroy(PrnInfo);
end;
i := Lst.IndexOf(Str);
i := Lst.IndexOf(Str{%H-});
if i > 0 then
Lst.Move(i, 0);
Result := Lst.Count > 0;
@ -4310,12 +4300,12 @@ begin
Result := QPrinter_colorMode(FHandle);
end;
function TQtPrinter.getCreator: WideString;
function TQtPrinter.getCreator: UnicodeString;
var
Str: WideString;
Str: UnicodeString;
begin
QPrinter_creator(FHandle, @Str);
Result := UTF16ToUTF8(Str);
Result := Str;
end;
function TQtPrinter.getDevType: Integer;
@ -4323,12 +4313,12 @@ begin
Result := QPrinter_devType(FHandle);
end;
function TQtPrinter.getDocName: WideString;
function TQtPrinter.getDocName: UnicodeString;
var
Str: WideString;
Str: UnicodeString;
begin
QPrinter_docName(FHandle, @Str);
Result := UTF16ToUTF8(Str);
Result := Str;
end;
function TQtPrinter.getDoubleSidedPrinting: Boolean;
@ -4366,12 +4356,12 @@ begin
Result := QPrinter_paperSource(FHandle);
end;
function TQtPrinter.getPrintProgram: WideString;
function TQtPrinter.getPrintProgram: UnicodeString;
var
Str: WideString;
Str: UnicodeString;
begin
QPrinter_printProgram(FHandle, @Str);
Result := UTF16ToUTF8(Str);
Result := Str;
end;
function TQtPrinter.getPrintRange: QPrinterPrintRange;
@ -4389,19 +4379,19 @@ begin
QPrinter_setColorMode(FHandle, AValue);
end;
procedure TQtPrinter.setCreator(const AValue: WideString);
procedure TQtPrinter.setCreator(const AValue: UnicodeString);
var
Str: WideString;
Str: UnicodeString;
begin
Str := GetUtf8String(AValue);
Str := AValue;
QPrinter_setCreator(FHandle, @Str);
end;
procedure TQtPrinter.setDocName(const AValue: WideString);
procedure TQtPrinter.setDocName(const AValue: UnicodeString);
var
Str: WideString;
Str: UnicodeString;
begin
Str := GetUtf8String(AValue);
Str := AValue;
QPrinter_setDocName(FHandle, @Str);
end;
@ -4425,36 +4415,36 @@ begin
QPrinter_setFullPage(FHandle, AValue);
end;
procedure TQtPrinter.setPrinterName(const AValue: WideString);
procedure TQtPrinter.setPrinterName(const AValue: UnicodeString);
var
Str: WideString;
Str: UnicodeString;
begin
Str := GetUtf8String(AValue);
Str := AValue;
QPrinter_setPrinterName(FHandle, @Str);
end;
function TQtPrinter.getPrinterName: WideString;
function TQtPrinter.getPrinterName: UnicodeString;
var
Str: WideString;
Str: UnicodeString;
begin
QPrinter_printerName(FHandle, @Str);
Result := UTF16ToUTF8(Str);
Result := Str;
end;
procedure TQtPrinter.setOutputFileName(const AValue: WideString);
procedure TQtPrinter.setOutputFileName(const AValue: UnicodeString);
var
Str: WideString;
Str: UnicodeString;
begin
Str := GetUtf8String(AValue);
Str := AValue;
QPrinter_setOutputFileName(FHandle, @Str);
end;
function TQtPrinter.getOutputFileName: WideString;
function TQtPrinter.getOutputFileName: UnicodeString;
var
Str: WideString;
Str: UnicodeString;
begin
QPrinter_outputFileName(FHandle, @Str);
Result := UTF16ToUTF8(Str);
Result := Str;
end;
procedure TQtPrinter.setOrientation(const AValue: QPrinterOrientation);
@ -4487,11 +4477,11 @@ begin
Result := QPrinter_pageOrder(FHandle);
end;
procedure TQtPrinter.setPrintProgram(const AValue: WideString);
procedure TQtPrinter.setPrintProgram(const AValue: UnicodeString);
var
Str: WideString;
Str: UnicodeString;
begin
Str := GetUtf8String(AValue);
Str := AValue;
QPrinter_setPrintProgram(FHandle, @Str);
end;
@ -4740,10 +4730,10 @@ end;
function TQtStringList.Get(Index: Integer): string;
var
W: Widestring;
W: Unicodestring;
begin
QStringList_at(FHandle, @W, Index);
Result := UTF16ToUTF8(W);
Result := {%H-}W;
end;
function TQtStringList.GetCount: Integer;
@ -4782,9 +4772,9 @@ end;
procedure TQtStringList.Insert(Index: Integer; const S: string);
var
W: WideString;
W: UnicodeString;
begin
W := GetUtf8String(S);
W := {%H-}S;
QStringList_insert(FHandle, Index, @W);
end;
@ -4975,19 +4965,19 @@ begin
Result := QActionGroup_addAction(FHandle, action);
end;
function TQtActionGroup.addAction(text: WideString): QActionH;
function TQtActionGroup.addAction(text: UnicodeString): QActionH;
var
WStr: WideString;
WStr: UnicodeString;
begin
WStr := GetUTF8String(text);
WStr := text;
Result := QActionGroup_addAction(FHandle, @WStr);
end;
function TQtActionGroup.addAction(icon: QIconH; text: WideString): QActionH;
function TQtActionGroup.addAction(icon: QIconH; text: UnicodeString): QActionH;
var
WStr: WideString;
WStr: UnicodeString;
begin
WStr := GetUTF8String(text);
WStr := text;
Result := QActionGroup_addAction(FHandle, icon, @WStr);
end;
@ -5033,7 +5023,7 @@ end;
procedure TQtObjectDump.AddToList(AnObject: QObjectH);
// var
// ObjName: WideString;
// ObjName: UnicodeString;
begin
if AnObject <> nil then
begin
@ -5054,10 +5044,10 @@ begin
Iterator(FRoot);
end;
function TQtObjectDump.findWidgetByName(const AName: WideString): QWidgetH;
function TQtObjectDump.findWidgetByName(const AName: UnicodeString): QWidgetH;
var
j: Integer;
WS: WideString;
WS: UnicodeString;
begin
Result := nil;
if AName = '' then
@ -5081,7 +5071,7 @@ begin
Result := False;
end;
function TQtObjectDump.GetObjectName(AnObject: QObjectH): WideString;
function TQtObjectDump.GetObjectName(AnObject: QObjectH): UnicodeString;
begin
Result := '';
if AnObject = nil then
@ -5090,7 +5080,7 @@ begin
end;
function TQtObjectDump.InheritsQtClass(AnObject: QObjectH;
AQtClass: WideString): Boolean;
AQtClass: UnicodeString): Boolean;
begin
if (AnObject = nil) or (AQtClass = '') then
Result := False

View File

@ -292,8 +292,7 @@ begin
QtTabWidget.setUpdatesEnabled(False);
QtTabWidget.BeginUpdate;
try
QtTabWidget.insertTab(AIndex, TQtPage(AChild.Handle).Widget,
GetUtf8String(AChild.Caption));
QtTabWidget.insertTab(AIndex, TQtPage(AChild.Handle).Widget, AChild.Caption{%H-});
finally
QtTabWidget.EndUpdate;
QtTabWidget.setUpdatesEnabled(True);
@ -481,7 +480,7 @@ begin
Index := AChild.PageIndex;
if Index < 0 then
Index := ATabControl.IndexOf(AChild);
TQtTabWidget(ATabControl.Handle).setTabText(Index, GetUtf8String(AText));
TQtTabWidget(ATabControl.Handle).setTabText(Index, AText{%H-});
end;
class procedure TQtWSCustomTabControl.SetTabPosition(
@ -492,9 +491,11 @@ end;
class procedure TQtWSCustomTabControl.SetTabSize(
const ATabControl: TCustomTabControl; const ATabWidth, ATabHeight: integer);
const
FmtS = 'QTabBar::tab { height: %dpx; width: %dpx; }';
var
ASize, ANewSize: TSize;
WS: WideString;
WS: UnicodeString;
begin
if not WSCheckHandleAllocated(ATabControl, 'SetTabSize') then
Exit;
@ -510,9 +511,9 @@ begin
else
begin
if ATabControl.TabPosition in [tpLeft, tpRight] then
WS := {%H-}Format('QTabBar::tab { height: %dpx; width: %dpx; }',[ANewSize.cx, ANewSize.cy])
WS := {%H-}Format(FmtS, [ANewSize.cx, ANewSize.cy])
else
WS := {%H-}Format('QTabBar::tab { height: %dpx; width: %dpx; }',[ANewSize.cy, ANewSize.cx]);
WS := {%H-}Format(FmtS, [ANewSize.cy, ANewSize.cx]);
end;
QWidget_setStyleSheet(TQtTabWidget(ATabControl.Handle).Widget, @WS);
end;

View File

@ -98,7 +98,7 @@ type
FHasTrailingLineBreak: Boolean; // Indicates whether lines have trailing line break
FOwner: TWinControl; // Lazarus Control Owning MemoStrings
procedure InternalUpdate;
procedure ExternalUpdate(var AStr: WideString;
procedure ExternalUpdate(var AStr: UnicodeString;
AClear, ABlockSignals: Boolean);
function GetInternalText: string;
procedure SetInternalText(const Value: string);
@ -135,7 +135,7 @@ implementation
------------------------------------------------------------------------------}
procedure TQtMemoStrings.InternalUpdate;
var
W: WideString;
W: UnicodeString;
TextEdit: TQtTextEdit;
begin
W := '';
@ -145,7 +145,7 @@ begin
W := TextEdit.getText;
end;
if W <> '' then
SetInternalText(UTF16ToUTF8(W))
SetInternalText(W{%H-})
else
SetInternalText('');
FTextChanged := False;
@ -160,10 +160,10 @@ end;
Updates Qt Widget from text - If DelphiOnChange, generates OnChange Event
------------------------------------------------------------------------------}
procedure TQtMemoStrings.ExternalUpdate(var AStr: WideString;
procedure TQtMemoStrings.ExternalUpdate(var AStr: UnicodeString;
AClear, ABlockSignals: Boolean);
var
W: WideString;
W: UnicodeString;
TextEdit: TQtTextEdit;
begin
if not FOwner.HandleAllocated then
@ -174,7 +174,7 @@ begin
TextEdit := TQtTextEdit(FOwner.Handle);
if ABlockSignals then
TextEdit.BeginUpdate;
W := GetUtf8String(AStr);
W := AStr;
if AClear then
begin
// never trigger changed signal when clearing text here.
@ -272,27 +272,24 @@ begin
end;
procedure TQtMemoStrings.Put(Index: Integer; const S: string);
var
W: WideString;
begin
{$ifdef VerboseQtMemoStrings}
WriteLn('TQtMemoStrings.Put Index=',Index,' S=',S);
{$endif}
if FTextChanged then InternalUpdate;
FStringList[Index] := S;
W := GetUTF8String(S);
TQtTextEdit(FOwner.Handle).setLineText(Index, W);
TQtTextEdit(FOwner.Handle).setLineText(Index, S{%H-});
end;
procedure TQtMemoStrings.SetTextStr(const Value: string);
var
W: WideString;
W: UnicodeString;
begin
{$ifdef VerboseQtMemoStrings}
WriteLn('TQtMemoStrings.SetTextStr Value=',Value);
{$endif}
SetInternalText(Value);
W := GetInternalText;
W := {%H-}GetInternalText;
ExternalUpdate(W, True, False);
FTextChanged := False;
end;
@ -339,7 +336,7 @@ end;
------------------------------------------------------------------------------}
procedure TQtMemoStrings.Assign(Source: TPersistent);
var
W: WideString;
W: UnicodeString;
begin
if (Source=Self) or (Source=nil) then
exit;
@ -353,7 +350,7 @@ begin
{$endif}
FStringList.Clear;
SetInternalText(TStrings(Source).Text);
W := GetInternalText;
W := {%H-}GetInternalText;
ExternalUpdate(W, True, False);
FTextChanged := False;
exit;
@ -417,7 +414,7 @@ end;
------------------------------------------------------------------------------}
procedure TQtMemoStrings.Insert(Index: integer; const S: string);
var
W: WideString;
W: UnicodeString;
begin
if FTextChanged then InternalUpdate;
if Index < 0 then Index := 0;
@ -432,7 +429,7 @@ begin
Index := FStringList.Add(S)
else
FStringList.Insert(Index, S);
W := GetUTF8String(S);
W := {%H-}S;
TQtTextEdit(FOwner.Handle).insertLine(Index, W);
FTextChanged := False; // FStringList is already updated, no need to update from WS.
end;
@ -474,7 +471,7 @@ end;
procedure TQtComboStrings.InsertItem(Index: Integer; const S: string);
var
FSavedIndex: Integer;
FSavedText: WideString;
FSavedText: UnicodeString;
begin
inherited InsertItem(Index, S);
FOwner.BeginUpdate;
@ -493,7 +490,7 @@ end;
procedure TQtComboStrings.InsertItem(Index: Integer; const S: string; O: TObject);
var
FSavedIndex: Integer;
FSavedText: WideString;
FSavedText: UnicodeString;
begin
inherited InsertItem(Index, S, O);
FOwner.BeginUpdate;
@ -510,8 +507,7 @@ begin
FOwner.EndUpdate;
end;
constructor TQtComboStrings.Create(AWinControl: TWinControl;
AOwner: TQtComboBox);
constructor TQtComboStrings.Create(AWinControl: TWinControl; AOwner: TQtComboBox);
begin
inherited Create;
FWinControl := AWinControl;

View File

@ -49,7 +49,6 @@ type
procedure FillStandardDescription(var Desc: TRawImageDescription);
function GetPixelsPerInch: Integer;
function GetUtf8String(const S: String): WideString;
implementation
@ -94,13 +93,6 @@ begin
// Desc.MaskShift := 0;
end;
function GetUtf8String(const S: String): WideString;
begin
Result := UTF8ToUTF16(S);
if Result = '' then
Result := S;
end;
{------------------------------------------------------------------------------
Function: GetPixelsPerInch
Params: none

View File

@ -54,7 +54,7 @@ type
function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; override;
procedure setContextMenu(menu: QMenuH);
procedure setIcon(icon: QIconH);
procedure setToolTip(tip: WideString);
procedure setToolTip(tip: UnicodeString);
procedure signalActivated(AReason: QSystemTrayIconActivationReason); cdecl;
procedure showBaloonHint(const ATitle, AHint: String;
const AFlag: QSystemTrayIconMessageIcon; const ATimeOut: Integer);
@ -73,7 +73,7 @@ implementation
constructor TQtSystemTrayIcon.Create(vIcon: QIconH);
var
AName: WideString; {just to debug}
AName: UnicodeString; {just to debug}
begin
inherited Create;
FSysTrayWidget := nil;
@ -175,7 +175,7 @@ var
X, Y: Integer;
R: TRect;
P: TQtPoint;
AHint: WideString;
AHint: UnicodeString;
{$IFDEF HASX11}
PaintData: TSysTrayIconPaintData;
{$ENDIF}
@ -225,7 +225,7 @@ begin
begin
R := GetGeometry;
QtPoint(R.Left, R.Top);
AHint := UTF8ToUTF16(FTrayIcon.Hint);
AHint := FTrayIcon{%H-}.Hint;
QToolTip_showText(@P, @AHint);
end;
end;
@ -253,7 +253,7 @@ begin
QSystemTrayIcon_setIcon(QSystemTrayIconH(TheObject), icon);
end;
procedure TQtSystemTrayIcon.setToolTip(tip: WideString);
procedure TQtSystemTrayIcon.setToolTip(tip: UnicodeString);
begin
QSystemTrayIcon_setToolTip(QSystemTrayIconH(TheObject), @tip)
end;
@ -312,11 +312,10 @@ end;
procedure TQtSystemTrayIcon.showBaloonHint(const ATitle, AHint: String;
const AFlag: QSystemTrayIconMessageIcon; const ATimeOut: Integer);
var
WHint: WideString;
WTitle: WideString;
WHint, WTitle: UnicodeString;
begin
WHint := GetUTF8String(AHint);
WTitle := GetUTF8String(ATitle);
WHint := {%H-}AHint;
WTitle := {%H-}ATitle;
QSystemTrayIcon_showMessage(QSystemTrayIconH(TheObject), @WTitle, @WHint, AFlag, ATimeOut);
end;

View File

@ -46,7 +46,7 @@ type
private
FStyle: QStyleH;
function GetStyle: QStyleH;
function GetStyleName: WideString;
function GetStyleName: UnicodeString;
protected
function InitThemes: Boolean; override;
function UseThemes: Boolean; override;
@ -56,7 +56,7 @@ type
function GetControlState(Details: TThemedElementDetails): QStyleState;
function GetDrawElement(Details: TThemedElementDetails): TQtDrawElement;
property Style: QStyleH read GetStyle;
property StyleName: WideString read GetStyleName;
property StyleName: UnicodeString read GetStyleName;
public
procedure DrawElement(DC: HDC; Details: TThemedElementDetails; const R: TRect; ClipRect: PRect); override;
procedure DrawEdge(DC: HDC; Details: TThemedElementDetails; const R: TRect; Edge, Flags: Cardinal; AContentRect: PRect); override;
@ -81,7 +81,7 @@ begin
Result := FStyle;
end;
function TQtThemeServices.GetStyleName: WideString;
function TQtThemeServices.GetStyleName: UnicodeString;
begin
QObject_objectName(Style, @Result);
end;
@ -557,7 +557,7 @@ var
Palette: QPaletteH;
Context: TQtDeviceContext;
Widget: QWidgetH;
W: WideString;
W: UnicodeString;
TextRect: TRect;
AOldMode: Integer;
ATextPalette: Cardinal;
@ -568,7 +568,7 @@ begin
case Details.Element of
teToolTip:
begin
W := GetUTF8String(S);
W := {%H-}S;
Context.save;
AOldMode := Context.SetBkMode(TRANSPARENT);
try
@ -612,7 +612,7 @@ begin
exit;
end;
W := GetUTF8String(S);
W := {%H-}S;
Context.save;
try
Context.SetBkMode(TRANSPARENT);
@ -660,7 +660,7 @@ begin
else
begin // default text drawing for all !
W := GetUTF8String(S);
W := {%H-}S;
Context.save;
AOldMode := Context.SetBkMode(TRANSPARENT);
if Context.Parent <> nil then

File diff suppressed because it is too large Load Diff

View File

@ -68,7 +68,7 @@ end;
This function is Called:
- Once on every OnPaint event
------------------------------------------------------------------------------}
function TQtWidgetSet.BeginPaint(Handle: hWnd; var PS: TPaintStruct): hdc;
function TQtWidgetSet.BeginPaint(Handle: hWnd; Var PS: TPaintStruct): hdc;
var
Widget: TQtWidget;
DC: TQtDeviceContext;
@ -591,7 +591,7 @@ begin
if not IsFontNameDefault(FamilyName) then
QtFont.setFamily(FamilyName)
else
QtFont.setFamily(UTF16ToUTF8(GetDefaultAppFontName));
QtFont.setFamily(GetDefaultAppFontName{%H-});
if LogFont.lfQuality <= High(QStyleStategy) then
QtFont.setStyleStrategy(QStyleStategy[LogFont.lfQuality]);
@ -1311,7 +1311,7 @@ end;
function TQtWidgetSet.DrawText(DC: HDC; Str: PChar; Count: Integer;
var ARect: TRect; Flags: Cardinal): Integer;
var
WideStr: WideString;
WStr: UnicodeString;
R: TRect;
QtDC: TQtDeviceContext;
F: Integer;
@ -1376,9 +1376,9 @@ begin
QtDC :=TQtDeviceContext(DC);
if Count >= 0 then
WideStr := GetUtf8String(Copy(Str, 1, Count))
WStr := {%H-}Copy(Str, 1, Count)
else
WideStr := GetUtf8String(Str);
WStr := Str;
ClipRect := Rect(0, 0, 0, 0);
B := QtDC.getClipping;
@ -1409,7 +1409,7 @@ begin
F := DTFlagsToQtFlags(Flags);
QtDC.Metrics.BoundingRect(@R, @ARect, F, @WideStr);
QtDC.Metrics.BoundingRect(@R, @ARect, F, @WStr);
//TODO: result should be different when DT_VCENTER or DT_BOTTOM is set
Result := R.Bottom - R.Top;
@ -1490,12 +1490,12 @@ begin
begin
// windows are removing trailing spaces in this case
// and we are doing same thing too.
WideStr := TrimLeft(WideStr);
WStr := TrimLeft(WStr);
with ARect do
WideStr := QtDC.Metrics.elidedText(WideStr, QtElideRight, Right - Left, 0);
WStr := QtDC.Metrics.elidedText(WStr, QtElideRight, Right - Left, 0);
end;
QtDC.DrawText(ARect.Left + Pt.X, ARect.Top + Pt.Y, ARect.Right-ARect.Left, ARect.Bottom-ARect.Top, F, @WideStr);
QtDC.DrawText(ARect.Left + Pt.X, ARect.Top + Pt.Y, ARect.Right-ARect.Left, ARect.Bottom-ARect.Top, F, @WStr);
end;
{------------------------------------------------------------------------------
@ -1754,7 +1754,7 @@ var
const AWritingSystem: QFontDatabaseWritingSystem = QFontDatabaseAny):integer;
var
StrLst: QStringlistH;
WStr: WideString;
WStr: UnicodeString;
j: integer;
begin
Result := -1;
@ -1765,7 +1765,7 @@ var
for j := 0 to Result - 1 do
begin
QStringList_at(StrLst, @WStr, j);
List.Add(UTF16ToUTF8(WStr));
List.Add(WStr{%H-});
end;
finally
QStringList_destroy(StrLst);
@ -1779,7 +1779,7 @@ var
var
StrLst: QStringlistH;
NewList: QStringListH;
WStr: WideString;
WStr: UnicodeString;
j: integer;
begin
Result := -1;
@ -1821,7 +1821,7 @@ var
for j := 0 to QStringList_size(NewList) - 1 do
begin
QStringList_at(NewList, @WStr, j);
List.Add(UTF16ToUTF8(WStr));
List.Add(WStr{%H-});
end;
Result := List.Count;
finally
@ -1832,20 +1832,20 @@ var
function GetStyleAt(AIndex: Integer): String;
var
WStr: WideString;
WStr: UnicodeString;
begin
Result := '';
if (AIndex >= 0) and (AIndex < QStringList_size(StylesList)) then
begin
QStringList_at(StylesList, @WStr, AIndex);
Result := UTF16ToUTF8(WStr);
Result := {%H-}WStr;
end;
end;
function GetWritingSystems(AFontName: String; AList: QStringListH;
ACharsetList: TFPList): Boolean;
var
WStr: WideString;
WStr: UnicodeString;
Arr: TPtrIntArray;
j: Integer;
begin
@ -1853,7 +1853,7 @@ var
QStringList_clear(AList);
if Assigned(CharSetList) then
CharSetList.Clear;
WStr := UTF8ToUTF16(AFontName);
WStr := {%H-}AFontName;
QFontDatabase_writingSystems(FontDB, @Arr, @WStr);
Result := length(Arr) > 0;
for j := 0 to High(Arr) do
@ -1870,9 +1870,9 @@ var
out AStyle: String): Integer;
var
Font: QFontH;
WStr: WideString;
WStr: UnicodeString;
begin
WStr := UTF8ToUTF16(AFontName);
WStr := {%H-}AFontName;
Font := QFont_create(@WStr);
ALogFontA.lfItalic := Byte(QFont_italic(Font));
ALogFontA.lfWeight := QFont_weight(Font);
@ -2195,7 +2195,7 @@ end;
function TQtWidgetSet.ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint;
Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean;
var
WideStr: WideString;
WStr: UnicodeString;
QtDC: TQtDeviceContext absolute DC;
R, R1: TRect;
Pt: TPoint;
@ -2208,7 +2208,7 @@ var
CurCount: LongInt;
CurDx: PInteger;
CurStr: PChar;
W: WideString;
W: UnicodeString;
begin
CurDx := Dx;
CurStr := Str;
@ -2217,16 +2217,12 @@ var
while CurCount > 0 do
begin
CharLen := UTF8CharacterLength(CurStr);
W := {%H-}Copy(CurStr, 1, CharLen);
if AClipped then
begin
W := GetUTF8String(Copy(CurStr, 1, CharLen));
QtDC.drawText(CurX, Y, Rect^.Right - Rect^.Left, Rect^.Bottom - Rect^.Top,
QtTextDontClip, @W);
end else
begin
W := GetUTF8String(Copy(CurStr, 1, CharLen));
QtTextDontClip, @W)
else
QtDC.drawText(CurX, Y, @W);
end;
inc(CurX, CurDx^);
inc(CurDx);
inc(CurStr, CharLen);
@ -2247,12 +2243,12 @@ begin
if ((Options and (ETO_OPAQUE + ETO_CLIPPED)) <> 0) and (Rect = nil) then
begin
if Count >= 0 then
WideStr := GetUtf8String(Copy(Str, 1, Count))
WStr := {%H-}Copy(Str, 1, Count)
else
WideStr := GetUtf8String(Str);
WStr := Str;
R := QtDC.getClipRegion.getBoundingRect;
QtDC.font.Metrics.boundingRect(@R1, @R, 0, @WideStr);
QtDC.font.Metrics.boundingRect(@R1, @R, 0, @WStr);
B := True;
Rect := @R1;
end;
@ -2278,7 +2274,7 @@ begin
QPaintEngine_testDirty(QtDC.PaintEngine, QPaintEngineDirtyBrushOrigin) then
begin
R := Rect^;
QtDC.font.Metrics.boundingRect(@R1, @R, QtTextSingleLine, @WideStr);
QtDC.font.Metrics.boundingRect(@R1, @R, QtTextSingleLine, @WStr);
if Options and ETO_CLIPPED = 0 then
Pt := Point(Rect^.Left - X, Rect^.Top - Y)
else
@ -2294,9 +2290,9 @@ begin
if Options and ETO_RTLREADING <> 0 then
QPainter_setLayoutDirection(QtDC.Widget, QtRightToLeft);
if Count >= 0 then
WideStr := GetUtf8String(Copy(Str, 1, Count))
WStr := {%H-}Copy(Str, 1, Count)
else
WideStr := GetUtf8String(Str);
WStr := Str;
if (Options and ETO_CLIPPED <> 0) then
begin
@ -2307,7 +2303,7 @@ begin
DoDrawCharByChar(True)
else
QtDC.drawText(X, Y, Rect^.Right - Rect^.Left, Rect^.Bottom - Rect^.Top,
QtTextDontClip, @WideStr);
QtTextDontClip, @WStr);
finally
QtDC.Restore;
end;
@ -2316,7 +2312,7 @@ begin
if Dx <> nil then
DoDrawCharByChar(False)
else
QtDC.drawText(X, Y, @WideStr);
QtDC.drawText(X, Y, @WStr);
end;
if Options and ETO_RTLREADING <> 0 then
QPainter_setLayoutDirection(QtDC.Widget, ALayout);
@ -3249,7 +3245,7 @@ begin
else
ALogFont^.lfQuality := DEFAULT_QUALITY;
end;
ALogFont^.lfFaceName := UTF16ToUTF8(AFont.getFamily);
ALogFont^.lfFaceName := AFont.getFamily;
end;
end
{------------------------------------------------------------------------------
@ -3592,7 +3588,7 @@ end;
------------------------------------------------------------------------------}
function TQtWidgetSet.GetScrollInfo(Handle: HWND; BarFlag: Integer;
var ScrollInfo: TScrollInfo): Boolean;
Var ScrollInfo: TScrollInfo): Boolean;
var
QtScrollBar: TQtScrollBar;
begin
@ -4260,7 +4256,7 @@ function TQtWidgetSet.GetTextExtentExPoint(DC: HDC; Str: PChar; Count,
var
i: Integer;
w: Integer;
AStr: WideString;
AStr: UnicodeString;
Accu: Integer;
begin
Result := False;
@ -4270,7 +4266,7 @@ begin
if Str = nil then
AStr := ''
else
AStr := GetUtf8String(Str);
AStr := Str;
Size.cx := 0;
Size.cY := Font.Metrics.Height;
if (AStr = '') then
@ -4337,7 +4333,7 @@ end;
------------------------------------------------------------------------------}
function TQtWidgetSet.GetTextExtentPoint(DC: HDC; Str: PChar; Count: Integer; var Size: TSize): Boolean;
var
WideStr: WideString;
WStr: UnicodeString;
QtDC: TQtDeviceContext absolute DC;
begin
{$ifdef VerboseQtWinAPI}
@ -4353,8 +4349,8 @@ begin
Size.cy := 0;
if (Count <= 0) or (Str = nil) or (StrPas(Str) = '') then
exit;
WideStr := GetUtf8String(Str);
Size.cx := QtDC.Metrics.width(@WideStr, Count);
WStr := Str;
Size.cx := QtDC.Metrics.width(@WStr, Count);
Size.cy := QtDC.Metrics.height;
Result := True;
@ -4369,7 +4365,7 @@ end;
function TQtWidgetSet.GetTextMetrics(DC: HDC; var TM: TTextMetric): Boolean;
var
QtFontMetrics: TQtFontMetrics;
FontFamily: WideString;
FontFamily: UnicodeString;
QtDC: TQtDeviceContext absolute DC;
FontWeight: Integer;
begin
@ -4851,7 +4847,7 @@ var
Font: TFont absolute AFont;
AMenu: QMenuH;
QtFont: QFontH;
AName: WideString;
AName: UnicodeString;
begin
Result := False;
if AStockFont = sfMenu then
@ -4861,7 +4857,7 @@ begin
try
QtFont := QWidget_font(AMenu);
QFont_family(QtFont, @AName);
Font.Name := UTF16ToUTF8(AName);
Font.Name := AName{%H-};
if QFont_pointSize(QtFont) > 0 then
Font.Size := QFont_pointSize(QtFont)
else
@ -4888,7 +4884,7 @@ begin
else
QApplication_font(QtFont);
QFont_family(QtFont, @AName);
Font.Name := UTF16ToUTF8(AName);
Font.Name := AName{%H-};
if QFont_pointSize(QtFont) > 0 then
Font.Size := QFont_pointSize(QtFont)
else
@ -5237,15 +5233,15 @@ const
end;
end;
var
Str: WideString;
TitleStr: WideString;
//OkStr: WideString;
Str: UnicodeString;
TitleStr: UnicodeString;
//OkStr: UnicodeString;
AParent: QWidgetH;
DialogType, DefButton, DefIcon : Cardinal;
begin
Result := 0;
Str := GetUtf8String(lpText);
TitleStr := GetUtf8String(lpCaption);
Str := lpText;
TitleStr := lpCaption;
//TODO: TRANSLATIONS for buttons text, use TQtMessageBox
if HWND <> 0 then
AParent := TQtWidget(Hwnd).Widget
@ -7018,7 +7014,7 @@ end;
function TQtWidgetSet.TextOut(DC: HDC; X, Y: Integer; Str: Pchar; Count: Integer
): Boolean;
var
WideStr: WideString;
WStr: UnicodeString;
begin
{$ifdef VerboseQtWinAPI}
WriteLn('[WinAPI TextOut]');
@ -7029,11 +7025,11 @@ begin
if not IsValidDC(DC) then Exit;
if Count >= 0 then
WideStr := GetUtf8String(Copy(Str, 1, Count))
WStr := {%H-}Copy(Str, 1, Count)
else
WideStr := GetUtf8String(Str);
WStr := Str;
TQtDeviceContext(DC).drawText(X, Y, @WideStr);
TQtDeviceContext(DC).drawText(X, Y, @WStr);
Result := True;
end;

View File

@ -555,7 +555,7 @@ end;
class procedure TQtWSStatusBar.RecreatePanels(const AStatusBar: TStatusBar;
const Widget: TQtStatusBar);
var
Str: WideString;
Str: UnicodeString;
i: Integer;
begin
// issues #18683 and #28307
@ -563,7 +563,7 @@ begin
ClearPanels(Widget);
if AStatusBar.SimplePanel then
begin
Str := GetUtf8String(AStatusBar.SimpleText);
Str := AStatusBar{%H-}.SimpleText;
Widget.showMessage(@Str);
end else
if AStatusBar.Panels.Count > 0 then
@ -572,7 +572,7 @@ begin
SetLength(Widget.Panels, AStatusBar.Panels.Count);
for i := 0 to AStatusBar.Panels.Count - 1 do
begin
Str := GetUtf8String(AStatusBar.Panels[i].Text);
Str := AStatusBar{%H-}.Panels[i].Text;
Widget.Panels[i] := TQtStatusBarPanel.CreateFrom(AStatusBar,
QLabel_create(@Str, Widget.Widget));
Widget.Panels[i].HasPaint := AStatusBar.Panels[i].Style = psOwnerDraw;
@ -619,13 +619,13 @@ end;
class procedure TQtWSStatusBar.PanelUpdate(const AStatusBar: TStatusBar; PanelIndex: integer);
var
QtStatusBar: TQtStatusBar;
Str: Widestring;
Str: Unicodestring;
begin
QtStatusBar := TQtStatusBar(AStatusBar.Handle);
if AStatusBar.SimplePanel then
begin
ClearPanels(QtStatusBar);
Str := GetUtf8String(AStatusBar.SimpleText);
Str := AStatusBar{%H-}.SimpleText;
QtStatusBar.showMessage(@Str);
end else
if AStatusBar.Panels.Count > 0 then
@ -635,7 +635,7 @@ begin
if (PanelIndex >= Low(QtStatusBar.Panels)) and
(PanelIndex <= High(QtStatusBar.Panels)) then
begin
Str := GetUtf8String(AStatusBar.Panels[PanelIndex].Text);
Str := AStatusBar{%H-}.Panels[PanelIndex].Text;
QLabel_setText(QLabelH(QtStatusBar.Panels[PanelIndex].Widget), @Str);
QLabel_setAlignment(QLabelH(QtStatusBar.Panels[PanelIndex].Widget),
AlignmentToQtAlignmentMap[AStatusBar.Panels[PanelIndex].Alignment]);
@ -650,19 +650,19 @@ end;
class procedure TQtWSStatusBar.SetPanelText(const AStatusBar: TStatusBar; PanelIndex: integer);
var
QtStatusBar: TQtStatusBar;
Str: Widestring;
Str: Unicodestring;
begin
QtStatusBar := TQtStatusBar(AStatusBar.Handle);
if AStatusBar.SimplePanel then
begin
Str := GetUtf8String(AStatusBar.SimpleText);
Str := AStatusBar{%H-}.SimpleText;
QtStatusBar.showMessage(@Str);
end else
begin
if (PanelIndex >= Low(QtStatusBar.Panels)) and
(PanelIndex <= High(QtStatusBar.Panels)) then
begin
Str := GetUtf8String(AStatusBar.Panels[PanelIndex].Text);
Str := AStatusBar{%H-}.Panels[PanelIndex].Text;
QLabel_setText(QLabelH(QtStatusBar.Panels[PanelIndex].Widget), @Str);
end;
end;
@ -783,7 +783,7 @@ var
QtTreeWidget: TQtTreeWidget;
TWI: QTreeWidgetItemH;
TWIChild: QTreeWidgetItemH;
Str: WideString;
Str: UnicodeString;
begin
if not WSCheckHandleAllocated(ALV, 'ColumnInsert') then
Exit;
@ -795,7 +795,7 @@ begin
QtTreeWidget := TQtTreeWidget(ALV.Handle);
if QtTreeWidget.ColCount <> TCustomListViewHack(ALV).Columns.Count then
QtTreeWidget.ColCount := TCustomListViewHack(ALV).Columns.Count;
QtTreeWidget.ColCount := TCustomListViewHack(ALV).Columns.Count;
if (QtTreeWidget.ColCount <= 1) and TCustomListViewHack(ALV).ShowColumnHeaders then
QtTreeWidget.setHeaderVisible(True);
@ -807,14 +807,14 @@ begin
TWIChild := QTreeWidgetItem_create(QTreeWidgetItemType);
QTreeWidgetItem_setFlags(TWIChild, QtItemIsEnabled);
QTreeWidgetItem_addChild(TWI, TWIChild);
Str := GetUtf8String(ALV.Column[AIndex].Caption);
Str := ALV{%H-}.Column[AIndex].Caption;
QTreeWidgetItem_setText(TWI, AIndex, @Str);
end;
if (csDesigning in ALV.ComponentState) then
exit;
QtTreeWidget.Header.Clickable := TCustomListViewHack(ALV).ColumnClick;
QtTreeWidget.Header.Clickable := TCustomListViewHack(ALV).ColumnClick;
end;
{------------------------------------------------------------------------------
@ -932,7 +932,7 @@ end;
class procedure TQtWSCustomListView.ColumnSetCaption(const ALV: TCustomListView;
const AIndex: Integer; const AColumn: TListColumn; const ACaption: String);
var
Str: WideString;
Str: UnicodeString;
QtTreeWidget: TQtTreeWidget;
TWI: QTreeWidgetItemH;
begin
@ -947,7 +947,7 @@ begin
TWI := QtTreeWidget.headerItem;
if TWI <> NiL then
begin
Str := GetUtf8String(ACaption);
Str := {%H-}ACaption;
QTreeWidgetItem_setText(TWI, AIndex, @Str);
end;
end;
@ -1420,12 +1420,9 @@ var
QtListWidget: TQtListWidget;
QtTreeWidget: TQtTreeWidget;
TWI: QTreeWidgetItemH;
Str: WideString;
Str: UnicodeString;
i: Integer;
AAlignment: QtAlignment;
//AImages: TCustomImageList;
//AMetric: Integer;
//ASizeHint: TSize;
//AIconWidth: Integer;
begin
if not WSCheckHandleAllocated(ALV, 'ItemInsert') then
@ -1440,10 +1437,7 @@ begin
begin
QtTreeWidget := TQtTreeWidget(ALV.Handle);
TWI := QTreeWidgetItem_create(QTreeWidgetItemType);
if AItem.Caption <> '' then
Str := GetUtf8String(AItem.Caption)
else
Str := '';
Str := AItem{%H-}.Caption;
if ALV.CheckBoxes then
begin
@ -1474,7 +1468,7 @@ begin
AAlignment := AlignmentToQtAlignmentMap[ALV.Column[i + 1].Alignment] or QtAlignVCenter;
if AItem.Subitems.Strings[i] <> '' then
begin
Str := GetUtf8String(AItem.Subitems.Strings[i]);
Str := AItem{%H-}.Subitems.Strings[i];
QtTreeWidget.setItemText(TWI, i + 1, Str, AAlignment);
QtTreeWidget.setItemData(TWI, i + 1, AItem);
end;
@ -1496,7 +1490,7 @@ var
QtListWidget: TQtListWidget;
QtTreeWidget: TQtTreeWidget;
TWI: QTreeWidgetItemH;
Str: WideString;
Str: UnicodeString;
AAlignment: QtAlignment;
begin
if not WSCheckHandleAllocated(ALV, 'ItemSetText') then
@ -1516,7 +1510,7 @@ begin
end else
begin
QtTreeWidget := TQtTreeWidget(ALV.Handle);
Str := GetUtf8String(AText);
Str := {%H-}AText;
TWI := QtTreeWidget.topLevelItem(AIndex);
if TWI <> NiL then
begin
@ -1875,10 +1869,9 @@ class procedure TQtWSCustomListView.InternalUpdateItems(
const AList: TCustomListView);
var
QtTreeWidget: TQtTreeWidget;
i: Integer;
j: Integer;
i, j: Integer;
AItem: TListItem;
WStr: WideString;
Str: UnicodeString;
Item: QTreeWidgetItemH;
AAlignment: QtAlignment;
ImgList: TImageList;
@ -1900,9 +1893,9 @@ begin
for i := 0 to AList.Items.Count - 1 do
begin
AItem := AList.Items[i];
WStr := GetUTF8String(AItem.Caption);
Str := AItem{%H-}.Caption;
Item := QtTreeWidget.topLevelItem(i);
QtTreeWidget.setItemText(Item, 0, WStr, AlignmentToQtAlignmentMap[AList.Column[0].Alignment]);
QtTreeWidget.setItemText(Item, 0, Str, AlignmentToQtAlignmentMap[AList.Column[0].Alignment]);
QtTreeWidget.setItemData(Item, 0, AItem);
if AList.Checkboxes then
begin
@ -1931,8 +1924,8 @@ begin
AAlignment := QtAlignLeft;
if (TCustomListViewHack(AList).Columns.Count > 0) and (j + 1 < TCustomListViewHack(AList).Columns.Count) then
AAlignment := AlignmentToQtAlignmentMap[TCustomListViewHack(AList).Column[j + 1].Alignment];
WStr := GetUtf8String(AItem.Subitems.Strings[j]);
QtTreeWidget.setItemText(Item, j + 1, WStr, AAlignment);
Str := AItem{%H-}.Subitems.Strings[j];
QtTreeWidget.setItemText(Item, j + 1, Str, AAlignment);
QtTreeWidget.setItemData(Item, j + 1, AItem);
end;
end;

View File

@ -298,7 +298,7 @@ begin
Result := not TQtWidget(AWinControl.Handle).getTextStatic;
if Result then
AText := UTF16ToUTF8(TQtWidget(AWinControl.Handle).getText);
AText := TQtWidget(AWinControl.Handle){%H-}.getText;
end;
class procedure TQtWSWinControl.SetText(const AWinControl: TWinControl;
@ -307,12 +307,12 @@ begin
if not WSCheckHandleAllocated(AWincontrol, 'SetText') then
Exit;
TQtWidget(AWinControl.Handle).BeginUpdate;
TQtWidget(AWinControl.Handle).setText(GetUtf8String(AText));
TQtWidget(AWinControl.Handle).setText(AText{%H-});
TQtWidget(AWinControl.Handle).EndUpdate;
end;
class procedure TQtWSWinControl.SetChildZPosition(const AWinControl,
AChild: TWinControl; const AOldPos, ANewPos: Integer; const AChildren: TFPList);
AChild: TWinControl; const AOldPos, ANewPos: Integer; const AChildren: TFPList);
var
n: Integer;
Child: TWinControl;

View File

@ -51,7 +51,7 @@ type
private
protected
class function GetQtFilterString(const AFileDialog: TFileDialog;
var ASelectedFilter: WideString): WideString;
var ASelectedFilter: UnicodeString): UnicodeString;
class procedure UpdateProperties(const AFileDialog: TFileDialog; QtFileDialog: TQtFileDialog);
published
class function CreateHandle(const ACommonDialog: TCommonDialog): THandle; override;
@ -190,7 +190,7 @@ end;
{ TQtWSFileDialog }
class function TQtWSFileDialog.GetQtFilterString(const AFileDialog: TFileDialog;
var ASelectedFilter: WideString): WideString;
var ASelectedFilter: UnicodeString): UnicodeString;
function GetExtensionString(ASource: String; AStart, ALength: Integer): String; inline;
begin
@ -292,10 +292,10 @@ begin
// Remember that AFileDialog.FilterIndex is a 1-based index and that
// List has a zero-based index
if (AFileDialog.FilterIndex > 0) and (List.Count >= AFileDialog.FilterIndex) then
ASelectedFilter := GetUTF8String(List.Strings[AFileDialog.FilterIndex - 1])
ASelectedFilter := List{%H-}.Strings[AFileDialog.FilterIndex - 1]
else
if (List.Count > 0) then
ASelectedFilter := GetUTF8String(List.Strings[0]);
ASelectedFilter := List{%H-}.Strings[0];
finally
List.Free;
@ -304,44 +304,44 @@ begin
if (AFileDialog is TSaveDialog) and (trim(TmpFilter)='()') then
Result := ''
else
Result := GetUtf8String(TmpFilter);
Result := {%H-}TmpFilter;
end;
class procedure TQtWSFileDialog.UpdateProperties(
const AFileDialog: TFileDialog; QtFileDialog: TQtFileDialog);
var
ATitle: WideString;
ATitle: UnicodeString;
{$ifndef QT_NATIVE_DIALOGS}
AInitDir: WideString;
AInitDir: UnicodeString;
{$ENDIF}
s: String;
S: String;
begin
ATitle := GetUtf8String(AFileDialog.Title);
ATitle := AFileDialog{%H-}.Title;
QtFileDialog.setWindowTitle(@ATitle);
{$ifndef QT_NATIVE_DIALOGS}
s := AFileDialog.InitialDir;
S := AFileDialog.InitialDir;
if UTF8Pos('$HOME', S) > 0 then
begin
{$IFDEF MSWINDOWS}
AInitDir := GetEnvironmentVariableUTF8('HOMEDRIVE') +
GetEnvironmentVariableUTF8('HOMEPATH');
AInitDir := {%H-}GetEnvironmentVariableUTF8('HOMEDRIVE') +
{%H-}GetEnvironmentVariableUTF8('HOMEPATH');
{$ELSE}
AInitDir := GetEnvironmentVariableUTF8('HOME');
AInitDir := {%H-}GetEnvironmentVariableUTF8('HOME');
{$ENDIF}
s := StringReplace(S,'$HOME', UTF8Encode(AInitDir),[rfReplaceAll]);
S := StringReplace(S,'$HOME', UTF8Encode(AInitDir),[rfReplaceAll]);
end else
if (S = '') then
S := GetCurrentDirUTF8;
if not DirectoryExistsUTF8(S) then
S := GetCurrentDirUTF8;
QtFileDialog.setDirectory(S);
QtFileDialog.setDirectory(S{%H-});
{$else}
s := AFileDialog.InitialDir;
S := AFileDialog.InitialDir;
if S = '' then
S := GetCurrentDirUTF8;
if DirectoryExistsUTF8(S) then
QtFileDialog.setDirectory(S);
QtFileDialog.setDirectory(S{%H-});
{$endif}
QtFileDialog.setHistory(AFileDialog.HistoryList);
@ -367,7 +367,7 @@ begin
if (AFileDialog.FileName <> '') and
not DirectoryExistsUTF8(AFileDialog.FileName) then
begin
ATitle := GetUTF8String(AFileDialog.FileName);
ATitle := AFileDialog{%H-}.FileName;
if (AFileDialog is TSaveDialog) or FileExistsUTF8(AFileDialog.FileName) then
QFileDialog_selectFile(QFileDialogH(QtFileDialog.Widget), @ATitle);
{$ifndef QT_NATIVE_DIALOGS}
@ -406,16 +406,15 @@ end;
------------------------------------------------------------------------------}
class procedure TQtWSFileDialog.ShowModal(const ACommonDialog: TCommonDialog);
var
ReturnText: WideString;
ReturnText: UnicodeString;
s: string;
FileDialog: TFileDialog;
ReturnList: QStringListH;
i: integer;
QtFileDialog: TQtFileDialog;
{$if defined(QT_NATIVE_DIALOGS) or defined(MSWINDOWS)}
s: string;
{$endif}
{$ifdef QT_NATIVE_DIALOGS}
selectedFilter, saveFileName, saveFilter, saveTitle, sDir: WideString;
selectedFilter, saveFileName, saveFilter, saveTitle: UnicodeString;
sDir: String;
Flags: Cardinal;
{$endif}
ActiveWin: HWND;
@ -436,13 +435,13 @@ begin
begin
sDir := FileDialog.InitialDir;
{$IFDEF MSWINDOWS}
saveFileName := GetEnvironmentVariableUTF8('HOMEDRIVE') +
GetEnvironmentVariableUTF8('HOMEPATH');
saveFileName := {%H-}GetEnvironmentVariableUTF8('HOMEDRIVE') +
{%H-}GetEnvironmentVariableUTF8('HOMEPATH');
{$ELSE}
saveFileName := GetEnvironmentVariableUTF8('HOME');
saveFileName := {%H-}GetEnvironmentVariableUTF8('HOME');
{$ENDIF}
sDir := StringReplace(sDir,'$HOME', UTF8Encode(saveFileName),[rfReplaceAll]);
saveFileName := GetUTF8String(SDir) + PathDelim + ExtractFileName(FileDialog.Filename);
saveFileName := sDir + PathDelim {%H-}+ ExtractFileName(FileDialog.Filename);
end;
{$endif}
@ -470,10 +469,10 @@ begin
SDir := SDir + PathDelim;
if (FileDialog.FileName <> '') and
(ExtractFileName(FileDialog.FileName) <> FileDialog.FileName) then
saveFileName := GetUtf8String(FileDialog.Filename)
saveFileName := FileDialog{%H-}.Filename
else
saveFileName := GetUtf8String(SDir+FileDialog.Filename);
saveTitle := GetUTF8String(FileDialog.Title);
saveFileName := SDir{%H-}+FileDialog.Filename;
saveTitle := FileDialog{%H-}.Title;
Flags := 0;
if not (ofOverwritePrompt in TSaveDialog(FileDialog).Options) then
@ -494,11 +493,11 @@ begin
if ReturnText <> '' then
begin
{$ifdef MSWINDOWS}
s := UTF16ToUTF8(ReturnText);
s := ReturnText;
s := StringReplace(s, '/','\', [rfReplaceAll]);
FileDialog.FileName := s;
{$else}
FileDialog.FileName := UTF16ToUTF8(ReturnText);
FileDialog.FileName := ReturnText{%H-};
{$endif}
FileDialog.UserChoice := mrOK;
end else
@ -517,19 +516,15 @@ begin
for i := 0 to QStringList_size(ReturnList) - 1 do
begin
QStringList_at(ReturnList, @ReturnText, i);
s := {%H-}ReturnText;
{$ifdef MSWINDOWS}
s := UTF16ToUTF8(ReturnText);
s := StringReplace(s, '/','\', [rfReplaceAll]);
{$endif}
FileDialog.Files.Add(s);
if i = 0 then
FileDialog.FileName := s;
{$else}
FileDialog.Files.Add(UTF16ToUTF8(ReturnText));
if i = 0 then
FileDialog.FileName := UTF16ToUTF8(ReturnText);
{$endif}
end;
ReturnText := FileDialog.Files.Text;
ReturnText := FileDialog{%H-}.Files.Text;
finally
QStringList_destroy(ReturnList);
end;
@ -544,10 +539,10 @@ begin
SDir := SDir + PathDelim;
if (FileDialog.FileName <> '') and
(ExtractFileName(FileDialog.FileName) <> FileDialog.FileName) then
saveFileName := GetUtf8String(FileDialog.Filename)
saveFileName := FileDialog{%H-}.Filename
else
saveFileName := GetUtf8String(SDir+FileDialog.Filename);
saveTitle := GetUTF8String(FileDialog.Title);
saveFileName := SDir{%H-}+FileDialog.Filename;
saveTitle := FileDialog{%H-}.Title;
Flags := 0;
if (ofReadOnly in TOpenDialog(FileDialog).Options) then
@ -569,15 +564,15 @@ begin
begin
QStringList_at(ReturnList, @ReturnText, i);
{$ifdef MSWINDOWS}
s := UTF16ToUTF8(ReturnText);
s := ReturnText;
s := StringReplace(s, '/','\', [rfReplaceAll]);
FileDialog.Files.Add(s);
if i = 0 then
FileDialog.FileName := s;
{$else}
FileDialog.Files.Add(UTF16ToUTF8(ReturnText));
FileDialog.Files.Add(ReturnText{%H-});
if i = 0 then
FileDialog.FileName := UTF16ToUTF8(ReturnText);
FileDialog.FileName := ReturnText{%H-};
{$endif}
end;
{assign to ReturnText first filename}
@ -608,13 +603,11 @@ begin
if ReturnText <> '' then
begin
s := {%H-}ReturnText;
{$ifdef MSWINDOWS}
s := UTF16ToUTF8(ReturnText);
s := StringReplace(s, '/','\', [rfReplaceAll]);
FileDialog.FileName := s;
{$else}
FileDialog.FileName := UTF16ToUTF8(ReturnText);
{$endif}
FileDialog.FileName := s;
FileDialog.UserChoice := mrOK;
end else
FileDialog.UserChoice := mrCancel;
@ -628,18 +621,18 @@ begin
begin
QStringList_at(ReturnList, @ReturnText, i);
{$ifdef MSWINDOWS}
s := UTF16ToUTF8(ReturnText);
s := ReturnText;
s := StringReplace(s, '/','\', [rfReplaceAll]);
FileDialog.Files.Add(s);
if i = 0 then
FileDialog.FileName := s;
{$else}
FileDialog.Files.Add(UTF16ToUTF8(ReturnText));
FileDialog.Files.Add(ReturnText{%H-});
if i = 0 then
FileDialog.FileName := UTF16ToUTF8(ReturnText);
FileDialog.FileName := ReturnText{%H-};
{$endif}
end;
ReturnText := FileDialog.Files.Text;
ReturnText := FileDialog{%H-}.Files.Text;
finally
QStringList_destroy(ReturnList);
end;
@ -654,8 +647,7 @@ end;
{ TQtWSOpenDialog }
class function TQtWSOpenDialog.CreateHandle(const ACommonDialog: TCommonDialog
): THandle;
class function TQtWSOpenDialog.CreateHandle(const ACommonDialog: TCommonDialog): THandle;
var
FileDialog: TQtFilePreviewDialog;
begin
@ -689,32 +681,34 @@ end;
class procedure TQtWSSelectDirectoryDialog.UpdateProperties(
const AFileDialog: TSelectDirectoryDialog; QtFileDialog: TQtFileDialog);
var
ATitle: WideString;
AInitDir: WideString;
s: String;
ATitle: UnicodeString;
{$ifndef QT_NATIVE_DIALOGS}
AInitDir: UnicodeString;
{$endif}
S: String;
begin
ATitle := GetUtf8String(AFileDialog.Title);
ATitle := AFileDialog{%H-}.Title;
QtFileDialog.setWindowTitle(@ATitle);
{$ifndef QT_NATIVE_DIALOGS}
s := AFileDialog.InitialDir;
S := AFileDialog.InitialDir;
if UTF8Pos('$HOME', AFileDialog.InitialDir) > 0 then
begin
{$IFDEF MSWINDOWS}
AInitDir := GetEnvironmentVariableUTF8('HOMEDRIVE') +
GetEnvironmentVariableUTF8('HOMEPATH');
AInitDir := {%H-}GetEnvironmentVariableUTF8('HOMEDRIVE') +
{%H-}GetEnvironmentVariableUTF8('HOMEPATH');
{$ELSE}
AInitDir := GetEnvironmentVariableUTF8('HOME');
AInitDir := {%H-}GetEnvironmentVariableUTF8('HOME');
{$ENDIF}
s := StringReplace(S,'$HOME', UTF8Encode(AInitDir),[rfReplaceAll]);
S := StringReplace(S,'$HOME', UTF8Encode(AInitDir),[rfReplaceAll]);
end;
if not DirectoryExistsUTF8(S) then
S := GetCurrentDirUTF8;
QtFileDialog.setDirectory(GetUTF8String(s));
QtFileDialog.setDirectory(S{%H-});
{$else}
S := AFileDialog.InitialDir;
if not DirectoryExistsUTF8(S) then
S := GetCurrentDirUTF8;
QtFileDialog.setDirectory(S);
QtFileDialog.setDirectory(S{%H-});
{$endif}
QtFileDialog.setSizeGripEnabled(ofEnableSizing in TSelectDirectoryDialog(AFileDialog).Options);
@ -757,10 +751,10 @@ end;
------------------------------------------------------------------------------}
class procedure TQtWSSelectDirectoryDialog.ShowModal(const ACommonDialog: TCommonDialog);
var
ReturnText: WideString;
ReturnText: UnicodeString;
{$ifdef QT_NATIVE_DIALOGS}
saveFileName: WideString;
saveTitle: WideString;
saveFileName: UnicodeString;
saveTitle: UnicodeString;
{$endif}
FileDialog: TSelectDirectoryDialog;
QtFileDialog: TQtFileDialog;
@ -784,32 +778,32 @@ begin
Code to call the dialog
------------------------------------------------------------------------------}
{$ifdef QT_NATIVE_DIALOGS}
saveTitle := GetUTF8String(FileDialog.Title);
// saveFileName := GetUtf8String(FileDialog.InitialDir);
saveTitle := FileDialog{%H-}.Title;
// saveFileName := FileDialog.InitialDir;
if UTF8Pos('$HOME', FileDialog.InitialDir) > 0 then
begin
s := FileDialog.InitialDir;
{$IFDEF MSWINDOWS}
saveFileName := GetEnvironmentVariableUTF8('HOMEDRIVE') +
GetEnvironmentVariableUTF8('HOMEPATH');
saveFileName := {%H-}GetEnvironmentVariableUTF8('HOMEDRIVE') +
{%H-}GetEnvironmentVariableUTF8('HOMEPATH');
{$ELSE}
saveFileName := GetEnvironmentVariableUTF8('HOME');
saveFileName := {%H-}GetEnvironmentVariableUTF8('HOME');
{$ENDIF}
s := StringReplace(S,'$HOME', UTF8Encode(saveFileName),[rfReplaceAll]);
saveFileName := GetUTF8String(s);
saveFileName := {%H-}s;
end else
saveFileName := GetUtf8String(FileDialog.InitialDir);
saveFileName := FileDialog{%H-}.InitialDir;
QFileDialog_getExistingDirectory(@ReturnText,
QWidget_parentWidget(QtFileDialog.Widget), @SaveTitle, @saveFileName);
if ReturnText <> '' then
begin
{$ifdef MSWINDOWS}
s := UTF16ToUTF8(ReturnText);
s := ReturnText;
s := StringReplace(s, '/','\', [rfReplaceAll]);
FileDialog.FileName := s;
{$else}
FileDialog.FileName := UTF16ToUTF8(ReturnText);
FileDialog.FileName := ReturnText{%H-};
{$endif}
FileDialog.UserChoice := mrOK;
end else
@ -824,18 +818,18 @@ begin
begin
QStringList_at(ReturnList, @ReturnText, i);
{$ifdef MSWINDOWS}
s := UTF16ToUTF8(ReturnText);
s := ReturnText;
s := StringReplace(s, '/','\', [rfReplaceAll]);
FileDialog.Files.Add(s);
if i = 0 then
FileDialog.FileName := s;
{$else}
FileDialog.Files.Add(UTF16ToUTF8(ReturnText));
FileDialog.Files.Add(ReturnText{%H-});
if i = 0 then
FileDialog.FileName := UTF16ToUTF8(ReturnText);
FileDialog.FileName := ReturnText{%H-};
{$endif}
end;
ReturnText := FileDialog.Files.Text;
ReturnText := FileDialog{%H-}.Files.Text;
finally
QStringList_destroy(ReturnList);
end;
@ -947,7 +941,7 @@ class procedure TQtWSFontDialog.ShowModal(const ACommonDialog: TCommonDialog);
var
ReturnFont, CurrentFont: QFontH;
ReturnBool: Boolean;
Str: WideString;
Str: UnicodeString;
{$IFDEF HASX11}
AWND: HWND;
{$ENDIF}
@ -963,7 +957,7 @@ begin
TQtWSCommonDialog.GetDialogParent(ACommonDialog));
QFont_family(ReturnFont, @Str);
TFontDialog(ACommonDialog).Font.Name := UTF16ToUTF8(Str);
TFontDialog(ACommonDialog).Font.Name := Str{%H-};
if QFont_pixelSize(ReturnFont) = -1 then
TFontDialog(ACommonDialog).Font.Size := QFont_pointSize(ReturnFont)

View File

@ -205,12 +205,12 @@ class function TQtWSCustomRadioGroup.CreateHandle(const AWinControl: TWinControl
const AParams: TCreateParams): TLCLIntfHandle;
var
QtGroupBox: TQtGroupBox;
Str: WideString;
Str: UnicodeString;
begin
QtGroupBox := TQtGroupBox.Create(AWinControl, AParams);
QtGroupBox.GroupBoxType := tgbtRadioGroup;
Str := GetUtf8String(AWinControl.Caption);
Str := AWinControl{%H-}.Caption;
QGroupBox_setTitle(QGroupBoxH(QtGroupBox.Widget), @Str);
QtGroupBox.AttachEvents;
@ -231,12 +231,12 @@ class function TQtWSCustomCheckGroup.CreateHandle(const AWinControl: TWinControl
const AParams: TCreateParams): TLCLIntfHandle;
var
QtGroupBox: TQtGroupBox;
Str: WideString;
Str: UnicodeString;
begin
QtGroupBox := TQtGroupBox.Create(AWinControl, AParams);
QtGroupBox.GroupBoxType := tgbtCheckGroup;
Str := GetUtf8String(AWinControl.Caption);
Str := AWinControl{%H-}.Caption;
QGroupBox_setTitle(QGroupBoxH(QtGroupBox.Widget), @Str);
QtGroupBox.AttachEvents;
@ -265,7 +265,7 @@ end;
class function TQtWSCustomTrayIcon.Show(const ATrayIcon: TCustomTrayIcon): Boolean;
var
Text: WideString;
Text: UnicodeString;
SystemTrayIcon: TQtSystemTrayIcon;
IconH: QIconH;
begin
@ -281,7 +281,7 @@ begin
ATrayIcon.Handle := HWND(SystemTrayIcon);
Text := UTF8ToUTF16(ATrayIcon.Hint);
Text := ATrayIcon{%H-}.Hint;
SystemTrayIcon.setToolTip(Text);
if Assigned(ATrayIcon.PopUpMenu) then
@ -303,7 +303,7 @@ class procedure TQtWSCustomTrayIcon.InternalUpdate(const ATrayIcon: TCustomTrayI
var
SystemTrayIcon: TQtSystemTrayIcon;
AIcon: QIconH;
AHint: WideString;
AHint: UnicodeString;
begin
if (ATrayIcon.Handle = 0) then Exit;
@ -330,13 +330,12 @@ begin
QIcon_destroy(AIcon);
end;
{ PopUpMenu }
if Assigned(ATrayIcon.PopUpMenu) then
if TQtMenu(ATrayIcon.PopUpMenu.Handle).Widget <> nil then
SystemTrayIcon.setContextMenu(QMenuH(TQtMenu(ATrayIcon.PopUpMenu.Handle).Widget));
AHint := UTF8ToUTF16(ATrayIcon.Hint);
AHint := ATrayIcon{%H-}.Hint;
SystemTrayIcon.setToolTip(AHint);
SystemTrayIcon.UpdateSystemTrayWidget;

View File

@ -184,7 +184,7 @@ class function TQtWSCustomForm.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): TLCLIntfHandle;
var
QtMainWindow: TQtMainWindow;
Str: WideString;
Str: UnicodeString;
APopupParent: TCustomForm;
AForm: TCustomForm;
begin
@ -208,8 +208,7 @@ begin
QtMainWindow.QtFormBorderStyle := Ord(AForm.BorderStyle);
QtMainWindow.QtFormStyle := Ord(AForm.FormStyle);
Str := GetUtf8String(AWinControl.Caption);
Str := AWinControl{%H-}.Caption;
QtMainWindow.SetWindowTitle(@Str);
if not (csDesigning in AForm.ComponentState) then

View File

@ -109,7 +109,7 @@ begin
Result.setHasSubmenu(AMenuItem.Count > 0);
if not AMenuItem.IsLine then
begin
Result.setText(GetUtf8String(AMenuItem.Caption));
Result.setText(AMenuItem.Caption{%H-});
Result.setEnabled(AMenuItem.Enabled);
Result.setCheckable(AMenuItem.RadioItem or AMenuItem.ShowAlwaysCheckable);
Result.BeginUpdate;
@ -256,7 +256,7 @@ begin
if ACaption = cLineCaption then
TQtMenu(Widget).setText('')
else
TQtMenu(Widget).setText(GetUtf8String(ACaption));
TQtMenu(Widget).setText(ACaption{%H-});
end;
end;

View File

@ -767,11 +767,11 @@ end;
------------------------------------------------------------------------------}
class procedure TQtWSCustomMemo.AppendText(const ACustomMemo: TCustomMemo; const AText: string);
var
AStr: WideString;
AStr: UnicodeString;
begin
if not WSCheckHandleAllocated(ACustomMemo, 'AppendText') or (Length(AText) = 0) then
Exit;
AStr := GetUtf8String(AText);
AStr := {%H-}AText;
TQtTextEdit(ACustomMemo.Handle).BeginUpdate;
TQtTextEdit(ACustomMemo.Handle).Append(AStr);
TQtTextEdit(ACustomMemo.Handle).EndUpdate;
@ -1411,7 +1411,7 @@ begin
Text := TCustomComboBox(AWinControl).Text;
QtComboBox.FList.Assign(TCustomComboBox(AWinControl).Items);
QtComboBox.setCurrentIndex(ItemIndex);
QtComboBox.setText(GetUTF8String(Text));
QtComboBox.setText(Text{%H-});
QtComboBox.setEditable((AParams.Style and CBS_DROPDOWN <> 0) or
(AParams.Style and CBS_SIMPLE <> 0));
@ -1444,7 +1444,7 @@ class function TQtWSCustomComboBox.GetItemIndex(
const ACustomComboBox: TCustomComboBox): integer;
var
QtComboBox: TQtComboBox;
WStr, WStr2: WideString;
WStr, WStr2: UnicodeString;
i: Integer;
begin
Result := -1;
@ -1679,7 +1679,7 @@ class function TQtWSCustomComboBox.GetItemHeight(
const ACustomComboBox: TCustomComboBox): Integer;
var
ComboBox: TQtComboBox;
AText: WideString;
AText: UnicodeString;
ACombo: QComboBoxH;
AItems: QStringListH;
begin
@ -1701,7 +1701,7 @@ begin
QWidget_setFont(ACombo, ComboBox.getFont);
QComboBox_setEditable(ACombo, not ACustomComboBox.ReadOnly);
AText := 'Mtjx';
AItems := QStringList_create(PWideString(@AText));
AItems := QStringList_create(@AText);
QComboBox_addItems(ACombo, AItems);
QStringList_destroy(AItems);
Result := QAbstractItemView_sizeHintForRow(QComboBox_view(ACombo), 0);