diff --git a/lcl/interfaces/qt6/qtobject.inc b/lcl/interfaces/qt6/qtobject.inc index 1a7af357c7..0f0517be14 100644 --- a/lcl/interfaces/qt6/qtobject.inc +++ b/lcl/interfaces/qt6/qtobject.inc @@ -508,7 +508,7 @@ procedure TQtWidgetSet.AppSetTitle(const ATitle: string); var W: WideString; begin - W := GetUtf8String(ATitle); + W := {%H-}ATitle; QCoreApplication_setApplicationName(@W); end; diff --git a/lcl/interfaces/qt6/qtobjects.pas b/lcl/interfaces/qt6/qtobjects.pas index 5911add009..43f7349ddf 100644 --- a/lcl/interfaces/qt6/qtobjects.pas +++ b/lcl/interfaces/qt6/qtobjects.pas @@ -1724,7 +1724,7 @@ procedure TQtFont.setFamily(p1: string); var Str: WideString; begin - Str := GetUtf8String(p1); + Str := {%H-}p1; QFont_setFamily(FHandle, @Str); end; @@ -4985,7 +4985,7 @@ procedure TQtStringList.Insert(Index: Integer; const S: string); var W: WideString; begin - W := GetUtf8String(S); + W := {%H-}S; QStringList_insert(FHandle, Index, @W); end; diff --git a/lcl/interfaces/qt6/qtpagecontrol.inc b/lcl/interfaces/qt6/qtpagecontrol.inc index 21dcbb8614..87487148c2 100644 --- a/lcl/interfaces/qt6/qtpagecontrol.inc +++ b/lcl/interfaces/qt6/qtpagecontrol.inc @@ -298,8 +298,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); @@ -489,7 +488,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( diff --git a/lcl/interfaces/qt6/qtprivate.pp b/lcl/interfaces/qt6/qtprivate.pp index 42d06032b8..b1fbd3ba55 100644 --- a/lcl/interfaces/qt6/qtprivate.pp +++ b/lcl/interfaces/qt6/qtprivate.pp @@ -170,7 +170,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. @@ -276,7 +276,7 @@ begin {$endif} if FTextChanged then InternalUpdate; FStringList[Index] := S; - W := GetUTF8String(S); + W := {%H-}S; TQtTextEdit(FOwner.Handle).setLineText(Index, W); end; @@ -288,7 +288,7 @@ begin WriteLn('TQtMemoStrings.SetTextStr Value=',Value); {$endif} SetInternalText(Value); - W := GetInternalText; + W := {%H-}GetInternalText; ExternalUpdate(W, True, False); FTextChanged := False; end; @@ -432,9 +432,9 @@ begin begin Index := FStringList.Add(S); if FHasTrailingLineBreak then - W := GetUTF8String(S + LineBreak) + W := UTF8ToUTF16(S + LineBreak) else - W := GetUTF8String(S); + W := UTF8ToUTF16(S); if FHasTrailingLineBreak then begin //issue #39444 @@ -452,7 +452,7 @@ begin end else begin FStringList.Insert(Index, S); - W := GetUTF8String(S); + W := UTF8ToUTF16(S); TQtTextEdit(FOwner.Handle).insertLine(Index, W); end; FTextChanged := False; // FStringList is already updated, no need to update from WS. diff --git a/lcl/interfaces/qt6/qtproc.pp b/lcl/interfaces/qt6/qtproc.pp index 39dda4aafe..3660c4167e 100644 --- a/lcl/interfaces/qt6/qtproc.pp +++ b/lcl/interfaces/qt6/qtproc.pp @@ -46,7 +46,6 @@ type procedure FillStandardDescription(var Desc: TRawImageDescription); -function GetUtf8String(const S: String): WideString; implementation @@ -91,9 +90,4 @@ begin // Desc.MaskShift := 0; end; -function GetUtf8String(const S: String): WideString; -begin - Result := UTF8ToUTF16(S); -end; - end. diff --git a/lcl/interfaces/qt6/qtsystemtrayicon.pas b/lcl/interfaces/qt6/qtsystemtrayicon.pas index f96c24446a..ea2e6cb035 100644 --- a/lcl/interfaces/qt6/qtsystemtrayicon.pas +++ b/lcl/interfaces/qt6/qtsystemtrayicon.pas @@ -340,8 +340,8 @@ var WHint: WideString; WTitle: WideString; begin - WHint := GetUTF8String(AHint); - WTitle := GetUTF8String(ATitle); + WHint := {%H-}AHint; + WTitle := {%H-}ATitle; QSystemTrayIcon_showMessage(QSystemTrayIconH(TheObject), @WTitle, @WHint, AFlag, ATimeOut); end; diff --git a/lcl/interfaces/qt6/qtthemes.pas b/lcl/interfaces/qt6/qtthemes.pas index 8c57fa18f5..b870cf8f3d 100644 --- a/lcl/interfaces/qt6/qtthemes.pas +++ b/lcl/interfaces/qt6/qtthemes.pas @@ -617,7 +617,7 @@ begin case Details.Element of teToolTip: begin - W := GetUTF8String(S); + W := {%H-}S; Context.save; AOldMode := Context.SetBkMode(TRANSPARENT); try @@ -661,7 +661,7 @@ begin exit; end; - W := GetUTF8String(S); + W := {%H-}S; Context.save; try Context.SetBkMode(TRANSPARENT); @@ -712,7 +712,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 diff --git a/lcl/interfaces/qt6/qtwinapi.inc b/lcl/interfaces/qt6/qtwinapi.inc index 3df2c6f4de..a4864fb42e 100644 --- a/lcl/interfaces/qt6/qtwinapi.inc +++ b/lcl/interfaces/qt6/qtwinapi.inc @@ -1373,9 +1373,9 @@ begin QtDC :=TQtDeviceContext(DC); if Count >= 0 then - WideStr := GetUtf8String(Copy(Str, 1, Count)) + WideStr := {%H-}Copy(Str, 1, Count) else - WideStr := GetUtf8String(Str); + WideStr := Str; ClipRect := Rect(0, 0, 0, 0); B := QtDC.getClipping; @@ -2188,16 +2188,12 @@ var while CurCount > 0 do begin CharLen := UTF8CodepointSize(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); @@ -2218,9 +2214,9 @@ begin if ((Options and (ETO_OPAQUE + ETO_CLIPPED)) <> 0) and (Rect = nil) then begin if Count >= 0 then - WideStr := GetUtf8String(Copy(Str, 1, Count)) + WideStr := {%H-}Copy(Str, 1, Count) else - WideStr := GetUtf8String(Str); + WideStr := Str; R := QtDC.getClipRegion.getBoundingRect; QtDC.font.Metrics.boundingRect(@R1, @R, 0, @WideStr); @@ -2242,9 +2238,9 @@ begin if Options and ETO_RTLREADING <> 0 then QPainter_setLayoutDirection(QtDC.Widget, QtRightToLeft); if Count >= 0 then - WideStr := GetUtf8String(Copy(Str, 1, Count)) + WideStr := {%H-}Copy(Str, 1, Count) else - WideStr := GetUtf8String(Str); + WideStr := Str; if (Options and ETO_CLIPPED <> 0) then begin @@ -4217,7 +4213,7 @@ begin if Str = nil then AStr := '' else - AStr := GetUtf8String(Str); + AStr := Str; Size.cx := 0; Size.cY := Font.Metrics.Height; if (AStr = '') then @@ -4304,7 +4300,7 @@ begin Size.cy := 0; if (Count <= 0) or (Str = nil) or (StrPas(Str) = '') then exit; - WideStr := GetUtf8String(Str); + WideStr := {%H-}Str; {$warning fixme Qt6} Size.cx := QtDC.Metrics.width(@WideStr, Count); Size.cy := QtDC.Metrics.height; @@ -4552,6 +4548,7 @@ begin if (TQtWidget(Handle) is TQtMainWindow) and (not TQtMainWindow(Handle).IsMdiChild) then begin + ARect := Rect(0,0,0,0); GetClientRect(Handle, ARect); Width := ARect.Width; Height := ARect.Height; @@ -5228,8 +5225,8 @@ var {$ENDIF} 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 @@ -7250,9 +7247,9 @@ begin if not IsValidDC(DC) then Exit; if Count >= 0 then - WideStr := GetUtf8String(Copy(Str, 1, Count)) + WideStr := {%H-}Copy(Str, 1, Count) else - WideStr := GetUtf8String(Str); + WideStr := Str; TQtDeviceContext(DC).drawText(X, Y, @WideStr); diff --git a/lcl/interfaces/qt6/qtwscomctrls.pp b/lcl/interfaces/qt6/qtwscomctrls.pp index f1761b4e25..c5db8532d4 100644 --- a/lcl/interfaces/qt6/qtwscomctrls.pp +++ b/lcl/interfaces/qt6/qtwscomctrls.pp @@ -571,7 +571,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 @@ -580,7 +580,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; @@ -633,7 +633,7 @@ begin 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 @@ -643,7 +643,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]); @@ -663,14 +663,14 @@ 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; @@ -815,7 +815,7 @@ begin TWIChild := QTreeWidgetItem_create(Ord(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; @@ -990,7 +990,7 @@ begin TWI := QtTreeWidget.headerItem; if TWI <> NiL then begin - Str := GetUtf8String(ACaption); + Str := {%H-}ACaption; QTreeWidgetItem_setText(TWI, AIndex, @Str); end; end; @@ -1524,7 +1524,7 @@ begin QtTreeWidget := TQtTreeWidget(ALV.Handle); TWI := QTreeWidgetItem_create(Ord(QTreeWidgetItemType)); if AItem.Caption <> '' then - Str := GetUtf8String(AItem.Caption) + Str := AItem{%H-}.Caption else Str := ''; @@ -1552,7 +1552,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; @@ -1594,7 +1594,7 @@ begin end else begin QtTreeWidget := TQtTreeWidget(ALV.Handle); - Str := GetUtf8String(AText); + Str := {%H-}AText; TWI := QtTreeWidget.topLevelItem(AIndex); if TWI <> NiL then begin @@ -2075,7 +2075,7 @@ begin for i := 0 to AList.Items.Count - 1 do begin AItem := AList.Items[i]; - WStr := GetUTF8String(AItem.Caption); + WStr := AItem{%H-}.Caption; Item := QtTreeWidget.topLevelItem(i); QtTreeWidget.setItemText(Item, 0, WStr, AlignmentToQtAlignmentMap[AList.Column[0].Alignment]); QtTreeWidget.setItemData(Item, 0, AItem); @@ -2113,7 +2113,7 @@ 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]); + WStr := AItem{%H-}.Subitems.Strings[j]; QtTreeWidget.setItemText(Item, j + 1, WStr, AAlignment); QtTreeWidget.setItemData(Item, j + 1, AItem); end; diff --git a/lcl/interfaces/qt6/qtwscontrols.pp b/lcl/interfaces/qt6/qtwscontrols.pp index 875668c029..04ac2152dc 100644 --- a/lcl/interfaces/qt6/qtwscontrols.pp +++ b/lcl/interfaces/qt6/qtwscontrols.pp @@ -360,7 +360,7 @@ begin Exit; Wdgt := TQtWidget(AWinControl.Handle); Wdgt.BeginUpdate; - Wdgt.setText(GetUtf8String(AText)); + Wdgt.setText(AText{%H-}); Wdgt.EndUpdate; end; diff --git a/lcl/interfaces/qt6/qtwsdialogs.pp b/lcl/interfaces/qt6/qtwsdialogs.pp index 1e4ca681b3..aa5d82b3fc 100644 --- a/lcl/interfaces/qt6/qtwsdialogs.pp +++ b/lcl/interfaces/qt6/qtwsdialogs.pp @@ -284,10 +284,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; @@ -296,7 +296,7 @@ begin if (AFileDialog is TSaveDialog) and (trim(TmpFilter)='()') then Result := '' else - Result := GetUtf8String(TmpFilter); + Result := {%H-}TmpFilter; end; class procedure TQtWSFileDialog.UpdateProperties( @@ -308,7 +308,7 @@ var {$ENDIF} s: String; begin - ATitle := GetUtf8String(AFileDialog.Title); + ATitle := AFileDialog{%H-}.Title; QtFileDialog.setWindowTitle(@ATitle); {$ifndef QT_NATIVE_DIALOGS} @@ -359,7 +359,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} @@ -684,7 +684,7 @@ var AInitDir: WideString; s: String; begin - ATitle := GetUtf8String(AFileDialog.Title); + ATitle := AFileDialog{%H-}.Title; QtFileDialog.setWindowTitle(@ATitle); {$ifndef QT_NATIVE_DIALOGS} s := AFileDialog.InitialDir; @@ -700,7 +700,7 @@ begin 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 diff --git a/lcl/interfaces/qt6/qtwsextctrls.pp b/lcl/interfaces/qt6/qtwsextctrls.pp index 72c1011b6f..c21e77a806 100644 --- a/lcl/interfaces/qt6/qtwsextctrls.pp +++ b/lcl/interfaces/qt6/qtwsextctrls.pp @@ -209,7 +209,7 @@ 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; @@ -235,7 +235,7 @@ 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; diff --git a/lcl/interfaces/qt6/qtwsforms.pp b/lcl/interfaces/qt6/qtwsforms.pp index dc906b6759..e1af7e2fac 100644 --- a/lcl/interfaces/qt6/qtwsforms.pp +++ b/lcl/interfaces/qt6/qtwsforms.pp @@ -205,7 +205,7 @@ begin QtMainWindow.QtFormBorderStyle := Ord(AForm.BorderStyle); QtMainWindow.QtFormStyle := Ord(AForm.FormStyle); - Str := GetUtf8String(AWinControl.Caption); + Str := AWinControl{%H-}.Caption; QtMainWindow.SetWindowTitle(@Str); diff --git a/lcl/interfaces/qt6/qtwsmenus.pp b/lcl/interfaces/qt6/qtwsmenus.pp index 2a061d0692..ec54144d37 100644 --- a/lcl/interfaces/qt6/qtwsmenus.pp +++ b/lcl/interfaces/qt6/qtwsmenus.pp @@ -112,7 +112,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); {issue #37741} @@ -283,7 +283,7 @@ begin if ACaption = cLineCaption then TQtMenu(Widget).setText('') else - TQtMenu(Widget).setText(GetUtf8String(ACaption)); + TQtMenu(Widget).setText(ACaption{%H-}); end; end; diff --git a/lcl/interfaces/qt6/qtwsstdctrls.pp b/lcl/interfaces/qt6/qtwsstdctrls.pp index 3d0eae354a..439a715613 100644 --- a/lcl/interfaces/qt6/qtwsstdctrls.pp +++ b/lcl/interfaces/qt6/qtwsstdctrls.pp @@ -756,7 +756,7 @@ var 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; @@ -1390,7 +1390,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));